From b3338081389ac2555fb87d35ef52f19841eb20c8 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 24 Sep 2024 19:08:31 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E5=90=91=E9=87=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/gglm/bigmodel/BigModelConstants.java | 3 +- .../com/hnac/hzims/fdp/vo/FdpFaultMatchVO.java | 2 +- .../scheduled/DeviceLedgerScheduledTask.java | 3 +- .../business/controller/VectorDataController.java | 3 +- .../business/service/VectorDataService.java | 3 +- .../service/impl/VectorDataServiceImpl.java | 33 ++++++++++----- .../bigmodel/database/service/WeaviateService.java | 25 ++++++++--- .../service/impl/CanvasResolveServiceImpl.java | 48 +++++++++++++++------- .../maintenance/service/DataRecordService.java | 42 ++++++++++--------- .../gglm/bigmodel/utils/RequestClientUtil.java | 5 ++- .../station/mapper/StationVideoTypeMapper.xml | 2 +- 11 files changed, 113 insertions(+), 56 deletions(-) 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/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..abb4d19 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 = BeanUtil.copy(item, DeviceAttrDTO.class); + 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/database/service/WeaviateService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java index cecd4a4..623bc47 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 @@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +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.hzinfo.exception.HzServiceException; @@ -30,6 +32,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; @@ -118,8 +121,12 @@ public class WeaviateService { // } public Boolean saveBatch(List entities,String className, Map attrsMap) { + Optional modelId = entities.stream().filter(entity -> { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity)); + return "1442295246932828161".equals(jsonObject.getString("modelId")); + }).findFirst(); // 查询Weaviate 4.7.0表是否存在 若不存则新建表 - Result existResult = weaviateClient.schema().exists().withClassName("Hzn_lm_" + className).run(); + 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); @@ -134,7 +141,13 @@ public class WeaviateService { Map params = new HashMap<>(2); params.put("table_name", className); List> data = new ArrayList<>(); - entities.forEach(entity -> data.add(this.getVectorData(entity,attrsMap))); + entities.forEach(entity -> { + // 将entity转换为Map + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity, SerializerFeature.WriteMapNullValue)); + Map map = new HashMap<>(); + jsonObject.forEach((k,v) -> map.put(k,Optional.ofNullable(jsonObject.getString(k)).orElse(""))); + data.add(this.getVectorData(map,attrsMap)); + }); log.info("data:{}",JSON.toJSONString(data)); params.put("data",data); String url = gglmUrl + invokeApi.getInsertVectors(); @@ -142,14 +155,16 @@ public class WeaviateService { return true; } - 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)).collect(Collectors.joining(" ")); + vector.put("content", value); vectors.add(vector); }); result.put("vector", vectors); @@ -178,7 +193,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/service/DataRecordService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java index 5c605ed..74a26bb 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 @@ -17,6 +17,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; @@ -81,26 +82,29 @@ public class DataRecordService extends BaseServiceImpl getDataRecordList() { 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); - } + List deviceAttrList = vectorDataService.getDeviceAttr(); + if(Func.isNotEmpty(deviceAttrList)) { + deviceAttrDTOS.addAll(deviceAttrList); } +// 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); +// } +// } return deviceAttrDTOS; } } 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/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 From 7dd9a02e36871388dc69727c7108c24f3ce87e48 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 09:18:55 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix:=E7=9F=A5=E8=AF=86=E5=BA=93=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E7=9A=84=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/service/impl/KnowledgeFileInfoServiceImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index 3cbbf28..4f4179b 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -8,10 +8,10 @@ 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.KnowledgeFileInfo; import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; 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 +21,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; @@ -55,9 +56,9 @@ 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); } From 04d2e4b493964baa0827849ca14823d2ddb78459 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 10:43:12 +0800 Subject: [PATCH 03/13] =?UTF-8?q?add:=E7=9F=A5=E8=AF=86=E5=BA=93=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=96=87=E4=BB=B6=E7=BA=A7=E8=81=94=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=86=E6=AE=B5=E4=BF=A1=E6=81=AF=E5=92=8C?= =?UTF-8?q?=E5=90=91=E9=87=8F=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/KnowledgeFileInfoController.java | 8 +++++++- .../maintenance/service/KnowledgeFileInfoService.java | 7 ++++++- .../service/impl/KnowledgeFileInfoServiceImpl.java | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) 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/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java index fb2f232..1d30668 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,15 @@ 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"; + String VICTOR_DATABASE_NAME = "knowledge_data"; Boolean store(IdRequest req); @@ -23,4 +26,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/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index 4f4179b..309faab 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -8,12 +8,16 @@ 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.configuration.BigModelInvokeApi; 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.vo.IdRequest; import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.gglm.bigmodel.utils.RequestClientUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.oss.model.BladeFile; @@ -41,7 +45,9 @@ import java.util.Map; @DS("hznlm") public class KnowledgeFileInfoServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; + private final KnowledgeFileFragmentService fileFragmentService; private final IOssClient ossClient; + private final BigModelInvokeApi invokeApi; @Value("${gglm.url}") private String interactionUrl; @@ -110,4 +116,16 @@ 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)); + Map deleteTableParams = new HashMap<>(1); + deleteTableParams.put("table_name", VICTOR_DATABASE_NAME); + RequestClientUtil.postCall(interactionUrl + invokeApi.getDeleteTable(), deleteTableParams); + } + return result; + } } From 1aff5fab37a85d4318e329e5787f912ad5fdd6bd Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 11:18:13 +0800 Subject: [PATCH 04/13] =?UTF-8?q?add:=E6=99=BA=E8=B0=B1=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E6=BA=90=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java | 2 ++ 1 file changed, 2 insertions(+) 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 { } From 885c99d63fafd3d0fda05c11b5cc56a808fec256 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 11:22:54 +0800 Subject: [PATCH 05/13] =?UTF-8?q?add:=E6=99=BA=E8=B0=B1=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E6=BA=90=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = "策略编码") From eb73cc5cc9954e51e6d4d2e3384e8511fc497a61 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 25 Sep 2024 14:07:45 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix:=20=E5=90=91=E9=87=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gglm/bigmodel/api/feign/WeaviatesClient.java | 2 +- .../service/impl/VectorDataServiceImpl.java | 2 +- .../database/controller/WeaviateController.java | 2 +- .../bigmodel/database/service/WeaviateService.java | 86 +++++++++------------- .../bigmodel/maintenance/dto/DeviceAttrDTO.java | 3 + .../bigmodel/maintenance/dto/DeviceFuncDTO.java | 3 + .../maintenance/service/DataInstructService.java | 7 ++ .../maintenance/service/DataRecordService.java | 29 ++------ 8 files changed, 58 insertions(+), 76 deletions(-) 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/service/impl/VectorDataServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java index abb4d19..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 @@ -84,7 +84,7 @@ public class VectorDataServiceImpl implements VectorDataService { if (null != rule) { item.setRule(rule); } - DeviceAttrDTO deviceAttrDTO = BeanUtil.copy(item, DeviceAttrDTO.class); + DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO(); deviceAttrDTO.setDeviceId(item.getDeviceId()); deviceAttrDTO.setDeviceName(item.getDeviceName()); deviceAttrDTO.setStationName(item.getProjectName()); 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..224514f 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 @@ -22,7 +22,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("操作成功!"); } 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 623bc47..d419337 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 @@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; 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; @@ -79,53 +80,8 @@ 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) { - Optional modelId = entities.stream().filter(entity -> { - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity)); - return "1442295246932828161".equals(jsonObject.getString("modelId")); - }).findFirst(); - // 查询Weaviate 4.7.0表是否存在 若不存则新建表 + 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); @@ -140,22 +96,48 @@ 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, className, attrsMap, params); + total += insert; + } + // 查询weaviate 中该表的数据量 + return String.format("传入数据总量为:%s 保存成功数量为:%s", entities.size(), total); + } + + /** + * 将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; + } + + private Integer insert(List entities,String className, Map attrsMap, Map params) { List> data = new ArrayList<>(); entities.forEach(entity -> { // 将entity转换为Map JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity, SerializerFeature.WriteMapNullValue)); Map map = new HashMap<>(); - jsonObject.forEach((k,v) -> map.put(k,Optional.ofNullable(jsonObject.getString(k)).orElse(""))); data.add(this.getVectorData(map,attrsMap)); + jsonObject.forEach((k,v) -> map.put(k,jsonObject.getString(k))); }); - log.info("data:{}",JSON.toJSONString(data)); 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(Map entity,Map attrsMap) { Map result = new HashMap<>(2); result.put("object", entity); 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/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 74a26bb..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; @@ -80,31 +81,17 @@ public class DataRecordService extends BaseServiceImpl getDataRecordList() { + List result = Lists.newArrayList(); List list = baseMapper.selectList(null); List deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class); + if(Func.isNotEmpty(deviceAttrDTOS)) { + deviceAttrDTOS.forEach(deviceAttrDTO -> deviceAttrDTO.setType("业务")); + result.addAll(deviceAttrDTOS); + } List deviceAttrList = vectorDataService.getDeviceAttr(); if(Func.isNotEmpty(deviceAttrList)) { - deviceAttrDTOS.addAll(deviceAttrList); + result.addAll(deviceAttrList); } -// 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); -// } -// } - return deviceAttrDTOS; + return result; } } From 31a924f53d2991e75cba709182cd9bc8344a6706 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 14:38:02 +0800 Subject: [PATCH 07/13] =?UTF-8?q?add:=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=86=E9=A1=B5=EF=BC=8C=E5=B9=B3=E5=8F=B0=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E5=9C=A8=E5=B1=9E=E6=80=A7=E4=B8=BA=E5=8D=95=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E6=97=B6=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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..5a4fc03 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 @@ -66,6 +66,7 @@ public class AgentLogServiceImpl extends ServiceImpl Date: Wed, 25 Sep 2024 14:49:18 +0800 Subject: [PATCH 08/13] =?UTF-8?q?add:=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=86=E9=A1=B5=EF=BC=8C=E5=B9=B3=E5=8F=B0=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E5=9C=A8=E5=B1=9E=E6=80=A7=E4=B8=BA=E5=8D=95=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E6=97=B6=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 5a4fc03..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; @@ -67,6 +67,7 @@ public class AgentLogServiceImpl extends ServiceImpl Date: Wed, 25 Sep 2024 15:07:11 +0800 Subject: [PATCH 09/13] =?UTF-8?q?add:=20=E5=90=91=E9=87=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AEapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../database/controller/WeaviateController.java | 8 ++++ .../bigmodel/database/service/WeaviateService.java | 51 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) 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 224514f..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 @@ -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 d419337..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,6 +4,7 @@ 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; @@ -11,6 +12,7 @@ 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; @@ -100,7 +102,7 @@ public class WeaviateService { List entitiesList = splitList(entities, 1000); int total = 0; for (List entityList : entitiesList) { - Integer insert = this.insert(entityList, className, attrsMap, params); + Integer insert = this.insert(entityList, attrsMap, params); total += insert; } // 查询weaviate 中该表的数据量 @@ -108,6 +110,36 @@ public class WeaviateService { } /** + * 根据条件删除数据 + * @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 截断大小 @@ -122,14 +154,21 @@ public class WeaviateService { return parts; } - private Integer insert(List entities,String className, Map attrsMap, Map params) { + /** + * 批量插入数据 + * @param entities 待插入的数据 + * @param attrsMap 向量計算Map + * @param params 向量計算参数 + * @return 插入数量 + */ + private Integer insert(List entities, Map attrsMap, Map params) { List> data = new ArrayList<>(); entities.forEach(entity -> { // 将entity转换为Map JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity, SerializerFeature.WriteMapNullValue)); - Map map = new HashMap<>(); + Map map = new HashMap<>(); data.add(this.getVectorData(map,attrsMap)); - jsonObject.forEach((k,v) -> map.put(k,jsonObject.getString(k))); + jsonObject.forEach((k,v) -> map.put(k,jsonObject.get(k))); }); params.put("data",data); String url = gglmUrl + invokeApi.getInsertVectors(); @@ -138,14 +177,14 @@ public class WeaviateService { return (Integer) stringIntegerMap.get("total"); } - private Map getVectorData(Map 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); - String value = Func.toStrList(",", fields).stream().map(field -> entity.get(field)).collect(Collectors.joining(" ")); + String value = Func.toStrList(",", fields).stream().map(field -> entity.get(field)).map(String::valueOf).collect(Collectors.joining(" ")); vector.put("content", value); vectors.add(vector); }); From 36548a5ea9f4c69b593454e6d32eb7ee06111ef5 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 15:44:25 +0800 Subject: [PATCH 10/13] =?UTF-8?q?add:=E5=90=91=E9=87=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gglm/bigmodel/business/vo/DeviceModelData.java | 23 ++++++++++++++++++---- .../bigmodel/maintenance/dto/KnowledgeData.java | 6 ++++++ .../maintenance/entity/AgentLogEntity.java | 6 +++--- .../service/KnowledgeFileInfoService.java | 1 - .../service/impl/KnowledgeFileInfoServiceImpl.java | 4 ---- 5 files changed, 28 insertions(+), 12 deletions(-) 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..496fe0f 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,6 +16,7 @@ public class DeviceModelData { /** * 模型id */ + @JsonProperty("model_id") private Long modelId; /** @@ -32,23 +32,25 @@ public class DeviceModelData { /** * 数据类型 */ + @JsonProperty("data_type") private String dbType; /** * 字段长度 */ + @JsonProperty("field_length") private String fieldLength; /** * 保留位数 */ - @JsonSerialize(nullsUsing = NullSerializer.class) + @JsonProperty("keep_figures") private Integer keepFigures; /** * 取数规则 0 平均值、1 最大值、2 最小值、3 最后值、4 最早值、5 和值、6 差值 */ - @JsonSerialize(nullsUsing = NullSerializer.class) + @JsonProperty("access_rules") private Integer accessRules; /** @@ -59,6 +61,7 @@ public class DeviceModelData { /** * 模型分类id */ + @JsonProperty("model_classify_id") private Long modelClassifyId; /** @@ -74,61 +77,73 @@ public class DeviceModelData { /** * 参数名称 */ + @JsonProperty("parameter_name") private String parameterName; /** * 参数标识 */ + @JsonProperty("parameter_tag") private String parameterTag; /** * 单点控制状态,0:分,1:合 */ + @JsonProperty("control_status") private Integer controlStatus; /** * 是否弹窗 */ + @JsonProperty("is_popup") private Integer isPopup; /** * 是否反校 */ + @JsonProperty("is_check") private Integer isCheck; /** * 参数来源,0:默认,1:属性值 */ + @JsonProperty("parameter_source") private Integer parameterSource; /** * 来源属性标识 */ + @JsonProperty("source_attr_signage") private String sourceAttrSignage; /** * 控制参数,0:分/合,1:退/投,2:停止/启动 */ + @JsonProperty("control_parameter") private Integer controlParameter; /** * 参数json */ + @JsonProperty("parameter_json") private String parameterJson; /** * 间隔时长 */ + @JsonProperty("interval_length") private Integer intervalLength; /** * 参数范围最小值 */ + @JsonProperty("min_value") private Integer minValue; /** * 参数范围最大值 */ + @JsonProperty("max_value") private Integer maxValue; /** 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/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java index 1d30668..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 @@ -17,7 +17,6 @@ import java.util.List; */ public interface KnowledgeFileInfoService extends IService { String SEGMENT_URL = "/kn/doc_segment"; - String VICTOR_DATABASE_NAME = "knowledge_data"; Boolean store(IdRequest req); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index 309faab..bc29937 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -47,7 +47,6 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpllambdaQuery().in(KnowledgeFileFragment::getDocId, idsList)); - Map deleteTableParams = new HashMap<>(1); - deleteTableParams.put("table_name", VICTOR_DATABASE_NAME); - RequestClientUtil.postCall(interactionUrl + invokeApi.getDeleteTable(), deleteTableParams); } return result; } From 0372115c339bb549f5f453ce0543e1d806549fc1 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 16:03:40 +0800 Subject: [PATCH 11/13] =?UTF-8?q?add:=E5=90=91=E9=87=8F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/gglm/bigmodel/business/vo/DeviceModelData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 496fe0f..f1b1d8e 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 @@ -62,7 +62,7 @@ public class DeviceModelData { * 模型分类id */ @JsonProperty("model_classify_id") - private Long modelClassifyId; + private String modelClassifyId; /** * 告警等级 From 2cedb196efd64b453c0ddfd374a437e465a05eee Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 16:14:52 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=E7=9F=A5=E8=AF=86=E5=BA=93=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/KnowledgeFileInfoServiceImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index bc29937..8f9f29c 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -8,7 +8,6 @@ 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.configuration.BigModelInvokeApi; import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; @@ -17,7 +16,6 @@ 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; -import com.hnac.gglm.bigmodel.utils.RequestClientUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.oss.model.BladeFile; @@ -68,16 +66,17 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl 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 From 5d68b198de299bdec81422750778cd8bf0cebd30 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 16:56:10 +0800 Subject: [PATCH 13/13] =?UTF-8?q?add:=E5=90=91=E9=87=8F=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=B0=E5=BD=95=EF=BC=8C=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=90=91=E9=87=8F=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gglm/bigmodel/business/vo/DeviceModelData.java | 28 +++++++++++----------- .../maintenance/entity/VectorParamEntity.java | 9 +++++++ .../service/impl/VectorParamServiceImpl.java | 8 ++++--- 3 files changed, 28 insertions(+), 17 deletions(-) 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 f1b1d8e..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 @@ -17,7 +17,7 @@ public class DeviceModelData { * 模型id */ @JsonProperty("model_id") - private Long modelId; + private String modelId; /** * 名称 @@ -45,13 +45,13 @@ public class DeviceModelData { * 保留位数 */ @JsonProperty("keep_figures") - private Integer keepFigures; + private String keepFigures; /** * 取数规则 0 平均值、1 最大值、2 最小值、3 最后值、4 最早值、5 和值、6 差值 */ @JsonProperty("access_rules") - private Integer accessRules; + private String accessRules; /** * 描述 @@ -67,12 +67,12 @@ public class DeviceModelData { /** * 告警等级 */ - private Integer level; + private String level; /** * 告警频率 */ - private Integer duration; + private String duration; /** * 参数名称 @@ -90,25 +90,25 @@ public class DeviceModelData { * 单点控制状态,0:分,1:合 */ @JsonProperty("control_status") - private Integer controlStatus; + private String controlStatus; /** * 是否弹窗 */ @JsonProperty("is_popup") - private Integer isPopup; + private String isPopup; /** * 是否反校 */ @JsonProperty("is_check") - private Integer isCheck; + private String isCheck; /** * 参数来源,0:默认,1:属性值 */ @JsonProperty("parameter_source") - private Integer parameterSource; + private String parameterSource; /** * 来源属性标识 @@ -120,7 +120,7 @@ public class DeviceModelData { * 控制参数,0:分/合,1:退/投,2:停止/启动 */ @JsonProperty("control_parameter") - private Integer controlParameter; + private String controlParameter; /** * 参数json @@ -132,24 +132,24 @@ public class DeviceModelData { * 间隔时长 */ @JsonProperty("interval_length") - private Integer intervalLength; + private String intervalLength; /** * 参数范围最小值 */ @JsonProperty("min_value") - private Integer minValue; + private String minValue; /** * 参数范围最大值 */ @JsonProperty("max_value") - private Integer maxValue; + 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/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/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());