|
|
|
@ -13,9 +13,7 @@ import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.flow.core.entity.BladeFlow; |
|
|
|
|
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.utils.TaskUtil; |
|
|
|
|
|
|
|
import org.springblade.hzinfo_inspect.duty.constants.OperationalConstants; |
|
|
|
import org.springblade.hzinfo_inspect.duty.constants.OperationalConstants; |
|
|
|
import org.springblade.hzinfo_inspect.duty.dto.ChangeShiftsReqDTO; |
|
|
|
import org.springblade.hzinfo_inspect.duty.dto.ChangeShiftsReqDTO; |
|
|
|
import org.springblade.hzinfo_inspect.duty.dto.ChangeShiftsRspDTO; |
|
|
|
import org.springblade.hzinfo_inspect.duty.dto.ChangeShiftsRspDTO; |
|
|
|
@ -23,7 +21,6 @@ import org.springblade.hzinfo_inspect.duty.dto.ImsDutyRecDTO; |
|
|
|
import org.springblade.hzinfo_inspect.duty.entity.*; |
|
|
|
import org.springblade.hzinfo_inspect.duty.entity.*; |
|
|
|
import org.springblade.hzinfo_inspect.duty.enums.DutyMainStatus; |
|
|
|
import org.springblade.hzinfo_inspect.duty.enums.DutyMainStatus; |
|
|
|
import org.springblade.hzinfo_inspect.duty.enums.DutyRecStatus; |
|
|
|
import org.springblade.hzinfo_inspect.duty.enums.DutyRecStatus; |
|
|
|
import org.springblade.hzinfo_inspect.duty.enums.JoinStatus; |
|
|
|
|
|
|
|
import org.springblade.hzinfo_inspect.duty.mapper.ImsDutyMainMapper; |
|
|
|
import org.springblade.hzinfo_inspect.duty.mapper.ImsDutyMainMapper; |
|
|
|
import org.springblade.hzinfo_inspect.duty.mapper.ImsDutyRecMapper; |
|
|
|
import org.springblade.hzinfo_inspect.duty.mapper.ImsDutyRecMapper; |
|
|
|
import org.springblade.hzinfo_inspect.duty.service.*; |
|
|
|
import org.springblade.hzinfo_inspect.duty.service.*; |
|
|
|
@ -76,8 +73,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IUserClient userClient; |
|
|
|
private IUserClient userClient; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IFlowClient flowClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ISysClient sysClient; |
|
|
|
private ISysClient sysClient; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IInspectPlanClient inspectPlanClient; |
|
|
|
private IInspectPlanClient inspectPlanClient; |
|
|
|
@ -147,29 +142,14 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
// 保存
|
|
|
|
// 保存
|
|
|
|
save(recEntity); |
|
|
|
save(recEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("groupEntityManagerId-------------------------:" + groupEntityManagerId); |
|
|
|
|
|
|
|
R<BladeFlow> result = flowClient.startProcessInstanceByKey(DutyRecProcessConstant. |
|
|
|
|
|
|
|
DUTY_REC_FLOW_KEY, StringUtil.format("{}:{}", |
|
|
|
|
|
|
|
DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, recEntity.getId()), new HashMap<String, Object>() {{ |
|
|
|
|
|
|
|
put("taskId", recEntity.getId()); |
|
|
|
|
|
|
|
put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(groupEntityManagerId.toString())); |
|
|
|
|
|
|
|
//put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, Arrays.stream(dutyMainEntity.getDutyPersonIds().split("\\^")).map(o -> TaskUtil.getTaskUser(o)).collect(Collectors.joining(",")));
|
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
log.info("result-------------------------:" + result); |
|
|
|
|
|
|
|
if (result.isSuccess()) { |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
Date date = new Date(); |
|
|
|
//判断是否延时交班
|
|
|
|
//判断是否延时交班
|
|
|
|
judgeDelayedHand(handDutyMainEntity, recEntity);//判断交班是否延时
|
|
|
|
judgeDelayedHand(handDutyMainEntity, recEntity);//判断交班是否延时
|
|
|
|
|
|
|
|
|
|
|
|
// 返回流程id写入业务表
|
|
|
|
// 返回流程id写入业务表
|
|
|
|
recEntity.setExecTime(date); |
|
|
|
recEntity.setExecTime(date); |
|
|
|
recEntity.setProcessInstanceId(result.getData().getProcessInstanceId()); |
|
|
|
recEntity.setStatus(DutyRecStatus.ACCEPT.getVal()); |
|
|
|
recEntity.setStatus(DutyRecStatus.EXEC.getVal()); |
|
|
|
|
|
|
|
//recEntity.setInspectTaskId(inspectTaskId);
|
|
|
|
|
|
|
|
updateById(recEntity); |
|
|
|
updateById(recEntity); |
|
|
|
} else { |
|
|
|
|
|
|
|
throw new ServiceException("开启流程失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.status(true); |
|
|
|
return R.status(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -197,7 +177,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
planVO.setPlanUsers(Lists.newArrayList(managerId)); |
|
|
|
planVO.setPlanUsers(Lists.newArrayList(managerId)); |
|
|
|
Long inspectTaskId = this.createInspectPlan(planVO); |
|
|
|
Long inspectTaskId = this.createInspectPlan(planVO); |
|
|
|
recDTO.setInspectTaskId(inspectTaskId); |
|
|
|
recDTO.setInspectTaskId(inspectTaskId); |
|
|
|
// 返回流程id写入业务表
|
|
|
|
|
|
|
|
recDTO.setExecTime(new Date()); |
|
|
|
recDTO.setExecTime(new Date()); |
|
|
|
recDTO.setStatus(DutyRecStatus.EXEC.getVal()); |
|
|
|
recDTO.setStatus(DutyRecStatus.EXEC.getVal()); |
|
|
|
// 判断交接班是否延时
|
|
|
|
// 判断交接班是否延时
|
|
|
|
@ -218,9 +197,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
imsDutyLogEntity.setHandTime(DateUtil.format(new Date(), PATTERN_DATETIME)); |
|
|
|
imsDutyLogEntity.setHandTime(DateUtil.format(new Date(), PATTERN_DATETIME)); |
|
|
|
imsDutyLogService.save(imsDutyLogEntity); |
|
|
|
imsDutyLogService.save(imsDutyLogEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
// 开启值班交接班流程
|
|
|
|
|
|
|
|
BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); |
|
|
|
|
|
|
|
recEntity.setProcessInstanceId(bladeFlow.getProcessInstanceId()); |
|
|
|
|
|
|
|
return updateById(recEntity); |
|
|
|
return updateById(recEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -265,37 +241,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
return managerId; |
|
|
|
return managerId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 开启值班交接班流程 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param recEntity 交接班信息 |
|
|
|
|
|
|
|
* @return 工作流执行结果 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private BladeFlow startDutyRecProcess(ImsDutyRecEntity recEntity, Long managerId) { |
|
|
|
|
|
|
|
ImsDutyRecDTO recDTO = BeanUtil.copy(recEntity, ImsDutyRecDTO.class); |
|
|
|
|
|
|
|
ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getDutyId()); |
|
|
|
|
|
|
|
recDTO.setHeadDutyMainVo(currentDuty); |
|
|
|
|
|
|
|
List<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getDutyId())); |
|
|
|
|
|
|
|
Assert.isTrue(carryDuties.size() <= 1, () -> { |
|
|
|
|
|
|
|
throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId())); |
|
|
|
|
|
|
|
Map<String, Object> variable = new HashMap() {{ |
|
|
|
|
|
|
|
putAll(BeanUtil.toMap(recDTO)); |
|
|
|
|
|
|
|
put("taskId", recEntity.getId()); |
|
|
|
|
|
|
|
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(); |
|
|
|
@ -566,8 +511,7 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
eq(ImsDutyRecEntity::getDutyId, imsDutyMainEntity.getId()); |
|
|
|
eq(ImsDutyRecEntity::getDutyId, imsDutyMainEntity.getId()); |
|
|
|
eq(ImsDutyRecEntity::getCreateDept, mainEntityById.getCreateDept()); |
|
|
|
eq(ImsDutyRecEntity::getCreateDept, mainEntityById.getCreateDept()); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if (ObjectUtil.isNotEmpty(recEntity) && StringUtil.isNotBlank(recEntity.getProcessInstanceId())) { |
|
|
|
if (ObjectUtil.isNotEmpty(recEntity) ) { |
|
|
|
flowClient.delProcessInstanceById(recEntity.getProcessInstanceId(), "交接班-异常数据处理"); |
|
|
|
|
|
|
|
recEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); |
|
|
|
recEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); |
|
|
|
recEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus()); |
|
|
|
recEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus()); |
|
|
|
this.updateById(recEntity); |
|
|
|
this.updateById(recEntity); |
|
|
|
@ -576,7 +520,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
imsDutyRecEntity.setDutyId(imsDutyMainEntity.getId()); |
|
|
|
imsDutyRecEntity.setDutyId(imsDutyMainEntity.getId()); |
|
|
|
imsDutyRecEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); |
|
|
|
imsDutyRecEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); |
|
|
|
imsDutyRecEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); |
|
|
|
imsDutyRecEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); |
|
|
|
|
|
|
|
|
|
|
|
this.save(imsDutyRecEntity); |
|
|
|
this.save(imsDutyRecEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
mainEntity1.setId(imsDutyMainEntity.getId()); |
|
|
|
mainEntity1.setId(imsDutyMainEntity.getId()); |
|
|
|
@ -731,15 +674,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty |
|
|
|
return this.baseMapper.selectRecInfoByDepts(depts, date); |
|
|
|
return this.baseMapper.selectRecInfoByDepts(depts, date); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R delProcessInstanceIds(String processInstanceIds) { |
|
|
|
|
|
|
|
String[] split = processInstanceIds.split(","); |
|
|
|
|
|
|
|
for (String processInstanceId : split) { |
|
|
|
|
|
|
|
flowClient.delProcessInstanceById(processInstanceId, "交接班-异常数据处理"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.success("操作成功"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 天数加1 |
|
|
|
* 天数加1 |
|
|
|
|