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. 119
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  5. 41
      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. 456
      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("分析结果")
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));
}
@PutMapping("/synchronization")
@PutMapping("/synchronization/{id}")
@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) throws JsonProcessingException {
return R.status(vectorParamService.synchronization(bladeToken, hzinfoToken));
@RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @PathVariable Long id) throws JsonProcessingException {
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);
Boolean synchronization(String bladeToken, String hzinfoToken);
Boolean synchronization(Long id ,String bladeToken, String hzinfoToken);
}

119
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.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
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 lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
@ -49,59 +49,57 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
.header("Hzinfo-Auth", hzinfoToken).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
String body = response.body();
log.info("getUrlResponse:" + body);
JSONObject jsonObject = JSON.parseObject(body);
VectorUrlResponse result = new VectorUrlResponse();
result.setOriginalData(JSONArray.parseArray(jsonObject.getString("data")).toJavaList(JSONObject.class));
// try {
// ObjectMapper mapper = new ObjectMapper();
// JsonNode rootNode = mapper.readTree(body);
// if (rootNode.isArray()) {
// return getUrlResponseByArray(rootNode);
// }
// JsonNode dataNode = rootNode.findValue("data");
// if (dataNode != null && dataNode.isArray()) {
// return getUrlResponseByArray(dataNode);
// }
// if (dataNode != null) {
// return getUrlResponseByObject(dataNode);
// }
// if (rootNode != null) {
// return getUrlResponseByObject(rootNode);
// }
// } catch (JsonProcessingException e) {
// log.error("getUrlResponse error", e);
// }
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(body);
if (rootNode.isArray()) {
return getUrlResponseByArray(rootNode);
}
JsonNode dataNode = rootNode.findValue("data");
if (dataNode != null && dataNode.isArray()) {
return getUrlResponseByArray(dataNode);
}
if (dataNode != null) {
return getUrlResponseByObject(dataNode);
}
if (rootNode != null) {
return getUrlResponseByObject(rootNode);
}
} catch (JsonProcessingException e) {
log.error("getUrlResponse error", e);
}
}
return null;
}
// private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException {
// VectorUrlResponse result = new VectorUrlResponse();
// result.setOriginalData(rootNode);
// JsonNode item = rootNode.get(0);
// if (item != null) {
// List<String> keyList = new ArrayList<>();
// Iterator<String> iterator = item.fieldNames();
// while (iterator.hasNext()) {
// keyList.add(iterator.next());
// }
// result.setKeyList(keyList);
// }
// return result;
// }
private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException {
VectorUrlResponse result = new VectorUrlResponse();
result.setOriginalData(JSONArray.parseArray(rootNode.toPrettyString()).toJavaList(JSONObject.class));
JsonNode item = rootNode.get(0);
if (item != null) {
List<String> keyList = new ArrayList<>();
Iterator<String> iterator = item.fieldNames();
while (iterator.hasNext()) {
keyList.add(iterator.next());
}
result.setKeyList(keyList);
}
return result;
}
// private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException {
// VectorUrlResponse result = new VectorUrlResponse();
// result.setOriginalData(rootNode);
// List<String> keyList = new ArrayList<>();
// Iterator<String> iterator = rootNode.fieldNames();
// while (iterator.hasNext()) {
// keyList.add(iterator.next());
// }
// result.setKeyList(keyList);
// return result;
// }
private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException {
VectorUrlResponse result = new VectorUrlResponse();
List<JSONObject> originalData = new ArrayList<>();
originalData.add(JSON.parseObject(rootNode.toPrettyString()));
result.setOriginalData(originalData);
List<String> keyList = new ArrayList<>();
Iterator<String> iterator = rootNode.fieldNames();
while (iterator.hasNext()) {
keyList.add(iterator.next());
}
result.setKeyList(keyList);
return result;
}
@Override
public List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) {
@ -110,12 +108,11 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
}
@Override
public Boolean synchronization(String bladeToken, String hzinfoToken) {
List<VectorParamEntity> list = this.list();
if (CollectionUtil.isEmpty(list)) {
public Boolean synchronization(Long id, String bladeToken, String hzinfoToken) {
VectorParamEntity entity = getById(id);
if (null == entity) {
return false;
}
for (VectorParamEntity entity : list) {
VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken);
if (response != null) {
ObjectMapper mapper = new ObjectMapper();
@ -131,24 +128,10 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
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);
}
this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()));
}
return true;
}
private JSONObject toJsonObject(JsonNode node) {
JSONObject jsonObject = JSON.parseObject(node.toString());
return jsonObject;
}
}

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

@ -3,21 +3,19 @@ package com.hnac.hzims.operational.report.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
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.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @author ysj
*/
@RestController
@Api(value = "运行月报",tags = "生产月报")
@Api(value = "运行月报", tags = "生产月报")
@AllArgsConstructor
@RequestMapping("/run/month")
public class RunMonthController {
@ -26,41 +24,48 @@ public class RunMonthController {
@GetMapping("/generate")
@ApiOperation(value = "生成站点月报",notes = "生成站点月报")
@ApiOperation(value = "生成站点月报", notes = "生成站点月报")
@ApiOperationSupport(order = 1)
public R<Boolean> generate(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.generate(mon,stationCode));
@RequestParam("stationCode") String stationCode) {
return R.data(runMonthService.generate(mon, stationCode));
}
@GetMapping("/check")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperation(value = "查询站点月报数据", notes = "查询站点月报数据")
@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));
}
@GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperation(value = "查询站点月报数据", notes = "查询站点月报数据")
@ApiOperationSupport(order = 3)
public R<RunMonthEntity> data(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.data(mon,stationCode));
@RequestParam("stationCode") String stationCode) {
return R.data(runMonthService.data(mon, stationCode));
}
@GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报")
@ApiOperation(value = "导出站点运行月报", notes = "导出站点运行月报")
@ApiOperationSupport(order = 4)
public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
runMonthService.export(mon,stationCode);
@RequestParam("stationCode") String stationCode) {
runMonthService.export(mon, stationCode);
}
@GetMapping("/generateAnalyseResult")
@ApiOperation(value = "生成分析结果",notes = "生成分析结果")
@ApiOperation(value = "生成分析结果", notes = "生成分析结果")
@ApiOperationSupport(order = 5)
public R generateAnalyseResult(@RequestParam @ApiParam("查询月份") String month, @RequestParam @ApiParam("站点编号") String stationCode) {
runMonthService.generateAnalyseResult(month,stationCode);
runMonthService.generateAnalyseResult(month, stationCode);
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 大模型调用结果
*/
Boolean generateAnalyseResult(String month,String stationCode);
Boolean evaluate(Long id, String text);
}

456
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