diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/dto/ImsDutyRecDTO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/dto/ImsDutyRecDTO.java index 2d96f73..2f1cdcb 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/dto/ImsDutyRecDTO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/dto/ImsDutyRecDTO.java @@ -1,9 +1,13 @@ package com.hnac.hzims.operational.duty.dto; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; +import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotNull; + /** * 模型DTO * @@ -15,4 +19,25 @@ public class ImsDutyRecDTO extends ImsDutyRecEntity { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "巡检路线数据") + @NotNull + private String routeData; + + @ApiModelProperty(value = "巡检路线ID字段") + @NotNull + private Long routeId; + + @ApiModelProperty(value = "路线名称") + @NotNull + private String routeName; + + @ApiModelProperty(value = "交班对象值班信息") + private ImsSchedulingVo headDutyMainVo; + + /** + * 接班对象值班信息 + */ + @ApiModelProperty(value = "接班对象值班信息") + private ImsSchedulingVo carryDutyMainVo; + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java index 3387fa1..7fd2b1c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java @@ -98,4 +98,9 @@ public class ImsDutyRecEntity extends TenantEntity { @ApiModelProperty(value = "延时状态 0 、未延时 1、延时") private Integer delayStatus; + @ApiModelProperty(value = "当前处理环节") + @QueryField(condition = SqlCondition.LIKE) + private String dealChain; + + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClient.java index d03bcba..8c99607 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClient.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.duty.feign; +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody; public interface IDutyRecClient { String API_PREFIX = "/ims_duty_rec"; String GET_CHANGE_SHIFTS = API_PREFIX + "/getChangeShifts"; + String DEAL_DUTY_REC_FLOW = API_PREFIX + "/dealDutyRecFlow"; /** @@ -25,4 +27,12 @@ public interface IDutyRecClient { */ @PostMapping(GET_CHANGE_SHIFTS) R getChangeShifts(@RequestBody ChangeShiftsReqDTO reqDTO); + + /** + * 处理交接班流程 + * @param processWorkFlowResponse redis消息中心订阅返回消息 + * @return 处理结果flag + */ + @PostMapping(DEAL_DUTY_REC_FLOW) + R dealDutyRecFlow(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClientFalllback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClientFalllback.java index 4a4ea76..9ba5e82 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClientFalllback.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClientFalllback.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.duty.feign; +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import org.springblade.core.tool.api.R; @@ -17,4 +18,9 @@ public class IDutyRecClientFalllback implements IDutyRecClient { response.setShiftsRate(0.0); return R.data(response); } + + @Override + public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) { + return R.fail("交接班处理流程失败"); + } } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/dto/ProjectDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/dto/ProjectDTO.java index fc91215..c827cf8 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/dto/ProjectDTO.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/dto/ProjectDTO.java @@ -24,4 +24,7 @@ public class ProjectDTO extends ProjectEntity implements Serializable { @ApiModelProperty("巡检内容DTO对象") private List contentDTOList; + @ApiModelProperty("是否为新模式 是否为从设备导入的项目") + private Boolean isNewModel; + } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/TemplateEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/TemplateEntity.java index 3803f95..cf0f4a1 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/TemplateEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/TemplateEntity.java @@ -58,4 +58,7 @@ public class TemplateEntity extends TenantEntity { */ @ApiModelProperty(value = "inspectType 支持的巡检类型 0普通巡检,1视频自动巡检,2机器人巡检") private String supportAutoVideo; + + + //private Boolean ; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java index 8a7e53b..7c55b54 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java @@ -243,6 +243,10 @@ public class ObjectServiceImpl extends BaseServiceImpllambdaQuery().eq(ObjectTemplateEntity::getObjectId,object.getId())); + } TemplateEntity template = new TemplateEntity(); template.setCode(String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond())); template.setName(object.getName()); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java index be62bfc..cedc7c7 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java @@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; +import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity; import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity; @@ -18,6 +20,7 @@ import com.hnac.hzinfo.inspect.obj.services.impl.ProjectContentServiceImpl; import com.hnac.hzinfo.inspect.obj.utils.CodeUtils; import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO; import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; +import com.hnac.hzinfo.inspect.obj.wrapper.ProjectWrapper; import com.hnac.hzinfo.inspect.utils.Condition; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -78,6 +81,17 @@ public class ProjectController { return R.data(pages); } + @GetMapping("/selectProject") + @ApiOperation(value = "巡检项目列表-下拉框", notes = "巡检项目列表-下拉框") + @ApiOperationSupport(order = 2) + public R> selectProject(ProjectDTO project) { + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new ProjectEntity(),project); + queryWrapper.isNotNull(project.getIsNewModel(),ProjectEntity::getEmCode); + queryWrapper.ne(project.getIsNewModel(),ProjectEntity::getEmCode,""); + List projectList = projectService.list(queryWrapper); + return R.data(ProjectWrapper.build().listVO(projectList)); + } + /** * 查询单条 */ diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectProjectContentService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectProjectContentService.java index dbe831c..12008f7 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectProjectContentService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectProjectContentService.java @@ -1,5 +1,6 @@ package com.hnac.hzinfo.inspect.task.service; +import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO; import org.springblade.core.mp.base.BaseService; import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; @@ -14,4 +15,6 @@ public interface ITaskObjectProjectContentService extends BaseService getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc); + void fillRealData(TaskObjectProjectContentVO contentVO); + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java index 15a433f..5d2d9ce 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java @@ -1,12 +1,31 @@ package com.hnac.hzinfo.inspect.task.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; +import com.hnac.hzinfo.inspect.obj.services.ContentService; +import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO; +import com.hnac.hzinfo.sdk.v5.redis.RedisClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectProjectContentMapper; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.List; +import java.util.Optional; /** * 服务实现类 @@ -14,9 +33,40 @@ import java.util.List; * @author Chill */ @Service +@AllArgsConstructor +@Slf4j public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl implements ITaskObjectProjectContentService { + + private final ContentService contentService; + private final IStationClient stationClient; + private final RedisClient redisClient; + @Override public List getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc) { return this.baseMapper.getTaskObjectProjectContents(topc); } + + @Override + public void fillRealData(TaskObjectProjectContentVO contentVO) { + if(Func.isNotEmpty(contentVO.getContentId())) { + ContentEntity content = contentService.getById(contentVO.getContentId()); + if(ObjectUtil.isNotEmpty(content) && Func.isNotEmpty(content.getFacDeviceId())) { + // 获取该项内容站点信息 + StationEntity station = new StationEntity(); + station.setRefDept(content.getCreateDept()); + R stationR = stationClient.getOne(station); + if(stationR.isSuccess() && ObjectUtil.isNotEmpty(stationR.getData())) { + // 获取任务巡检内容实时数据 + List realDate = redisClient.getBatchRealDataByRealId(stationR.getData().getCode(), Lists.newArrayList(content.getFacDeviceId())); + log.info("station:{},facDeviceId:{},实时数据:{}",stationR.getData().getCode(),content.getFacDeviceId(), JSON.toJSONString(realDate)); + JSONObject realDataObject = Optional.ofNullable(realDate).map(list -> list.get(0)).filter(StringUtil::isNotBlank).map(JSONObject::parseObject).orElse(null); + // q值为0时为有效值 + if(ObjectUtil.isNotEmpty(realDataObject) && realDataObject.getIntValue("q") == 0) { + contentVO.setRealData(realDataObject.getDoubleValue("v")); + contentVO.setGatherTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(realDataObject.getLongValue("ts")), ZoneId.systemDefault())); + } + } + } + } + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java index 5fbcde7..4f988b5 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java @@ -2,10 +2,15 @@ package com.hnac.hzinfo.inspect.task.service.impl; import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectMapper; +import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectService; import com.hnac.hzinfo.inspect.task.vo.TaskObjectOfflineVO; +import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO; import com.hnac.hzinfo.inspect.task.vo.TaskObjectVO; +import lombok.AllArgsConstructor; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; import org.springframework.stereotype.Service; import java.util.List; @@ -16,8 +21,11 @@ import java.util.List; * @author Chill */ @Service +@AllArgsConstructor public class TaskObjectServiceImpl extends BaseServiceImpl implements ITaskObjectService { + private final ITaskObjectProjectContentService taskContentService; + @Override public List getTaskObjectList(TaskObjectEntity taskObjectEntity) { return this.baseMapper.getTaskObjects(taskObjectEntity); @@ -25,7 +33,16 @@ public class TaskObjectServiceImpl extends BaseServiceImpl getTaskObjectsDetail(TaskObjectEntity to){ - return this.baseMapper.getTaskObjectsDetail(to); + List taskObjectVOList = this.baseMapper.getTaskObjectsDetail(to); + if(CollectionUtil.isNotEmpty(taskObjectVOList)) { + taskObjectVOList.stream() + .filter(taskObjectVO -> CollectionUtil.isNotEmpty(taskObjectVO.getProjects())) + .flatMap(taskObjectVO -> taskObjectVO.getProjects().stream()) + .filter(project -> CollectionUtil.isNotEmpty(project.getContents())) + .flatMap(project -> project.getContents().stream()) + .forEach(contentVO -> taskContentService.fillRealData(contentVO)); + } + return taskObjectVOList; } @Override diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java index 5f2fc41..46d5259 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java @@ -1,12 +1,16 @@ package com.hnac.hzinfo.inspect.task.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.time.LocalDateTime; /** * 任务对象项目内容 @@ -116,4 +120,11 @@ public class TaskObjectProjectContentVO implements Serializable { @ApiModelProperty(value = "记值方式为选择时选择值") private String dictType; + @ApiModelProperty(value = "实时数据") + private Double realData; + + @ApiModelProperty(value = "实时数据采集时间") + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + private LocalDateTime gatherTime; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java index 86e6f1b..c9d10d5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java @@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.entity.AnalyseExample; import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; @@ -99,6 +100,7 @@ public class ImsDutyRecController extends BladeController { @ApiOperation(value = "新增或修改,然后提交,开始工作流程", notes = "传入imsDutyRec") public R submit(@Valid @RequestBody ImsDutyRecEntity imsDutyRec,@RequestBody PlanVO vo) { return imsDutyRecService.submit(imsDutyRec,vo); + //return R.status(imsDutyRecService.submitV2(imsDutyRec,vo)); } /** @@ -326,6 +328,13 @@ public class ImsDutyRecController extends BladeController { return iImsAnalyseExampleService.updateAnalyseExample(analyseExample); } + @PostMapping("/changeShift") + @ApiOperationSupport(order = 21) + @ApiOperation(value = "交班", notes = "传入imsDutyRecDTO交接班信息") + public R changeShift(@Valid @RequestBody ImsDutyRecDTO imsDutyRecDTO) { + return R.status(imsDutyRecService.changeShift(imsDutyRecDTO)); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java index a838169..a682f6f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java @@ -1,21 +1,44 @@ package com.hnac.hzims.operational.duty.feign; +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; +import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.service.IImsDutyRecService; +import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RestController; @RestController +@AllArgsConstructor public class DutyRecClient implements IDutyRecClient { - @Autowired - private IImsDutyRecService service; + private final IImsDutyRecService service; + private final BladeLogger logger; @Override public R getChangeShifts(ChangeShiftsReqDTO reqDTO) { return R.data(service.getChangeShifts(reqDTO)); } + + @Override + public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) { + logger.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse)); + ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class); + Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> { + throw new RuntimeException("未接收到交接班信息!"); + }); + recDTO.setDealChain(processWorkFlowResponse.getTaskName()); + return R.status(service.dealDutyRecFlow(recDTO)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java index cde2617..35c4d6e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.duty.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; +import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; @@ -24,6 +25,12 @@ public interface IImsDutyRecService extends BaseService { R submit(ImsDutyRecEntity imsDutyRecEntity, PlanVO vo); + /** + * 开启交接班 + * @param recDTO 交接班信息 + * @return 交接班成功与否flag + */ + Boolean changeShift(ImsDutyRecDTO recDTO); /** * 执行工作流 @@ -117,8 +124,15 @@ public interface IImsDutyRecService extends BaseService { /** * 交接班统计 - * @param reqDTO + * @param reqDTO 交接班信息 * @return */ ChangeShiftsRspDTO getChangeShifts(ChangeShiftsReqDTO reqDTO); + + /** + * 执行工作流-处理业务数据 + * @param recDTO 交接班信息 + * @return + */ + Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 13be917..6d31008 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -1,10 +1,13 @@ package com.hnac.hzims.operational.duty.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.fegin.IMessageClient; @@ -17,6 +20,7 @@ import com.hnac.hzims.operational.duty.constant.DutyProcessConstant; import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; +import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.entity.*; import com.hnac.hzims.operational.duty.enume.DutyMainStatus; import com.hnac.hzims.operational.duty.enume.DutyRecStatus; @@ -30,6 +34,7 @@ import com.hnac.hzims.operational.duty.vo.ImsRecVo; import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; import com.hnac.hzims.operational.duty.wrapper.ImsDutyRecWrapper; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzinfo.inspect.plan.PlanContants; import com.hnac.hzinfo.inspect.plan.feign.IInspectPlanClient; import com.hnac.hzinfo.inspect.plan.vo.PlanVO; import lombok.extern.slf4j.Slf4j; @@ -49,13 +54,16 @@ import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import java.math.BigDecimal; +import java.sql.Time; import java.text.SimpleDateFormat; -import java.time.LocalDate; +import java.time.*; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @@ -187,6 +195,104 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl { + throw new ServiceException("获取值班班组长失败!"); + }); + // 新建巡检计划并获取巡检任务Id + PlanVO planVO = new PlanVO(); + planVO.setRouteId(recDTO.getRouteId()); + planVO.setRouteData(recDTO.getRouteData()); + planVO.setRouteName(recDTO.getRouteName()); + planVO.setPlanUsers(Lists.newArrayList(managerId)); + Long inspectTaskId = this.createInspectPlan(planVO); + ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class); + recEntity.setInspectTaskId(inspectTaskId); + // 返回流程id写入业务表 + recDTO.setExecTime(new Date()); + recDTO.setStatus(DutyRecStatus.EXEC.getVal()); + // 开启值班交接班流程 + BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); + recDTO.setProcessInstanceId(bladeFlow.getProcessInstanceId()); + return updateById(recEntity); + } + + /** + * 根据值班ID获取值班负责人Id + * @param dutyId 值班ID + * @return 值班负责人ID + */ + private Long getHandleGroupManagerByDuty(Long dutyId) { + ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId); + // 判断是否已交班 + List dutyRecs = this.list(Wrappers.lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId)); + Assert.isTrue(CollectionUtil.isNotEmpty(dutyRecs),() -> { + throw new ServiceException("您已交班,请勿重复交班!"); + }); + //根据上一班值班id查询值班信息 + ImsDutyMainEntity preDutyMain = imsDutyMainMapper.selectOne(Wrappers.lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId)); + Assert.isTrue(ObjectUtil.isEmpty(preDutyMain),() -> { + throw new ServiceException("当前时间没有接班人!"); + }); + //获取接班人班组组长 + Long managerId; + if (Func.isNotEmpty(dutyMain.getDutyGroupId())) { + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyMain.getDutyGroupId()); + ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); + eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); + }}); + Assert.isTrue(ObjectUtil.isEmpty(groupPEntity), () -> { + throw new ServiceException("接班班组长不存在,请指定班组长后进行交班!"); + }); + managerId = groupEntity.getManagerId(); + } else { + managerId = Optional.ofNullable(imsDutyMainPersonService.selectByMainId(dutyMain.getId())).filter(CollectionUtil::isNotEmpty) + .map(list -> list.get(0)).map(ImsDutyMainPersonEntity::getDutyChargePerson).orElse(null); + } + R manager = userClient.userInfoById(managerId); + Assert.isTrue(manager.isSuccess() && ObjectUtil.isNotEmpty(manager.getData()),() -> { + throw new ServiceException("获取接班组长失败,值班组长ID为:" + Optional.ofNullable(managerId).map(String::valueOf).orElse("")); + }); + return managerId; + } + + /** + * 开启值班交接班流程 + * @param recEntity 交接班信息 + * @return 工作流执行结果 + */ + private BladeFlow startDutyRecProcess(ImsDutyRecEntity recEntity ,Long managerId) { + ImsDutyRecDTO recDTO = BeanUtil.copy(recEntity,ImsDutyRecDTO.class); + ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getId()); + recDTO.setHeadDutyMainVo(currentDuty); + List carryDuties = imsDutyMainService.list(Wrappers.lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getId())); + Assert.isTrue(carryDuties.size() <= 1,() -> { + throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size()); + }); + recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId())); + Map variable = BeanUtil.toMap(recDTO); + variable.put("taskId", recEntity.getId()); + variable.put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString())); + + R flowResult = flowClient.startProcessInstanceByKey( + DutyRecProcessConstant.DUTY_REC_FLOW_KEY, + StringUtil.format("{}:{}", DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, recEntity.getId()), + variable + ); + Assert.isTrue(flowResult.isSuccess(),() -> { + throw new ServiceException(flowResult.getMsg()); + }); + return flowResult.getData(); + } private void updateMain(Long dutyId) { ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); @@ -1114,41 +1220,46 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl> listMap = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("execStartTime", execStartTime); - map.put("execEndTime", execEndTime); - listMap.add(map); - vo.setExecTimeJson(JSONObject.toJSONString(listMap)); - List list = new ArrayList<>(); - list.add(princId); - vo.setPlanType("common"); - vo.setPlanUsers(list); - R> listR = inspectPlanClient.addPlanAndChecked(vo); - List data = listR.getData(); - if (CollectionUtil.isNotEmpty(data)) { - return data.get(0); - } - return null; + + // 设置巡检计划计划开始结束时间 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.minusMinutes(5); + LocalDateTime endTime = now.plusHours(2); + vo.setStartTime(startTime.toLocalDate()); + vo.setEndTime(endTime.toLocalDate()); + Map execTime = new HashMap(2){{ + put("execStartTime",startTime.toLocalTime()); + put("execEndTime", startTime.toLocalTime()); + }}; + List> execTimeList = Lists.newArrayList(execTime); + vo.setExecTimeJson(JSONObject.toJSONString(execTimeList)); + R> createPlanResult = inspectPlanClient.addPlanAndChecked(vo); + Assert.isTrue(createPlanResult.isSuccess(),() -> { + throw new ServiceException(createPlanResult.getMsg()); + }); + return Optional.ofNullable(createPlanResult.getData()).map(list -> list.get(0)).orElse(null); + } + + //新增巡检计划 获取巡检任务ID + public Long getInspectTaskId(PlanVO vo, Long princId) { + vo.setPlanUsers(Lists.newArrayList(princId)); + return this.createInspectPlan(vo); } @@ -1244,5 +1355,83 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl { + throw new RuntimeException("更新交班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); + }); + // 更新接班值班 + Assert.isTrue(imsDutyMainService.updateById(carryDutyMain),() -> { + throw new RuntimeException("更新接班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); + }); + // 更新交接班 + Assert.isTrue(this.updateById(dutyRec),() -> { + throw new RuntimeException("更新交接班失败,更新对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); + }); + return true; + } + /** + * 计算交接班状态 + * @param duty 值班信息 + * @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类 + * @return 延时状态 + */ + private Integer getChangeShiftStatus(ImsDutyMainEntity duty, Integer recDelayStatus, int type) { + Long duration = this.changeShiftDuration(duty, type); + if (duration > 30) { + if (recDelayStatus == DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()) { + // 赋值延时状态 为3 交接班延时 + return DutyContants.DutyRecDelayStatusEnum.REC_DELAY_STATUS.getStatus(); + } else { + // 赋值延时状态 为2 接班延时 + return DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus(); + } + } + return recDelayStatus; + } + + /** + * 交接班时间差 + * @param duty 值班信息 + * @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类 + * @return 延时时长 + */ + private Long changeShiftDuration(ImsDutyMainEntity duty, int type) { + LocalDateTime now = LocalDateTime.now(); + // 获取当前值班班次 + ImsDutyClassEntity dutyClass = imsDutyClassService.getById(duty.getId()); + Assert.isTrue(ObjectUtil.isNotEmpty(dutyClass),()-> { + throw new RuntimeException("接班获取班次失败!"); + }); + Instant dutyDateInstant = duty.getDutyDate().toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + Time startTime = dutyClass.getStartTime(); + Time endTime = dutyClass.getEndTime(); + // 拼接开始、结束时间 + LocalDateTime startDateTime = LocalDateTime.of(dutyDateInstant.atZone(zoneId).toLocalDate(),LocalTime.of(startTime.getHours(),startTime.getMinutes(),startTime.getSeconds())); + LocalDateTime endDateTime = LocalDateTime.of(dutyDateInstant.atZone(zoneId).toLocalDate(),LocalTime.of(endTime.getHours(),endTime.getMinutes(),endTime.getSeconds())); + if(endDateTime.isBefore(startDateTime)) { + endDateTime = endDateTime.plusDays(1); + } + // 交班延时判断 + if(type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { + return Duration.between(now,endDateTime).toMinutes(); + } + // 接班延时判断 + else if(type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { + return Duration.between(now,startDateTime).toMinutes(); + } + return null; + } } diff --git a/hzims-service/operational/src/main/resources/db/1.0.1.sql b/hzims-service/operational/src/main/resources/db/1.0.1.sql index 3ea5926..e8abe20 100644 --- a/hzims-service/operational/src/main/resources/db/1.0.1.sql +++ b/hzims-service/operational/src/main/resources/db/1.0.1.sql @@ -30,3 +30,5 @@ INSERT INTO `hzims_station_push_configuration` (`ID`, `station_type`, `station_t INSERT INTO `hzims_station_push_configuration` (`ID`, `station_type`, `station_type_name`, `is_push`, `TENANT_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `IS_DELETED`, `STATUS`, `CREATE_DEPT`, `fdp_station_type`) VALUES (1679458692029796354, 7, '充电站', 0, '200000', '2023-07-13 19:52:10', '2023-07-13 19:52:10', 1434782836098891778, 1434782836098891778, 0, 1, 20000001, NULL); INSERT INTO `hzims_station_push_configuration` (`ID`, `station_type`, `station_type_name`, `is_push`, `TENANT_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `IS_DELETED`, `STATUS`, `CREATE_DEPT`, `fdp_station_type`) VALUES (1679458773470597121, 8, '泵站', 0, '200000', '2023-07-13 19:52:29', '2023-07-13 19:52:29', 1434782836098891778, 1434782836098891778, 0, 1, 20000001, NULL); INSERT INTO `hzims_station_push_configuration` (`ID`, `station_type`, `station_type_name`, `is_push`, `TENANT_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `IS_DELETED`, `STATUS`, `CREATE_DEPT`, `fdp_station_type`) VALUES (1679458845390327809, 9, '闸门', 0, '200000', '2023-07-13 19:52:46', '2023-07-13 19:52:46', 1434782836098891778, 1434782836098891778, 0, 1, 20000001, NULL); +-- 交接班中新增当前处理环节字段 +alter table `hz_ims_duty_rec` add COLUMN `deal_chain` varchar(100) comment '当前处理环节'; \ No newline at end of file