|
|
|
@ -2,10 +2,7 @@ package com.mh.user.strategy;
|
|
|
|
|
|
|
|
|
|
import com.mh.common.utils.StringUtils; |
|
|
|
|
import com.mh.user.constants.Constant; |
|
|
|
|
import com.mh.user.entity.DataResultChEntity; |
|
|
|
|
import com.mh.user.entity.DataResultClEntity; |
|
|
|
|
import com.mh.user.entity.DeviceCodeParamEntity; |
|
|
|
|
import com.mh.user.entity.MeterManageEntity; |
|
|
|
|
import com.mh.user.entity.*; |
|
|
|
|
import com.mh.user.service.DataResultService; |
|
|
|
|
import com.mh.user.service.ProjectInfoService; |
|
|
|
|
import com.mh.user.utils.ExchangeStringUtil; |
|
|
|
@ -134,6 +131,9 @@ public class ModbusProtocolStrategy implements ProtocolStrategy {
|
|
|
|
|
analysisCloudOrder485(sValue, deviceCodeParamEntity); |
|
|
|
|
} else if ("0".equals(deviceCodeParamEntity.getDeviceType())) { |
|
|
|
|
analysisChillerOrder485(sValue, deviceCodeParamEntity); |
|
|
|
|
} else if ("1".equals(deviceCodeParamEntity.getDeviceType())) { |
|
|
|
|
// 解析入库
|
|
|
|
|
analysisMeterOrder485(sValue, deviceCodeParamEntity); |
|
|
|
|
} |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
log.error("modbus标准协议:策略解析报文异常", e); |
|
|
|
@ -141,6 +141,35 @@ public class ModbusProtocolStrategy implements ProtocolStrategy {
|
|
|
|
|
return sValue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 解析电表返回的数据 |
|
|
|
|
* |
|
|
|
|
* @param dataStr |
|
|
|
|
*/ |
|
|
|
|
public void analysisMeterOrder485(final String dataStr, final DeviceCodeParamEntity deviceCodeParam) { |
|
|
|
|
threadPoolService.execute(() -> { |
|
|
|
|
Date date = new Date(); |
|
|
|
|
String dateStr = sdf1.format(date); |
|
|
|
|
try { |
|
|
|
|
DataResultEntity dataResultEntity = new DataResultEntity(); |
|
|
|
|
dataResultEntity.setDeviceAddr(deviceCodeParam.getDeviceAddr()); //通讯编号
|
|
|
|
|
dataResultEntity.setDeviceType(deviceCodeParam.getDeviceType()); //类型
|
|
|
|
|
dataResultEntity.setProjectId(deviceCodeParam.getProjectId()); //所属项目
|
|
|
|
|
dataResultEntity.setCurValue(new BigDecimal(dataStr)); //当前读数
|
|
|
|
|
dataResultEntity.setCurDate(sdf1.parse(dateStr)); //当前日期
|
|
|
|
|
dataResultEntity.setGrade(deviceCodeParam.getGrade()); |
|
|
|
|
dataResultEntity.setRegisterAddr(deviceCodeParam.getRegisterAddr()); |
|
|
|
|
dataResultEntity.setRegisterName(deviceCodeParam.getRegisterName()); |
|
|
|
|
String projectName = projectInfoService.selectName(deviceCodeParam.getProjectId()); |
|
|
|
|
log.info("电表==>{},读数==>{},项目名称==>{}", deviceCodeParam.getDeviceAddr(), dataStr, projectName); |
|
|
|
|
dataResultService.saveDataResult(dataResultEntity); |
|
|
|
|
log.info("电表保存数据成功!项目名称:{}", projectName); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("保存电表数据失败!", e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 解析冷水机组返回的数据 |
|
|
|
|
*/ |
|
|
|
|