diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java index 3b014bb..f853ff6 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/flow/StartProcessService.java @@ -1,9 +1,7 @@ package com.hnac.hzims.common.flow; -import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tool.api.R; -import org.springframework.transaction.annotation.Transactional; /** * @Author dfy @@ -27,12 +25,13 @@ public interface StartProcessService { * @param dictValue * @return */ - void startProcess(String entity, String dictValue); + R startProcess(String entity, String dictValue,String param); -// /** -// * 补偿工作流流程 -// * @param response -// */ -// Boolean compensation(ProcessWorkFlowRes ponse response); + /** + * 补偿工作流流程 + * @param id + * @return + */ + R compensationProcess(String id); } diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmHandleFlowEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmHandleFlowEntity.java index 14d4d38..f1f6139 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmHandleFlowEntity.java +++ b/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; @ApiModelProperty("工作流是否运行正常") private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java index a8d6a20..cabf95e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessPlanEntity.java +++ b/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 = "创建用户名称") private String updateUserName; + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; + + @ApiModelProperty(value = "流程参数") + private String remark; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java index eac70ff..790d3d2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java +++ b/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 = "创建用户名称") private Long constructionId; + + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java index 1befff8..7d07753 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java +++ b/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; @ApiModelProperty("机构名称") private String deptName; + + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java index 0735f33..9d6bccf 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java +++ b/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) private ImsDutyLogEntity imsDutyLogEntity; + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java new file mode 100644 index 0000000..b0a5fbe --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoricalCurveVo.java @@ -0,0 +1,59 @@ +package com.hnac.hzims.operational.history.vo; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "历史告警数据查询") +public class HistoricalCurveVo { + + @ApiModelProperty(value = "第一个点位") + private String firstAttrId; + + @ApiModelProperty(value = "第二个点位") + private String secondAttrId; + + @ApiModelProperty(value = "第三个点位") + private String thirdlyAttrId; + + @ApiModelProperty(value = "第四个点位") + private String fourthAttrId; + + @ApiModelProperty(value = "第五个点位") + private String fifthAttrId; + + @ApiModelProperty(value = "开始时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + private LocalDateTime startTime; + + @ApiModelProperty(value = "结束时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + private LocalDateTime endTime; + + @ApiModelProperty(value = "厂组点/设备") + private Integer dimension; + + @ApiModelProperty(value = "维度 :0-10秒 、 1-1分钟 、2-5分钟 .....") + private Integer intervalType; + + @ApiModelProperty(value = "是否分页") + private Boolean isPage; + + @ApiModelProperty(value = "页码") + private Integer current; + + @ApiModelProperty(value = "页码条数") + private Integer pageSize; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java new file mode 100644 index 0000000..6ab8c38 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/history/vo/HistoryProjectAlarmVo.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.operational.history.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "历史告警数据查询") +public class HistoryProjectAlarmVo { + + @ApiModelProperty(value = "站点编号") + private String projectId; + + @ApiModelProperty(value = "维度") + private Integer dimension; + + @ApiModelProperty(value = "主键Id") + private String id; + + @ApiModelProperty(value = "告警类型") + private Integer soeType; + + @ApiModelProperty(value = "开始时间") + private String startTime; + + @ApiModelProperty(value = "结束时间") + private String endTime; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenanceTaskEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenanceTaskEntity.java index 2a94015..12fbd56 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenanceTaskEntity.java +++ b/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 = "创建用户名称") private String updateUserName; + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java index d0b79d3..37b03b0 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java +++ b/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 PROJECT_MANAGER = "projectManager"; } diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/CompensateProcessClientFallback.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/CompensateProcessClientFallback.java new file mode 100644 index 0000000..898d834 --- /dev/null +++ b/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 variables) { + return R.fail("流程开启失败,请稍后重试"); + } +} diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ICompensateProcessClient.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ICompensateProcessClient.java new file mode 100644 index 0000000..68ae4e8 --- /dev/null +++ b/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 variables); + +} diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/to/ProcessWorkFlowResponse.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/to/ProcessWorkFlowResponse.java index 7dafb53..29642e1 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/to/ProcessWorkFlowResponse.java +++ b/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 */ private String userId; + + private Integer code; + + private String result; + + private String deptId; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java index dfeb664..91dcac2 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/InnerDangerEntity.java +++ b/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("工作流是否运行正常") private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/entity/HazardTask.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/entity/HazardTask.java index bbeee20..b9a42b0 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/entity/HazardTask.java +++ b/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 = "流程步骤人员名称") private String nextStepOperator; + + @ApiModelProperty("工作流是否运行正常") + private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } \ No newline at end of file diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java index f01ff29..53134f1 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java +++ b/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("工作流是否运行正常") private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; + } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java index 59a74ca..95f329b 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java +++ b/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("是否运行正常") private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remarkFlow; + @TableField(exist = false) @ApiModelProperty("监护人确认结果:approved-确认,rejected-作废") diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java index 6d45228..00c31d3 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java +++ b/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("工作流是否运行正常") private Boolean isNormal; + @ApiModelProperty("工作流启动参数") + private String remark; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java index 8c75506..4952543 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java @@ -6,7 +6,6 @@ import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; import com.hnac.hzinfo.subscribe.SoeSubscribe; import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; -import org.eclipse.paho.client.mqttv3.MqttException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -61,11 +60,11 @@ public class MqttConfigHzims { log.info(fdpClient.toString()+fdpClient.getClientId()); //drools DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); - MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); + MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), droolsMqttConsumer); log.info(droolsClient.toString()+droolsClient.getClientId()); //Soe SoeSubscribe soeSubscribe = new SoeSubscribe(); - MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); + MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), soeMqttConsumer); log.info(soeClient.toString()+soeClient.getClientId()); //hz3000 HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); @@ -73,9 +72,9 @@ public class MqttConfigHzims { log.info(hz3000Client.toString()+hz3000Client.getClientId()); //视频 SoeSubscribe subscribe = new SoeSubscribe(); - MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); + MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), videoMqttConsumer); log.info(videoClient.toString()+videoClient.getClientId()); - }catch (MqttException e){ + }catch (Exception e){ log.error(e.toString()) ; } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/AlarmHandleController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/AlarmHandleController.java index 3739df0..574e95b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/AlarmHandleController.java +++ b/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) @ApiOperation(value = "告警处理", notes = "传入AlarmHandleEntity") public R execute(@RequestBody AlarmHandleFlowEntity param) { - return R.status(service.execute(param)); + return service.execute(param); } /** diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java index 9ff45bc..b1e3a7f 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java +++ b/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 org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; import org.springblade.system.user.entity.User; import java.util.List; @@ -19,7 +20,7 @@ import java.util.List; */ public interface AlarmHandleService extends IService { - boolean execute(AlarmHandleFlowEntity param); + R execute(AlarmHandleFlowEntity param); IPage pageCondition(Query query, HandleQueryVo param); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java index 85289f1..ed7a54c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java +++ b/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 map=new HashMap<>(); - map.put("uuid",param.getAlarmId()); - if (1L ==way){ - map.put("result","误报"); - map.put("diag_solution",param.getFalseAlarmDesc()); - } else if (2L ==way){ - map.put("result","延后处理"); - map.put("result_info",param.getDelayCause()); - }else { - map.put("result","处理中"); - } - log.info(map.toString()); - R r = iFdpDiagnoseClient.setFaultStatusInfo(map); - if (!r.isSuccess()){ - log.error("setFaultStatusInfo接口修改处理状态异常,请求数据为:"+map+"\n"+"参数为:"+param+r.getMsg()); + transactionTemplate.setTransactionManager(transactionManager); + String res = transactionTemplate.execute(status -> { + this.save(alarmHandleEntity); + //修改fdp对应得数据 + // 预警 + if(AlarmHandleConstant.EARLY_WARNING.equals(param.getAlarmType())){ + Map map=new HashMap<>(); + map.put("uuid",param.getAlarmId()); + if (1L ==way){ + map.put("result","误报"); + map.put("diag_solution",param.getFalseAlarmDesc()); + } else if (2L ==way){ + map.put("result","延后处理"); + map.put("result_info",param.getDelayCause()); + }else { + map.put("result","处理中"); + } + log.info(map.toString()); + R r = iFdpDiagnoseClient.setFaultStatusInfo(map); + if (!r.isSuccess()){ + log.error("setFaultStatusInfo接口修改处理状态异常,请求数据为:"+map+"\n"+"参数为:"+param+r.getMsg()); // throw new ServiceException("修改告警状态异常,请稍后重试!"); + } } - } - return JSONObject.toJSONString(alarmHandleEntity); + return JSONObject.toJSONString(alarmHandleEntity); + }); + return res; } @Override - public void startProcess(String entity, String dictValue) { + public R startProcess(String entity, String dictValue,String variable) { AlarmHandleFlowEntity param= JSONObject.parseObject(entity, AlarmHandleFlowEntity.class); if (AlarmHandleConstant.HANDLE.contains(param.getHandleWay())) { alarmHandleFlowMapper.insert(param); @@ -139,20 +151,43 @@ public class AlarmHandleServiceImpl extends ServiceImpl variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); - R result = processClient.startProcessInstanceContainNameByKey(AlarmHandleConstant.dealAlarm, businessKey, processName, variable); + Map variables =new HashMap<>(); + 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.setRemark(JSONObject.toJSONString(variable)); alarmHandleFlowMapper.updateById(param); + R r=new R(); + r.setCode(result.getCode()); + r.setMsg(result.getMsg()); + r.setData(variable); log.error("缺陷流程开启失败,错误描述 : " + result.getMsg()); - throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg()); + return r; }else { - param.setProcessInstanceId(result.getData().getProcessInstanceId()); + param.setIsNormal(true); + param.setProcessInstanceId(result.getData().toString()); 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 diff --git a/hzims-service/hzims-alarm/src/main/resources/db/3.0.0.sql b/hzims-service/hzims-alarm/src/main/resources/db/3.0.0.sql new file mode 100644 index 0000000..5aa1dfe --- /dev/null +++ b/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 ; diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java index f5a94d7..091a209 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java +++ b/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.processflow.entity.WorkflowOperationLog; 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.service.ProcessService; import lombok.extern.slf4j.Slf4j; @@ -37,7 +38,6 @@ public class StandardWorkTicketConsumer implements IQueueConsume { @Autowired private List ticketServiceList; - @Autowired private WorkflowOperationLogService workflowOperationLogService; @@ -48,6 +48,10 @@ public class StandardWorkTicketConsumer implements IQueueConsume { Assert.isTrue(Func.isNotEmpty(response),() -> { 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); log.setVariables(JSON.toJSONString(response.getVariables())); @@ -59,6 +63,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume { if(serviceOptional.isPresent()) { try { serviceOptional.get().calculate(response); + } catch (Exception e) { log.setFaultLog(e.getMessage()); diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java new file mode 100644 index 0000000..704276e --- /dev/null +++ b/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 variables) { + return processService.startFlow(userId,dictValue,taskId,processName,variables); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java index 0c51818..14e73c1 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/ProcessDictService.java @@ -16,6 +16,7 @@ public interface ProcessDictService extends IService { * 根据字典key查询字典value */ String selectDictValueByKey(String dictKey); + ProcessDict selectDictLabelByKey(String dictKey); diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/impl/ProcessDictServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/impl/ProcessDictServiceImpl.java index b6ada10..171d1ae 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/service/impl/ProcessDictServiceImpl.java +++ b/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 processDictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(baseMapper); + processDictLambdaQueryChainWrapper.eq(ProcessDict::getDictKey,dictKey); + return processDictLambdaQueryChainWrapper.one(); + } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java index 9ea4616..8c75ea7 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java +++ b/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; +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.operational.access.constants.AccessConstants; +import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant; 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.Qualifier; 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 @@ -14,6 +35,107 @@ import java.util.List; */ @Slf4j 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 variables) { + log.info("开启流程....."); + R 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 variables) { +// R 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 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> 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 result = sysClient.getDeptName(createUser.getCreateDept()); + if (result.isSuccess()) { + message.setDeptName(result.getData()); + } + List 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); + } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java index cf5f4ea..7869a16 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java +++ b/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.processflow.strategy.entity.WorkflowQueue; +import org.springblade.core.tool.api.R; + +import java.util.Map; /** * @Author dfy @@ -11,6 +14,9 @@ import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; */ public interface ProcessService { + R startFlow(String userId, String dictValue, String taskId, String processName, Map variables) ; + + void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId); /** * 设置执行那种实现类 * @param flowQueue diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java index 6eff952..d8d6cc8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java +++ b/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检修计划流程开启") @Operate(label = "检修计划流程开启",type = BusinessType.INSERT,risk = Risk.NO,ignore = false) public R startV4(@RequestBody AccessPlanV4DTO entity) { - return R.status(service.startProcessV4(entity)); + return service.startProcessV4(entity); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java index b852aec..2b1a417 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java +++ b/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{ - boolean startProcessV4(AccessPlanV4DTO entity); + R startProcessV4(AccessPlanV4DTO entity); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java index d6147c5..9db994d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java +++ b/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 { - void startProcessV4(AccessTaskV4DTO entity); + R startProcessV4(AccessTaskV4DTO entity); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index 99fd9b3..f633d72 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/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; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.constants.AccessConstants; 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.OperAccessPlanVO; 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.extern.slf4j.Slf4j; 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.feign.IUserClient; 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.support.TransactionCallback; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.CollectionUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -68,7 +81,7 @@ import java.util.stream.Collectors; @Service @Slf4j @RequiredArgsConstructor -public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ +public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProcessService { private final IOperAccessPlanService planService; @@ -85,6 +98,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ private final ISysClient sysClient; private final IFlowClient flowClient; + private final ICompensateProcessClient compensateProcessClient; private final IUserClient userClient; @@ -96,27 +110,79 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ * @return */ @Override - @Transactional(rollbackFor = Exception.class) - public boolean startProcessV4(AccessPlanV4DTO entity) { - // 步骤1.保存检修计划 - this.saveAccess(entity); + public R startProcessV4(AccessPlanV4DTO entity) { + String s = saveEntity(JSONObject.toJSONString(entity)); + // 步骤2.开启检修计划流程 + R r = this.startProcess(s, "overhaul_plan",null); + return r; + } - // 步骤2.保存检修材料 - this.saveAccessMaterial(entity); + 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.保存检修计划 + AccessPlanV4DTO saveAccess = saveAccess(accessPlanV4DTO); + + // 步骤2.保存检修材料 + saveAccessMaterial(accessPlanV4DTO); + // 步骤3.保存检修明细 + saveAccessContent(accessPlanV4DTO); + return JSONObject.toJSONString(saveAccess); + }); + return res; + } - // 步骤3.保存检修明细 - this.saveAccessContent(entity); + @Override + public R startProcess(String entity, String dictValue,String param) { + AccessPlanV4DTO accessPlanV4DTO= JSONObject.parseObject(entity, AccessPlanV4DTO.class); + Map 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; + } + } - // 步骤2.开启检修计划流程 - this.startProcess(entity); - return true; + @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 */ - 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.setProcDefId("overhaul_plan"); @@ -139,6 +205,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setUpdateUserName(user.getNickName()); } planService.save(entity); + return entity; } @@ -208,25 +275,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ /** - * 开启检修计划流程 - * @param entity - */ - private void startProcess(AccessPlanV4DTO entity) { - Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); - variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); - R 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 * @return @@ -239,6 +287,11 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setTaskName(processWorkFlowResponse.getTaskName()); // 流程阶段执行人员名称 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")){ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); @@ -256,13 +309,17 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ return this.planService.updateById(entity); } log.error("plan_listener_entity:{}",entity); + String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + //流程找不到下一个审批人处理 this.planService.updateById(entity); this.saveAccessMaterial(entity); this.saveAccessContent(entity); - String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName()) - .concat(",当前环节:") - .concat(processWorkFlowResponse.getTaskName()); - this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + if(700!=processWorkFlowResponse.getCode()){ + + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + } return true; } @@ -609,4 +666,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ headStyle.setFont(font); return headStyle; } + + } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java index 18cbe09..0761305 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java +++ b/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; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.middle.process.feign.ICompensateProcessClient; 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.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO; -import com.hnac.hzims.operational.access.entity.OperAccessContentEntity; -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.entity.*; import com.hnac.hzims.operational.access.mapper.OperAccessTaskMapper; import com.hnac.hzims.operational.access.service.*; 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.extern.slf4j.Slf4j; 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.Query; 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.feign.IUserClient; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; import java.text.DecimalFormat; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -54,7 +59,7 @@ import java.util.stream.Collectors; @Service @Slf4j @RequiredArgsConstructor -public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { +public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProcessService { private final IOperAccessTaskService taskService; @@ -75,54 +80,88 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { private final IUserClient userClient; private final IMessageClient messageClient; - + private final ICompensateProcessClient compensateProcessClient; /** * 开启检修任务流程 * @param entity * @return */ @Override - @Transactional(rollbackFor = Exception.class) - public void startProcessV4(AccessTaskV4DTO entity) { - // 步骤1.保存检修任务 - this.save(entity); - - // 步骤2.保存检修材料 - this.saveMaterial(entity); + public R startProcessV4(AccessTaskV4DTO entity) { + String saved = saveEntity(JSONObject.toJSONString(entity)); + // 步骤4.开启检修任务流程 + R r = this.startProcess(saved, "overhaul_task",null); + return r; + } + private final PlatformTransactionManager transactionManager; + private final TransactionTemplate transactionTemplate; - // 步骤3.保存检修详情 - this.saveDetails(entity); + @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.保存检修材料 + this.saveMaterial(accessTaskV4DTO); + // 步骤3.保存检修详情 + this.saveDetails(accessTaskV4DTO); + return JSONObject.toJSONString(save); + }); + return res; - // 步骤4.开启检修任务流程 - this.startProcess(entity); } - /** - * 开启检修流程 - * @param entity - */ - private void startProcess(AccessTaskV4DTO entity) { - Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); - if(ObjectUtil.isNotEmpty(entity.getCreateUser())){ - variables.put("startFlowUserId",entity.getCreateUser().toString()); + @Override + public R startProcess(String entity, String dictValue,String param) { + AccessTaskV4DTO accessTaskV4DTO= JSONObject.parseObject(entity, AccessTaskV4DTO.class); + Map 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("solve",TaskUtil.getTaskUser(entity.getHandler().toString())); - R result = flowClient.startProcessInstanceContainNameByKey("overhaul_task", FlowUtil.getBusinessKey("access_task_v4", String.valueOf(entity.getId())), entity.getName(),variables); + if(ObjectUtil.isNotEmpty(accessTaskV4DTO.getCreateUser())){ + variables.put("startFlowUserId",accessTaskV4DTO.getCreateUser().toString()); + } + variables.put("solve",TaskUtil.getTaskUser(accessTaskV4DTO.getHandler().toString())); + R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue, + FlowUtil.getBusinessKey("access_task_v4", + String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables); + log.error("开启检修任务流程失败{}" + result); // 更新任务流程Id - if (result.isSuccess()) { - BladeFlow flow = result.getData(); - entity.setProcessInstanceId(flow.getProcessInstanceId()); - taskService.updateById(entity); + if (200==result.getCode()) { + accessTaskV4DTO.setProcessInstanceId(result.getData().toString()); + accessTaskV4DTO.setIsNormal(true); + taskService.updateById(accessTaskV4DTO); + return R.success("启动流程成功"); } 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 */ - 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))); if (ObjectUtil.isNotEmpty(entity.getHandler())){ User user = UserCache.getUser(entity.getHandler()); @@ -133,6 +172,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { } } taskService.save(entity); + return entity; } /** @@ -195,6 +235,11 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { // 对象转换 Map variables = (Map) processWorkFlowResponse.getVariables(); AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); + entity.setIsNormal(true); + if(700==processWorkFlowResponse.getCode()){ + entity.setIsNormal(false); + entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + } // 当前流程名称 entity.setTaskName(processWorkFlowResponse.getTaskName()); // 流程阶段执行人员名称 @@ -221,7 +266,9 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName()) .concat(",当前环节:") .concat(processWorkFlowResponse.getTaskName()); - this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + if(700!=processWorkFlowResponse.getCode()){ + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + } return true; } @@ -295,4 +342,6 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords())); return pages; } + + } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java index 184304c..ed16fcd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java @@ -80,7 +80,7 @@ public class OperAccessPlanServiceImpl extends ServiceImpl result = processClient.getTaskByProcessInstanceIdAndUserId(processInstanceId,"taskUser_" + previousHandleUser); + R result = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId,"taskUser_" + previousHandleUser); if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ throw new ServiceException("获取缺陷流程失败!"); } @@ -315,7 +315,7 @@ public class OperAccessPlanServiceImpl extends ServiceImpl> communications(String roleId,Date start,@RequestParam Date end){ + public R> communications(String roleId,Date start,Date end){ return R.data(monitorService.communications(roleId,start,end)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/DefectCheckController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/DefectCheckController.java index 4486899..4db04a9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/DefectCheckController.java +++ b/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; 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.service.IDefectCheckService; +import com.hnac.hzims.operational.defect.service.impl.DefectCheckServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -10,10 +12,7 @@ import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @author ysj @@ -25,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController; @Validated 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) @ApiOperation(value = "保存现象、开启缺陷处理流程", notes = "现象对象") 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); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/OperDefectClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/OperDefectClient.java index 33366bf..7a66a6e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/OperDefectClient.java +++ b/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) @Override public R createDefect(@RequestBody OperPhenomenonEntity entity) { - return R.data(defectCheckService.startCheck(entity)); + return defectCheckService.startCheck(entity); } @PostMapping(SAVE_DEFECT) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java index 9df20ba..251df75 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IDefectCheckService.java @@ -21,7 +21,7 @@ public interface IDefectCheckService extends IService { * @param phenomenon * @return */ - OperPhenomenonEntity startCheck(OperPhenomenonEntity phenomenon); + R startCheck(OperPhenomenonEntity phenomenon); /** * 监听回调消息 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java index 4c48585..14a5ecb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java +++ b/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; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; 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.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; 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.Func; 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.message.MessageConstants; 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.data.redis.core.RedisTemplate; 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 java.beans.BeanInfo; @@ -69,7 +72,7 @@ import java.util.concurrent.TimeUnit; @Service @Slf4j @RequiredArgsConstructor -public class DefectCheckServiceImpl extends ServiceImpl implements IDefectCheckService { +public class DefectCheckServiceImpl extends ServiceImpl implements IDefectCheckService , StartProcessService { private final IOperDefectService defectService; @@ -79,13 +82,15 @@ public class DefectCheckServiceImpl extends ServiceImpl() {{ - eq(OperPhenomenonEntity::getDefectCode, entity.getDefectCode()); - last("limit 1"); - }}); - this.startDefectCheckV2(operPhenomenon); + String saved = saveEntity(JSONObject.toJSONString(entity)); +// if (!this.savePhenomenon(entity)) { +// throw new ServiceException("保存现象失败!"); +// } +// // 步骤2.开启缺陷流程 +// OperPhenomenonEntity operPhenomenon = this.getOne(new LambdaQueryWrapper() {{ +// eq(OperPhenomenonEntity::getDefectCode, entity.getDefectCode()); +// last("limit 1"); +// }}); +// this.startDefectCheckV2(operPhenomenon); + r= this.startProcess(saved, TreatMethodConstant.DEFECT_CHECK,null); redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁 } else { // 加锁失败,抛出异常 throw new ServiceException("开启现象流程失败!"); } - return entity; + return r ; }catch (Exception e){ e.printStackTrace(); log.error("保存现象失败!"+e); @@ -138,13 +145,9 @@ public class DefectCheckServiceImpl extends ServiceImpl" + entity.getFaultName(); // 开启新的缺陷流程 String businessKey = FlowUtil.getBusinessKey("hzims_oper_phenomenon", "" + entity.getId()); - Map variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); -// variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); - R result = processClient.startProcessInstanceContainNameByKey(TreatMethodConstant.DEFECT_CHECK, businessKey, processName, variable); + Map 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); + } + R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), dictValue, businessKey, processName, variables); +// R result = processClient.startProcessInstanceContainNameByKey( dictValue,businessKey, processName, variable); // 流程开启失败 - if (!result.isSuccess()) { - throw new ServiceException("缺陷流程开启失败,错误描述 : " + result.getMsg()); + if (200!=result.getCode()) { + entity.setIsNormal(false); + entity.setRemark(JSONObject.toJSONString(variables)); + this.baseMapper.updateById(entity); + log.error("缺陷流程开启失败,错误描述 : " + result.getMsg()); + return result; } // 关联流程唯一键 - entity.setCheckProcessInstanceId(result.getData().getProcessInstanceId()); - operDefectStatisticsEntity.setCheckProcessInstanceId(result.getData().getProcessInstanceId()); + entity.setIsNormal(true); + entity.setCheckProcessInstanceId(result.getData().toString()); + OperDefectStatisticsEntity operDefectStatisticsEntity = new OperDefectStatisticsEntity(); + BeanUtil.copy(entity, operDefectStatisticsEntity); + operDefectStatisticsEntity.setCheckProcessInstanceId(result.getData().toString()); this.baseMapper.updateById(entity); 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 * @@ -348,6 +377,14 @@ public class DefectCheckServiceImpl extends ServiceImpl { * @param recDTO 交接班信息 * @return 交接班成功与否flag */ - Boolean changeShift(ImsDutyRecDTO recDTO); + R changeShift(ImsDutyRecDTO recDTO); /** * 执行工作流 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 2ec88ae..9a8e991 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/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.extension.service.impl.ServiceImpl; 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.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.constant.DutyProcessConstant; 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.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.message.MessageConstants; 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.springframework.beans.factory.annotation.Autowired; 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.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; @@ -79,7 +91,7 @@ import static org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME; */ @Slf4j @Service -public class ImsDutyRecServiceImpl extends ServiceImpl implements IImsDutyRecService { +public class ImsDutyRecServiceImpl extends ServiceImpl implements IImsDutyRecService, StartProcessService { @Resource private ITicketInfoClient ticketInfoClient; @Autowired @@ -110,7 +122,12 @@ public class ImsDutyRecServiceImpl extends ServiceImpl { @@ -228,21 +255,81 @@ public class ImsDutyRecServiceImpl extends ServiceImpl 0) { - recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); - } + transactionTemplate.setTransactionManager(transactionManager); + String res = transactionTemplate.execute(status -> { + // 在这里执行需要事务控制的代码 + + if(Func.isNotEmpty(duration) && duration > 0) { + recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); + } + ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class); + if (Func.isEmpty(recEntity.getId())) { + save(recEntity); + } + ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity(); + imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME)); + 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); - if (Func.isEmpty(recEntity.getId())) { - save(recEntity); - } - ImsDutyLogEntity imsDutyLogEntity = recDTO.getImsDutyLogEntity(); - imsDutyLogEntity.setHandTime(DateUtil.format(new Date(),PATTERN_DATETIME)); - imsDutyLogService.saveOrUpdate(imsDutyLogEntity); // 开启值班交接班流程 recEntity.setQrCodeContent(System.currentTimeMillis() + ""); - BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); - recEntity.setProcessInstanceId(bladeFlow.getProcessInstanceId()); - return updateById(recEntity); + // 获取班组组长 + Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId()); + Assert.isTrue(Func.isNotEmpty(managerId),() -> { + throw new ServiceException("获取值班班组长失败!"); + }); + ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getDutyId()); + recDTO.setHeadDutyMainVo(currentDuty); + List carryDuties = imsDutyMainService.list(Wrappers.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 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> projectAlarm(HistoryProjectAlarmVo alarm, Query query) { + return R.data(alarmService.projectAlarm(alarm,query)); + } + + + @GetMapping("/projectFacDevice") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "站点厂组", notes = "根据站点id查询厂组信息") + public R> projectFacDevice(@RequestParam(value = "projectId") String projectId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectFacDevice(projectId,attrName)); + } + + @GetMapping("/projectFacDeviceAttr") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "站点厂租点", notes = "根据厂组Id查询厂组点信息") + public R> projectFacDeviceAttr(@RequestParam(value = "facDeviceId") String facDeviceId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectFacDeviceAttr(facDeviceId,attrName)); + } + @GetMapping("/projectDeviceInstance") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "站点虚拟设备息", notes = "根据站点id查询虚拟设备") + public R> projectDeviceInstance(@RequestParam(value = "projectId") String projectId, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectDeviceInstance(projectId,attrName)); + } + + @GetMapping("/projectDeviceInstanceAttr") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "设备点位信息", notes = "根据设备编号查询点位") + public R> projectDeviceInstanceAttr(@RequestParam(value = "deviceCode") String deviceCode, + @RequestParam(value = "attrName",required = false) String attrName) { + return R.data(pointService.projectDeviceInstanceAttr(deviceCode,attrName)); + } + + @PostMapping("/historicalCurve") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "查询历史数据曲线图", notes = "获取历史数据折线图数据") + public R> historicalCurve(@RequestBody HistoricalCurveVo curve) { + return R.data(pointService.historicalCurve(curve)); + } + + @PostMapping("/attrStatistics") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "历史数据统计", notes = "获取历史数据统计数据") + public R> attrStatistics(@RequestBody HistoricalCurveVo curve) { + return R.data(pointService.attrStatistics(curve)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java new file mode 100644 index 0000000..712fefd --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.history.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; + +import javax.management.Query; +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +public interface AlarmService { + + + Map projectAlarm(HistoryProjectAlarmVo alarm, Query query); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java new file mode 100644 index 0000000..3588143 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/PointService.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.operational.history.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; +import com.hnac.hzinfo.dataconfig.entity.Device; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +public interface PointService { + + + List projectFacDevice(String projectId, String attrName); + + List projectFacDeviceAttr(String facDeviceId, String attrName); + + List projectDeviceInstance(String projectId,String attrName); + + List projectDeviceInstanceAttr(String deviceCode, String attrName); + + Map historicalCurve(HistoricalCurveVo curve); + + Map attrStatistics(HistoricalCurveVo curve); +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java new file mode 100644 index 0000000..daeca61 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java @@ -0,0 +1,51 @@ +package com.hnac.hzims.operational.history.service.impl; + +import com.hnac.hzims.operational.history.service.AlarmService; +import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import javax.management.Query; +import java.util.HashMap; +import java.util.Map; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class AlarmServiceImpl implements AlarmService { + + private final SoeDataClient soeClient; + + + /** + * 查询站点告警数据 + * @param alarm + * @param query + * @return + */ + @Override + public Map projectAlarm(HistoryProjectAlarmVo alarm, Query query) { + Result> result = soeClient.getDeviceSoeData( + alarm.getProjectId(), + alarm.getDimension(), + alarm.getId(), + alarm.getSoeType(), + alarm.getStartTime(), + alarm.getEndTime(), + query + ); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new HashMap<>(); + } + return result.getData(); + } + + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java new file mode 100644 index 0000000..5ea8453 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/PointServiceImpl.java @@ -0,0 +1,151 @@ +package com.hnac.hzims.operational.history.service.impl; + +import com.hnac.hzims.operational.history.service.PointService; +import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; +import com.hnac.hzinfo.sdk.core.response.DataResultCode; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +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.hzfac.HzFacClient; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; +import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class PointServiceImpl implements PointService { + + private final DeviceDataClient deviceDataClient; + + private final ProjectClient projectClient; + + private final DeviceClient deviceClient; + + private final HzFacClient hzFacClient; + + + /** + * 根据站点查询厂组点信息 + * @param projectId + * @return + */ + @Override + public List projectFacDevice(String projectId,String attrName) { + Result> result = hzFacClient.facDeviceByProjectId(projectId,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + /** + * 根据厂组Id查询厂组点信息 + * @param facDeviceId + * @param attrName + * @return + */ + @Override + public List projectFacDeviceAttr(String facDeviceId, String attrName) { + Result> result = hzFacClient.facDeviceAttrList(facDeviceId,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + /** + * 根据站点查询虚拟设备 + * @param projectId + * @return + */ + @Override + public List projectDeviceInstance(String projectId,String attrName) { + R> result = deviceClient.getOnlineDeviceInstanceSearchName(projectId,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + /** + * 查询站点厂组/设备点位信息 + * @param deviceCode + * @param attrName + * @return + */ + @Override + public List projectDeviceInstanceAttr(String deviceCode, String attrName) { + Result> result = deviceClient.getDeviceAttrByName(deviceCode,attrName); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + /** + * 查询历史数据曲线图 + * @return + */ + @Override + public Map historicalCurve(HistoricalCurveVo curve) { + Result> result = deviceDataClient.getLineDataByRealId( + curve.getFirstAttrId(), + curve.getSecondAttrId(), + curve.getThirdlyAttrId(), + curve.getFourthAttrId(), + curve.getFifthAttrId(), + curve.getStartTime(), + curve.getEndTime(), + curve.getDimension(), + curve.getIntervalType(), + curve.getIsPage(), + curve.getCurrent(), + curve.getPageSize() + ); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + /** + * 历史数据统计 + * @param curve + * @return + */ + @Override + public Map attrStatistics(HistoricalCurveVo curve) { + Result> result = deviceDataClient.getAttrStatistics( + curve.getFirstAttrId(), + curve.getSecondAttrId(), + curve.getThirdlyAttrId(), + curve.getFourthAttrId(), + curve.getFifthAttrId(), + curve.getStartTime(), + curve.getEndTime(), + curve.getDimension(), + curve.getIntervalType()); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + throw new ServiceException(DataResultCode.FAIL,result.getMsg()); + } + return result.getData(); + } + + +} + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java index 70bbe2f..c40702b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java +++ b/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; +import com.alibaba.fastjson.JSONObject; 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.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.equipment.entity.EmInfoEntity; 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.duty.entity.ImsDutyMainEntity; 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.OperMaintenanceTaskEntity; -import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceLibraryMapper; import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; 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.handler.annotation.XxlJob; 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.system.user.cache.UserCache; 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.stereotype.Component; @@ -41,7 +37,6 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -54,7 +49,7 @@ import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant @Component @Slf4j @AllArgsConstructor -public class MaintenanceTaskSchedule { +public class MaintenanceTaskSchedule implements StartProcessService { private final IOperMaintenancePlanService planService; private final IOperMaintenanceTaskService taskService; @@ -176,9 +171,22 @@ public class MaintenanceTaskSchedule { * @param task 日常维护任务 * @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())) { - return null; + log.error("找不到日常维护执行人{}",task); + return R.success("日程维护执行成功"); } OperMaintenanceTaskEntityVo vo = BeanUtil.copy(task,OperMaintenanceTaskEntityVo.class); Map params = new HashMap() {{ @@ -194,7 +202,25 @@ public class MaintenanceTaskSchedule { }); put("operMaintenanceTaskEntityVo",vo); }}; - R flowResult = flowClient.startProcessInstanceContainNameByKey(FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY, String.valueOf(task.getId()), task.getTitle(), params); - return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); + R flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params); + 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; } } diff --git a/hzims-service/operational/src/main/resources/db/3.0.1.sql b/hzims-service/operational/src/main/resources/db/3.0.1.sql new file mode 100644 index 0000000..0dc314e --- /dev/null +++ b/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 ; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java index 56a53d7..6efee20 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java +++ b/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.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; @@ -81,10 +80,11 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl { - boolean startProcess(HazardRiskProcessDTO process); + R startProcess(HazardRiskProcessDTO process); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java index d87116d..d78a2fb 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java +++ b/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.TypeReference; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; 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.flow.service.IInnerDangerFlowService; 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.vo.*; import com.hnac.hzims.safeproduct.statistic.vo.RiskInnerVO; -import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; 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.utils.*; 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.system.cache.DictCache; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; import java.util.*; import java.util.stream.Collectors; @@ -59,19 +65,23 @@ public class HazardTaskServiceImpl extends ServiceImpl{ - HazardEstimateVo estimate = new HazardEstimateVo(); - estimate.setCategoryId(source.getCategoryId()); - estimate.setTaskId(process.getId()); - estimate.setSourceId(source.getId()); - estimate.setHazardName(source.getHazardName()); - estimate.setAccidentIncentive(source.getAccidentIncentive()); - estimate.setCauseConsequence(source.getCauseConsequence()); - estimate.setEvaluationMethod(source.getEvaluationMethod()); - estimate.setLUpLimit(source.getLUpLimit()); - estimate.setLDownLimit(source.getLDownLimit()); - estimate.setEUpLimit(source.getEUpLimit()); - estimate.setEDownLimit(source.getLDownLimit()); - estimate.setCSUpLimit(source.getCSUpLimit()); - estimate.setCSDownLimit(source.getCSDownLimit()); - return estimate; - }).collect(Collectors.toList())); - hazardEstimateService.saveBatch(process.getEstimates()); - return JSON.toJSONString(process); + //增加事务 + transactionTemplate.setTransactionManager(transactionManager); + String res = transactionTemplate.execute(status -> { + // 保存任务 + super.save(process); + // 生成风险评估记录 + process.setEstimates(sources.stream().map(source->{ + HazardEstimateVo estimate = new HazardEstimateVo(); + estimate.setCategoryId(source.getCategoryId()); + estimate.setTaskId(process.getId()); + estimate.setSourceId(source.getId()); + estimate.setHazardName(source.getHazardName()); + estimate.setAccidentIncentive(source.getAccidentIncentive()); + estimate.setCauseConsequence(source.getCauseConsequence()); + estimate.setEvaluationMethod(source.getEvaluationMethod()); + estimate.setLUpLimit(source.getLUpLimit()); + estimate.setLDownLimit(source.getLDownLimit()); + estimate.setEUpLimit(source.getEUpLimit()); + estimate.setEDownLimit(source.getLDownLimit()); + estimate.setCSUpLimit(source.getCSUpLimit()); + estimate.setCSDownLimit(source.getCSDownLimit()); + return estimate; + }).collect(Collectors.toList())); + hazardEstimateService.saveBatch(process.getEstimates()); + return JSON.toJSONString(process); + }); + return res; + } @Override - public void startProcess(String entity, String dictValue) { + public R startProcess(String entity, String dictValue,String param) { HazardRiskProcessDTO process= JSONObject.parseObject(entity, HazardRiskProcessDTO.class); - // 查询作业区域负责人 - Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class); - variables.put(HazardRiskConstants.TROUBLE, TaskUtil.getTaskUser(String.valueOf(process.getHead()))); - R result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey(HazardRiskConstants.HAZARD_RISK_KEY,String.valueOf(process.getId())), process.getTaskName(), variables); + Map variables =new HashMap<>(); + 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()))); + } + 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); // 更新任务流程Id - if (result.isSuccess()) { - BladeFlow flow = result.getData(); - process.setProcessInstanceId(flow.getProcessInstanceId()); + if (200==result.getCode()) { + process.setIsNormal(true); + process.setProcessInstanceId(result.getData().toString()); this.updateById(process); + return R.success("启动流程成功"); } 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 @@ -192,6 +231,12 @@ public class HazardTaskServiceImpl extends ServiceImpl { - boolean start(WorkTaskVO workTask); + R start(WorkTaskVO workTask); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java index 576ff43..bcc9bd5 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java @@ -79,12 +79,12 @@ public class WorkTaskServiceImpl extends ServiceImpl variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead()))); @@ -143,9 +143,15 @@ public class WorkTaskServiceImpl extends ServiceImpl processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params); + R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), + standardTicketInfoVo.getTitle(), params); if (!processInstanceContainNameByKey.isSuccess()) { standardTicketInfoEntity.setIsNormal(false); + standardTicketInfoEntity.setRemarkFlow(JSONObject.toJSONString(params)); standardTicketInfoService.save(standardTicketInfoEntity); + R r=new R(); + r.setCode(processInstanceContainNameByKey.getCode()); + r.setMsg(processInstanceContainNameByKey.getMsg()); + r.setData(params); log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg()); - throw new ServiceException("不好意思,您暂无权限..."); + return r; } Duration between = Duration.between(start, Instant.now()); log.info("================================================================"); log.info("耗时: " + (between.getSeconds()) + "秒"); log.info("耗时: " + (between.toMillis()) + "毫秒"); log.info("================================================================"); + return R.success("启动流程成功"); } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java index 6792a43..2f84c19 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java @@ -48,8 +48,7 @@ public class TicketProcessController { @PostMapping("/startUp") @Operate(label = "工作票开票",type = BusinessType.INSERT,risk = Risk.LOW,ignore = false) public R start(@RequestBody WorkTicketVo workTicketVo) { - Long ticketId = ticketProcessService.startUp(workTicketVo); - return R.data(ticketId); + return ticketProcessService.startUp(workTicketVo); } @ApiOperation("开启工作票线下流程") diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java index e343357..9603b49 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java +++ b/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.ticket.twoTicket.vo.process.WorkTicketVo; +import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; import java.util.Map; @@ -18,7 +19,7 @@ public interface TicketProcessService { /** * 启动开票流程 */ - Long startUp(WorkTicketVo workTicketVo); + R startUp(WorkTicketVo workTicketVo); /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 425df0e..5c47f1e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/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.utils.WordHelper; 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.WorkTicketVo; import com.hnac.hzims.ticket.utils.MergeDocUtils; @@ -164,7 +163,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc // @SneakyThrows @Override @Transactional - public Long startUp(WorkTicketVo workTicketVo) { + public R startUp(WorkTicketVo workTicketVo) { log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); //保存操作票 @@ -177,10 +176,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc throw new ServiceException("服务器异常,请联系管理员"); } //开启动作流 - this.startProcess(saveEntity,dictValue); + R r = this.startProcess(saveEntity, dictValue); // //处理任务--老版本业务要求,2024/07/05弃用 // this.returnTicket(workTicketVo); - return workTicketVo.getWorkTicket().getId(); + return r; } @Override @@ -237,7 +236,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc } @Override - public void startProcess(String entity, String dictValue) { + public R startProcess(String entity, String dictValue) { WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket()); workTicketVo.setWorkTicket(workTicket); @@ -245,7 +244,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc //若为线下工作票 则无需开启工作流 Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus(); if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { - return; + return R.success("线下流程,开票成功"); } Map params = new HashMap<>(4); params.put("workTicketVo", workTicketVo); @@ -262,13 +261,18 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc if (!processInstanceContainNameByKey.isSuccess()) { //保存流程开始失败情况 workTicket.setIsNormal(false); + workTicket.setRemark(JSONObject.toJSONString(params)); boolean isSave = firstWorkTicketService.save(workTicket); log.info("ticket:start:save",JSON.toJSONString(workTicket)); if (!isSave) { throw new IllegalArgumentException("保存工作对象错误"); } log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); - throw new ServiceException("流程开启失败,请检查流程和用户权限后重试!"); + R r=new R(); + r.setCode(processInstanceContainNameByKey.getCode()); + r.setMsg("流程开启失败,请检查流程和用户权限后重试!"); + r.setData(params); + return r; } log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); Duration between = Duration.between(start, Instant.now()); @@ -277,6 +281,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc log.info("耗时: " + (between.getSeconds()) + "秒"); log.info("耗时: " + (between.toMillis()) + "毫秒"); log.info("================================================================"); + return R.success("启动流程成功"); } /** * 验证是走那种工作票流程,默认走第一种工作票 @@ -1406,6 +1411,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc Assert.isTrue(flowR.isSuccess(),() -> { //保存流程开始失败情况 workTicket.setIsNormal(false); + workTicket.setRemark(JSON.toJSONString(params)); boolean isSave = firstWorkTicketService.save(workTicket); log.info("ticket:start:save",JSON.toJSONString(workTicket)); if (!isSave) { diff --git a/hzims-service/ticket/src/main/resources/db/3.0.0.sql b/hzims-service/ticket/src/main/resources/db/3.0.0.sql new file mode 100644 index 0000000..101eda0 --- /dev/null +++ b/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 ;