Browse Source

新增:工作流补偿机制

zhongwei
ty 5 months ago
parent
commit
69f0a7eea9
  1. 15
      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. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java
  4. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java
  5. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java
  6. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java
  7. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenanceTaskEntity.java
  8. 2
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java
  9. 22
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/CompensateProcessClientFallback.java
  10. 34
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ICompensateProcessClient.java
  11. 6
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/to/ProcessWorkFlowResponse.java
  12. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java
  13. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/entity/HazardTask.java
  14. 3
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java
  15. 3
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java
  16. 2
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java
  17. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/AlarmHandleController.java
  18. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java
  19. 8
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java
  20. 59
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java
  21. 4
      hzims-service/hzims-alarm/src/main/resources/db/3.0.0.sql
  22. 7
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java
  23. 41
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java
  24. 1
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java
  25. 7
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/impl/ProcessDictServiceImpl.java
  26. 122
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java
  27. 6
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java
  28. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java
  29. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java
  30. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java
  31. 125
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
  32. 113
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
  33. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java
  34. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/DefectCheckController.java
  35. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/OperDefectClient.java
  36. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java
  37. 132
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java
  38. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java
  39. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java
  40. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java
  41. 103
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java
  42. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java
  43. 50
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java
  44. 20
      hzims-service/operational/src/main/resources/db/3.0.1.sql
  45. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java
  46. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardTaskController.java
  47. 3
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardTaskService.java
  48. 73
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java
  49. 10
      hzims-service/safeproduct/src/main/resources/db/3.0.0.sql
  50. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java
  51. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java
  52. 16
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java
  53. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java
  54. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java
  55. 18
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  56. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  57. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java
  58. 20
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  59. 9
      hzims-service/ticket/src/main/resources/db/3.0.0.sql

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

@ -1,9 +1,7 @@
package com.hnac.hzims.common.flow; package com.hnac.hzims.common.flow;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.transaction.annotation.Transactional;
/** /**
* @Author dfy * @Author dfy
@ -27,12 +25,13 @@ public interface StartProcessService {
* @param dictValue * @param dictValue
* @return * @return
*/ */
void startProcess(String entity, String dictValue); R startProcess(String entity, String dictValue,String param);
// /** /**
// * 补偿工作流流程 * 补偿工作流流程
// * @param response * @param id
// */ * @return
// Boolean compensation(ProcessWorkFlowRes ponse response); */
R compensationProcess(String id);
} }

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

@ -103,4 +103,6 @@ public class AlarmHandleFlowEntity extends BaseEntity {
private String createDeptName; private String createDeptName;
@ApiModelProperty("工作流是否运行正常") @ApiModelProperty("工作流是否运行正常")
private Boolean isNormal; private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java

@ -168,4 +168,9 @@ public class OperAccessPlanEntity extends TenantEntity {
@ApiModelProperty(value = "创建用户名称") @ApiModelProperty(value = "创建用户名称")
private String updateUserName; private String updateUserName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
@ApiModelProperty(value = "流程参数")
private String remark;
} }

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java

@ -142,4 +142,10 @@ public class OperAccessTaskEntity extends TenantEntity {
@ApiModelProperty(value = "创建用户名称") @ApiModelProperty(value = "创建用户名称")
private Long constructionId; private Long constructionId;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java

@ -443,4 +443,7 @@ public class OperPhenomenonEntity extends TenantEntity {
private String createUserName; private String createUserName;
@ApiModelProperty("机构名称") @ApiModelProperty("机构名称")
private String deptName; private String deptName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
} }

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java

@ -107,4 +107,9 @@ public class ImsDutyRecEntity extends TenantEntity {
@TableField(exist=false) @TableField(exist=false)
private ImsDutyLogEntity imsDutyLogEntity; private ImsDutyLogEntity imsDutyLogEntity;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenanceTaskEntity.java

@ -229,4 +229,9 @@ public class OperMaintenanceTaskEntity extends TenantEntity {
@ApiModelProperty(value = "创建用户名称") @ApiModelProperty(value = "创建用户名称")
private String updateUserName; private String updateUserName;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

2
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java

@ -74,4 +74,6 @@ public class TicketProcessConstant {
* 风险排查标识 * 风险排查标识
*/ */
public static final String HAZARD_RISK = "hazard_risk"; public static final String HAZARD_RISK = "hazard_risk";
/**项目经理**/
public static final String PROJECT_MANAGER = "projectManager";
} }

22
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/CompensateProcessClientFallback.java

@ -0,0 +1,22 @@
package com.hnac.hzims.middle.process.fallback;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author ysj
*/
@Component
public class CompensateProcessClientFallback implements ICompensateProcessClient {
@Override
public R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) {
return R.fail("流程开启失败,请稍后重试");
}
}

34
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ICompensateProcessClient.java

@ -0,0 +1,34 @@
package com.hnac.hzims.middle.process.feign;
import com.hnac.hzims.middle.process.fallback.CompensateProcessClientFallback;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* @author ysj
*/
@FeignClient(
value = "hzims-middle",
fallback = CompensateProcessClientFallback.class
)
public interface ICompensateProcessClient {
String API_PREFIX = "/feign/compensateProcess";
String START_FLOW = API_PREFIX + "/startFlow";
@PostMapping(START_FLOW)
R startFlow(@RequestParam("userId") String userId,
@RequestParam("dictValue")String dictValue,
@RequestParam("taskId")String taskId,
@RequestParam("processName")String processName,
@RequestBody Map<String, Object> variables);
}

6
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/to/ProcessWorkFlowResponse.java

@ -60,4 +60,10 @@ public class ProcessWorkFlowResponse implements Serializable {
* 用户Id * 用户Id
*/ */
private String userId; private String userId;
private Integer code;
private String result;
private String deptId;
} }

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

@ -298,5 +298,8 @@ public class InnerDangerEntity extends TenantEntity implements Serializable {
@ApiModelProperty("工作流是否运行正常") @ApiModelProperty("工作流是否运行正常")
private Boolean isNormal; private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/entity/HazardTask.java

@ -52,4 +52,10 @@ public class HazardTask extends BaseEntity {
@ApiModelProperty(value = "流程步骤人员名称") @ApiModelProperty(value = "流程步骤人员名称")
private String nextStepOperator; private String nextStepOperator;
@ApiModelProperty("工作流是否运行正常")
private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

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

@ -106,4 +106,7 @@ public class WorkTaskEntity extends TenantEntity {
@ApiModelProperty("工作流是否运行正常") @ApiModelProperty("工作流是否运行正常")
private Boolean isNormal; private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

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

@ -161,6 +161,9 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab
@ApiModelProperty("是否运行正常") @ApiModelProperty("是否运行正常")
private Boolean isNormal; private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remarkFlow;
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty("监护人确认结果:approved-确认,rejected-作废") @ApiModelProperty("监护人确认结果:approved-确认,rejected-作废")

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

@ -512,5 +512,7 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
@ApiModelProperty("工作流是否运行正常") @ApiModelProperty("工作流是否运行正常")
private Boolean isNormal; private Boolean isNormal;
@ApiModelProperty("工作流启动参数")
private String remark;
} }

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/AlarmHandleController.java

@ -43,7 +43,7 @@ public class AlarmHandleController extends BladeController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "告警处理", notes = "传入AlarmHandleEntity") @ApiOperation(value = "告警处理", notes = "传入AlarmHandleEntity")
public R execute(@RequestBody AlarmHandleFlowEntity param) { public R execute(@RequestBody AlarmHandleFlowEntity param) {
return R.status(service.execute(param)); return service.execute(param);
} }
/** /**

3
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java

@ -8,6 +8,7 @@ import com.hnac.hzims.alarm.config.vo.AlarmHandleVo;
import com.hnac.hzims.alarm.show.vo.HandleQueryVo; import com.hnac.hzims.alarm.show.vo.HandleQueryVo;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import java.util.List; import java.util.List;
@ -19,7 +20,7 @@ import java.util.List;
*/ */
public interface AlarmHandleService extends IService<AlarmHandleEntity> { public interface AlarmHandleService extends IService<AlarmHandleEntity> {
boolean execute(AlarmHandleFlowEntity param); R execute(AlarmHandleFlowEntity param);
IPage<AlarmHandleVo> pageCondition(Query query, HandleQueryVo param); IPage<AlarmHandleVo> pageCondition(Query query, HandleQueryVo param);

8
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java

@ -63,7 +63,11 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl<AlarmHandleFlowMappe
return R.fail("告警消息转换失败"); return R.fail("告警消息转换失败");
} }
taskId = alarmHandleFlowEntity.getId(); taskId = alarmHandleFlowEntity.getId();
alarmHandleFlowEntity.setIsNormal(true);
if(700==processWorkFlowResponse.getCode()){
alarmHandleFlowEntity.setIsNormal(false);
alarmHandleFlowEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
//设置当前环节+当前环节处理人 //设置当前环节+当前环节处理人
if (StringUtils.isNotEmpty(processWorkFlowResponse.getNextStepOperator())) { if (StringUtils.isNotEmpty(processWorkFlowResponse.getNextStepOperator())) {
alarmHandleFlowEntity.setCurrentOperator(processWorkFlowResponse.getTaskName()); alarmHandleFlowEntity.setCurrentOperator(processWorkFlowResponse.getTaskName());
@ -117,7 +121,9 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl<AlarmHandleFlowMappe
} }
this.updateById(alarmHandleFlowEntity); this.updateById(alarmHandleFlowEntity);
//推送消息中心相关消息 //推送消息中心相关消息
if(700!=processWorkFlowResponse.getCode()) {
sendMessage(processWorkFlowResponse, alarmHandleFlowEntity, taskId); sendMessage(processWorkFlowResponse, alarmHandleFlowEntity, taskId);
}
log.info("告警消息转换结束" + processWorkFlowResponse); log.info("告警消息转换结束" + processWorkFlowResponse);
return R.success("消息保存成功"); return R.success("消息保存成功");
} }

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

@ -1,7 +1,9 @@
package com.hnac.hzims.alarm.show.service.impl; package com.hnac.hzims.alarm.show.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.alarm.config.entity.AlarmHandleEntity; import com.hnac.hzims.alarm.config.entity.AlarmHandleEntity;
import com.hnac.hzims.alarm.config.entity.AlarmHandleFlowEntity; import com.hnac.hzims.alarm.config.entity.AlarmHandleFlowEntity;
@ -15,7 +17,9 @@ import com.hnac.hzims.alarm.show.wrapper.HandleWrapper;
import com.hnac.hzims.common.flow.StartProcessService; 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 com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
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;
@ -32,6 +36,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -59,7 +65,9 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
private final IFdpDiagnoseClient iFdpDiagnoseClient; private final IFdpDiagnoseClient iFdpDiagnoseClient;
private final AlarmHandleFlowMapper alarmHandleFlowMapper; private final AlarmHandleFlowMapper alarmHandleFlowMapper;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/** /**
* 告警处理 * 告警处理
@ -68,11 +76,11 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
* @return * @return
*/ */
@Override @Override
public boolean execute(AlarmHandleFlowEntity param) { public R execute(AlarmHandleFlowEntity param) {
saveEntity(JSONObject.toJSONString(param)); String s = saveEntity(JSONObject.toJSONString(param));
//开启流程 //开启流程
R r = startProcess(s, AlarmHandleConstant.dealAlarm,null);
return true; return r;
} }
@Override @Override
@ -105,6 +113,8 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
param.setCreateUserName(AuthUtil.getUserName()); param.setCreateUserName(AuthUtil.getUserName());
alarmHandleEntity.setCreateDeptName(param.getCreateDeptName()); alarmHandleEntity.setCreateDeptName(param.getCreateDeptName());
} }
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
this.save(alarmHandleEntity); this.save(alarmHandleEntity);
//修改fdp对应得数据 //修改fdp对应得数据
// 预警 // 预警
@ -128,10 +138,12 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
} }
} }
return JSONObject.toJSONString(alarmHandleEntity); return JSONObject.toJSONString(alarmHandleEntity);
});
return res;
} }
@Override @Override
public void startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue,String variable) {
AlarmHandleFlowEntity param= JSONObject.parseObject(entity, AlarmHandleFlowEntity.class); AlarmHandleFlowEntity param= JSONObject.parseObject(entity, AlarmHandleFlowEntity.class);
if (AlarmHandleConstant.HANDLE.contains(param.getHandleWay())) { if (AlarmHandleConstant.HANDLE.contains(param.getHandleWay())) {
alarmHandleFlowMapper.insert(param); alarmHandleFlowMapper.insert(param);
@ -139,20 +151,43 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
String processName = "[" + AuthUtil.getUserName() + "] 发起 " + "【" + param.getAlarmContent() + "】告警处理流程"; String processName = "[" + AuthUtil.getUserName() + "] 发起 " + "【" + param.getAlarmContent() + "】告警处理流程";
// 开启告警处理流程 // 开启告警处理流程
String businessKey = FlowUtil.getBusinessKey("hzims_alarm_handle", "" + param.getId()); String businessKey = FlowUtil.getBusinessKey("hzims_alarm_handle", "" + param.getId());
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variables =new HashMap<>();
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(AlarmHandleConstant.dealAlarm, businessKey, processName, variable); if (StringUtils.isNotBlank(variable)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(variable,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),AlarmHandleConstant.dealAlarm, businessKey, processName, variables);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (200!=result.getCode()) {
param.setIsNormal(false); param.setIsNormal(false);
param.setRemark(JSONObject.toJSONString(variable));
alarmHandleFlowMapper.updateById(param); alarmHandleFlowMapper.updateById(param);
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variable);
log.error("缺陷流程开启失败,错误描述 : " + result.getMsg()); log.error("缺陷流程开启失败,错误描述 : " + result.getMsg());
throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg()); return r;
}else { }else {
param.setProcessInstanceId(result.getData().getProcessInstanceId()); param.setIsNormal(true);
param.setProcessInstanceId(result.getData().toString());
alarmHandleFlowMapper.updateById(param); alarmHandleFlowMapper.updateById(param);
return R.success("启动流程成功");
} }
} }
return R.success("告警处理成功");
} }
@Override
public R compensationProcess(String id) {
AlarmHandleFlowEntity alarmHandleFlowEntity = alarmHandleFlowMapper.selectById(id);
if (ObjectUtils.isNotEmpty(alarmHandleFlowEntity)){
return this.startProcess(JSON.toJSONString(alarmHandleFlowEntity), AlarmHandleConstant.dealAlarm,alarmHandleFlowEntity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
}
/** /**
* 分页 * 分页
* @param query * @param query

4
hzims-service/hzims-alarm/src/main/resources/db/3.0.0.sql

@ -0,0 +1,4 @@
ALTER TABLE `hzims_alarm_handle_flow`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_alarm_handle_flow`
ADD COLUMN `remark` text NULL ;

7
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.processflow.entity.WorkflowOperationLog; import com.hnac.hzims.middle.processflow.entity.WorkflowOperationLog;
import com.hnac.hzims.middle.processflow.service.WorkflowOperationLogService; import com.hnac.hzims.middle.processflow.service.WorkflowOperationLogService;
import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService;
import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
import com.hnac.hzims.middle.processflow.strategy.service.ProcessService; import com.hnac.hzims.middle.processflow.strategy.service.ProcessService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -37,7 +38,6 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
@Autowired @Autowired
private List<ProcessService> ticketServiceList; private List<ProcessService> ticketServiceList;
@Autowired @Autowired
private WorkflowOperationLogService workflowOperationLogService; private WorkflowOperationLogService workflowOperationLogService;
@ -48,6 +48,10 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
Assert.isTrue(Func.isNotEmpty(response),() -> { Assert.isTrue(Func.isNotEmpty(response),() -> {
throw new ServiceException("消息转换失败,消息内容为:" + message); throw new ServiceException("消息转换失败,消息内容为:" + message);
}); });
if (700==response.getCode()){
ticketServiceList.get(0).pushFailMessage(Long.valueOf(response.getTaskId()),response.getBusinessKey(),
response.getUserId(), response.getTaskName(),response.getResult(),response.getDeptId());
}
// 保存日志 // 保存日志
WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class); WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class);
log.setVariables(JSON.toJSONString(response.getVariables())); log.setVariables(JSON.toJSONString(response.getVariables()));
@ -59,6 +63,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
if(serviceOptional.isPresent()) { if(serviceOptional.isPresent()) {
try { try {
serviceOptional.get().calculate(response); serviceOptional.get().calculate(response);
} }
catch (Exception e) { catch (Exception e) {
log.setFaultLog(e.getMessage()); log.setFaultLog(e.getMessage());

41
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java

@ -0,0 +1,41 @@
package com.hnac.hzims.middle.processflow.feign;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService;
import com.hnac.hzims.middle.processflow.strategy.serviceimpl.DefectProcessServiceImpl;
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient;
import com.hnac.hzims.operational.access.vo.MaterialConsumeVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import static com.hnac.hzims.middle.process.feign.ICompensateProcessClient.START_FLOW;
/**
* @author ysj
*/
@RestController
@RequestMapping("/feign/compensateProcess")
@Slf4j
@RequiredArgsConstructor
public class CompensateProcessClient implements ICompensateProcessClient {
@Resource
private DefectProcessServiceImpl processService;
@Override
@PostMapping("/startFlow")
public R startFlow(@RequestParam("userId") String userId,
@RequestParam("dictValue")String dictValue,
@RequestParam("taskId")String taskId,
@RequestParam("processName")String processName,
@RequestBody Map<String, Object> variables) {
return processService.startFlow(userId,dictValue,taskId,processName,variables);
}
}

1
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java

@ -16,6 +16,7 @@ public interface ProcessDictService extends IService<ProcessDict> {
* 根据字典key查询字典value * 根据字典key查询字典value
*/ */
String selectDictValueByKey(String dictKey); String selectDictValueByKey(String dictKey);
ProcessDict selectDictLabelByKey(String dictKey);

7
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/impl/ProcessDictServiceImpl.java

@ -30,4 +30,11 @@ public class ProcessDictServiceImpl extends ServiceImpl<ProcessDictMapper, Proc
processDictLambdaQueryChainWrapper.eq(ProcessDict::getDictKey,dictKey); processDictLambdaQueryChainWrapper.eq(ProcessDict::getDictKey,dictKey);
return processDictLambdaQueryChainWrapper.one().getDictValue(); return processDictLambdaQueryChainWrapper.one().getDictValue();
} }
@Override
public ProcessDict selectDictLabelByKey(String dictKey) {
LambdaQueryChainWrapper<ProcessDict> processDictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(baseMapper);
processDictLambdaQueryChainWrapper.eq(ProcessDict::getDictKey,dictKey);
return processDictLambdaQueryChainWrapper.one();
}
} }

122
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java

@ -1,10 +1,31 @@
package com.hnac.hzims.middle.processflow.strategy.abstracts; package com.hnac.hzims.middle.processflow.strategy.abstracts;
import com.hnac.hzims.middle.processflow.entity.ProcessDict;
import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.service.ProcessService; import com.hnac.hzims.middle.processflow.strategy.service.ProcessService;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO;
import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.DEAL_ALARM;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.PROJECT_MANAGER;
/** /**
* @Author dfy * @Author dfy
@ -14,6 +35,107 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
public abstract class ProcessAbstractService implements ProcessService { public abstract class ProcessAbstractService implements ProcessService {
@Autowired
private IMessageClient messageClient;
@Autowired
private IUserClient userClient;
@Autowired
private ISysClient sysClient;
@Autowired
private IFlowClient flowClient;
@Autowired
private ProcessDictService processDictService;
@Override
public R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) {
log.info("开启流程.....");
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables);
R r = new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
// 更新任务流程Id
if (result.isSuccess()) {
log.info("开启流程成功:{}",variables);
BladeFlow flow = result.getData();
r.setData(flow.getProcessInstanceId());
} else {
log.error("开启流程失败:{}",result);
log.error("流程信息为{}",variables);
r.setData(variables);
pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg());
}
return r;
}
// public R compensateFlow(String userId,String dictValue,String taskId,String processName,Map<String, Object> variables) {
// R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables);
// log.error("start_process_planV4 :{}", result);
// R r = new R();
// r.setCode(result.getCode());
// r.setMsg(result.getMsg());
// // 更新任务流程Id
// if (result.isSuccess()) {
// BladeFlow flow = result.getData();
// r.setData(flow.getProcessInstanceId());
// } else {
// r.setData(variables);
// pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg());
// }
// return r;
// }
public void pushStartFailMessage(String dictValue,Long taskId, String userId, String content,String reason) {
ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue);
BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id
message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题
message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription());
// 内容
String res= StringUtil.format("你有一个{}的{}流程开启失败,失败原因为:{}",content,
processDict.getDictLabel(), reason);
message.setContent(res);
message.setTenantId("200000");
User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData();
message.setDeptId(createUser.getCreateDept());
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) {
message.setDeptName(result.getData());
}
message.setCreateUser(admin.getId());
message.setUserIds(userId);
messageClient.sendAppAndWsMsgByUsers(message);
}
@Override
public void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId) {
ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey);
BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id
message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题
message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription());
// 内容
String res= StringUtil.format("你有一个{}的{}流程流转失败,失败原因为:{}",content,
processDict.getDictLabel(), reason);
message.setContent(res);
message.setTenantId("200000");
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER);
User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData();
message.setDeptId(createUser.getCreateDept());
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) {
message.setDeptName(result.getData());
}
List<User> data = userListR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setCreateUser(admin.getId());
message.setUserIds(userIds);
messageClient.sendAppAndWsMsgByUsers(message);
}
} }

6
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java

@ -2,6 +2,9 @@ package com.hnac.hzims.middle.processflow.strategy.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
import org.springblade.core.tool.api.R;
import java.util.Map;
/** /**
* @Author dfy * @Author dfy
@ -11,6 +14,9 @@ import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
*/ */
public interface ProcessService { public interface ProcessService {
R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) ;
void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId);
/** /**
* 设置执行那种实现类 * 设置执行那种实现类
* @param flowQueue * @param flowQueue

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java

@ -41,7 +41,7 @@ public class AccessPlanV4Controller extends BladeController {
@ApiOperation(value = "v4检修计划流程开启") @ApiOperation(value = "v4检修计划流程开启")
@Operate(label = "检修计划流程开启",type = BusinessType.INSERT,risk = Risk.NO,ignore = false) @Operate(label = "检修计划流程开启",type = BusinessType.INSERT,risk = Risk.NO,ignore = false)
public R startV4(@RequestBody AccessPlanV4DTO entity) { public R startV4(@RequestBody AccessPlanV4DTO entity) {
return R.status(service.startProcessV4(entity)); return service.startProcessV4(entity);
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java

@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletResponse;
*/ */
public interface AccessPlanV4Service{ public interface AccessPlanV4Service{
boolean startProcessV4(AccessPlanV4DTO entity); R startProcessV4(AccessPlanV4DTO entity);
boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse);

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java

@ -13,7 +13,7 @@ import org.springblade.core.tool.api.R;
*/ */
public interface AccessTaskV4Service { public interface AccessTaskV4Service {
void startProcessV4(AccessTaskV4DTO entity); R startProcessV4(AccessTaskV4DTO entity);
boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse);

125
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java

@ -1,12 +1,16 @@
package com.hnac.hzims.operational.access.service.impl; package com.hnac.hzims.operational.access.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;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
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.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.constants.AccessConstants; import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.access.dto.*; import com.hnac.hzims.operational.access.dto.*;
@ -16,6 +20,10 @@ import com.hnac.hzims.operational.access.vo.AccessExportVo;
import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; import com.hnac.hzims.operational.access.vo.AccessTaskExportVo;
import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; import com.hnac.hzims.operational.access.vo.OperAccessPlanVO;
import com.hnac.hzims.operational.access.wrapper.OperAccessPlanWrapper; import com.hnac.hzims.operational.access.wrapper.OperAccessPlanWrapper;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
@ -46,7 +54,12 @@ import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -68,7 +81,7 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProcessService {
private final IOperAccessPlanService planService; private final IOperAccessPlanService planService;
@ -85,6 +98,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
private final ISysClient sysClient; private final ISysClient sysClient;
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ICompensateProcessClient compensateProcessClient;
private final IUserClient userClient; private final IUserClient userClient;
@ -96,27 +110,79 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) public R startProcessV4(AccessPlanV4DTO entity) {
public boolean startProcessV4(AccessPlanV4DTO entity) { String s = saveEntity(JSONObject.toJSONString(entity));
// 步骤2.开启检修计划流程
R r = this.startProcess(s, "overhaul_plan",null);
return r;
}
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
@Override
public String saveEntity(String entity) {
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
AccessPlanV4DTO accessPlanV4DTO = JSONObject.parseObject(entity, AccessPlanV4DTO.class);
// 步骤1.保存检修计划 // 步骤1.保存检修计划
this.saveAccess(entity); AccessPlanV4DTO saveAccess = saveAccess(accessPlanV4DTO);
// 步骤2.保存检修材料 // 步骤2.保存检修材料
this.saveAccessMaterial(entity); saveAccessMaterial(accessPlanV4DTO);
// 步骤3.保存检修明细 // 步骤3.保存检修明细
this.saveAccessContent(entity); saveAccessContent(accessPlanV4DTO);
return JSONObject.toJSONString(saveAccess);
});
return res;
}
// 步骤2.开启检修计划流程 @Override
this.startProcess(entity); public R startProcess(String entity, String dictValue,String param) {
return true; AccessPlanV4DTO accessPlanV4DTO= JSONObject.parseObject(entity, AccessPlanV4DTO.class);
Map<String, Object> variables =new HashMap<>();
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class);
}
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue, FlowUtil.getBusinessKey("access_plan_v4",
String.valueOf(accessPlanV4DTO.getId())), accessPlanV4DTO.getName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (200==result.getCode()) {
accessPlanV4DTO.setProcessInstanceId(result.getData().toString());
accessPlanV4DTO.setIsNormal(true);
planService.updateById(accessPlanV4DTO);
return R.success("启动流程成功");
} else {
accessPlanV4DTO.setIsNormal(false);
accessPlanV4DTO.setRemark(JSONObject.toJSONString(variables));
planService.updateById(accessPlanV4DTO);
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variables);
return r;
}
}
@Override
public R compensationProcess(String id) {
OperAccessPlanEntity entity = planService.getById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), "overhaul_plan",entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
* 保存检修计划 * 保存检修计划
* @param entity * @param entity
*/ */
private void saveAccess(AccessPlanV4DTO entity) { private AccessPlanV4DTO saveAccess(AccessPlanV4DTO entity) {
// 检修计划保存 // 检修计划保存
entity.setCode("PLAN_" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); entity.setCode("PLAN_" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999)));
entity.setProcDefId("overhaul_plan"); entity.setProcDefId("overhaul_plan");
@ -139,6 +205,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
entity.setUpdateUserName(user.getNickName()); entity.setUpdateUserName(user.getNickName());
} }
planService.save(entity); planService.save(entity);
return entity;
} }
@ -208,25 +275,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
/** /**
* 开启检修计划流程
* @param entity
*/
private void startProcess(AccessPlanV4DTO entity) {
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class);
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("overhaul_plan", FlowUtil.getBusinessKey("access_plan_v4",String.valueOf(entity.getId())), entity.getName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
entity.setProcessInstanceId(flow.getProcessInstanceId());
planService.updateById(entity);
} else {
throw new ServiceException("开启检修计划流程失败,code=" + result.getCode());
}
}
/**
* 检修计划流程监听 * 检修计划流程监听
* @param processWorkFlowResponse * @param processWorkFlowResponse
* @return * @return
@ -239,6 +287,11 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
entity.setTaskName(processWorkFlowResponse.getTaskName()); entity.setTaskName(processWorkFlowResponse.getTaskName());
// 流程阶段执行人员名称 // 流程阶段执行人员名称
entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator());
entity.setIsNormal(true);
if(700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){
entity.setTaskName("流程结束"); entity.setTaskName("流程结束");
entity.setNextStepOperator("流程结束,无需人员处理"); entity.setNextStepOperator("流程结束,无需人员处理");
@ -256,13 +309,17 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
return this.planService.updateById(entity); return this.planService.updateById(entity);
} }
log.error("plan_listener_entity:{}",entity); log.error("plan_listener_entity:{}",entity);
this.planService.updateById(entity);
this.saveAccessMaterial(entity);
this.saveAccessContent(entity);
String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName()) String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName())
.concat(",当前环节:") .concat(",当前环节:")
.concat(processWorkFlowResponse.getTaskName()); .concat(processWorkFlowResponse.getTaskName());
//流程找不到下一个审批人处理
this.planService.updateById(entity);
this.saveAccessMaterial(entity);
this.saveAccessContent(entity);
if(700!=processWorkFlowResponse.getCode()){
this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); this.sendMessage(entity,processWorkFlowResponse.getUserId(),content);
}
return true; return true;
} }
@ -609,4 +666,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
headStyle.setFont(font); headStyle.setFont(font);
return headStyle; return headStyle;
} }
} }

113
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java

@ -1,18 +1,21 @@
package com.hnac.hzims.operational.access.service.impl; package com.hnac.hzims.operational.access.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;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
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.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO;
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO;
import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO;
import com.hnac.hzims.operational.access.entity.OperAccessContentEntity; import com.hnac.hzims.operational.access.entity.*;
import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity;
import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity;
import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity;
import com.hnac.hzims.operational.access.mapper.OperAccessTaskMapper; import com.hnac.hzims.operational.access.mapper.OperAccessTaskMapper;
import com.hnac.hzims.operational.access.service.*; import com.hnac.hzims.operational.access.service.*;
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO;
@ -20,7 +23,6 @@ import com.hnac.hzims.operational.access.wrapper.OperAccessTaskWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
@ -41,9 +43,12 @@ import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -54,7 +59,7 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProcessService {
private final IOperAccessTaskService taskService; private final IOperAccessTaskService taskService;
@ -75,54 +80,88 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
private final IUserClient userClient; private final IUserClient userClient;
private final IMessageClient messageClient; private final IMessageClient messageClient;
private final ICompensateProcessClient compensateProcessClient;
/** /**
* 开启检修任务流程 * 开启检修任务流程
* @param entity * @param entity
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) public R startProcessV4(AccessTaskV4DTO entity) {
public void startProcessV4(AccessTaskV4DTO entity) { String saved = saveEntity(JSONObject.toJSONString(entity));
// 步骤1.保存检修任务 // 步骤4.开启检修任务流程
this.save(entity); R r = this.startProcess(saved, "overhaul_task",null);
return r;
}
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
@Override
public String saveEntity(String entity) {
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
AccessTaskV4DTO accessTaskV4DTO= JSONObject.parseObject(entity, AccessTaskV4DTO.class);
// 步骤1.保存检修任务
AccessTaskV4DTO save = this.save(accessTaskV4DTO);
// 步骤2.保存检修材料 // 步骤2.保存检修材料
this.saveMaterial(entity); this.saveMaterial(accessTaskV4DTO);
// 步骤3.保存检修详情 // 步骤3.保存检修详情
this.saveDetails(entity); this.saveDetails(accessTaskV4DTO);
return JSONObject.toJSONString(save);
});
return res;
// 步骤4.开启检修任务流程
this.startProcess(entity);
} }
/** @Override
* 开启检修流程 public R startProcess(String entity, String dictValue,String param) {
* @param entity AccessTaskV4DTO accessTaskV4DTO= JSONObject.parseObject(entity, AccessTaskV4DTO.class);
*/ Map<String, Object> variables =new HashMap<>();
private void startProcess(AccessTaskV4DTO entity) { if (StringUtils.isNotBlank(param)){
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
if(ObjectUtil.isNotEmpty(entity.getCreateUser())){ }else {
variables.put("startFlowUserId",entity.getCreateUser().toString()); variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class);
}
if(ObjectUtil.isNotEmpty(accessTaskV4DTO.getCreateUser())){
variables.put("startFlowUserId",accessTaskV4DTO.getCreateUser().toString());
} }
variables.put("solve",TaskUtil.getTaskUser(entity.getHandler().toString())); variables.put("solve",TaskUtil.getTaskUser(accessTaskV4DTO.getHandler().toString()));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("overhaul_task", FlowUtil.getBusinessKey("access_task_v4", String.valueOf(entity.getId())), entity.getName(),variables); R<BladeFlow> result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue,
FlowUtil.getBusinessKey("access_task_v4",
String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables);
log.error("开启检修任务流程失败{}" + result);
// 更新任务流程Id // 更新任务流程Id
if (result.isSuccess()) { if (200==result.getCode()) {
BladeFlow flow = result.getData(); accessTaskV4DTO.setProcessInstanceId(result.getData().toString());
entity.setProcessInstanceId(flow.getProcessInstanceId()); accessTaskV4DTO.setIsNormal(true);
taskService.updateById(entity); taskService.updateById(accessTaskV4DTO);
return R.success("启动流程成功");
} else { } else {
throw new ServiceException("开启检修任务流程失败,code=" + result.getCode()); accessTaskV4DTO.setIsNormal(false);
accessTaskV4DTO.setRemark(JSONObject.toJSONString(variables));
taskService.updateById(accessTaskV4DTO);
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variables);
return r;
}
}
@Override
public R compensationProcess(String id) {
OperAccessTaskEntity entity = taskService.getById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), "overhaul_task",entity.getRemark());
} }
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
* 检修任务保存 * 检修任务保存
* @param entity * @param entity
*/ */
private void save(AccessTaskV4DTO entity) { private AccessTaskV4DTO save(AccessTaskV4DTO entity) {
entity.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); entity.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999)));
if (ObjectUtil.isNotEmpty(entity.getHandler())){ if (ObjectUtil.isNotEmpty(entity.getHandler())){
User user = UserCache.getUser(entity.getHandler()); User user = UserCache.getUser(entity.getHandler());
@ -133,6 +172,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
} }
} }
taskService.save(entity); taskService.save(entity);
return entity;
} }
/** /**
@ -195,6 +235,11 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
// 对象转换 // 对象转换
Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables(); Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessTaskV4DTO>(){}); AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessTaskV4DTO>(){});
entity.setIsNormal(true);
if(700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
// 当前流程名称 // 当前流程名称
entity.setTaskName(processWorkFlowResponse.getTaskName()); entity.setTaskName(processWorkFlowResponse.getTaskName());
// 流程阶段执行人员名称 // 流程阶段执行人员名称
@ -221,7 +266,9 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName()) String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName())
.concat(",当前环节:") .concat(",当前环节:")
.concat(processWorkFlowResponse.getTaskName()); .concat(processWorkFlowResponse.getTaskName());
if(700!=processWorkFlowResponse.getCode()){
this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); this.sendMessage(entity,processWorkFlowResponse.getUserId(),content);
}
return true; return true;
} }
@ -295,4 +342,6 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords())); pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords()));
return pages; return pages;
} }
} }

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java

@ -80,7 +80,7 @@ public class OperAccessPlanServiceImpl extends ServiceImpl<OperAccessPlanMapper,
private final IUserClient userClient; private final IUserClient userClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IWorkTicketTemplateClient templateClient; private final IWorkTicketTemplateClient templateClient;
private final IFlowClient processClient; // private final IFlowClient processClient;
@Value("${hzims.operation.access.task-key}") @Value("${hzims.operation.access.task-key}")
private String taskKey; private String taskKey;
@ -301,7 +301,7 @@ public class OperAccessPlanServiceImpl extends ServiceImpl<OperAccessPlanMapper,
// 检修任务流程实例ID // 检修任务流程实例ID
if(ObjectUtil.isNotEmpty(phenomenon)) { if(ObjectUtil.isNotEmpty(phenomenon)) {
String processInstanceId = phenomenon.getCheckProcessInstanceId(); String processInstanceId = phenomenon.getCheckProcessInstanceId();
R<BladeFlow> result = processClient.getTaskByProcessInstanceIdAndUserId(processInstanceId,"taskUser_" + previousHandleUser); R<BladeFlow> result = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId,"taskUser_" + previousHandleUser);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){
throw new ServiceException("获取缺陷流程失败!"); throw new ServiceException("获取缺陷流程失败!");
} }
@ -315,7 +315,7 @@ public class OperAccessPlanServiceImpl extends ServiceImpl<OperAccessPlanMapper,
variables.put(TreatMethodConstant.DEFECT_HANDLER_USER,"taskUser_" + handle); variables.put(TreatMethodConstant.DEFECT_HANDLER_USER,"taskUser_" + handle);
task.setVariables(variables); task.setVariables(variables);
// 执行流程 // 执行流程
processClient.completeTask(task); flowClient.completeTask(task);
// 修改现象状态、处理任务实例 // 修改现象状态、处理任务实例
phenomenon.setHandler(handle); phenomenon.setHandler(handle);
phenomenon.setHandleStatus(RepairConstant.ACCESS_PLAN_TASK); phenomenon.setHandleStatus(RepairConstant.ACCESS_PLAN_TASK);

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/DefectCheckController.java

@ -1,8 +1,10 @@
package com.hnac.hzims.operational.defect.controller; package com.hnac.hzims.operational.defect.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IDefectCheckService; import com.hnac.hzims.operational.defect.service.IDefectCheckService;
import com.hnac.hzims.operational.defect.service.impl.DefectCheckServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -10,10 +12,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author ysj * @author ysj
@ -25,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
@Validated @Validated
public class DefectCheckController extends BladeController { public class DefectCheckController extends BladeController {
private final IDefectCheckService service; private final DefectCheckServiceImpl service;
/** /**
* 保存现象开启缺陷流程 * 保存现象开启缺陷流程
@ -37,7 +36,14 @@ public class DefectCheckController extends BladeController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "保存现象、开启缺陷处理流程", notes = "现象对象") @ApiOperation(value = "保存现象、开启缺陷处理流程", notes = "现象对象")
public R startCheck(@RequestBody OperPhenomenonEntity phenomenon) { public R startCheck(@RequestBody OperPhenomenonEntity phenomenon) {
return R.data(service.startCheck(phenomenon)); return service.startCheck(phenomenon);
}
@GetMapping("/compensationProcess")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "保存现象、开启缺陷处理流程", notes = "现象对象")
public R compensationProcess(@RequestParam String id) {
return service.compensationProcess(id);
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/OperDefectClient.java

@ -36,7 +36,7 @@ public class OperDefectClient implements IOperDefectClient {
@PostMapping(CREATE_DEFECT) @PostMapping(CREATE_DEFECT)
@Override @Override
public R createDefect(@RequestBody OperPhenomenonEntity entity) { public R createDefect(@RequestBody OperPhenomenonEntity entity) {
return R.data(defectCheckService.startCheck(entity)); return defectCheckService.startCheck(entity);
} }
@PostMapping(SAVE_DEFECT) @PostMapping(SAVE_DEFECT)

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java

@ -21,7 +21,7 @@ public interface IDefectCheckService extends IService<OperPhenomenonEntity> {
* @param phenomenon * @param phenomenon
* @return * @return
*/ */
OperPhenomenonEntity startCheck(OperPhenomenonEntity phenomenon); R startCheck(OperPhenomenonEntity phenomenon);
/** /**
* 监听回调消息 * 监听回调消息

132
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java

@ -1,13 +1,15 @@
package com.hnac.hzims.operational.defect.service.impl; package com.hnac.hzims.operational.defect.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
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.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
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.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity; import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity;
@ -33,8 +35,6 @@ import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageDTO;
@ -47,7 +47,10 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.beans.BeanInfo; import java.beans.BeanInfo;
@ -69,7 +72,7 @@ import java.util.concurrent.TimeUnit;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, OperPhenomenonEntity> implements IDefectCheckService { public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, OperPhenomenonEntity> implements IDefectCheckService , StartProcessService {
private final IOperDefectService defectService; private final IOperDefectService defectService;
@ -79,13 +82,15 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
private final ISysClient sysClient; private final ISysClient sysClient;
private final IUserClient userClient; private final IUserClient userClient;
@Autowired
private RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IStationClient stationClient; private final IStationClient stationClient;
private final IFlowClient processClient; // private final IFlowClient processClient;
private final IMessageClient messageClient; private final IMessageClient messageClient;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/** /**
* 保存现象开启缺陷处理流程 * 保存现象开启缺陷处理流程
@ -94,8 +99,7 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) public R startCheck(OperPhenomenonEntity entity) {
public OperPhenomenonEntity startCheck(OperPhenomenonEntity entity) {
if (ObjectUtil.isEmpty(entity.getCreateDept())) { if (ObjectUtil.isEmpty(entity.getCreateDept())) {
throw new ServiceException("获取缺陷所属机构失败!"); throw new ServiceException("获取缺陷所属机构失败!");
} }
@ -108,26 +112,29 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
if (StringUtils.isNotBlank(AuthUtil.getNickName())){ if (StringUtils.isNotBlank(AuthUtil.getNickName())){
entity.setCreateUserName(AuthUtil.getNickName()); entity.setCreateUserName(AuthUtil.getNickName());
} }
R r=new R();
//加锁 //加锁
Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + entity.getCreateDept(), entity.getCreateDept(), 30, TimeUnit.SECONDS); Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + entity.getCreateDept(), entity.getCreateDept(), 30, TimeUnit.SECONDS);
try { try {
if (lock) { if (lock) {
// 步骤1.保存现象 // 步骤1.保存现象
if (!this.savePhenomenon(entity)) { String saved = saveEntity(JSONObject.toJSONString(entity));
throw new ServiceException("保存现象失败!"); // if (!this.savePhenomenon(entity)) {
} // throw new ServiceException("保存现象失败!");
// 步骤2.开启缺陷流程 // }
OperPhenomenonEntity operPhenomenon = this.getOne(new LambdaQueryWrapper<OperPhenomenonEntity>() {{ // // 步骤2.开启缺陷流程
eq(OperPhenomenonEntity::getDefectCode, entity.getDefectCode()); // OperPhenomenonEntity operPhenomenon = this.getOne(new LambdaQueryWrapper<OperPhenomenonEntity>() {{
last("limit 1"); // eq(OperPhenomenonEntity::getDefectCode, entity.getDefectCode());
}}); // last("limit 1");
this.startDefectCheckV2(operPhenomenon); // }});
// this.startDefectCheckV2(operPhenomenon);
r= this.startProcess(saved, TreatMethodConstant.DEFECT_CHECK,null);
redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁 redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁
} else { } else {
// 加锁失败,抛出异常 // 加锁失败,抛出异常
throw new ServiceException("开启现象流程失败!"); throw new ServiceException("开启现象流程失败!");
} }
return entity; return r ;
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
log.error("保存现象失败!"+e); log.error("保存现象失败!"+e);
@ -138,13 +145,9 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
} }
} }
/** @Override
* 保存现象 public String saveEntity(String entityString) {
* OperPhenomenonEntity entity= JSONObject.parseObject(entityString, OperPhenomenonEntity.class);
* @param entity
* @return
*/
private boolean savePhenomenon(OperPhenomenonEntity entity) {
String deptId = entity.getCreateDept().toString(); String deptId = entity.getCreateDept().toString();
if (StringUtils.isBlank(deptId)) { if (StringUtils.isBlank(deptId)) {
throw new ServiceException("获取当前用户机构失败!"); throw new ServiceException("获取当前用户机构失败!");
@ -193,26 +196,32 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
// Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline); // Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline);
// entity.setDiscriminateDeadline(discriminateDeadline); // entity.setDiscriminateDeadline(discriminateDeadline);
// 最后甄别时间字段弃用 // 最后甄别时间字段弃用
return this.save(entity); //保存的时候单独增加事务,不妨碍其他
transactionTemplate.setTransactionManager(transactionManager);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
// 在这里执行需要事务控制的代码
boolean save = save(entity);
if (!save){
throw new ServiceException("保存业务表单失败,请稍后重试!");
} }
/**
* 启动缺陷处理流程
*
* @param entity
*/
private void startDefectCheckV2(OperPhenomenonEntity entity) {
//新增缺陷流程记录 //新增缺陷流程记录
OperDefectStatisticsEntity operDefectStatisticsEntity = new OperDefectStatisticsEntity(); OperDefectStatisticsEntity operDefectStatisticsEntity = new OperDefectStatisticsEntity();
BeanUtil.copy(entity, operDefectStatisticsEntity); BeanUtil.copy(entity, operDefectStatisticsEntity);
statisticsService.save(operDefectStatisticsEntity); statisticsService.save(operDefectStatisticsEntity);
//新增现象记录 //新增现象记录
OperAppearanceEntity operAppearanceEntity = new OperAppearanceEntity(); OperAppearanceEntity operAppearanceEntity = new OperAppearanceEntity();
BeanUtil.copy(entity, operAppearanceEntity); BeanUtil.copy(entity, operAppearanceEntity);
operAppearanceService.save(operAppearanceEntity); operAppearanceService.save(operAppearanceEntity);
}
});
return JSONObject.toJSONString(entity);
}
@Override
public R startProcess(String entityString, String dictValue,String param) {
OperPhenomenonEntity entity= JSONObject.parseObject(entityString, OperPhenomenonEntity.class);
// 现象发起人名字 // 现象发起人名字
String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse(""); String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse("");
// 现象发起来源 // 现象发起来源
@ -221,20 +230,40 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
String processName = "[" + userName + "] 发起 " + "【" + sourceName + "】缺陷处理流程" + "——>" + entity.getFaultName(); String processName = "[" + userName + "] 发起 " + "【" + sourceName + "】缺陷处理流程" + "——>" + entity.getFaultName();
// 开启新的缺陷流程 // 开启新的缺陷流程
String businessKey = FlowUtil.getBusinessKey("hzims_oper_phenomenon", "" + entity.getId()); String businessKey = FlowUtil.getBusinessKey("hzims_oper_phenomenon", "" + entity.getId());
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variables =new HashMap<>();
// variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); if (StringUtils.isNotBlank(param)){
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(TreatMethodConstant.DEFECT_CHECK, businessKey, processName, variable); variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class);
}
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), dictValue, businessKey, processName, variables);
// R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey( dictValue,businessKey, processName, variable);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (200!=result.getCode()) {
throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg()); entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(variables));
this.baseMapper.updateById(entity);
log.error("缺陷流程开启失败,错误描述 : " + result.getMsg());
return result;
} }
// 关联流程唯一键 // 关联流程唯一键
entity.setCheckProcessInstanceId(result.getData().getProcessInstanceId()); entity.setIsNormal(true);
operDefectStatisticsEntity.setCheckProcessInstanceId(result.getData().getProcessInstanceId()); entity.setCheckProcessInstanceId(result.getData().toString());
OperDefectStatisticsEntity operDefectStatisticsEntity = new OperDefectStatisticsEntity();
BeanUtil.copy(entity, operDefectStatisticsEntity);
operDefectStatisticsEntity.setCheckProcessInstanceId(result.getData().toString());
this.baseMapper.updateById(entity); this.baseMapper.updateById(entity);
statisticsService.updateById(operDefectStatisticsEntity); statisticsService.updateById(operDefectStatisticsEntity);
return R.success("启动流程成功");
}
@Override
public R compensationProcess(String id){
OperPhenomenonEntity operPhenomenonEntity = this.baseMapper.selectById(id);
if (ObjectUtils.isNotEmpty(operPhenomenonEntity)){
return this.startProcess(JSON.toJSONString(operPhenomenonEntity), TreatMethodConstant.DEFECT_CHECK,operPhenomenonEntity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
* 实体类转换成map * 实体类转换成map
* *
@ -348,6 +377,14 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
log.info("缺陷ID:" + operPhenomenonEntity.getDefectCode() + "入库成功"); log.info("缺陷ID:" + operPhenomenonEntity.getDefectCode() + "入库成功");
} }
//流程找不到下一个审批人处理
if(700==processWorkFlowResponse.getCode()){
operPhenomenonEntity.setIsNormal(false);
operPhenomenonEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}else {
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,taskId);
}
//更新数据库 //更新数据库
Long statisticsEntityId = statisticsEntity.getId(); Long statisticsEntityId = statisticsEntity.getId();
Long appearanceEntityId = appearanceEntity.getId(); Long appearanceEntityId = appearanceEntity.getId();
@ -360,8 +397,6 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
}}); }});
statisticsService.updateById(statisticsEntity); statisticsService.updateById(statisticsEntity);
operAppearanceService.updateById(appearanceEntity); operAppearanceService.updateById(appearanceEntity);
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,taskId);
log.info("消缺消息转换结束"+processWorkFlowResponse); log.info("消缺消息转换结束"+processWorkFlowResponse);
return R.success("消息保存成功"); return R.success("消息保存成功");
} }
@ -421,4 +456,5 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
} }
return solve; return solve;
} }
} }

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java

@ -13,6 +13,7 @@ import com.hnac.hzims.operational.duty.service.IImsAnalyseExampleService;
import com.hnac.hzims.operational.duty.service.IImsDutyEmergencyService; import com.hnac.hzims.operational.duty.service.IImsDutyEmergencyService;
import com.hnac.hzims.operational.duty.service.IImsDutyLogService; import com.hnac.hzims.operational.duty.service.IImsDutyLogService;
import com.hnac.hzims.operational.duty.service.IImsDutyRecService; import com.hnac.hzims.operational.duty.service.IImsDutyRecService;
import com.hnac.hzims.operational.duty.service.impl.ImsDutyRecServiceImpl;
import com.hnac.hzims.operational.duty.vo.ImsDutyEmergencyVo; import com.hnac.hzims.operational.duty.vo.ImsDutyEmergencyVo;
import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO;
import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition;
@ -55,7 +56,7 @@ import java.util.List;
@Slf4j @Slf4j
public class ImsDutyRecController extends BladeController { public class ImsDutyRecController extends BladeController {
@Resource @Resource
private IImsDutyRecService imsDutyRecService; private ImsDutyRecServiceImpl imsDutyRecService;
@Resource @Resource
private IImsDutyEmergencyService iImsDutyEmergencyService; private IImsDutyEmergencyService iImsDutyEmergencyService;
@Resource @Resource
@ -340,7 +341,7 @@ public class ImsDutyRecController extends BladeController {
@ApiOperationSupport(order = 21) @ApiOperationSupport(order = 21)
@ApiOperation(value = "交班", notes = "传入imsDutyRecDTO交接班信息") @ApiOperation(value = "交班", notes = "传入imsDutyRecDTO交接班信息")
public R changeShift(@Valid @RequestBody ImsDutyRecDTO imsDutyRecDTO) { public R changeShift(@Valid @RequestBody ImsDutyRecDTO imsDutyRecDTO) {
return R.status(imsDutyRecService.changeShift(imsDutyRecDTO)); return imsDutyRecService.changeShift(imsDutyRecDTO);
} }
// /** // /**
// * 查询交接班值班日志 // * 查询交接班值班日志
@ -412,6 +413,12 @@ public class ImsDutyRecController extends BladeController {
log.error("转换对象失败!"); log.error("转换对象失败!");
} }
} }
@GetMapping("/compensationProcess")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "补偿-重启流程", notes = "现象对象")
public R compensationProcess(@RequestParam String id) {
return imsDutyRecService.compensationProcess(id);
}
} }

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java

@ -41,6 +41,11 @@ public class DutyRecClient implements IDutyRecClient {
throw new RuntimeException("未接收到交接班信息!"); throw new RuntimeException("未接收到交接班信息!");
}); });
recDTO.setDealChain(processWorkFlowResponse.getTaskName()); recDTO.setDealChain(processWorkFlowResponse.getTaskName());
recDTO.setIsNormal(true);
if(700==processWorkFlowResponse.getCode()){
recDTO.setIsNormal(false);
recDTO.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
return R.status(service.dealDutyRecFlow(recDTO)); return R.status(service.dealDutyRecFlow(recDTO));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java

@ -32,7 +32,7 @@ public interface IImsDutyRecService extends IService<ImsDutyRecEntity> {
* @param recDTO 交接班信息 * @param recDTO 交接班信息
* @return 交接班成功与否flag * @return 交接班成功与否flag
*/ */
Boolean changeShift(ImsDutyRecDTO recDTO); R changeShift(ImsDutyRecDTO recDTO);
/** /**
* 执行工作流 * 执行工作流

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

@ -9,8 +9,15 @@ 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.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.monitor.utils.DateUtils;
import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.OperationalConstants;
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.duty.DutyContants; import com.hnac.hzims.operational.duty.DutyContants;
import com.hnac.hzims.operational.duty.constant.DutyProcessConstant; import com.hnac.hzims.operational.duty.constant.DutyProcessConstant;
import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant; import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant;
@ -45,6 +52,7 @@ import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.constant.ProcessConstant; import org.springblade.flow.core.constant.ProcessConstant;
import org.springblade.flow.core.entity.BladeFlow; 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.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.MessagePushRecordDto; import org.springblade.message.dto.MessagePushRecordDto;
@ -55,7 +63,11 @@ import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -79,7 +91,7 @@ import static org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME;
*/ */
@Slf4j @Slf4j
@Service @Service
public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDutyRecEntity> implements IImsDutyRecService { public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDutyRecEntity> implements IImsDutyRecService, StartProcessService {
@Resource @Resource
private ITicketInfoClient ticketInfoClient; private ITicketInfoClient ticketInfoClient;
@Autowired @Autowired
@ -110,7 +122,12 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
private IImsDutyGroupPService imsDutyGroupPService; private IImsDutyGroupPService imsDutyGroupPService;
@Autowired @Autowired
private IImsDutyMainPersonService imsDutyMainPersonService; private IImsDutyMainPersonService imsDutyMainPersonService;
@Autowired
private ICompensateProcessClient compensateProcessClient;
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
private TransactionTemplate transactionTemplate;
@Override @Override
@Deprecated//2023.12.18 @Deprecated//2023.12.18
@ -208,8 +225,18 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
* @return 交接班成功标识 * @return 交接班成功标识
*/ */
@Override @Override
// @Transactional(rollbackFor = Exception.class) public R changeShift(ImsDutyRecDTO recDTO) {
public Boolean changeShift(ImsDutyRecDTO recDTO) { //保存对应业务表单
String saved = saveEntity(JSONObject.toJSONString(recDTO));
//开启动作流
R r = this.startProcess(JSON.toJSONString(saved), DutyRecProcessConstant.DUTY_REC_FLOW_KEY,null);
return r;
}
@Override
public String saveEntity(String entity) {
ImsDutyRecDTO recDTO= JSONObject.parseObject(entity, ImsDutyRecDTO.class);
transactionTemplate.setTransactionManager(transactionManager);
// 获取班组组长 // 获取班组组长
Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId()); Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
Assert.isTrue(Func.isNotEmpty(managerId),() -> { Assert.isTrue(Func.isNotEmpty(managerId),() -> {
@ -228,6 +255,10 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
recDTO.setStatus(DutyRecStatus.EXEC.getVal()); recDTO.setStatus(DutyRecStatus.EXEC.getVal());
// 判断交接班是否延时 // 判断交接班是否延时
Long duration = this.changeShiftDuration(imsDutyMainService.getById(recDTO.getDutyId()), OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()); Long duration = this.changeShiftDuration(imsDutyMainService.getById(recDTO.getDutyId()), OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal());
transactionTemplate.setTransactionManager(transactionManager);
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());
} }
@ -238,11 +269,67 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity(); ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity();
imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME)); imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME));
imsDutyLogService.saveOrUpdate(imsDutyLogEntity); imsDutyLogService.saveOrUpdate(imsDutyLogEntity);
return JSONObject.toJSONString(recDTO);
});
return res;
}
@Override
public R startProcess(String entity, String dictValue,String param) {
ImsDutyRecDTO recDTO= JSONObject.parseObject(entity, ImsDutyRecDTO.class);
ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class);
// 开启值班交接班流程 // 开启值班交接班流程
recEntity.setQrCodeContent(System.currentTimeMillis() + ""); recEntity.setQrCodeContent(System.currentTimeMillis() + "");
BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); // 获取班组组长
recEntity.setProcessInstanceId(bladeFlow.getProcessInstanceId()); Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
return updateById(recEntity); Assert.isTrue(Func.isNotEmpty(managerId),() -> {
throw new ServiceException("获取值班班组长失败!");
});
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()));
}};
String businessKey = FlowUtil.getBusinessKey( DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, "" + recDTO.getId());
String processName = AuthUtil.getUserName()+"发起的交班流程";
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue,
businessKey,
processName,
variable);
if (200!=result.getCode()) {
recEntity.setIsNormal(false);
recEntity.setRemark(JSONObject.toJSONString(variable));
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variable);
updateById(recEntity);
log.error("交接班请求报错"+result.getMsg());
return r;
}
recEntity.setIsNormal(true);
recEntity.setProcessInstanceId(result.getData().toString());
updateById(recEntity);
return R.success("启动流程成功");
}
@Override
public R compensationProcess(String id) {
ImsDutyRecEntity rec = this.baseMapper.selectById(id);
if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty(rec)){
return this.startProcess(JSON.toJSONString(rec), DutyRecProcessConstant.DUTY_REC_FLOW_KEY,rec.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
@ -1525,4 +1612,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
} }
return handNumber; return handNumber;
} }
} }

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java

@ -2,16 +2,13 @@ package com.hnac.hzims.operational.history.service.impl;
import com.hnac.hzims.operational.history.service.PointService; import com.hnac.hzims.operational.history.service.PointService;
import com.hnac.hzinfo.dataconfig.entity.Device; import com.hnac.hzinfo.dataconfig.entity.Device;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,11 +34,12 @@ public class PointServiceImpl implements PointService {
*/ */
@Override @Override
public List<Device> projectFacDevice(String projectId) { public List<Device> projectFacDevice(String projectId) {
Result<List<Device>> result = deviceClient.facDeviceByProjectId(projectId); /**Result<List<Device>> result = deviceClient.facDeviceByProjectId(projectId);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); return new ArrayList<>();
} }
return result.getData(); return result.getData();*/
return new ArrayList<>();
} }
/** /**

50
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java

@ -1,8 +1,9 @@
package com.hnac.hzims.operational.maintenance.scheduled; package com.hnac.hzims.operational.maintenance.scheduled;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
@ -10,14 +11,11 @@ import com.hnac.hzims.operational.constants.FlowKeyConstants;
import com.hnac.hzims.operational.constants.RedisKeyConstants; import com.hnac.hzims.operational.constants.RedisKeyConstants;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceLibraryEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceLibraryMapper;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskEntityVo; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskEntityVo;
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
@ -32,8 +30,6 @@ import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -41,7 +37,6 @@ import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -54,7 +49,7 @@ import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant
@Component @Component
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
public class MaintenanceTaskSchedule { public class MaintenanceTaskSchedule implements StartProcessService {
private final IOperMaintenancePlanService planService; private final IOperMaintenancePlanService planService;
private final IOperMaintenanceTaskService taskService; private final IOperMaintenanceTaskService taskService;
@ -176,9 +171,22 @@ public class MaintenanceTaskSchedule {
* @param task 日常维护任务 * @param task 日常维护任务
* @return 工作流实例ID * @return 工作流实例ID
*/ */
private String startProcessInstance(OperMaintenanceTaskEntity task) { private void startProcessInstance(OperMaintenanceTaskEntity task) {
String s = saveEntity(JSONObject.toJSONString(task));
startProcess(s,FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY,null);
}
@Override
public String saveEntity(String entity) {
return entity;
}
@Override
public R startProcess(String entity, String dictValue,String param) {
OperMaintenanceTaskEntity task = JSONObject.parseObject(entity,OperMaintenanceTaskEntity.class);
if(Func.isEmpty(task.getDisposer())) { if(Func.isEmpty(task.getDisposer())) {
return null; log.error("找不到日常维护执行人{}",task);
return R.success("日程维护执行成功");
} }
OperMaintenanceTaskEntityVo vo = BeanUtil.copy(task,OperMaintenanceTaskEntityVo.class); OperMaintenanceTaskEntityVo vo = BeanUtil.copy(task,OperMaintenanceTaskEntityVo.class);
Map<String,Object> params = new HashMap<String, Object>() {{ Map<String,Object> params = new HashMap<String, Object>() {{
@ -194,7 +202,25 @@ public class MaintenanceTaskSchedule {
}); });
put("operMaintenanceTaskEntityVo",vo); put("operMaintenanceTaskEntityVo",vo);
}}; }};
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY, String.valueOf(task.getId()), task.getTitle(), params); R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params);
return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); if (!flowResult.isSuccess()){
task.setIsNormal(false);
task.setRemark(JSONObject.toJSONString(params));
taskService.updateById(task);
R r=new R();
r.setCode(flowResult.getCode());
r.setMsg(flowResult.getMsg());
r.setData(params);
log.error(task.getId()+"日常维护任务启动流程失败{}", task);
return r;
}
String s = Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null);
log.info(task.getId()+"日常维护任务启动成功{}", s);
return R.success("启动流程成功");
}
@Override
public R compensationProcess(String id) {
return null;
} }
} }

20
hzims-service/operational/src/main/resources/db/3.0.1.sql

@ -0,0 +1,20 @@
ALTER TABLE `hzims_oper_phenomenon`
MODIFY COLUMN `REMARK` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '冗余字段' ;
ALTER TABLE `hz_ims_duty_rec`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_oper_access_task`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_oper_access_plan`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_oper_maintenance_task`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hz_ims_duty_rec`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_oper_access_task`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_oper_access_plan`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_oper_maintenance_task`
ADD COLUMN `remark` text NULL ;

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

@ -31,7 +31,6 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
@ -81,10 +80,11 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
last("limit 1"); last("limit 1");
}}); }});
BeanUtil.copy(saveEntity,hiddenDangerVo); BeanUtil.copy(saveEntity,hiddenDangerVo);
this.startProcess(JSONObject.toJSONString(hiddenDangerVo), HIDDEN_DANGER_CHECK); R r = this.startProcess(JSONObject.toJSONString(hiddenDangerVo), HIDDEN_DANGER_CHECK);
return R.success("隐患流程发起成功"); return r;
} }
@Override @Override
@Transactional
public String saveEntity(String entity) { public String saveEntity(String entity) {
InnerDangerEntity innerDangerEntity= JSONObject.parseObject(entity, InnerDangerEntity.class); InnerDangerEntity innerDangerEntity= JSONObject.parseObject(entity, InnerDangerEntity.class);
if (Func.isEmpty(innerDangerEntity.getCode())) { if (Func.isEmpty(innerDangerEntity.getCode())) {
@ -118,7 +118,7 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
} }
@Override @Override
public void 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);
@ -132,15 +132,21 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (!result.isSuccess()) {
innerDangerEntity.setIsNormal(false); innerDangerEntity.setIsNormal(false);
innerDangerEntity.setRemark(JSONObject.toJSONString(variable));
this.baseMapper.updateById(innerDangerEntity); this.baseMapper.updateById(innerDangerEntity);
log.error("隐患处理流程开启失败,错误描述 : {}", result); log.error("隐患处理流程开启失败,错误描述 : {}", result);
throw new ServiceException("隐患处理流程开启失败,错误描述 : " + result.getMsg()); R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variable);
return r;
} else { } else {
// 关联流程唯一键 // 关联流程唯一键
innerDangerEntity.setProcessInstanceId(result.getData().getProcessInstanceId()); innerDangerEntity.setProcessInstanceId(result.getData().getProcessInstanceId());
innerDangerEntity.setTaskId(result.getData().getTaskId()); innerDangerEntity.setTaskId(result.getData().getTaskId());
this.baseMapper.updateById(innerDangerEntity); this.baseMapper.updateById(innerDangerEntity);
} }
return R.success("启动流程成功");
} }
/** /**

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardTaskController.java

@ -28,7 +28,7 @@ public class HazardTaskController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "开启流程", notes = "传入Correlation") @ApiOperation(value = "开启流程", notes = "传入Correlation")
public R startProcess(@RequestBody HazardRiskProcessDTO process) { public R startProcess(@RequestBody HazardRiskProcessDTO process) {
return R.status(service.startProcess(process)); return service.startProcess(process);
} }
@PostMapping("/pages") @PostMapping("/pages")

3
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardTaskService.java

@ -10,6 +10,7 @@ import com.hnac.hzims.safeproduct.risk.vo.HazardTaskVo;
import com.hnac.hzims.safeproduct.risk.vo.StationEstimateVo; import com.hnac.hzims.safeproduct.risk.vo.StationEstimateVo;
import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo; import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo;
import com.hnac.hzims.safeproduct.statistic.vo.RiskInnerVO; import com.hnac.hzims.safeproduct.statistic.vo.RiskInnerVO;
import org.springblade.core.tool.api.R;
import java.util.List; import java.util.List;
@ -19,7 +20,7 @@ import java.util.List;
*/ */
public interface HazardTaskService extends IService<HazardTask> { public interface HazardTaskService extends IService<HazardTask> {
boolean startProcess(HazardRiskProcessDTO process); R startProcess(HazardRiskProcessDTO process);
boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse);

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

@ -4,10 +4,14 @@ 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.ObjectUtils;
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.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.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
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;
import com.hnac.hzims.safeproduct.risk.constants.HazardRiskConstants; import com.hnac.hzims.safeproduct.risk.constants.HazardRiskConstants;
@ -17,11 +21,11 @@ import com.hnac.hzims.safeproduct.risk.mapper.HazardTaskMapper;
import com.hnac.hzims.safeproduct.risk.service.*; import com.hnac.hzims.safeproduct.risk.service.*;
import com.hnac.hzims.safeproduct.risk.vo.*; import com.hnac.hzims.safeproduct.risk.vo.*;
import com.hnac.hzims.safeproduct.statistic.vo.RiskInnerVO; import com.hnac.hzims.safeproduct.statistic.vo.RiskInnerVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.entity.BladeFlow;
@ -30,7 +34,9 @@ import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.system.cache.DictCache; import org.springblade.system.cache.DictCache;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -59,19 +65,23 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/** /**
* 风险排查流程开启 * 风险排查流程开启
* @param process * @param process
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) public R startProcess(HazardRiskProcessDTO process) {
public boolean startProcess(HazardRiskProcessDTO process) {
//保存业务表单 //保存业务表单
saveEntity(JSONObject.toJSONString(process)); String saved = saveEntity(JSONObject.toJSONString(process));
//开启动作流 //开启动作流
this.startProcess(JSON.toJSONString(process),HazardRiskConstants.HAZARD_RISK_KEY); R r = this.startProcess(JSON.toJSONString(saved), HazardRiskConstants.HAZARD_RISK_KEY,null);
return true; return r ;
} }
@Override @Override
@ -105,6 +115,9 @@ 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());
//增加事务
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
// 保存任务 // 保存任务
super.save(process); super.save(process);
// 生成风险评估记录 // 生成风险评估记录
@ -127,26 +140,52 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
hazardEstimateService.saveBatch(process.getEstimates()); hazardEstimateService.saveBatch(process.getEstimates());
return JSON.toJSONString(process); return JSON.toJSONString(process);
});
return res;
} }
@Override @Override
public void startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue,String param) {
HazardRiskProcessDTO process= JSONObject.parseObject(entity, HazardRiskProcessDTO.class); HazardRiskProcessDTO process= JSONObject.parseObject(entity, HazardRiskProcessDTO.class);
// 查询作业区域负责人 Map<String, Object> variables =new HashMap<>();
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class); if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class);
variables.put(HazardRiskConstants.TROUBLE, TaskUtil.getTaskUser(String.valueOf(process.getHead()))); 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); }
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue, FlowUtil.getBusinessKey(HazardRiskConstants.HAZARD_RISK_KEY,String.valueOf(process.getId())), process.getTaskName(), variables);
log.error("start_process_planV4 :{}",result); log.error("start_process_planV4 :{}",result);
// 更新任务流程Id // 更新任务流程Id
if (result.isSuccess()) { if (200==result.getCode()) {
BladeFlow flow = result.getData(); process.setIsNormal(true);
process.setProcessInstanceId(flow.getProcessInstanceId()); process.setProcessInstanceId(result.getData().toString());
this.updateById(process); this.updateById(process);
return R.success("启动流程成功");
} else { } else {
throw new ServiceException("开启检修计划流程失败,code=" + result.getCode()); process.setIsNormal(false);
process.setRemark(JSONObject.toJSONString(variables));
this.updateById(process);
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variables);
log.error("开启检修计划流程失败,code=" + result.getCode());
return r;
} }
} }
@Override
public R compensationProcess(String id) {
HazardTask hazardTask = super.baseMapper.selectById(id);
if (ObjectUtils.isNotEmpty(hazardTask)){
return this.startProcess(JSON.toJSONString(hazardTask), HazardRiskConstants.HAZARD_RISK_KEY,hazardTask.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
}
/** /**
* 流程发起 * 流程发起
* @param process * @param process
@ -192,6 +231,12 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
// 流程阶段执行人员名称 // 流程阶段执行人员名称
entity.setNextStepOperator("流程结束,无需人员处理"); entity.setNextStepOperator("流程结束,无需人员处理");
} }
entity.setIsNormal(true);
//流程找不到下一个审批人处理
if(700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
// 更新风险排查任务信息 // 更新风险排查任务信息
this.updateById(entity); this.updateById(entity);
if(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY_1.equals(variables.get(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY)) || if(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY_1.equals(variables.get(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY)) ||

10
hzims-service/safeproduct/src/main/resources/db/3.0.0.sql

@ -0,0 +1,10 @@
ALTER TABLE `hzims_inner_danger_info`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_risk_hazard_task`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_inner_danger_info`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_risk_hazard_task`
ADD COLUMN `remark` text NULL ;

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java

@ -76,6 +76,6 @@ public class WorkTaskController extends BladeController {
@ApiOperation(value = "工作任务单") @ApiOperation(value = "工作任务单")
@Operate(label = "开启工作任务单流程", type = BusinessType.INSERT,risk = Risk.LOW,ignore = false) @Operate(label = "开启工作任务单流程", type = BusinessType.INSERT,risk = Risk.LOW,ignore = false)
public R startV4(@RequestBody WorkTaskVO workTask) { public R startV4(@RequestBody WorkTaskVO workTask) {
return R.status(workTaskService.start(workTask)); return workTaskService.start(workTask);
} }
} }

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java

@ -8,6 +8,7 @@ import com.hnac.hzims.ticket.repair.vo.WorkTaskVO;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import java.util.List; import java.util.List;
@ -16,7 +17,7 @@ import java.util.List;
*/ */
public interface IWorkTaskService extends IService<WorkTaskEntity> { public interface IWorkTaskService extends IService<WorkTaskEntity> {
boolean start(WorkTaskVO workTask); R start(WorkTaskVO workTask);
boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse);

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

@ -79,12 +79,12 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
* @return * @return
*/ */
@Override @Override
public boolean start(WorkTaskVO workTask) { public R start(WorkTaskVO workTask) {
// 步骤1.保存工作任务单 // 步骤1.保存工作任务单
String saved = this.saveEntity(JSON.toJSONString(workTask)); String saved = this.saveEntity(JSON.toJSONString(workTask));
// 步骤2.开启检修计划流程 // 步骤2.开启检修计划流程
this.startProcess(saved,"work_task"); R r = this.startProcess(saved, "work_task");
return true; return r;
} }
@Override @Override
@ -121,7 +121,7 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
} }
@Override @Override
public void startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue) {
WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class); WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class);
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class);
variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead()))); variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead())));
@ -143,9 +143,15 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
this.updateById(workTask); this.updateById(workTask);
} else { } else {
workTask.setIsNormal(false); workTask.setIsNormal(false);
workTask.setRemark(JSONObject.toJSONString(variables));
this.updateById(workTask); this.updateById(workTask);
throw new ServiceException("开启工作任务计划流程失败,code=" + result.getCode()); R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variables);
return r;
} }
return R.success("启动流程成功");
} }

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java

@ -45,8 +45,7 @@ public class OperationTicketController {
@ApiOperation("启动流程") @ApiOperation("启动流程")
@PostMapping("/startUp") @PostMapping("/startUp")
public R start(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) { public R start(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) {
operationTicketService.startUp(StandardTicketInfoVo); return operationTicketService.startUp(StandardTicketInfoVo);
return R.success("申请开票成功");
} }

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java

@ -3,6 +3,7 @@ package com.hnac.hzims.ticket.standardTicket.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo;
import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -19,7 +20,7 @@ public interface OperationTicketService {
* 启动流程 * 启动流程
* @param standardTicketInfoVo * @param standardTicketInfoVo
*/ */
void startUp(StandardTicketInfoVo standardTicketInfoVo); R startUp(StandardTicketInfoVo standardTicketInfoVo);
/** /**

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

@ -33,7 +33,6 @@ 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;
@ -101,7 +100,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
* @param standardTicketInfoVo * @param standardTicketInfoVo
*/ */
@Override @Override
public void startUp(StandardTicketInfoVo standardTicketInfoVo) { public R 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)); String standardTicketInfoVoBySave = this.saveEntity(JSONObject.toJSONString(standardTicketInfoVo));
@ -112,7 +111,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");
} }
//启动流程 //启动流程
this.startProcess(standardTicketInfoVoBySave, dictValue); return this.startProcess(standardTicketInfoVoBySave, dictValue);
} }
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
@ -168,7 +167,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
@Override @Override
public void startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class); StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo); StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo);
Instant start = Instant.now(); Instant start = Instant.now();
@ -177,18 +176,25 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
params.put("taskId", standardTicketInfoVo.getId()); params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程 //已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params); R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()),
standardTicketInfoVo.getTitle(), params);
if (!processInstanceContainNameByKey.isSuccess()) { if (!processInstanceContainNameByKey.isSuccess()) {
standardTicketInfoEntity.setIsNormal(false); standardTicketInfoEntity.setIsNormal(false);
standardTicketInfoEntity.setRemarkFlow(JSONObject.toJSONString(params));
standardTicketInfoService.save(standardTicketInfoEntity); standardTicketInfoService.save(standardTicketInfoEntity);
R r=new R();
r.setCode(processInstanceContainNameByKey.getCode());
r.setMsg(processInstanceContainNameByKey.getMsg());
r.setData(params);
log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg()); log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限..."); return r;
} }
Duration between = Duration.between(start, Instant.now()); Duration between = Duration.between(start, Instant.now());
log.info("================================================================"); log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒"); log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒"); log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================"); log.info("================================================================");
return R.success("启动流程成功");
} }
/** /**

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java

@ -48,8 +48,7 @@ public class TicketProcessController {
@PostMapping("/startUp") @PostMapping("/startUp")
@Operate(label = "工作票开票",type = BusinessType.INSERT,risk = Risk.LOW,ignore = false) @Operate(label = "工作票开票",type = BusinessType.INSERT,risk = Risk.LOW,ignore = false)
public R start(@RequestBody WorkTicketVo workTicketVo) { public R start(@RequestBody WorkTicketVo workTicketVo) {
Long ticketId = ticketProcessService.startUp(workTicketVo); return ticketProcessService.startUp(workTicketVo);
return R.data(ticketId);
} }
@ApiOperation("开启工作票线下流程") @ApiOperation("开启工作票线下流程")

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java

@ -2,6 +2,7 @@ package com.hnac.hzims.ticket.twoTicket.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Map; import java.util.Map;
@ -18,7 +19,7 @@ public interface TicketProcessService {
/** /**
* 启动开票流程 * 启动开票流程
*/ */
Long startUp(WorkTicketVo workTicketVo); R startUp(WorkTicketVo workTicketVo);
/** /**

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

@ -28,7 +28,6 @@ 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;
@ -164,7 +163,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
// @SneakyThrows // @SneakyThrows
@Override @Override
@Transactional @Transactional
public Long startUp(WorkTicketVo workTicketVo) { public R 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】 。。。方法");
//保存操作票 //保存操作票
@ -177,10 +176,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");
} }
//开启动作流 //开启动作流
this.startProcess(saveEntity,dictValue); R r = this.startProcess(saveEntity, dictValue);
// //处理任务--老版本业务要求,2024/07/05弃用 // //处理任务--老版本业务要求,2024/07/05弃用
// this.returnTicket(workTicketVo); // this.returnTicket(workTicketVo);
return workTicketVo.getWorkTicket().getId(); return r;
} }
@Override @Override
@ -237,7 +236,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
} }
@Override @Override
public void startProcess(String entity, String dictValue) { public R startProcess(String entity, String dictValue) {
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class);
WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket()); WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket());
workTicketVo.setWorkTicket(workTicket); workTicketVo.setWorkTicket(workTicket);
@ -245,7 +244,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
//若为线下工作票 则无需开启工作流 //若为线下工作票 则无需开启工作流
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus(); Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus();
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) {
return; return R.success("线下流程,开票成功");
} }
Map<String, Object> params = new HashMap<>(4); Map<String, Object> params = new HashMap<>(4);
params.put("workTicketVo", workTicketVo); params.put("workTicketVo", workTicketVo);
@ -262,13 +261,18 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
if (!processInstanceContainNameByKey.isSuccess()) { if (!processInstanceContainNameByKey.isSuccess()) {
//保存流程开始失败情况 //保存流程开始失败情况
workTicket.setIsNormal(false); workTicket.setIsNormal(false);
workTicket.setRemark(JSONObject.toJSONString(params));
boolean isSave = firstWorkTicketService.save(workTicket); boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket)); log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) { if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误"); throw new IllegalArgumentException("保存工作对象错误");
} }
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("流程开启失败,请检查流程和用户权限后重试!"); R r=new R();
r.setCode(processInstanceContainNameByKey.getCode());
r.setMsg("流程开启失败,请检查流程和用户权限后重试!");
r.setData(params);
return r;
} }
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); log.info("获取启动流程数据 : {}", processInstanceContainNameByKey);
Duration between = Duration.between(start, Instant.now()); Duration between = Duration.between(start, Instant.now());
@ -277,6 +281,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
log.info("耗时: " + (between.getSeconds()) + "秒"); log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒"); log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================"); log.info("================================================================");
return R.success("启动流程成功");
} }
/** /**
* 验证是走那种工作票流程默认走第一种工作票 * 验证是走那种工作票流程默认走第一种工作票
@ -1406,6 +1411,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
Assert.isTrue(flowR.isSuccess(),() -> { Assert.isTrue(flowR.isSuccess(),() -> {
//保存流程开始失败情况 //保存流程开始失败情况
workTicket.setIsNormal(false); workTicket.setIsNormal(false);
workTicket.setRemark(JSON.toJSONString(params));
boolean isSave = firstWorkTicketService.save(workTicket); boolean isSave = firstWorkTicketService.save(workTicket);
log.info("ticket:start:save",JSON.toJSONString(workTicket)); log.info("ticket:start:save",JSON.toJSONString(workTicket));
if (!isSave) { if (!isSave) {

9
hzims-service/ticket/src/main/resources/db/3.0.0.sql

@ -0,0 +1,9 @@
ALTER TABLE `hzims_standard_ticket_info`
ADD COLUMN `remark_flow` text NULL ;
ALTER TABLE `hzims_work_ticket_info`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_standard_ticket_info`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_work_ticket_info`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
Loading…
Cancel
Save