diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java index 8453f4f..19a53ab 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java +++ b/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"; } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java index e291305..08966a3 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java +++ b/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() { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java index 5410a52..00467f8 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java +++ b/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 attrMap = new HashMap<>(); attrMap.put("dataSummary","dataSummary"); weaviateInsertDTO.setAttrsMap(attrMap); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java index bacaf79..2142405 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java +++ b/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())); } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java index 437465a..1a8fc53 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java +++ b/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> getDeviceAttr() { + public R> getDeviceAttr() { return R.data(vectorDataService.getDeviceAttr()); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java index afa5941..202de0f 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java +++ b/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 getModelData(); - List getDeviceAttr(); + List getDeviceAttr(); List getDeviceFunc(); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java index c1f26d9..ea1f6e6 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java +++ b/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 getDeviceAttr() { + public List getDeviceAttr() { List list = deviceClient.listDeviceAttr().getData(); + List 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 map = nameList.stream().collect(Collectors.toMap(ProjectNameVo::getId, ProjectNameVo::getName)); list.forEach(item -> { - String projectName = map.get(item.getProjectId()); - if (null != projectName) { - item.setProjectName(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; diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java index 7bebc16..5593352 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java +++ b/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:事件 diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java index 108a655..b16899a 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java +++ b/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 saveBatch(@RequestBody WeaviateSaveDTO req) { + public R saveBatch(@RequestBody WeaviateSaveDTO req) { weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap()); return R.success("操作成功!"); } @@ -44,4 +45,11 @@ public class WeaviateController { public R query(@RequestBody WeaviateQueryDTO query) { return R.data(weaviateService.query(query.getResultFields(),query.getClassName(),query.getQuery())); } + + @DeleteMapping("/deleteCondition") + public R deleteCondition(@RequestBody Map request) { + String className = (String) request.get("className"); + Map condition = (Map) request.get("condition"); + return R.status(weaviateService.deleteCondition(className,condition)); + } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java index cecd4a4..f83fb3b 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java +++ b/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 attrsMap) { -// entities = entities.subList(0, 1); -// ObjectCreator creator = weaviateClient.data().creator().withClassName(className); -// List vectorStrs = Lists.newArrayList(); -// List attrs = Lists.newArrayList(); -// if(Func.isNotEmpty(attrsMap)) { -// // 格式化数据 -// attrsMap.forEach((k,v) -> attrs.add(v)); -// // 解析待计算的向量字段 -// entities.forEach(entity -> { -// List 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> vector = this.splitVector(entities.size(), attrsMap, vectors); -// for(int i = 0; i < entities.size(); i++) { -// // log.info("vector:{}",JSON.toJSONString(vector.get(i))); -// Map properties = this.objectToMap(entities.get(i)); -// log.info("properties:{}",JSON.toJSONString(properties)); -// Result 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 attrsMap) { - // 查询Weaviate 4.7.0表是否存在 若不存则新建表 - Result existResult = weaviateClient.schema().exists().withClassName("Hzn_lm_" + className).run(); + public String saveBatch(List entities,String className, Map attrsMap) { + // 查询表是否存在 若不存则新建表 + Result existResult = weaviateClient.schema().exists().withClassName(BigModelConstants.PREFIX + "_" + className).run(); if(existResult.hasErrors() || !existResult.getResult()) { Map createTableParams = new HashMap<>(2); Map deleteTableParams = new HashMap<>(1); @@ -133,23 +98,94 @@ public class WeaviateService { } Map params = new HashMap<>(2); params.put("table_name", className); + // 将entities按size截断为1000个一组 + 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 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 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 + */ + public static List> splitList(List list, int size) { + List> 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 attrsMap, Map params) { List> data = new ArrayList<>(); - entities.forEach(entity -> data.add(this.getVectorData(entity,attrsMap))); - log.info("data:{}",JSON.toJSONString(data)); + entities.forEach(entity -> { + // 将entity转换为Map + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity, SerializerFeature.WriteMapNullValue)); + Map 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 stringIntegerMap = RequestClientUtil.postCall(url, params, new TypeReference>() { + }); + return (Integer) stringIntegerMap.get("total"); } - private Map getVectorData(Object entity,Map attrsMap) { + private Map getVectorData(Map entity,Map attrsMap) { Map result = new HashMap<>(2); result.put("object", entity); List> vectors = new ArrayList<>(); attrsMap.forEach((k,fields) -> { Map 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 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 { // 删除记录 diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java index 1cc7fdb..f2fc3b0 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ b/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 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 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 resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); - R 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 extraParams = new HashMap<>(1); - extraParams.put("picResource",picResource); - extraVO.setParams(extraParams); + int picSource = canvasVO.getPicSource(); + // 将 canvasVO 转换为 Map + Map 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 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 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 entry : entries) { String replaceVariables = "{" + entry.getKey() + "}"; - path = StringUtil.replace(path,replaceVariables,entry.getValue()); + path = StringUtil.replace(path,replaceVariables,String.valueOf(entry.getValue())); } return path; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java index 3e6a8f8..ba97c55 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java +++ b/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 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) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java index 4330048..7057a1a 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java +++ b/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 = "平台"; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java index dedfabe..1df8b54 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java +++ b/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 = "平台"; + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java index 6e1d3ce..161d588 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java +++ b/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; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java index 5ab9d50..0df71b8 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java +++ b/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) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java index aadec23..04e3dce 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java +++ b/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; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java index 76fb1cc..f12b37a 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java +++ b/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 getDataInstructList() { + List result = Lists.newArrayList(); List list = baseMapper.selectList(null); List deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class); + if(Func.isNotEmpty(deviceFuncDTOS)) { + deviceFuncDTOS.forEach(deviceFuncDTO -> deviceFuncDTO.setType("业务")); + result.addAll(deviceFuncDTOS); + } List deviceFuncList = vectorDataService.getDeviceFunc(); if (deviceFuncList != null) { for (DeviceFuncInfoDTO deviceFunc : deviceFuncList) { diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java index 5c605ed..66eaac9 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java +++ b/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 getDataRecordList() { + List result = Lists.newArrayList(); List list = baseMapper.selectList(null); List deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class); - List 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); } - return deviceAttrDTOS; + List deviceAttrList = vectorDataService.getDeviceAttr(); + if(Func.isNotEmpty(deviceAttrList)) { + result.addAll(deviceAttrList); + } + return result; } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java index fb2f232..52d11df 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java +++ b/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 { - 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 { IPage listPage(IPage page, KnowledgeFileInfo req); R upload(MultipartFile file); + + Boolean removeRecursive(List idsList); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java index 23f7331..39aab78 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java +++ b/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 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 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 wrapper = Wrappers.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 wrapper = Wrappers.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 upload(MultipartFile file) { return ossClient.putFile(file); } + + @Override + public Boolean removeRecursive(List idsList) { + Boolean result = removeByIds(idsList); + if (result) { + fileFragmentService.remove(Wrappers.lambdaQuery().in(KnowledgeFileFragment::getDocId, idsList)); + } + return result; + } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java index 1a2aea4..50db76b 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java +++ b/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 ServiceImpllambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()))) { + String syncResult = weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap); + if (this.update(Wrappers.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()); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java index f5a9c04..2fc190d 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java +++ b/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 结果解析对象类型 */ public static T postCall(String url, Map body, TypeReference 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 + "失败!"); }); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java index 7e4d67a..be26907 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java +++ b/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 = "策略编码") diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java index ba93219..12acbae 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java +++ b/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 { } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml index 38f35b1..1414e4a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.xml +++ b/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