Browse Source

add:向量配置,月报评价

zhongwei
luyie 3 months ago
parent
commit
fe5855cbab
  1. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java
  2. 6
      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. 149
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  5. 85
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  7. 482
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  8. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java

@ -44,4 +44,7 @@ public class RunMonthEntity extends TenantEntity {
@ApiModelProperty("分析结果") @ApiModelProperty("分析结果")
private String analyseResult; private String analyseResult;
@ApiModelProperty("评价")
private String evaluation;
} }

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

@ -107,11 +107,11 @@ public class VectorParamController {
return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken));
} }
@PutMapping("/synchronization") @PutMapping("/synchronization/{id}")
@ApiOperation(value = "同步") @ApiOperation(value = "同步")
@ApiOperationSupport(order = 10) @ApiOperationSupport(order = 10)
public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, 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) throws JsonProcessingException { @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @PathVariable Long id) throws JsonProcessingException {
return R.status(vectorParamService.synchronization(bladeToken, hzinfoToken)); return R.status(vectorParamService.synchronization(id, 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); List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken);
Boolean synchronization(String bladeToken, String hzinfoToken); Boolean synchronization(Long id ,String bladeToken, String hzinfoToken);
} }

149
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -16,7 +17,6 @@ import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import com.hnac.hzims.bigmodel.maintenance.vo.VectorUrlResponse; import com.hnac.hzims.bigmodel.maintenance.vo.VectorUrlResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -49,59 +49,57 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
.header("Hzinfo-Auth", hzinfoToken).execute(); .header("Hzinfo-Auth", hzinfoToken).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) { if (response.getStatus() == HttpServletResponse.SC_OK) {
String body = response.body(); String body = response.body();
log.info("getUrlResponse:" + body); try {
JSONObject jsonObject = JSON.parseObject(body); ObjectMapper mapper = new ObjectMapper();
VectorUrlResponse result = new VectorUrlResponse(); JsonNode rootNode = mapper.readTree(body);
result.setOriginalData(JSONArray.parseArray(jsonObject.getString("data")).toJavaList(JSONObject.class)); if (rootNode.isArray()) {
// try { return getUrlResponseByArray(rootNode);
// ObjectMapper mapper = new ObjectMapper(); }
// JsonNode rootNode = mapper.readTree(body); JsonNode dataNode = rootNode.findValue("data");
// if (rootNode.isArray()) { if (dataNode != null && dataNode.isArray()) {
// return getUrlResponseByArray(rootNode); return getUrlResponseByArray(dataNode);
// } }
// JsonNode dataNode = rootNode.findValue("data"); if (dataNode != null) {
// if (dataNode != null && dataNode.isArray()) { return getUrlResponseByObject(dataNode);
// return getUrlResponseByArray(dataNode); }
// } if (rootNode != null) {
// if (dataNode != null) { return getUrlResponseByObject(rootNode);
// return getUrlResponseByObject(dataNode); }
// } } catch (JsonProcessingException e) {
// if (rootNode != null) { log.error("getUrlResponse error", e);
// return getUrlResponseByObject(rootNode); }
// }
// } catch (JsonProcessingException e) {
// log.error("getUrlResponse error", e);
// }
} }
return null; return null;
} }
// private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException { private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException {
// VectorUrlResponse result = new VectorUrlResponse(); VectorUrlResponse result = new VectorUrlResponse();
// result.setOriginalData(rootNode); result.setOriginalData(JSONArray.parseArray(rootNode.toPrettyString()).toJavaList(JSONObject.class));
// JsonNode item = rootNode.get(0); JsonNode item = rootNode.get(0);
// if (item != null) { if (item != null) {
// List<String> keyList = new ArrayList<>(); List<String> keyList = new ArrayList<>();
// Iterator<String> iterator = item.fieldNames(); Iterator<String> iterator = item.fieldNames();
// while (iterator.hasNext()) { while (iterator.hasNext()) {
// keyList.add(iterator.next()); keyList.add(iterator.next());
// } }
// result.setKeyList(keyList); result.setKeyList(keyList);
// } }
// return result; return result;
// } }
// private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException { private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException {
// VectorUrlResponse result = new VectorUrlResponse(); VectorUrlResponse result = new VectorUrlResponse();
// result.setOriginalData(rootNode); List<JSONObject> originalData = new ArrayList<>();
// List<String> keyList = new ArrayList<>(); originalData.add(JSON.parseObject(rootNode.toPrettyString()));
// Iterator<String> iterator = rootNode.fieldNames(); result.setOriginalData(originalData);
// while (iterator.hasNext()) { List<String> keyList = new ArrayList<>();
// keyList.add(iterator.next()); Iterator<String> iterator = rootNode.fieldNames();
// } while (iterator.hasNext()) {
// result.setKeyList(keyList); keyList.add(iterator.next());
// return result; }
// } result.setKeyList(keyList);
return result;
}
@Override @Override
public List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) { public List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) {
@ -110,45 +108,30 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
} }
@Override @Override
public Boolean synchronization(String bladeToken, String hzinfoToken) { public Boolean synchronization(Long id, String bladeToken, String hzinfoToken) {
List<VectorParamEntity> list = this.list(); VectorParamEntity entity = getById(id);
if (CollectionUtil.isEmpty(list)) { if (null == entity) {
return false; return false;
} }
for (VectorParamEntity entity : list) { VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken);
VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); if (response != null) {
if (response != null) { ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = null;
JsonNode rootNode = null; try {
try { rootNode = mapper.readTree(entity.getAttributeMap());
rootNode = mapper.readTree(entity.getAttributeMap()); } catch (JsonProcessingException e) {
} catch (JsonProcessingException e) { e.printStackTrace();
e.printStackTrace();
}
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());
}
List<Object> dataList = new ArrayList();
JsonNode dataObject = (JsonNode) response.getOriginalData();
if (dataObject.isArray()) {
Iterator<JsonNode> dataIterator = dataObject.iterator();
while (dataIterator.hasNext()) {
dataList.add(toJsonObject(dataIterator.next()));
}
} else {
dataList.add(toJsonObject(dataObject));
}
weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap);
} }
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()));
} }
return true; return true;
} }
private JSONObject toJsonObject(JsonNode node) {
JSONObject jsonObject = JSON.parseObject(node.toString());
return jsonObject;
}
} }

85
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java

@ -3,64 +3,69 @@ package com.hnac.hzims.operational.report.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.service.RunMonthService; import com.hnac.hzims.operational.report.service.RunMonthService;
import com.hnac.hzims.operational.report.vo.RunMonthEvaluateVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author ysj * @author ysj
*/ */
@RestController @RestController
@Api(value = "运行月报",tags = "生产月报") @Api(value = "运行月报", tags = "生产月报")
@AllArgsConstructor @AllArgsConstructor
@RequestMapping("/run/month") @RequestMapping("/run/month")
public class RunMonthController { public class RunMonthController {
private final RunMonthService runMonthService; private final RunMonthService runMonthService;
@GetMapping("/generate") @GetMapping("/generate")
@ApiOperation(value = "生成站点月报",notes = "生成站点月报") @ApiOperation(value = "生成站点月报", notes = "生成站点月报")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<Boolean> generate(@RequestParam("mon") String mon, public R<Boolean> generate(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){ @RequestParam("stationCode") String stationCode) {
return R.data(runMonthService.generate(mon,stationCode)); return R.data(runMonthService.generate(mon, stationCode));
} }
@GetMapping("/check") @GetMapping("/check")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") @ApiOperation(value = "查询站点月报数据", notes = "查询站点月报数据")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<Boolean> check(@RequestParam("stationCode") String stationCode){ public R<Boolean> check(@RequestParam("stationCode") String stationCode) {
return R.data(runMonthService.check(stationCode)); return R.data(runMonthService.check(stationCode));
} }
@GetMapping("/data") @GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") @ApiOperation(value = "查询站点月报数据", notes = "查询站点月报数据")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R<RunMonthEntity> data(@RequestParam("mon") String mon, public R<RunMonthEntity> data(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){ @RequestParam("stationCode") String stationCode) {
return R.data(runMonthService.data(mon,stationCode)); return R.data(runMonthService.data(mon, stationCode));
} }
@GetMapping("/export") @GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报") @ApiOperation(value = "导出站点运行月报", notes = "导出站点运行月报")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public void export(@RequestParam("mon") String mon, public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){ @RequestParam("stationCode") String stationCode) {
runMonthService.export(mon,stationCode); runMonthService.export(mon, stationCode);
} }
@GetMapping("/generateAnalyseResult") @GetMapping("/generateAnalyseResult")
@ApiOperation(value = "生成分析结果",notes = "生成分析结果") @ApiOperation(value = "生成分析结果", notes = "生成分析结果")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R generateAnalyseResult(@RequestParam @ApiParam("查询月份") String month, @RequestParam @ApiParam("站点编号") String stationCode) { public R generateAnalyseResult(@RequestParam @ApiParam("查询月份") String month, @RequestParam @ApiParam("站点编号") String stationCode) {
runMonthService.generateAnalyseResult(month,stationCode); runMonthService.generateAnalyseResult(month, stationCode);
return R.success("调用成功!"); return R.success("调用成功!");
} }
@PutMapping("/evaluate")
@ApiOperation(value = "站点月报评价", notes = "站点月报评价")
@ApiOperationSupport(order = 6)
public R evaluate(@RequestBody RunMonthEvaluateVO req) {
return R.data(runMonthService.evaluate(req.getId(), req.getText()));
}
} }

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

@ -24,4 +24,6 @@ public interface RunMonthService extends IService<RunMonthEntity> {
* @return 大模型调用结果 * @return 大模型调用结果
*/ */
Boolean generateAnalyseResult(String month,String stationCode); Boolean generateAnalyseResult(String month,String stationCode);
Boolean evaluate(Long id, String text);
} }

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

File diff suppressed because it is too large Load Diff

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunMonthEvaluateVO.java

@ -0,0 +1,13 @@
package com.hnac.hzims.operational.report.vo;
import lombok.Data;
/**
* @Author: ypj
* @Date: 2024/9/6 14:50
*/
@Data
public class RunMonthEvaluateVO {
private String text;
private Long id;
}
Loading…
Cancel
Save