Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
yang_shj 2 months ago
parent
commit
eb788eb6d3
  1. 3
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java
  2. 2
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java
  3. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java
  4. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java
  5. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java
  6. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java
  7. 31
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java
  8. 53
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java
  9. 10
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java
  10. 138
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java
  11. 48
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  12. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java
  13. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java
  14. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java
  15. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java
  16. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java
  17. 9
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java
  18. 7
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java
  19. 29
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java
  20. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java
  21. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java
  22. 30
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java
  23. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  24. 5
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java
  25. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java
  26. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java
  27. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml

3
hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java

@ -10,5 +10,6 @@ public interface BigModelConstants {
String APP_NAME = "gglm-big-model";
/**前端展示服务名**/
String MODULE_NAME = "大模型管理";
/**项目前缀**/
String PREFIX = "Hzims";
}

2
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java

@ -45,7 +45,7 @@ public class FdpFaultMatchVO implements Serializable {
private String deviceFaultName;
public void setItemName() {
this.itemId = String.format("%s %s", this.deviceName, this.faultName);
this.itemName = String.format("%s %s", this.deviceName, this.faultName);
}
public void setDeviceFaultName() {

3
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java

@ -3,6 +3,7 @@ package com.hnac.hzims.equipment.scheduled;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hnac.gglm.bigmodel.BigModelConstants;
import com.hnac.gglm.bigmodel.api.dto.WeaviateInsertDTO;
import com.hnac.gglm.bigmodel.api.dto.WeaviateQueryDTO;
import com.hnac.gglm.bigmodel.api.feign.IWeaviatesClient;
@ -76,7 +77,7 @@ public class DeviceLedgerScheduledTask {
// 批量插入数据
WeaviateInsertDTO weaviateInsertDTO = new WeaviateInsertDTO();
weaviateInsertDTO.setEntities(deviceLedgerList);
weaviateInsertDTO.setClassName(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME.replace("Hzn_lm_",""));
weaviateInsertDTO.setClassName(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME.replace(BigModelConstants.PREFIX + "_",""));
Map<String,String> attrMap = new HashMap<>();
attrMap.put("dataSummary","dataSummary");
weaviateInsertDTO.setAttrsMap(attrMap);

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java

@ -32,6 +32,6 @@ public class WeaviatesClient implements IWeaviatesClient {
@Override
@PostMapping(SAVE_BATCH)
public R saveBatch(@RequestBody WeaviateInsertDTO insertDTO) {
return R.status(weaviateService.saveBatch(insertDTO.getEntities(), insertDTO.getClassName(), insertDTO.getAttrsMap()));
return R.data(weaviateService.saveBatch(insertDTO.getEntities(), insertDTO.getClassName(), insertDTO.getAttrsMap()));
}
}

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java

@ -4,6 +4,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.business.service.KnowledgeDataService;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.business.vo.DeviceModelData;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO;
@ -74,7 +75,7 @@ public class VectorDataController {
@ApiOperation(value = "获取设备属性数据")
@ApiOperationSupport(order = 5)
@ApiInterface
public R<List<DeviceAttrInfoDTO>> getDeviceAttr() {
public R<List<DeviceAttrDTO>> getDeviceAttr() {
return R.data(vectorDataService.getDeviceAttr());
}

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java

@ -1,6 +1,7 @@
package com.hnac.gglm.bigmodel.business.service;
import com.hnac.gglm.bigmodel.business.vo.DeviceModelData;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO;
@ -24,7 +25,7 @@ public interface VectorDataService {
List<DeviceModelData> getModelData();
List<DeviceAttrInfoDTO> getDeviceAttr();
List<DeviceAttrDTO> getDeviceAttr();
List<DeviceFuncInfoDTO> getDeviceFunc();

31
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java

@ -3,6 +3,7 @@ package com.hnac.gglm.bigmodel.business.service.impl;
import com.hnac.gglm.bigmodel.business.constants.AccessRules;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.business.vo.DeviceModelData;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO;
@ -17,11 +18,10 @@ import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -75,17 +75,33 @@ public class VectorDataServiceImpl implements VectorDataService {
}
@Override
public List<DeviceAttrInfoDTO> getDeviceAttr() {
public List<DeviceAttrDTO> getDeviceAttr() {
List<DeviceAttrInfoDTO> list = deviceClient.listDeviceAttr().getData();
List<DeviceAttrDTO> deviceAttrDTOS = new ArrayList<>();
if (null != list && !list.isEmpty()) {
list.forEach(item -> {
String rule = AccessRules.getDescByCode(item.getRule());
if (null != rule) {
item.setRule(rule);
}
DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO();
deviceAttrDTO.setDeviceId(item.getDeviceId());
deviceAttrDTO.setDeviceName(item.getDeviceName());
deviceAttrDTO.setStationName(item.getProjectName());
deviceAttrDTO.setStationId(item.getProjectId());
deviceAttrDTO.setRecordName(item.getName());
deviceAttrDTO.setItemId(item.getSignage());
String stationName = deviceAttrDTO.getStationName() == null ? "" : deviceAttrDTO.getStationName();
String deviceName = deviceAttrDTO.getDeviceName() == null ? "" : deviceAttrDTO.getDeviceName();
String recordName = deviceAttrDTO.getRecordName() == null ? "" : deviceAttrDTO.getRecordName();
deviceAttrDTO.setItemName(new StringBuffer(stationName)
.append(" ").append(deviceName)
.append(" ").append(recordName).toString());
deviceAttrDTO.setRule(item.getRule());
deviceAttrDTOS.add(deviceAttrDTO);
});
}
return list;
return deviceAttrDTOS;
}
@Override
@ -104,12 +120,9 @@ public class VectorDataServiceImpl implements VectorDataService {
if (null == nameList || nameList.isEmpty()) {
return list;
}
Map<String, String> map = nameList.stream().collect(Collectors.toMap(ProjectNameVo::getId, ProjectNameVo::getName));
list.forEach(item -> {
String projectName = map.get(item.getProjectId());
if (null != projectName) {
String projectName = Optional.ofNullable(nameList.stream().filter(name -> name.getId().equals(item.getProjectId())).findFirst().orElse(null)).map(ProjectNameVo::getName).orElse("");
item.setProjectName(projectName);
}
item.setItemName(item.getProjectName() + " " + item.getName());
});
return list;

53
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java

@ -1,7 +1,6 @@
package com.hnac.gglm.bigmodel.business.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO;
@ -17,7 +16,8 @@ public class DeviceModelData {
/**
* 模型id
*/
private Long modelId;
@JsonProperty("model_id")
private String modelId;
/**
* 名称
@ -32,24 +32,26 @@ public class DeviceModelData {
/**
* 数据类型
*/
@JsonProperty("data_type")
private String dbType;
/**
* 字段长度
*/
@JsonProperty("field_length")
private String fieldLength;
/**
* 保留位数
*/
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer keepFigures;
@JsonProperty("keep_figures")
private String keepFigures;
/**
* 取数规则 0 平均值1 最大值2 最小值3 最后值4 最早值5 和值6 差值
*/
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer accessRules;
@JsonProperty("access_rules")
private String accessRules;
/**
* 描述
@ -59,82 +61,95 @@ public class DeviceModelData {
/**
* 模型分类id
*/
private Long modelClassifyId;
@JsonProperty("model_classify_id")
private String modelClassifyId;
/**
* 告警等级
*/
private Integer level;
private String level;
/**
* 告警频率
*/
private Integer duration;
private String duration;
/**
* 参数名称
*/
@JsonProperty("parameter_name")
private String parameterName;
/**
* 参数标识
*/
@JsonProperty("parameter_tag")
private String parameterTag;
/**
* 单点控制状态0:1:
*/
private Integer controlStatus;
@JsonProperty("control_status")
private String controlStatus;
/**
* 是否弹窗
*/
private Integer isPopup;
@JsonProperty("is_popup")
private String isPopup;
/**
* 是否反校
*/
private Integer isCheck;
@JsonProperty("is_check")
private String isCheck;
/**
* 参数来源0:默认1:属性值
*/
private Integer parameterSource;
@JsonProperty("parameter_source")
private String parameterSource;
/**
* 来源属性标识
*/
@JsonProperty("source_attr_signage")
private String sourceAttrSignage;
/**
* 控制参数0:/1:退/2:停止/启动
*/
private Integer controlParameter;
@JsonProperty("control_parameter")
private String controlParameter;
/**
* 参数json
*/
@JsonProperty("parameter_json")
private String parameterJson;
/**
* 间隔时长
*/
private Integer intervalLength;
@JsonProperty("interval_length")
private String intervalLength;
/**
* 参数范围最小值
*/
private Integer minValue;
@JsonProperty("min_value")
private String minValue;
/**
* 参数范围最大值
*/
private Integer maxValue;
@JsonProperty("max_value")
private String maxValue;
/**
* 参数系数
*/
private Integer coefficient;
private String coefficient;
/**
* 类型0:属性1:功能2:事件

10
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java

@ -9,6 +9,7 @@ import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
@ -22,7 +23,7 @@ public class WeaviateController {
private final WeaviateService weaviateService;
@PostMapping("/saveBatch")
public R<Boolean> saveBatch(@RequestBody WeaviateSaveDTO req) {
public R<String> saveBatch(@RequestBody WeaviateSaveDTO req) {
weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap());
return R.success("操作成功!");
}
@ -44,4 +45,11 @@ public class WeaviateController {
public R<Object> query(@RequestBody WeaviateQueryDTO query) {
return R.data(weaviateService.query(query.getResultFields(),query.getClassName(),query.getQuery()));
}
@DeleteMapping("/deleteCondition")
public R<Boolean> deleteCondition(@RequestBody Map<String,Object> request) {
String className = (String) request.get("className");
Map<String,String> condition = (Map<String, String>) request.get("condition");
return R.status(weaviateService.deleteCondition(className,condition));
}
}

138
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java

@ -4,10 +4,15 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.BigModelConstants;
import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi;
import com.hnac.gglm.bigmodel.utils.RequestClientUtil;
import com.hnac.hzims.fdp.constants.ScheduledConstant;
import com.hnac.hzinfo.exception.HzServiceException;
import io.weaviate.client.Config;
import io.weaviate.client.WeaviateAuthClient;
@ -30,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.ResultCode;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -76,50 +82,9 @@ public class WeaviateService {
return !result.hasErrors();
}
// /**
// * 对象批量保存向量数据库
// * @param entities 保存对象列表
// * @param className 保存表名
// * @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔
// * @return 保存操作结果
// */
// public Boolean saveBatch(List entities,String className, Map<String,String> attrsMap) {
// entities = entities.subList(0, 1);
// ObjectCreator creator = weaviateClient.data().creator().withClassName(className);
// List<String> vectorStrs = Lists.newArrayList();
// List<String> attrs = Lists.newArrayList();
// if(Func.isNotEmpty(attrsMap)) {
// // 格式化数据
// attrsMap.forEach((k,v) -> attrs.add(v));
// // 解析待计算的向量字段
// entities.forEach(entity -> {
// List<String> 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<Map<String, Float[]>> vector = this.splitVector(entities.size(), attrsMap, vectors);
// for(int i = 0; i < entities.size(); i++) {
// // log.info("vector:{}",JSON.toJSONString(vector.get(i)));
// Map<String, Object> properties = this.objectToMap(entities.get(i));
// log.info("properties:{}",JSON.toJSONString(properties));
// Result<WeaviateObject> run = creator.withProperties(properties).withVectors(vector.get(i)).run();
// if(run.hasErrors()) {
// log.error("保存失败!,保存结果为:{}",JSON.toJSONString(run));
// }
// }
// } else {
// entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run());
// return true;
// }
// return false;
// }
public Boolean saveBatch(List entities,String className, Map<String,String> attrsMap) {
// 查询Weaviate 4.7.0表是否存在 若不存则新建表
Result<Boolean> existResult = weaviateClient.schema().exists().withClassName("Hzn_lm_" + className).run();
public String saveBatch(List entities,String className, Map<String,String> attrsMap) {
// 查询表是否存在 若不存则新建表
Result<Boolean> existResult = weaviateClient.schema().exists().withClassName(BigModelConstants.PREFIX + "_" + className).run();
if(existResult.hasErrors() || !existResult.getResult()) {
Map<java.lang.String,Object> createTableParams = new HashMap<>(2);
Map<String,String> deleteTableParams = new HashMap<>(1);
@ -133,23 +98,94 @@ public class WeaviateService {
}
Map<String,Object> params = new HashMap<>(2);
params.put("table_name", className);
// 将entities按size截断为1000个一组
List<List> entitiesList = splitList(entities, 1000);
int total = 0;
for (List entityList : entitiesList) {
Integer insert = this.insert(entityList, attrsMap, params);
total += insert;
}
// 查询weaviate 中该表的数据量
return String.format("传入数据总量为:%s 保存成功数量为:%s", entities.size(), total);
}
/**
* 根据条件删除数据
* @param className 表名
* @param condition 查询条件
* @return 删除结果
*/
public Boolean deleteCondition(String className,Map<String,String> condition) {
// 查询到相关数据
Object query = this.query(null, className, condition);
if(Func.isEmpty(query)) {
throw new HzServiceException("暂无数据,删除失败!");
}
JSONObject queryJson = JSONObject.parseObject(JSON.toJSONString(query));
JSONArray data = Optional.ofNullable(queryJson).map(json -> json.getJSONObject("Get"))
.map(json -> json.getJSONArray(className)).orElse(null);
if(Func.isNotEmpty(data)) {
List<String> ids = data.stream().map(item -> {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(item));
return Optional.ofNullable(jsonObject)
.map(json -> json.getJSONObject("_additional"))
.map(json -> json.getString("id"))
.orElse("");
}).filter(Func::isNotEmpty).collect(Collectors.toList());
if(Func.isNotEmpty(ids)) {
this.delete(ids.stream().collect(Collectors.joining(",")), className);
}
}
return true;
}
/**
* 将list按size截断为多个list
* @param list 待截断的list
* @param size 截断大小
* @return
* @param <T>
*/
public static <T> List<List<T>> splitList(List<T> list, int size) {
List<List<T>> parts = new ArrayList<>();
for (int i = 0; i < list.size(); i += size) {
parts.add(list.subList(i, Math.min(list.size(), i + size)));
}
return parts;
}
/**
* 批量插入数据
* @param entities 待插入的数据
* @param attrsMap 向量計算Map
* @param params 向量計算参数
* @return 插入数量
*/
private Integer insert(List entities, Map<String,String> attrsMap, Map<String,Object> params) {
List<Map<String, Object>> data = new ArrayList<>();
entities.forEach(entity -> data.add(this.getVectorData(entity,attrsMap)));
log.info("data:{}",JSON.toJSONString(data));
entities.forEach(entity -> {
// 将entity转换为Map<String,String>
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity, SerializerFeature.WriteMapNullValue));
Map<String,Object> map = new HashMap<>();
data.add(this.getVectorData(map,attrsMap));
jsonObject.forEach((k,v) -> map.put(k,jsonObject.get(k)));
});
params.put("data",data);
String url = gglmUrl + invokeApi.getInsertVectors();
RequestClientUtil.postCall(url,params);
return true;
Map<String, Object> stringIntegerMap = RequestClientUtil.postCall(url, params, new TypeReference<Map<String, Object>>() {
});
return (Integer) stringIntegerMap.get("total");
}
private Map<String,Object> getVectorData(Object entity,Map<String,String> attrsMap) {
private Map<String,Object> getVectorData(Map<String,Object> entity,Map<String,String> attrsMap) {
Map<String,Object> result = new HashMap<>(2);
result.put("object", entity);
List<Map<String,String>> vectors = new ArrayList<>();
attrsMap.forEach((k,fields) -> {
Map<String,String> vector = new HashMap<>();
vector.put("key",k);
vector.put("content", this.getFieldValue(fields, entity));
String value = Func.toStrList(",", fields).stream().map(field -> entity.get(field)).map(String::valueOf).collect(Collectors.joining(" "));
vector.put("content", value);
vectors.add(vector);
});
result.put("vector", vectors);
@ -178,7 +214,7 @@ public class WeaviateService {
if(Func.isEmpty(ids) && Func.isNotEmpty(className)) {
// 删除className
Map<String,String> deleteTableParams = new HashMap<>(1);
deleteTableParams.put("table_name",className.replace("Hzn_lm_",""));
deleteTableParams.put("table_name",className.replace(BigModelConstants.PREFIX + "_",""));
RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams);
} else {
// 删除记录

48
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java

@ -10,6 +10,9 @@ import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.exception.HzServiceException;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
@ -34,6 +37,7 @@ import java.util.stream.IntStream;
public class CanvasResolveServiceImpl implements IResolveService {
private final IStationClient stationClient;
private final ScadaClient scadaClient;
@Override
public ExtraVO resolve(ModelFunctionReq req) {
@ -49,41 +53,57 @@ public class CanvasResolveServiceImpl implements IResolveService {
@Override
public ExtraVO resolve(String id) {
List<String> params = Func.toStrList("\\^", id);
Long scadaId;
if(params.size() == 1) {
scadaId = Long.valueOf(id);
} else if(params.size() == 7) {
scadaId = Long.valueOf(params.get(6));
} else {
throw new HzServiceException("画面id格式错误,解析失败");
}
Result<CanvasVO> canvasById = scadaClient.getCanvasById(null, scadaId);
if(!canvasById.isSuccess()) {
throw new HzServiceException("获取画面信息失败");
}
CanvasVO canvasVO = canvasById.getData();
if(canvasVO == null) {
throw new HzServiceException("获取画面信息失败");
}
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc());
final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST);
// 将ID解析为
Map<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE);
R<StationEntity> stationR = stationClient.getStationByCode(resolveMap.get("projectId"));
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name"));
int picResource = Integer.parseInt(resolveMap.get("picResource"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
int picSource = canvasVO.getPicSource();
// 将 canvasVO 转换为 Map
Map<String, String> resolveMap = JSON.parseObject(JSON.toJSONString(canvasVO), Map.class);
// 云组态
if(picResource == 0) {
if(picSource == 0) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v3.0
else if(picResource == 1) {
else if(picSource == 1) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v4.0
else if (picResource == 2) {
else if (picSource == 2) {
// pic_name 去掉头部的/ 以及尾部的.js
String context = resolveMap.get("context");
context = this.removeHeadChars(context,"/");
context = this.removeTailChars(context,".js");
resolveMap.put("context",context);
extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&itemName={itemName}", resolveMap));
extraVO.setRoute(canvasHost + this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}", resolveMap));
}
else {
throw new HzServiceException(ResultCode.FAILURE,"解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
}
R<StationEntity> stationR = stationClient.getStationByCode(canvasVO.getProjectId());
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource", picSource);
extraVO.setParams(extraParams);
return extraVO;
}
@ -102,7 +122,7 @@ public class CanvasResolveServiceImpl implements IResolveService {
// 替换path中变量
for (Map.Entry<String, String> entry : entries) {
String replaceVariables = "{" + entry.getKey() + "}";
path = StringUtil.replace(path,replaceVariables,entry.getValue());
path = StringUtil.replace(path,replaceVariables,String.valueOf(entry.getValue()));
}
return path;
}

8
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java

@ -1,8 +1,11 @@
package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo;
import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService;
import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService;
import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest;
import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest;
@ -21,6 +24,8 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @Author: ypj
* @Date: 2024/9/10 16:44
@ -66,7 +71,8 @@ public class KnowledgeFileInfoController {
@ApiOperation(value = "删除")
@ApiOperationSupport(order = 5)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(knowledgeFileInfoService.removeByIds(Func.toLongList(",", ids)));
List<Long> idsList = Func.toLongList(",", ids);
return R.status(knowledgeFileInfoService.removeRecursive( idsList));
}
@PostMapping(value = "/upload", produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java

@ -39,4 +39,7 @@ public class DeviceAttrDTO {
@ApiModelProperty("取数规则")
@JsonProperty("rule")
private String rule;
@ApiModelProperty("数据类型")
private String type = "平台";
}

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java

@ -36,4 +36,7 @@ public class DeviceFuncDTO {
@JsonProperty("yk_name")
private String ykName;
@ApiModelProperty("遥控名称")
private String type = "平台";
}

6
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java

@ -1,6 +1,7 @@
package com.hnac.gglm.bigmodel.maintenance.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -14,23 +15,28 @@ import lombok.Data;
public class KnowledgeData {
@ApiModelProperty("文档ID")
@TableField("DOC_ID")
@JsonProperty("doc_id")
private Long docId;
@ApiModelProperty("文档问题")
@TableField("DOC_QS")
@JsonProperty("doc_qs")
private String docQs;
@ApiModelProperty("文档内容")
@TableField("DOC_CONTENT")
@JsonProperty("doc_content")
private String docContent;
@ApiModelProperty("文档页码")
@TableField("DOC_PAGE_INDEX")
@JsonProperty("doc_page_index")
private Integer docPageIndex;
@ApiModelProperty("知识库领域")
private String area;
@ApiModelProperty("等级")
@JsonProperty("doc_level")
private Integer level;
}

6
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java

@ -65,17 +65,17 @@ public class AgentLogEntity extends TenantEntity implements Serializable {
@ApiModelProperty("用户结论,0为错误,1为正确")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("user_conclusion")
private int userConclusion;
private Integer userConclusion;
@ApiModelProperty("标注状态,0为未标注,1为已标注")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("label_status")
private int labelStatus;
private Integer labelStatus;
@ApiModelProperty("标注结果,0为错误,1为正确")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("label_result")
private int labelResult;
private Integer labelResult;
@ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样")
@QueryField(condition = SqlCondition.LIKE)

9
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java

@ -10,6 +10,7 @@ import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: ypj
@ -50,4 +51,12 @@ public class VectorParamEntity extends TenantEntity implements Serializable {
@TableField("REMARK")
@QueryField(condition = SqlCondition.LIKE)
private String remark;
@ApiModelProperty("同步时间")
@TableField("SYNCHRONIZATION_TIME")
private Date synchronizationTime;
@ApiModelProperty("同步说明")
@TableField("SYNCHRONIZATION_REMARK")
private String synchronizationRemark;
}

7
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java

@ -3,6 +3,7 @@ package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO;
import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity;
@ -12,6 +13,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -52,8 +54,13 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
}
public List<DeviceFuncDTO> getDataInstructList() {
List<DeviceFuncDTO> result = Lists.newArrayList();
List<DataInstructEntity> list = baseMapper.selectList(null);
List<DeviceFuncDTO> deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class);
if(Func.isNotEmpty(deviceFuncDTOS)) {
deviceFuncDTOS.forEach(deviceFuncDTO -> deviceFuncDTO.setType("业务"));
result.addAll(deviceFuncDTOS);
}
List<DeviceFuncInfoDTO> deviceFuncList = vectorDataService.getDeviceFunc();
if (deviceFuncList != null) {
for (DeviceFuncInfoDTO deviceFunc : deviceFuncList) {

29
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java

@ -3,6 +3,7 @@ package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO;
@ -17,6 +18,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.List;
@ -79,28 +81,17 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
}
public List<DeviceAttrDTO> getDataRecordList() {
List<DeviceAttrDTO> result = Lists.newArrayList();
List<DataRecordEntity> list = baseMapper.selectList(null);
List<DeviceAttrDTO> deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class);
List<DeviceAttrInfoDTO> deviceAttrList = vectorDataService.getDeviceAttr();
if (deviceAttrList != null) {
for (DeviceAttrInfoDTO deviceAttr : deviceAttrList) {
DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO();
deviceAttrDTO.setDeviceId(deviceAttr.getDeviceId());
deviceAttrDTO.setDeviceName(deviceAttr.getDeviceName());
deviceAttrDTO.setStationName(deviceAttr.getProjectName());
deviceAttrDTO.setStationId(deviceAttr.getProjectId());
deviceAttrDTO.setRecordName(deviceAttr.getName());
deviceAttrDTO.setItemId(deviceAttr.getSignage());
String stationName = deviceAttrDTO.getStationName() == null ? "" : deviceAttrDTO.getStationName();
String deviceName = deviceAttrDTO.getDeviceName() == null ? "" : deviceAttrDTO.getDeviceName();
String recordName = deviceAttrDTO.getRecordName() == null ? "" : deviceAttrDTO.getRecordName();
deviceAttrDTO.setItemName(new StringBuffer(stationName)
.append(" ").append(deviceName)
.append(" ").append(recordName).toString());
deviceAttrDTO.setRule(deviceAttr.getRule());
deviceAttrDTOS.add(deviceAttrDTO);
if(Func.isNotEmpty(deviceAttrDTOS)) {
deviceAttrDTOS.forEach(deviceAttrDTO -> deviceAttrDTO.setType("业务"));
result.addAll(deviceAttrDTOS);
}
List<DeviceAttrDTO> deviceAttrList = vectorDataService.getDeviceAttr();
if(Func.isNotEmpty(deviceAttrList)) {
result.addAll(deviceAttrList);
}
return deviceAttrDTOS;
return result;
}
}

6
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java

@ -9,12 +9,14 @@ import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @Author: ypj
* @Date: 2024/9/10 16:42
*/
public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> {
String SEGMENT_URL= "/kn/doc_segment";
String SEGMENT_URL = "/kn/doc_segment";
Boolean store(IdRequest req);
@ -23,4 +25,6 @@ public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> {
IPage<KnowledgeFileInfo> listPage(IPage<KnowledgeFileInfo> page, KnowledgeFileInfo req);
R<BladeFile> upload(MultipartFile file);
Boolean removeRecursive(List<Long> idsList);
}

4
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java

@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.AgentLogMapper;
import com.hnac.gglm.bigmodel.maintenance.service.AgentLogService;
import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.gglm.bigmodel.maintenance.vo.LabelRequest;
import lombok.AllArgsConstructor;
@ -66,6 +66,8 @@ public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEnt
.eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId())
.eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId())
.like(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName())
.like(StringUtil.isNotBlank(req.getQ()), AgentLogEntity::getQ, req.getQ())
.eq(ObjectUtil.isNotEmpty(req.getLabelStatus()), AgentLogEntity::getLabelStatus, req.getLabelStatus())
.orderByAsc(AgentLogEntity::getCreateTime)
.orderByAsc(AgentLogEntity::getChatId);
return this.page(page, queryWrapper);

30
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java

@ -8,10 +8,12 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo;
import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper;
import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService;
import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService;
import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus;
import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest;
import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest;
import lombok.RequiredArgsConstructor;
@ -21,6 +23,7 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.resource.feign.IOssClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -40,6 +43,7 @@ import java.util.Map;
@DS("hznlm")
public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoMapper, KnowledgeFileInfo> implements KnowledgeFileInfoService {
private final KnowledgeFileInfoMapper knowledgeFileInfoMapper;
private final KnowledgeFileFragmentService fileFragmentService;
private final IOssClient ossClient;
@Value("${gglm.url}")
@ -55,23 +59,24 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoM
Map<String, Object> params = new HashMap<>();
params.put("doc_id", knowledgeFileInfo.getId().toString());
params.put("url", knowledgeFileInfo.getUrl());
params.put("tenant_id", tenantId);
params.put("create_user", createUser.toString());
params.put("create_dept", createDept);
params.put("tenant_id", StringUtil.isBlank(tenantId) ? "000000" : tenantId);
params.put("create_user", ObjectUtil.isEmpty(createUser) ? "-1" : createUser.toString());
params.put("create_dept", StringUtil.isBlank(createDept) ? "000000" : createDept);
return JsonUtil.toJson(params);
}
private Boolean store(KnowledgeFileInfo knowledgeFileInfo, String tenantId, Long createUser, String createDept) {
LambdaUpdateWrapper<KnowledgeFileInfo> wrapper = Wrappers.<KnowledgeFileInfo>lambdaUpdate()
.set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode())
.eq(KnowledgeFileInfo::getId, knowledgeFileInfo.getId());
this.update(wrapper);
HttpResponse response = HttpRequest.post(interactionUrl + SEGMENT_URL)
.body(getParamsJson(knowledgeFileInfo, tenantId, createUser, createDept), "application/json")
.execute();
if (!response.isOk()) {
return false;
}
LambdaUpdateWrapper<KnowledgeFileInfo> wrapper = Wrappers.<KnowledgeFileInfo>lambdaUpdate()
.set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode())
.eq(KnowledgeFileInfo::getId, knowledgeFileInfo.getId());
return this.update(wrapper);
return Boolean.TRUE;
}
@Override
@ -109,4 +114,13 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoM
public R<BladeFile> upload(MultipartFile file) {
return ossClient.putFile(file);
}
@Override
public Boolean removeRecursive(List<Long> idsList) {
Boolean result = removeByIds(idsList);
if (result) {
fileFragmentService.remove(Wrappers.<KnowledgeFileFragment>lambdaQuery().in(KnowledgeFileFragment::getDocId, idsList));
}
return result;
}
}

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

@ -5,7 +5,6 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -159,8 +158,11 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
attrMap.put(key, rootNode.findValue(key).textValue());
}
String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", "");
weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap);
if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()))) {
String syncResult = weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap);
if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate()
.eq(VectorParamEntity::getId, id)
.set(VectorParamEntity::getSynchronizationRemark, syncResult)
.set(VectorParamEntity::getSynchronizationTime, new Date()))) {
return vectorParamLogService.synchronization(VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.SYNCHRONIZATION.getCode()).build());

5
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java

@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.hnac.hzinfo.exception.HzServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.ResultCode;
@ -43,7 +44,7 @@ public class RequestClientUtil {
* @param body 传参body
*/
public static void postCall(String url, Map body) {
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body, SerializerFeature.WriteMapNullValue)).execute();
if(Func.isNotEmpty(response.body()) && !"[]".equals(response.body())) {
log.info("接口调用结果为:{}",response.body());
}
@ -61,7 +62,7 @@ public class RequestClientUtil {
* @param <T> 结果解析对象类型
*/
public static <T> T postCall(String url, Map body, TypeReference<T> typeRef) {
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body, SerializerFeature.WriteMapNullValue)).execute();
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new HzServiceException(ResultCode.FAILURE, "远程调用大模型接口" + url + "失败!");
});

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java

@ -17,7 +17,7 @@ import org.springblade.core.tenant.mp.TenantEntity;
@ApiModel(value = "大模型分析信息")
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("hzims_analysis_info")
@TableName("gglm_analysis_info")
public class ZhipuAnalysisInfoEntity extends TenantEntity {
@ApiModelProperty(value = "策略编码")

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java

@ -1,5 +1,6 @@
package com.hnac.gglm.bigmodel.zhipuai.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
@ -7,5 +8,6 @@ import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
* @Author: ypj
* @Date: 2024/8/12 20:05
*/
@DS("hznlm")
public interface ZhipuAnalysisInfoMapper extends UserDataScopeBaseMapper<ZhipuAnalysisInfoEntity> {
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml

@ -78,7 +78,7 @@
hsvt.`name` AS video_name,
hsvt.station_id AS station_id,
hs.`name` AS station_name,
concat(hs.`code`, ' ', hs.`name`) AS item_name
concat(hs.`name`, ' ', hsvt.`name`) AS item_name
FROM `hzims_station_video_type` hsvt
LEFT JOIN hzims_station hs ON hsvt.station_id = hs.`code`
WHERE

Loading…
Cancel
Save