Browse Source

# 交接班流程改造

zhongwei
haungxing 1 year ago
parent
commit
237d6d60a4
  1. 8
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java
  2. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java
  3. 73
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java
  4. 4
      hzims-service/operational/src/main/resources/files/交接班流程.bpmn20.xml

8
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java

@ -11,6 +11,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
@ -58,13 +60,15 @@ public class PlanVO extends TenantEntity implements Serializable {
* 计划开始时间 * 计划开始时间
*/ */
@ApiModelProperty(value = "计划开始时间") @ApiModelProperty(value = "计划开始时间")
@JsonFormat(pattern="yyyy-MM-dd") @JsonFormat(pattern = DateUtil.PATTERN_DATE)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
private LocalDate startTime; private LocalDate startTime;
/** /**
* 计划结束时间 * 计划结束时间
*/ */
@ApiModelProperty(value = "计划结束时间") @ApiModelProperty(value = "计划结束时间")
@JsonFormat(pattern="yyyy-MM-dd") @JsonFormat(pattern = DateUtil.PATTERN_DATE)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
private LocalDate endTime; private LocalDate endTime;
/** /**
* 计划模式 0 人员 1岗位 2机构 3自由模式 4 自由人模式 * 计划模式 0 人员 1岗位 2机构 3自由模式 4 自由人模式

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java

@ -1,6 +1,7 @@
package com.hnac.hzims.operational.duty.feign; package com.hnac.hzims.operational.duty.feign;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; 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;
@ -34,7 +35,8 @@ public class DutyRecClient implements IDutyRecClient {
@Override @Override
public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) { public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) {
logger.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse)); logger.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse));
ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class); //ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class);
ImsDutyRecDTO recDTO = JSONObject.parseObject(JSON.toJSONString(processWorkFlowResponse.getVariables()),ImsDutyRecDTO.class);
Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> { Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> {
throw new RuntimeException("未接收到交接班信息!"); throw new RuntimeException("未接收到交接班信息!");
}); });

73
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java

@ -201,6 +201,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
* @return 交接班成功标识 * @return 交接班成功标识
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Boolean changeShift(ImsDutyRecDTO recDTO) { public Boolean changeShift(ImsDutyRecDTO recDTO) {
// 获取班组组长 // 获取班组组长
Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId()); Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
@ -214,14 +215,22 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
planVO.setRouteName(recDTO.getRouteName()); planVO.setRouteName(recDTO.getRouteName());
planVO.setPlanUsers(Lists.newArrayList(managerId)); planVO.setPlanUsers(Lists.newArrayList(managerId));
Long inspectTaskId = this.createInspectPlan(planVO); Long inspectTaskId = this.createInspectPlan(planVO);
ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class); recDTO.setInspectTaskId(inspectTaskId);
recEntity.setInspectTaskId(inspectTaskId);
// 返回流程id写入业务表 // 返回流程id写入业务表
recDTO.setExecTime(new Date()); recDTO.setExecTime(new Date());
recDTO.setStatus(DutyRecStatus.EXEC.getVal()); recDTO.setStatus(DutyRecStatus.EXEC.getVal());
// 判断交接班是否延时
Long duration = this.changeShiftDuration(imsDutyMainService.getById(recDTO.getDutyId()), OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal());
if(Func.isNotEmpty(duration) && duration > 0) {
recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus());
}
ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class);
if (Func.isEmpty(recEntity.getId())) {
save(recEntity);
}
// 开启值班交接班流程 // 开启值班交接班流程
BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId);
recDTO.setProcessInstanceId(bladeFlow.getProcessInstanceId()); recEntity.setProcessInstanceId(bladeFlow.getProcessInstanceId());
return updateById(recEntity); return updateById(recEntity);
} }
@ -234,28 +243,28 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId); ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId);
// 判断是否已交班 // 判断是否已交班
List<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId)); List<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId));
Assert.isTrue(CollectionUtil.isNotEmpty(dutyRecs),() -> { Assert.isTrue(CollectionUtil.isEmpty(dutyRecs),() -> {
throw new ServiceException("您已交班,请勿重复交班!"); throw new ServiceException("您已交班,请勿重复交班!");
}); });
//根据上一班值班id查询值班信息 //根据上一班值班id查询值班信息
ImsDutyMainEntity preDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId)); ImsDutyMainEntity carryDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId));
Assert.isTrue(ObjectUtil.isEmpty(preDutyMain),() -> { Assert.isTrue(ObjectUtil.isNotEmpty(carryDutyMain),() -> {
throw new ServiceException("当前时间没有接班人!"); throw new ServiceException("当前时间没有接班人!");
}); });
//获取接班人班组组长 //获取接班人班组组长
Long managerId; Long managerId;
if (Func.isNotEmpty(dutyMain.getDutyGroupId())) { if (Func.isNotEmpty(dutyMain.getDutyGroupId())) {
ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyMain.getDutyGroupId()); ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(carryDutyMain.getDutyGroupId());
ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper<ImsDutyGroupPEntity>() {{ ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper<ImsDutyGroupPEntity>() {{
eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId());
eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1");
}}); }});
Assert.isTrue(ObjectUtil.isEmpty(groupPEntity), () -> { Assert.isTrue(ObjectUtil.isNotEmpty(groupPEntity), () -> {
throw new ServiceException("接班班组长不存在,请指定班组长后进行交班!"); throw new ServiceException("接班班组长不存在,请指定班组长后进行交班!");
}); });
managerId = groupEntity.getManagerId(); managerId = groupEntity.getManagerId();
} else { } else {
managerId = Optional.ofNullable(imsDutyMainPersonService.selectByMainId(dutyMain.getId())).filter(CollectionUtil::isNotEmpty) managerId = Optional.ofNullable(imsDutyMainPersonService.selectByMainId(carryDutyMain.getId())).filter(CollectionUtil::isNotEmpty)
.map(list -> list.get(0)).map(ImsDutyMainPersonEntity::getDutyChargePerson).orElse(null); .map(list -> list.get(0)).map(ImsDutyMainPersonEntity::getDutyChargePerson).orElse(null);
} }
R<User> manager = userClient.userInfoById(managerId); R<User> manager = userClient.userInfoById(managerId);
@ -272,16 +281,18 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
*/ */
private BladeFlow startDutyRecProcess(ImsDutyRecEntity recEntity ,Long managerId) { private BladeFlow startDutyRecProcess(ImsDutyRecEntity recEntity ,Long managerId) {
ImsDutyRecDTO recDTO = BeanUtil.copy(recEntity,ImsDutyRecDTO.class); ImsDutyRecDTO recDTO = BeanUtil.copy(recEntity,ImsDutyRecDTO.class);
ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getId()); ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getDutyId());
recDTO.setHeadDutyMainVo(currentDuty); recDTO.setHeadDutyMainVo(currentDuty);
List<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getId())); List<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getDutyId()));
Assert.isTrue(carryDuties.size() <= 1,() -> { Assert.isTrue(carryDuties.size() <= 1,() -> {
throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size()); throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size());
}); });
recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId())); recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId()));
Map<String,Object> variable = BeanUtil.toMap(recDTO); Map<String,Object> variable = new HashMap(){{
variable.put("taskId", recEntity.getId()); putAll(BeanUtil.toMap(recDTO));
variable.put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString())); put("taskId", recEntity.getId());
put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString()));
}};
R<BladeFlow> flowResult = flowClient.startProcessInstanceByKey( R<BladeFlow> flowResult = flowClient.startProcessInstanceByKey(
DutyRecProcessConstant.DUTY_REC_FLOW_KEY, DutyRecProcessConstant.DUTY_REC_FLOW_KEY,
@ -1244,8 +1255,8 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
vo.setStartTime(startTime.toLocalDate()); vo.setStartTime(startTime.toLocalDate());
vo.setEndTime(endTime.toLocalDate()); vo.setEndTime(endTime.toLocalDate());
Map<String, Object> execTime = new HashMap(2){{ Map<String, Object> execTime = new HashMap(2){{
put("execStartTime",startTime.toLocalTime()); put("execStartTime",DateTimeFormatter.ofPattern(DateUtil.PATTERN_TIME).format(startTime.toLocalTime()));
put("execEndTime", startTime.toLocalTime()); put("execEndTime", DateTimeFormatter.ofPattern(DateUtil.PATTERN_TIME).format(endTime.toLocalTime()));
}}; }};
List<Map<String, Object>> execTimeList = Lists.newArrayList(execTime); List<Map<String, Object>> execTimeList = Lists.newArrayList(execTime);
vo.setExecTimeJson(JSONObject.toJSONString(execTimeList)); vo.setExecTimeJson(JSONObject.toJSONString(execTimeList));
@ -1356,16 +1367,24 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
} }
@Override @Override
@Transactional
public Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO) { public Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO) {
ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class); ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class);
ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class); ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class);
ImsDutyRecEntity dutyRec = BeanUtil.copy(recDTO, ImsDutyRecEntity.class); if(StringUtil.isBlank(recDTO.getDealChain())) {
recDTO.setDealChain("结束");
if("接班确认".equals(recDTO.getDealChain())) {
// 接班确认-获取交接班延时状态 // 接班确认-获取交接班延时状态
this.getChangeShiftStatus(carryDutyMain,dutyRec.getDelayStatus(),OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()); recDTO.setDelayStatus(this.getChangeShiftStatus(carryDutyMain,recDTO.getDelayStatus(),OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()));
//修改交班人所在主表数据状态为 已完成
headDutyMain.setStatus(DutyMainStatus.ACCEPT.getVal());
//修改接班人所在主表数据状态为 值班中
carryDutyMain.setStatus(DutyMainStatus.EXEC.getVal());
// 交接班接班信息填充
recDTO.setStatus(DutyRecStatus.ACCEPT.getVal());
recDTO.setAcceptTime(new Date());
recDTO.setQrCodeContent(System.currentTimeMillis() + "");
} }
ImsDutyRecEntity dutyRec = BeanUtil.copy(recDTO, ImsDutyRecEntity.class);
// 更新交班值班 // 更新交班值班
Assert.isTrue(imsDutyMainService.updateById(headDutyMain),() -> { Assert.isTrue(imsDutyMainService.updateById(headDutyMain),() -> {
throw new RuntimeException("更新交班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); throw new RuntimeException("更新交班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo()));
@ -1375,9 +1394,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
throw new RuntimeException("更新接班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); throw new RuntimeException("更新接班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo()));
}); });
// 更新交接班 // 更新交接班
Assert.isTrue(this.updateById(dutyRec),() -> { this.updateById(dutyRec);
throw new RuntimeException("更新交接班失败,更新对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo()));
});
return true; return true;
} }
@ -1403,14 +1420,14 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
/** /**
* 交接班时间差 * 交接班时间差
* @param duty 值班信息 * @param duty 值班信息 交班为当前值班 接班为下一值班
* @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类 * @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类
* @return 延时时长 * @return 延时时长
*/ */
private Long changeShiftDuration(ImsDutyMainEntity duty, int type) { private Long changeShiftDuration(ImsDutyMainEntity duty, int type) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// 获取当前值班班次 // 获取当前值班班次
ImsDutyClassEntity dutyClass = imsDutyClassService.getById(duty.getId()); ImsDutyClassEntity dutyClass = imsDutyClassService.getById(duty.getClassId());
Assert.isTrue(ObjectUtil.isNotEmpty(dutyClass),()-> { Assert.isTrue(ObjectUtil.isNotEmpty(dutyClass),()-> {
throw new RuntimeException("接班获取班次失败!"); throw new RuntimeException("接班获取班次失败!");
}); });
@ -1426,11 +1443,11 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims
} }
// 交班延时判断 // 交班延时判断
if(type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { if(type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) {
return Duration.between(now,endDateTime).toMinutes(); return Duration.between(endDateTime,now).toMinutes();
} }
// 接班延时判断 // 接班延时判断
else if(type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { else if(type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) {
return Duration.between(now,startDateTime).toMinutes(); return Duration.between(startDateTime,now).toMinutes();
} }
return null; return null;
} }

4
hzims-service/operational/src/main/resources/files/交接班流程.bpmn20.xml

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef"> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
<process id="duty_rec" name="交接班流程" isExecutable="true"> <process id="duty_rec" name="交接班流程" isExecutable="true">
<startEvent id="startEvent1"></startEvent> <startEvent id="startEvent1" name="开始"></startEvent>
<userTask id="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6" name="接班确认" flowable:candidateUsers="${carryUser}"></userTask> <userTask id="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6" name="接班确认" flowable:candidateUsers="${carryUser}"></userTask>
<sequenceFlow id="sid-3EF4FFFF-0B0E-4270-944C-E874E84E93A5" sourceRef="startEvent1" targetRef="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6"></sequenceFlow> <sequenceFlow id="sid-3EF4FFFF-0B0E-4270-944C-E874E84E93A5" sourceRef="startEvent1" targetRef="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6"></sequenceFlow>
<endEvent id="sid-0FC1E0FD-D27F-4302-A457-D3A0389183D7"></endEvent> <endEvent id="sid-0FC1E0FD-D27F-4302-A457-D3A0389183D7" name="结束"></endEvent>
<sequenceFlow id="sid-6A995FDB-E8FA-4468-B201-7B74C46AEC71" sourceRef="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6" targetRef="sid-0FC1E0FD-D27F-4302-A457-D3A0389183D7"></sequenceFlow> <sequenceFlow id="sid-6A995FDB-E8FA-4468-B201-7B74C46AEC71" sourceRef="sid-9FEC0D53-CF7B-4028-82CA-020E814195C6" targetRef="sid-0FC1E0FD-D27F-4302-A457-D3A0389183D7"></sequenceFlow>
</process> </process>
<bpmndi:BPMNDiagram id="BPMNDiagram_duty_rec"> <bpmndi:BPMNDiagram id="BPMNDiagram_duty_rec">

Loading…
Cancel
Save