|
|
|
|
@ -185,6 +185,29 @@ public class HeatPumpStrategy implements DeviceStrategy {
|
|
|
|
|
String dataStr = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(dataValue)), 4); |
|
|
|
|
str = str + funCode + registerAddr + dataStr; |
|
|
|
|
} |
|
|
|
|
} else if (Constant.BRAND_HAI_ER_TWO.equals(brand)) { |
|
|
|
|
if (StringUtils.isBlank(funCode) || funCode.equals("03") || funCode.equals("04")) { |
|
|
|
|
if (StringUtils.isBlank(registerAddr) |
|
|
|
|
|| registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1300"),4))) { // 运行状态
|
|
|
|
|
str = str + funCode +registerAddr+"0001"; |
|
|
|
|
param = "运行状态"; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1057"),4))) { // 水温
|
|
|
|
|
str = str + funCode +registerAddr+"0001"; |
|
|
|
|
param = "实际温度"; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1004"),4))) { // 故障状态,100*N+11
|
|
|
|
|
str = str + funCode + registerAddr+"0001"; |
|
|
|
|
param = "故障状态"; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1302"),4))) { // 读温度设定
|
|
|
|
|
str = str + funCode + 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; |
|
|
|
|
@ -227,6 +250,8 @@ public class HeatPumpStrategy implements DeviceStrategy {
|
|
|
|
|
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); |
|
|
|
|
} else if (Constant.BRAND_HAI_ER_TWO.equals(brand)) { |
|
|
|
|
rtData = getHaiErTwo(dateStr, registerAddr, buildingId, buildingName, checkStr, sValue, addr, dataType); |
|
|
|
|
} |
|
|
|
|
if (!StringUtils.isBlank(rtData)) { |
|
|
|
|
nowDataService.saveNowHistoryData(addr, "热泵", rtData, dataType.toString(), buildingId); |
|
|
|
|
@ -319,6 +344,88 @@ public class HeatPumpStrategy implements DeviceStrategy {
|
|
|
|
|
return sValue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getHaiErTwo(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") || checkStr.substring(2, 4).equalsIgnoreCase("04")) {//读
|
|
|
|
|
if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1300"), 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("1302"), 4)) |
|
|
|
|
|| registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1057"), 4)) ) { |
|
|
|
|
//20003设定温度,20026水箱水温
|
|
|
|
|
if (registerAddr.equalsIgnoreCase(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1302"), 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("1004"), 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("1300")) { //运行状态
|
|
|
|
|
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 = ""; |
|
|
|
|
|