Browse Source

新增:工作流补偿机制

zhongwei
ty 5 months ago
parent
commit
8be8ed37d3
  1. 38
      hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java
  2. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmHandleFlowEntity.java
  3. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java
  4. 3
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java
  5. 3
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java
  6. 4
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java
  7. 66
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java
  8. 82
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java
  9. 40
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java
  10. 1
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/controller/TicketInfoEvaluateController.java
  11. 72
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java
  12. 113
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  13. 155
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  14. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java

38
hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java

@ -0,0 +1,38 @@
package com.hnac.hzims.common.flow;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.api.R;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:39
*/
public interface StartProcessService {
/**
* 业务保存相关方法
* @param entity
* @return
*/
String saveEntity(String entity);
/**
* 启动工作流流程
* @param entity
* @param dictValue
* @return
*/
void startProcess(String entity, String dictValue);
// /**
// * 补偿工作流流程
// * @param response
// */
// Boolean compensation(ProcessWorkFlowRes ponse response);
}

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmHandleFlowEntity.java

@ -101,4 +101,6 @@ public class AlarmHandleFlowEntity extends BaseEntity {
private String approvalUserName; private String approvalUserName;
@ApiModelProperty("创建机构名称") @ApiModelProperty("创建机构名称")
private String createDeptName; private String createDeptName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
} }

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java

@ -296,4 +296,7 @@ public class InnerDangerEntity extends TenantEntity implements Serializable {
private Date conclusionTime; private Date conclusionTime;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
} }

3
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java

@ -103,4 +103,7 @@ public class WorkTaskEntity extends TenantEntity {
@ApiModelProperty(value = "创建机构名称") @ApiModelProperty(value = "创建机构名称")
private String deptName; private String deptName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
} }

3
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java

@ -159,6 +159,9 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab
@ApiModelProperty("许可人名称") @ApiModelProperty("许可人名称")
private String guardianName; private String guardianName;
@ApiModelProperty("是否运行正常")
private Boolean isNormal;
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty("监护人确认结果:approved-确认,rejected-作废") @ApiModelProperty("监护人确认结果:approved-确认,rejected-作废")
private String verifyResult; private String verifyResult;

4
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java

@ -509,4 +509,8 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
@ApiModelProperty("修改人名称") @ApiModelProperty("修改人名称")
private String updateUserName; private String updateUserName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
} }

66
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java

@ -12,8 +12,10 @@ import com.hnac.hzims.alarm.show.service.AlarmHandleDetailService;
import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmHandleService;
import com.hnac.hzims.alarm.show.vo.HandleQueryVo; import com.hnac.hzims.alarm.show.vo.HandleQueryVo;
import com.hnac.hzims.alarm.show.wrapper.HandleWrapper; import com.hnac.hzims.alarm.show.wrapper.HandleWrapper;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient; import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient;
import com.hnac.hzims.safeproduct.vo.InnerDangerVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -42,7 +44,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, AlarmHandleEntity> implements AlarmHandleService { public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, AlarmHandleEntity> implements AlarmHandleService , StartProcessService {
private final AlarmHandleDetailService detailService; private final AlarmHandleDetailService detailService;
@ -67,33 +69,44 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
*/ */
@Override @Override
public boolean execute(AlarmHandleFlowEntity param) { public boolean execute(AlarmHandleFlowEntity param) {
saveEntity(JSONObject.toJSONString(param));
//开启流程
return true;
}
@Override
public String saveEntity(String entity) {
AlarmHandleFlowEntity param= JSONObject.parseObject(entity, AlarmHandleFlowEntity.class);
//保存实体类
Long way = param.getHandleWay(); Long way = param.getHandleWay();
if (!AlarmHandleConstant.HANDLE_WAY.contains(way)) { if (!AlarmHandleConstant.HANDLE_WAY.contains(way)) {
throw new ServiceException("无效处理!"); throw new ServiceException("无效处理!");
} }
// 处理记录 // 处理记录
AlarmHandleEntity entity = new AlarmHandleEntity(); AlarmHandleEntity alarmHandleEntity = new AlarmHandleEntity();
entity.setAlarmId(param.getAlarmId()); alarmHandleEntity.setAlarmId(param.getAlarmId());
entity.setType(param.getType()); alarmHandleEntity.setType(param.getType());
// entity.setDetailId(detail.getId()); // entity.setDetailId(detail.getId());
entity.setAlarmTime(param.getAlarmTime()); alarmHandleEntity.setAlarmTime(param.getAlarmTime());
entity.setAlarmContent(param.getAlarmContent()); alarmHandleEntity.setAlarmContent(param.getAlarmContent());
entity.setHandleWay(param.getHandleWay()); alarmHandleEntity.setHandleWay(param.getHandleWay());
entity.setStationCode(param.getStationCode()); alarmHandleEntity.setStationCode(param.getStationCode());
entity.setAlarmType(param.getAlarmType()); alarmHandleEntity.setAlarmType(param.getAlarmType());
// entity.setAccessId(param.getAccessId()); // entity.setAccessId(param.getAccessId());
// entity.setPhenomenonId(param.getPhenomenonId()); // entity.setPhenomenonId(param.getPhenomenonId());
entity.setHandleUser(param.getHandleUser()); alarmHandleEntity.setHandleUser(param.getHandleUser());
entity.setDelayTime(param.getDelayTime()); alarmHandleEntity.setDelayTime(param.getDelayTime());
entity.setDelayCause(param.getDelayCause()); alarmHandleEntity.setDelayCause(param.getDelayCause());
entity.setFalseAlarmDesc(param.getFalseAlarmDesc()); alarmHandleEntity.setFalseAlarmDesc(param.getFalseAlarmDesc());
entity.setFilePath(param.getFilePath()); alarmHandleEntity.setFilePath(param.getFilePath());
if (StringUtils.isNotBlank(AuthUtil.getUserName())){ if (StringUtils.isNotBlank(AuthUtil.getUserName())){
entity.setCreateUserName(AuthUtil.getUserName()); alarmHandleEntity.setCreateUserName(AuthUtil.getUserName());
param.setCreateUserName(AuthUtil.getUserName()); param.setCreateUserName(AuthUtil.getUserName());
entity.setCreateDeptName(param.getCreateDeptName()); alarmHandleEntity.setCreateDeptName(param.getCreateDeptName());
} }
this.save(entity); this.save(alarmHandleEntity);
//修改fdp对应得数据
// 预警 // 预警
if(AlarmHandleConstant.EARLY_WARNING.equals(param.getAlarmType())){ if(AlarmHandleConstant.EARLY_WARNING.equals(param.getAlarmType())){
Map<String, Object> map=new HashMap<>(); Map<String, Object> map=new HashMap<>();
@ -114,8 +127,13 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
// throw new ServiceException("修改告警状态异常,请稍后重试!"); // throw new ServiceException("修改告警状态异常,请稍后重试!");
} }
} }
//开启流程 return JSONObject.toJSONString(alarmHandleEntity);
if (AlarmHandleConstant.HANDLE.contains(way)) { }
@Override
public void startProcess(String entity, String dictValue) {
AlarmHandleFlowEntity param= JSONObject.parseObject(entity, AlarmHandleFlowEntity.class);
if (AlarmHandleConstant.HANDLE.contains(param.getHandleWay())) {
alarmHandleFlowMapper.insert(param); alarmHandleFlowMapper.insert(param);
// 流程名称 // 流程名称
String processName = "[" + AuthUtil.getUserName() + "] 发起 " + "【" + param.getAlarmContent() + "】告警处理流程"; String processName = "[" + AuthUtil.getUserName() + "] 发起 " + "【" + param.getAlarmContent() + "】告警处理流程";
@ -125,15 +143,16 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(AlarmHandleConstant.dealAlarm, businessKey, processName, variable); R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(AlarmHandleConstant.dealAlarm, businessKey, processName, variable);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (!result.isSuccess()) {
param.setIsNormal(false);
alarmHandleFlowMapper.updateById(param);
log.error("缺陷流程开启失败,错误描述 : " + result.getMsg()); log.error("缺陷流程开启失败,错误描述 : " + result.getMsg());
throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg()); throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg());
}else {
param.setProcessInstanceId(result.getData().getProcessInstanceId());
alarmHandleFlowMapper.updateById(param);
} }
param.setProcessInstanceId(result.getData().getProcessInstanceId());
alarmHandleFlowMapper.updateById(param);
} }
return true;
} }
/** /**
* 分页 * 分页
* @param query * @param query
@ -190,4 +209,5 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
return this.baseMapper.incompleteContent(end,stations); return this.baseMapper.incompleteContent(end,stations);
} }
} }

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

@ -1,5 +1,6 @@
package com.hnac.hzims.safeproduct.flow.service.impl; package com.hnac.hzims.safeproduct.flow.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.safeproduct.dto.InnerDangerDTO; import com.hnac.hzims.safeproduct.dto.InnerDangerDTO;
@ -17,6 +19,7 @@ import com.hnac.hzims.safeproduct.entity.InnerDangerEntity;
import com.hnac.hzims.safeproduct.flow.mapper.InnerDangerMapper; import com.hnac.hzims.safeproduct.flow.mapper.InnerDangerMapper;
import com.hnac.hzims.safeproduct.flow.service.IInnerDangerFlowService; import com.hnac.hzims.safeproduct.flow.service.IInnerDangerFlowService;
import com.hnac.hzims.safeproduct.vo.*; import com.hnac.hzims.safeproduct.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
@ -46,7 +49,8 @@ import static com.hnac.hzims.safeproduct.Constants.HIDDEN_DANGER_CHECK;
* Created by ty 2023/9/18 10:16 * Created by ty 2023/9/18 10:16
**/ **/
@Service @Service
public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, InnerDangerEntity> implements IInnerDangerFlowService { @Slf4j
public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, InnerDangerEntity> implements IInnerDangerFlowService , StartProcessService {
@Autowired @Autowired
private ISysClient sysClient; private ISysClient sysClient;
@ -71,65 +75,74 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
public R startHiddenDanger(InnerDangerVo hiddenDangerVo) { public R startHiddenDanger(InnerDangerVo hiddenDangerVo) {
InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
BeanUtil.copy(hiddenDangerVo, innerDangerEntity); BeanUtil.copy(hiddenDangerVo, innerDangerEntity);
if (!saveHiddenDanger(innerDangerEntity)) { saveEntity(JSONObject.toJSONString(innerDangerEntity));
throw new ServiceException("隐患保存失败,请稍后重试!");
}
InnerDangerEntity saveEntity = this.getOne(new LambdaQueryWrapper<InnerDangerEntity>() {{ InnerDangerEntity saveEntity = this.getOne(new LambdaQueryWrapper<InnerDangerEntity>() {{
eq(InnerDangerEntity::getCode, innerDangerEntity.getCode()); eq(InnerDangerEntity::getCode, innerDangerEntity.getCode());
last("limit 1"); last("limit 1");
}}); }});
InnerDangerEntity res = this.startHiddenDangerFlow(saveEntity, hiddenDangerVo); BeanUtil.copy(saveEntity,hiddenDangerVo);
return R.data(res); this.startProcess(JSONObject.toJSONString(hiddenDangerVo), HIDDEN_DANGER_CHECK);
return R.success("隐患流程发起成功");
} }
@Override
private boolean saveHiddenDanger(InnerDangerEntity entity) { public String saveEntity(String entity) {
if (Func.isEmpty(entity.getCode())) { InnerDangerEntity innerDangerEntity= JSONObject.parseObject(entity, InnerDangerEntity.class);
entity.setCode(UUID.randomUUID().toString()); if (Func.isEmpty(innerDangerEntity.getCode())) {
innerDangerEntity.setCode(UUID.randomUUID().toString());
} }
// 隐患发起人 : 当前用户Id // 隐患发起人 : 当前用户Id
if (Func.isEmpty(entity.getRegistrant())) { if (Func.isEmpty(innerDangerEntity.getRegistrant())) {
entity.setRegistrant(AuthUtil.getUserId()); innerDangerEntity.setRegistrant(AuthUtil.getUserId());
entity.setRegistrantName(AuthUtil.getUserName()); innerDangerEntity.setRegistrantName(AuthUtil.getUserName());
} }
// 隐患发起时间 // 隐患发起时间
entity.setRegistrantTime(new Date()); innerDangerEntity.setRegistrantTime(new Date());
// 隐患发起时间 // 隐患发起时间
entity.setUpdateTime(new Date()); innerDangerEntity.setUpdateTime(new Date());
entity.setCreateUser(AuthUtil.getUserId()); innerDangerEntity.setCreateUser(AuthUtil.getUserId());
entity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); innerDangerEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
if (Func.isEmpty(entity.getHiddenDangerDept())) { if (Func.isEmpty(innerDangerEntity.getHiddenDangerDept())) {
return false; throw new ServiceException("隐患保存失败,请检查好填写信息后重试!");
} }
if (Func.isEmpty(entity.getHiddenDangerDeptName())) { if (Func.isEmpty(innerDangerEntity.getHiddenDangerDeptName())) {
R<String> deptNameR = sysClient.getDeptName(entity.getHiddenDangerDept()); R<String> deptNameR = sysClient.getDeptName(innerDangerEntity.getHiddenDangerDept());
if (deptNameR.isSuccess() && StringUtils.isNotEmpty(deptNameR.getData())) { if (deptNameR.isSuccess() && StringUtils.isNotEmpty(deptNameR.getData())) {
entity.setHiddenDangerDeptName(deptNameR.getData()); innerDangerEntity.setHiddenDangerDeptName(deptNameR.getData());
} }
} }
return this.save(entity); boolean save = this.save(innerDangerEntity);
if (!save) {
throw new ServiceException("隐患保存失败,请稍后重试!");
}
return JSON.toJSONString(innerDangerEntity);
} }
private InnerDangerEntity startHiddenDangerFlow(InnerDangerEntity entity,InnerDangerVo hiddenDangerVo) { @Override
BeanUtil.copy(entity,hiddenDangerVo); public void startProcess(String entity, String dictValue) {
InnerDangerVo innerDangerVo = JSONObject.parseObject(entity, InnerDangerVo.class);
InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
BeanUtil.copy(innerDangerVo, innerDangerEntity);
// 隐患处理名字 // 隐患处理名字
String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse(""); String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse("");
// 流程名称 // 流程名称
String processName = "[" + userName + "] 发起 " + "【风险点:" + entity.getRiskPointName() + "】隐患处理流程" + "——>" + entity.getHiddenDangerName(); String processName = "[" + userName + "] 发起 " + "【风险点:" + innerDangerVo.getRiskPointName() + "】隐患处理流程" + "——>" + innerDangerVo.getHiddenDangerName();
// 开启新的隐患处理流程 // 开启新的隐患处理流程
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(hiddenDangerVo, 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, entity.getId().toString(), processName, variable); R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(HIDDEN_DANGER_CHECK, innerDangerVo.getId().toString(), processName, variable);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (!result.isSuccess()) {
innerDangerEntity.setIsNormal(false);
this.baseMapper.updateById(innerDangerEntity);
log.error("隐患处理流程开启失败,错误描述 : {}", result);
throw new ServiceException("隐患处理流程开启失败,错误描述 : " + result.getMsg()); throw new ServiceException("隐患处理流程开启失败,错误描述 : " + result.getMsg());
} else {
// 关联流程唯一键
innerDangerEntity.setProcessInstanceId(result.getData().getProcessInstanceId());
innerDangerEntity.setTaskId(result.getData().getTaskId());
this.baseMapper.updateById(innerDangerEntity);
} }
// 关联流程唯一键
entity.setProcessInstanceId(result.getData().getProcessInstanceId());
entity.setTaskId(result.getData().getTaskId());
this.baseMapper.updateById(entity);
return entity;
} }
/** /**
* @param processWorkFlowResponse * @param processWorkFlowResponse
*/ */
@ -392,4 +405,5 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
return innerDangerEntities; return innerDangerEntities;
} }
} }

40
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java

@ -1,9 +1,12 @@
package com.hnac.hzims.safeproduct.risk.service.impl; package com.hnac.hzims.safeproduct.risk.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.safeproduct.entity.InnerDangerEntity; import com.hnac.hzims.safeproduct.entity.InnerDangerEntity;
import com.hnac.hzims.safeproduct.flow.service.IInnerDangerFlowService; import com.hnac.hzims.safeproduct.flow.service.IInnerDangerFlowService;
@ -38,7 +41,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
@Service @Service
public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardTask> implements HazardTaskService { public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardTask> implements HazardTaskService , StartProcessService {
private final HazardWorkService workService; private final HazardWorkService workService;
@ -64,6 +67,16 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean startProcess(HazardRiskProcessDTO process) { public boolean startProcess(HazardRiskProcessDTO process) {
//保存业务表单
saveEntity(JSONObject.toJSONString(process));
//开启动作流
this.startProcess(JSON.toJSONString(process),HazardRiskConstants.HAZARD_RISK_KEY);
return true;
}
@Override
public String saveEntity(String entity) {
HazardRiskProcessDTO process= JSONObject.parseObject(entity, HazardRiskProcessDTO.class);
// 查询作业区域是否存在任务流程 // 查询作业区域是否存在任务流程
HazardTask task = this.getOne(Wrappers.<HazardTask>lambdaQuery() HazardTask task = this.getOne(Wrappers.<HazardTask>lambdaQuery()
.eq(HazardTask::getWorkId,process.getWorkId()) .eq(HazardTask::getWorkId,process.getWorkId())
@ -92,10 +105,8 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
process.setActStartTime(new Date()); process.setActStartTime(new Date());
process.setStationCode(hazardWork.getStationCode()); process.setStationCode(hazardWork.getStationCode());
process.setStationName(hazardWork.getStationName()); process.setStationName(hazardWork.getStationName());
// 保存任务 // 保存任务
super.save(process); super.save(process);
// 生成风险评估记录 // 生成风险评估记录
process.setEstimates(sources.stream().map(source->{ process.setEstimates(sources.stream().map(source->{
HazardEstimateVo estimate = new HazardEstimateVo(); HazardEstimateVo estimate = new HazardEstimateVo();
@ -115,12 +126,26 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
return estimate; return estimate;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
hazardEstimateService.saveBatch(process.getEstimates()); hazardEstimateService.saveBatch(process.getEstimates());
return JSON.toJSONString(process);
// 发起流程
this.start(process);
return true;
} }
@Override
public void startProcess(String entity, String dictValue) {
HazardRiskProcessDTO process= JSONObject.parseObject(entity, HazardRiskProcessDTO.class);
// 查询作业区域负责人
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class);
variables.put(HazardRiskConstants.TROUBLE, TaskUtil.getTaskUser(String.valueOf(process.getHead())));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey(HazardRiskConstants.HAZARD_RISK_KEY,String.valueOf(process.getId())), process.getTaskName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
process.setProcessInstanceId(flow.getProcessInstanceId());
this.updateById(process);
} else {
throw new ServiceException("开启检修计划流程失败,code=" + result.getCode());
}
}
/** /**
* 流程发起 * 流程发起
@ -374,4 +399,5 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
} }
return riskInner; return riskInner;
} }
} }

1
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/controller/TicketInfoEvaluateController.java

@ -1,5 +1,6 @@
package com.hnac.hzims.ticket.allTicket.controller; package com.hnac.hzims.ticket.allTicket.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.ticket.allTicket.dto.TicketInfoEvaluateDto; import com.hnac.hzims.ticket.allTicket.dto.TicketInfoEvaluateDto;

72
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java

@ -1,5 +1,5 @@
package com.hnac.hzims.ticket.repair.service.impl; package com.hnac.hzims.ticket.repair.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.repair.constants.WorkTaskConstants; import com.hnac.hzims.ticket.repair.constants.WorkTaskConstants;
import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity;
@ -53,7 +54,7 @@ import java.util.*;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEntity> implements IWorkTaskService { public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEntity> implements IWorkTaskService , StartProcessService {
private final IWorkTicketInfoService workTicketInfoService; private final IWorkTicketInfoService workTicketInfoService;
@ -80,42 +81,15 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
@Override @Override
public boolean start(WorkTaskVO workTask) { public boolean start(WorkTaskVO workTask) {
// 步骤1.保存工作任务单 // 步骤1.保存工作任务单
this.saveWorkTask(workTask); this.saveEntity(JSON.toJSONString(workTask));
// 步骤2.开启检修计划流程 // 步骤2.开启检修计划流程
this.startProcess(workTask); this.startProcess(JSON.toJSONString(workTask),"work_task");
return true; return true;
} }
private void startProcess(WorkTaskVO workTask) { @Override
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); public String saveEntity(String entity) {
variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead()))); WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class);
// 班组成员
String[] member = workTask.getMember().split(",");
for(int i = 1;i <= 5 ; i++){
if(i > member.length){
variables.put("duty" + i, "");
}else{
variables.put("duty" + i, TaskUtil.getTaskUser(member[i-1]));
}
}
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("work_task", FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables);
log.error("work_task_start_process_result :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
workTask.setProcessInstanceId(flow.getProcessInstanceId());
this.updateById(workTask);
} else {
throw new ServiceException("开启工作任务计划流程失败,code=" + result.getCode());
}
}
/**
* 保存工作任务单
* @param workTask
*/
private void saveWorkTask(WorkTaskVO workTask) {
// 查询当月最序号记录 // 查询当月最序号记录
WorkTaskEntity max = this.getOne(Wrappers.<WorkTaskEntity>lambdaQuery() WorkTaskEntity max = this.getOne(Wrappers.<WorkTaskEntity>lambdaQuery()
.like(WorkTaskEntity::getCreateTime,DateUtil.format(new Date(),"yyyy-MM")) .like(WorkTaskEntity::getCreateTime,DateUtil.format(new Date(),"yyyy-MM"))
@ -143,8 +117,38 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
workTask.setDeptName(result.getData().getDeptName()); workTask.setDeptName(result.getData().getDeptName());
} }
this.save(workTask); this.save(workTask);
return JSON.toJSONString(workTask);
}
@Override
public void startProcess(String entity, String dictValue) {
WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class);
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class);
variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead())));
// 班组成员
String[] member = workTask.getMember().split(",");
for(int i = 1;i <= 5 ; i++){
if(i > member.length){
variables.put("duty" + i, "");
}else{
variables.put("duty" + i, TaskUtil.getTaskUser(member[i-1]));
}
}
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables);
log.error("work_task_start_process_result :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
workTask.setProcessInstanceId(flow.getProcessInstanceId());
this.updateById(workTask);
} else {
workTask.setIsNormal(false);
this.updateById(workTask);
throw new ServiceException("开启工作任务计划流程失败,code=" + result.getCode());
}
} }
/** /**
* 工作任务监听 - 业务处理 * 工作任务监听 - 业务处理
* @param processWorkFlowResponse * @param processWorkFlowResponse

113
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
@ -32,6 +33,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
@ -72,7 +74,7 @@ import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OPERA
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class OperationTicketServiceImpl implements OperationTicketService { public class OperationTicketServiceImpl implements OperationTicketService , StartProcessService {
private final IStandardTicketInfoService standardTicketInfoService; private final IStandardTicketInfoService standardTicketInfoService;
@ -101,6 +103,20 @@ public class OperationTicketServiceImpl implements OperationTicketService {
@Override @Override
public void startUp(StandardTicketInfoVo standardTicketInfoVo) { public void startUp(StandardTicketInfoVo standardTicketInfoVo) {
log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法"); log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法");
//保存操作票
String standardTicketInfoVoBySave = this.saveEntity(JSONObject.toJSONString(standardTicketInfoVo));
//查询流程对应value
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY);
log.info("查询第操作票值: {}", dictValue);
if (StringUtils.isBlank(dictValue)) {
throw new ServiceException("服务器异常,请联系管理员");
}
//启动流程
this.startProcess(standardTicketInfoVoBySave, dictValue);
}
@Override
public String saveEntity(String entity) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
if (standardTicketInfoVo.getSignage() == null) { if (standardTicketInfoVo.getSignage() == null) {
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); throw new ServiceException("票据抬头未配置,请您到站点管理配置");
} }
@ -126,7 +142,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); throw new ServiceException("票据抬头未配置,请您到站点管理配置");
} }
//signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); //signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
standardTicketInfoVo.setSignage(signage); standardTicketInfoVo.setSignage(signage);
standardTicketInfoVo.setSignageCode(station.getCode()); standardTicketInfoVo.setSignageCode(station.getCode());
//2. 获取编码 //2. 获取编码
@ -137,18 +152,43 @@ public class OperationTicketServiceImpl implements OperationTicketService {
} }
standardTicketInfoVo.setCode(code); standardTicketInfoVo.setCode(code);
//3. 保存操作对象 //3. 保存操作对象
this.saveStandardTicketInfo(standardTicketInfoVo); StandardTicketInfoEntity standardTicketInfo = getStandardTicketInfoEntity(standardTicketInfoVo);
boolean save = standardTicketInfoService.save(standardTicketInfo);
if (!save) {
throw new ServiceException("Save failed");
}
BeanUtils.copyProperties(standardTicketInfo, standardTicketInfoVo);
//5. 保存安全措施 //5. 保存安全措施
List<StandardTicketMeasureVo> standardTicketInfoVos = this.saveStandardTicketMeasure(this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo)); List<StandardTicketMeasureVo> standardTicketInfoVos = this.saveStandardTicketMeasure(this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo));
standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos);
//6. 查询第操作票值 log.info("保存操作对象 :{}", standardTicketInfoVo);
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY); return JSON.toJSONString(standardTicketInfoVo);
log.info("查询第操作票值: {}", dictValue); }
if (StringUtils.isBlank(dictValue)) {
throw new ServiceException("服务器异常,请联系管理员");
@Override
public void startProcess(String entity, String dictValue) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo);
Instant start = Instant.now();
Map<String, Object> params = new HashMap<>(4);
params.put("standardTicketInfoVo", standardTicketInfoVo);
params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params);
if (!processInstanceContainNameByKey.isSuccess()) {
standardTicketInfoEntity.setIsNormal(false);
standardTicketInfoService.save(standardTicketInfoEntity);
log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限...");
} }
// 7.启动流程 Duration between = Duration.between(start, Instant.now());
this.startProcess(standardTicketInfoVo, dictValue); log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
} }
/** /**
@ -292,30 +332,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
} }
} }
/**
* 启动流程
*
* @param standardTicketInfoVo
* @param dictValue
*/
private void startProcess(StandardTicketInfoVo standardTicketInfoVo, String dictValue) {
Instant start = Instant.now();
Map<String, Object> params = new HashMap<>(4);
params.put("standardTicketInfoVo", standardTicketInfoVo);
params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params);
if (!processInstanceContainNameByKey.isSuccess()) {
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限...");
}
Duration between = Duration.between(start, Instant.now());
log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
}
/** /**
@ -353,7 +369,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
if (!save) { if (!save) {
throw new ServiceException("Save failed"); throw new ServiceException("Save failed");
} }
return measureEntityList.stream().map(item -> { return measureEntityList.stream().map(item -> {
StandardTicketMeasureVo standardTicketMeasureVo = new StandardTicketMeasureVo(); StandardTicketMeasureVo standardTicketMeasureVo = new StandardTicketMeasureVo();
BeanUtils.copyProperties(item, standardTicketMeasureVo); BeanUtils.copyProperties(item, standardTicketMeasureVo);
@ -361,21 +376,16 @@ public class OperationTicketServiceImpl implements OperationTicketService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/**
* 保存工作对象 private static StandardTicketInfoEntity getStandardTicketInfoEntity(StandardTicketInfoVo standardTicketInfoVo) {
*
* @param standardTicketInfoVo
* @return
*/
private void saveStandardTicketInfo(StandardTicketInfoVo standardTicketInfoVo) {
StandardTicketInfoEntity standardTicketInfo = new StandardTicketInfoEntity(); StandardTicketInfoEntity standardTicketInfo = new StandardTicketInfoEntity();
BeanUtils.copyProperties(standardTicketInfoVo, standardTicketInfo); BeanUtils.copyProperties(standardTicketInfoVo, standardTicketInfo);
//保存前保存对应用户得姓名 //保存前保存对应用户得姓名
BladeUser user = AuthUtil.getUser(); BladeUser user = AuthUtil.getUser();
if (ObjectUtil.isNotEmpty(user.getUserName())){ if (ObjectUtil.isNotEmpty(user.getUserName())){
standardTicketInfo.setCreateUserName(user.getUserName()); standardTicketInfo.setCreateUserName(user.getUserName());
standardTicketInfo.setUpdateUserName(user.getUserName()); standardTicketInfo.setUpdateUserName(user.getUserName());
} }
/*发令人、受令人、负责人、监护人*/ /*发令人、受令人、负责人、监护人*/
if(ObjectUtil.isNotEmpty(standardTicketInfoVo.getIssueOrderPerson())) { if(ObjectUtil.isNotEmpty(standardTicketInfoVo.getIssueOrderPerson())) {
@ -397,12 +407,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
standardTicketInfo.setGuardianName(guardian.getRealName()); standardTicketInfo.setGuardianName(guardian.getRealName());
} }
} }
return standardTicketInfo;
boolean save = standardTicketInfoService.save(standardTicketInfo);
if (!save) {
throw new ServiceException("Save failed");
}
BeanUtils.copyProperties(standardTicketInfo, standardTicketInfoVo);
} }

155
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
@ -27,6 +28,7 @@ import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import com.hnac.hzims.ticket.twoTicket.utils.WordHelper; import com.hnac.hzims.ticket.twoTicket.utils.WordHelper;
import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils; import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo;
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo; import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import com.hnac.hzims.ticket.utils.MergeDocUtils; import com.hnac.hzims.ticket.utils.MergeDocUtils;
@ -87,7 +89,7 @@ import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.MACHI
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TicketProcessServiceImpl implements TicketProcessService { public class TicketProcessServiceImpl implements TicketProcessService, StartProcessService {
private final IFlowClient flowClient; private final IFlowClient flowClient;
@ -159,12 +161,31 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* *
* @param workTicketVo * @param workTicketVo
*/ */
@SneakyThrows // @SneakyThrows
@Override @Override
@Transactional @Transactional
public Long startUp(WorkTicketVo workTicketVo) { public Long startUp(WorkTicketVo workTicketVo) {
log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); log.info("ticket:start:request",JSON.toJSONString(workTicketVo));
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法");
//保存操作票
String saveEntity = saveEntity(JSONObject.toJSONString(workTicketVo));
workTicketVo= JSONObject.parseObject(saveEntity, WorkTicketVo.class);
//查询第工作票值
String dictValue = getDictValue(workTicketVo);
log.info("查询第工作票值: {}", dictValue);
if (StringUtils.isBlank(dictValue)) {
throw new ServiceException("服务器异常,请联系管理员");
}
//开启动作流
this.startProcess(saveEntity,dictValue);
// //处理任务--老版本业务要求,2024/07/05弃用
// this.returnTicket(workTicketVo);
return workTicketVo.getWorkTicket().getId();
}
@Override
public String saveEntity(String entity) {
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class);
if (workTicketVo.getWorkTicket().getSignage() == null) { if (workTicketVo.getWorkTicket().getSignage() == null) {
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); throw new ServiceException("票据抬头未配置,请您到站点管理配置");
} }
@ -200,27 +221,63 @@ public class TicketProcessServiceImpl implements TicketProcessService {
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");
} }
workTicketVo.getWorkTicket().setCode(code); workTicketVo.getWorkTicket().setCode(code);
//3 .保存工作对象 //保存工作对象
log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket()));
this.saveWorkTicketInfo(workTicketVo.getWorkTicket()); WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket());
//4. 保存安全措施 boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误");
}
//保存安全措施
this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket()); this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket());
//5. 保存工作任务 //保存工作任务
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket());
//6. 查询第工作票值 return JSONObject.toJSONString(workTicketVo);
String dictValue = getDictValue(workTicketVo); }
log.info("查询第工作票值: {}", dictValue);
if (StringUtils.isBlank(dictValue)) { @Override
throw new ServiceException("服务器异常,请联系管理员"); public void startProcess(String entity, String dictValue) {
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class);
WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket());
workTicketVo.setWorkTicket(workTicket);
Instant start = Instant.now();
//若为线下工作票 则无需开启工作流
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus();
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) {
return;
}
Map<String, Object> params = new HashMap<>(4);
params.put("workTicketVo", workTicketVo);
//获取当前登录人
Long userId = AuthUtil.getUserId();
//负责人
Long principal = workTicketVo.getWorkTicket().getPrincipal();
if ("8".equals(workTicketVo.getWorkTicket().getType()) && principal.longValue() != userId.longValue()) {
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal());
} }
//7. 开启动作流 //已开启流程
this.dealProcess(dictValue, workTicketVo); R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params);
//8. 处理任务 log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess());
this.returnTicket(workTicketVo); if (!processInstanceContainNameByKey.isSuccess()) {
//保存流程开始失败情况
workTicket.setIsNormal(false);
boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误");
}
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("流程开启失败,请检查流程和用户权限后重试!");
}
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey);
Duration between = Duration.between(start, Instant.now());
return workTicketVo.getWorkTicket().getId(); log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
} }
/** /**
* 验证是走那种工作票流程默认走第一种工作票 * 验证是走那种工作票流程默认走第一种工作票
* *
@ -707,54 +764,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} }
} }
/**
* 开启流程
*
* @param newFirstWorkTicketFlowKey
* @param workTicketVo
*/
public void dealProcess(String newFirstWorkTicketFlowKey, WorkTicketVo workTicketVo) {
Instant start = Instant.now();
//若为线下工作票 则无需开启工作流
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus();
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) {
return;
}
//log.info("租户Id:{}", AuthUtil.getTenantId());
//log.info("用户部门Id: {}", AuthUtil.getUser().getDeptId());
//log.info("用户Id: {}", AuthUtil.getUserId());
//获取签发人角色下的人员
// R<List<User>> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.parseLong(AuthUtil.getUser().getDeptId()), TicketConstants.SIGNER_ROLE);
// if (!listR.isSuccess() || CollectionUtil.isEmpty(listR.getData())) {
// throw new ServiceException("工作票签发人角色下未查询到相关人员");
// }
Map<String, Object> params = new HashMap<>(4);
params.put("workTicketVo", workTicketVo);
//获取当前登录人
Long userId = AuthUtil.getUserId();
//负责人
Long principal = workTicketVo.getWorkTicket().getPrincipal();
if ("8".equals(workTicketVo.getWorkTicket().getType()) && principal.longValue() != userId.longValue()) {
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal());
}
//已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(newFirstWorkTicketFlowKey, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params);
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess());
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) {
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限...");
}
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey);
Duration between = Duration.between(start, Instant.now());
log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
}
/** /**
* 保存工作任务 * 保存工作任务
* *
@ -810,7 +819,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param workTicket * @param workTicket
* @return * @return
*/ */
public WorkTicketInfoEntity saveWorkTicketInfo(WorkTicketInfoEntity workTicket) { public WorkTicketInfoEntity getWorkTicketInfo(WorkTicketInfoEntity workTicket) {
workTicket.setStatus(Func.isEmpty(workTicket.getPrincipal()) || Func.isEmpty(workTicket.getClassGroupMembers()) ? WorkTicketConstants.FirstWorkTicketStatusEnum.OFFLINE_OPERATE.getStatus() : WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus()); workTicket.setStatus(Func.isEmpty(workTicket.getPrincipal()) || Func.isEmpty(workTicket.getClassGroupMembers()) ? WorkTicketConstants.FirstWorkTicketStatusEnum.OFFLINE_OPERATE.getStatus() : WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus());
//班组成员名称 //班组成员名称
String byclassGroupMembers = getByClassGroupMembers(workTicket); String byclassGroupMembers = getByClassGroupMembers(workTicket);
@ -826,11 +835,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicket.setIsHazard(false); workTicket.setIsHazard(false);
workTicket.setIsRailway(false); workTicket.setIsRailway(false);
workTicket.setIsLimited(false); workTicket.setIsLimited(false);
boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误");
}
return workTicket; return workTicket;
} }
@ -1392,7 +1396,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param workTicketVo 工作票 * @param workTicketVo 工作票
* @return 工作流实例ID * @return 工作流实例ID
*/ */
private String startOfflineTicketProcess(WorkTicketVo workTicketVo) { public String startOfflineTicketProcess(WorkTicketVo workTicketVo) {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
workTicketVo.setWorkTicket(workTicket); workTicketVo.setWorkTicket(workTicket);
@ -1400,6 +1404,13 @@ public class TicketProcessServiceImpl implements TicketProcessService {
R<BladeFlow> flowR = R<BladeFlow> flowR =
flowClient.startProcessInstanceContainNameByKey("offlineWorkTicket",String.valueOf(workTicket.getId()),workTicket.getWorkContent(), params); flowClient.startProcessInstanceContainNameByKey("offlineWorkTicket",String.valueOf(workTicket.getId()),workTicket.getWorkContent(), params);
Assert.isTrue(flowR.isSuccess(),() -> { Assert.isTrue(flowR.isSuccess(),() -> {
//保存流程开始失败情况
workTicket.setIsNormal(false);
boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误");
}
throw new ServiceException("开启工作流失败,请联系管理员"); throw new ServiceException("开启工作流失败,请联系管理员");
}); });
return flowR.getData().getProcessInstanceId(); return flowR.getData().getProcessInstanceId();

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java

@ -150,6 +150,9 @@ public class StandardTicketInfoVo extends TenantEntity {
@ApiModelProperty("许可人名称") @ApiModelProperty("许可人名称")
private String guardianName; private String guardianName;
@ApiModelProperty("是否运行正常")
private Boolean isNormal;
@ApiModelProperty("安全措施") @ApiModelProperty("安全措施")
private List<StandardTicketMeasureVo> standardTicketMeasureVos; private List<StandardTicketMeasureVo> standardTicketMeasureVos;
} }

Loading…
Cancel
Save