Browse Source

Merge branch 'prod-5.1.3' of http://175.6.40.68:8081/Jone/hzims-back into prod-5.1.3

zhongwei
liwen 5 months ago
parent
commit
19ccd99448
  1. 5
      hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java
  2. 21
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java
  3. 3
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java
  4. 23
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java
  5. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java
  6. 2
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ObjectEntity.java
  7. 2
      hzims-service/assets/src/main/resources/template/template.yml
  8. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java
  9. 21
      hzims-service/equipment/src/main/resources/template/template.yml
  10. 27
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java
  11. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java
  12. 9
      hzims-service/hzims-alarm/src/main/resources/template/template.yml
  13. 2
      hzims-service/hzims-basic/src/main/resources/template/template.yml
  14. 5
      hzims-service/hzims-big-model/pom.xml
  15. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java
  16. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java
  17. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java
  18. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java
  19. 21
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java
  20. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java
  21. 56
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java
  22. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java
  23. 252
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java
  24. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java
  25. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
  26. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java
  27. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  28. 40
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java
  29. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java
  30. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java
  31. 30
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java
  32. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java
  33. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java
  34. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java
  35. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java
  36. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java
  37. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java
  38. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java
  39. 9
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java
  40. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java
  41. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java
  42. 16
      hzims-service/hzims-big-model/src/main/resources/template/template.yml
  43. 4
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java
  44. 4
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java
  45. 49
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java
  46. 4
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java
  47. 2
      hzims-service/hzims-middle/src/main/resources/template/template.yml
  48. 14
      hzims-service/hzims-scheduled/src/main/resources/template/template.yml
  49. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml
  50. 2
      hzims-service/inspect/src/main/resources/template/template.yml
  51. 27
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
  52. 29
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
  53. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java
  54. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java
  55. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java
  56. 41
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java
  57. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java
  58. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java
  59. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java
  60. 49
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java
  61. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java
  62. 30
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java
  63. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  64. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/VideoSyncAspect.java
  65. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  66. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java
  67. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  68. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/wrapper/VideoSyncWrapper.java
  69. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java
  70. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java
  71. 151
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java
  72. 2
      hzims-service/operational/src/main/resources/db/3.0.1.sql
  73. 14
      hzims-service/operational/src/main/resources/template/template.yml
  74. 61
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java
  75. 32
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java
  76. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java
  77. 4
      hzims-service/safeproduct/src/main/resources/template/template.yml
  78. 56
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java
  79. 71
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  80. 79
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  81. 4
      hzims-service/ticket/src/main/resources/db/3.0.0.sql
  82. 2
      hzims-service/ticket/src/main/resources/template/template.yml
  83. 2
      hzims-service/weather/src/main/resources/template/template.yml

5
hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java

@ -1,9 +1,11 @@
package com.hnac.hzims.common.service; package com.hnac.hzims.common.service;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -22,6 +24,9 @@ public class UserAuthDataService {
* @return * @return
*/ */
public String getUserAuthDataSQL(Long userId) { public String getUserAuthDataSQL(Long userId) {
if(CommonConstant.SYSTEM_USER.equals(userId)) {
return "";
}
R<User> r = userClient.userInfoById(userId); R<User> r = userClient.userInfoById(userId);
String sqlScript = null; String sqlScript = null;
if(r.getCode() != HttpStatus.OK.value() || r.getData() == null) { if(r.getCode() != HttpStatus.OK.value() || r.getData() == null) {

21
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java

@ -0,0 +1,21 @@
package com.hnac.hzims.bigmodel.api.wrapper;
import com.hnac.hzims.bigmodel.api.dto.SyncDTO;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/08/20 09:23
* @Describe 对象转换为同步对象基础类
*/
public abstract class BaseSyncWrapper<O,S extends SyncDTO> {
public abstract S convert(O obj);
public List<S> listVO(List<O> list) {
return list.stream().map(this::convert).collect(Collectors.toList());
}
}

3
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java

@ -28,4 +28,7 @@ public class PowerDataDTO implements Serializable {
@ApiModelProperty("发电单位") @ApiModelProperty("发电单位")
private String unit = "万kWh"; private String unit = "万kWh";
@ApiModelProperty("运行时长单位")
private String runtimeUnit = "h";
} }

23
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java

@ -0,0 +1,23 @@
package com.hnac.hzims.bigmodel.database.entity;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/08/22 19:35
*/
@Data
@EqualsAndHashCode
public class WeaviateEntity implements Serializable {
@JSONField(name = "item_id")
private String itemId;
@JSONField(name = "item_name")
private String itemName;
}

2
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java

@ -26,7 +26,7 @@ public class ControlEntity extends TenantEntity implements Serializable {
@ApiModelProperty(value = "itemId",required = true) @ApiModelProperty(value = "itemId",required = true)
private String itemId; private String itemId;
@ApiModelProperty(value = "站点名称",required = true) @ApiModelProperty(value = "站点名称")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
private String stationName; private String stationName;

2
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ObjectEntity.java

@ -49,7 +49,7 @@ public class ObjectEntity extends TenantEntity {
* 地理位置 * 地理位置
*/ */
@ApiModelProperty(value = "地理位置,长度必须为1到128") @ApiModelProperty(value = "地理位置,长度必须为1到128")
@Size(min=1,max = 128,message ="地理位置长度必须为1到128") // @Size(min=1,max = 128,message ="地理位置长度必须为1到128")
private String address; private String address;
/** /**
* 经度(东经) * 经度(东经)

2
hzims-service/assets/src/main/resources/template/template.yml

@ -13,7 +13,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_assets?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-assets?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
#swagger扫描路径配置 #swagger扫描路径配置

6
hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java

@ -122,7 +122,11 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>(); return new ArrayList<>();
} }
return result.getData(); return result.getData().stream().peek(fac->{
fac.setName(Arrays.stream(fac.getName().split("\\."))
.reduce((first, second) -> second)
.orElse(fac.getName()));
}).collect(Collectors.toList());
} }
/** /**

21
hzims-service/equipment/src/main/resources/template/template.yml

@ -12,23 +12,23 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
slave: slave:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
inspect: inspect:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
hzims: hzims:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
bladex: bladex:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
@ -89,9 +89,14 @@ blade:
data: data:
sdk: sdk:
enabled: true enabled: true
url: http://${hzims.sdk.ip}/api/hzinfo-data-config url: "http://${hzims.sdk.ip}/api/hzinfo-data-config"
appId: ${hzims.sdk.appId} ctrlUrl: "http://${hzims.sdk.ip}/api/hzinfo-data-handler"
appSecret: ${hzims.sdk.appSecret} appId: "${hzims.sdk.appId}"
appSecret: "${hzims.sdk.appSecret}"
redisIp: "${hzinfo.redis.ip}"
redisPort: ${hzinfo.redis.port}
password: "${hzinfo.redis.password}"
maxKeys: 1000
data-scope: data-scope:
enabled: false enabled: false

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

@ -2,6 +2,8 @@ package com.hnac.hzims.alarm.show.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
@ -13,6 +15,7 @@ import com.hnac.hzims.alarm.show.service.AlarmHandleFlowService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient; import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -63,6 +66,9 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl<AlarmHandleFlowMappe
log.info("告警消息转换失败:" + e.getMessage()); log.info("告警消息转换失败:" + e.getMessage());
return R.fail("告警消息转换失败"); return R.fail("告警消息转换失败");
} }
if (ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
return handException(processWorkFlowResponse);
}
taskId = alarmHandleFlowEntity.getId(); taskId = alarmHandleFlowEntity.getId();
alarmHandleFlowEntity.setIsNormal(true); alarmHandleFlowEntity.setIsNormal(true);
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
@ -122,14 +128,29 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl<AlarmHandleFlowMappe
} }
this.updateById(alarmHandleFlowEntity); this.updateById(alarmHandleFlowEntity);
//推送消息中心相关消息 //推送消息中心相关消息
if(ObjectUtils.isEmpty(processWorkFlowResponse.getCode())||700!=processWorkFlowResponse.getCode()) {
sendMessage(processWorkFlowResponse, alarmHandleFlowEntity, taskId); sendMessage(processWorkFlowResponse, alarmHandleFlowEntity, taskId);
}
log.info("告警消息转换结束" + processWorkFlowResponse); log.info("告警消息转换结束" + processWorkFlowResponse);
return R.success("消息保存成功"); return R.success("消息保存成功");
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("补偿流程处理失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("补偿流程处理失败");
}
AlarmHandleFlowEntity alarmHandleFlowEntity = this.baseMapper.selectOne(new LambdaQueryWrapper<AlarmHandleFlowEntity>() {{
eq(AlarmHandleFlowEntity::getId, split[1]);
}});
alarmHandleFlowEntity.setIsNormal(false);
alarmHandleFlowEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
alarmHandleFlowEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
alarmHandleFlowEntity.setCurrentOperator(processWorkFlowResponse.getTaskName());
alarmHandleFlowEntity.setCurrentLinkHandler("");
this.baseMapper.updateById(alarmHandleFlowEntity);
log.info("补偿流程消息转换结束"+ processWorkFlowResponse);
return R.success("补偿流程消息保存成功");
}
private void sendMessage(ProcessWorkFlowResponse processWorkFlowResponse, AlarmHandleFlowEntity alarmHandleFlowEntity, Long taskId) { private void sendMessage(ProcessWorkFlowResponse processWorkFlowResponse, AlarmHandleFlowEntity alarmHandleFlowEntity, Long taskId) {
//推送消息 //推送消息
if (processWorkFlowResponse.getTaskId() != null) { if (processWorkFlowResponse.getTaskId() != null) {

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

@ -159,9 +159,9 @@ public class AlarmHandleServiceImpl extends ServiceImpl<AlarmHandleMapper, Alarm
} }
R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),AlarmHandleConstant.dealAlarm, businessKey, processName, variables); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),AlarmHandleConstant.dealAlarm, businessKey, processName, variables);
// 流程开启失败 // 流程开启失败
if (200!=result.getCode()) { if (ObjectUtils.isNotEmpty(result.getCode())&&200!=result.getCode()) {
param.setIsNormal(false); param.setIsNormal(false);
param.setRemark(JSONObject.toJSONString(variable)); param.setRemark(variable);
alarmHandleFlowMapper.updateById(param); alarmHandleFlowMapper.updateById(param);
R r=new R(); R r=new R();
r.setCode(result.getCode()); r.setCode(result.getCode());

9
hzims-service/hzims-alarm/src/main/resources/template/template.yml

@ -9,7 +9,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
@ -36,11 +36,12 @@ hzims:
password: ${hzinfo.mq.password} password: ${hzinfo.mq.password}
msg: msg:
template: aliyun-alarm-sms template: aliyun-alarm-sms
enabled: false enabled: true
wxPush: wxPush:
template: hIgINCsjpG-gyCKh8wzwBeRL9tanTLqRDgv-X8B9vyc template: hIgINCsjpG-gyCKh8wzwBeRL9tanTLqRDgv-X8B9vyc
enabled: false enabled: true
url:
getFaultGraphInfo: http://${hzims.fdp.url.ip}:${hzims.fdp.url.port}/diagnose/getFaultGraphInfo
logging: logging:
level: level:

2
hzims-service/hzims-basic/src/main/resources/template/template.yml

@ -8,7 +8,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

5
hzims-service/hzims-big-model/pom.xml

@ -83,6 +83,11 @@
<artifactId>oapi-java-sdk</artifactId> <artifactId>oapi-java-sdk</artifactId>
<version>release-V4-2.0.2</version> <version>release-V4-2.0.2</version>
</dependency> </dependency>
<dependency>
<groupId>io.weaviate</groupId>
<artifactId>client</artifactId>
<version>4.7.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java

@ -1,9 +1,11 @@
package com.hnac.hzims.bigmodel.api.feign; package com.hnac.hzims.bigmodel.api.feign;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest;
import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -15,12 +17,14 @@ import java.util.List;
*/ */
@RestController @RestController
@AllArgsConstructor @AllArgsConstructor
@Slf4j
public class DataAnalyseClient implements IDataAnalyseClient { public class DataAnalyseClient implements IDataAnalyseClient {
private final IHznlmInvokeService invokeService; private final IHznlmInvokeService invokeService;
@Override @Override
public R smartReportGeneratePower(RunReportAnalyseRequest req) { public R smartReportGeneratePower(RunReportAnalyseRequest req) {
log.info("获取运行月报告传参详情为:{}", JSON.toJSONString(req));
invokeService.smartReportGeneratePower(req); invokeService.smartReportGeneratePower(req);
return R.success("发起问答成功"); return R.success("发起问答成功");
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java

@ -1,4 +1,4 @@
package com.hnac.hzims.bigmodel.business.control; package com.hnac.hzims.bigmodel.business.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.business.service.DataSourceService; import com.hnac.hzims.bigmodel.business.service.DataSourceService;

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java

@ -1,7 +1,6 @@
package com.hnac.hzims.bigmodel.business.control; package com.hnac.hzims.bigmodel.business.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.business.service.RemoteService; import com.hnac.hzims.bigmodel.business.service.RemoteService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -9,6 +8,7 @@ import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.ControlDTO;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -27,7 +27,7 @@ public class RemoteController {
@ApiOperation("下发遥控指令") @ApiOperation("下发遥控指令")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@PostMapping("/sendRemoteControl") @PostMapping("/sendRemoteControl")
public R<Object> sendRemoteControl(ControlDTO controlDTO) { public R<Object> sendRemoteControl(@RequestBody ControlDTO controlDTO) {
return remoteService.sendRemoteControl(controlDTO); return remoteService.sendRemoteControl(controlDTO);
} }

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java

@ -58,11 +58,15 @@ public class DataSourceService {
throw new HzServiceException(ResultCode.FAILURE,"查询语句中存在未进行鉴权的表,查询失败!"); throw new HzServiceException(ResultCode.FAILURE,"查询语句中存在未进行鉴权的表,查询失败!");
}); });
if("1".equals(propertise.get(0).getAuthType())) { if("1".equals(propertise.get(0).getAuthType())) {
String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0 and " + userAuthDataSQL +") temp";
sql = sql.replace(tableAuthVO.getTableName(),tableSubStr);
} else {
String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0) temp";
sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); sql = sql.replace(tableAuthVO.getTableName(),tableSubStr);
} }
} }
} }
sql = sql.replaceAll("&gt;", ">").replaceAll("&lt;", "<");
log.info("执行sql:{}",sql); log.info("执行sql:{}",sql);
return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName());
} }

21
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java

@ -0,0 +1,21 @@
package com.hnac.hzims.bigmodel.business.wrapper;
import com.hnac.hzims.bigmodel.api.dto.CanvasSyncDTO;
import com.hnac.hzims.bigmodel.api.wrapper.BaseSyncWrapper;
import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
/**
* @Author: huangxing
* @Date: 2024/08/20 16:49
*/
@Component
@AllArgsConstructor
public class CanvasSyncWrapper extends BaseSyncWrapper<CanvasVO, CanvasSyncDTO> {
@Override
public CanvasSyncDTO convert(CanvasVO obj) {
return null;
}
}

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java

@ -62,4 +62,9 @@ public class BigModelInvokeApi {
*/ */
private String updateKnowledge; private String updateKnowledge;
/**
* 计算向量
*/
private String compute;
} }

56
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java

@ -0,0 +1,56 @@
package com.hnac.hzims.bigmodel.configuration;
import io.weaviate.client.Config;
import io.weaviate.client.WeaviateAuthClient;
import io.weaviate.client.WeaviateClient;
import io.weaviate.client.v1.auth.exception.AuthException;
import io.weaviate.client.v1.data.api.ObjectCreator;
import io.weaviate.client.v1.data.api.ObjectDeleter;
import io.weaviate.client.v1.data.api.ObjectUpdater;
import io.weaviate.client.v1.data.api.ObjectsGetter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: huangxing
* @Date: 2024/08/22 18:38
*/
@Configuration
public class WeaviateConfigure {
private final WeaviateProperties weaviateProperties;
public WeaviateConfigure(WeaviateProperties weaviateProperties) {
this.weaviateProperties = weaviateProperties;
}
@Bean
public WeaviateClient weaviateClient() throws AuthException {
Config config = new Config(this.weaviateProperties.getSchema(), this.weaviateProperties.getHost() + ":" + this.weaviateProperties.getPort());
return WeaviateAuthClient.apiKey(config,this.weaviateProperties.getApiKey());
}
@Bean
public ObjectsGetter objectsGetter() throws AuthException {
WeaviateClient weaviateClient = weaviateClient();
return weaviateClient.data().objectsGetter();
}
@Bean
public ObjectCreator objectCreator() throws AuthException {
WeaviateClient weaviateClient = weaviateClient();
return weaviateClient.data().creator();
}
@Bean
public ObjectDeleter deleter() throws AuthException {
WeaviateClient weaviateClient = weaviateClient();
return weaviateClient.data().deleter();
}
@Bean
public ObjectUpdater updater() throws AuthException {
WeaviateClient weaviateClient = weaviateClient();
return weaviateClient.data().updater();
}
}

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java

@ -0,0 +1,32 @@
package com.hnac.hzims.bigmodel.configuration;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Author: huangxing
* @Date: 2024/08/21 15:22
*/
@Data
@Component
@ConfigurationProperties(prefix = "weaviate.datasource")
public class WeaviateProperties {
private String schema;
private String host;
private String port;
/**
* 登录认证KEY
*/
private String apiKey;
/**
* 数据库表名前缀
*/
private String classNamePrefix;
}

252
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java

@ -0,0 +1,252 @@
package com.hnac.hzims.bigmodel.database.service;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi;
import com.hnac.hzinfo.exception.HzServiceException;
import io.weaviate.client.base.Result;
import io.weaviate.client.v1.data.api.ObjectCreator;
import io.weaviate.client.v1.data.api.ObjectDeleter;
import io.weaviate.client.v1.data.api.ObjectUpdater;
import io.weaviate.client.v1.data.api.ObjectsGetter;
import io.weaviate.client.v1.data.model.WeaviateObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @Author: huangxing
* @Date: 2024/08/22 19:17
*/
@RequiredArgsConstructor
@Service
@Slf4j
public class WeaviateService {
private final ObjectCreator objectCreator;
private final ObjectUpdater objectUpdater;
private final ObjectDeleter objectDeleter;
private final ObjectsGetter objectsGetter;
private final BigModelInvokeApi invokeApi;
@Value("${gglm.vectorUrl}")
private String vectorUrl;
/**
* 对象保存向量数据库
* @param entity 保存对象
* @param className 保存表名
* @param attrs 待计算的列信息
* @return 保存操作结果
*/
public Boolean save(Object entity, String className, List<String> attrs) {
ObjectCreator creator = objectCreator.withClassName(className);
if(Func.isNotEmpty(attrs)) {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity));
List<String> vectors = attrs.stream().map(attr -> jsonObject.getString(attr)).collect(Collectors.toList());
Float[] compute = this.compute(vectors);
creator.withVector(compute);
}
Result<WeaviateObject> result = creator.withProperties(BeanUtil.toMap(entity)).run();
return !result.hasErrors();
}
/**
* 对象批量保存向量数据库
* @param entities 保存对象列表
* @param className 保存表名
* @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔
* @return 保存操作结果
*/
public Boolean saveBatch(List entities,String className, Map<String,String> attrsMap) {
ObjectCreator creator = objectCreator.withClassName(className);
List<String> vectorStrs = Lists.newArrayList();
List<String> attrs = Lists.newArrayList();
if(Func.isNotEmpty(attrsMap)) {
// 格式化数据
attrsMap.forEach((k,v) -> attrs.add(v));
// 解析待计算的向量字段
entities.forEach(entity -> {
List<String> vectorStr = attrs.stream().map(fields -> this.getFieldValue(fields, entity)).filter(Func::isNotEmpty).collect(Collectors.toList());
vectorStrs.addAll(vectorStr);
});
}
if(Func.isNotEmpty(vectorStrs)) {
// 若解析出来的向量存在值
Float[] vectors = this.compute(vectorStrs);
List<Map<String, Float[]>> vector = this.splitVector(entities.size(), attrsMap, vectors);
for(int i = 0; i < entities.size(); i++) {
creator.withProperties(BeanUtil.toMap(entities.get(i))).withVectors(vector.get(i)).run();
}
} else {
entities.forEach(entity -> creator.withProperties(BeanUtil.toMap(entity)).run());
return true;
}
return false;
}
/**
* 删除向量数据库表名
* @param className 表名
* @return 删除结果
*/
public Boolean deleteByClassName(String className) {
Result<Boolean> result = objectDeleter.withClassName(className).run();
return !result.hasErrors();
}
/**
* 删除向量数据库ID
* @param id 向量数据库ID
* @return 删除结果
*/
public Boolean deleteById(String id) {
Result<Boolean> result = objectDeleter.withID(id).run();
return !result.hasErrors();
}
/**
* 更新数据库通过ID
* @param id 向量数据库ID
* @return 更新结果
*/
public Boolean updateById(String id, Object entity, String className, Map<String,String> attrMap) {
ObjectUpdater updater = objectUpdater.withClassName(className).withID(id).withProperties(BeanUtil.toMap(entity));
// 计算向量
Map<String, Float[]> vector = new HashMap<>();
if(Func.isNotEmpty(attrMap)) {
attrMap.forEach((k,v) -> {
String fieldValue = this.getFieldValue(v, entity);
Float[] compute = this.compute(Lists.newArrayList(fieldValue));
vector.put(k,compute);
});
}
if(Func.isNotEmpty(vector)) {
updater.withVectors(vector);
}
Result<Boolean> result = updater.run();
return !result.hasErrors();
}
public List<Map> list(String id,String className) {
if(Func.isNotEmpty(id)) {
objectsGetter.withID(id);
}
if(Func.isNotEmpty(className)) {
objectsGetter.withClassName(className);
}
Result<List<WeaviateObject>> result = objectsGetter.run();
if(result.hasErrors()) {
throw new HzServiceException("查询失败!");
}
return result.getResult().stream().map(WeaviateObject::getProperties).collect(Collectors.toList());
}
/**
* 拆解计算出来的向量Float[]
* @param entitySize 对象列表size
* @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔
* @param vectorTotal 计算出的向量总量
* @return 拆解结果
*/
private List<Map<String,Float[]>> splitVector(Integer entitySize,Map<String,String> attrsMap,Float[] vectorTotal) {
List<Map<String,Float[]>> result = Lists.newArrayList();
List<Float> vectorTotalList = Lists.newArrayList(vectorTotal);
// 获取待切割的下标
List<Integer> indexes = this.getSplitIndex(vectorTotal.length, entitySize);
int step = vectorTotal.length / entitySize;
indexes.forEach(index -> {
List<Float> vectors = vectorTotalList.subList(index, index + step);
Map<String,Float[]> vectorMap = new HashMap<>();
List<Integer> splitIndex = this.getSplitIndex(vectors.size(), attrsMap.size());
AtomicInteger i = new AtomicInteger();
attrsMap.forEach((k,v) -> {
List<Float> vector = vectors.subList(splitIndex.get(i.get()), splitIndex.get(i.get() + (vectors.size() / attrsMap.size())));
vectorMap.put(k, vector.toArray(new Float[vector.size()]));
i.getAndIncrement();
});
});
return result;
}
/**
* 获取将list等量分隔成若干份的列表下标
* @param size 总数
* @param splitNum 分隔数量
* @return 下标集合
*/
private List<Integer> getSplitIndex(int size,int splitNum) {
if(size % splitNum != 0) {
throw new HzServiceException("向量计算失败,无法根据同步对象进行等量分隔!");
}
return IntStream.iterate(0, index -> index + 1)
.limit(splitNum)
.mapToObj(index -> index * (size / splitNum))
.collect(Collectors.toList());
}
private String getFieldValue(String fields,Object object) {
Class clazz = object.getClass();
return Func.toStrList(",", fields).stream().map(field -> {
try {
Field declaredField = clazz.getDeclaredField(field);
declaredField.setAccessible(true);
return declaredField.get(object).toString();
} catch (NoSuchFieldException | IllegalAccessException e) {
return null;
}
}).collect(Collectors.joining(" "));
}
/**
* 计算向量值
* @param vectors 待计算的向量
* @return 向量值Float[]
*/
private Float[] compute(List<String> vectors) {
// 向量计算
String url = vectorUrl + invokeApi.getCompute();
String jsonData = JSONUtil.toJsonStr(vectors);
HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json; charset=utf-8")
.body(jsonData)
.execute();
byte[] bytes = response.bodyBytes();
if (bytes.length % 4 != 0) {
throw new HzServiceException("向量计算失败!响应数据长度不是4的倍数");
}
List<byte[]> chunks = new ArrayList<>();
int range = bytes.length / 4;
IntStream.range(0, range)
.forEach(index -> {
byte[] chunk = new byte[4];
int page = index * 4;
chunk[0] = bytes[page];
chunk[1] = bytes[page + 1];
chunk[2] = bytes[page + 2];
chunk[3] = bytes[page + 3];
chunks.add(chunk);
});
List<Float> floats = chunks.stream().map(b -> {
ByteBuffer buffer = ByteBuffer.wrap(b).order(ByteOrder.LITTLE_ENDIAN);
return buffer.getFloat();
}).collect(Collectors.toList());
return floats.toArray(new Float[floats.size()]);
}
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java

@ -0,0 +1,11 @@
package com.hnac.hzims.bigmodel.database.util;
/**
* @Author: huangxing
* @Date: 2024/08/23 10:09
*/
public class WeaviateUtil {
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java

@ -64,7 +64,7 @@ public class FontEndInteractiveController {
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
@GetMapping("/interruptSession") @GetMapping("/interruptSession")
public R interruptSession(@RequestParam(value = "id") String sessionId) { public R interruptSession(@RequestParam(value = "id") String sessionId) {
hznlmInvokeService.askAbort(sessionId); hznlmInvokeService.interruptSession(sessionId);
return R.success("操作成功!"); return R.success("操作成功!");
} }
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java

@ -81,6 +81,8 @@ public interface IHznlmInvokeService {
*/ */
void askAbort(String sessionId); void askAbort(String sessionId);
void interruptSession(String sessionId);
/** /**
* 发起机组发电量智能报表分析问答 * 发起机组发电量智能报表分析问答
* @param req 待分析的数据 * @param req 待分析的数据

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java

@ -17,6 +17,7 @@ import com.hnac.hzims.bigmodel.utils.RequestClientUtil;
import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzinfo.exception.HzServiceException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -126,6 +127,33 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
sessionRedisManager.removeSessionId(sessionId); sessionRedisManager.removeSessionId(sessionId);
} }
public void interruptSession(String sessionId) {
this.askAbort(sessionId);
// 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果
int status = 999;
int attempts = 0;
while (status > 0) {
// 若重连超过10次 则抛出错误
if(attempts >= 8) {
throw new HzServiceException("中断失败!长时间未获取到中断状态");
}
List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId);
if(Func.isNotEmpty(answers)) {
log.info(answers.get(0).getStatus()+"");
status = answers.get(0).getStatus();
}
// 若获取到的状态不等于2 则延时0.5秒
if(status > 0) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
attempts ++;
}
}
@Override @Override
public void smartReportGeneratePower(RunReportAnalyseRequest req) { public void smartReportGeneratePower(RunReportAnalyseRequest req) {
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();

40
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java

@ -0,0 +1,40 @@
package com.hnac.hzims.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/08/21 08:33
*/
@Data
@EqualsAndHashCode
@ApiModel(value = "同步向量库基础配置",description = "同步向量库基础配置")
@TableName("")
public class SyncPropertyEntity extends TenantEntity implements Serializable {
@ApiModelProperty("配置编号")
private String code;
@ApiModelProperty("数据源")
private String datasource;
@ApiModelProperty("数据源名称")
private String datasourceName;
@ApiModelProperty("数据库表名")
private String tableName;
@ApiModelProperty("向量数据库表名,由小写字母以及_组成")
private String vectorTableName;
@ApiModelProperty("表描述")
private String tableDesc;
}

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java

@ -20,17 +20,17 @@ public class TableColumnService {
private final DataSourceService dataSourceService; private final DataSourceService dataSourceService;
public List<Map<String,Object>> getDatabase(String datasource) { public List<Map<String,Object>> getDatabase(String datasource) {
String sql = "select distinct `table_schema` as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; String sql = "select distinct UPPER(`table_schema`) as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }
public List<Map<String, Object>> getTables(String datasource,String database) { public List<Map<String, Object>> getTables(String datasource,String database) {
String sql = "select distinct `table_name` as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';"; String sql = "select distinct UPPER(`table_name`) as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }
public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) { public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) {
String sql = "select distinct `column_name` as columnName,`column_comment` as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; String sql = "select distinct UPPER(`column_name`) as columnName,UPPER(`column_comment`) as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java

@ -21,7 +21,8 @@ public enum ErrorCode implements IResultCode {
UNKNOWN_ANALYSIS_TYPE(1888000007, "未知的识别类型"), UNKNOWN_ANALYSIS_TYPE(1888000007, "未知的识别类型"),
NO_COMPARATOR(1888000008, "未获取到对比对象"), NO_COMPARATOR(1888000008, "未获取到对比对象"),
NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"), NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"),
GET_RESULT_FAIL(1888000010, "获取结果失败"),; GET_RESULT_FAIL(1888000010, "获取结果失败"),
NO_ANSWER_FROM_PLATFORM(1888000011, "未从平台获取到答案");
private final int code; private final int code;
private final String msg; private final String msg;

30
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java

@ -1,31 +1,41 @@
package com.hnac.hzims.bigmodel.zhipuai.constants; package com.hnac.hzims.bigmodel.zhipuai.constants;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.BooleanParser;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.IntegerParser;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.ResultDataParser;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.StringParser;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/14 8:28 * @Date: 2024/8/14 8:28
*/ */
@Getter @Getter
@Slf4j
public enum ResultDataType implements BaseEnum { public enum ResultDataType implements BaseEnum {
OBJECT("Object", "Object类型", Object.class.getName(), null), STRING("String", "String类型", StringParser.class),
STRING("String", "String类型", String.class.getName(), null), BOOLEAN("Boolean", "Boolean类型", BooleanParser.class),
BOOLEAN("Boolean","Boolean类型",Boolean.class.getName(),"parseBoolean"), INTEGER("Integer", "Integer类型", IntegerParser.class);
INTEGER("Integer","Integer类型",Integer.class.getName(),"parseInt");
private final String code; private final String code;
private final String msg; private final String msg;
private final String className; private final Class<? extends ResultDataParser> parser;
private final String method; ResultDataType(String code, String msg, Class<? extends ResultDataParser> parser) {
ResultDataType(String code, String msg, String className, String method) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
this.className = className; this.parser = parser;
this.method = method;
} }
public ResultDataParser getParser() {
try {
return parser.newInstance();
} catch (Exception e) {
log.error("get result data parse fail", e);
}
return null;
}
} }

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java

@ -1,8 +1,8 @@
package com.hnac.hzims.bigmodel.zhipuai.constants; package com.hnac.hzims.bigmodel.zhipuai.constants;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultBooleanStrategy; import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultBooleanStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultCommonStrategy; import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultCommonStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy; import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java

@ -73,7 +73,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
ModelApiResponse response = sendRequest(text, url); ModelApiResponse response = sendRequest(text, url);
log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null"));
Assert.<HzServiceException>isTrue(Objects.nonNull(response) && response.isSuccess(), () -> { Assert.<HzServiceException>isTrue(Objects.nonNull(response) && response.isSuccess(), () -> {
throw ErrorCode.throwCommonException(Optional.ofNullable(response).map(ModelApiResponse::getMsg).orElse("没有收到大模型平台响应")); throw ErrorCode.throwCommonException(Optional.ofNullable(response).map(ModelApiResponse::getMsg).orElse(ErrorCode.NO_ANSWER_FROM_PLATFORM.getMsg()));
}); });
try { try {
String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString();

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java

@ -1,10 +1,11 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler.result;
import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ComparisonType; import com.hnac.hzims.bigmodel.zhipuai.constants.ComparisonType;
import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Objects; import java.util.Objects;

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java

@ -1,7 +1,8 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler.result;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy;
/** /**
* @Author: ypj * @Author: ypj
@ -13,7 +14,6 @@ public class ResultCommonStrategy implements ResultStrategy<Object> {
return ResultStrategyType.COMMON.getCode(); return ResultStrategyType.COMMON.getCode();
} }
@Override @Override
public Object getResult(ZhipuAnalysisInfoEntity info, Object data) { public Object getResult(ZhipuAnalysisInfoEntity info, Object data) {
return data; return data;

20
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java

@ -1,13 +1,11 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler.result;
import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultDataType; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultDataType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.slf4j.Logger; import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.ResultDataParser;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.utils.StringUtil;
import java.lang.reflect.Method; import java.util.Optional;
/** /**
* @Author: ypj * @Author: ypj
@ -23,15 +21,9 @@ public interface ResultStrategy<T> {
default Object convertOriginalData(String originalData, String className) { default Object convertOriginalData(String originalData, String className) {
ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class); ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class);
if (null != type && StringUtil.isNotBlank(type.getMethod())) { if (null != type) {
try { ResultDataParser parser = type.getParser();
Class<?> clazz = Class.forName(type.getClassName()); return Optional.ofNullable(parser).map(p -> p.parse(originalData)).orElse(originalData);
Method method = clazz.getMethod(type.getMethod(), String.class);
return method.invoke(null, originalData);
} catch (Exception ignore) {
Logger logger = LoggerFactory.getLogger(ResultStrategy.class);
logger.info("parse data error", ignore);
}
} }
return originalData; return originalData;
} }

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java

@ -0,0 +1,12 @@
package com.hnac.hzims.bigmodel.zhipuai.handler.result.data;
/**
* @Author: ypj
* @Date: 2024/8/28 16:12
*/
public class BooleanParser implements ResultDataParser<Boolean> {
@Override
public Boolean parse(String originalData) {
return Boolean.parseBoolean(originalData);
}
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java

@ -0,0 +1,12 @@
package com.hnac.hzims.bigmodel.zhipuai.handler.result.data;
/**
* @Author: ypj
* @Date: 2024/8/28 16:46
*/
public class IntegerParser implements ResultDataParser<Integer> {
@Override
public Integer parse(String originalData) {
return Integer.parseInt(originalData);
}
}

9
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java

@ -0,0 +1,9 @@
package com.hnac.hzims.bigmodel.zhipuai.handler.result.data;
/**
* @Author: ypj
* @Date: 2024/8/28 16:04
*/
public interface ResultDataParser<T> {
T parse(String originalData);
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java

@ -0,0 +1,12 @@
package com.hnac.hzims.bigmodel.zhipuai.handler.result.data;
/**
* @Author: ypj
* @Date: 2024/8/28 16:11
*/
public class StringParser implements ResultDataParser<String> {
@Override
public String parse(String originalData) {
return originalData;
}
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

@ -7,7 +7,7 @@ import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy; import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService;

16
hzims-service/hzims-big-model/src/main/resources/template/template.yml

@ -11,31 +11,31 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/test_hzims_big_model?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_big_model?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
operation: operation:
url: jdbc:mysql://192.168.60.34:3576/test_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
equipment: equipment:
url: jdbc:mysql://192.168.60.34:3576/test_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
ticket: ticket:
url: jdbc:mysql://192.168.60.34:3576/test_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
safeproduct: safeproduct:
url: jdbc:mysql://192.168.60.34:3576/test_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
inspect: inspect:
url: jdbc:mysql://192.168.60.34:3576/test_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
alarm: alarm:
url: jdbc:mysql://192.168.60.34:3576/test_hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.60.34:3576/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
information: information:
@ -49,6 +49,7 @@ spring:
gglm: gglm:
url: "http://${gglm.host}:${gglm.port}" url: "http://${gglm.host}:${gglm.port}"
vectorUrl: "http://${vector.host}:${vector.port}"
api: api:
assistantAsk: "/qa/assistant_ask" assistantAsk: "/qa/assistant_ask"
assistantStatus: "/qa/assistant_status" assistantStatus: "/qa/assistant_status"
@ -62,6 +63,7 @@ gglm:
smartReportGeneratePower: "/custom/smart_report_generate_power" smartReportGeneratePower: "/custom/smart_report_generate_power"
assistantAnalyseAsk: "/qa/assistant_analyse_ask" assistantAnalyseAsk: "/qa/assistant_analyse_ask"
updateKnowledge: "/kn/update_knowledge" updateKnowledge: "/kn/update_knowledge"
compute: "compute"
swagger: swagger:
base-packages: com.hnac.hzims.bigmodel base-packages: com.hnac.hzims.bigmodel

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

@ -49,8 +49,8 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
throw new ServiceException("消息转换失败,消息内容为:" + message); throw new ServiceException("消息转换失败,消息内容为:" + message);
}); });
if (ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ if (ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
ticketServiceList.get(0).pushFailMessage(Long.valueOf(response.getTaskId()),response.getBusinessKey(), ticketServiceList.get(0).pushFailMessage(response.getBusinessKey(),response.getProcessDefinitionKey(),
response.getUserId(), response.getTaskName(),response.getResult(),response.getDeptId()); response.getTaskName(),response.getResult(),response.getDeptId());
} }
// 保存日志 // 保存日志
WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class); WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class);

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

@ -33,9 +33,9 @@ public class CompensateProcessClient implements ICompensateProcessClient {
@PostMapping("/startFlow") @PostMapping("/startFlow")
public R startFlow(@RequestParam("userId") String userId, public R startFlow(@RequestParam("userId") String userId,
@RequestParam("dictValue")String dictValue, @RequestParam("dictValue")String dictValue,
@RequestParam("taskId")String taskId, @RequestParam("businessKey")String businessKey,
@RequestParam("processName")String processName, @RequestParam("processName")String processName,
@RequestBody Map<String, Object> variables) { @RequestBody Map<String, Object> variables) {
return processService.startFlow(userId,dictValue,taskId,processName,variables); return processService.startFlow(userId,dictValue,businessKey,processName,variables);
} }
} }

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

@ -4,13 +4,14 @@ import com.hnac.hzims.middle.processflow.entity.ProcessDict;
import com.hnac.hzims.middle.processflow.service.ProcessDictService; import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.service.ProcessService; import com.hnac.hzims.middle.processflow.strategy.service.ProcessService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageFlowDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
@ -43,11 +44,11 @@ public abstract class ProcessAbstractService implements ProcessService {
private ProcessDictService processDictService; private ProcessDictService processDictService;
@Override @Override
public R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) { public R startFlow(String userId, String dictValue, String businessKey, String processName, Map<String, Object> variables) {
log.info("开启流程....."); log.info("开启流程.....");
R r = new R(); R r = new R();
try { try {
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables); R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, businessKey, processName, variables);
r.setSuccess(result.isSuccess()); r.setSuccess(result.isSuccess());
r.setCode(result.getCode()); r.setCode(result.getCode());
r.setMsg(result.getMsg()); r.setMsg(result.getMsg());
@ -60,7 +61,7 @@ public abstract class ProcessAbstractService implements ProcessService {
log.error("开启流程失败:{}",result); log.error("开启流程失败:{}",result);
log.error("流程信息为{}",variables); log.error("流程信息为{}",variables);
r.setData(variables); r.setData(variables);
pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg()); pushStartFailMessage(dictValue,businessKey,userId,processName,result.getMsg());
} }
return r; return r;
}catch (Exception e){ }catch (Exception e){
@ -85,11 +86,11 @@ public abstract class ProcessAbstractService implements ProcessService {
// return r; // return r;
// } // }
public void pushStartFailMessage(String dictValue,Long taskId, String userId, String content,String reason) { public void pushStartFailMessage(String dictValue,String businessKey, String userId, String content,String reason) {
ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue); ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue);
BusinessMessageDTO message = new BusinessMessageDTO(); BusinessMessageFlowDTO message = new BusinessMessageFlowDTO();
// 计划Id // 计划Id
message.setTaskId(taskId); message.setTaskId(businessKey);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题 // 主题
@ -108,36 +109,46 @@ public abstract class ProcessAbstractService implements ProcessService {
} }
message.setCreateUser(admin.getId()); message.setCreateUser(admin.getId());
message.setUserIds(userId); message.setUserIds(userId);
messageClient.sendAppAndWsMsgByUsers(message); messageClient.sendAppAndWsMsgByUsersFlow(message);
} }
@Override @Override
public void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId) { public void pushFailMessage(String businessKey, String proessKey, String content,String reason,String deptId) {
ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey); ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey);
BusinessMessageDTO message = new BusinessMessageDTO(); BusinessMessageFlowDTO message = new BusinessMessageFlowDTO();
// BusinessMessageDTO message = new BusinessMessageDTO();
// 计划Id // 计划Id
message.setTaskId(taskId); message.setTaskId(businessKey);
message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey());
// 主题 // 主题
message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription()); message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription());
// 内容 // 内容
String res= StringUtil.format("你有一个{}的{}流程流转失败,失败原因为:{}",content, String res= StringUtil.format("你有一个流程环节为{}的{}流转失败,失败原因为:{}",content,
processDict.getDictLabel(), reason); processDict.getDictLabel(), reason);
message.setContent(res); message.setContent(res);
message.setTenantId("200000"); message.setTenantId("200000");
R<List<User>> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER); R<List<User>> userListR = userClient.queryUserByRoleAlias("200000", Long.valueOf(deptId), PROJECT_MANAGER);
User admin = userClient.userByAccount("200000", "admin").getData(); User admin = userClient.userByAccount("200000", "admin").getData();
User createUser = userClient.userInfoById(Long.valueOf(userId)).getData(); message.setDeptId(Long.valueOf(deptId));
message.setDeptId(createUser.getCreateDept()); R<String> result = sysClient.getDeptName(Long.valueOf(deptId));
R<String> result = sysClient.getDeptName(createUser.getCreateDept());
if (result.isSuccess()) { if (result.isSuccess()) {
message.setDeptName(result.getData()); message.setDeptName(result.getData());
} }
if (CollectionUtil.isNotEmpty(userListR.getData())){
List<User> data = userListR.getData(); List<User> data = userListR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setCreateUser(admin.getId());
message.setUserIds(userIds); message.setUserIds(userIds);
messageClient.sendAppAndWsMsgByUsers(message); }else {
R<List<User>> listR = userClient.queryUserByRoleAlias("200000", Long.valueOf(20000001), PROJECT_MANAGER);
if (ObjectUtil.isEmpty(listR)||CollectionUtil.isEmpty(listR.getData())){
return;
}
List<User> data =listR.getData();
String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(","));
message.setUserIds(userIds);
}
message.setCreateUser(admin.getId());
messageClient.sendAppAndWsMsgByUsersFlow(message);
} }
} }

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

@ -14,9 +14,9 @@ import java.util.Map;
*/ */
public interface ProcessService { public interface ProcessService {
R startFlow(String userId, String dictValue, String taskId, String processName, Map<String, Object> variables) ; R startFlow(String userId, String dictValue, String businessKey, String processName, Map<String, Object> variables) ;
void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId); void pushFailMessage(String taskId, String proessKey, String content,String reason,String deptId);
/** /**
* 设置执行那种实现类 * 设置执行那种实现类
* @param flowQueue * @param flowQueue

2
hzims-service/hzims-middle/src/main/resources/template/template.yml

@ -8,7 +8,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

14
hzims-service/hzims-scheduled/src/main/resources/template/template.yml

@ -14,31 +14,31 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
equipment: equipment:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
ticket: ticket:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
safeproduct: safeproduct:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
inspect: inspect:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
basic: basic:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
alarm: alarm:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml

@ -3,7 +3,7 @@
<mapper namespace="com.hnac.hzinfo.inspect.obj.mapper.ObjectTemplateMapper"> <mapper namespace="com.hnac.hzinfo.inspect.obj.mapper.ObjectTemplateMapper">
<select id="getListByObjectId" resultType="com.hnac.hzinfo.inspect.obj.entity.ObjectTemplateEntity"> <select id="getListByObjectId" resultType="com.hnac.hzinfo.inspect.obj.entity.ObjectTemplateEntity">
SELECT t.id,o.code,o.name,o.SUPPORT_AUTO_VIDEO,t.template_id,t.object_id SELECT distinct t.id,o.code,o.name,o.SUPPORT_AUTO_VIDEO,t.template_id,t.object_id
from hz_st_re_object_template t from hz_st_re_object_template t
left JOIN hz_st_re_template o on (t.template_id=o.id) left JOIN hz_st_re_template o on (t.template_id=o.id)
left join hz_st_re_template_project p on o.id = p.template_id left join hz_st_re_template_project p on o.id = p.template_id

2
hzims-service/inspect/src/main/resources/template/template.yml

@ -18,7 +18,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

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

@ -121,7 +121,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces
private final TransactionTemplate transactionTemplate; private final TransactionTemplate transactionTemplate;
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
transactionTemplate.setTransactionManager(transactionManager); transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> { String res = transactionTemplate.execute(status -> {
AccessPlanV4DTO accessPlanV4DTO = JSONObject.parseObject(entity, AccessPlanV4DTO.class); AccessPlanV4DTO accessPlanV4DTO = JSONObject.parseObject(entity, AccessPlanV4DTO.class);
@ -289,8 +288,8 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces
entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator());
entity.setIsNormal(true); entity.setIsNormal(true);
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false); handException(processWorkFlowResponse);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); return false;
} }
if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){
entity.setTaskName("流程结束"); entity.setTaskName("流程结束");
@ -322,7 +321,27 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces
} }
return true; return true;
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
OperAccessPlanEntity operAccessPlanEntity = planService.getOne(new LambdaQueryWrapper<OperAccessPlanEntity>() {{
eq(OperAccessPlanEntity::getId, split[1]);
}});
operAccessPlanEntity.setIsNormal(false);
operAccessPlanEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
operAccessPlanEntity.setTaskName(processWorkFlowResponse.getTaskName());
operAccessPlanEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
operAccessPlanEntity.setNextStepOperator("");
boolean flag = planService.updateById(operAccessPlanEntity);
if (!flag){
log.info("异常状态消息保存失败"+ processWorkFlowResponse);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
/** /**
* 开启检修任务 * 开启检修任务

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

@ -131,7 +131,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces
String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables); String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables);
log.error("开启检修任务流程失败{}" + result); log.error("开启检修任务流程失败{}" + result);
// 更新任务流程Id // 更新任务流程Id
if (200==result.getCode()) { if (200==result.getCode()&&ObjectUtil.isNotEmpty(result.getData())) {
accessTaskV4DTO.setProcessInstanceId(result.getData().toString()); accessTaskV4DTO.setProcessInstanceId(result.getData().toString());
accessTaskV4DTO.setIsNormal(true); accessTaskV4DTO.setIsNormal(true);
taskService.updateById(accessTaskV4DTO); taskService.updateById(accessTaskV4DTO);
@ -237,8 +237,8 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces
AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessTaskV4DTO>(){}); AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<AccessTaskV4DTO>(){});
entity.setIsNormal(true); entity.setIsNormal(true);
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false); handException(processWorkFlowResponse);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); return false;
} }
// 当前流程名称 // 当前流程名称
entity.setTaskName(processWorkFlowResponse.getTaskName()); entity.setTaskName(processWorkFlowResponse.getTaskName());
@ -266,12 +266,31 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces
String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName()) String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName())
.concat(",当前环节:") .concat(",当前环节:")
.concat(processWorkFlowResponse.getTaskName()); .concat(processWorkFlowResponse.getTaskName());
if(ObjectUtils.isEmpty(processWorkFlowResponse.getCode())||700!=processWorkFlowResponse.getCode()){
this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); this.sendMessage(entity,processWorkFlowResponse.getUserId(),content);
}
return true; return true;
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
OperAccessTaskEntity operAccessTaskEntity = taskService.getOne(new LambdaQueryWrapper<OperAccessTaskEntity>() {{
eq(OperAccessTaskEntity::getId, split[1]);
}});
operAccessTaskEntity.setIsNormal(false);
operAccessTaskEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
operAccessTaskEntity.setTaskName(processWorkFlowResponse.getTaskName());
operAccessTaskEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
operAccessTaskEntity.setNextStepOperator("");
boolean flag = taskService.updateById(operAccessTaskEntity);
if (!flag){
log.info("异常状态消息保存失败"+ processWorkFlowResponse);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
/** /**
* 推送业务流程消息 * 推送业务流程消息

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java

@ -27,12 +27,6 @@ public class HzimsDataController {
private final HzimsDataService service; private final HzimsDataService service;
@GetMapping("/saveArea")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "获取区域列表数据", notes = "无需传入参数")
public R saveArea() {
return R.data(service.saveArea());
}
@GetMapping("/stationNumber") @GetMapping("/stationNumber")

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java

@ -15,11 +15,6 @@ import java.util.List;
*/ */
public interface HzimsDataService { public interface HzimsDataService {
/**
* 获取区域列表数据
* @return
*/
boolean saveArea();
List<StationNumberVo> stationNumber(); List<StationNumberVo> stationNumber();

39
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

@ -85,10 +85,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@Value("${hzims.operation.save.area.url}")
public String AREA_URL;
@Value("${hzims.operation.save.station.url}")
public String STATION_URL;
private final static String charge = "hzims:operation:key:charge"; private final static String charge = "hzims:operation:key:charge";
@ -105,41 +102,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
@Override
public boolean saveArea() {
R<List<Dept>> result = sysClient.getDeptList();
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
throw new ServiceException("暂无区域数据!");
}
List<Integer> types = Arrays.asList(HomePageConstant.HYDROPOWER, HomePageConstant.WATER_CONSERVANCY, HomePageConstant.PUMPING, HomePageConstant.GATE);
Map<Dept, List<StationEntity>> map = areaService.getAuthArea(result.getData(), null, types, HomePageConstant.HYDROPOWER_SERVETYPE,true);
if (MapUtils.isEmpty(map)) {
throw new ServiceException("暂无区域数据!");
}
List<EminfoAndEmParamVo> deviceList = emService.getEmInfoList();
// 获取区域列表数据
List<AreaVo> list = map.entrySet().stream().map(entry->{
AreaVo vo = new AreaVo();
vo.setDeptId(entry.getKey().getId());
vo.setDeptName(entry.getKey().getDeptName());
int hydropowerCount = (int) entry.getValue().stream().filter(o->HomePageConstant.HYDROPOWER.equals(o.getType())).count();
vo.setHydropowerStationCount(hydropowerCount);
int waterCount = entry.getValue().size() - hydropowerCount;
vo.setWaterStationCount(waterCount);
List<Long> value = entry.getValue().stream().filter(o->HomePageConstant.HYDROPOWER.equals(o.getType())).map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(value)){
vo.setInstalledCapacity(0.0);
}else{
double installedCapacity = deviceList.stream().filter(o-> null != o.getInstalledCapacity() && value.contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum();
vo.setInstalledCapacity(installedCapacity);
}
return vo;
}).collect(Collectors.toList());
// 调用Http请求
return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL);
}
/** /**

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

@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -335,6 +337,10 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
long taskId; long taskId;
OperPhenomenonEntity operPhenomenonEntity; OperPhenomenonEntity operPhenomenonEntity;
log.info("消缺消息开始转换"+processWorkFlowResponse); log.info("消缺消息开始转换"+processWorkFlowResponse);
//流程找不到下一个审批人处理
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
return handException(processWorkFlowResponse);
}
try { try {
Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables(); Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
//现象缺陷全表更新 //现象缺陷全表更新
@ -368,7 +374,6 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
Long differTime = TimeUtils.getDifferTime(operPhenomenonEntity.getPlanStartTime(), operPhenomenonEntity.getPlanEndTime()); Long differTime = TimeUtils.getDifferTime(operPhenomenonEntity.getPlanStartTime(), operPhenomenonEntity.getPlanEndTime());
operPhenomenonEntity.setPlanHours(differTime.intValue()); operPhenomenonEntity.setPlanHours(differTime.intValue());
} }
taskId = operPhenomenonEntity.getId();
//缺陷库记录 //缺陷库记录
if (ObjectUtil.isNotEmpty(operPhenomenonEntity.getIsWarehousing()) && 1==(operPhenomenonEntity.getIsWarehousing())) { if (ObjectUtil.isNotEmpty(operPhenomenonEntity.getIsWarehousing()) && 1==(operPhenomenonEntity.getIsWarehousing())) {
OperDefectEntity operDefectEntity = new OperDefectEntity(); OperDefectEntity operDefectEntity = new OperDefectEntity();
@ -384,14 +389,7 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
log.info("缺陷ID:" + operPhenomenonEntity.getDefectCode() + "入库成功"); log.info("缺陷ID:" + operPhenomenonEntity.getDefectCode() + "入库成功");
} }
//流程找不到下一个审批人处理
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
operPhenomenonEntity.setIsNormal(false);
operPhenomenonEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}else {
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,taskId);
}
//更新数据库 //更新数据库
Long statisticsEntityId = statisticsEntity.getId(); Long statisticsEntityId = statisticsEntity.getId();
Long appearanceEntityId = appearanceEntity.getId(); Long appearanceEntityId = appearanceEntity.getId();
@ -405,6 +403,31 @@ public class DefectCheckServiceImpl extends ServiceImpl<OperPhenomenonMapper, Op
statisticsService.updateById(statisticsEntity); statisticsService.updateById(statisticsEntity);
operAppearanceService.updateById(appearanceEntity); operAppearanceService.updateById(appearanceEntity);
log.info("消缺消息转换结束"+processWorkFlowResponse); log.info("消缺消息转换结束"+processWorkFlowResponse);
log.info("推送给用户消息"+processWorkFlowResponse);
//推送消息中心相关消息
sendMessage(processWorkFlowResponse, operPhenomenonEntity,operPhenomenonEntity.getId());
log.info("推送给消息结束");
return R.success("消息保存成功");
}
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("消缺异常处理失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("消缺异常处理失败");
}
OperPhenomenonEntity operPhenomenonEntity = this.baseMapper.selectOne(new LambdaQueryWrapper<OperPhenomenonEntity>() {{
eq(OperPhenomenonEntity::getId, split[1]);
}});
operPhenomenonEntity.setIsNormal(false);
operPhenomenonEntity.setCheckProcessInstanceId(processWorkFlowResponse.getTaskId());
operPhenomenonEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
operPhenomenonEntity.setCurrentOperator(processWorkFlowResponse.getTaskName());
operPhenomenonEntity.setCurrentLinkHandler("");
this.baseMapper.update(operPhenomenonEntity, new LambdaUpdateWrapper<OperPhenomenonEntity>() {{
eq(OperPhenomenonEntity::getDefectCode, operPhenomenonEntity.getDefectCode());
}});
log.info("消缺消息转换结束"+ processWorkFlowResponse);
return R.success("消息保存成功"); return R.success("消息保存成功");
} }

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

@ -32,18 +32,6 @@ public class DutyRecClient implements IDutyRecClient {
@Override @Override
public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) { public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) {
log.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse)); return service.dealDutyRecFlow(processWorkFlowResponse);
//ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class);
ImsDutyRecDTO recDTO = JSONObject.parseObject(JSON.toJSONString(processWorkFlowResponse.getVariables()),ImsDutyRecDTO.class);
Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> {
throw new RuntimeException("未接收到交接班信息!");
});
recDTO.setDealChain(processWorkFlowResponse.getTaskName());
recDTO.setIsNormal(true);
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
recDTO.setIsNormal(false);
recDTO.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
return R.status(service.dealDutyRecFlow(recDTO));
} }
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java

@ -25,7 +25,6 @@ public interface ImsDutyRecQRRecordMapper extends UserDataScopeBaseMapper<ImsDut
* @return * @return
*/ */
@UserDataAuth List<ImsDutyRecQRRecordVo> selectPageList(@Param(value = "page")IPage page,@Param(value = "vo") ImsDutyRecQRRecordVo vo);
List<ImsDutyRecQRRecordVo> selectPageList(IPage page,@Param(value = "vo") ImsDutyRecQRRecordVo vo);
} }

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

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.duty.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO;
import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO;
import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO;
@ -130,7 +131,7 @@ public interface IImsDutyRecService extends IService<ImsDutyRecEntity> {
* @param recDTO 交接班信息 * @param recDTO 交接班信息
* @return * @return
*/ */
Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO); R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse);
R<ImsDutyLogEntity> getDutyLog(ImsDutyLogEntity imsDutyLogEntity); R<ImsDutyLogEntity> getDutyLog(ImsDutyLogEntity imsDutyLogEntity);

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

@ -10,10 +10,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.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.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.monitor.utils.DateUtils;
import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.OperationalConstants;
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity; import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
@ -1321,8 +1324,19 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
} }
@Override @Override
//@Transactional public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) {
public Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO) { log.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse));
//ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class);
ImsDutyRecDTO recDTO = JSONObject.parseObject(JSON.toJSONString(processWorkFlowResponse.getVariables()),ImsDutyRecDTO.class);
Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> {
throw new RuntimeException("未接收到交接班信息!");
});
recDTO.setDealChain(processWorkFlowResponse.getTaskName());
recDTO.setIsNormal(true);
if(ObjectUtil.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
handException(processWorkFlowResponse);
}
ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class); ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class);
ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class); ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class);
if(StringUtil.isBlank(recDTO.getDealChain())) { if(StringUtil.isBlank(recDTO.getDealChain())) {
@ -1366,13 +1380,36 @@ public class ImsDutyRecServiceImpl extends ServiceImpl<ImsDutyRecMapper, ImsDuty
} }
// 更新交接班 // 更新交接班
if (ObjectUtil.isNotEmpty(dutyRec)&&ObjectUtil.isNotEmpty(dutyRec.getId())) { if (ObjectUtil.isNotEmpty(dutyRec)&&ObjectUtil.isNotEmpty(dutyRec.getId())) {
return this.updateById(dutyRec); boolean b = this.updateById(dutyRec);
}else { if (b){
log.error("更新交接班记录失败"+dutyRec.toString()); return R.success("更新交接班记录成功");
return false;
} }
} }
log.error("更新交接班记录失败"+dutyRec.toString());
return R.fail("更新交接班记录失败");
}
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
ImsDutyRecEntity imsDutyRecEntity = this.getOne(new LambdaQueryWrapper<ImsDutyRecEntity>() {{
eq(ImsDutyRecEntity::getId, split[1]);
}});
imsDutyRecEntity.setIsNormal(false);
imsDutyRecEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
imsDutyRecEntity.setDealChain(processWorkFlowResponse.getTaskName());
imsDutyRecEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
boolean flag = this.updateById(imsDutyRecEntity);
if (!flag){
log.info("异常状态消息保存失败"+ processWorkFlowResponse);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
/** /**
* 计算交接班状态 * 计算交接班状态
* @param duty 值班信息 * @param duty 值班信息

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

@ -1,12 +1,17 @@
package com.hnac.hzims.operational.maintenance.scheduled; package com.hnac.hzims.operational.maintenance.scheduled;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.alarm.config.entity.AlarmHandleFlowEntity;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.operational.constants.FlowKeyConstants; import com.hnac.hzims.operational.constants.FlowKeyConstants;
import com.hnac.hzims.operational.constants.RedisKeyConstants; import com.hnac.hzims.operational.constants.RedisKeyConstants;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
@ -28,6 +33,7 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -41,6 +47,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.hnac.hzims.operational.constants.FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY;
import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant.GENERATE_MAINTENANCE_TASK_SCHEDULE; import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant.GENERATE_MAINTENANCE_TASK_SCHEDULE;
/** /**
@ -57,6 +64,7 @@ public class MaintenanceTaskSchedule implements StartProcessService {
private final IImsDutyMainService dutyMainService; private final IImsDutyMainService dutyMainService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IEmInfoClient emInfoClient; private final IEmInfoClient emInfoClient;
private final ICompensateProcessClient compensateProcessClient;
@XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE) @XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE)
public ReturnT<String> execute(String param) throws Exception { public ReturnT<String> execute(String param) throws Exception {
@ -173,10 +181,11 @@ public class MaintenanceTaskSchedule implements StartProcessService {
*/ */
private void startProcessInstance(OperMaintenanceTaskEntity task) { private void startProcessInstance(OperMaintenanceTaskEntity task) {
String s = saveEntity(JSONObject.toJSONString(task)); String s = saveEntity(JSONObject.toJSONString(task));
startProcess(s,FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY,null); startProcess(s, MAINTENANCE_TASK_FLOW_KEY,null);
} }
@Override @Override
//没有保存多张表,不单独开启事务
public String saveEntity(String entity) { public String saveEntity(String entity) {
return entity; return entity;
} }
@ -202,8 +211,13 @@ public class MaintenanceTaskSchedule implements StartProcessService {
}); });
put("operMaintenanceTaskEntityVo",vo); put("operMaintenanceTaskEntityVo",vo);
}}; }};
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params); if (StringUtils.isNotBlank(param)){
if (!flowResult.isSuccess()){ params=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class);
}
String businessKey = FlowUtil.getBusinessKey("hzims_oper_maintenance_task", "" +task.getId());
R flowResult = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), dictValue, businessKey, task.getTitle(), params);
// R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params);
if (200!=flowResult.getCode()){
task.setIsNormal(false); task.setIsNormal(false);
task.setRemark(JSONObject.toJSONString(params)); task.setRemark(JSONObject.toJSONString(params));
taskService.updateById(task); taskService.updateById(task);
@ -213,14 +227,22 @@ public class MaintenanceTaskSchedule implements StartProcessService {
r.setData(params); r.setData(params);
log.error(task.getId()+"日常维护任务启动流程失败{}", task); log.error(task.getId()+"日常维护任务启动流程失败{}", task);
return r; return r;
}else {
task.setIsNormal(true);
task.setProcessInstanceId(flowResult.getData().toString());
taskService.updateById(task);
} }
String s = Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); String s = flowResult.getData().toString();
log.info(task.getId()+"日常维护任务启动成功{}", s); log.info(task.getId()+"日常维护任务启动成功{}", s);
return R.success("启动流程成功"); return R.success("启动流程成功");
} }
@Override @Override
public R compensationProcess(String id) { public R compensationProcess(String id) {
return null; OperMaintenanceTaskEntity operMaintenanceTaskEntity = taskService.getById(id);
if (ObjectUtils.isNotEmpty(operMaintenanceTaskEntity)){
return this.startProcess(JSON.toJSONString(operMaintenanceTaskEntity), MAINTENANCE_TASK_FLOW_KEY,operMaintenanceTaskEntity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
} }

30
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
@ -125,12 +126,17 @@ public class MaintenanceServiceImpl implements MaintenanceService {
log.error("获取表单出现异常了~~~~"+response); log.error("获取表单出现异常了~~~~"+response);
throw new IllegalArgumentException(e.getMessage()); throw new IllegalArgumentException(e.getMessage());
} }
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
handException(response);
return;
}
OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity(); OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity();
BeanUtils.copyProperties(standardTicketInfoVo, entity); BeanUtils.copyProperties(standardTicketInfoVo, entity);
//1.查询日常维护信息 //1.查询日常维护信息
//有Id才进行生成操作 //有Id才进行生成操作
if (StringUtils.isNotBlank(response.getBusinessKey())) { if (StringUtils.isNotBlank(response.getBusinessKey())) {
Long id = NumberUtils.toLong(response.getBusinessKey()); String str = response.getBusinessKey().split(":")[1];
Long id = NumberUtils.toLong(str);
OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id); OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id);
if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) { if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) {
log.error("获取日常维护数据不存在" + response); log.error("获取日常维护数据不存在" + response);
@ -178,6 +184,28 @@ public class MaintenanceServiceImpl implements MaintenanceService {
} }
} }
private R handException(ProcessWorkFlowResponse response) {
String[] split = response.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ response);
return R.fail("异常消息处理失败");
}
OperMaintenanceTaskEntity entity = taskService.getOne(new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{
eq(OperMaintenanceTaskEntity::getId, split[1]);
}});
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(response.getVariables()));
entity.setFlowTaskName(response.getTaskName());
entity.setProcessInstanceId(response.getTaskId());
entity.setNextStepOperator("");
boolean flag = taskService.updateById(entity);
if (!flag){
log.info("异常状态消息保存失败"+ response);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
/** /**
* 填充日常维护信息 * 填充日常维护信息

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -369,7 +369,7 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
// 告警信息 // 告警信息
List<SoeDataDTO> soeDataDTOS = alarms.stream().filter(a -> deviceName.equals(a.getDeviceName())).map(alarm -> { List<SoeDataDTO> soeDataDTOS = alarms.stream().filter(a -> deviceName.equals(a.getDeviceName())).map(alarm -> {
SoeDataDTO soeDataDTO = new SoeDataDTO(); SoeDataDTO soeDataDTO = new SoeDataDTO();
soeDataDTO.setDate(month); soeDataDTO.setDate(req.getMonth());
soeDataDTO.setName(alarm.getContent()); soeDataDTO.setName(alarm.getContent());
soeDataDTO.setTimes(alarm.getCount()); soeDataDTO.setTimes(alarm.getCount());
return soeDataDTO; return soeDataDTO;

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java → hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/VideoSyncAspect.java

@ -5,24 +5,17 @@ import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants;
import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.wrapper.VideoSyncWrapper;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.mqtt.producer.IMqttSender; import org.springblade.mqtt.producer.IMqttSender;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @Author: huangxing * @Author: huangxing
@ -32,9 +25,9 @@ import java.util.stream.Collectors;
@Component @Component
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
public class AddVideoAspect { public class VideoSyncAspect {
private final IStationService stationService; private final VideoSyncWrapper wrapper;
private final IMqttSender mqttSender; private final IMqttSender mqttSender;
@Pointcut("execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.saveBatch(..)) " + @Pointcut("execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.saveBatch(..)) " +
@ -51,26 +44,15 @@ public class AddVideoAspect {
if(args.length == 1) { if(args.length == 1) {
Object arg = args[0]; Object arg = args[0];
if(arg instanceof StationVideoTypeEntity) { if(arg instanceof StationVideoTypeEntity) {
List<VideoSyncDTO> videoSyncDTOS = Lists.newArrayList(this.convert((StationVideoTypeEntity) arg)); List<VideoSyncDTO> videoSyncDTOS = Lists.newArrayList(wrapper.convert((StationVideoTypeEntity) arg));
mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS)); mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS));
} }
else if(arg instanceof List) { else if(arg instanceof List) {
List<StationVideoTypeEntity> videoList = (List<StationVideoTypeEntity>) args[0]; List<StationVideoTypeEntity> videoList = (List<StationVideoTypeEntity>) args[0];
List<VideoSyncDTO> videoSyncDTOS = videoList.stream().map(this::convert).collect(Collectors.toList()); List<VideoSyncDTO> videoSyncDTOS = wrapper.listVO(videoList);
mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS)); mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS));
} }
} }
} }
private VideoSyncDTO convert(StationVideoTypeEntity entity) {
VideoSyncDTO videoSyncDTO = BeanUtil.copy(entity,VideoSyncDTO.class);
StationVO station = stationService.getStationByCode(entity.getStationId());
String stationName = Optional.ofNullable(station).map(StationVO::getName).orElse("");
videoSyncDTO.setId(String.valueOf(entity.getId()));
videoSyncDTO.setItemId(String.valueOf(entity.getId()));
videoSyncDTO.setStationName(stationName);
videoSyncDTO.setItemName(stationName + " " + videoSyncDTO.getName());
return videoSyncDTO;
}
} }

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

@ -225,10 +225,7 @@ public class StationVideoTypeController extends BladeController {
} }
@RequestMapping(value = "/getVideoReviewerToken", method = {RequestMethod.GET, RequestMethod.POST})
public R<String> getVideoReviewerToken() {
return R.data(stationVideoTypeService.getVideoReviewerToken());
}
@GetMapping("/getVideoMonitorByAgency") @GetMapping("/getVideoMonitorByAgency")

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java

@ -48,11 +48,7 @@ public interface IStationVideoTypeService extends IService<StationVideoTypeEntit
*/ */
List<StationVideoTypeEntity> getVideoByIds(String ids,String randomCode); List<StationVideoTypeEntity> getVideoByIds(String ids,String randomCode);
/**
* 获取视频查看人员Token
* @return 视频查看人员Token
*/
String getVideoReviewerToken();
/** /**
* 获取海康威视各站点列表 * 获取海康威视各站点列表

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -58,8 +58,6 @@ public class StationVideoTypeServiceImpl extends ServiceImpl<StationVideoTypeMap
private final IHikVideoService hikVideoService; private final IHikVideoService hikVideoService;
@Value("${url.video.login}")
private String videoLoginUrl;
@Value("${hzims.video.random-code}") @Value("${hzims.video.random-code}")
private String definitionCode; private String definitionCode;
/** 秘钥appKey **/ /** 秘钥appKey **/
@ -157,15 +155,7 @@ public class StationVideoTypeServiceImpl extends ServiceImpl<StationVideoTypeMap
return result; return result;
} }
@Override
public String getVideoReviewerToken() {
String result = HttpUtil.post(videoLoginUrl, "");
JSONObject resultObject = JSONObject.parseObject(result);
String data = resultObject.getString("data");
String access_token = JSONObject.parseObject(data).getString("access_token");
log.info("视频查看人员登陆token为:{}",access_token);
return access_token;
}
@Override @Override
public List<JSONObject> getHikVisionStations() { public List<JSONObject> getHikVisionStations() {

38
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/wrapper/VideoSyncWrapper.java

@ -0,0 +1,38 @@
package com.hnac.hzims.operational.station.wrapper;
import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO;
import com.hnac.hzims.bigmodel.api.wrapper.BaseSyncWrapper;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationVO;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Optional;
/**
* @Author: huangxing
* @Date: 2024/08/20 11:21
*/
@Component
@AllArgsConstructor
public class VideoSyncWrapper extends BaseSyncWrapper<StationVideoTypeEntity, VideoSyncDTO> {
private final IStationService stationService;
@Override
public VideoSyncDTO convert(StationVideoTypeEntity entity) {
VideoSyncDTO videoSyncDTO = BeanUtil.copy(entity,VideoSyncDTO.class);
StationVO station = stationService.getStationByCode(entity.getStationId());
String stationName = Optional.ofNullable(station).map(StationVO::getName).orElse("");
videoSyncDTO.setId(String.valueOf(entity.getId()));
videoSyncDTO.setItemId(String.valueOf(entity.getId()));
videoSyncDTO.setStationName(stationName);
videoSyncDTO.setItemName(stationName + " " + videoSyncDTO.getName());
return videoSyncDTO;
}
}

15
hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java

@ -32,21 +32,8 @@ public class DistributeWorkOrderController {
private final IOperAccessTaskService operAccessTaskService; private final IOperAccessTaskService operAccessTaskService;
private final IOperDefectService operDefectService; private final IOperDefectService operDefectService;
@GetMapping("/testDistributeWorkOrder")
@ApiOperation(value = "检修工单派发",notes = "检修工单派发")
@ApiImplicitParam(name = "operAccessTaskEntity", value = "检修任务", paramType = "body", dataType = "OperAccessTaskEntity")
@ApiOperationSupport(order = 1)
public R distributeWorkOrder(@RequestBody OperAccessTaskEntity operAccessTaskEntity){
return distributeWorkOrderService.distributeAccessTask(operAccessTaskEntity);
}
@GetMapping("/testDistributeDefect")
@ApiOperation(value = "消缺工单派发",notes = "消缺工单派发")
@ApiImplicitParam(name = "operAccessTaskEntity", value = "消缺对象", paramType = "query", dataType = "operDefectEntity")
@ApiOperationSupport(order = 2)
public R testDistributeDefect(@RequestBody OperDefectEntity operDefectEntity){
return distributeWorkOrderService.distributeDefectTask(operDefectEntity);
}
@GetMapping("/getAccessWorkOrderList") @GetMapping("/getAccessWorkOrderList")
@ApiOperation(value = "获取检修工单列表",notes = "获取检修工单列表") @ApiOperation(value = "获取检修工单列表",notes = "获取检修工单列表")

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java

@ -5,19 +5,8 @@ import com.hnac.hzims.operational.defect.entity.OperDefectEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@Deprecated @Deprecated
public interface IDistributeWorkOrderService { public interface IDistributeWorkOrderService {
/**
* 派发检修任务
* @param operAccessTaskEntity
* @return
*/
R distributeAccessTask(OperAccessTaskEntity operAccessTaskEntity);
/**
* 派发消缺任务
* @param operDefectEntity
* @return
*/
R distributeDefectTask(OperDefectEntity operDefectEntity);
/** /**
* 获取检修工单列表 * 获取检修工单列表

151
hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java

@ -51,11 +51,6 @@ public class DistributeWorkOrderServiceImpl implements IDistributeWorkOrderServi
private final IOperPhenomenonService operPhenomenonService; private final IOperPhenomenonService operPhenomenonService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@Value("${url.water-out.orderCrtPackage}")
private String orderCrtPackageUrl;
@Value("${url.water-out.orderCrtGrabPackage}")
private String orderCrtGrabPackageUrl;
@Value("${hzims.operation.workOrder.access}") @Value("${hzims.operation.workOrder.access}")
private String accessWorkOrderKey; private String accessWorkOrderKey;
@ -63,152 +58,6 @@ public class DistributeWorkOrderServiceImpl implements IDistributeWorkOrderServi
@Value("${hzims.operation.workOrder.defect}") @Value("${hzims.operation.workOrder.defect}")
private String defectWorkOrderKey; private String defectWorkOrderKey;
@Override
public R distributeAccessTask(OperAccessTaskEntity operAccessTaskEntity){
if(ObjectUtil.isEmpty(operAccessTaskEntity)){
return R.fail("暂无检修记录!");
}
OrderPackageDto orderPackageDto = new OrderPackageDto();
orderPackageDto.setCreater(AuthUtil.getUser().getUserName());
orderPackageDto.setFloatRange("1");
orderPackageDto.setProjectCost(0);
/*结束时间需大于当前时间*/
orderPackageDto.setFinishTime(DateUtil.format(LocalDateTime.now().plusHours(5),DateUtil.PATTERN_DATETIME));
orderPackageDto.setProjectCode(operAccessTaskEntity.getId().toString());
orderPackageDto.setProjectName(operAccessTaskEntity.getName());
Publisher publisher = new Publisher();
publisher.setId(operAccessTaskEntity.getCreateUser().toString());
User user = UserCache.getUser(operAccessTaskEntity.getCreateUser());
publisher.setContactAddress("123123");
publisher.setContactName("123123");
publisher.setContactPhone(user.getPhone());
publisher.setPublisher(user.getRealName());
publisher.setPublisherScale("123123");
orderPackageDto.setPublisher(publisher);
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
orderPackageDto.setStartTime(fmt.format(operAccessTaskEntity.getPlanStartTime()));
orderPackageDto.setWaterId(operAccessTaskEntity.getCreateDept().toString());
//完善招标信息
List<TenderDto> tenderList = new ArrayList<>();
TenderDto tenderDto = new TenderDto();
//采用大修工单
tenderDto.setOrderType("6");
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime planStartTime = LocalDateTime.ofInstant(operAccessTaskEntity.getPlanStartTime().toInstant(),zoneId);
LocalDateTime planEndTime = LocalDateTime.ofInstant(operAccessTaskEntity.getPlanEndTime().toInstant(),zoneId);
Long workHours = Duration.between(planStartTime,planEndTime).toHours();
tenderDto.setWorkHours(workHours.intValue());
tenderDto.setWorkPrice("0");
//大修工单内容
List<OtherOrderDTO> overhaulOrderList = new ArrayList<>();
OtherOrderDTO overHaulOrder = new OtherOrderDTO();
overHaulOrder.setOrderType("6");
overHaulOrder.setWorkCode(operAccessTaskEntity.getCode());
overHaulOrder.setTenantId(operAccessTaskEntity.getTenantId());
overHaulOrder.setWorkHour(workHours.intValue());
overHaulOrder.setWorkName(operAccessTaskEntity.getName());
EmInfoEntity emInfoEntity = emInfoClient.getByCode(operAccessTaskEntity.getEmCode());
overHaulOrder.setWorkPos(Optional.ofNullable(emInfoEntity).map(EmInfoEntity::getName).orElse(null));
overHaulOrder.setWorkTime(DateUtil.format(operAccessTaskEntity.getPlanStartTime(),DateUtil.PATTERN_DATETIME));
overhaulOrderList.add(overHaulOrder);
tenderDto.setOverhaulOrderList(overhaulOrderList);
tenderList.add(tenderDto);
orderPackageDto.setTenderList(tenderList);
log.info("-------------------------------------派发工单对象为-------------------------------------");
log.info(JSON.toJSONString(orderPackageDto));
HttpResponse httpResponse = HttpClientUtils.post(orderCrtPackageUrl, JSONObject.toJSONString(orderPackageDto));
if(httpResponse.getCode() == 200){
JSONObject jsonObject = JSONObject.parseObject(httpResponse.getData());
try{
String id = JSONObject.parseObject(jsonObject.getString("data")).getString("id");
//将工单处理结果暂存入redis中
// long maxSize = redisTemplate.opsForZSet().zCard(accessWorkOrderKey);
// redisTemplate.opsForZSet().add(accessWorkOrderKey,id, maxSize > 0 ? (maxSize - 1) : 0L);
}
catch (Exception e){
e.printStackTrace();
}
}
return R.data("调用成功!");
}
@Override
public R distributeDefectTask(OperDefectEntity operDefectEntity){
if(ObjectUtil.isEmpty(operDefectEntity)){
return R.fail("暂无消缺单记录!");
}
GrabPackageDTO grabPackageDTO = new GrabPackageDTO();
grabPackageDTO.setCreateUser(AuthUtil.getUser().getUserName());
grabPackageDTO.setFinishTime(DateUtil.format(LocalDateTime.now().plusHours(8),DateUtil.PATTERN_DATETIME));
List<RepairOrderAcptDto> repairOrderAcptDtos = new ArrayList<>();
RepairOrderAcptDto repairOrderAcptDto = new RepairOrderAcptDto();
//完善工单内容
if(StringUtil.isNotBlank(operDefectEntity.getDefectCode())){
//根据现象、缺陷编码获取现象
OperPhenomenonEntity operPhenomenonEntity = operPhenomenonService.getOne(new LambdaQueryWrapper<OperPhenomenonEntity>(){{
eq(OperPhenomenonEntity::getDefectCode,operDefectEntity.getDefectCode());
}}.last("limit 1"));
if(ObjectUtil.isNotEmpty(operPhenomenonEntity)){
if(StringUtil.isNotBlank(operPhenomenonEntity.getEmCode())){
repairOrderAcptDto.setEquCode(operPhenomenonEntity.getEmCode());
EmInfoEntity emInfoEntity = emInfoClient.getByCode(operPhenomenonEntity.getEmCode());
repairOrderAcptDto.setEquName(Optional.ofNullable(emInfoEntity).map(EmInfoEntity::getName).orElse(null));
}
if(StringUtil.isNotBlank(operPhenomenonEntity.getFaultCode())){
List<RepairOrderContentDTO> contentDTOList = new ArrayList<>();
RepairOrderContentDTO repairOrderContentDTO = new RepairOrderContentDTO();
repairOrderContentDTO.setFaultCode(operPhenomenonEntity.getFaultCode());
repairOrderContentDTO.setFaultName(operPhenomenonEntity.getFaultName());
contentDTOList.add(repairOrderContentDTO);
repairOrderAcptDto.setContentList(contentDTOList);
}
}
}
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = Optional.ofNullable(operDefectEntity.getActStartTime()).map(time->fmt.format(time)).orElse(null);
repairOrderAcptDto.setStartTime(startTime);
R<Dept> deptR = sysClient.getDept(operDefectEntity.getCreateDept());
repairOrderAcptDto.setEquType("010101");
repairOrderAcptDto.setOrgName("长沙敢胜院");
repairOrderAcptDto.setCreateUser(operDefectEntity.getCreateUser().toString());
repairOrderAcptDto.setTenantId(operDefectEntity.getTenantId());
repairOrderAcptDto.setWorkTime(DateUtil.format(operDefectEntity.getActStartTime(),DateUtil.PATTERN_DATETIME));
repairOrderAcptDto.setFaultDisp("捞渣、清渣装置故障");
repairOrderAcptDto.setInstallPos("粗格栅间");
repairOrderAcptDto.setIsBallot(0);
repairOrderAcptDto.setUserName(UserCache.getUser(operDefectEntity.getCreateUser()).getName());
repairOrderAcptDto.setIsMajorRepairs("一般维修");
repairOrderAcptDto.setRepairType("general_repair");
repairOrderAcptDto.setSeverity("严重");
repairOrderAcptDto.setSpecModel("GL1400");
repairOrderAcptDto.setTimeLimit("6.00");
repairOrderAcptDto.setWorkCode(operDefectEntity.getId().toString());
repairOrderAcptDto.setWorkPrice(0);
repairOrderAcptDto.setWorkRatio(1);
repairOrderAcptDto.setWorkHour(4);
List<RepairOrderPrognosisDTO> repairOrderPrognosisDTOS = new ArrayList<>();
RepairOrderPrognosisDTO repairOrderPrognosisDTO = new RepairOrderPrognosisDTO();
repairOrderPrognosisDTO.setCause("测试...");
repairOrderPrognosisDTO.setDescribeContent("测试...");
repairOrderPrognosisDTO.setProjectCode("test0000001");
repairOrderPrognosisDTO.setProjectContent("测试....");
repairOrderPrognosisDTO.setProjectName("测试...");
repairOrderPrognosisDTO.setWorkHour("4.00");
repairOrderPrognosisDTOS.add(repairOrderPrognosisDTO);
repairOrderAcptDto.setPrognosisList(repairOrderPrognosisDTOS);
repairOrderAcptDtos.add(repairOrderAcptDto);
grabPackageDTO.setRepairOrderAcptDtos(repairOrderAcptDtos);
log.info("-------------------------------------派发消缺单对象为-------------------------------------");
log.info(JSON.toJSONString(grabPackageDTO));
HttpResponse httpResponse = HttpClientUtils.post(orderCrtGrabPackageUrl, JSONObject.toJSONString(grabPackageDTO));
//将工单处理结果暂存入redis中
long maxSize = redisTemplate.opsForZSet().zCard(defectWorkOrderKey);
//redisTemplate.opsForZSet().add(defectWorkOrderKey,"", maxSize > 0 ? (maxSize - 1) : 0L);
return R.data("调用成功!");
}
@Override @Override
public R getAccessWorkOrderList(){ public R getAccessWorkOrderList(){

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

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

14
hzims-service/operational/src/main/resources/template/template.yml

@ -8,7 +8,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
@ -162,20 +162,10 @@ blade:
lock: lock:
enabled: true enabled: true
address: redis://${hzinfo.redis.ip}:${hzinfo.redis.hzinfo.redis.port} address: redis://${hzinfo.redis.ip}:${hzinfo.redis.hzinfo.redis.port}
password: password: ${hzims.sdk.password}
database: 0 database: 0
ssl: false ssl: false
logging: logging:
level: level:
com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient: NONE com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient: NONE
url:
video:
stationsPath: http://localhost:10001/stations
monitorsPath: http://localhost:10001/monitor
login: https://175.6.40.67:9300/hzApi/auth/mix/login?tenantId=200000&account=videoViewers&pwd=e10adc3949ba59abbe56e057f20f883e&grant_type=password&scope=all&type=account
water-out:
#工单受理
orderCrtPackage: http://175.6.40.67:9021/api/water-out/orderCrt/package
orderCrtGrabPackage: http://175.6.40.67:9021/api/water-out/orderCrt/grabPackage

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

@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity;
import com.hnac.hzims.safeproduct.dto.InnerDangerDTO; import com.hnac.hzims.safeproduct.dto.InnerDangerDTO;
import com.hnac.hzims.safeproduct.entity.InnerDangerEntity; import com.hnac.hzims.safeproduct.entity.InnerDangerEntity;
import com.hnac.hzims.safeproduct.flow.mapper.InnerDangerMapper; import com.hnac.hzims.safeproduct.flow.mapper.InnerDangerMapper;
@ -31,6 +33,7 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
@ -61,6 +64,8 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
@Autowired @Autowired
private IMessageClient messageClient; private IMessageClient messageClient;
@Autowired
private ICompensateProcessClient compensateProcessClient;
@ -73,7 +78,7 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
@Override @Override
public R startHiddenDanger(InnerDangerVo hiddenDangerVo) { public R startHiddenDanger(InnerDangerVo hiddenDangerVo) {
String saved = saveEntity(JSONObject.toJSONString(hiddenDangerVo)); String saved = saveEntity(JSONObject.toJSONString(hiddenDangerVo));
R r = this.startProcess(saved, HIDDEN_DANGER_CHECK); R r = this.startProcess(saved, HIDDEN_DANGER_CHECK,null);
return r; return r;
} }
@Override @Override
@ -104,6 +109,7 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
innerDangerEntity.setHiddenDangerDeptName(deptNameR.getData()); innerDangerEntity.setHiddenDangerDeptName(deptNameR.getData());
} }
} }
//只有一张表,不使用事务
boolean save = this.save(innerDangerEntity); boolean save = this.save(innerDangerEntity);
if (!save) { if (!save) {
throw new ServiceException("隐患保存失败,请稍后重试!"); throw new ServiceException("隐患保存失败,请稍后重试!");
@ -114,15 +120,6 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
@Override @Override
public R startProcess(String entity, String dictValue, String param) { public R startProcess(String entity, String dictValue, String param) {
return null;
}
@Override
public R compensationProcess(String id) {
return null;
}
public R startProcess(String entity, String dictValue) {
InnerDangerVo innerDangerVo= JSONObject.parseObject(entity, InnerDangerVo.class); InnerDangerVo innerDangerVo= JSONObject.parseObject(entity, InnerDangerVo.class);
InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
BeanUtil.copy(innerDangerVo, innerDangerEntity); BeanUtil.copy(innerDangerVo, innerDangerEntity);
@ -132,12 +129,14 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
String processName = "[" + userName + "] 发起 " + "【风险点:" + innerDangerVo.getRiskPointName() + "】隐患处理流程" + "——>" + innerDangerEntity.getHiddenDangerName(); String processName = "[" + userName + "] 发起 " + "【风险点:" + innerDangerVo.getRiskPointName() + "】隐患处理流程" + "——>" + innerDangerEntity.getHiddenDangerName();
// 开启新的隐患处理流程 // 开启新的隐患处理流程
Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(innerDangerVo, DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(innerDangerVo, DateUtil.PATTERN_DATETIME), Map.class);
R<BladeFlow> result = processClient.startProcessInstanceContainNameByKey(dictValue, innerDangerVo.getId().toString(), processName, variable); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue, FlowUtil.getBusinessKey("hzims_inner_danger_info", String.valueOf(innerDangerVo.getId())),
processName, variable);
// 流程开启失败 // 流程开启失败
if (!result.isSuccess()) { if (200!=result.getCode()) {
innerDangerEntity.setIsNormal(false); innerDangerEntity.setIsNormal(false);
innerDangerEntity.setRemark(JSONObject.toJSONString(variable)); innerDangerEntity.setRemark(JSONObject.toJSONString(variable));
this.baseMapper.updateById(innerDangerVo); this.baseMapper.updateById(innerDangerEntity);
log.error("隐患处理流程开启失败,错误描述 : {}", result); log.error("隐患处理流程开启失败,错误描述 : {}", result);
R r=new R(); R r=new R();
r.setCode(result.getCode()); r.setCode(result.getCode());
@ -146,19 +145,28 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
return r; return r;
} else { } else {
// 关联流程唯一键 // 关联流程唯一键
innerDangerEntity.setProcessInstanceId(result.getData().getProcessInstanceId()); innerDangerEntity.setProcessInstanceId(result.getData().toString());
innerDangerEntity.setTaskId(result.getData().getTaskId()); innerDangerEntity.setIsNormal(true);
this.baseMapper.updateById(innerDangerEntity); this.baseMapper.updateById(innerDangerEntity);
}
return R.success("启动流程成功"); return R.success("启动流程成功");
} }
}
@Override
public R compensationProcess(String id) {
InnerDangerEntity entity = this.baseMapper.selectById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), HIDDEN_DANGER_CHECK,entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
}
/** /**
* @param processWorkFlowResponse * @param processWorkFlowResponse
*/ */
@Override @Override
public R listenAndUpdateDefect(ProcessWorkFlowResponse processWorkFlowResponse) { public R listenAndUpdateDefect(ProcessWorkFlowResponse processWorkFlowResponse) {
InnerDangerVo hiddenDangerVo; InnerDangerVo hiddenDangerVo;
log.warn("隐患处理流程消息开始转换"); log.warn("隐患处理流程消息开始转换");
try { try {
@ -170,6 +178,9 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
log.error("隐患处理流程消息转换失败:" + e.getMessage()); log.error("隐患处理流程消息转换失败:" + e.getMessage());
return R.fail("隐患处理流程消息转换失败"); return R.fail("隐患处理流程消息转换失败");
} }
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
return handException(processWorkFlowResponse);
}
InnerDangerEntity saveEntity = this.getOne(new LambdaQueryWrapper<InnerDangerEntity>() {{ InnerDangerEntity saveEntity = this.getOne(new LambdaQueryWrapper<InnerDangerEntity>() {{
eq(InnerDangerEntity::getCode, hiddenDangerVo.getCode()); eq(InnerDangerEntity::getCode, hiddenDangerVo.getCode());
last("limit 1"); last("limit 1");
@ -193,6 +204,21 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
return R.success("消息保存成功"); return R.success("消息保存成功");
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
InnerDangerEntity innerDangerEntity = this.baseMapper.selectById(split[1]);
innerDangerEntity.setIsNormal(false);
innerDangerEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
innerDangerEntity.setCurrentOperator(processWorkFlowResponse.getTaskName());
innerDangerEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
innerDangerEntity.setCurrentLinkHandler("");
this.baseMapper.updateById(innerDangerEntity);
return R.fail("消息保存成功");
}
@Override @Override
public IPage<HiddenDangerBaseVo> getHiddenDangerBase(HiddenDangerBaseVo hiddenDangerBaseVo, Query query) { public IPage<HiddenDangerBaseVo> getHiddenDangerBase(HiddenDangerBaseVo hiddenDangerBaseVo, Query query) {
InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); InnerDangerEntity innerDangerEntity = new InnerDangerEntity();
@ -292,6 +318,7 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl<InnerDangerMapper, I
}else { }else {
iPage.setRecords(new ArrayList<>()); iPage.setRecords(new ArrayList<>());
} }
return iPage; return iPage;
} }

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

@ -3,6 +3,7 @@ package com.hnac.hzims.safeproduct.risk.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -216,6 +217,12 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) {
// 流程参数获取 // 流程参数获取
Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables(); Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
//流程找不到下一个审批人处理
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
handException(processWorkFlowResponse);
log.info("风险排查流程补偿流程处理完毕");
return false;
}
// 对象转换 // 对象转换
HazardRiskProcessDTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<HazardRiskProcessDTO>(){}); HazardRiskProcessDTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<HazardRiskProcessDTO>(){});
try{ try{
@ -238,11 +245,7 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
entity.setNextStepOperator("流程结束,无需人员处理"); entity.setNextStepOperator("流程结束,无需人员处理");
} }
entity.setIsNormal(true); entity.setIsNormal(true);
//流程找不到下一个审批人处理
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
}
// 更新风险排查任务信息 // 更新风险排查任务信息
this.updateById(entity); this.updateById(entity);
if(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY_1.equals(variables.get(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY)) || if(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY_1.equals(variables.get(HazardRiskConstants.HAZARD_RISK_NEW_PROPERTY)) ||
@ -259,7 +262,24 @@ public class HazardTaskServiceImpl extends ServiceImpl<HazardTaskMapper, HazardT
} }
return true; return true;
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("补偿流程处理失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("补偿流程处理失败");
}
HazardTask hazardTask = this.baseMapper.selectOne(new LambdaQueryWrapper<HazardTask>() {{
eq(HazardTask::getId, split[1]);
}});
hazardTask.setIsNormal(false);
hazardTask.setProcessInstanceId(processWorkFlowResponse.getTaskId());
hazardTask.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
hazardTask.setProcessSteps(processWorkFlowResponse.getTaskName());
hazardTask.setNextStepOperator("");
this.baseMapper.updateById(hazardTask);
log.info("补偿流程消息转换结束"+ processWorkFlowResponse);
return R.success("补偿流程消息保存成功");
}
/** /**
* 风险评估变量值流程穿插 * 风险评估变量值流程穿插
* @param processWorkFlowResponse * @param processWorkFlowResponse

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java

@ -1,6 +1,7 @@
package com.hnac.hzims.safeproduct.risk.service.impl; package com.hnac.hzims.safeproduct.risk.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -104,14 +105,14 @@ public class HazardWorkServiceImpl extends ServiceImpl<HazardWorkMapper, HazardW
Long headId = record.getHead(); Long headId = record.getHead();
if (headId != null) { if (headId != null) {
R<User> header = userClient.userInfoById(headId); R<User> header = userClient.userInfoById(headId);
if (header.isSuccess()) { if (header.isSuccess() && ObjectUtils.isNotEmpty(header.getData())) {
hazardWorkVO.setHeadName(header.getData().getRealName()); hazardWorkVO.setHeadName(header.getData().getRealName());
} }
} }
Long manageId = record.getManage(); Long manageId = record.getManage();
if (manageId != null) { if (manageId != null) {
R<User> manager = userClient.userInfoById(manageId); R<User> manager = userClient.userInfoById(manageId);
if (manager.isSuccess()) { if (manager.isSuccess() && ObjectUtils.isNotEmpty(manager.getData())) {
hazardWorkVO.setManagerName(manager.getData().getRealName()); hazardWorkVO.setManagerName(manager.getData().getRealName());
} }
} }

4
hzims-service/safeproduct/src/main/resources/template/template.yml

@ -14,11 +14,11 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
slave: slave:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

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

@ -2,13 +2,18 @@ package com.hnac.hzims.ticket.repair.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.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.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity;
import com.hnac.hzims.ticket.repair.constants.WorkTaskConstants; import com.hnac.hzims.ticket.repair.constants.WorkTaskConstants;
import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity;
import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper; import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper;
@ -42,6 +47,8 @@ import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -58,6 +65,8 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
private final IWorkTicketInfoService workTicketInfoService; private final IWorkTicketInfoService workTicketInfoService;
private final ICompensateProcessClient compensateProcessClient;
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ISysClient sysClient; private final ISysClient sysClient;
@ -86,7 +95,6 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
R r = this.startProcess(saved, "work_task",""); R r = this.startProcess(saved, "work_task","");
return r; return r;
} }
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class); WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class);
@ -116,19 +124,29 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){
workTask.setDeptName(result.getData().getDeptName()); workTask.setDeptName(result.getData().getDeptName());
} }
//保存步骤只涉及到一张表,不加事务
this.save(workTask); this.save(workTask);
return JSON.toJSONString(workTask); return JSON.toJSONString(workTask);
} }
@Override @Override
public R compensationProcess(String id) { public R compensationProcess(String id) {
return null; WorkTaskEntity entity = this.baseMapper.selectById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), "work_task",entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
@Override @Override
public R startProcess(String entity, String dictValue,String param) { public R startProcess(String entity, String dictValue,String param) {
WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class); WorkTaskVO workTask= JSONObject.parseObject(entity, WorkTaskVO.class);
Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); Map<String, Object> variables;
if (StringUtil.isNotBlank(param)) {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param, DateUtil.PATTERN_DATETIME), Map.class);
}else {
variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class);
}
variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead()))); variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead())));
// 班组成员 // 班组成员
String[] member = workTask.getMember().split(","); String[] member = workTask.getMember().split(",");
@ -139,13 +157,16 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
variables.put("duty" + i, TaskUtil.getTaskUser(member[i-1])); variables.put("duty" + i, TaskUtil.getTaskUser(member[i-1]));
} }
} }
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
dictValue,FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId()))
, workTask.getCode(), variables);
log.error("work_task_start_process_result :{}",result); log.error("work_task_start_process_result :{}",result);
// 更新任务流程Id // 更新任务流程Id
if (result.isSuccess()) { if (200==result.getCode()) {
BladeFlow flow = result.getData(); workTask.setIsNormal(true);
workTask.setProcessInstanceId(flow.getProcessInstanceId()); workTask.setProcessInstanceId(result.getData().toString());
this.updateById(workTask); this.updateById(workTask);
return R.success("启动流程成功");
} else { } else {
workTask.setIsNormal(false); workTask.setIsNormal(false);
workTask.setRemark(JSONObject.toJSONString(variables)); workTask.setRemark(JSONObject.toJSONString(variables));
@ -156,7 +177,6 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
r.setData(variables); r.setData(variables);
return r; return r;
} }
return R.success("启动流程成功");
} }
@ -168,6 +188,10 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
@Override @Override
public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) {
Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables(); Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables();
if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){
handException(processWorkFlowResponse);
return false;
}
log.error("work_task_listener_variables : {}",variables); log.error("work_task_listener_variables : {}",variables);
Object head = variables.get("head"); Object head = variables.get("head");
if(ObjectUtil.isNotEmpty(head)){ if(ObjectUtil.isNotEmpty(head)){
@ -176,6 +200,7 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
WorkTaskVO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<WorkTaskVO>(){}); WorkTaskVO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<WorkTaskVO>(){});
// 当前流程名称 // 当前流程名称
entity.setTaskName(processWorkFlowResponse.getTaskName()); entity.setTaskName(processWorkFlowResponse.getTaskName());
entity.setIsNormal(true);
// 流程阶段执行人员名称 // 流程阶段执行人员名称
entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator());
entity.setHeadHandleTime(new Date()); entity.setHeadHandleTime(new Date());
@ -198,6 +223,21 @@ public class WorkTaskServiceImpl extends ServiceImpl<WorkTaskMapper, WorkTaskEnt
return true; return true;
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
WorkTaskEntity workTaskEntity = this.baseMapper.selectById(split[1]);
workTaskEntity.setIsNormal(false);
workTaskEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
workTaskEntity.setTaskName(processWorkFlowResponse.getTaskName());
workTaskEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
workTaskEntity.setNextStepOperator("");
this.baseMapper.updateById(workTaskEntity);
return R.success("消息保存成功");
}
/** /**
* 工作任务单-分页查询 * 工作任务单-分页查询
* @param page * @param page

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

@ -4,12 +4,15 @@ import cn.afterturn.easypoi.word.WordExportUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.TicketConstants;
@ -36,9 +39,11 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
@ -47,7 +52,9 @@ import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -86,7 +93,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
private final ProcessDictFeignService processDictFeignService; private final ProcessDictFeignService processDictFeignService;
private final IFlowClient flowClient; private final ICompensateProcessClient compensateProcessClient;
private final IMessageClient messageClient; private final IMessageClient messageClient;
@ -117,6 +124,8 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
//启动流程 //启动流程
return this.startProcess(standardTicketInfoVoBySave, dictValue,""); return this.startProcess(standardTicketInfoVoBySave, dictValue,"");
} }
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class); StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
@ -153,7 +162,10 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");
} }
//多张表开启事务
standardTicketInfoVo.setCode(code); standardTicketInfoVo.setCode(code);
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
//3. 保存操作对象 //3. 保存操作对象
StandardTicketInfoEntity standardTicketInfo = getStandardTicketInfoEntity(standardTicketInfoVo); StandardTicketInfoEntity standardTicketInfo = getStandardTicketInfoEntity(standardTicketInfoVo);
standardTicketInfo.setStatus(1); standardTicketInfo.setStatus(1);
@ -167,6 +179,8 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos);
log.info("保存操作对象 :{}", standardTicketInfoVo); log.info("保存操作对象 :{}", standardTicketInfoVo);
return JSON.toJSONString(standardTicketInfoVo); return JSON.toJSONString(standardTicketInfoVo);
});
return res;
} }
@ -175,20 +189,23 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
public R startProcess(String entity, String dictValue,String param) { public R startProcess(String entity, String dictValue,String param) {
StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class); StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class);
StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo); StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo);
Instant start = Instant.now();
Map<String, Object> params = new HashMap<>(4); Map<String, Object> params = new HashMap<>(4);
params.put("standardTicketInfoVo", standardTicketInfoVo); params.put("standardTicketInfoVo", standardTicketInfoVo);
params.put("taskId", standardTicketInfoVo.getId()); params.put("taskId", standardTicketInfoVo.getId());
if (ObjectUtils.isNotEmpty(standardTicketInfoVo.getGuardian())) { if (ObjectUtils.isNotEmpty(standardTicketInfoVo.getGuardian())) {
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
} }
if (StringUtils.isNotBlank(param)){
params=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param, DateUtil.PATTERN_DATETIME), Map.class);
}
//已开启流程 //已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), R processInstanceContainNameByKey = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),
standardTicketInfoVo.getTitle(), params); dictValue, FlowUtil.getBusinessKey("hzims_standard_ticket_info",
if (!processInstanceContainNameByKey.isSuccess()) { String.valueOf(standardTicketInfoVo.getId())),standardTicketInfoVo.getTitle(), params);
if (200!=processInstanceContainNameByKey.getCode()) {
standardTicketInfoEntity.setIsNormal(false); standardTicketInfoEntity.setIsNormal(false);
standardTicketInfoEntity.setRemarkFlow(JSONObject.toJSONString(params)); standardTicketInfoEntity.setRemarkFlow(JSONObject.toJSONString(params));
standardTicketInfoService.save(standardTicketInfoEntity); standardTicketInfoService.updateById(standardTicketInfoEntity);
R r=new R(); R r=new R();
r.setCode(processInstanceContainNameByKey.getCode()); r.setCode(processInstanceContainNameByKey.getCode());
r.setMsg(processInstanceContainNameByKey.getMsg()); r.setMsg(processInstanceContainNameByKey.getMsg());
@ -196,17 +213,21 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg()); log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg());
return r; return r;
} }
Duration between = Duration.between(start, Instant.now()); standardTicketInfoEntity.setProcessInstanceId(processInstanceContainNameByKey.getData().toString());
log.info("================================================================"); standardTicketInfoEntity.setIsNormal(true);
log.info("耗时: " + (between.getSeconds()) + "秒"); standardTicketInfoService.updateById(standardTicketInfoEntity);
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
return R.success("启动流程成功"); return R.success("启动流程成功");
} }
@Override @Override
public R compensationProcess(String id) { public R compensationProcess(String id) {
return null; //查询流程对应value
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY);
StandardTicketInfoEntity entity = standardTicketInfoService.getById(id);
if (ObjectUtils.isNotEmpty(entity)){
return this.startProcess(JSON.toJSONString(entity), dictValue,entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
@ -227,6 +248,10 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
String formData = JSON.toJSONString(response.getVariables()); String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData); log.info("获取表单的数据:{}", formData);
StandardTicketInfoVo standardTicketInfoVo = null; StandardTicketInfoVo standardTicketInfoVo = null;
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
handException(response);
return ;
}
try { try {
JSONObject jsonObject = JSONObject.parseObject(formData); JSONObject jsonObject = JSONObject.parseObject(formData);
// standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class); // standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class);
@ -238,6 +263,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
e.printStackTrace(); e.printStackTrace();
throw new IllegalArgumentException(e.getMessage()); throw new IllegalArgumentException(e.getMessage());
} }
//1.查询操作票信息 //1.查询操作票信息
Long id = NumberUtils.toLong(response.getBusinessKey()); Long id = NumberUtils.toLong(response.getBusinessKey());
StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id); StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id);
@ -310,6 +336,27 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
} }
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
StandardTicketInfoEntity entity = standardTicketInfoService.getOne(new LambdaQueryWrapper<StandardTicketInfoEntity>() {{
eq(StandardTicketInfoEntity::getId, split[1]);
}});
entity.setIsNormal(false);
entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
entity.setTaskName(processWorkFlowResponse.getTaskName());
entity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
entity.setNextStepOperator("");
boolean flag = standardTicketInfoService.updateById(entity);
if (!flag){
log.info("异常状态消息保存失败"+ processWorkFlowResponse);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
/** /**
* 填充数据 * 填充数据

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

@ -3,13 +3,16 @@ package com.hnac.hzims.ticket.twoTicket.service.impl;
import cn.afterturn.easypoi.word.WordExportUtil; import cn.afterturn.easypoi.word.WordExportUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.flow.StartProcessService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient;
import com.hnac.hzims.operational.feign.IAccessTaskClient; import com.hnac.hzims.operational.feign.IAccessTaskClient;
@ -51,6 +54,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.message.MessageConstants; import org.springblade.message.MessageConstants;
import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.dto.BusinessMessageDTO;
import org.springblade.message.fegin.IMessageClient; import org.springblade.message.fegin.IMessageClient;
@ -60,7 +64,9 @@ import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
@ -140,6 +146,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
@Value("${hzims.ticket.path.word.templatePath}") @Value("${hzims.ticket.path.word.templatePath}")
private String templatePath; private String templatePath;
private final ICompensateProcessClient compensateProcessClient;
private final TicketInfoDangerService ticketInfoDangerService; private final TicketInfoDangerService ticketInfoDangerService;
@ -162,7 +169,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
*/ */
// @SneakyThrows // @SneakyThrows
@Override @Override
@Transactional // @Transactional
public R startUp(WorkTicketVo workTicketVo) { public R startUp(WorkTicketVo workTicketVo) {
log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); log.info("ticket:start:request",JSON.toJSONString(workTicketVo));
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法");
@ -179,7 +186,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
R r = this.startProcess(saveEntity, dictValue,""); R r = this.startProcess(saveEntity, dictValue,"");
return r; return r;
} }
private final PlatformTransactionManager transactionManager;
private final TransactionTemplate transactionTemplate;
@Override @Override
public String saveEntity(String entity) { public String saveEntity(String entity) {
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class);
@ -208,7 +216,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); throw new ServiceException("票据抬头未配置,请您到站点管理配置");
} }
//signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); //signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
workTicketVo.getWorkTicket().setSignage(station.getSignage()); workTicketVo.getWorkTicket().setSignage(station.getSignage());
workTicketVo.getWorkTicket().setSignageCode(station.getCode()); workTicketVo.getWorkTicket().setSignageCode(station.getCode());
//2. 获取编码 //2. 获取编码
@ -217,6 +224,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");
} }
transactionTemplate.setTransactionManager(transactionManager);
String res = transactionTemplate.execute(status -> {
workTicketVo.getWorkTicket().setCode(code); workTicketVo.getWorkTicket().setCode(code);
//保存工作对象 //保存工作对象
log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket()));
@ -231,6 +240,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
//保存工作任务 //保存工作任务
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket());
return JSONObject.toJSONString(workTicketVo); return JSONObject.toJSONString(workTicketVo);
});
return res;
} }
@ -245,7 +256,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) {
return R.success("线下流程,开票成功"); return R.success("线下流程,开票成功");
} }
Map<String, Object> params = new HashMap<>(4); Map<String, Object> params = new HashMap<>();
params.put("workTicketVo", workTicketVo); params.put("workTicketVo", workTicketVo);
//获取当前登录人 //获取当前登录人
Long userId = AuthUtil.getUserId(); Long userId = AuthUtil.getUserId();
@ -255,7 +266,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal());
} }
//已开启流程 //已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); R processInstanceContainNameByKey = compensateProcessClient.startFlow(
AuthUtil.getUserId().toString(),dictValue,
FlowUtil.getBusinessKey("hzims_work_ticket_info",String.valueOf(workTicketVo.getWorkTicket().getId())),
workTicketVo.getWorkTicket().getWorkContent(),params);
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess());
if (!processInstanceContainNameByKey.isSuccess()) { if (!processInstanceContainNameByKey.isSuccess()) {
//保存流程开始失败情况 //保存流程开始失败情况
@ -272,20 +286,24 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
r.setMsg("流程开启失败,请检查流程和用户权限后重试!"); r.setMsg("流程开启失败,请检查流程和用户权限后重试!");
r.setData(params); r.setData(params);
return r; return r;
} }else {
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); workTicket.setProcessInstanceId(processInstanceContainNameByKey.getData().toString());
Duration between = Duration.between(start, Instant.now()); workTicket.setIsNormal(true);
firstWorkTicketService.updateById(workTicket);
log.info("================================================================");
log.info("耗时: " + (between.getSeconds()) + "秒");
log.info("耗时: " + (between.toMillis()) + "毫秒");
log.info("================================================================");
return R.success("启动流程成功"); return R.success("启动流程成功");
} }
}
@Override @Override
public R compensationProcess(String id) { public R compensationProcess(String id) {
return null; WorkTicketInfoEntity entity = firstWorkTicketService.getById(id);
if (ObjectUtils.isNotEmpty(entity)){
WorkTicketVo workTicketVo = new WorkTicketVo();
workTicketVo.setWorkTicket(entity);
String dictValue = getDictValue(workTicketVo);
return this.startProcess(JSON.toJSONString(entity), dictValue,entity.getRemark());
}
return R.fail("找不到对应流程数据,请稍后重试!");
} }
/** /**
@ -321,7 +339,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void findPending(ProcessWorkFlowResponse response) { public void findPending(ProcessWorkFlowResponse response) {
try { try {
log.info("获取待处理的数据 {}", response); log.info("获取待处理的数据 {}", response);
log.info("获取businessKey: {}", response.getBusinessKey()); log.info("获取businessKey: {}", response.getBusinessKey());
@ -332,6 +349,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单 //json转换表单
String formData = JSON.toJSONString(response.getVariables()); String formData = JSON.toJSONString(response.getVariables());
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
handException(response);
return ;
}
log.info("获取表单的数据:{}", formData); log.info("获取表单的数据:{}", formData);
FristWorkTicketVo fristWorkFlowResponse = null; FristWorkTicketVo fristWorkFlowResponse = null;
try { try {
@ -343,6 +364,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
//获取表单数据 //获取表单数据
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo(); WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
workTicket.setIsNormal(true);
//2.流程处理 //2.流程处理
String businessKey = response.getBusinessKey(); String businessKey = response.getBusinessKey();
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
@ -503,10 +525,33 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("工作票流转失败,失败原因:{}",e);
} }
} }
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) {
String[] split = processWorkFlowResponse.getBusinessKey().split(":");
if (StringUtils.isBlank(split[1])){
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse);
return R.fail("异常消息处理失败");
}
WorkTicketInfoEntity workTicketInfoEntity = ticketInfoService.getOne(new LambdaQueryWrapper<WorkTicketInfoEntity>() {{
eq(WorkTicketInfoEntity::getId, split[1]);
}});
workTicketInfoEntity.setIsNormal(false);
workTicketInfoEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables()));
workTicketInfoEntity.setTaskName(processWorkFlowResponse.getTaskName());
workTicketInfoEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId());
workTicketInfoEntity.setNextStepOperator("");
boolean flag = ticketInfoService.updateById(workTicketInfoEntity);
if (!flag){
log.info("异常状态消息保存失败"+ processWorkFlowResponse);
return R.success("消息保存失败");
}
return R.fail("消息保存成功");
}
@Override @Override
public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) { public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) {
log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response)); log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response));
@ -515,6 +560,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc
log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables())); log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables()));
throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员"); throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员");
}); });
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){
handException(response);
return false;
}
WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo(); WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId()); WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId());

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

@ -2,11 +2,15 @@ ALTER TABLE `hzims_standard_ticket_info`
ADD COLUMN `remark_flow` text NULL ; ADD COLUMN `remark_flow` text NULL ;
ALTER TABLE `hzims_work_ticket_info` ALTER TABLE `hzims_work_ticket_info`
ADD COLUMN `remark` text NULL ; ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_work_task`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_standard_ticket_info` ALTER TABLE `hzims_standard_ticket_info`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_work_ticket_info` ALTER TABLE `hzims_work_ticket_info`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_work_task`
ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ;
ALTER TABLE `hzims_standard_ticket_info` ALTER TABLE `hzims_standard_ticket_info`
ADD COLUMN `em_code` varchar(255) NULL COMMENT '设备编号' , ADD COLUMN `em_code` varchar(255) NULL COMMENT '设备编号' ,

2
hzims-service/ticket/src/main/resources/template/template.yml

@ -8,7 +8,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

2
hzims-service/weather/src/main/resources/template/template.yml

@ -8,7 +8,7 @@ spring:
autoconfigure: autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource: datasource:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/test_hzims_weather?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_weather?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}

Loading…
Cancel
Save