Browse Source

add:月分析评价接口更新,向量配置支持多id同步

zhongwei
luyie 3 months ago
parent
commit
914318cd63
  1. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java
  2. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java
  3. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java
  4. 42
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  5. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorSynchronizeRequest.java
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  7. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  8. 29
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  9. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java
  10. 4
      hzims-service/operational/src/main/resources/db/3.0.3.sql

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

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

2
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<VectorParamEntity> {
List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken);
Boolean synchronization(Long id ,String bladeToken, String hzinfoToken);
Boolean synchronization(List<Long> id ,String bladeToken, String hzinfoToken);
}

42
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<VectorParamMapper, Vecto
.header("Hzinfo-Auth", hzinfoToken).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
String body = response.body();
log.info("vector url response url:{}, response:{}", url, body);
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(body);
@ -108,28 +109,33 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
}
@Override
public Boolean synchronization(Long id, String bladeToken, String hzinfoToken) {
VectorParamEntity entity = getById(id);
if (null == entity) {
public Boolean synchronization(List<Long> 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<String, String> attrMap = new HashMap<>();
Iterator<String> 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<String, String> attrMap = new HashMap<>();
Iterator<String> 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.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()));
}
weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap);
this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()));
}
return true;
}

15
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<Long> ids;
}

2
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));
}
}

8
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<RunMonthEntity> {
/**
* 生成分析结果
* @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);
}

29
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 ServiceImpl<RunMonthMapper, RunMonthEnt
}
@Override
public Boolean evaluate(Long id, String text) {
return this.update(Wrappers.<RunMonthEntity>lambdaUpdate().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<String, Object> conclusionMap = new HashMap<>();
if (StringUtil.isNotBlank(conclusion)) {
conclusionMap = JsonUtil.toMap(conclusion);
}
String evaluation = entity.getEvaluation();
Map<String, Object> 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.<RunMonthEntity>lambdaUpdate()
.set(RunMonthEntity::getConclusion, JsonUtil.toJson(conclusionMap))
.set(RunMonthEntity::getEvaluation, JsonUtil.toJson(evaluationMap))
.eq(RunMonthEntity::getId, req.getId()));
}
/**

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

4
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 '评价';
Loading…
Cancel
Save