Browse Source

修复:隐患流程修复

zhongwei
ty 4 months ago
parent
commit
c048f619a2
  1. 29
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java

29
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java

@ -69,24 +69,18 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
return this.baseMapper.selectPage(Condition.getPage(query), Condition.getQueryWrapper(innerDangerEntity)); return this.baseMapper.selectPage(Condition.getPage(query), Condition.getQueryWrapper(innerDangerEntity));
} }
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
@Override @Override
public R startHiddenDanger(InnerDangerVo hiddenDangerVo) { public R startHiddenDanger(InnerDangerVo hiddenDangerVo) {
InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); String saved = saveEntity(JSONObject.toJSONString(hiddenDangerVo));
BeanUtil.copy(hiddenDangerVo, innerDangerEntity); R r = this.startProcess(saved, HIDDEN_DANGER_CHECK);
saveEntity(JSONObject.toJSONString(innerDangerEntity));
InnerDangerEntity saveEntity = this.getOne(new LambdaQueryWrapper<InnerDangerEntity>() {{
eq(InnerDangerEntity::getCode, innerDangerEntity.getCode());
last("limit 1");
}});
BeanUtil.copy(saveEntity,hiddenDangerVo);
R r = this.startProcess(JSONObject.toJSONString(hiddenDangerVo), HIDDEN_DANGER_CHECK);
return r; return r;
} }
@Override @Override
@Transactional
public String saveEntity(String entity) { public String saveEntity(String entity) {
InnerDangerEntity innerDangerEntity= JSONObject.parseObject(entity, InnerDangerEntity.class); InnerDangerVo hiddenDangerVo= JSONObject.parseObject(entity, InnerDangerVo.class);
InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
BeanUtil.copy(hiddenDangerVo, innerDangerEntity);
if (Func.isEmpty(innerDangerEntity.getCode())) { if (Func.isEmpty(innerDangerEntity.getCode())) {
innerDangerEntity.setCode(UUID.randomUUID().toString()); innerDangerEntity.setCode(UUID.randomUUID().toString());
} }
@ -114,7 +108,8 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
if (!save) { if (!save) {
throw new ServiceException("隐患保存失败,请稍后重试!"); throw new ServiceException("隐患保存失败,请稍后重试!");
} }
return JSON.toJSONString(innerDangerEntity); BeanUtil.copy(innerDangerEntity, hiddenDangerVo);
return JSON.toJSONString(hiddenDangerVo);
} }
@Override @Override
@ -128,21 +123,21 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
} }
public R startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue) {
InnerDangerVo innerDangerVo = JSONObject.parseObject(entity, InnerDangerVo.class); InnerDangerVo innerDangerVo= JSONObject.parseObject(entity, InnerDangerVo.class);
InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
BeanUtil.copy(innerDangerVo, innerDangerEntity); BeanUtil.copy(innerDangerVo, innerDangerEntity);
// 隐患处理名字 // 隐患处理名字
String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse(""); String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse("");
// 流程名称 // 流程名称
String processName = "[" + userName + "] 发起 " + "【风险点:" + innerDangerVo.getRiskPointName() + "】隐患处理流程" + "——>" + innerDangerVo.getHiddenDangerName(); String processName = "[" + userName + "] 发起 " + "【风险点:" + innerDangerVo.getRiskPointName() + "】隐患处理流程" + "——>" + innerDangerEntity.getHiddenDangerName();
// 开启新的隐患处理流程 // 开启新的隐患处理流程
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(innerDangerVo, DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(innerDangerVo, DateUtil.PATTERN_DATETIME), Map.class);
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(HIDDEN_DANGER_CHECK, innerDangerVo.getId().toString(), processName, variable); R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(dictValue, innerDangerVo.getId().toString(), processName, variable);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (!result.isSuccess()) {
innerDangerEntity.setIsNormal(false); innerDangerEntity.setIsNormal(false);
innerDangerEntity.setRemark(JSONObject.toJSONString(variable)); innerDangerEntity.setRemark(JSONObject.toJSONString(variable));
this.baseMapper.updateById(innerDangerEntity); this.baseMapper.updateById(innerDangerVo);
log.error("隐患处理流程开启失败,错误描述 : {}", result); log.error("隐患处理流程开启失败,错误描述 : {}", result);
R r=new R(); R r=new R();
r.setCode(result.getCode()); r.setCode(result.getCode());

Loading…
Cancel
Save