diff --git a/mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java b/mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java index 63cdbf0..abe9b5a 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java +++ b/mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java @@ -99,8 +99,15 @@ public class OperationController extends BaseController { @ControlDeviceAno(value = "设备操作") public AjaxResult operationDevice(@RequestBody List changeValues) { try { - // 判断id是否是DTU设备类型 - if (!iOperationService.isAdvanTech(changeValues)) { + // 增加判断是否是昆仑通态触摸屏的MQTT设备 + if (!iOperationService.isKuLunTouchScreen(changeValues)) { + String sendOrder = iOperationService.operationKLTTDevice(changeValues); + String name = mhConfig.getName(); + // 获取mqtt操作队列(后期通过mqtt队列配置发送主题) + log.info("发送主题:{},消息:{}", name + "/" + controlTopic, sendOrder); + iMqttGatewayService.publish(name + "/" + controlTopic, sendOrder, 1); + } else if (!iOperationService.isAdvanTech(changeValues)) { + // 判断id是否是DTU设备类型 String sendOrder = iOperationService.operationDevice(changeValues); String name = mhConfig.getName(); // 获取mqtt操作队列(后期通过mqtt队列配置发送主题) diff --git a/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java b/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java index b4b4373..d6b9fc9 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java @@ -18,6 +18,7 @@ public class CollectionParamsManageDataVO { // getter方法 private String deviceName; + private String mtNum; private Integer orderNum; private String systemType; private String deviceType; @@ -31,6 +32,7 @@ public class CollectionParamsManageDataVO { // 构造函数 public CollectionParamsManageDataVO(Map map) { this.deviceName = (String) map.get("device_name"); + this.mtNum = (String) map.get("mt_num"); this.orderNum = map.get("order_num") instanceof Integer ? (Integer) map.get("order_num") : (map.get("order_num") != null ? Integer.valueOf(map.get("order_num").toString()) : null); diff --git a/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java b/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java index da7a671..a5a09fd 100644 --- a/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java +++ b/mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java @@ -139,11 +139,11 @@ public class DataProcessServiceImpl implements DataProcessService { @Override public void insertERSData(AdvantechReceiver data) { - insertData(data, "ERS_REGISTER", Constants.ERS); + insertData(data, "ERS_REGISTER", Constants.DEVICE); } private void insertData(AdvantechReceiver data, String registerKey, String cacheKey) { - log.info("{}数据解析入库:{}", registerKey.equals("CHILLERS_REGISTER") ? "机组设备" : "计量设备", data); + // log.info("{}数据解析入库:{}", registerKey.equals("CHILLERS_REGISTER") ? "机组设备" : "计量设备", data); if (registerKey.equals("CHILLERS_REGISTER")) { databaseMapper.createChillerTable(); } else { @@ -224,7 +224,7 @@ public class DataProcessServiceImpl implements DataProcessService { String tag = advantechDatas.getTag(); String value = String.valueOf(advantechDatas.getValue()); String quality = String.valueOf(advantechDatas.getQuality()); - log.info("时间: {},tag标签: {},value值: {}, 质量:{}", formattedTime, tag, value, quality); + // log.info("时间: {},tag标签: {},value值: {}, 质量:{}", formattedTime, tag, value, quality); try { if (StringUtils.isBlank(tag)) { continue; diff --git a/mh-framework/src/main/java/com/mh/framework/mqtt/service/impl/EventsServiceImpl.java b/mh-framework/src/main/java/com/mh/framework/mqtt/service/impl/EventsServiceImpl.java index fc0b4c1..499e9a9 100644 --- a/mh-framework/src/main/java/com/mh/framework/mqtt/service/impl/EventsServiceImpl.java +++ b/mh-framework/src/main/java/com/mh/framework/mqtt/service/impl/EventsServiceImpl.java @@ -72,7 +72,7 @@ public class EventsServiceImpl implements IEventsService { AdvantechReceiver commonTopicReceiver = new AdvantechReceiver(); if (!topic.contains(Constants.TEMP)) { commonTopicReceiver = mapper.readValue(receiver, AdvantechReceiver.class); - log.info("主题:{},类型:{}: ,数据:{}", topic, logMessage, commonTopicReceiver.toString()); + // log.info("主题:{},类型:{}: ,数据:{}", topic, logMessage, commonTopicReceiver.toString()); } // 接入消息队列,利用消息对接进行数据处理 // 判断当前主题属于哪种主动上报数据 diff --git a/mh-framework/src/main/java/com/mh/framework/rabbitmq/consumer/ReceiveHandler.java b/mh-framework/src/main/java/com/mh/framework/rabbitmq/consumer/ReceiveHandler.java index b2ff82c..c4c7a13 100644 --- a/mh-framework/src/main/java/com/mh/framework/rabbitmq/consumer/ReceiveHandler.java +++ b/mh-framework/src/main/java/com/mh/framework/rabbitmq/consumer/ReceiveHandler.java @@ -60,7 +60,7 @@ public class ReceiveHandler { )) public void receiveERSData(@Payload String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws InterruptedException, IOException { try { - log.info("MQ消费者:热回收系统设备采集:{}", msg); + //log.info("MQ消费者:热回收系统设备采集:{}", msg); //TODO 数据解析入库操作 msg转成实体类,入库 AdvantechReceiver boilerData = AdvantechJsonParser.parse(msg); dataProcessService.insertERSData(boilerData); diff --git a/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java index 7c97abc..3d73d86 100644 --- a/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java +++ b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java @@ -370,6 +370,7 @@ public interface CollectionParamsManageMapper extends BaseMapper" + "") BigDecimal selectEER(@Param("deviceNums") List deviceNums); + + @Select("") + BigDecimal queryHourData(@Param("deviceNums") List accumulatedHeat, + @Param("table") String table, + @Param("date") String date); + } 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 8bf5b2d..8614b34 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 @@ -572,7 +572,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag public void updateCollectionParamsManages(ArrayList chillersEntities) { // 批量更新 chillersEntities.forEach(chillerEntity -> { - log.info("chillerEntity: {}", chillerEntity.toString()); + // log.info("chillerEntity: {}", chillerEntity.toString()); if (chillerEntity.getId() != null && !StringUtils.isEmpty(chillerEntity.getId())) { collectionParamsManageMapper.updateCurValueById(chillerEntity.getId(), chillerEntity.getCurValue(), diff --git a/mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java b/mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java index a2df029..0760c3c 100644 --- a/mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java +++ b/mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java @@ -17,4 +17,7 @@ public interface IOperationDeviceService { boolean isAdvanTech(List changeValues); + boolean isKuLunTouchScreen(List changeValues); + + String operationKLTTDevice(List changeValues); } 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..9b503af 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 @@ -13,6 +13,7 @@ import com.mh.common.utils.DateUtils; import com.mh.common.utils.ModbusUtils; import com.mh.common.utils.NettyTools; import com.mh.common.utils.StringUtils; +import com.mh.system.mapper.SysDictDataMapper; import com.mh.system.mapper.device.CollectionParamsManageMapper; import com.mh.system.mapper.device.GatewayManageMapper; import com.mh.system.mapper.policy.PolicyManageMapper; @@ -45,6 +46,63 @@ public class OperationDeviceServiceImpl implements IOperationDeviceService { @Resource private PolicyManageMapper policyManageMapper; + @Resource + private GatewayManageMapper gatewayManageMapper; + + @Resource + private SysDictDataMapper sysDictDataMapper; + + @Override + public String operationKLTTDevice(List changeValues) { + JSONObject jsonObject = new JSONObject(); + for (OrderEntity changeValue : changeValues) { + // 获取报文 + String message = changeValue.getParam(); +// // 获取报文类型 +// Integer type = changeValue.getType(); +// if (type != null) { +// if (type == 1) { +// // 设置延时开关时间,参数需要*1000 +// message = String.valueOf(new BigDecimal(message).multiply(new BigDecimal("1000")).intValue()); +// } +// } + // 获取报文其他信息 + String otherName = changeValue.getOtherName(); + if (StringUtils.isEmpty(otherName)) { + // 从数据库id获取设备名称 + CollectionParamsManage collectionParamsManage = collectionParamsManageMapper.selectById(changeValue.getId()); + if (null != collectionParamsManage) { + otherName = collectionParamsManage.getOtherName(); + } else { + return null; + } + } + jsonObject.put(otherName, message); + } + return jsonObject.toString(); + } + + @Override + public boolean isKuLunTouchScreen(List changeValues) { + if (!changeValues.isEmpty()) { + for (OrderEntity changeValue : changeValues) { + String cpmId = changeValue.getId(); + CollectionParamsManage collectionParamsManage = collectionParamsManageMapper.selectById(cpmId); + if (null != collectionParamsManage) { + String gatewayId = collectionParamsManage.getGatewayId(); + GatewayManage gatewayManage = gatewayManageMapper.selectById(gatewayId); + if (null != gatewayManage) { + String dictLabel = sysDictDataMapper.selectDictLabel("communication_type", String.valueOf(gatewayManage.getCommunicationType())); + if (!dictLabel.equals("MQTT/KNTT")) { + return true; + } + } + } + } + } + return false; + } + @Override public boolean isAdvanTech(List changeValues) { // 判断是否存在非研华网关设备 diff --git a/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java index c50cb7b..2fd796f 100644 --- a/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java @@ -20,6 +20,7 @@ import lombok.Setter; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -164,7 +165,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { result.put("orderNum", item.getOrderNum()); result.put("paramType", item.getParamType()); result.put("otherName", item.getOtherName()); - result.put("curValue", item.getCurValue()); + result.put("curValue", item.getCurValue().setScale(1, RoundingMode.HALF_UP)); result.put("curTime", item.getCurTime()); result.put("status", item.getStatus()); @@ -260,7 +261,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { .filter(item -> // 离心机入口温度 (device_type=14, order_num=4, param_type=31) ("14".equals(item.getDeviceType()) && - "31".equals(item.getParamType()) && + "12".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) || // 离心机出水温度 (device_type=6, order_num=1, param_type=12, other_name like '%出水温度%') ("6".equals(item.getDeviceType()) && @@ -270,7 +271,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { item.getOtherName().contains("出水温度")) || // 保障进水温度 (device_type=14, order_num=3, param_type=31) ("14".equals(item.getDeviceType()) && - "31".equals(item.getParamType()) && + "12".equals(item.getParamType()) && Integer.valueOf(3).equals(item.getOrderNum())) || // 离心机进水压力 (device_type=13, order_num=4, param_type=13) ("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) || @@ -283,17 +284,17 @@ public class ProOverviewServiceImpl implements IProOverviewService { result.put("orderNum", item.getOrderNum()); result.put("paramType", item.getParamType()); result.put("otherName", item.getOtherName()); - result.put("curValue", item.getCurValue()); + result.put("curValue", item.getCurValue().setScale(1, BigDecimal.ROUND_HALF_UP)); result.put("curTime", item.getCurTime()); result.put("status", item.getStatus()); // 根据条件确定设备类型名称 String deviceTypeName = ""; - if ("14".equals(item.getDeviceType()) && "31".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) { + if ("14".equals(item.getDeviceType()) && "12".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) { deviceTypeName = "离心机入口温度"; } else if ("6".equals(item.getDeviceType()) && "12".equals(item.getParamType()) && Integer.valueOf(1).equals(item.getOrderNum())) { deviceTypeName = "离心机出水温度"; - } else if ("14".equals(item.getDeviceType()) && "31".equals(item.getParamType()) && Integer.valueOf(3).equals(item.getOrderNum())) { + } else if ("14".equals(item.getDeviceType()) && "12".equals(item.getParamType()) && Integer.valueOf(3).equals(item.getOrderNum())) { deviceTypeName = "保障进水温度"; } else if ("13".equals(item.getDeviceType()) && "13".equals(item.getParamType()) && Integer.valueOf(4).equals(item.getOrderNum())) { deviceTypeName = "离心机进水压力"; @@ -328,7 +329,7 @@ public class ProOverviewServiceImpl implements IProOverviewService { result.put("orderNum", item.getOrderNum()); result.put("paramType", item.getParamType()); result.put("otherName", item.getOtherName()); - result.put("curValue", item.getCurValue()); + result.put("curValue", item.getCurValue().setScale(1, RoundingMode.HALF_UP)); result.put("curTime", item.getCurTime()); result.put("status", item.getStatus()); @@ -377,9 +378,12 @@ public class ProOverviewServiceImpl implements IProOverviewService { .map(CollectionParamsManageDataVO::getCurValue) .reduce(BigDecimal.ZERO, BigDecimal::add); + // 查询日表,求出匹配accumulatedHeat集合 + BigDecimal hourData = overviewMapper.queryHourData(accumulatedHeat, "data_hour"+DateUtils.getDate().substring(0, 4), DateUtils.getDate()); + result.put("instantaneousHeatSum", instantaneousHeatSum); result.put("accumulatedHeatSum", accumulatedHeatSum); - result.put("dailyAccumulatedHeat", BigDecimal.ZERO); // 日累积热量,先默认0 + result.put("dailyAccumulatedHeat", hourData.setScale(1, RoundingMode.HALF_UP)); // 日累积热量,先默认0 // result.put("instantaneousHeatDetails", instantaneousHeat); // result.put("accumulatedHeatDetails", accumulatedHeat); @@ -422,9 +426,11 @@ public class ProOverviewServiceImpl implements IProOverviewService { .map(CollectionParamsManageDataVO::getCurValue) .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal hourData = overviewMapper.queryHourData(accumulatedHeat, "data_hour"+DateUtils.getDate().substring(0, 4), DateUtils.getDate()); + result.put("instantaneousHeatSum", instantaneousHeatSum); result.put("accumulatedHeatSum", accumulatedHeatSum); - result.put("dailyAccumulatedHeat", BigDecimal.ZERO); // 日累计热量,先默认0 + result.put("dailyAccumulatedHeat", hourData.setScale(1, RoundingMode.HALF_UP)); // 日累计热量,先默认0 // result.put("instantaneousHeatDetails", instantaneousHeat); // result.put("accumulatedHeatDetails", accumulatedHeat);