Browse Source

1、热回收系统触摸屏mqtt数据处理;

2、首页热回收数据日累积值计算;
3、热回收系统mqtt操作指令下发;
dev_gh_ers
25604 3 weeks ago
parent
commit
1b27a0c287
  1. 9
      mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java
  2. 2
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageDataVO.java
  3. 6
      mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java
  4. 2
      mh-framework/src/main/java/com/mh/framework/mqtt/service/impl/EventsServiceImpl.java
  5. 2
      mh-framework/src/main/java/com/mh/framework/rabbitmq/consumer/ReceiveHandler.java
  6. 1
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  7. 16
      mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java
  8. 2
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  9. 3
      mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java
  10. 58
      mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java
  11. 24
      mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java

9
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<OrderEntity> changeValues) {
try {
// 增加判断是否是昆仑通态触摸屏的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设备类型
if (!iOperationService.isAdvanTech(changeValues)) {
String sendOrder = iOperationService.operationDevice(changeValues);
String name = mhConfig.getName();
// 获取mqtt操作队列(后期通过mqtt队列配置发送主题)

2
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<String, Object> 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);

6
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;

2
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());
}
// 接入消息队列,利用消息对接进行数据处理
// 判断当前主题属于哪种主动上报数据

2
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);

1
mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java

@ -370,6 +370,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
@Select("SELECT " +
" dl.device_name, " +
" cpm.mt_num, " +
" dl.order_num, " +
" dl.system_type, " +
" dl.device_type, " +

16
mh-system/src/main/java/com/mh/system/mapper/energy/OverviewMapper.java

@ -4,6 +4,7 @@ import com.mh.common.core.domain.ColumnFilter;
import com.mh.common.core.domain.entity.ChillersEntity;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import com.mh.common.core.domain.entity.DataMonth;
import com.mh.common.core.domain.vo.CollectionParamsManageDataVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -73,4 +74,19 @@ public interface OverviewMapper {
" </foreach>" +
"</script>")
BigDecimal selectEER(@Param("deviceNums") List<CollectionParamsManage> deviceNums);
@Select("<script>" +
"SELECT SUM(calc_value) FROM ${table} " +
"WHERE device_type = '2' " +
" AND cur_time &gt;= concat(#{date}, ' 00:00:00')::timestamp " +
" AND cur_time &lt;= concat(#{date}, ' 23:59:59')::timestamp " +
" AND device_num IN " +
" <foreach collection='deviceNums' item='item' open='(' separator=',' close=')'>" +
" #{item.mtNum} " +
" </foreach>" +
"</script>")
BigDecimal queryHourData(@Param("deviceNums") List<CollectionParamsManageDataVO> accumulatedHeat,
@Param("table") String table,
@Param("date") String date);
}

2
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<CollectionParamsManage> 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(),

3
mh-system/src/main/java/com/mh/system/service/operation/IOperationDeviceService.java

@ -17,4 +17,7 @@ public interface IOperationDeviceService {
boolean isAdvanTech(List<OrderEntity> changeValues);
boolean isKuLunTouchScreen(List<OrderEntity> changeValues);
String operationKLTTDevice(List<OrderEntity> changeValues);
}

58
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<OrderEntity> 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<OrderEntity> 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<OrderEntity> changeValues) {
// 判断是否存在非研华网关设备

24
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);

Loading…
Cancel
Save