|
|
@@ -3,6 +3,7 @@ package com.yunfeiyun.agmp.iot.common.constant.device;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.yunfeiyun.agmp.common.enums.RedisCacheKey;
|
|
|
import com.yunfeiyun.agmp.common.framework.manager.RedisCacheManager;
|
|
|
+import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.spring.SpringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.device.xph.XphRedisUtil;
|
|
|
@@ -13,9 +14,9 @@ import com.yunfeiyun.agmp.iot.common.enums.YfqxzEnumFactor;
|
|
|
import java.util.*;
|
|
|
|
|
|
public class ElementFactorUtil {
|
|
|
- private static Map<String, Integer> getEnumCounterMap(List<? extends QxzChartDataDto> dataList){
|
|
|
+ private static Map<String, Integer> getEnumCounterMap(List<QxzDataDto> dataList){
|
|
|
Map<String, Integer> eNumCounterMap = new HashMap<>();
|
|
|
- for (QxzChartDataDto dataitem : dataList) {
|
|
|
+ for (QxzDataDto dataitem : dataList) {
|
|
|
String eNum = dataitem.getENum();
|
|
|
eNumCounterMap.put(eNum, eNumCounterMap.getOrDefault(eNum, 0) + 1);
|
|
|
}
|
|
|
@@ -144,7 +145,7 @@ public class ElementFactorUtil {
|
|
|
return iotDevicefactor;
|
|
|
}
|
|
|
|
|
|
- public static IotDevicefactor setDisplayname(IotQxzDataListRseVo resVo, Map<String, IotDevicefactor> devicefactorMap, QxzChartDataDto dataitem, String devtypeBid){
|
|
|
+ public static IotDevicefactor setDisplayname(IotQxzDataListRseVo resVo, Map<String, IotDevicefactor> devicefactorMap, QxzDataDto dataitem, String devtypeBid){
|
|
|
IotDevicefactor iotDevicefactor = null;
|
|
|
resVo.setAddress(getAddress(dataitem.getEName(), dataitem.getEKey()));
|
|
|
if(Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_WSHJ_JC)
|
|
|
@@ -158,16 +159,89 @@ public class ElementFactorUtil {
|
|
|
return iotDevicefactor;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取通道信息MAP
|
|
|
+ * @param dataList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static Map<String, List<String>> getEnumAddressMap(List<QxzDataDto> dataList){
|
|
|
+ Map<String, List<String>> eNumAddressMap = new HashMap<>();
|
|
|
+ for (QxzDataDto dataitem : dataList) {
|
|
|
+ String eNum = dataitem.getENum();
|
|
|
+ List<String> addressList = eNumAddressMap.getOrDefault(eNum, new ArrayList<>());
|
|
|
+ String address = String.join("-", dataitem.getEName(), dataitem.getEKey());
|
|
|
+ if(!addressList.contains(address)){
|
|
|
+ addressList.add(address);
|
|
|
+ }
|
|
|
+ eNumAddressMap.put(eNum, addressList);
|
|
|
+ }
|
|
|
+ return eNumAddressMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<IotQxzDataListRseVo> qxzListProcessData(List<QxzDataDto> dataList, List<IotDevicefactor> factorList, IotDevice iotDeviceResVo, boolean isDisable){
|
|
|
+ String devtypeBid = iotDeviceResVo.getDevtypeBid();
|
|
|
+ Map<String, String> eleNameMap = getXphHttpEleNameMap(iotDeviceResVo);
|
|
|
+ Map<String, IotDevicefactor> devicefactorMap = getDevicefactorMap(factorList);
|
|
|
+ Map<String, Integer> eNumCounterMap = getEnumCounterMap(dataList);
|
|
|
+
|
|
|
+ List<IotQxzDataListRseVo> retList = new ArrayList<>();
|
|
|
+ for (QxzDataDto dataitem : dataList) {
|
|
|
+ String eNum = dataitem.getENum();
|
|
|
+ Integer eNumCount = eNumCounterMap.get(eNum);
|
|
|
+
|
|
|
+ IotQxzDataListRseVo iotQxzDataListRseVo = new IotQxzDataListRseVo();
|
|
|
+ iotQxzDataListRseVo.setFactorCode(dataitem.getENum());
|
|
|
+ iotQxzDataListRseVo.setNumber(dataitem.getEValue());
|
|
|
+ iotQxzDataListRseVo.setTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, dataitem.getTime()));
|
|
|
+ iotQxzDataListRseVo.setDevBid(dataitem.getDevBid());
|
|
|
+
|
|
|
+ /* 设置要素名称 用于联合唯一 和前端区分显示 */
|
|
|
+ IotDevicefactor iotDevicefactor = setDisplayname(iotQxzDataListRseVo, devicefactorMap, dataitem, devtypeBid);
|
|
|
+ String dfDisable = "0";
|
|
|
+ if(iotDevicefactor != null){
|
|
|
+ dfDisable = iotDevicefactor.getDfDisable();
|
|
|
+ if(!isDisable && Objects.equals(dfDisable,"1")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iotQxzDataListRseVo.setDfDisable(dfDisable);
|
|
|
+
|
|
|
+ if(IotDeviceDictConst.TYPE_XPH_TRSH_CL.equals(devtypeBid)){
|
|
|
+ if(!StringUtils.isEmpty(iotQxzDataListRseVo.getFactorName())){
|
|
|
+ iotQxzDataListRseVo.setFactorName(iotQxzDataListRseVo.getFactorName().replace("大气", ""));
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(iotQxzDataListRseVo.getFactorDisplayname())){
|
|
|
+ if(eleNameMap.containsKey(dataitem.getEKey())){
|
|
|
+ iotQxzDataListRseVo.setFactorDisplayname(eleNameMap.get(dataitem.getEKey()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_GP_QXZ)){
|
|
|
+ if(eleNameMap.containsKey(dataitem.getEKey())){
|
|
|
+ iotQxzDataListRseVo.setFactorName(eleNameMap.get(dataitem.getEKey()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_GP_QXZ) && StringUtils.isEmpty(iotQxzDataListRseVo.getFactorDisplayname())){
|
|
|
+ if(eNumCount > 1){
|
|
|
+ String dspName = (eNumCount * 10) + "厘米" + iotQxzDataListRseVo.getFactorName();
|
|
|
+ iotQxzDataListRseVo.setFactorDisplayname(dspName);
|
|
|
+ eNumCounterMap.put(eNum, eNumCount - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retList.add(iotQxzDataListRseVo);
|
|
|
+ }
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
public static List<IotQxzDataListRseVo> qxzChartProcessData(
|
|
|
- List<QxzChartDataDto> dataList, List<IotDevicefactor> factorList, IotDevice iotDeviceResVo, boolean isDisable) {
|
|
|
+ List<QxzDataDto> dataList, List<IotDevicefactor> factorList, IotDevice iotDeviceResVo, boolean isDisable) {
|
|
|
String devtypeBid = iotDeviceResVo.getDevtypeBid();
|
|
|
- String devCode = iotDeviceResVo.getDevCode();
|
|
|
Map<String, Integer> eNumCounterMap = getEnumCounterMap(dataList);
|
|
|
Map<String, String> eleNameMap = getXphHttpEleNameMap(iotDeviceResVo);
|
|
|
Map<String, IotDevicefactor> devicefactorMap = getDevicefactorMap(factorList);
|
|
|
|
|
|
List<IotQxzDataListRseVo> retList = new ArrayList<>();
|
|
|
- for (QxzChartDataDto dataitem : dataList) {
|
|
|
+ for (QxzDataDto dataitem : dataList) {
|
|
|
String eNum = dataitem.getENum();
|
|
|
Integer eNumCount = eNumCounterMap.get(eNum);
|
|
|
|