Browse Source

修正:交接班逻辑漏洞

zhongwei
ty 4 months ago
parent
commit
6920dd6ac9
  1. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java

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

@ -229,13 +229,18 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
//保存对应业务表单 //保存对应业务表单
String saved = saveEntity(JSONObject.toJSONString(recDTO)); String saved = saveEntity(JSONObject.toJSONString(recDTO));
//开启动作流 //开启动作流
R r = this.startProcess(JSON.toJSONString(saved), DutyRecProcessConstant.DUTY_REC_FLOW_KEY,null); R r = this.startProcess(saved, DutyRecProcessConstant.DUTY_REC_FLOW_KEY,null);
return r; return r;
} }
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
ImsDutyRecDTO recDTO= JSONObject.parseObject(entity, ImsDutyRecDTO.class); ImsDutyRecDTO recDTO= JSONObject.parseObject(entity, ImsDutyRecDTO.class);
// 判断是否已交班
List<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, recDTO.getDutyId()));
Assert.isTrue(CollectionUtil.isEmpty(dutyRecs),() -> {
throw new ServiceException("您已交班,请勿重复交班!");
});
transactionTemplate.setTransactionManager(transactionManager); transactionTemplate.setTransactionManager(transactionManager);
// 获取班组组长 // 获取班组组长
Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId()); Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
@ -258,13 +263,13 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
transactionTemplate.setTransactionManager(transactionManager); transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> { String res = transactionTemplate.execute(status -> {
// 在这里执行需要事务控制的代码 // 在这里执行需要事务控制的代码
if(Func.isNotEmpty(duration) && duration > 0) { if(Func.isNotEmpty(duration) && duration > 0) {
recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus());
} }
ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class); ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class);
if (Func.isEmpty(recEntity.getId())) { if (Func.isEmpty(recEntity.getId())) {
save(recEntity); save(recEntity);
recDTO.setId(recEntity.getId());
} }
ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity(); ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity();
imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME)); imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME));
@ -339,11 +344,7 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
*/ */
private Long getHandleGroupManagerByDuty(Long dutyId) { private Long getHandleGroupManagerByDuty(Long dutyId) {
ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId); ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId);
// 判断是否已交班
List<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId));
Assert.isTrue(CollectionUtil.isEmpty(dutyRecs),() -> {
throw new ServiceException("您已交班,请勿重复交班!");
});
//根据上一班值班id查询值班信息 //根据上一班值班id查询值班信息
ImsDutyMainEntity carryDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId)); ImsDutyMainEntity carryDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId));
Assert.isTrue(ObjectUtil.isNotEmpty(carryDutyMain),() -> { Assert.isTrue(ObjectUtil.isNotEmpty(carryDutyMain),() -> {

Loading…
Cancel
Save