diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java new file mode 100644 index 0000000..ec1215b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java @@ -0,0 +1,49 @@ +package com.hnac.gglm.bigmodel.business.constants; + +import lombok.Getter; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author: ypj + * @Date: 2024/9/20 22:39 + */ +@Getter +public enum AccessRules { + MOST_EARLY("0", "最早值"), + LARGEST("1", "最大值"), + SMALLEST("2", "最小值"), + AVERAGE("3", "平均值"), + SUM("4", "累计值/和值"), + CHANGE("5", "变化值/差值"), + LAST("6", "最新值/最后值"); + + private final String code; + private final String desc; + + private static final Map map = new ConcurrentHashMap<>(); + + static { + for (AccessRules accessRules : AccessRules.values()) { + map.put(accessRules.code, accessRules); + } + } + + AccessRules(String code, String desc) { + this.code = code; + this.desc = desc; + } + + public static AccessRules getByCode(String code) { + return map.get(code); + } + + public static String getDescByCode(String code) { + AccessRules rule = getByCode(code); + if (null != rule) { + return rule.getDesc(); + } + return null; + } +} 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 fcdde9f..598ca28 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 @@ -7,6 +7,7 @@ import com.hnac.gglm.bigmodel.business.vo.DeviceModelData; import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; import com.hnac.hzinfo.api.annotation.ApiInterface; 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; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; @@ -76,11 +77,20 @@ public class VectorDataController { return R.data(vectorDataService.getDeviceAttr()); } + @GetMapping("/getDeviceFunc") + @ApiOperation(value = "获取设备功能数据") + @ApiOperationSupport(order = 6) + @ApiInterface + public R> getDeviceFunc() { + return R.data(vectorDataService.getDeviceFunc()); + } + @GetMapping("/listKnowledgeData") @ApiOperation(value = "获取知识库数据") - @ApiOperationSupport(order = 6) + @ApiOperationSupport(order = 7) @ApiInterface public R> listKnowledgeData() { return R.data(knowledgeDataService.listKnowledgeData()); } + } 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 cf61e75..15c5224 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 @@ -2,6 +2,7 @@ package com.hnac.gglm.bigmodel.business.service; import com.hnac.gglm.bigmodel.business.vo.DeviceModelData; 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; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; @@ -23,4 +24,6 @@ public interface VectorDataService { List getModelData(); 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 f4bce9d..26bf4b4 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 @@ -1,9 +1,11 @@ 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.hzinfo.sdk.v5.device.client.DeviceClient; 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.ModelClient; import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; @@ -67,6 +69,27 @@ public class VectorDataServiceImpl implements VectorDataService { @Override public List getDeviceAttr() { - return deviceClient.listDeviceAttr().getData(); + List list = deviceClient.listDeviceAttr().getData(); + if (null != list && !list.isEmpty()) { + list.forEach(item -> { + item.setItemName(item.getProjectName() + " " + item.getDeviceName() + " " + item.getName()); + String rule = AccessRules.getDescByCode(item.getRule()); + if (null != rule) { + item.setRule(rule); + } + }); + } + return list; + } + + @Override + public List getDeviceFunc() { + List list = deviceClient.listDeviceFunc().getData(); + if (null != list && !list.isEmpty()) { + list.forEach(item -> { + item.setItemName(item.getProjectName() + " " + item.getDeviceName() + " " + item.getName()); + }); + } + return list; } }