Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
3a321b3a39
  1. 25
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/dto/ImsDutyRecDTO.java
  2. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java
  3. 10
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClient.java
  4. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/feign/IDutyRecClientFalllback.java
  5. 3
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/dto/ProjectDTO.java
  6. 3
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/TemplateEntity.java
  7. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java
  8. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java
  9. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectProjectContentService.java
  10. 50
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java
  11. 19
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java
  12. 11
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java
  13. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java
  14. 27
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java
  15. 16
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java
  16. 251
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java
  17. 2
      hzims-service/operational/src/main/resources/db/1.0.1.sql

25
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; package com.hnac.hzims.operational.duty.dto;
import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; 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.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/** /**
* 模型DTO * 模型DTO
* *
@ -15,4 +19,25 @@ public class ImsDutyRecDTO extends ImsDutyRecEntity {
private static final long serialVersionUID = 1L; 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;
} }

5
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、延时") @ApiModelProperty(value = "延时状态 0 、未延时 1、延时")
private Integer delayStatus; private Integer delayStatus;
@ApiModelProperty(value = "当前处理环节")
@QueryField(condition = SqlCondition.LIKE)
private String dealChain;
} }

10
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; 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.OperationalConstants;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO;
@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface IDutyRecClient { public interface IDutyRecClient {
String API_PREFIX = "/ims_duty_rec"; String API_PREFIX = "/ims_duty_rec";
String GET_CHANGE_SHIFTS = API_PREFIX + "/getChangeShifts"; 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) @PostMapping(GET_CHANGE_SHIFTS)
R<ChangeShiftsRspDTO> getChangeShifts(@RequestBody ChangeShiftsReqDTO reqDTO); R<ChangeShiftsRspDTO> getChangeShifts(@RequestBody ChangeShiftsReqDTO reqDTO);
/**
* 处理交接班流程
* @param processWorkFlowResponse redis消息中心订阅返回消息
* @return 处理结果flag
*/
@PostMapping(DEAL_DUTY_REC_FLOW)
R dealDutyRecFlow(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse);
} }

6
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; 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.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -17,4 +18,9 @@ public class IDutyRecClientFalllback implements IDutyRecClient {
response.setShiftsRate(0.0); response.setShiftsRate(0.0);
return R.data(response); return R.data(response);
} }
@Override
public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) {
return R.fail("交接班处理流程失败");
}
} }

3
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对象") @ApiModelProperty("巡检内容DTO对象")
private List<ContentDTO> contentDTOList; private List<ContentDTO> contentDTOList;
@ApiModelProperty("是否为新模式 是否为从设备导入的项目")
private Boolean isNewModel;
} }

3
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机器人巡检") @ApiModelProperty(value = "inspectType 支持的巡检类型 0普通巡检,1视频自动巡检,2机器人巡检")
private String supportAutoVideo; private String supportAutoVideo;
//private Boolean ;
} }

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java

@ -243,6 +243,10 @@ public class ObjectServiceImpl extends BaseServiceImpl<InspectObjectMapper, Obje
private void generateTemplate(ObjectEntity object) { private void generateTemplate(ObjectEntity object) {
// 若巡检对象设备编码存在,则生成巡检模板 // 若巡检对象设备编码存在,则生成巡检模板
if(Func.isNotEmpty(object.getEmCodes())) { if(Func.isNotEmpty(object.getEmCodes())) {
// 清空巡检对象与巡检模板的绑定关系
if(Func.isNotEmpty(object.getId())) {
objectTemplateService.remove(Wrappers.<ObjectTemplateEntity>lambdaQuery().eq(ObjectTemplateEntity::getObjectId,object.getId()));
}
TemplateEntity template = new TemplateEntity(); TemplateEntity template = new TemplateEntity();
template.setCode(String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond())); template.setCode(String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond()));
template.setName(object.getName()); template.setName(object.getName());

14
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.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; 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.ProjectContentEntity;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity; 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.utils.CodeUtils;
import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO; import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import com.hnac.hzinfo.inspect.obj.wrapper.ProjectWrapper;
import com.hnac.hzinfo.inspect.utils.Condition; import com.hnac.hzinfo.inspect.utils.Condition;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -78,6 +81,17 @@ public class ProjectController {
return R.data(pages); return R.data(pages);
} }
@GetMapping("/selectProject")
@ApiOperation(value = "巡检项目列表-下拉框", notes = "巡检项目列表-下拉框")
@ApiOperationSupport(order = 2)
public R<List<ProjectVO>> selectProject(ProjectDTO project) {
LambdaQueryWrapper<ProjectEntity> queryWrapper = Condition.getQueryWrapper(new ProjectEntity(),project);
queryWrapper.isNotNull(project.getIsNewModel(),ProjectEntity::getEmCode);
queryWrapper.ne(project.getIsNewModel(),ProjectEntity::getEmCode,"");
List<ProjectEntity> projectList = projectService.list(queryWrapper);
return R.data(ProjectWrapper.build().listVO(projectList));
}
/** /**
* 查询单条 * 查询单条
*/ */

3
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; package com.hnac.hzinfo.inspect.task.service;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity;
@ -14,4 +15,6 @@ public interface ITaskObjectProjectContentService extends BaseService<TaskObject
List<TaskObjectProjectContentEntity> getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc); List<TaskObjectProjectContentEntity> getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc);
void fillRealData(TaskObjectProjectContentVO contentVO);
} }

50
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; 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 org.springblade.core.mp.base.BaseServiceImpl;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity;
import com.hnac.hzinfo.inspect.task.mapper.TaskObjectProjectContentMapper; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectProjectContentMapper;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; 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 org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* 服务实现类 * 服务实现类
@ -14,9 +33,40 @@ import java.util.List;
* @author Chill * @author Chill
*/ */
@Service @Service
@AllArgsConstructor
@Slf4j
public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl<TaskObjectProjectContentMapper, TaskObjectProjectContentEntity> implements ITaskObjectProjectContentService { public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl<TaskObjectProjectContentMapper, TaskObjectProjectContentEntity> implements ITaskObjectProjectContentService {
private final ContentService contentService;
private final IStationClient stationClient;
private final RedisClient redisClient;
@Override @Override
public List<TaskObjectProjectContentEntity> getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc) { public List<TaskObjectProjectContentEntity> getTaskObjectProjectContentList(TaskObjectProjectContentEntity topc) {
return this.baseMapper.getTaskObjectProjectContents(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<StationEntity> stationR = stationClient.getOne(station);
if(stationR.isSuccess() && ObjectUtil.isNotEmpty(stationR.getData())) {
// 获取任务巡检内容实时数据
List<String> 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()));
}
}
}
}
}
} }

19
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.entity.TaskObjectEntity;
import com.hnac.hzinfo.inspect.task.mapper.TaskObjectMapper; 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.service.ITaskObjectService;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectOfflineVO; 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 com.hnac.hzinfo.inspect.task.vo.TaskObjectVO;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl; 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 org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -16,8 +21,11 @@ import java.util.List;
* @author Chill * @author Chill
*/ */
@Service @Service
@AllArgsConstructor
public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, TaskObjectEntity> implements ITaskObjectService { public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, TaskObjectEntity> implements ITaskObjectService {
private final ITaskObjectProjectContentService taskContentService;
@Override @Override
public List<TaskObjectEntity> getTaskObjectList(TaskObjectEntity taskObjectEntity) { public List<TaskObjectEntity> getTaskObjectList(TaskObjectEntity taskObjectEntity) {
return this.baseMapper.getTaskObjects(taskObjectEntity); return this.baseMapper.getTaskObjects(taskObjectEntity);
@ -25,7 +33,16 @@ public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, Tas
@Override @Override
public List<TaskObjectVO> getTaskObjectsDetail(TaskObjectEntity to){ public List<TaskObjectVO> getTaskObjectsDetail(TaskObjectEntity to){
return this.baseMapper.getTaskObjectsDetail(to); List<TaskObjectVO> 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 @Override

11
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; 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.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.*; import lombok.*;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* 任务对象项目内容 * 任务对象项目内容
@ -116,4 +120,11 @@ public class TaskObjectProjectContentVO implements Serializable {
@ApiModelProperty(value = "记值方式为选择时选择值") @ApiModelProperty(value = "记值方式为选择时选择值")
private String dictType; private String dictType;
@ApiModelProperty(value = "实时数据")
private Double realData;
@ApiModelProperty(value = "实时数据采集时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime gatherTime;
} }

9
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.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType; 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.AnalyseExample;
import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
@ -99,6 +100,7 @@ public class ImsDutyRecController extends BladeController {
@ApiOperation(value = "新增或修改,然后提交,开始工作流程", notes = "传入imsDutyRec") @ApiOperation(value = "新增或修改,然后提交,开始工作流程", notes = "传入imsDutyRec")
public R submit(@Valid @RequestBody ImsDutyRecEntity imsDutyRec,@RequestBody PlanVO vo) { public R submit(@Valid @RequestBody ImsDutyRecEntity imsDutyRec,@RequestBody PlanVO vo) {
return imsDutyRecService.submit(imsDutyRec,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); 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));
}
} }

27
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; 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.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; 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.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.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.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@AllArgsConstructor
public class DutyRecClient implements IDutyRecClient { public class DutyRecClient implements IDutyRecClient {
@Autowired private final IImsDutyRecService service;
private IImsDutyRecService service; private final BladeLogger logger;
@Override @Override
public R<ChangeShiftsRspDTO> getChangeShifts(ChangeShiftsReqDTO reqDTO) { public R<ChangeShiftsRspDTO> getChangeShifts(ChangeShiftsReqDTO reqDTO) {
return R.data(service.getChangeShifts(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));
}
} }

16
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.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; 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.ImsDutyClassEntity;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity;
@ -24,6 +25,12 @@ public interface IImsDutyRecService extends BaseService<ImsDutyRecEntity> {
R submit(ImsDutyRecEntity imsDutyRecEntity, PlanVO vo); R submit(ImsDutyRecEntity imsDutyRecEntity, PlanVO vo);
/**
* 开启交接班
* @param recDTO 交接班信息
* @return 交接班成功与否flag
*/
Boolean changeShift(ImsDutyRecDTO recDTO);
/** /**
* 执行工作流 * 执行工作流
@ -117,8 +124,15 @@ public interface IImsDutyRecService extends BaseService<ImsDutyRecEntity> {
/** /**
* 交接班统计 * 交接班统计
* @param reqDTO * @param reqDTO 交接班信息
* @return * @return
*/ */
ChangeShiftsRspDTO getChangeShifts(ChangeShiftsReqDTO reqDTO); ChangeShiftsRspDTO getChangeShifts(ChangeShiftsReqDTO reqDTO);
/**
* 执行工作流-处理业务数据
* @param recDTO 交接班信息
* @return
*/
Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO);
} }

251
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; package com.hnac.hzims.operational.duty.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; 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.constant.DutyRecProcessConstant;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; 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.entity.*;
import com.hnac.hzims.operational.duty.enume.DutyMainStatus; import com.hnac.hzims.operational.duty.enume.DutyMainStatus;
import com.hnac.hzims.operational.duty.enume.DutyRecStatus; 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.vo.ImsSchedulingVo;
import com.hnac.hzims.operational.duty.wrapper.ImsDutyRecWrapper; import com.hnac.hzims.operational.duty.wrapper.ImsDutyRecWrapper;
import com.hnac.hzims.operational.station.service.IStationService; 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.feign.IInspectPlanClient;
import com.hnac.hzinfo.inspect.plan.vo.PlanVO; import com.hnac.hzinfo.inspect.plan.vo.PlanVO;
import lombok.extern.slf4j.Slf4j; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Time;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -187,6 +195,104 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
return R.status(true); return R.status(true);
} }
/**
* 开启交接班
* @param recDTO 交接班信息 - 巡检路线IDNAMEDATA
* @return 交接班成功标识
*/
@Override
public Boolean changeShift(ImsDutyRecDTO recDTO) {
// 获取班组组长
Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
Assert.isTrue(Func.isNotEmpty(managerId),() -> {
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<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId));
Assert.isTrue(CollectionUtil.isNotEmpty(dutyRecs),() -> {
throw new ServiceException("您已交班,请勿重复交班!");
});
//根据上一班值班id查询值班信息
ImsDutyMainEntity preDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>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<ImsDutyGroupPEntity>() {{
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<User> 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<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>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<String,Object> variable = BeanUtil.toMap(recDTO);
variable.put("taskId", recEntity.getId());
variable.put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString()));
R<BladeFlow> 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) { private void updateMain(Long dutyId) {
ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity();
@ -1114,41 +1220,46 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
log.info(booleanR.toString()); log.info(booleanR.toString());
} }
//新增巡检计划 获取巡检任务ID /**
public Long getInspectTaskId(PlanVO vo, Long princId) { * 创建交接班巡检任务
* @param vo 巡检任务VO对象
* @return 巡检任务ID
*/
private Long createInspectPlan(PlanVO vo) {
// 填充巡检计划信息
vo.setName(DateUtil.format(new Date(), "yyyy-MM-dd HH") + "-交接班巡视"); vo.setName(DateUtil.format(new Date(), "yyyy-MM-dd HH") + "-交接班巡视");
vo.setMethod(DutyRecProcessConstant.INSPECT_PANL_METHOD); vo.setMethod(PlanContants.PlanMethodEnum.SEIZE.getMethod());
vo.setAutoVideo(DutyRecProcessConstant.INSPECT_PANL_AUTO_VIDEO); vo.setAutoVideo(PlanContants.AutoVideoEnum.NO.getFlag());
vo.setCycle(DutyRecProcessConstant.INSPECT_PANL_AUTO_CYCLE); vo.setCycle(PlanContants.PlanCycleEnum.NEVER_CYCLE.getCycle());
Date date = new Date(); vo.setType(PlanContants.PlanTypeEnum.USER_TYPE.getType());
Date startDate = minutlDate(date, 5);
Date endDate = hrDate(date, 2);
LocalDate startTime = LocalDate.parse(DateUtil.format(startDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
LocalDate endTime = LocalDate.parse(DateUtil.format(endDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
vo.setStartTime(startTime);
vo.setEndTime(endTime);
vo.setType(DutyRecProcessConstant.INSPECT_PANL_TYPE);
vo.setTaskTimesADay(DutyRecProcessConstant.INSPECT_PANL_TASK_TIMES_A_DAY); vo.setTaskTimesADay(DutyRecProcessConstant.INSPECT_PANL_TASK_TIMES_A_DAY);
vo.setPlanType(PlanContants.PlanContentTypeEnum.COMMON.getDesc());
vo.setStartRemind(DutyRecProcessConstant.INSPECT_PANL_START_REMIND); vo.setStartRemind(DutyRecProcessConstant.INSPECT_PANL_START_REMIND);
vo.setEndRemind(DutyRecProcessConstant.INSPECT_PANL_END_REMIND); vo.setEndRemind(DutyRecProcessConstant.INSPECT_PANL_END_REMIND);
String execStartTime = DateUtil.format(startDate, DateUtil.PATTERN_TIME);
String execEndTime = DateUtil.format(endDate, DateUtil.PATTERN_TIME); // 设置巡检计划计划开始结束时间
List<Map<String, Object>> listMap = new ArrayList<>(); LocalDateTime now = LocalDateTime.now();
Map<String, Object> map = new HashMap<>(); LocalDateTime startTime = now.minusMinutes(5);
map.put("execStartTime", execStartTime); LocalDateTime endTime = now.plusHours(2);
map.put("execEndTime", execEndTime); vo.setStartTime(startTime.toLocalDate());
listMap.add(map); vo.setEndTime(endTime.toLocalDate());
vo.setExecTimeJson(JSONObject.toJSONString(listMap)); Map<String, Object> execTime = new HashMap(2){{
List<Long> list = new ArrayList<>(); put("execStartTime",startTime.toLocalTime());
list.add(princId); put("execEndTime", startTime.toLocalTime());
vo.setPlanType("common"); }};
vo.setPlanUsers(list); List<Map<String, Object>> execTimeList = Lists.newArrayList(execTime);
R<List<Long>> listR = inspectPlanClient.addPlanAndChecked(vo); vo.setExecTimeJson(JSONObject.toJSONString(execTimeList));
List<Long> data = listR.getData(); R<List<Long>> createPlanResult = inspectPlanClient.addPlanAndChecked(vo);
if (CollectionUtil.isNotEmpty(data)) { Assert.isTrue(createPlanResult.isSuccess(),() -> {
return data.get(0); throw new ServiceException(createPlanResult.getMsg());
});
return Optional.ofNullable(createPlanResult.getData()).map(list -> list.get(0)).orElse(null);
} }
return 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<ImsDutyRecMapper, Ims
return response; return response;
} }
@Override
public Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO) {
ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class);
ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class);
ImsDutyRecEntity dutyRec = BeanUtil.copy(recDTO, ImsDutyRecEntity.class);
if("接班确认".equals(recDTO.getDealChain())) {
// 接班确认-获取交接班延时状态
this.getChangeShiftStatus(carryDutyMain,dutyRec.getDelayStatus(),OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal());
}
// 更新交班值班
Assert.isTrue(imsDutyMainService.updateById(headDutyMain),() -> {
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;
}
} }

2
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 (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 (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); 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 '当前处理环节';
Loading…
Cancel
Save