|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|