Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

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

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

@ -1,9 +1,7 @@
package com.hnac.hzims.common.flow;
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);
}

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

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

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

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

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

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

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

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

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

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

59
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;
}

32
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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9
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()) ;
}
}

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

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

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

@ -8,6 +8,7 @@ import com.hnac.hzims.alarm.config.vo.AlarmHandleVo;
import com.hnac.hzims.alarm.show.vo.HandleQueryVo;
import 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<AlarmHandleEntity> {
boolean execute(AlarmHandleFlowEntity param);
R execute(AlarmHandleFlowEntity param);
IPage<AlarmHandleVo> pageCondition(Query query, HandleQueryVo param);

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

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

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

@ -1,7 +1,9 @@
package com.hnac.hzims.alarm.show.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.alarm.config.entity.AlarmHandleEntity;
import com.hnac.hzims.alarm.config.entity.AlarmHandleFlowEntity;
@ -15,7 +17,9 @@ import com.hnac.hzims.alarm.show.wrapper.HandleWrapper;
import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient;
import com.hnac.hzims.safeproduct.vo.InnerDangerVo;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
@ -32,6 +36,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.*;
import java.util.stream.Collectors;
@ -59,7 +65,9 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
private final IFdpDiagnoseClient iFdpDiagnoseClient;
private final AlarmHandleFlowMapper alarmHandleFlowMapper;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/**
* 告警处理
@ -68,11 +76,11 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
* @return
*/
@Override
public boolean execute(AlarmHandleFlowEntity param) {
saveEntity(JSONObject.toJSONString(param));
public R execute(AlarmHandleFlowEntity param) {
String s = saveEntity(JSONObject.toJSONString(param));
//开启流程
return true;
R r = startProcess(s, AlarmHandleConstant.dealAlarm,null);
return r;
}
@Override
@ -105,6 +113,8 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
param.setCreateUserName(AuthUtil.getUserName());
alarmHandleEntity.setCreateDeptName(param.getCreateDeptName());
}
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
this.save(alarmHandleEntity);
//修改fdp对应得数据
// 预警
@ -128,10 +138,12 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
}
}
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<AlarmHandleMapper, Alarm
String processName = "[" + AuthUtil.getUserName() + "] 发起 " + "【" + param.getAlarmContent() + "】告警处理流程";
// 开启告警处理流程
String businessKey = FlowUtil.getBusinessKey("hzims_alarm_handle", "" + param.getId());
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(AlarmHandleConstant.dealAlarm, businessKey, processName, variable);
Map<String, Object> 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

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

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

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

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.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<ProcessService> 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());

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

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

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

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

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

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

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

@ -1,10 +1,31 @@
package com.hnac.hzims.middle.processflow.strategy.abstracts;
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<String, Object> variables) {
log.info("开启流程.....");
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables);
R r = new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
// 更新任务流程Id
if (result.isSuccess()) {
log.info("开启流程成功:{}",variables);
BladeFlow flow = result.getData();
r.setData(flow.getProcessInstanceId());
} else {
log.error("开启流程失败:{}",result);
log.error("流程信息为{}",variables);
r.setData(variables);
pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg());
}
return r;
}
// public R compensateFlow(String userId,String dictValue,String taskId,String processName,Map<String, Object> variables) {
// R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables);
// log.error("start_process_planV4 :{}", result);
// R r = new R();
// r.setCode(result.getCode());
// r.setMsg(result.getMsg());
// // 更新任务流程Id
// if (result.isSuccess()) {
// BladeFlow flow = result.getData();
// r.setData(flow.getProcessInstanceId());
// } else {
// r.setData(variables);
// pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg());
// }
// return r;
// }
public void pushStartFailMessage(String dictValue,Long taskId, String userId, String content,String reason) {
ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue);
BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id
message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题
message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription());
// 内容
String res= StringUtil.format("你有一个{}的{}流程开启失败,失败原因为:{}",content,
processDict.getDictLabel(), reason);
message.setContent(res);
message.setTenantId("200000");
User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData();
message.setDeptId(createUser.getCreateDept());
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) {
message.setDeptName(result.getData());
}
message.setCreateUser(admin.getId());
message.setUserIds(userId);
messageClient.sendAppAndWsMsgByUsers(message);
}
@Override
public void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId) {
ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey);
BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id
message.setTaskId(taskId);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题
message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription());
// 内容
String res= StringUtil.format("你有一个{}的{}流程流转失败,失败原因为:{}",content,
processDict.getDictLabel(), reason);
message.setContent(res);
message.setTenantId("200000");
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER);
User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData();
message.setDeptId(createUser.getCreateDept());
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) {
message.setDeptName(result.getData());
}
List<User> data = userListR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setCreateUser(admin.getId());
message.setUserIds(userIds);
messageClient.sendAppAndWsMsgByUsers(message);
}
}

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

@ -2,6 +2,9 @@ package com.hnac.hzims.middle.processflow.strategy.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.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<String, Object> variables) ;
void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId);
/**
* 设置执行那种实现类
* @param flowQueue

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

@ -41,7 +41,7 @@ public class AccessPlanV4Controller extends BladeController {
@ApiOperation(value = "v4检修计划流程开启")
@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);
}

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

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

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

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

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

@ -1,12 +1,16 @@
package com.hnac.hzims.operational.access.service.impl;
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) {
public R startProcessV4(AccessPlanV4DTO entity) {
String s = saveEntity(JSONObject.toJSONString(entity));
// 步骤2.开启检修计划流程
R r = this.startProcess(s, "overhaul_plan",null);
return r;
}
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
@Override
public String saveEntity(String entity) {
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
AccessPlanV4DTO accessPlanV4DTO = JSONObject.parseObject(entity, AccessPlanV4DTO.class);
// 步骤1.保存检修计划
this.saveAccess(entity);
AccessPlanV4DTO saveAccess = saveAccess(accessPlanV4DTO);
// 步骤2.保存检修材料
this.saveAccessMaterial(entity);
saveAccessMaterial(accessPlanV4DTO);
// 步骤3.保存检修明细
this.saveAccessContent(entity);
saveAccessContent(accessPlanV4DTO);
return JSONObject.toJSONString(saveAccess);
});
return res;
}
// 步骤2.开启检修计划流程
this.startProcess(entity);
return true;
@Override
public R startProcess(String entity, String dictValue,String param) {
AccessPlanV4DTO accessPlanV4DTO= JSONObject.parseObject(entity, AccessPlanV4DTO.class);
Map<String, Object> variables =new HashMap<>();
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class);
}
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue, FlowUtil.getBusinessKey("access_plan_v4",
String.valueOf(accessPlanV4DTO.getId())), accessPlanV4DTO.getName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (200==result.getCode()) {
accessPlanV4DTO.setProcessInstanceId(result.getData().toString());
accessPlanV4DTO.setIsNormal(true);
planService.updateById(accessPlanV4DTO);
return R.success("启动流程成功");
} else {
accessPlanV4DTO.setIsNormal(false);
accessPlanV4DTO.setRemark(JSONObject.toJSONString(variables));
planService.updateById(accessPlanV4DTO);
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variables);
return r;
}
}
@Override
public R compensationProcess(String id) {
OperAccessPlanEntity entity = planService.getById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), "overhaul_plan",entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
}
/**
* 保存检修计划
* @param entity
*/
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<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class);
variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("overhaul_plan", FlowUtil.getBusinessKey("access_plan_v4",String.valueOf(entity.getId())), entity.getName(), variables);
log.error("start_process_planV4 :{}",result);
// 更新任务流程Id
if (result.isSuccess()) {
BladeFlow flow = result.getData();
entity.setProcessInstanceId(flow.getProcessInstanceId());
planService.updateById(entity);
} else {
throw new ServiceException("开启检修计划流程失败,code=" + result.getCode());
}
}
/**
* 检修计划流程监听
* @param processWorkFlowResponse
* @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);
this.planService.updateById(entity);
this.saveAccessMaterial(entity);
this.saveAccessContent(entity);
String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName())
.concat(",当前环节:")
.concat(processWorkFlowResponse.getTaskName());
//流程找不到下一个审批人处理
this.planService.updateById(entity);
this.saveAccessMaterial(entity);
this.saveAccessContent(entity);
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;
}
}

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

@ -1,18 +1,21 @@
package com.hnac.hzims.operational.access.service.impl;
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);
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;
@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(entity);
this.saveMaterial(accessTaskV4DTO);
// 步骤3.保存检修详情
this.saveDetails(entity);
this.saveDetails(accessTaskV4DTO);
return JSONObject.toJSONString(save);
});
return res;
// 步骤4.开启检修任务流程
this.startProcess(entity);
}
/**
* 开启检修流程
* @param entity
*/
private void startProcess(AccessTaskV4DTO entity) {
Map<String, Object> 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<String, Object> variables =new HashMap<>();
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class);
}
if(ObjectUtil.isNotEmpty(accessTaskV4DTO.getCreateUser())){
variables.put("startFlowUserId",accessTaskV4DTO.getCreateUser().toString());
}
variables.put("solve",TaskUtil.getTaskUser(entity.getHandler().toString()));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("overhaul_task", FlowUtil.getBusinessKey("access_task_v4", String.valueOf(entity.getId())), entity.getName(),variables);
variables.put("solve",TaskUtil.getTaskUser(accessTaskV4DTO.getHandler().toString()));
R<BladeFlow> result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue,
FlowUtil.getBusinessKey("access_task_v4",
String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables);
log.error("开启检修任务流程失败{}" + result);
// 更新任务流程Id
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<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessTaskV4DTO>(){});
entity.setIsNormal(true);
if(700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
// 当前流程名称
entity.setTaskName(processWorkFlowResponse.getTaskName());
// 流程阶段执行人员名称
@ -221,7 +266,9 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName())
.concat(",当前环节:")
.concat(processWorkFlowResponse.getTaskName());
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;
}
}

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

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

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java

@ -62,7 +62,7 @@ public class CentralMonitorController extends BladeController {
@GetMapping("/communications")
@ApiOperation("查询通讯告警图表数据")
@ApiOperationSupport(order = 4)
public R<List<PointDataVo>> communications(String roleId,Date start,@RequestParam Date end){
public R<List<PointDataVo>> communications(String roleId,Date start,Date end){
return R.data(monitorService.communications(roleId,start,end));
}
}

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

@ -1,8 +1,10 @@
package com.hnac.hzims.operational.defect.controller;
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);
}
}

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

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

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

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

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

@ -1,13 +1,15 @@
package com.hnac.hzims.operational.defect.service.impl;
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<OperPhenomenonMapper, OperPhenomenonEntity> implements IDefectCheckService {
public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, OperPhenomenonEntity> implements IDefectCheckService , StartProcessService {
private final IOperDefectService defectService;
@ -79,13 +82,15 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
private final ISysClient sysClient;
private final IUserClient userClient;
@Autowired
private RedisTemplate redisTemplate;
private final RedisTemplate redisTemplate;
private final IStationClient stationClient;
private final IFlowClient processClient;
// private final IFlowClient processClient;
private final IMessageClient messageClient;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/**
* 保存现象开启缺陷处理流程
@ -94,8 +99,7 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public OperPhenomenonEntity startCheck(OperPhenomenonEntity entity) {
public R startCheck(OperPhenomenonEntity entity) {
if (ObjectUtil.isEmpty(entity.getCreateDept())) {
throw new ServiceException("获取缺陷所属机构失败!");
}
@ -108,26 +112,29 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
if (StringUtils.isNotBlank(AuthUtil.getNickName())){
entity.setCreateUserName(AuthUtil.getNickName());
}
R r=new R();
//加锁
Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + entity.getCreateDept(), entity.getCreateDept(), 30, TimeUnit.SECONDS);
try {
if (lock) {
// 步骤1.保存现象
if (!this.savePhenomenon(entity)) {
throw new ServiceException("保存现象失败!");
}
// 步骤2.开启缺陷流程
OperPhenomenonEntity operPhenomenon = this.getOne(new LambdaQueryWrapper<OperPhenomenonEntity>() {{
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<OperPhenomenonEntity>() {{
// 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<OperPhenomenonMapper, Op
}
}
/**
* 保存现象
*
* @param entity
* @return
*/
private boolean savePhenomenon(OperPhenomenonEntity entity) {
@Override
public String saveEntity(String entityString) {
OperPhenomenonEntity entity= JSONObject.parseObject(entityString, OperPhenomenonEntity.class);
String deptId = entity.getCreateDept().toString();
if (StringUtils.isBlank(deptId)) {
throw new ServiceException("获取当前用户机构失败!");
@ -193,26 +196,32 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
// Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline);
// entity.setDiscriminateDeadline(discriminateDeadline);
// 最后甄别时间字段弃用
return this.save(entity);
//保存的时候单独增加事务,不妨碍其他
transactionTemplate.setTransactionManager(transactionManager);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
// 在这里执行需要事务控制的代码
boolean save = save(entity);
if (!save){
throw new ServiceException("保存业务表单失败,请稍后重试!");
}
/**
* 启动缺陷处理流程
*
* @param entity
*/
private void startDefectCheckV2(OperPhenomenonEntity entity) {
//新增缺陷流程记录
OperDefectStatisticsEntity operDefectStatisticsEntity = new OperDefectStatisticsEntity();
BeanUtil.copy(entity, operDefectStatisticsEntity);
statisticsService.save(operDefectStatisticsEntity);
//新增现象记录
OperAppearanceEntity operAppearanceEntity = new OperAppearanceEntity();
BeanUtil.copy(entity, operAppearanceEntity);
operAppearanceService.save(operAppearanceEntity);
}
});
return JSONObject.toJSONString(entity);
}
@Override
public R startProcess(String entityString, String dictValue,String param) {
OperPhenomenonEntity entity= JSONObject.parseObject(entityString, OperPhenomenonEntity.class);
// 现象发起人名字
String userName = Optional.ofNullable(AuthUtil.getUserName()).orElse("");
// 现象发起来源
@ -221,20 +230,40 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
String processName = "[" + userName + "] 发起 " + "【" + sourceName + "】缺陷处理流程" + "——>" + entity.getFaultName();
// 开启新的缺陷流程
String businessKey = FlowUtil.getBusinessKey("hzims_oper_phenomenon", "" + entity.getId());
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class);
// variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId())));
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(TreatMethodConstant.DEFECT_CHECK, businessKey, processName, variable);
Map<String, Object> variables =new HashMap<>();
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class);
}
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), dictValue, businessKey, processName, variables);
// R<BladeFlow> 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<OperPhenomenonMapper, Op
log.info("缺陷ID:" + operPhenomenonEntity.getDefectCode() + "入库成功");
}
//流程找不到下一个审批人处理
if(700==processWorkFlowResponse.getCode()){
operPhenomenonEntity.setIsNormal(false);
operPhenomenonEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}else {
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,taskId);
}
//更新数据库
Long statisticsEntityId = statisticsEntity.getId();
Long appearanceEntityId = appearanceEntity.getId();
@ -360,8 +397,6 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
}});
statisticsService.updateById(statisticsEntity);
operAppearanceService.updateById(appearanceEntity);
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,taskId);
log.info("消缺消息转换结束"+processWorkFlowResponse);
return R.success("消息保存成功");
}
@ -421,4 +456,5 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
}
return solve;
}
}

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

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

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

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

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

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

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

@ -9,8 +9,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.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<ImsDutyRecMapper, ImsDutyRecEntity> implements IImsDutyRecService {
public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDutyRecEntity> implements IImsDutyRecService, StartProcessService {
@Resource
private ITicketInfoClient ticketInfoClient;
@Autowired
@ -110,7 +122,12 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
private IImsDutyGroupPService imsDutyGroupPService;
@Autowired
private IImsDutyMainPersonService imsDutyMainPersonService;
@Autowired
private ICompensateProcessClient compensateProcessClient;
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
private TransactionTemplate transactionTemplate;
@Override
@Deprecated//2023.12.18
@ -208,8 +225,18 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
* @return 交接班成功标识
*/
@Override
// @Transactional(rollbackFor = Exception.class)
public Boolean changeShift(ImsDutyRecDTO recDTO) {
public R changeShift(ImsDutyRecDTO recDTO) {
//保存对应业务表单
String saved = saveEntity(JSONObject.toJSONString(recDTO));
//开启动作流
R r = this.startProcess(JSON.toJSONString(saved), DutyRecProcessConstant.DUTY_REC_FLOW_KEY,null);
return r;
}
@Override
public String saveEntity(String entity) {
ImsDutyRecDTO recDTO= JSONObject.parseObject(entity, ImsDutyRecDTO.class);
transactionTemplate.setTransactionManager(transactionManager);
// 获取班组组长
Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId());
Assert.isTrue(Func.isNotEmpty(managerId),() -> {
@ -228,6 +255,10 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
recDTO.setStatus(DutyRecStatus.EXEC.getVal());
// 判断交接班是否延时
Long duration = this.changeShiftDuration(imsDutyMainService.getById(recDTO.getDutyId()), OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal());
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
// 在这里执行需要事务控制的代码
if(Func.isNotEmpty(duration) && duration > 0) {
recDTO.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus());
}
@ -238,11 +269,67 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
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);
// 开启值班交接班流程
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<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getDutyId()));
Assert.isTrue(carryDuties.size() <= 1,() -> {
throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size());
});
recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId()));
Map<String,Object> variable = new HashMap(){{
putAll(BeanUtil.toMap(recDTO));
put("taskId", recEntity.getId());
put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString()));
}};
String businessKey = FlowUtil.getBusinessKey( DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, "" + recDTO.getId());
String processName = AuthUtil.getUserName()+"发起的交班流程";
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue,
businessKey,
processName,
variable);
if (200!=result.getCode()) {
recEntity.setIsNormal(false);
recEntity.setRemark(JSONObject.toJSONString(variable));
R r=new R();
r.setCode(result.getCode());
r.setMsg(result.getMsg());
r.setData(variable);
updateById(recEntity);
log.error("交接班请求报错"+result.getMsg());
return r;
}
recEntity.setIsNormal(true);
recEntity.setProcessInstanceId(result.getData().toString());
updateById(recEntity);
return R.success("启动流程成功");
}
@Override
public R compensationProcess(String id) {
ImsDutyRecEntity rec = this.baseMapper.selectById(id);
if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty(rec)){
return this.startProcess(JSON.toJSONString(rec), DutyRecProcessConstant.DUTY_REC_FLOW_KEY,rec.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
}
/**
@ -1525,4 +1612,6 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
}
return handNumber;
}
}

94
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java

@ -0,0 +1,94 @@
package com.hnac.hzims.operational.history.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.history.service.AlarmService;
import com.hnac.hzims.operational.history.service.PointService;
import com.hnac.hzims.operational.history.vo.HistoricalCurveVo;
import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.management.Query;
import java.util.List;
import java.util.Map;
/**
* @author ysj
*/
@RestController
@RequestMapping("/history")
@Api(value = "历史数据查询", tags = "历史数据查询")
@AllArgsConstructor
public class HistoryController extends BladeController {
private final PointService pointService;
private final AlarmService alarmService;
@GetMapping("/projectAlarm")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "站点告警数据", notes = "查询站点告警数据")
public R<Map<String, Object>> projectAlarm(HistoryProjectAlarmVo alarm, Query query) {
return R.data(alarmService.projectAlarm(alarm,query));
}
@GetMapping("/projectFacDevice")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "站点厂组", notes = "根据站点id查询厂组信息")
public R<List<FacDeviceVO>> 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<List<FacDeviceAttrVO>> 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<List<DeviceInstanceVO>> 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<List<DeviceInstanceAttrVO>> 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<Map<String, Object>> historicalCurve(@RequestBody HistoricalCurveVo curve) {
return R.data(pointService.historicalCurve(curve));
}
@PostMapping("/attrStatistics")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "历史数据统计", notes = "获取历史数据统计数据")
public R<Map<String, Object>> attrStatistics(@RequestBody HistoricalCurveVo curve) {
return R.data(pointService.attrStatistics(curve));
}
}

20
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<String, Object> projectAlarm(HistoryProjectAlarmVo alarm, Query query);
}

33
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<FacDeviceVO> projectFacDevice(String projectId, String attrName);
List<FacDeviceAttrVO> projectFacDeviceAttr(String facDeviceId, String attrName);
List<DeviceInstanceVO> projectDeviceInstance(String projectId,String attrName);
List<DeviceInstanceAttrVO> projectDeviceInstanceAttr(String deviceCode, String attrName);
Map<String, Object> historicalCurve(HistoricalCurveVo curve);
Map<String, Object> attrStatistics(HistoricalCurveVo curve);
}

51
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<String, Object> projectAlarm(HistoryProjectAlarmVo alarm, Query query) {
Result<Map<String, Object>> 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();
}
}

151
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<FacDeviceVO> projectFacDevice(String projectId,String attrName) {
Result<List<FacDeviceVO>> 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<FacDeviceAttrVO> projectFacDeviceAttr(String facDeviceId, String attrName) {
Result<List<FacDeviceAttrVO>> 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<DeviceInstanceVO> projectDeviceInstance(String projectId,String attrName) {
R<List<DeviceInstanceVO>> 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<DeviceInstanceAttrVO> projectDeviceInstanceAttr(String deviceCode, String attrName) {
Result<List<DeviceInstanceAttrVO>> 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<String, Object> historicalCurve(HistoricalCurveVo curve) {
Result<Map<String, Object>> 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<String, Object> attrStatistics(HistoricalCurveVo curve) {
Result<Map<String, Object>> 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();
}
}

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

@ -1,8 +1,9 @@
package com.hnac.hzims.operational.maintenance.scheduled;
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<String,Object> params = new HashMap<String, Object>() {{
@ -194,7 +202,25 @@ public class MaintenanceTaskSchedule {
});
put("operMaintenanceTaskEntityVo",vo);
}};
R<BladeFlow> 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<BladeFlow> 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;
}
}

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

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

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

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

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

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

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

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

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

@ -4,10 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.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<HazardTaskMapper, HazardT
private final IFlowClient flowClient;
private final ICompensateProcessClient compensateProcessClient;
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
/**
* 风险排查流程开启
* @param process
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean startProcess(HazardRiskProcessDTO process) {
public R startProcess(HazardRiskProcessDTO process) {
//保存业务表单
saveEntity(JSONObject.toJSONString(process));
String saved = saveEntity(JSONObject.toJSONString(process));
//开启动作流
this.startProcess(JSON.toJSONString(process),HazardRiskConstants.HAZARD_RISK_KEY);
return true;
R r = this.startProcess(JSON.toJSONString(saved), HazardRiskConstants.HAZARD_RISK_KEY,null);
return r ;
}
@Override
@ -105,6 +115,9 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
process.setActStartTime(new Date());
process.setStationCode(hazardWork.getStationCode());
process.setStationName(hazardWork.getStationName());
//增加事务
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
// 保存任务
super.save(process);
// 生成风险评估记录
@ -127,26 +140,52 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
}).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<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class);
Map<String, Object> variables =new HashMap<>();
if (StringUtils.isNotBlank(param)){
variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(process, DateUtil.PATTERN_DATETIME), Map.class);
variables.put(HazardRiskConstants.TROUBLE, TaskUtil.getTaskUser(String.valueOf(process.getHead())));
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey(HazardRiskConstants.HAZARD_RISK_KEY,String.valueOf(process.getId())), process.getTaskName(), variables);
}
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<HazardTaskMapper, HazardT
// 流程阶段执行人员名称
entity.setNextStepOperator("流程结束,无需人员处理");
}
entity.setIsNormal(true);
//流程找不到下一个审批人处理
if(700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
// 更新风险排查任务信息
this.updateById(entity);
if(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY_1.equals(variables.get(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY)) ||

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -33,7 +33,6 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
@ -101,7 +100,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
* @param standardTicketInfoVo
*/
@Override
public void startUp(StandardTicketInfoVo standardTicketInfoVo) {
public R startUp(StandardTicketInfoVo standardTicketInfoVo) {
log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法");
//保存操作票
String standardTicketInfoVoBySave = this.saveEntity(JSONObject.toJSONString(standardTicketInfoVo));
@ -112,7 +111,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
throw new ServiceException("服务器异常,请联系管理员");
}
//启动流程
this.startProcess(standardTicketInfoVoBySave, dictValue);
return this.startProcess(standardTicketInfoVoBySave, dictValue);
}
@Override
public String saveEntity(String entity) {
@ -168,7 +167,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
@Override
public void startProcess(String entity, String dictValue) {
public R startProcess(String entity, String dictValue) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo);
Instant start = Instant.now();
@ -177,18 +176,25 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params);
R<BladeFlow> 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("启动流程成功");
}
/**

3
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("开启工作票线下流程")

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

@ -2,6 +2,7 @@ package com.hnac.hzims.ticket.twoTicket.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.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);
/**

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

@ -28,7 +28,6 @@ import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import com.hnac.hzims.ticket.twoTicket.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<String, Object> 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) {

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

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