diff --git a/mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java b/mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java index 626002e..7fc3174 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java +++ b/mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java @@ -5,6 +5,7 @@ import com.mh.common.core.domain.AjaxResult; import com.mh.common.core.domain.entity.CollectionParamsManage; import com.mh.common.core.domain.entity.CommunicationParams; import com.mh.common.core.domain.entity.SysDictData; +import com.mh.common.core.domain.vo.CollectionParamsManageVO; import com.mh.common.core.domain.vo.CollectionParamsManageVO2; import com.mh.common.core.domain.vo.EnergyConsumptionVO; import com.mh.common.core.domain.vo.EnergyQueryVO; @@ -54,6 +55,35 @@ public class ChillersParamsController extends BaseController { public TableDataInfo list(CollectionParamsManage collectionParamsManage) { collectionParamsManage.setIsUse(0); List list = iCollectionParamsManageService.selectCollectionParamsManageList(collectionParamsManage); + + // 这里遍历collectionParamsManages,判断otherName, + // 如果otherName="1号主机-A回路运行电流"的curValue大于5A,则修改otherName="1号主机-机组开机关机"的curValue=1,则赋值给runStatus + // 如果otherName="1号主机-负载"或者otherName="1号主机-负荷限制",其curValue值乘以10 + + // 1. 找出"1号主机-A回路运行电流"的curValue + BigDecimal runningCurrentValue = list.stream() + .filter(p -> "1号主机-A回路运行电流".equals(p.getOtherName())) + .map(CollectionParamsManage::getCurValue) + .findFirst() + .orElse(null); + + // 如果运行电流大于5A,则设置"1号主机-运行状态"的curValue=1 + if (runningCurrentValue != null && runningCurrentValue.compareTo(new BigDecimal("5")) > 0) { + list.stream() + .filter(p -> "1号主机-运行状态".equals(p.getOtherName())) + .forEach(p -> p.setCurValue(new BigDecimal("1"))); + } + + // 2. "1号主机-负载" 和 "1号主机-负荷限制" 的curValue乘以10 + list.stream() + .filter(p -> "1号主机-负载".equals(p.getOtherName()) + || "1号主机-负荷限制".equals(p.getOtherName())) + .forEach(p -> { + if (p.getCurValue() != null) { + p.setCurValue(p.getCurValue().multiply(new BigDecimal("10"))); + } + }); + // list中的CollectionParamsManage中的other_name去掉“号主机”之前数据 list.forEach(item -> { String otherName = item.getOtherName(); diff --git a/mh-admin/src/main/resources/application.yml b/mh-admin/src/main/resources/application.yml index c3ae7c3..44f7920 100644 --- a/mh-admin/src/main/resources/application.yml +++ b/mh-admin/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: dev + active: prod # 用户配置 user: diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java index 45c3a7f..54626a6 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java @@ -81,7 +81,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag "PLC1500_DB8304", // 压力瞬时值 "PLC1500_DB8308", // 流量瞬时值 "PLC1500_DB8320" //流量累积值 - ); + ); private static final List steamBoilerAO = List.of("DB611566", // 锅炉1-工作最小转速 "DB611550",// 锅炉1-工作最大转速 @@ -216,6 +216,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag /** * 处理otherName字段,按"-"分割并取最后一部分 + * * @param collectionParamsManages 待处理的集合 * @return 处理后的集合 */ @@ -517,6 +518,34 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag if (collectionParamsManages.isEmpty()) { return List.of(); } + // 这里遍历collectionParamsManages,判断otherName, + // 如果otherName="1号主机-A回路运行电流"的curValue大于5A,则修改otherName="1号主机-机组开机关机"的curValue=1,则赋值给runStatus + // 如果otherName="1号主机-负载"或者otherName="1号主机-负荷限制",其curValue值乘以10 + + // 1. 找出"1号主机-A回路运行电流"的curValue + BigDecimal runningCurrentValue = collectionParamsManages.stream() + .filter(p -> "1号主机-A回路运行电流".equals(p.getOtherName())) + .map(CollectionParamsManageVO::getCurValue) + .findFirst() + .orElse(null); + + // 如果运行电流大于5A,则设置"1号主机-机组开机关机"的curValue=1 + if (runningCurrentValue != null && runningCurrentValue.compareTo(new BigDecimal("5")) > 0) { + collectionParamsManages.stream() + .filter(p -> "1号主机-运行状态".equals(p.getOtherName())) + .forEach(p -> p.setCurValue(new BigDecimal("1"))); + } + + // 2. "1号主机-负载" 和 "1号主机-负荷限制" 的curValue乘以10 + collectionParamsManages.stream() + .filter(p -> "1号主机-负载".equals(p.getOtherName()) + || "1号主机-负荷限制".equals(p.getOtherName())) + .forEach(p -> { + if (p.getCurValue() != null) { + p.setCurValue(p.getCurValue().multiply(new BigDecimal("10"))); + } + }); + // 得出的collectionParamsManages进行数据赋值,如果paramType="1',则是运行状态,则赋值给runStatus, // 如果paramType="5",则是故障报警,则赋值给alarmStatus // 如果paramType="6",则是手自动状态,则赋值给handOrAuto diff --git a/mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java index 8087e41..30220e0 100644 --- a/mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java @@ -106,7 +106,7 @@ public class OperationDeviceServiceImpl implements IOperationDeviceService { // 从策略管理中获取数据,判断是否需要放大10的n次方倍 PolicyManage policyManage = policyManageMapper.selectOntByCpmId(changeValue.getId()); if (null != policyManage) { - message = String.valueOf(new BigDecimal(message).multiply(BigDecimal.valueOf(Math.pow(10, policyManage.getDigits()))).intValue()); + message = String.valueOf(new BigDecimal(message).multiply(BigDecimal.valueOf(Math.pow(10, policyManage.getDigits())))); // 判断是否存在加减载时间,存在加减载时间还需要在乘以60 if (policyManage.getFunPolicyType().equals("1") && (policyManage.getPointName().contains("加载") || policyManage.getPointName().contains("减载"))) { message = String.valueOf(new BigDecimal(message).multiply(BigDecimal.valueOf(60)).intValue()); @@ -116,7 +116,7 @@ public class OperationDeviceServiceImpl implements IOperationDeviceService { // 发送报文 AdvantechDatas data = new AdvantechDatas(); data.setTag(otherName); - data.setValue(Integer.valueOf(message)); + data.setValue(new BigDecimal(message).doubleValue()); advantechDatas.add(data); } return advantechDatas;