From 914318cd633ded0a2e95acd20ea0b5697e30bea4 Mon Sep 17 00:00:00 2001 From: luyie Date: Sat, 7 Sep 2024 12:33:26 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=9C=88=E5=88=86=E6=9E=90=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=96=B0=EF=BC=8C=E5=90=91?= =?UTF-8?q?=E9=87=8F=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81=E5=A4=9Aid?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/report/entity/RunMonthEntity.java | 3 ++ .../controller/VectorParamController.java | 7 ++-- .../maintenance/service/VectorParamService.java | 2 +- .../service/impl/VectorParamServiceImpl.java | 42 ++++++++++++---------- .../maintenance/vo/VectorSynchronizeRequest.java | 15 ++++++++ .../report/controller/RunMonthController.java | 2 +- .../report/service/RunMonthService.java | 8 +++-- .../report/service/impl/RunMonthServiceImpl.java | 29 +++++++++++++-- .../operational/report/vo/RunMonthEvaluateVO.java | 4 ++- .../operational/src/main/resources/db/3.0.3.sql | 4 +++ 10 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorSynchronizeRequest.java create mode 100644 hzims-service/operational/src/main/resources/db/3.0.3.sql diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java index d646833..bdbf463 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java @@ -47,4 +47,7 @@ public class RunMonthEntity extends TenantEntity { @ApiModelProperty("评价") private String evaluation; + @ApiModelProperty("重新判定的结论") + private String conclusion; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java index 0f72ac5..a5db614 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService; +import com.hnac.hzims.bigmodel.maintenance.vo.VectorSynchronizeRequest; import com.hnac.hzinfo.api.annotation.ApiInterface; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -107,11 +108,11 @@ public class VectorParamController { return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); } - @PutMapping("/synchronization/{id}") + @PutMapping("/synchronization/") @ApiOperation(value = "同步") @ApiOperationSupport(order = 10) public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, - @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @PathVariable Long id) throws JsonProcessingException { - return R.status(vectorParamService.synchronization(id, bladeToken, hzinfoToken)); + @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @RequestBody VectorSynchronizeRequest req) throws JsonProcessingException { + return R.status(vectorParamService.synchronization(req.getIds(), bladeToken, hzinfoToken)); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java index bc22e15..56f8269 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java @@ -18,5 +18,5 @@ public interface VectorParamService extends IService { List getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken); - Boolean synchronization(Long id ,String bladeToken, String hzinfoToken); + Boolean synchronization(List id ,String bladeToken, String hzinfoToken); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java index 03c19fb..9a9af62 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java @@ -49,6 +49,7 @@ public class VectorParamServiceImpl extends ServiceImpl ids, String bladeToken, String hzinfoToken) { + if (null == ids && ids.isEmpty()) { return false; } - VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); - if (response != null) { - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootNode = null; - try { - rootNode = mapper.readTree(entity.getAttributeMap()); - } catch (JsonProcessingException e) { - e.printStackTrace(); + for (Long id : ids) { + VectorParamEntity entity = getById(id); + if (null == entity) { + return false; } - Map attrMap = new HashMap<>(); - Iterator iterator = rootNode.fieldNames(); - while (iterator.hasNext()) { - String key = iterator.next(); - attrMap.put(key, rootNode.findValue(key).textValue()); + VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); + if (response != null) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode rootNode = null; + try { + rootNode = mapper.readTree(entity.getAttributeMap()); + } catch (JsonProcessingException e) { + log.error("getUrlResponseKeyList error", e); + } + Map attrMap = new HashMap<>(); + Iterator iterator = rootNode.fieldNames(); + while (iterator.hasNext()) { + String key = iterator.next(); + attrMap.put(key, rootNode.findValue(key).textValue()); + } + weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); + this.update(Wrappers.lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); } - weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); - this.update(Wrappers.lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); } return true; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorSynchronizeRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorSynchronizeRequest.java new file mode 100644 index 0000000..c3b0a54 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorSynchronizeRequest.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.bigmodel.maintenance.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/7 11:04 + */ +@Data +public class VectorSynchronizeRequest { + + private List ids; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java index 7e47281..784f4d7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java @@ -66,6 +66,6 @@ public class RunMonthController { @ApiOperation(value = "站点月报评价", notes = "站点月报评价") @ApiOperationSupport(order = 6) public R evaluate(@RequestBody RunMonthEvaluateVO req) { - return R.data(runMonthService.evaluate(req.getId(), req.getText())); + return R.data(runMonthService.evaluate(req)); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java index 600b3d4..c3177fe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.report.service; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.operational.report.entity.RunMonthEntity; +import com.hnac.hzims.operational.report.vo.RunMonthEvaluateVO; /** @@ -19,11 +20,12 @@ public interface RunMonthService extends IService { /** * 生成分析结果 - * @param month 月份 + * + * @param month 月份 * @param stationCode 站点编号 * @return 大模型调用结果 */ - Boolean generateAnalyseResult(String month,String stationCode); + Boolean generateAnalyseResult(String month, String stationCode); - Boolean evaluate(Long id, String text); + Boolean evaluate(RunMonthEvaluateVO req); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index a926c3e..7cbe87a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -38,6 +38,7 @@ import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; +import com.hnac.hzinfo.exception.HzServiceException; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; @@ -55,6 +56,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.*; import org.springframework.stereotype.Service; @@ -868,8 +870,31 @@ public class RunMonthServiceImpl extends ServiceImpllambdaUpdate().set(RunMonthEntity::getEvaluation, text).eq(RunMonthEntity::getId, id)); + public Boolean evaluate(RunMonthEvaluateVO req) { + RunMonthEntity entity = this.getById(req.getId()); + if (ObjectUtil.isEmpty(entity)) { + throw new HzServiceException("未查询到月报信息!"); + } + String conclusion = entity.getConclusion(); + Map conclusionMap = new HashMap<>(); + if (StringUtil.isNotBlank(conclusion)) { + conclusionMap = JsonUtil.toMap(conclusion); + } + String evaluation = entity.getEvaluation(); + Map evaluationMap = new HashMap<>(); + if (StringUtil.isNotBlank(evaluation)) { + evaluationMap = JsonUtil.toMap(evaluation); + } + if (StringUtil.isNotBlank(req.getContent())) { + conclusionMap.put(req.getType(), req.getContent()); + } + if (StringUtil.isNotBlank(req.getEvaluation())) { + evaluationMap.put(req.getType(), req.getEvaluation()); + } + return this.update(Wrappers.lambdaUpdate() + .set(RunMonthEntity::getConclusion, JsonUtil.toJson(conclusionMap)) + .set(RunMonthEntity::getEvaluation, JsonUtil.toJson(evaluationMap)) + .eq(RunMonthEntity::getId, req.getId())); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java index 3e50ceb..27e81cc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java @@ -8,6 +8,8 @@ import lombok.Data; */ @Data public class RunMonthEvaluateVO { - private String text; + private String content; private Long id; + private String evaluation; + private String type; } diff --git a/hzims-service/operational/src/main/resources/db/3.0.3.sql b/hzims-service/operational/src/main/resources/db/3.0.3.sql new file mode 100644 index 0000000..593be3b --- /dev/null +++ b/hzims-service/operational/src/main/resources/db/3.0.3.sql @@ -0,0 +1,4 @@ +--月报告增加评价字段 +ALTER TABLE `hzims_run_month_report` + ADD COLUMN `CONCLUSION` text NULL COMMENT '重新判定的结论' ; +ALTER TABLE `hzims_run_month_report` ADD COLUMN `EVALUATION` text NULL COMMENT '评价'; \ No newline at end of file