You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
566 lines
34 KiB
566 lines
34 KiB
package com.mh.user.strategy; |
|
|
|
import com.mh.common.utils.StringUtils; |
|
import com.mh.user.constants.Constant; |
|
import com.mh.user.entity.DeviceCodeParamEntity; |
|
import com.mh.user.entity.NowPublicDataEntity; |
|
import com.mh.user.service.*; |
|
import com.mh.user.utils.ExchangeStringUtil; |
|
import com.mh.user.utils.SpringBeanUtil; |
|
import lombok.extern.slf4j.Slf4j; |
|
import org.springframework.context.ApplicationContext; |
|
|
|
import java.math.BigDecimal; |
|
|
|
/** |
|
* @author LJF |
|
* @version 1.0 |
|
* @project CHWS |
|
* @description 热泵策略 |
|
* @date 2024-03-18 09:51:17 |
|
*/ |
|
@Slf4j |
|
public class HeatPumpStrategy implements DeviceStrategy { |
|
|
|
|
|
// 调用service |
|
ApplicationContext context = SpringBeanUtil.getApplicationContext(); |
|
NowDataService nowDataService = context.getBean(NowDataService.class); |
|
NowPublicDataService nowPublicDataService = context.getBean(NowPublicDataService.class); |
|
PumpSetService pumpSetService = context.getBean(PumpSetService.class); |
|
DeviceInstallService deviceInstallService = context.getBean(DeviceInstallService.class); |
|
DealDataService dealDataService = context.getBean(DealDataService.class); |
|
|
|
private static class SingletonHolder { |
|
private static final HeatPumpStrategy INSTANCE = new HeatPumpStrategy(); |
|
} |
|
|
|
private HeatPumpStrategy() { |
|
// 防止外部直接实例化 |
|
} |
|
|
|
public static HeatPumpStrategy getInstance() { |
|
return HeatPumpStrategy.SingletonHolder.INSTANCE; |
|
} |
|
|
|
@Override |
|
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
String deviceAddr = deviceCodeParamEntity.getDeviceAddr(); |
|
String brand = deviceCodeParamEntity.getBrand(); |
|
String funCode = deviceCodeParamEntity.getFunCode(); |
|
String registerAddr = deviceCodeParamEntity.getRegisterAddr(); |
|
String dataValue = deviceCodeParamEntity.getDataValue(); |
|
String str = ""; |
|
String param = ""; |
|
if (deviceAddr != null && deviceAddr.length() > 0) { |
|
try { |
|
// 0代表前面补充0,2代表长度为2,d代表参数为正数型 |
|
str = ExchangeStringUtil.decToHex(deviceAddr); |
|
str = ExchangeStringUtil.addZeroForNum(str, 2); |
|
if (StringUtils.isBlank(brand) || Constant.BRAND_MEI_DI.equals(brand)) { |
|
if (StringUtils.isBlank(funCode) || funCode.equals("03")) { |
|
if (StringUtils.isBlank(registerAddr) || registerAddr.equalsIgnoreCase("0641")) { // 运行状态 |
|
str = str + "0306410001"; |
|
param = "运行状态"; |
|
} else if (registerAddr.equalsIgnoreCase("0007")) { // 水温 |
|
str = str + "0300070001"; |
|
param = "实际温度"; |
|
} else if (registerAddr.equalsIgnoreCase("000B")) { // 故障状态,100*N+11 |
|
str = str + "03000B0001"; |
|
param = "故障状态"; |
|
} else if (registerAddr.equalsIgnoreCase("0642")) { // 读温度设定 |
|
str = str + "0306420001"; |
|
param = "设定温度"; |
|
} else if (registerAddr.equalsIgnoreCase("0656")) { //读时段1 |
|
str = str + "0306560004"; |
|
param = "时段1"; |
|
} else if (registerAddr.equalsIgnoreCase("065A")) { //读时段2 |
|
str = str + "03065A0004"; |
|
param = "时段2"; |
|
} |
|
} else {//10 |
|
if (StringUtils.isBlank(registerAddr) || registerAddr.equalsIgnoreCase("0642")) {//温度设定,写 |
|
str = str + "100642000102" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(dataValue)), 4); //写,待测试 |
|
} else { |
|
if (dataValue.length() == 8) { |
|
String strData = "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(0, 2)), 2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(2, 4)), 2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(4, 6)), 2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(6, 8)), 2); |
|
if (registerAddr.equalsIgnoreCase("0656")) {//时段1 |
|
str = str + "100656000408" + strData; //写 |
|
} else if (registerAddr.equalsIgnoreCase("065A")) {//时段2 |
|
str = str + "10065A000408" + strData; //写 |
|
} |
|
} |
|
} |
|
} |
|
} else if (Constant.BRAND_MEI_DI_TWO.equals(brand)) { |
|
if (StringUtils.isBlank(funCode) || funCode.equals("03")) { |
|
if (registerAddr == null || registerAddr.equals("") || registerAddr.equalsIgnoreCase("0BBD")) { // 运行状态 |
|
str = str + "030BBD0001"; |
|
param = "运行状态"; |
|
} else if (registerAddr.equalsIgnoreCase("0064")) { // 水温 |
|
str = str + "0300640001"; |
|
param = "实际温度"; |
|
} else if (registerAddr.equalsIgnoreCase("0BBB")) { // 故障状态 |
|
str = str + "030BBB0001"; |
|
param = "故障状态"; |
|
} else if (registerAddr.equalsIgnoreCase("0003")) { // 读温度设定 |
|
str = str + "0300030001"; |
|
param = "设定温度"; |
|
} |
|
} else {//06 |
|
if (StringUtils.isBlank(registerAddr) || registerAddr.equalsIgnoreCase("0003")) {//温度设定,写 |
|
str = str + "060003" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(dataValue)), 4); //写,待测试 |
|
} else if (registerAddr.equals("0000")) {//开关机 |
|
if (dataValue.equals("0000")) { |
|
str = str + "0600000000"; //关机 |
|
} else { |
|
str = str + "0600000003"; //制热水,开机 |
|
} |
|
} |
|
} |
|
} else if (Constant.BRAND_RUI_XING.equals(brand)) { |
|
if (StringUtils.isBlank(funCode) || funCode.equals("03")) { |
|
if (StringUtils.isBlank(registerAddr) || registerAddr.equalsIgnoreCase("0001")) { // 运行状态 |
|
str = str + "0300010001"; |
|
param = "运行状态"; |
|
} else if (registerAddr.equalsIgnoreCase("0046")) { // 水温 |
|
str = str + "0300460001"; |
|
param = "实际温度"; |
|
} else if (registerAddr.equalsIgnoreCase("0050")) { // 故障状态,100*N+11 |
|
str = str + "0300500001"; |
|
param = "故障状态"; |
|
} else if (registerAddr.equalsIgnoreCase("000A")) { // 读温度设定 |
|
str = str + "03000A0001"; |
|
param = "设定温度"; |
|
} else if (registerAddr.equalsIgnoreCase("0028")) { //读时段1 |
|
str = str + "0300280004"; |
|
param = "时段1"; |
|
} else if (registerAddr.equalsIgnoreCase("002C")) { //读时段2 |
|
str = str + "03002C0004"; |
|
param = "时段2"; |
|
} |
|
} else if ("06".equals(funCode)) { |
|
str = str + funCode + registerAddr;// 定时开机开关机 |
|
if ("0023".equals(registerAddr)) { |
|
param = "时段1"; |
|
} else { |
|
param = "时段2"; |
|
} |
|
} else {//10 |
|
if (StringUtils.isBlank(registerAddr) || registerAddr.equalsIgnoreCase("000A")) {//温度设定,写 |
|
str = str + "10000A000102" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(dataValue)), 4); //写,待测试 |
|
} else if (registerAddr.equalsIgnoreCase("0028") || registerAddr.equalsIgnoreCase("002C")) {//时段1 |
|
if (dataValue.length() == 8) { |
|
String strData = "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.IntToHex(Integer.parseInt(dataValue.substring(0, 2))),2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.IntToHex(Integer.parseInt(dataValue.substring(2, 4))),2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.IntToHex(Integer.parseInt(dataValue.substring(4, 6))),2) |
|
+ "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.IntToHex(Integer.parseInt(dataValue.substring(6, 8))),2); |
|
str = str + "10"+registerAddr+"000408" + strData; //写 |
|
} |
|
} |
|
} |
|
} else if (Constant.BRAND_HAI_ER.equals(brand)) { |
|
if (StringUtils.isBlank(funCode) || funCode.equals("03")) { |
|
if (StringUtils.isBlank(registerAddr) |
|
|| registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20001"),4))) { // 运行状态 |
|
str = str + "03"+registerAddr+"0001"; |
|
param = "运行状态"; |
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20026"),4))) { // 水温 |
|
str = str + "03"+registerAddr+"0001"; |
|
param = "实际温度"; |
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20041"),4))) { // 故障状态,100*N+11 |
|
str = str + "03"+registerAddr+"0001"; |
|
param = "故障状态"; |
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20003"),4))) { // 读温度设定 |
|
str = str + "03"+registerAddr+"0001"; |
|
param = "设定温度"; |
|
} |
|
} else if ("06".equals(funCode)) { |
|
if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20003"), 4))) { |
|
dataValue = (new BigDecimal(dataValue)).multiply(new BigDecimal("10")).toString(); |
|
} |
|
String dataStr = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(dataValue)), 4); |
|
str = str + funCode + registerAddr + dataStr; |
|
} |
|
} |
|
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验 |
|
str = str + checkWord; |
|
} catch (Exception e) { |
|
log.info("热泵" + param + "指令>>>>异常" + str, e); |
|
} |
|
} |
|
log.info("热泵" + param + "指令>>>>" + str); |
|
return str.toUpperCase(); |
|
} |
|
|
|
@Override |
|
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr) { |
|
String checkStr = dataStr.substring(0, dataStr.length() - 4);//检验报文 |
|
String checkWord = ExchangeStringUtil.getStrCRC16(checkStr);//生成校验码 |
|
String sValue = null; |
|
StringBuffer dataType = new StringBuffer(); |
|
String rtData = Constant.FAIL; |
|
if (!checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
|
log.info("热泵报文检验失败: " + dataStr); |
|
return Constant.FAIL; |
|
} |
|
String addr = ExchangeStringUtil.hexToDec(checkStr.substring(0, 2));//地址 |
|
String data = ""; |
|
if (StringUtils.isBlank(brand) || Constant.BRAND_MEI_DI.equals(brand)) { |
|
if (checkStr.substring(2, 4).equalsIgnoreCase("03")) {//读 |
|
rtData = getMeiDi(registerAddr, buildingId, buildingName, checkStr, sValue, addr, dataType); |
|
} else if (checkStr.substring(2, 4).equalsIgnoreCase("10")) { |
|
log.info("时间: " + dateStr + ",热泵ID: " + addr + ",操作成功! "); |
|
return Constant.SUCCESS; |
|
} |
|
} else if (Constant.BRAND_MEI_DI_TWO.equals(brand)) { |
|
if (checkStr.substring(2, 4).equalsIgnoreCase("03")) {// 读 |
|
rtData = getMeiDiTwo(registerAddr, buildingId, buildingName, checkStr, sValue, addr, dataType); |
|
} else if (checkStr.substring(2, 4).equalsIgnoreCase("06")) { |
|
log.info("时间: " + dateStr + ",热泵ID: " + addr + ",操作成功! "); |
|
return Constant.SUCCESS; |
|
} |
|
} else if (Constant.BRAND_RUI_XING.equals(brand)) { |
|
rtData = getRuiXing(dateStr, registerAddr, buildingId, buildingName, checkStr, sValue, addr, dataType); |
|
} else if (Constant.BRAND_HAI_ER.equals(brand)) { |
|
rtData = getHaiEr(dateStr, registerAddr, buildingId, buildingName, checkStr, sValue, addr, dataType); |
|
} |
|
if (!StringUtils.isBlank(rtData)) { |
|
nowDataService.saveNowHistoryData(addr, "热泵", rtData, dataType.toString(), buildingId); |
|
log.info("时间: " + dateStr + "热泵ID:" + addr + ",数据: " + rtData + ",保存数据库成功!楼栋名称:" + buildingName); |
|
} |
|
nowDataService.proWaterTemp(dateStr, buildingId, addr); //保存楼栋时间点温度变化 |
|
log.info("----------------保存楼栋时间点温度变化值!----------------"); |
|
return rtData; |
|
} |
|
|
|
private String getHaiEr(String dateStr, String registerAddr, String buildingId, String buildingName, String checkStr, String sValue, String addr, StringBuffer stringBuffer) { |
|
String data; |
|
stringBuffer.setLength(0); |
|
String dataType = ""; |
|
if (checkStr.substring(2, 4).equalsIgnoreCase("03")) {//读 |
|
if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20001"), 4))) { //运行状态 |
|
dataType = "runState"; |
|
data = checkStr.substring(8, 10); |
|
if (data.equalsIgnoreCase("00")) { |
|
sValue = "不运行"; //关机模式 |
|
} else if (data.equalsIgnoreCase("01")) { |
|
sValue = "运行"; // 开机模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20003"), 4)) |
|
|| registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20026"), 4)) ) { |
|
//20003设定温度,20026水箱水温 |
|
if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20003"), 4))) { |
|
dataType = "tempSet"; |
|
} else { |
|
dataType = "waterTemp"; |
|
} |
|
//读数 |
|
sValue = ExchangeStringUtil.hexToDec(checkStr.substring(6, 10)); |
|
sValue = String.valueOf(Double.parseDouble(sValue)/10); |
|
if (dataType.equals("waterTemp")) { |
|
String avgTemp = nowDataService.selectAve(buildingId); |
|
NowPublicDataEntity publicData = new NowPublicDataEntity(); |
|
publicData.setBuildingId(buildingId); |
|
publicData.setUseWaterTemp(avgTemp); |
|
publicData.setBackWaterTemp(avgTemp); |
|
String pumpId = nowDataService.selectMinPumpId(buildingId); |
|
// 如果是华夏,则取新增得字段标识为热泵ID |
|
String name = dealDataService.customName(); |
|
if (name.contains(Constant.CUSTOM_NAME_HUAXIA)) { |
|
pumpId = deviceInstallService.selectSinglePumpId(buildingId, addr); |
|
} |
|
log.info("---------------addr:" + addr + ",pumpId:" + pumpId + " ---------------"); |
|
if (addr.equals(pumpId)) { //取ID最小的热泵为单箱温度 |
|
publicData.setSingleTemp(sValue); |
|
log.info("---------------单箱温度:" + sValue + "---------------"); |
|
} |
|
nowPublicDataService.saveNowHistoryPublicData(publicData); |
|
log.info("楼栋名称:" + buildingName + ",热泵编号:" + addr); |
|
} else if (dataType.equals("tempSet")) { |
|
pumpSetService.updatePumpSetTemp(sValue, buildingId, addr); //更新设定温度 |
|
} |
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("20041"), 4))) { //故障状态 |
|
dataType = "isFault"; |
|
String sData = ExchangeStringUtil.hexString2binaryString(checkStr.substring(8, 10)); |
|
sData = ExchangeStringUtil.addZeroForNum(sData, 8); |
|
if (sData.substring(7, 8).equalsIgnoreCase("0")) { |
|
sValue = "无故障"; |
|
deviceInstallService.updateDeviceFault("0", addr, "热泵"); |
|
} else if (sData.substring(7, 8).equalsIgnoreCase("1")) { |
|
sValue = "有故障"; |
|
deviceInstallService.updateDeviceFault("1", addr, "热泵"); |
|
} |
|
} |
|
} else if (checkStr.substring(2, 4).equalsIgnoreCase("06")) { |
|
if (registerAddr.equalsIgnoreCase("0001")) { //运行状态 |
|
dataType = "runState"; |
|
data = checkStr.substring(10, 12); |
|
if (data.equalsIgnoreCase("00")) { |
|
sValue = "不运行"; //开机模式 |
|
} else if (data.equalsIgnoreCase("01")) { |
|
sValue = "运行"; // 开机模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} |
|
} else if (checkStr.substring(2, 4).equalsIgnoreCase("10")) { |
|
log.info("时间: " + dateStr + ",热泵ID: " + addr + ",操作成功! "); |
|
sValue = Constant.SUCCESS; |
|
} |
|
stringBuffer.append(dataType); |
|
return sValue; |
|
} |
|
|
|
private String getRuiXing(String dateStr, String registerAddr, String buildingId, String buildingName, String checkStr, String sValue, String addr, StringBuffer stringBuffer) { |
|
String data; |
|
String dataType = ""; |
|
stringBuffer.setLength(0); |
|
if (checkStr.substring(2, 4).equalsIgnoreCase("03")) {//读 |
|
if (registerAddr.equalsIgnoreCase("0001")) { //运行状态 |
|
dataType = "runState"; |
|
data = checkStr.substring(8, 10); |
|
if (data.equalsIgnoreCase("00")) { |
|
sValue = "不运行"; //关机模式 |
|
} else if (data.equalsIgnoreCase("01")) { |
|
sValue = "运行"; //制热模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} else if (registerAddr.equalsIgnoreCase("000A") || registerAddr.equalsIgnoreCase("0046")) { |
|
//000A设定温度,0046水箱水温 |
|
if (registerAddr.equalsIgnoreCase("000A")) { |
|
dataType = "tempSet"; |
|
} else { |
|
dataType = "waterTemp"; |
|
} |
|
//读数 |
|
sValue = ExchangeStringUtil.hexToDec(checkStr.substring(6, 10)); |
|
if (dataType.equals("waterTemp")) { |
|
sValue = String.valueOf(Double.parseDouble(sValue)/10); |
|
String avgTemp = nowDataService.selectAve(buildingId); |
|
NowPublicDataEntity publicData = new NowPublicDataEntity(); |
|
publicData.setBuildingId(buildingId); |
|
// 供水温度 |
|
publicData.setUseWaterTemp(avgTemp); |
|
// 回水温度 |
|
publicData.setBackWaterTemp(avgTemp); |
|
String pumpId = nowDataService.selectMinPumpId(buildingId); |
|
// 如果是华夏,则取新增得字段标识为热泵ID |
|
String name = dealDataService.customName(); |
|
if (name.contains(Constant.CUSTOM_NAME_HUAXIA)) { |
|
pumpId = deviceInstallService.selectSinglePumpId(buildingId, addr); |
|
} |
|
log.info("---------------addr:" + addr + ",pumpId:" + pumpId + " ---------------"); |
|
if (addr.equals(pumpId)) { //取ID最小的热泵为单箱温度 |
|
publicData.setSingleTemp(sValue); |
|
log.info("---------------单箱温度:" + sValue + "---------------"); |
|
} |
|
nowPublicDataService.saveNowHistoryPublicData(publicData); |
|
log.info("楼栋名称:" + buildingName + ",热泵编号:" + addr); |
|
} else if (dataType.equals("tempSet")) { |
|
pumpSetService.updatePumpSetTemp(sValue, buildingId, addr); //更新设定温度 |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("0050")) { //故障状态 |
|
dataType = "isFault"; |
|
String sData = ExchangeStringUtil.hexString2binaryString(checkStr.substring(8, 10)); |
|
sData = ExchangeStringUtil.addZeroForNum(sData, 8); |
|
if (sData.substring(7, 8).equalsIgnoreCase("0")) { |
|
sValue = "无故障"; |
|
deviceInstallService.updateDeviceFault("0", addr, "热泵"); |
|
} else if (sData.substring(7, 8).equalsIgnoreCase("1")) { |
|
sValue = "有故障"; |
|
deviceInstallService.updateDeviceFault("1", addr, "热泵"); |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("0028") |
|
|| registerAddr.equalsIgnoreCase("002C") |
|
|| registerAddr.equalsIgnoreCase("0030")) { //读定时设置值 |
|
// 01 03 08 0003 0000 0016 0000 4713 |
|
String startTime = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.hexToDec(checkStr.substring(6, 10)), 2) |
|
+ ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.hexToDec(checkStr.substring(10, 14)), 2); |
|
String closetTime = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.hexToDec(checkStr.substring(14, 18)), 2) |
|
+ ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.hexToDec(checkStr.substring(18, 22)), 2); |
|
sValue = startTime + closetTime; |
|
} |
|
} else if (checkStr.substring(2, 4).equalsIgnoreCase("06")) { |
|
if (registerAddr.equalsIgnoreCase("0001")) { //运行状态 |
|
dataType = "runState"; |
|
data = checkStr.substring(10, 12); |
|
if (data.equalsIgnoreCase("00")) { |
|
sValue = "不运行"; //关机模式 |
|
} else if (data.equalsIgnoreCase("01")) { |
|
sValue = "运行"; //制热模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} else { |
|
log.info("时间: " + dateStr + ",热泵ID: " + addr + ",操作成功! "); |
|
sValue = Constant.SUCCESS; |
|
} |
|
} |
|
stringBuffer.append(dataType); |
|
return sValue; |
|
} |
|
|
|
private String getMeiDi(String registerAddr, String buildingId, String buildingName, String checkStr, String sValue, String addr, StringBuffer stringBuffer) { |
|
String data; |
|
String dataType = ""; |
|
stringBuffer.setLength(0); |
|
if (registerAddr.equalsIgnoreCase("0641")) { //运行状态 |
|
dataType = "runState"; |
|
data = checkStr.substring(8, 10); |
|
log.info("------------美的热泵状态值-----------" + data); |
|
if (data.equalsIgnoreCase("08")) { |
|
sValue = "不运行"; //关机模式 |
|
} else if (data.equalsIgnoreCase("01")) { |
|
sValue = "运行"; //制冷模式 |
|
} else if (data.equalsIgnoreCase("02")) { |
|
sValue = "运行"; //制热模式 |
|
} else if (data.equalsIgnoreCase("04")) { |
|
sValue = "运行"; //水泵模式 |
|
} else if (data.equalsIgnoreCase("10")) { |
|
sValue = "运行"; //制热水模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} else if (registerAddr.equalsIgnoreCase("0642") || registerAddr.equalsIgnoreCase("0007")) { |
|
//0642设定温度,0007水箱水温 |
|
if (registerAddr.equalsIgnoreCase("0642")) { |
|
dataType = "tempSet"; |
|
} else { |
|
dataType = "waterTemp"; |
|
} |
|
//读数 |
|
sValue = ExchangeStringUtil.hexToDec(checkStr.substring(6, 10)); |
|
if (dataType.equals("waterTemp")) { |
|
String avgTemp = nowDataService.selectAve(buildingId); |
|
NowPublicDataEntity publicData = new NowPublicDataEntity(); |
|
publicData.setBuildingId(buildingId); |
|
publicData.setUseWaterTemp(avgTemp); |
|
publicData.setBackWaterTemp(avgTemp); |
|
String pumpId = nowDataService.selectMinPumpId(buildingId); |
|
// 如果是华夏,则取新增得字段标识为热泵ID |
|
String name = dealDataService.customName(); |
|
if (name.contains(Constant.CUSTOM_NAME_HUAXIA)) { |
|
pumpId = deviceInstallService.selectSinglePumpId(buildingId, addr); |
|
} |
|
if (addr.equals(pumpId)) { //取ID最小的热泵为单箱温度 |
|
publicData.setSingleTemp(sValue); |
|
log.info("---------------单箱温度:" + sValue + "---------------"); |
|
} |
|
nowPublicDataService.saveNowHistoryPublicData(publicData); |
|
log.info("楼栋名称:" + buildingName + ",热泵编号:" + addr); |
|
} else if (dataType.equals("tempSet")) { |
|
pumpSetService.updatePumpSetTemp(sValue, buildingId, addr); //更新设定温度 |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("000B")) { //故障状态 |
|
dataType = "isFault"; |
|
String sData = ExchangeStringUtil.hexString2binaryString(checkStr.substring(8, 10)); |
|
sData = ExchangeStringUtil.addZeroForNum(sData, 8); |
|
if (sData.substring(7, 8).equalsIgnoreCase("0")) { |
|
sValue = "无故障"; |
|
deviceInstallService.updateDeviceFault("0", addr, "热泵"); |
|
} else if (sData.substring(7, 8).equalsIgnoreCase("1")) { |
|
sValue = "有故障"; |
|
deviceInstallService.updateDeviceFault("1", addr, "热泵"); |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("0656") |
|
|| registerAddr.equalsIgnoreCase("065A") |
|
|| registerAddr.equalsIgnoreCase("065E")) { //读定时设置值 |
|
String startTime = checkStr.substring(8, 10) + checkStr.substring(12, 14); |
|
String closetTime = checkStr.substring(16, 18) + checkStr.substring(20, 22); |
|
sValue = startTime + closetTime; |
|
} |
|
stringBuffer.append(dataType); |
|
return sValue; |
|
} |
|
|
|
private String getMeiDiTwo(String registerAddr, String buildingId, String buildingName, String checkStr, String sValue, String addr, StringBuffer stringBuffer) { |
|
String data; |
|
String dataType = ""; |
|
stringBuffer.setLength(0); |
|
if (registerAddr.equalsIgnoreCase("0BBD")) { //运行状态 |
|
dataType = "runState"; |
|
data = ExchangeStringUtil.hexString2binaryString(checkStr.substring(8, 10)); |
|
data = ExchangeStringUtil.addZeroForNum(data, 8);//二进制数,补够8位 |
|
data = data.substring(4, 8); //截取后四位 |
|
log.info("------------美的2热泵状态值-----------" + data); |
|
if (data.equalsIgnoreCase("0000")) { //0 |
|
sValue = "不运行"; //关机 |
|
} else if (data.equalsIgnoreCase("0001")) {//1 |
|
sValue = "运行"; //水泵 |
|
} else if (data.equalsIgnoreCase("0010")) {//2 |
|
sValue = "运行"; //制冷 |
|
} else if (data.equalsIgnoreCase("0011")) {//3 |
|
sValue = "运行"; //制热 |
|
} else if (data.equalsIgnoreCase("0100")) {//4 |
|
sValue = "运行"; //热水 |
|
} else if (data.equalsIgnoreCase("0101")) {//5 |
|
sValue = "运行"; //采暖 |
|
} else if (data.equalsIgnoreCase("0110")) {//6 |
|
sValue = "运行"; //电热模式 |
|
} |
|
//计算热泵运行时间,按分钟 |
|
nowDataService.proPumpMinutes(buildingId, addr, sValue); |
|
log.info("计算热泵运行时长,楼栋名称:" + buildingName + ",热泵编号:" + addr + ",状态:" + sValue); |
|
} else if (registerAddr.equalsIgnoreCase("0003") || registerAddr.equalsIgnoreCase("0064")) { |
|
//0003设定温度,0064水箱水温 |
|
if (registerAddr.equalsIgnoreCase("0003")) { |
|
dataType = "tempSet"; |
|
} else { |
|
dataType = "waterTemp"; |
|
} |
|
//读数 |
|
sValue = ExchangeStringUtil.hexToDec(checkStr.substring(6, 10)); |
|
if (dataType.equals("waterTemp")) { |
|
String avgTemp = nowDataService.selectAve(buildingId); |
|
NowPublicDataEntity publicData = new NowPublicDataEntity(); |
|
publicData.setBuildingId(buildingId); |
|
publicData.setUseWaterTemp(avgTemp); |
|
publicData.setBackWaterTemp(avgTemp); |
|
String pumpId = nowDataService.selectMinPumpId(buildingId); |
|
// 如果是华夏,则取新增得字段标识为热泵ID |
|
String name = dealDataService.customName(); |
|
if (name.contains(Constant.CUSTOM_NAME_HUAXIA)) { |
|
pumpId = deviceInstallService.selectSinglePumpId(buildingId, addr); |
|
} |
|
log.info("---------------addr:" + addr + ",pumpId:" + pumpId + " ---------------"); |
|
if (addr.equals(pumpId)) { //取ID最小的热泵为单箱温度 |
|
publicData.setSingleTemp(sValue); |
|
log.info("---------------单箱温度:" + sValue + "---------------"); |
|
} |
|
nowPublicDataService.saveNowHistoryPublicData(publicData); |
|
log.info("楼栋名称:" + buildingName + ",热泵编号:" + addr); |
|
} else if (dataType.equals("tempSet")) { |
|
pumpSetService.updatePumpSetTemp(sValue, buildingId, addr); //更新设定温度 |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("0BBB")) { //故障状态 |
|
dataType = "isFault"; |
|
String sData = ExchangeStringUtil.hexString2binaryString(checkStr.substring(8, 10)); |
|
sData = ExchangeStringUtil.addZeroForNum(sData, 8); |
|
if (sData.substring(7, 8).equalsIgnoreCase("0")) { |
|
sValue = "无故障"; |
|
} else if (sData.substring(7, 8).equalsIgnoreCase("1")) { |
|
sValue = "有故障"; |
|
} |
|
} else if (registerAddr.equalsIgnoreCase("0656") |
|
|| registerAddr.equalsIgnoreCase("065A") |
|
|| registerAddr.equalsIgnoreCase("065E")) { //定时设置值 |
|
String startTime = ExchangeStringUtil.hexToDec(checkStr.substring(8, 10)) + ExchangeStringUtil.hexToDec(checkStr.substring(12, 14)); |
|
String closetTime = ExchangeStringUtil.hexToDec(checkStr.substring(16, 18)) + ExchangeStringUtil.hexToDec(checkStr.substring(20, 22)); |
|
sValue = startTime + closetTime; |
|
} |
|
stringBuffer.append(dataType); |
|
return sValue; |
|
} |
|
}
|
|
|