Commit 732c1fd7 authored by KeYong's avatar KeYong

Merge branch 'developer' of 172.16.10.76:moa/amos-boot-biz into develop

parents 55603ab5 27769726
package com.yeejoin.amos.maintenance.common.enums;
import lombok.Data;
import java.util.Arrays;
import java.util.Optional;
/**
* @author DELL
*/
public enum PlanTypeEnum {
/**
* 计划类型枚举
*/
PLAN_TYPE_DAY("1","日计划"),
PLAN_TYPE_WEEK("2","周计划"),
PLAN_TYPE_MONTH("3","月计划"),
PLAN_TYPE_YEAR("4","年计划");
/**
* 名称
*/
private String name;
/**
* code
*/
private String code;
PlanTypeEnum(String code, String name){
this.code = code;
this.name = name;
}
public String getName() {
return name;
}
public static PlanTypeEnum getEnumByCode(String code) {
Optional<PlanTypeEnum> op = Arrays.stream(PlanTypeEnum.values()).filter(e->e.code.equals(code)).findFirst();
return op.orElse(null);
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
......@@ -224,6 +224,11 @@ public class Check extends BasicEntity {
private String ownerId;
/**
* 业主单位名称
*/
private String ownerName;
/**
* 维保公司id
*/
private String companyId;
......@@ -288,6 +293,13 @@ public class Check extends BasicEntity {
this.companyName = companyName;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public String getOwnerId() {
return ownerId;
......
......@@ -140,4 +140,7 @@ public class AlertCalledDto extends BaseDto {
@ApiModelProperty(value = "结案说明")
private String finalReason;
@ApiModelProperty(value = "是否辅屏查询")
private String isAuxiliaryScreen;
}
......@@ -217,4 +217,8 @@ public class AlertCalled extends BaseEntity {
@ApiModelProperty(value = "响应级别")
private String responseLevel;
@TableField(exist=false)
@ApiModelProperty(value = "是否辅屏查询")
private String isAuxiliaryScreen;
}
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -39,6 +21,22 @@ import com.yeejoin.amos.boot.module.common.api.entity.LinkageUnit;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import com.yeejoin.amos.boot.module.common.api.mapper.LinkageUnitMapper;
import com.yeejoin.amos.boot.module.common.api.service.ILinkageUnitService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 联动单位服务实现类
......@@ -90,7 +88,7 @@ public class LinkageUnitServiceImpl extends BaseService<LinkageUnitDto, LinkageU
}
});
});
List<LinkageUnitDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(linkageUnitList.getRecords()),
List<LinkageUnitDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(linkageUnitListMap),
LinkageUnitDto.class);
List<LinkageUnitDto> detaiList = resultDtoList.stream().map(item -> {
Date now = new Date();
......
......@@ -209,7 +209,6 @@ public class PointController extends AbstractBaseController {
Page<PointDto> pointList = iPointService.queryPointInfoWithItem(criterias, commonPageable, ownerId);
return CommonResponseUtil.success(pointList);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检点信息失败");
}
......
package com.yeejoin.amos.maintenance.business.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yeejoin.amos.maintenance.core.framework.PersonIdentify;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.maintenance.business.param.RoutePageParam;
import com.yeejoin.amos.maintenance.business.service.intfc.IRouteService;
......@@ -35,14 +9,23 @@ import com.yeejoin.amos.maintenance.business.util.RoutePageParamUtil;
import com.yeejoin.amos.maintenance.core.common.request.CommonPageable;
import com.yeejoin.amos.maintenance.core.common.request.CommonRequest;
import com.yeejoin.amos.maintenance.core.common.request.RoutePointInputItemRequest;
import com.yeejoin.amos.maintenance.core.framework.PersonIdentify;
import com.yeejoin.amos.maintenance.dao.entity.InputItem;
import com.yeejoin.amos.maintenance.dao.entity.Plan;
import com.yeejoin.amos.maintenance.dao.entity.Route;
import com.yeejoin.amos.maintenance.dao.entity.RoutePoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/api/route")
......@@ -122,39 +105,8 @@ public class RouteController extends AbstractBaseController {
@ApiOperation(value = "删除巡检路线", notes = "删除巡检路线")
@DeleteMapping(value = "/deleteRoute", produces = "application/json;charset=UTF-8")
public CommonResponse deleteRoute(@ApiParam(value = "巡检路线ID", required = false) @RequestParam List<Long> routeIds) {
try {
//校验1:线路上有点时返回删除失败
Map<Long, String> idNameMap = new HashMap<>();
for (long id : routeIds) {
int routePointCount = routeService.countRoutePoint(id);
if (routePointCount > 0) {
Route route = routeService.queryRouteById(id);
idNameMap.put(id, route.getName());
}
}
if (idNameMap.size() > 0) {
return CommonResponseUtil.failure(idNameMap, "删除路线失败:路线上已设置巡检点");
}
//校验2:计划在使用,删除失败
idNameMap.clear();
for (long id : routeIds) {
int routePointCount = routeService.countRoutePoint(id);
if (routePointCount > 0) {
List<Plan> planList = routeService.queryPlanByRouteId(id);
if (planList != null && planList.size() > 0) {
idNameMap.put(id, planList.get(0).getName());
}
}
}
if (idNameMap.size() > 0) {
return CommonResponseUtil.failure(idNameMap, "删除路线失败:计划在使用");
}
routeService.delRouteById(routeIds.toArray(new Long[0]));
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("删除巡检路线失败");
}
routeService.delRouteById(routeIds.toArray(new Long[0]));
return CommonResponseUtil.success();
}
/**
......
......@@ -47,6 +47,11 @@ public class PlanTaskPointInputItemBo {
private String ownerId;
/**
* 业主单位名称
*/
private String ownerName;
/**
* 单位id
*/
private String companyId;
......
......@@ -33,10 +33,7 @@ import com.yeejoin.amos.maintenance.business.util.DaoCriteria;
import com.yeejoin.amos.maintenance.business.util.ToolUtils;
import com.yeejoin.amos.maintenance.business.vo.CheckAnalysisVo;
import com.yeejoin.amos.maintenance.business.vo.CheckInfoVo;
import com.yeejoin.amos.maintenance.common.enums.CheckStatusEnum;
import com.yeejoin.amos.maintenance.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.maintenance.common.enums.PointLevelEnum;
import com.yeejoin.amos.maintenance.common.enums.PointStatusEnum;
import com.yeejoin.amos.maintenance.common.enums.*;
import com.yeejoin.amos.maintenance.core.common.request.CommonPageable;
import com.yeejoin.amos.maintenance.core.common.response.*;
import com.yeejoin.amos.maintenance.core.enums.QueryOperatorEnum;
......@@ -115,6 +112,9 @@ public class CheckServiceImpl implements ICheckService {
@Value("${file.url}")
private String fileUrl;
@Autowired
IRouteDao iRouteDao;
final String CHECK_UPDATE_TOPIC = "maintenance/date/update";
......@@ -141,6 +141,7 @@ public class CheckServiceImpl implements ICheckService {
//1.前置校验
this.checkCanFinishTask(mtUserSeq, planTask, recordParam.getPointId());
Point point = iPointService.queryPointById(recordParam.getPointId());
Route route = iRouteDao.findById(planTask.getRouteId()).orElseThrow(() -> new RuntimeException("路线不存在"));
Check check = new Check();
if (ObjectUtils.isEmpty(point) || ObjectUtils.isEmpty(detail)) {
throw new Exception("前置校验不通过");
......@@ -164,7 +165,8 @@ public class CheckServiceImpl implements ICheckService {
check.setUploadTime(new Date());
check.setOrgCode(recordParam.getOrgCode());
check.setUserId(mtUserSeq);
check.setOwnerId(point.getOwnerId());
check.setOwnerId(route.getOwnerId());
check.setOwnerName(route.getOwnerName());
check.setBuildingName(point.getBuildingName());
check.setEquipmentName(point.getEquipmentName());
check.setPlanType(detail.get("planType").toString());
......@@ -1125,6 +1127,10 @@ public class CheckServiceImpl implements ICheckService {
if (facility.containsKey("isOk")) {
facility.put("isOkDesc", CheckStatusEnum.getEnum(String.valueOf(facility.get("isOk"))).getName());
}
if (facility.containsKey("planType")) {
PlanTypeEnum planType = PlanTypeEnum.getEnumByCode(String.valueOf(facility.get("planType")));
facility.put("planTypeDesc", planType != null ? planType.getName() : "其他");
}
return facility;
}
......
......@@ -76,30 +76,37 @@ public class RouteServiceImpl implements IRouteService {
@Override
@Transactional
public Route addRoute(Route route) {
public Route addRoute(Route route) {
String creatorId = route.getCreatorId();
String orgCode = route.getOrgCode();
//1.保存主表
route = iRouteDao.saveAndFlush(route);
Long rId = route.getId();
List<RoutePoint> routePoints = route.getRoutePointList();
//2.保存子表
routePoints.forEach(rp -> {
rp.setOrgCode(orgCode);
rp.setRouteId(rId);
rp.setCreatorId(creatorId);
List<RoutePointItem> routePointItems = rp.getRoutePointItem();
//2.1保存点路线关系表
rp = iRoutePointDao.saveAndFlush(rp);
Long rpId = rp.getId();
routePointItems = routePointItems.stream().filter(RoutePointItem::getIsBound).collect(Collectors.toList());
routePointItems.forEach(rpi -> {
rpi.setRoutePointId(rpId);
rpi.setCreatorId(creatorId);
iRoutePointItemDao.saveAndFlush(rpi);
});
//2.2保存点项关系表
if (!routePointItems.isEmpty()) {
iRoutePointItemDao.saveAll(routePointItems);
}
});
return route;
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void delRouteById(Long[] ids) {
//0.删除路线
iRouteDao.delRouteById(Arrays.asList(ids));
......@@ -126,7 +133,7 @@ public class RouteServiceImpl implements IRouteService {
iRoutePointItemDao.delRoutePointItem(rp.getId());
iRoutePointDao.deleteById(rp.getId());
//删除p_plan_task_detail 对应点、更新p_plan_task点数量、完成数量
this.updatePlanTask(rp.getPointId(),finalRoute.getId());
this.updatePlanTask(rp.getPointId(), finalRoute.getId());
} else {
List<RoutePointItem> routePointItems = rp.getRoutePointItem();
iRoutePointDao.saveAndFlush(rp);
......@@ -156,9 +163,15 @@ public class RouteServiceImpl implements IRouteService {
}
private void updatePlanTask(long pointId, long routeId) {
//1.查询指定路线的任务
List<PlanTask> planTaskList = planTaskDao.findByRouteId(routeId);
Map<Long, PlanTask> planTaskMap = planTaskList.stream().collect(Collectors.toMap(BasicEntity::getId, Function.identity()));
//2.查询指定的点
List<PlanTaskDetail> planTaskDetailList = iPlanTaskDetailDao.findByPointId(pointId);
Map<Long,PlanTask> planTaskMap = planTaskList.stream().collect(Collectors.toMap(BasicEntity::getId, Function.identity()));
//3.过滤指定父任务id的执行数据
planTaskDetailList = planTaskDetailList.stream().filter(e ->
planTaskList.stream().map(BasicEntity::getId).collect(Collectors.toList()).contains(e.getTaskNo())).collect(Collectors.toList());
//4.更新任务主表点的数量及完成数量
for (PlanTaskDetail planTaskDetail : planTaskDetailList) {
PlanTask planTask = planTaskMap.get(planTaskDetail.getTaskNo());
if (1 == planTaskDetail.getIsFinish()) {
......@@ -168,9 +181,9 @@ public class RouteServiceImpl implements IRouteService {
planTask.setPointNum(planTask.getPointNum() - 1);
}
}
//更新主表完成数量,点数量
//5.更新主表完成数量,点数量
planTaskDao.saveAll(planTaskList);
//删除路线下的维保点
//6.删除路线下的维保点
planTaskDetailMapper.deleteByPointIdAndRouteId(pointId, routeId);
}
......
......@@ -212,6 +212,7 @@ public class JobService implements IJobService {
check.setRouteName(arg.getRouteName());
check.setCheckTime(arg.getEndTime());
check.setOwnerId(arg.getOwnerId());
check.setOwnerName(arg.getOwnerName());
check.setCompanyId(arg.getCompanyId());
check.setCompanyName(arg.getCompanyName());
check.setEquipmentName(arg.getEquipmentName());
......@@ -323,8 +324,7 @@ public class JobService implements IJobService {
updatePlanTaskStatus(planTask, PlanTaskFinishStatusEnum.OVERTIME.getValue());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
log.error("任务加到定时任务或者更新失败", e);
}
}
......
......@@ -270,9 +270,11 @@ public class AlertCalledController extends BaseController {
queryWrapper.orderByDesc("call_time");
if(null != alertCalled.getCallTimeStart() && null != alertCalled.getCallTimeEnd()) {
queryWrapper.between("call_time", alertCalled.getCallTimeStart(),
alertCalled.getCallTimeEnd().getTime());
if(!ValidationUtil.isEmpty(alertCalled.getIsAuxiliaryScreen())) {
if(!ValidationUtil.isEmpty(alertCalled.getCallTimeStart()) && !ValidationUtil.isEmpty(alertCalled.getCallTimeEnd())) {
queryWrapper.between("call_time", alertCalled.getCallTimeStart(),
alertCalled.getCallTimeEnd().getTime());
}
} else {
queryWrapper.between("call_time", DateUtils.stampToDate(System.currentTimeMillis(),DateUtils.DATE_PATTERN),
DateUtils.stampToDate(DateUtils.dateAddDays(new Date(),1).getTime(),DateUtils.DATE_PATTERN));
......@@ -282,15 +284,15 @@ public class AlertCalledController extends BaseController {
queryWrapper.isNull("father_alert");
}
if(ValidationUtil.isEmpty(alertCalled.getType())) {
if(!ValidationUtil.isEmpty(alertCalled.getType())) {
queryWrapper.eq("type",alertCalled.getType());
}
if(ValidationUtil.isEmpty(alertCalled.getAlarmType())) {
if(!ValidationUtil.isEmpty(alertCalled.getAlarmType())) {
queryWrapper.eq("alarm_type",alertCalled.getAlarmType());
}
if(ValidationUtil.isEmpty(alertCalled.getAlertSource())) {
if(!ValidationUtil.isEmpty(alertCalled.getAlertSource())) {
queryWrapper.eq("alert_source",alertCalled.getAlertSource());
}
return queryWrapper;
......
......@@ -223,4 +223,15 @@
ALTER TABLE p_check add COLUMN `end_time` datetime DEFAULT NULL COMMENT '结束时间' after `begin_time`;
</sql>
</changeSet>
<changeSet author="suhuiguang" id="1630291249911-4">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="p_check" columnName="owner_name"/>
</not>
</preConditions>
<comment>p_check add COLUMN owner_name '业主单位名称'</comment>
<sql>
ALTER TABLE p_check add COLUMN `owner_name` varchar(255) DEFAULT NULL COMMENT '业主单位名称' after `owner_id`;
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -2033,9 +2033,18 @@
pc.plan_name as planName,
pc.plan_type as planType,
pc.owner_name as ownerName,
pc.begin_time as beginTime,
pc.end_time as endTime,
pc.check_time as checkTime,
date_format(
pc.begin_time,
'%Y-%m-%d %H:%i:%s'
) as beginTime,
date_format(
pc.end_time,
'%Y-%m-%d %H:%i:%s'
) as endTime,
date_format(
pc.check_time,
'%Y-%m-%d %H:%i:%s'
) as checkTime,
pc.risk_and_manage as riskAndManage,
pc.remark
FROM p_check pc
......
......@@ -393,6 +393,7 @@
temp1.buildingName,
temp1.equipmentName,
temp1.remark as riskAndManage,
temp1.ownerName,
pii.`name` inputName,
temp2.*
FROM
......@@ -411,6 +412,7 @@
r.name as routeName,
p.name as pointName,
p.owner_id as ownerId,
p.owner_name as ownerName,
p.point_no as pointNo,
p.building_name as buildingName,
p.equipment_name as equipmentName,
......@@ -432,7 +434,7 @@
ptd.plan_id planId,
ptd.user_id AS userId,
ptd.org_code AS orgCode,
ptd.end_time AS endTime,
ptd.begin_time AS beginTime,
ptd.end_time AS endTime,
ptd.company_id as companyId,
ptd.company_name as companyName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment