diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java index 7d7de77..d793fd8 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/service/UserAuthDataService.java @@ -1,9 +1,11 @@ package com.hnac.hzims.common.service; +import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.logs.utils.StringUtils; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; 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.feign.IUserClient; import org.springframework.http.HttpStatus; @@ -22,6 +24,9 @@ public class UserAuthDataService { * @return */ public String getUserAuthDataSQL(Long userId) { + if(CommonConstant.SYSTEM_USER.equals(userId)) { + return ""; + } R r = userClient.userInfoById(userId); String sqlScript = null; if(r.getCode() != HttpStatus.OK.value() || r.getData() == null) { diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java new file mode 100644 index 0000000..4cef0d1 --- /dev/null +++ b/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 { + + public abstract S convert(O obj); + + public List listVO(List list) { + return list.stream().map(this::convert).collect(Collectors.toList()); + } + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java index f146a12..429369b 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java +++ b/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("发电单位") private String unit = "万kWh"; + @ApiModelProperty("运行时长单位") + private String runtimeUnit = "h"; + } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java new file mode 100644 index 0000000..6c2b3ba --- /dev/null +++ b/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; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java index 889b04a..d2176e8 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java +++ b/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) private String itemId; - @ApiModelProperty(value = "站点名称",required = true) + @ApiModelProperty(value = "站点名称") @QueryField(condition = SqlCondition.LIKE) private String stationName; diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ObjectEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ObjectEntity.java index 4a7efdb..7ef2305 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ObjectEntity.java +++ b/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") - @Size(min=1,max = 128,message ="地理位置长度必须为1到128") + // @Size(min=1,max = 128,message ="地理位置长度必须为1到128") private String address; /** * 经度(东经) diff --git a/hzims-service/assets/src/main/resources/template/template.yml b/hzims-service/assets/src/main/resources/template/template.yml index 8aaa1ea..3a4fb6f 100644 --- a/hzims-service/assets/src/main/resources/template/template.yml +++ b/hzims-service/assets/src/main/resources/template/template.yml @@ -13,7 +13,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure 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} password: ${hzinfo.db.busines.password} #swagger扫描路径配置 diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java index 85b96b4..5c51965 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java +++ b/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())){ 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()); } /** diff --git a/hzims-service/equipment/src/main/resources/template/template.yml b/hzims-service/equipment/src/main/resources/template/template.yml index b99b6b0..959a4b4 100644 --- a/hzims-service/equipment/src/main/resources/template/template.yml +++ b/hzims-service/equipment/src/main/resources/template/template.yml @@ -12,23 +12,23 @@ spring: primary: master datasource: 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} @@ -89,9 +89,14 @@ blade: data: sdk: enabled: true - url: http://${hzims.sdk.ip}/api/hzinfo-data-config - appId: ${hzims.sdk.appId} - appSecret: ${hzims.sdk.appSecret} + url: "http://${hzims.sdk.ip}/api/hzinfo-data-config" + ctrlUrl: "http://${hzims.sdk.ip}/api/hzinfo-data-handler" + appId: "${hzims.sdk.appId}" + appSecret: "${hzims.sdk.appSecret}" + redisIp: "${hzinfo.redis.ip}" + redisPort: ${hzinfo.redis.port} + password: "${hzinfo.redis.password}" + maxKeys: 1000 data-scope: enabled: false diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java index 700ca5f..2d3090e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java @@ -2,6 +2,8 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.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.fdp.feign.IFdpDiagnoseClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -63,6 +66,9 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl() {{ + 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) { //推送消息 if (processWorkFlowResponse.getTaskId() != null) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 14f7b9f..769e53e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -159,9 +159,9 @@ public class AlarmHandleServiceImpl extends ServiceImploapi-java-sdk release-V4-2.0.2 + + io.weaviate + client + 4.7.0 + diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java index cf41b72..d0ac0d4 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java +++ b/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; +import com.alibaba.fastjson.JSON; import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.RestController; @@ -15,12 +17,14 @@ import java.util.List; */ @RestController @AllArgsConstructor +@Slf4j public class DataAnalyseClient implements IDataAnalyseClient { private final IHznlmInvokeService invokeService; @Override public R smartReportGeneratePower(RunReportAnalyseRequest req) { + log.info("获取运行月报告传参详情为:{}", JSON.toJSONString(req)); invokeService.smartReportGeneratePower(req); return R.success("发起问答成功"); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java similarity index 94% rename from hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java rename to hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java index 4efcf3b..47e7cc5 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java +++ b/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.hnac.hzims.bigmodel.business.service.DataSourceService; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java similarity index 83% rename from hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java rename to hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java index 3b4422c..ac0c0b3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java +++ b/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.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.business.service.RemoteService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -9,6 +8,7 @@ import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -27,7 +27,7 @@ public class RemoteController { @ApiOperation("下发遥控指令") @ApiOperationSupport(order = 1) @PostMapping("/sendRemoteControl") - public R sendRemoteControl(ControlDTO controlDTO) { + public R sendRemoteControl(@RequestBody ControlDTO controlDTO) { return remoteService.sendRemoteControl(controlDTO); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java index 23613a2..ac1c3c8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java +++ b/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,"查询语句中存在未进行鉴权的表,查询失败!"); }); 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.replaceAll(">", ">").replaceAll("<", "<"); log.info("执行sql:{}",sql); return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java new file mode 100644 index 0000000..306e13d --- /dev/null +++ b/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 { + + @Override + public CanvasSyncDTO convert(CanvasVO obj) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java index c11b4b6..b6b842a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java +++ b/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 compute; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java new file mode 100644 index 0000000..6bd2f14 --- /dev/null +++ b/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(); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java new file mode 100644 index 0000000..468bae9 --- /dev/null +++ b/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; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java new file mode 100644 index 0000000..cbc926b --- /dev/null +++ b/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 attrs) { + ObjectCreator creator = objectCreator.withClassName(className); + if(Func.isNotEmpty(attrs)) { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity)); + List vectors = attrs.stream().map(attr -> jsonObject.getString(attr)).collect(Collectors.toList()); + Float[] compute = this.compute(vectors); + creator.withVector(compute); + } + Result 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 attrsMap) { + ObjectCreator creator = objectCreator.withClassName(className); + List vectorStrs = Lists.newArrayList(); + List attrs = Lists.newArrayList(); + if(Func.isNotEmpty(attrsMap)) { + // 格式化数据 + attrsMap.forEach((k,v) -> attrs.add(v)); + // 解析待计算的向量字段 + entities.forEach(entity -> { + List 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> 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 result = objectDeleter.withClassName(className).run(); + return !result.hasErrors(); + } + + /** + * 删除向量数据库(ID) + * @param id 向量数据库ID + * @return 删除结果 + */ + public Boolean deleteById(String id) { + Result result = objectDeleter.withID(id).run(); + return !result.hasErrors(); + } + + /** + * 更新数据库(通过ID) + * @param id 向量数据库ID + * @return 更新结果 + */ + public Boolean updateById(String id, Object entity, String className, Map attrMap) { + ObjectUpdater updater = objectUpdater.withClassName(className).withID(id).withProperties(BeanUtil.toMap(entity)); + // 计算向量 + Map 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 result = updater.run(); + return !result.hasErrors(); + } + + public List list(String id,String className) { + if(Func.isNotEmpty(id)) { + objectsGetter.withID(id); + } + if(Func.isNotEmpty(className)) { + objectsGetter.withClassName(className); + } + Result> 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> splitVector(Integer entitySize,Map attrsMap,Float[] vectorTotal) { + List> result = Lists.newArrayList(); + List vectorTotalList = Lists.newArrayList(vectorTotal); + // 获取待切割的下标 + List indexes = this.getSplitIndex(vectorTotal.length, entitySize); + int step = vectorTotal.length / entitySize; + indexes.forEach(index -> { + List vectors = vectorTotalList.subList(index, index + step); + Map vectorMap = new HashMap<>(); + List splitIndex = this.getSplitIndex(vectors.size(), attrsMap.size()); + AtomicInteger i = new AtomicInteger(); + attrsMap.forEach((k,v) -> { + List 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 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 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 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 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()]); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java new file mode 100644 index 0000000..1c056ce --- /dev/null +++ b/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 { + + + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java index 21b05f4..b7cab25 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java +++ b/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) @GetMapping("/interruptSession") public R interruptSession(@RequestParam(value = "id") String sessionId) { - hznlmInvokeService.askAbort(sessionId); + hznlmInvokeService.interruptSession(sessionId); return R.success("操作成功!"); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java index 51ed3f3..2ef2107 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java +++ b/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 interruptSession(String sessionId); + /** * 发起机组发电量智能报表分析问答 * @param req 待分析的数据 diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index b8bdb15..48e9881 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/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.sessionManager.InteractiveSessionManager; import com.hnac.hzims.common.constant.CommonConstant; +import com.hnac.hzinfo.exception.HzServiceException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; @@ -126,6 +127,33 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { 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 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 public void smartReportGeneratePower(RunReportAnalyseRequest req) { Map params = new HashMap<>(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java new file mode 100644 index 0000000..c800041 --- /dev/null +++ b/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; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java index 91f04fb..b8d4fc3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java +++ b/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; public List> 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); } public List> 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); } public List> 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); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java index c6f5d74..02f55cb 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java +++ b/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, "未知的识别类型"), NO_COMPARATOR(1888000008, "未获取到对比对象"), NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"), - GET_RESULT_FAIL(1888000010, "获取结果失败"),; + GET_RESULT_FAIL(1888000010, "获取结果失败"), + NO_ANSWER_FROM_PLATFORM(1888000011, "未从平台获取到答案"); private final int code; private final String msg; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java index e85b8b5..2f82a7e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java +++ b/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; +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.extern.slf4j.Slf4j; /** * @Author: ypj * @Date: 2024/8/14 8:28 */ @Getter +@Slf4j public enum ResultDataType implements BaseEnum { - OBJECT("Object", "Object类型", Object.class.getName(), null), - STRING("String", "String类型", String.class.getName(), null), - BOOLEAN("Boolean","Boolean类型",Boolean.class.getName(),"parseBoolean"), - INTEGER("Integer","Integer类型",Integer.class.getName(),"parseInt"); + STRING("String", "String类型", StringParser.class), + BOOLEAN("Boolean", "Boolean类型", BooleanParser.class), + INTEGER("Integer", "Integer类型", IntegerParser.class); private final String code; private final String msg; - private final String className; + private final Class parser; - private final String method; - - ResultDataType(String code, String msg, String className, String method) { + ResultDataType(String code, String msg, Class parser) { this.code = code; this.msg = msg; - this.className = className; - this.method = method; + this.parser = parser; } + public ResultDataParser getParser() { + try { + return parser.newInstance(); + } catch (Exception e) { + log.error("get result data parse fail", e); + } + return null; + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java index 8532bb9..9f04f2f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java +++ b/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; -import com.hnac.hzims.bigmodel.zhipuai.handler.ResultBooleanStrategy; -import com.hnac.hzims.bigmodel.zhipuai.handler.ResultCommonStrategy; -import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultBooleanStrategy; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultCommonStrategy; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; import lombok.Getter; import lombok.extern.slf4j.Slf4j; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index 6e98f7b..36ad46c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/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); log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); Assert.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 { String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java similarity index 93% rename from hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java rename to hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java index 477c3a8..3b7e000 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java +++ b/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.ComparisonType; import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; import org.springframework.util.Assert; import java.util.Objects; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java similarity index 79% rename from hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java rename to hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java index b1c21fe..e506065 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java +++ b/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.entity.ZhipuAnalysisInfoEntity; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; /** * @Author: ypj @@ -13,7 +14,6 @@ public class ResultCommonStrategy implements ResultStrategy { return ResultStrategyType.COMMON.getCode(); } - @Override public Object getResult(ZhipuAnalysisInfoEntity info, Object data) { return data; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java similarity index 56% rename from hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java rename to hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java index b86adea..90c6bbf 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java +++ b/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.ResultDataType; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springblade.core.tool.utils.StringUtil; +import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.ResultDataParser; -import java.lang.reflect.Method; +import java.util.Optional; /** * @Author: ypj @@ -23,15 +21,9 @@ public interface ResultStrategy { default Object convertOriginalData(String originalData, String className) { ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class); - if (null != type && StringUtil.isNotBlank(type.getMethod())) { - try { - Class clazz = Class.forName(type.getClassName()); - 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); - } + if (null != type) { + ResultDataParser parser = type.getParser(); + return Optional.ofNullable(parser).map(p -> p.parse(originalData)).orElse(originalData); } return originalData; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java new file mode 100644 index 0000000..1af115a --- /dev/null +++ b/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 { + @Override + public Boolean parse(String originalData) { + return Boolean.parseBoolean(originalData); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java new file mode 100644 index 0000000..cc0cfe5 --- /dev/null +++ b/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 { + @Override + public Integer parse(String originalData) { + return Integer.parseInt(originalData); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java new file mode 100644 index 0000000..854e7e0 --- /dev/null +++ b/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 parse(String originalData); +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java new file mode 100644 index 0000000..a9218e1 --- /dev/null +++ b/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 { + @Override + public String parse(String originalData) { + return originalData; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java index 0afde6f..956f6f2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ b/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.ResultStrategyType; 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.ZhipuAnalysisFactory; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; diff --git a/hzims-service/hzims-big-model/src/main/resources/template/template.yml b/hzims-service/hzims-big-model/src/main/resources/template/template.yml index 77287f6..25ca6f6 100644 --- a/hzims-service/hzims-big-model/src/main/resources/template/template.yml +++ b/hzims-service/hzims-big-model/src/main/resources/template/template.yml @@ -11,31 +11,31 @@ spring: primary: master datasource: 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} information: @@ -49,6 +49,7 @@ spring: gglm: url: "http://${gglm.host}:${gglm.port}" + vectorUrl: "http://${vector.host}:${vector.port}" api: assistantAsk: "/qa/assistant_ask" assistantStatus: "/qa/assistant_status" @@ -62,6 +63,7 @@ gglm: smartReportGeneratePower: "/custom/smart_report_generate_power" assistantAnalyseAsk: "/qa/assistant_analyse_ask" updateKnowledge: "/kn/update_knowledge" + compute: "compute" swagger: base-packages: com.hnac.hzims.bigmodel diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java index ef665b1..e3ce896 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java @@ -49,8 +49,8 @@ public class StandardWorkTicketConsumer implements IQueueConsume { throw new ServiceException("消息转换失败,消息内容为:" + message); }); if (ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ - ticketServiceList.get(0).pushFailMessage(Long.valueOf(response.getTaskId()),response.getBusinessKey(), - response.getUserId(), response.getTaskName(),response.getResult(),response.getDeptId()); + ticketServiceList.get(0).pushFailMessage(response.getBusinessKey(),response.getProcessDefinitionKey(), + response.getTaskName(),response.getResult(),response.getDeptId()); } // 保存日志 WorkflowOperationLog log = BeanUtil.copy(response, WorkflowOperationLog.class); diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java index 704276e..014dd12 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/feign/CompensateProcessClient.java @@ -33,9 +33,9 @@ public class CompensateProcessClient implements ICompensateProcessClient { @PostMapping("/startFlow") public R startFlow(@RequestParam("userId") String userId, @RequestParam("dictValue")String dictValue, - @RequestParam("taskId")String taskId, + @RequestParam("businessKey")String businessKey, @RequestParam("processName")String processName, @RequestBody Map variables) { - return processService.startFlow(userId,dictValue,taskId,processName,variables); + return processService.startFlow(userId,dictValue,businessKey,processName,variables); } } \ No newline at end of file diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java index 9952839..b7014fb 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java @@ -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.strategy.service.ProcessService; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.message.MessageConstants; -import org.springblade.message.dto.BusinessMessageDTO; +import org.springblade.message.dto.BusinessMessageFlowDTO; import org.springblade.message.fegin.IMessageClient; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; @@ -43,11 +44,11 @@ public abstract class ProcessAbstractService implements ProcessService { private ProcessDictService processDictService; @Override - public R startFlow(String userId, String dictValue, String taskId, String processName, Map variables) { + public R startFlow(String userId, String dictValue, String businessKey, String processName, Map variables) { log.info("开启流程....."); R r = new R(); try { - R result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables); + R result = flowClient.startProcessInstanceContainNameByKey(dictValue, businessKey, processName, variables); r.setSuccess(result.isSuccess()); r.setCode(result.getCode()); r.setMsg(result.getMsg()); @@ -60,7 +61,7 @@ public abstract class ProcessAbstractService implements ProcessService { log.error("开启流程失败:{}",result); log.error("流程信息为{}",variables); r.setData(variables); - pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg()); + pushStartFailMessage(dictValue,businessKey,userId,processName,result.getMsg()); } return r; }catch (Exception e){ @@ -85,11 +86,11 @@ public abstract class ProcessAbstractService implements ProcessService { // 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); - BusinessMessageDTO message = new BusinessMessageDTO(); + BusinessMessageFlowDTO message = new BusinessMessageFlowDTO(); // 计划Id - message.setTaskId(taskId); + message.setTaskId(businessKey); message.setBusinessClassify(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.setUserIds(userId); - messageClient.sendAppAndWsMsgByUsers(message); + messageClient.sendAppAndWsMsgByUsersFlow(message); } @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); - BusinessMessageDTO message = new BusinessMessageDTO(); + BusinessMessageFlowDTO message = new BusinessMessageFlowDTO(); +// BusinessMessageDTO message = new BusinessMessageDTO(); // 计划Id - message.setTaskId(taskId); + message.setTaskId(businessKey); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); // 主题 message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription()); // 内容 - String res= StringUtil.format("你有一个{}的{}流程流转失败,失败原因为:{}",content, + String res= StringUtil.format("你有一个流程环节为{}的{}流转失败,失败原因为:{}",content, processDict.getDictLabel(), reason); message.setContent(res); message.setTenantId("200000"); - R> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER); + R> userListR = userClient.queryUserByRoleAlias("200000", Long.valueOf(deptId), PROJECT_MANAGER); User admin = userClient.userByAccount("200000", "admin").getData(); - User createUser = userClient.userInfoById(Long.valueOf(userId)).getData(); - message.setDeptId(createUser.getCreateDept()); - R result = sysClient.getDeptName(createUser.getCreateDept()); + message.setDeptId(Long.valueOf(deptId)); + R result = sysClient.getDeptName(Long.valueOf(deptId)); if (result.isSuccess()) { message.setDeptName(result.getData()); } - List data = userListR.getData(); - String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + if (CollectionUtil.isNotEmpty(userListR.getData())){ + List data = userListR.getData(); + String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + message.setUserIds(userIds); + }else { + R> listR = userClient.queryUserByRoleAlias("200000", Long.valueOf(20000001), PROJECT_MANAGER); + if (ObjectUtil.isEmpty(listR)||CollectionUtil.isEmpty(listR.getData())){ + return; + } + List data =listR.getData(); + String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + message.setUserIds(userIds); + } message.setCreateUser(admin.getId()); - message.setUserIds(userIds); - messageClient.sendAppAndWsMsgByUsers(message); + messageClient.sendAppAndWsMsgByUsersFlow(message); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java index 7869a16..68ab7f0 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java @@ -14,9 +14,9 @@ import java.util.Map; */ public interface ProcessService { - R startFlow(String userId, String dictValue, String taskId, String processName, Map variables) ; + R startFlow(String userId, String dictValue, String businessKey, String processName, Map 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 diff --git a/hzims-service/hzims-middle/src/main/resources/template/template.yml b/hzims-service/hzims-middle/src/main/resources/template/template.yml index 1746921..36a8370 100644 --- a/hzims-service/hzims-middle/src/main/resources/template/template.yml +++ b/hzims-service/hzims-middle/src/main/resources/template/template.yml @@ -8,7 +8,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure 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} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/hzims-scheduled/src/main/resources/template/template.yml b/hzims-service/hzims-scheduled/src/main/resources/template/template.yml index cf19301..fc8cd35 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/template/template.yml +++ b/hzims-service/hzims-scheduled/src/main/resources/template/template.yml @@ -14,31 +14,31 @@ spring: primary: master datasource: 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} 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} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml index 6136502..8220245 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectTemplateMapper.xml @@ -3,7 +3,7 @@