diff --git a/user-service/src/main/java/com/mh/user/service/impl/DeviceControlServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/DeviceControlServiceImpl.java index 3a3d0a2..7e04c57 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/DeviceControlServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/DeviceControlServiceImpl.java @@ -159,6 +159,12 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setFunCode("10"); deviceCodeParam.setRegisterAddr("010C"); rtData = serialPortSingle.serialPortSend(deviceCodeParam); + } else if (!StringUtils.isBlank(brand) && brand.equals("蒙浩") && !rtData.equals(Constant.FAIL) && deviceCodeParam.getRegisterAddr().equals("0000")) { + log.error("进入蒙浩时控控制指令发送"); + // 需要继续发送指令 + deviceCodeParam.setFunCode("10"); + deviceCodeParam.setRegisterAddr("0004"); + rtData = serialPortSingle.serialPortSend(deviceCodeParam); } } } @@ -394,9 +400,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(1); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetClose1": @@ -405,9 +412,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(2); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetOpen2": @@ -416,9 +424,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(1); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetClose2": @@ -427,9 +436,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(2); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetOpen3": @@ -438,9 +448,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(1); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetClose3": @@ -449,9 +460,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(2); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetOpen4": @@ -460,9 +472,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(1); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "timeSetClose4": @@ -471,9 +484,10 @@ public class DeviceControlServiceImpl implements DeviceControlService { deviceCodeParam.setRegisterSize(2); if (Constant.WRITE.equals(type)) { deviceCodeParam.setFunCode("06"); - String[] time = split[1].split(":"); - deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); - serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time[0])*60 + Integer.parseInt(time[1]))); + String time1 = split[1].substring(0, 2); + String time2 = split[1].substring(2, 4); + deviceCodeParam.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); + serialPortModel.setDataValue(String.valueOf(Integer.parseInt(time1)*60 + Integer.parseInt(time2))); } break; case "channelSet": diff --git a/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java index 24acfb0..e46eac4 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java @@ -1,6 +1,7 @@ package com.mh.user.service.impl; import com.github.pagehelper.util.StringUtil; +import com.mh.user.constants.Constant; import com.mh.user.entity.DeviceCodeParamEntity; import com.mh.user.entity.DeviceInstallEntity; import com.mh.user.entity.DeviceInstallTempEntity; @@ -72,6 +73,17 @@ public class DeviceInstallServiceImpl implements DeviceInstallService { deviceCodeParamEntity.setThread(deviceInstallEntity.getDataCom().toLowerCase().replace("com", "")); // 顺便生成采集信息 switch (deviceInstallEntity.getDeviceType()) { + case "多路控制": + if (Constant.BRAND_YUAN_XIANG.equals(deviceInstallEntity.getBrand())) { + deviceCodeParamEntity.setRegisterAddr("0018");//DO点:读多路启停状态 + deviceCodeParamEntity.setFunCode("03"); + deviceCodeParamMapper.insertDeviceCodeParamList3(Collections.singletonList(deviceCodeParamEntity)); + + deviceCodeParamEntity.setRegisterAddr("0010");//DI点:读取多路运行故障状态 + deviceCodeParamEntity.setFunCode("03"); + deviceCodeParamMapper.insertDeviceCodeParamList3(Collections.singletonList(deviceCodeParamEntity)); + } + break; case "压变": case "温度变送器": case "温控": diff --git a/user-service/src/main/java/com/mh/user/strategy/TimeControlStrategy.java b/user-service/src/main/java/com/mh/user/strategy/TimeControlStrategy.java index c27464f..4d4d398 100644 --- a/user-service/src/main/java/com/mh/user/strategy/TimeControlStrategy.java +++ b/user-service/src/main/java/com/mh/user/strategy/TimeControlStrategy.java @@ -64,17 +64,17 @@ public class TimeControlStrategy implements DeviceStrategy { } else if (funCode.equals("10")) {//写 // 判断寄存器地址 registerAddr = registerAddr.toUpperCase(); - if ("0108".equals(registerAddr)) { + if ("0000".equals(registerAddr)) { // 1F1001080003060014001200225B97 str = str + funCode + registerAddr + "000306" - + "00" + dataValue.substring(2, 4) // 年 - + "00" + dataValue.substring(4,6) // 月 - + "00" + dataValue.substring(6,8); // 日 + + "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) ; // 日 } else if ("0004".equals(registerAddr)) { // 1F10010C0004080015004300300002BA23 str = str + funCode + registerAddr + "000306" - + "00" + dataValue.substring(8, 10) // 时 - + "00" + dataValue.substring(10,12) // 分 + + "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(8, 10)), 2) // 时 + + "00" + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(dataValue.substring(10, 12)), 2) // 分 + "0000"; // 秒 } } else if (funCode.equals("06")) {