From 20dc892fd72e5e9c19a5a5188f7daf9bcd87e0f0 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期五, 22 十一月 2024 09:57:41 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictAlarmMessageEntity.java | 5 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpApiService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java | 45 ++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigSaveReqVO.java | 65 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageRespVO.java | 61 +++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/SourceApiEnum.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java | 235 ++++++++-- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java | 29 - iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpApiServiceImpl.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmConfigController.java | 74 +++ iailab-module-model/iailab-module-model-biz/db/mysql.sql | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataQualityEnum.java | 37 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigRespVO.java | 66 +++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java | 5 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmConfigService.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java | 39 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java | 34 - iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollector.java | 48 ++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java | 74 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmMessageDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageSaveReqVO.java | 59 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java | 1 /dev/null | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmConfigServiceImpl.java | 44 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java | 30 - iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmConfigDao.java | 10 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigPageReqVO.java | 25 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java | 33 - 35 files changed, 1,013 insertions(+), 182 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollector.java new file mode 100644 index 0000000..94e86af --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollector.java @@ -0,0 +1,48 @@ +package com.iailab.module.data.channel.http.collector; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ + +import com.iailab.framework.common.constant.CommonConstant; +import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; +import com.iailab.module.data.channel.http.entity.HttpApiEntity; +import com.iailab.module.data.channel.http.service.HttpApiService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@Component +public class HttpCollector { + + @Autowired + private HttpApiService httpApiService; + + @Autowired + private HttpCollectorForIhd httpCollectorForIhd; + + public Object getTagValue(String apiId, String tag) { + HttpApiEntity httpApi = httpApiService.getFromCatch(apiId); + if (httpApi == null) { + return CommonConstant.BAD_VALUE; + } + List<String> tagNames = new ArrayList<>(); + tagNames.add(tag); + Map<String, Object> valueMap = new HashMap<String, Object>(); + if (SourceApiEnum.iHyperDB.getCode().equals(httpApi.getCode())) { + valueMap = httpCollectorForIhd.getLastValues(apiId, tagNames); + } + if (valueMap.get(tag) == null) { + return CommonConstant.BAD_VALUE; + } + return valueMap.get(tag); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/SourceApiEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/SourceApiEnum.java new file mode 100644 index 0000000..0022bd6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/SourceApiEnum.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.channel.http.collector; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Getter +@AllArgsConstructor +public enum SourceApiEnum { + iHyperDB("iHyperDB", "宝信IHD"); + + private String code; + private String desc; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java index 94cf2b9..ce58758 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java @@ -6,17 +6,11 @@ import com.google.gson.Gson; import com.iailab.framework.common.constant.CommonConstant; import com.iailab.module.data.channel.http.entity.HttpApiEntity; -import com.iailab.module.data.channel.http.entity.HttpTagEntity; import com.iailab.module.data.channel.http.service.HttpApiService; -import com.iailab.module.data.channel.http.service.HttpTagService; import com.iailab.module.data.common.enums.DataSourceType; import com.iailab.module.data.common.utils.DateUtils; import com.iailab.module.data.common.utils.HttpRequest; import com.iailab.module.data.common.utils.TagUtils; -import com.iailab.module.data.influxdb.pojo.InfluxPointValueBoolPOJO; -import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO; -import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; -import com.iailab.module.data.influxdb.pojo.InfluxPointValueStrPOJO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.BoundHashOperations; @@ -26,8 +20,14 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; import java.util.*; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * iHyperDB采集 @@ -39,7 +39,7 @@ @Slf4j @Component public class HttpCollectorForIhd { - private Map<String, HttpApiEntity> apiMap = new HashMap<>(); + private static Map<String, HttpApiEntity> apiMap = new HashMap<>(); @Autowired private HttpApiService httpApiService; @@ -47,12 +47,43 @@ @Autowired private RedisTemplate redisTemplate; - @Autowired - private HttpTagService httpTagService; + ThreadPoolExecutor threadPool = new ThreadPoolExecutor(18, 36, 30, TimeUnit.SECONDS, + new ArrayBlockingQueue<Runnable>(36), new ThreadPoolExecutor.AbortPolicy()); private static final String STA_TRUE = "true"; - private static final int GROUP_MAX_COUNT = 50; + private static final int GROUP_MAX_COUNT = 90; + + private static final int MAX_WAIT = 30; + + private static final String pattern = "yyyyMMddHHmm00"; + + private static final String IS_SUCCESS = "isSuccess"; + + /** + * tagName + */ + private static final String N = "n"; + + /** + * dimension + */ + private static final String D = "d"; + + /** + * 类型 + */ + private static final String P = "p"; + + /** + * dataValue + */ + private static final String V = "v"; + + /** + * dataTime + */ + private static final String T = "t"; private HttpApiEntity getHttpApi(String id) { if (apiMap.containsKey(id)) { @@ -69,29 +100,30 @@ StringBuilder tagSb = new StringBuilder(); tagSb.append("["); Map<String, Object> queryParams = new HashMap<>(); - queryParams.put("datatype", valueType); - queryParams.put("dimension", dimension); - queryParams.put("tagname", tagNo); + queryParams.put(P, valueType); + queryParams.put(D, dimension); + queryParams.put(N, tagNo); String jsonString = JSON.toJSONString(queryParams); tagSb.append(jsonString); tagSb.append("]"); - String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00"); + String currentDate = DateUtils.format(new Date(), pattern); String responseStr = HttpRequest.sendPost(httpApi.getUrl() + "/" + currentDate, tagSb.toString()); JSONObject responseObj = JSON.parseObject(responseStr); - if (STA_TRUE.equals(responseObj.get("isSuccess").toString())) { + if (STA_TRUE.equals(responseObj.get(IS_SUCCESS).toString())) { JSONArray tagValueList = responseObj.getJSONArray("data"); if (!CollectionUtils.isEmpty(tagValueList)) { for (int i = 0; i < tagValueList.size(); i++) { JSONObject item = tagValueList.getJSONObject(i); - value = new BigDecimal(item.get("value").toString()); + value = new BigDecimal(item.get(V).toString()); } } } return value; } - public Map<String, Object> getLastValues(List<String> tagNames) { + public Map<String, Object> getLastValues(String sourceId, List<String> tagNames) { Map<String, Object> result = new HashMap<>(); + HttpApiEntity httpApi = this.getHttpApi(sourceId); try { if (CollectionUtils.isEmpty(tagNames)) { return result; @@ -100,8 +132,8 @@ for (int i = 0; i < tagNames.size(); i++) { //先查缓存 BoundHashOperations<String, String, Object> ops = redisTemplate.boundHashOps(tagNames.get(i)); - if (ops.get("value") != null) { - BigDecimal value = new BigDecimal(ops.get("value").toString()); + if (ops.get(V) != null) { + BigDecimal value = new BigDecimal(ops.get(V).toString()); result.put(tagNames.get(i), value.setScale(3, RoundingMode.HALF_UP)); } else { noCacheTagNames.add(tagNames.get(i)); @@ -115,26 +147,26 @@ Gson gson = new Gson(); String tagSb = gson.toJson(noCacheTagNames); log.info("body=====" + tagSb); - String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00"); + String currentDate = DateUtils.format(new Date(), pattern); String responseStr = ""; - responseStr = HttpRequest.sendPost("http://172.16.59.105:9082/api/IHD/getPointslast" + "/" + currentDate, tagSb); + responseStr = HttpRequest.sendPost(httpApi.getUrl().replace("getPointdatasAvg", "getPointslast") + "/" + currentDate, tagSb); JSONObject responseObj = JSON.parseObject(responseStr); - if (STA_TRUE.equals(responseObj.get("isSuccess").toString())) { + if (STA_TRUE.equals(responseObj.get(IS_SUCCESS).toString())) { JSONArray tagValueList = responseObj.getJSONArray("data"); if (!CollectionUtils.isEmpty(tagValueList)) { for (int i = 0; i < tagValueList.size(); i++) { JSONObject item = tagValueList.getJSONObject(i); - if (item.get("value") != null) { + if (item.get(V) != null) { //存缓存 - BoundHashOperations<String, String, Object> ops = redisTemplate.boundHashOps(item.get("tagname").toString()); - ops.put("value", item.get("value").toString()); + BoundHashOperations<String, String, Object> ops = redisTemplate.boundHashOps(item.get(V).toString()); + ops.put(V, item.get(V).toString()); //设置过期时间 - redisTemplate.expire(item.get("tagname").toString(), 10, TimeUnit.SECONDS); + redisTemplate.expire(item.get(N).toString(), 10, TimeUnit.SECONDS); //把查询到的数据插入结果集 - BigDecimal value = new BigDecimal(item.get("value").toString()); - result.put(item.get("tagname").toString(), value.setScale(3, RoundingMode.HALF_UP)); + BigDecimal value = new BigDecimal(item.get(V).toString()); + result.put(item.get(N).toString(), value.setScale(3, RoundingMode.HALF_UP)); } else { - result.put(item.get("tagname").toString(), CommonConstant.BAD_VALUE); + result.put(item.get(N).toString(), CommonConstant.BAD_VALUE); } } } @@ -148,42 +180,127 @@ return result; } - public Map<String, Object> getTagValues(List<Object[]> params) { + public Map<String, Object> getTagValues(List<Object[]> params, Date collectTime) { + Map<String, Object> result = new HashMap<>(); if (CollectionUtils.isEmpty(params)) { return new HashMap<>(); } + try { + Map<Integer, List<Object[]>> measurePointsCountGroup = new HashMap<>(); + int pointListSize = params.size(); + int groupCount = pointListSize / GROUP_MAX_COUNT + ((pointListSize % GROUP_MAX_COUNT) > 0 ? 1 : 0); + log.info("groupCount=" + groupCount); + for (int i = 0; i < groupCount; i++) { + int end = (i + 1) * GROUP_MAX_COUNT; + if (end > pointListSize) { + end = pointListSize; + } + measurePointsCountGroup.put(i, params.subList(i * GROUP_MAX_COUNT, end)); + } + log.info("measurePointsCountGroup.size()=" + measurePointsCountGroup.size()); + result = new ConcurrentHashMap<>(params.size()); + CountDownLatch countDownLatch = new CountDownLatch(measurePointsCountGroup.size()); + for (Map.Entry<Integer, List<Object[]>> measurePointsItem : measurePointsCountGroup.entrySet()) { + HttpApiEntity httpApi = this.getHttpApi(measurePointsItem.getValue().get(0)[0].toString()); + // 并发 + Thread.sleep(200); + threadPool.submit(new Task(httpApi.getUrl(), httpApi.getCode(), result, measurePointsItem.getValue(), + collectTime, countDownLatch)); + // 顺序 + //this.getByHtp(result, measurePointsItem.getValue(), collectTime); + } + countDownLatch.await(MAX_WAIT, TimeUnit.SECONDS); - Map<Integer, List<Object[]>> measurePointsCountGroup = new HashMap<>(); - int pointListSize = params.size(); - int groupCount = pointListSize / GROUP_MAX_COUNT + ((pointListSize % GROUP_MAX_COUNT) > 0 ? 1 : 0); - log.info("groupCount=" + groupCount); - for (int i = 0; i < groupCount; i++) { - int end = (i + 1) * GROUP_MAX_COUNT; - if (end > pointListSize) { - end = pointListSize; - } - measurePointsCountGroup.put(i, params.subList(i * GROUP_MAX_COUNT, end)); - } - Map<String, Object> result = new HashMap<>(params.size()); - for (Map.Entry<Integer, List<Object[]>> measurePointsItem : measurePointsCountGroup.entrySet()) { - try { - getByHtp(result, measurePointsItem.getValue()); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } return result; } - private void getByHtp(Map<String, Object> result, List<Object[]> params) { - HttpApiEntity httpApi = this.getHttpApi(params.get(0)[0].toString()); + /** + * 异步采集任务 + */ + private class Task implements Runnable { + String url; + String sourceName; + Date collectTime; + Map<String, Object> result; + List<Object[]> params; + CountDownLatch countDownLatch; + + public Task(String url, String sourceName, Map<String, Object> result, List<Object[]> params, + Date collectTime, CountDownLatch countDownLatch) { + this.url = url; + this.sourceName = sourceName; + this.result = result; + this.collectTime = collectTime; + this.params = params; + this.countDownLatch = countDownLatch; + } + + @Override + public void run() { + try { + log.info("请求的Tag数量:" + params.size()); + this.getByHtp(url, sourceName, result, params, collectTime); + log.info("请求结束:url=" + url); + } catch (Exception ex) { + log.info("获取采集值失败," + ex.getMessage()); + ex.printStackTrace(); + } finally { + countDownLatch.countDown(); + } + } + + /** + * getTagDataByHttp + * + * @param url + * @param sourceName + * @param result + * @param params + * @param collectTime + */ + private void getByHtp(String url, String sourceName, Map<String, Object> result, List<Object[]> params, Date collectTime) { + StringBuilder tagSb = new StringBuilder(); + tagSb.append("["); + for (int i = 0; i < params.size(); i++) { + Map<String, Object> queryParams = new HashMap<>(); + queryParams.put(N, params.get(i)[1]); + queryParams.put(D, params.get(i)[2]); + queryParams.put(P, params.get(i)[3]); + String jsonString = JSON.toJSONString(queryParams); + tagSb.append(jsonString); + if (i < params.size() - 1) { + tagSb.append(","); + } + } + tagSb.append("]"); + log.info("body=====" + tagSb); + String currentDate = DateUtils.format(collectTime, pattern); + String responseStr = HttpRequest.sendPost(url + "/" + currentDate, tagSb.toString()); + JSONObject responseObj = JSON.parseObject(responseStr); + log.info("responseObj=====" + responseObj.toJSONString()); + if (STA_TRUE.equals(responseObj.get(IS_SUCCESS).toString())) { + JSONArray tagValueList = responseObj.getJSONArray("data"); + if (!CollectionUtils.isEmpty(tagValueList)) { + for (int i = 0; i < tagValueList.size(); i++) { + JSONObject item = tagValueList.getJSONObject(i); + result.put(TagUtils.genTagId(DataSourceType.HTTP.getCode(), sourceName, item.get(N).toString()), item.get(V)); + } + } + } + } + } + + private void getByHtp(String url, String sourceName, Map<String, Object> result, List<Object[]> params, Date collectTime) { StringBuilder tagSb = new StringBuilder(); tagSb.append("["); for (int i = 0; i < params.size(); i++) { Map<String, Object> queryParams = new HashMap<>(); - queryParams.put("tagname", params.get(i)[1]); - queryParams.put("dimension", params.get(i)[2]); - queryParams.put("datatype", params.get(i)[3]); + queryParams.put(N, params.get(i)[1]); + queryParams.put(D, params.get(i)[2]); + queryParams.put(P, params.get(i)[3]); String jsonString = JSON.toJSONString(queryParams); tagSb.append(jsonString); if (i < params.size() - 1) { @@ -191,17 +308,17 @@ } } tagSb.append("]"); - log.info("body=====" + tagSb.toString()); - String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00"); - String responseStr = HttpRequest.sendPost(httpApi.getUrl() + "/" + currentDate, tagSb.toString()); + log.info("body=====" + tagSb); + String currentDate = DateUtils.format(collectTime, pattern); + String responseStr = HttpRequest.sendPost(url + "/" + currentDate, tagSb.toString()); JSONObject responseObj = JSON.parseObject(responseStr); log.info("responseObj=====" + responseObj.toJSONString()); - if (STA_TRUE.equals(responseObj.get("isSuccess").toString())) { + if (STA_TRUE.equals(responseObj.get(IS_SUCCESS).toString())) { JSONArray tagValueList = responseObj.getJSONArray("data"); if (!CollectionUtils.isEmpty(tagValueList)) { for (int i = 0; i < tagValueList.size(); i++) { JSONObject item = tagValueList.getJSONObject(i); - result.put(TagUtils.genTagId(DataSourceType.HTTP.getCode(), httpApi.getCode(), item.get("tagname").toString()), item.get("value")); + result.put(TagUtils.genTagId(DataSourceType.HTTP.getCode(), sourceName, item.get(N).toString()), item.get(V)); } } } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/package-info.java deleted file mode 100644 index 77e2f4b..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.iailab.module.data.channel.http.collector; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java index c296722..0731d9e 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java @@ -7,7 +7,7 @@ import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; -import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; +import com.iailab.module.data.channel.http.collector.HttpCollector; import com.iailab.module.data.channel.http.entity.HttpTagEntity; import com.iailab.module.data.channel.http.service.HttpTagService; import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO; @@ -15,6 +15,7 @@ import com.iailab.module.data.channel.tag.vo.TagExportExcelVO; import com.iailab.module.data.channel.tag.vo.TagImportExcelVO; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; +import com.iailab.module.data.common.enums.DataQualityEnum; import com.iailab.module.data.common.enums.IsEnableEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -29,7 +30,6 @@ import javax.validation.Valid; import java.io.IOException; import java.util.*; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -47,29 +47,19 @@ private HttpTagService tagService; @Resource - private HttpCollectorForIhd httpCollectorForIhd; + private HttpCollector httpCollector; @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("page") public CommonResult<PageResult<HttpTagRespVO>> page(@Valid HttpTagPageReqVO reqVO) { - PageResult<HttpTagEntity> page = tagService.queryPage(reqVO); - PageResult<HttpTagRespVO> pageResultVO = new PageResult<>(); - List<String> tagNames = page.getList().stream() - .map(HttpTagEntity::getTagName) - .collect(Collectors.toList()); - Map<String, Object> dataMap = httpCollectorForIhd.getLastValues(tagNames); - - List<HttpTagRespVO> vos = page.getList().stream().map(entity -> { - - HttpTagRespVO vo = BeanUtils.toBean(entity,HttpTagRespVO.class); - vo.setDataValue(Double.parseDouble(dataMap.get(entity.getTagName()).toString())); - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<HttpTagRespVO> pageResult = BeanUtils.toBean(page, HttpTagRespVO.class); + pageResult.getList().forEach(item -> { + item.setDataValue(httpCollector.getTagValue(item.getApiId(), item.getTagName())); + item.setDataTime(new Date()); + item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); + }); + return success(pageResult); } @PreAuthorize("@ss.hasPermission('data:channel-http:query')") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpApiService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpApiService.java index 57a7cb8..52ab2b1 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpApiService.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpApiService.java @@ -19,5 +19,7 @@ HttpApiEntity getByCode(String code); + HttpApiEntity getFromCatch(String id); + List<HttpApiEntity> list(); } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpApiServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpApiServiceImpl.java index d712f46..c6571a6 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpApiServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpApiServiceImpl.java @@ -11,12 +11,17 @@ import javax.annotation.Resource; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @Service public class HttpApiServiceImpl extends ServiceImpl<HttpApiDao, HttpApiEntity> implements HttpApiService { @Resource private HttpApiDao httpApiDao; + + + private static Map<String, HttpApiEntity> idMap = new ConcurrentHashMap<>(); @Override public PageResult<HttpApiEntity> queryPage(HttpApiPageReqVO reqVO) { @@ -49,6 +54,19 @@ } @Override + public HttpApiEntity getFromCatch(String id) { + if (idMap.containsKey(id)) { + return idMap.get(id); + } + HttpApiEntity entity = httpApiDao.selectById(id); + if (entity == null) { + return null; + } + idMap.put(id, entity); + return idMap.get(id); + } + + @Override public List<HttpApiEntity> list() { return httpApiDao.selectList(new QueryWrapper<>()); } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java index 2baca7c..1891995 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java @@ -2,6 +2,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -43,7 +44,16 @@ @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("数据值") - private Double dataValue; + private Object dataValue; + + @Schema(description = "数据质量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据质量") + private String dataQuality; + + @Schema(description = "数据时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date dataTime; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("创建时间") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java index 02b60d5..f0b2ce7 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java @@ -8,8 +8,6 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.kio.collector.KingIOCollector; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; import com.iailab.module.data.channel.kio.service.ChannelKioTagService; import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO; @@ -17,6 +15,7 @@ import com.iailab.module.data.channel.tag.vo.TagExportExcelVO; import com.iailab.module.data.channel.tag.vo.TagImportExcelVO; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; +import com.iailab.module.data.common.enums.DataQualityEnum; import com.iailab.module.data.common.enums.IsEnableEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -34,7 +33,6 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -57,25 +55,14 @@ @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") @GetMapping("page") public CommonResult<PageResult<KioTagRespVO>> page(@Valid KioTagPageReqVO reqVO){ - PageResult<ChannelKioTagEntity> page = channelKioTagService.queryPage(reqVO); - PageResult<KioTagRespVO> pageResultVO = new PageResult<>(); - pageResultVO.setTotal(page.getTotal()); - - List<KioTagRespVO> vos = page.getList().stream().map(entity -> { - - KioTagRespVO vo = BeanUtils.toBean(entity,KioTagRespVO.class); - try { - vo.setDataValue(Double.parseDouble(kingIOCollector.getTagValue(reqVO.getDeviceId(), entity.getTagName()))); - }catch (Exception e){ - e.printStackTrace(); - } - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<KioTagRespVO> pageResult = BeanUtils.toBean(page, KioTagRespVO.class); + pageResult.getList().forEach(item -> { + item.setDataValue(kingIOCollector.getTagValue(item.getDevice(), item.getTagName())); + item.setDataTime(new Date()); + item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); + }); + return success(pageResult); } @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java index e80a47a..4f359b6 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java @@ -2,6 +2,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -43,7 +44,16 @@ @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("数据值") - private Double dataValue; + private Object dataValue; + + @Schema(description = "数据质量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据质量") + private String dataQuality; + + @Schema(description = "数据时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date dataTime; @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("关联设备") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java index e97669d..ec6ade8 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java @@ -9,13 +9,13 @@ import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.modbus.collector.ModBusCollector; import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; -import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; import com.iailab.module.data.channel.modbus.vo.ModBusTagExportExcelVO; import com.iailab.module.data.channel.modbus.vo.ModBusTagImportExcelVO; import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO; import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; +import com.iailab.module.data.common.enums.DataQualityEnum; import com.iailab.module.data.common.enums.IsEnableEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -28,13 +28,11 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.util.ArrayList; import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -56,20 +54,15 @@ @GetMapping("/page") public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) { PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO); - PageResult<ModBusTagRespVO> pageResultVO = new PageResult<>(); - pageResultVO.setTotal(page.getTotal()); - - List<ModBusTagRespVO> vos = page.getList().stream().map(entity -> { - - ModBusTagRespVO vo = BeanUtils.toBean(entity,ModBusTagRespVO.class); - vo.setDataValue(modBusCollector.getTagValue(entity.getDevice(),entity.getTagName())); - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<ModBusTagRespVO> pageResult = BeanUtils.toBean(page, ModBusTagRespVO.class); + pageResult.getList().forEach(item -> { + item.setDataValue(modBusCollector.getTagValue(reqVO.getDeviceId(), item.getTagName())); + item.setDataTime(new Date()); + item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); + }); + return success(pageResult); } + /** * 根据id查询设备详情 * @@ -141,7 +134,7 @@ .build() ); // 输出 - ExcelUtils.write(response, "tag导入模板.xls", "tag列表", ModBusTagImportExcelVO.class, list,true); + ExcelUtils.write(response, "tag导入模板.xls", "tag列表", ModBusTagImportExcelVO.class, list, true); } @PostMapping("/import") @@ -155,6 +148,6 @@ @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport, @RequestParam("device") String device) throws Exception { List<ModBusTagImportExcelVO> list = ExcelUtils.read(file, ModBusTagImportExcelVO.class); - return success(channelModbusTagService.importModBusTagList(list, updateSupport,device)); + return success(channelModbusTagService.importModBusTagList(list, updateSupport, device)); } } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java index 6596d7a..b34ace9 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java @@ -2,6 +2,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -64,4 +65,13 @@ @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("更新时间") private Date updateTime; + + @Schema(description = "数据质量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据质量") + private String dataQuality; + + @Schema(description = "数据时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date dataTime; } \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java index 7a11afc..56aded4 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java @@ -5,22 +5,17 @@ import com.iailab.framework.common.pojo.PageParam; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; -import com.iailab.module.data.channel.opcda.collector.OpcDACollector; -import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity; -import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService; import com.iailab.module.data.channel.opcda.service.ChannelOPCDATagService; import com.iailab.module.data.channel.opcda.vo.OpcDaTagExportExcelVO; import com.iailab.module.data.channel.opcda.vo.OpcDaTagImportExcelVO; import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO; import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO; -import com.iailab.module.data.common.enums.DataSourceType; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; import com.iailab.module.data.common.enums.IsEnableEnum; import com.iailab.module.data.common.exception.RRException; -import com.iailab.module.data.common.utils.TagUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -32,13 +27,11 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.util.ArrayList; import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -55,34 +48,12 @@ @Autowired private ChannelOPCDATagService channelOPCDATagService; - @Autowired - private OpcDACollector opcDACollector; - - @Autowired - private ChannelOPCDADeviceService channelOPCDADeviceService; - @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')") @GetMapping("page") public CommonResult<PageResult<OpcDaTagRespVO>> list(@Valid OpcDaTagPageReqVO reqVO) { - PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO); - PageResult<OpcDaTagRespVO> pageResultVO = new PageResult<>(); - pageResultVO.setTotal(page.getTotal()); - - List<OpcDaTagRespVO> vos = page.getList().stream().map(entity -> { - - OpcDaTagRespVO vo = BeanUtils.toBean(entity,OpcDaTagRespVO.class); - List<String[]> tags = new ArrayList<>(); - String[] array = {reqVO.getServerId(),entity.getTagName()}; - tags.add(array); - ChannelOPCDADeviceEntity OPCDADevice = channelOPCDADeviceService.info(reqVO.getServerId()); - vo.setDataValue(Double.parseDouble(opcDACollector.getTagValues(tags).get(TagUtils.genTagId(DataSourceType.OPCDA.getCode(), OPCDADevice.getServerName(),entity.getTagName())).toString())); - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<OpcDaTagRespVO> pageResult = BeanUtils.toBean(page, OpcDaTagRespVO.class); + return success(pageResult); } @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java index f8c0ea7..d155b0f 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java @@ -2,6 +2,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -52,4 +53,13 @@ @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("更新时间") private Date updateTime; + + @Schema(description = "数据质量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据质量") + private String dataQuality; + + @Schema(description = "数据时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date dataTime; } \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java index bca1e0b..8c85b89 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java @@ -8,8 +8,6 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; import com.iailab.module.data.channel.opcua.vo.OpcUaTagExportExcelVO; @@ -17,6 +15,7 @@ import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO; import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; +import com.iailab.module.data.common.enums.DataQualityEnum; import com.iailab.module.data.common.enums.IsEnableEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -34,13 +33,13 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; /** * 操作opcua tag配置 + * * @author lirm * @Description * @createTime 2024年08月26日 @@ -57,25 +56,14 @@ @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { - PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); - PageResult<OpcUaTagRespVO> pageResultVO = new PageResult<>(); - pageResultVO.setTotal(page.getTotal()); - - List<OpcUaTagRespVO> vos = page.getList().stream().map(entity -> { - - OpcUaTagRespVO vo = BeanUtils.toBean(entity,OpcUaTagRespVO.class); - try{ - vo.setDataValue( Double.parseDouble(opcUaCollector.getTagValue(reqVO.getDeviceId(),entity.getTagName()))); - }catch (Exception e){ - e.printStackTrace(); - } - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<OpcUaTagRespVO> pageResult = BeanUtils.toBean(page, OpcUaTagRespVO.class); + pageResult.getList().forEach(item -> { + item.setDataValue(opcUaCollector.getTagValue(reqVO.getDeviceId(), item.getTagName())); + item.setDataTime(new Date()); + item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); + }); + return success(pageResult); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @@ -130,7 +118,7 @@ .build() ); // 输出 - ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcUaTagImportExcelVO.class, list,true); + ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcUaTagImportExcelVO.class, list, true); } @PostMapping("/import") @@ -144,6 +132,6 @@ @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport, @RequestParam("device") String device) throws Exception { List<OpcUaTagImportExcelVO> list = ExcelUtils.read(file, OpcUaTagImportExcelVO.class); - return success(channelOpcuaTagService.importOpcUaTagList(list, updateSupport,device)); + return success(channelOpcuaTagService.importOpcUaTagList(list, updateSupport, device)); } } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java index bf91151..33c7305 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java @@ -2,6 +2,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -35,7 +36,16 @@ @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("数据值") - private Double dataValue; + private Object dataValue; + + @Schema(description = "数据质量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据质量") + private String dataQuality; + + @Schema(description = "数据时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date dataTime; @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("关联设备") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java index 45047bb..d2a80b7 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java @@ -14,5 +14,6 @@ BigDecimal ZERO_VALUE = new BigDecimal("0"); + // 宝信IHD String iHyperDB = "iHyperDB"; } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataQualityEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataQualityEnum.java new file mode 100644 index 0000000..50c7860 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataQualityEnum.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Getter +@AllArgsConstructor +public enum DataQualityEnum { + GOOD("Good", "Good"), + + BAD("Bad", "Bad"); + + private String code; + private String desc; + + public static DataQualityEnum getEumByValue(Object value) { + if (value == null) { + return BAD; + } else if (value instanceof Number) { + if (new BigDecimal(((Number) value).doubleValue()).compareTo(CommonConstant.BAD_VALUE) == 0) { + return BAD; + } + } else if (value instanceof String) { + if (value.toString().equals(CommonConstant.BAD_VALUE.toString())) { + return BAD; + } + } + return GOOD; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java index 41299ec..4d781a1 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java @@ -1,5 +1,6 @@ package com.iailab.module.data.point.collection.handler; +import com.iailab.module.data.channel.http.collector.SourceApiEnum; import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; import com.iailab.module.data.channel.opcda.collector.OpcDACollector; import com.iailab.module.data.common.enums.CommonConstant; @@ -81,7 +82,7 @@ } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) { kioTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) { - if (CommonConstant.iHyperDB.equals(item.getSourceName())) { + if (SourceApiEnum.iHyperDB.getCode().equals(item.getSourceName())) { httpTagIhd.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()}); } } @@ -101,7 +102,7 @@ tagValues.putAll(kingIOCollector.getTagValues(kioTagIds)); } if (!CollectionUtils.isEmpty(httpTagIhd)) { - tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd)); + tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd, collectTime)); } this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); log.info("测量点处理结束"); diff --git a/iailab-module-model/iailab-module-model-biz/db/mysql.sql b/iailab-module-model/iailab-module-model-biz/db/mysql.sql index 59662c5..649f596 100644 --- a/iailab-module-model/iailab-module-model-biz/db/mysql.sql +++ b/iailab-module-model/iailab-module-model-biz/db/mysql.sql @@ -236,6 +236,7 @@ create table t_mm_predict_alarm_message ( id varchar(36) not null, + config_id varchar(36) COMMENT '配置ID', title varchar(36) COMMENT '消息标题', content varchar(128) COMMENT '消息内容', alarm_obj varchar(36) COMMENT '监控对象', @@ -250,6 +251,7 @@ create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', primary key (id), INDEX idx_item_id (item_id), + INDEX idx_config_id (config_id), INDEX idx_alarm_obj (alarm_obj), INDEX idx_alarm_time (alarm_time) ) engine = innodb diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmConfigController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmConfigController.java new file mode 100644 index 0000000..26c1675 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmConfigController.java @@ -0,0 +1,74 @@ +package com.iailab.module.model.mcs.pre.controller.admin; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; +import com.iailab.module.model.mcs.pre.service.MmPredictAlarmConfigService; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigPageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigRespVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigSaveReqVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@RestController +@RequestMapping("/model/pre/alarm-config") +public class MmPredictAlarmConfigController { + + @Autowired + private MmPredictAlarmConfigService mmPredictAlarmConfigService; + + @PostMapping("/create") + @Operation(summary = "创建预警配置") + @PreAuthorize("@ss.hasPermission('pre:alarm-config:create')") + public CommonResult<Boolean> create(@Valid @RequestBody MmPredictAlarmConfigSaveReqVO createReqVO) { + mmPredictAlarmConfigService.create(createReqVO); + return success(true); + } + + @PutMapping("/update") + @Operation(summary = "更新预警配置") + @PreAuthorize("@ss.hasPermission('pre:alarm-config:update')") + public CommonResult<Boolean> update(@Valid @RequestBody MmPredictAlarmConfigSaveReqVO updateReqVO) { + mmPredictAlarmConfigService.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除预警配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('pre:alarm-config:delete')") + public CommonResult<Boolean> deleteTenant(@RequestParam("id") String id) { + mmPredictAlarmConfigService.delete(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得预警配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('pre:alarm-config:query')") + public CommonResult<MmPredictAlarmConfigRespVO> getInfo(@RequestParam("id") String id) { + MmPredictAlarmConfigEntity entity = mmPredictAlarmConfigService.getInfo(id); + return success(BeanUtils.toBean(entity, MmPredictAlarmConfigRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得预警配置分页") + @PreAuthorize("@ss.hasPermission('pre:alarm-config:query')") + public CommonResult<PageResult<MmPredictAlarmConfigRespVO>> getTenantPage(@Valid MmPredictAlarmConfigPageReqVO pageVO) { + PageResult<MmPredictAlarmConfigEntity> pageResult = mmPredictAlarmConfigService.page(pageVO); + return success(BeanUtils.toBean(pageResult, MmPredictAlarmConfigRespVO.class)); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java new file mode 100644 index 0000000..952913c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java @@ -0,0 +1,74 @@ +package com.iailab.module.model.mcs.pre.controller.admin; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; +import com.iailab.module.model.mcs.pre.service.MmPredictAlarmMessageService; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageRespVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@RestController +@RequestMapping("/model/pre/alarm-message") +public class MmPredictAlarmMessageController { + + @Autowired + private MmPredictAlarmMessageService mmPredictAlarmMessageService; + + @PostMapping("/create") + @Operation(summary = "创建预警消息") + @PreAuthorize("@ss.hasPermission('pre:alarm-message:create')") + public CommonResult<Boolean> create(@Valid @RequestBody MmPredictAlarmMessageSaveReqVO createReqVO) { + mmPredictAlarmMessageService.create(createReqVO); + return success(true); + } + + @PutMapping("/update") + @Operation(summary = "更新预警消息") + @PreAuthorize("@ss.hasPermission('pre:alarm-message:update')") + public CommonResult<Boolean> update(@Valid @RequestBody MmPredictAlarmMessageSaveReqVO updateReqVO) { + mmPredictAlarmMessageService.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除预警消息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('pre:alarm-message:delete')") + public CommonResult<Boolean> deleteTenant(@RequestParam("id") String id) { + mmPredictAlarmMessageService.delete(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得预警消息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('pre:alarm-message:query')") + public CommonResult<MmPredictAlarmMessageRespVO> getInfo(@RequestParam("id") String id) { + MmPredictAlarmMessageEntity entity = mmPredictAlarmMessageService.getInfo(id); + return success(BeanUtils.toBean(entity, MmPredictAlarmMessageRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得预警消息分页") + @PreAuthorize("@ss.hasPermission('pre:alarm-message:query')") + public CommonResult<PageResult<MmPredictAlarmMessageRespVO>> getTenantPage(@Valid MmPredictAlarmMessagePageReqVO pageVO) { + PageResult<MmPredictAlarmMessageEntity> pageResult = mmPredictAlarmMessageService.page(pageVO); + return success(BeanUtils.toBean(pageResult, MmPredictAlarmMessageRespVO.class)); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmConfigDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmConfigDao.java index 2fc2bb5..47fe438 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmConfigDao.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmConfigDao.java @@ -1,8 +1,11 @@ package com.iailab.module.model.mcs.pre.dao; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigPageReqVO; import org.apache.ibatis.annotations.Mapper; /** @@ -13,4 +16,11 @@ @TenantDS @Mapper public interface MmPredictAlarmConfigDao extends BaseMapperX<MmPredictAlarmConfigEntity> { + + default PageResult<MmPredictAlarmConfigEntity> selectPage(MmPredictAlarmConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<MmPredictAlarmConfigEntity>() + .likeIfPresent(MmPredictAlarmConfigEntity::getTitle, reqVO.getTitle()) + .likeIfPresent(MmPredictAlarmConfigEntity::getAlarmObj, reqVO.getAlarmObj()) + .orderByDesc(MmPredictAlarmConfigEntity::getCreateTime)); + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmMessageDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmMessageDao.java index b31aef2..4fb7078 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmMessageDao.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmPredictAlarmMessageDao.java @@ -1,8 +1,11 @@ package com.iailab.module.model.mcs.pre.dao; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; import org.apache.ibatis.annotations.Mapper; /** @@ -13,4 +16,15 @@ @TenantDS @Mapper public interface MmPredictAlarmMessageDao extends BaseMapperX<MmPredictAlarmMessageEntity> { + + default PageResult<MmPredictAlarmMessageEntity> selectPage(MmPredictAlarmMessagePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<MmPredictAlarmMessageEntity>() + .eqIfPresent(MmPredictAlarmMessageEntity::getConfigId, reqVO.getConfigId()) + .likeIfPresent(MmPredictAlarmMessageEntity::getTitle, reqVO.getTitle()) + .eqIfPresent(MmPredictAlarmMessageEntity::getAlarmObj, reqVO.getAlarmObj()) + .likeIfPresent(MmPredictAlarmMessageEntity::getContent, reqVO.getContent()) + .geIfPresent(MmPredictAlarmMessageEntity::getAlarmTime, reqVO.getStartTime()) + .leIfPresent(MmPredictAlarmMessageEntity::getAlarmTime, reqVO.getEndTime()) + .orderByDesc(MmPredictAlarmMessageEntity::getCreateTime)); + } } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictAlarmMessageEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictAlarmMessageEntity.java index 8615f1f..249378f 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictAlarmMessageEntity.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmPredictAlarmMessageEntity.java @@ -26,6 +26,11 @@ private String id; /** + * 配置ID + */ + private String configId; + + /** * 消息标题 */ private String title; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmConfigService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmConfigService.java index 594aa76..9bc8319 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmConfigService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmConfigService.java @@ -1,9 +1,25 @@ package com.iailab.module.model.mcs.pre.service; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigPageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigSaveReqVO; + /** * @author PanZhibao * @Description * @createTime 2024年11月19日 */ -public interface MmPredictAlarmConfigService { +public interface MmPredictAlarmConfigService extends BaseService<MmPredictAlarmConfigEntity> { + + PageResult<MmPredictAlarmConfigEntity> page(MmPredictAlarmConfigPageReqVO reqVO); + + MmPredictAlarmConfigEntity getInfo(String id); + + void create(MmPredictAlarmConfigSaveReqVO reqVO); + + void update(MmPredictAlarmConfigSaveReqVO reqVO); + + void delete(String id); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java index 12f1cf4..3e1485e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java @@ -1,9 +1,25 @@ package com.iailab.module.model.mcs.pre.service; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; + /** * @author PanZhibao * @Description * @createTime 2024年11月19日 */ -public interface MmPredictAlarmMessageService { +public interface MmPredictAlarmMessageService extends BaseService<MmPredictAlarmMessageEntity> { + + PageResult<MmPredictAlarmMessageEntity> page(MmPredictAlarmMessagePageReqVO reqVO); + + MmPredictAlarmMessageEntity getInfo(String id); + + void create(MmPredictAlarmMessageSaveReqVO reqVO); + + void update(MmPredictAlarmMessageSaveReqVO reqVO); + + void delete(String id); } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmConfigServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmConfigServiceImpl.java index 12b29de..6536a6c 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmConfigServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmConfigServiceImpl.java @@ -1,11 +1,53 @@ package com.iailab.module.model.mcs.pre.service.impl; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.model.mcs.pre.dao.MmPredictAlarmConfigDao; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; import com.iailab.module.model.mcs.pre.service.MmPredictAlarmConfigService; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigPageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigSaveReqVO; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2024年11月19日 */ -public class MmPredictAlarmConfigServiceImpl implements MmPredictAlarmConfigService { +@Service +public class MmPredictAlarmConfigServiceImpl extends BaseServiceImpl<MmPredictAlarmConfigDao, MmPredictAlarmConfigEntity> + implements MmPredictAlarmConfigService { + + @Override + public PageResult<MmPredictAlarmConfigEntity> page(MmPredictAlarmConfigPageReqVO reqVO) { + return baseDao.selectPage(reqVO); + } + + @Override + public MmPredictAlarmConfigEntity getInfo(String id) { + return baseDao.selectById(id); + } + + @Override + public void create(MmPredictAlarmConfigSaveReqVO reqVO) { + MmPredictAlarmConfigEntity entity = BeanUtils.toBean(reqVO, MmPredictAlarmConfigEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateTime(new Date()); + baseDao.insert(entity); + } + + @Override + public void update(MmPredictAlarmConfigSaveReqVO reqVO) { + MmPredictAlarmConfigEntity entity = BeanUtils.toBean(reqVO, MmPredictAlarmConfigEntity.class); + baseDao.updateById(entity); + } + + @Override + public void delete(String id) { + baseDao.deleteById(id); + } } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java index 8a475cc..33da851 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java @@ -1,11 +1,54 @@ package com.iailab.module.model.mcs.pre.service.impl; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.model.mcs.pre.dao.MmPredictAlarmMessageDao; +import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; import com.iailab.module.model.mcs.pre.service.MmPredictAlarmMessageService; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2024年11月19日 */ -public class MmPredictAlarmMessageServiceImpl implements MmPredictAlarmMessageService { +@Service +public class MmPredictAlarmMessageServiceImpl extends BaseServiceImpl<MmPredictAlarmMessageDao, MmPredictAlarmMessageEntity> + implements MmPredictAlarmMessageService { + + + @Override + public PageResult<MmPredictAlarmMessageEntity> page(MmPredictAlarmMessagePageReqVO reqVO) { + return baseDao.selectPage(reqVO); + } + + @Override + public MmPredictAlarmMessageEntity getInfo(String id) { + return baseDao.selectById(id); + } + + @Override + public void create(MmPredictAlarmMessageSaveReqVO reqVO) { + MmPredictAlarmMessageEntity entity = BeanUtils.toBean(reqVO, MmPredictAlarmMessageEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateTime(new Date()); + baseDao.insert(entity); + } + + @Override + public void update(MmPredictAlarmMessageSaveReqVO reqVO) { + MmPredictAlarmMessageEntity entity = BeanUtils.toBean(reqVO, MmPredictAlarmMessageEntity.class); + baseDao.updateById(entity); + } + + @Override + public void delete(String id) { + baseDao.deleteById(id); + } } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigPageReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigPageReqVO.java new file mode 100644 index 0000000..4630825 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigPageReqVO.java @@ -0,0 +1,25 @@ +package com.iailab.module.model.mcs.pre.vo; + +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型平台 - Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MmPredictAlarmConfigPageReqVO extends PageParam { + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "监控对象") + private String alarmObj; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigRespVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigRespVO.java new file mode 100644 index 0000000..5807ec9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigRespVO.java @@ -0,0 +1,66 @@ +package com.iailab.module.model.mcs.pre.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型服务 - 预警配置 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MmPredictAlarmConfigRespVO { + @Schema(description = "ID") + private String id; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "监控对象") + private String alarmObj; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "输出ID") + private String outId; + + @Schema(description = "比较长度") + private Integer compLength; + + @Schema(description = "上限") + private BigDecimal upperLimit; + + @Schema(description = "下限") + private BigDecimal lowerLimit; + + @Schema(description = "单位") + private String unit; + + @Schema(description = "转换系数") + private BigDecimal coefficient; + + @Schema(description = "调度方案") + private String scheduleId; + + @Schema(description = "是否启用(0禁用 1启用)") + private Integer isEnable; + + @Schema(description = "创建者") + private String creator; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "更新者") + private String updater; + + @Schema(description = "更新时间") + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigSaveReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigSaveReqVO.java new file mode 100644 index 0000000..d31ca3a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmConfigSaveReqVO.java @@ -0,0 +1,65 @@ +package com.iailab.module.model.mcs.pre.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型服务 - 预警信息创建/修改 Request VO") +@Data +public class MmPredictAlarmConfigSaveReqVO { + + @Schema(description = "ID") + private String id; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "监控对象") + private String alarmObj; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "输出ID") + private String outId; + + @Schema(description = "比较长度") + private Integer compLength; + + @Schema(description = "上限") + private BigDecimal upperLimit; + + @Schema(description = "下限") + private BigDecimal lowerLimit; + + @Schema(description = "单位") + private String unit; + + @Schema(description = "转换系数") + private BigDecimal coefficient; + + @Schema(description = "调度方案") + private String scheduleId; + + @Schema(description = "是否启用(0禁用 1启用)") + private Integer isEnable; + + @Schema(description = "创建者") + private String creator; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "更新者") + private String updater; + + @Schema(description = "更新时间") + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java new file mode 100644 index 0000000..e4e0f8b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java @@ -0,0 +1,39 @@ +package com.iailab.module.model.mcs.pre.vo; + +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型平台 - Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MmPredictAlarmMessagePageReqVO extends PageParam { + + @Schema(description = "配置ID", example = "") + private String configId; + + @Schema(description = "消息标题", example = "") + private String title; + + @Schema(description = "消息内容", example = "") + private String content; + + @Schema(description = "监控对象", example = "") + private String alarmObj; + + @Schema(description = "开始时间", example = "") + private Date startTime; + + @Schema(description = "结束时间", example = "") + private Date endTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageRespVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageRespVO.java new file mode 100644 index 0000000..fabd0ef --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageRespVO.java @@ -0,0 +1,61 @@ +package com.iailab.module.model.mcs.pre.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型服务 - 预警消息 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MmPredictAlarmMessageRespVO { + + @Schema(description = "ID") + private String id; + + @Schema(description = "配置ID") + private String configId; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "消息内容") + private String content; + + @Schema(description = "监控对象") + private String alarmObj; + + @Schema(description = "监控点位ID") + private String pointId; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "输出ID") + private String outId; + + @Schema(description = "当前值") + private BigDecimal currentValue; + + @Schema(description = "超出时间") + private Date outTime; + + @Schema(description = "超出值") + private BigDecimal outValue; + + @Schema(description = "预警类型") + private String alarmType; + + @Schema(description = "预警时间") + private Date alarmTime; + + @Schema(description = "创建时间") + private Date createTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageSaveReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageSaveReqVO.java new file mode 100644 index 0000000..7fd678d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessageSaveReqVO.java @@ -0,0 +1,59 @@ +package com.iailab.module.model.mcs.pre.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月20日 + */ +@Schema(description = "模型服务 - 预警信息创建/修改 Request VO") +@Data +public class MmPredictAlarmMessageSaveReqVO { + + @Schema(description = "ID") + private String id; + + @Schema(description = "配置ID") + private String configId; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "消息内容") + private String content; + + @Schema(description = "监控对象") + private String alarmObj; + + @Schema(description = "监控点位ID") + private String pointId; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "输出ID") + private String outId; + + @Schema(description = "当前值") + private BigDecimal currentValue; + + @Schema(description = "超出时间") + private Date outTime; + + @Schema(description = "超出值") + private BigDecimal outValue; + + @Schema(description = "预警类型") + private String alarmType; + + @Schema(description = "预警时间") + private Date alarmTime; + + @Schema(description = "创建时间") + private Date createTime; +} \ No newline at end of file -- Gitblit v1.9.3