中央热水项目
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.

1009 lines
59 KiB

package com.mh.user.utils;
import com.mh.common.utils.StringUtils;
import com.mh.user.constants.Constant;
import com.mh.user.entity.*;
import com.mh.user.service.DeviceCodeParamService;
import com.mh.user.service.DeviceInstallService;
import com.mh.user.service.impl.DeviceDisplayServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import java.util.ArrayList;
import java.util.List;
/**
* @author ljf
* @title :
* @description :
* @updateTime 2020-04-22
* @throws :
*/
@Slf4j
public class GetReadOrder485 {
// 调用service
ApplicationContext context = SpringBeanUtil.getApplicationContext();
DeviceDisplayServiceImpl.GatewayManageService gatewayManageService = context.getBean(DeviceDisplayServiceImpl.GatewayManageService.class);
DeviceInstallService deviceInstallService = context.getBean(DeviceInstallService.class);
DeviceCodeParamService deviceCodeParamService = context.getBean(DeviceCodeParamService.class);
// 电表
public static String createMeterOrder(DeviceCodeParamEntity orderParamModel) {
String str = "";
String deviceAddr = orderParamModel.getDeviceAddr();
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
//0代表前面补充0,12代表长度为12,d代表参数为正数型,基表通讯号
str = String.format("%012d", Long.parseLong(deviceAddr));
//转换位置
str = ExchangeStringUtil.changePosition(str);
//拼接功能码
str = "68" + str + "680102";
String strData = "1090";
//加33操作
str = str + ExchangeStringUtil.addThree(strData);
//检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);
str = "FEFEFE" + str + checkSum + "16";
} catch (Exception e) {
log.error("生成采集电表指令错误==>", e);
}
}
return str.toUpperCase();
}
// 水表
public static String createWtMeterOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
if (StringUtils.isBlank(brand) || brand.equals("艾美柯")) {
// 0 代表前面补充0,14 代表长度为14,d 代表参数为正数型
str = String.format("%014d", Long.parseLong(deviceAddr));//基表通讯号
// 转换位置
str = ExchangeStringUtil.changePosition(str);
// 拼接功能码
str = "6810" + str + "0103901F00"; //水表读读数指令
// 检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);
str = "FEFEFE" + str + checkSum + "16";
} else if (brand.equals("脉冲")) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2);
str = str + "0302020002";//读表累计值
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
}
} catch (Exception e) {
e.printStackTrace();
log.error("生成水表采集指令异常>>>>", e);
}
}
return str.toUpperCase();
}
// 热泵,参数:功能码、品牌、数据、通讯表号、寄存器地址
public static String createPumpOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String funCode = orderParamModel.getFunCode();
String registerAddr = orderParamModel.getRegisterAddr();
String dataValue = orderParamModel.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" + dataValue.substring(0, 2) + "00" + dataValue.substring(2, 4) + "00" + dataValue.substring(4, 6) + "00" + dataValue.substring(6, 8);
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; //写
}
}
}
}
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} catch (Exception e) {
log.info("热泵" + param + "指令>>>>异常" + str, e);
}
}
log.info("热泵" + param + "指令>>>>" + str);
return str.toUpperCase();
}
// 水位开关(水位设定)
public static String createRelayOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String funCode = orderParamModel.getFunCode();
String registerAddr = orderParamModel.getRegisterAddr();
String dataValue = orderParamModel.getDataValue();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
if (StringUtils.isBlank(brand) || Constant.BRAND_ZHONG_KAI.equals(brand)) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2);
if (StringUtils.isBlank(funCode) || funCode.equals("17")) { //读
str = "33" + str + "1700000000"; //旧版继电器
} else if (funCode.equals("12")) {//写
if (dataValue != null && !dataValue.equals("")) {
//0001(90%) 0002(80%) 0003(70%)...
if (dataValue.equals("100%")) {
registerAddr = "1300000000"; //全开
} else if (dataValue.equals("90%")) {
registerAddr = "1200000001";
} else if (dataValue.equals("80%")) {
registerAddr = "1200000002";
} else if (dataValue.equals("70%")) {
registerAddr = "1200000003";
} else if (dataValue.equals("60%")) {
registerAddr = "1200000004";
} else if (dataValue.equals("50%")) {
registerAddr = "1200000005";
} else if (dataValue.equals("40%")) {
registerAddr = "1200000006";
}
str = "33" + str + registerAddr; //示例:33011200000001
}
} else if (funCode.equals("13")) {//写
str = "33" + str + "1300000000"; //全开
} else {
str = "33" + str + "1400000000"; //全合
}
// 检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);
str = str + checkSum;
} else if (Constant.BRAND_YUAN_XIANG.equals(brand)) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2);
if (StringUtils.isBlank(funCode) || funCode.equals("03")) {//读
if (registerAddr.equalsIgnoreCase("0018")) { //读全部位置
str = str + "0300180008";
} else if (registerAddr.equalsIgnoreCase("0010")) { //读全部DI
str = str + "0300100008";
}
} else if (funCode.equals("06")) { // 写
if (!StringUtils.isBlank(dataValue)) {
if (dataValue.equals("100%")) {
registerAddr = "10001800081000000000000000000000000000000000"; //全开
} else if (dataValue.equals("90%")) {
registerAddr = "0600180001";
} else if (dataValue.equals("80%")) {
registerAddr = "0600190001";
} else if (dataValue.equals("70%")) {
registerAddr = "06001A0001";
} else if (dataValue.equals("60%")) {
registerAddr = "06001B0001";
} else if (dataValue.equals("50%")) {
registerAddr = "06001C0001";
} else if (dataValue.equals("40%")) {
registerAddr = "06001D0001";
}
//0018(90%) 0019(80%) 001A(70%)...
str = str + registerAddr; //示例:010600180001
}
} else {//写
if (dataValue.equals("0000")) {
str = str + "10001800081000000000000000000000000000000000"; //全开
} else {
str = str + "10001800081000010001000100010001000100010001"; //全合
}
}
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} else if (Constant.BRAND_DING_WEI.equals(brand)) {
str = String.format("%012d", Long.parseLong(deviceAddr));
//转换位置
str = ExchangeStringUtil.changePosition(str); //表号
String strData = "";
if (funCode.equals("0407")) {//写
str = "68" + str + "680407";
String mark = "25C0"; //C025交换位置
String strData1 = "00000000"; //命令带密码4字节,权限密码默认为00000000
String strData2 = "";
if (dataValue.equals("100%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00000000");
} else if (dataValue.equals("90%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00000001");
} else if (dataValue.equals("85%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00000011");
} else if (dataValue.equals("80%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00000111");
} else if (dataValue.equals("75%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00001111");
} else if (dataValue.equals("70%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00011111");
} else if (dataValue.equals("65%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00111111");
} else if (dataValue.equals("60%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("01111111");
} else if (dataValue.equals("50%")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("11111111");
} else if (dataValue.equals("自动")) {
strData2 = ExchangeStringUtil.parseByte2HexStr("00100110");
}
strData = mark + strData1 + strData2;
} else if (funCode.equals("0102")) { //读
str = "68" + str + "680102";
strData = "25C0"; //标志
}
strData = ExchangeStringUtil.addThree(strData); //加33
str = str + strData;
//检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);//校验
str = "FEFEFE" + str + checkSum + "16";
}
} catch (Exception e) {
if (registerAddr.equals("0010")) {
log.error("生成热泵状态指令出错!" + str, e);
} else {
log.error("生成水位开关指令出错!" + str, e);
}
}
}
return str.toUpperCase();
}
// 热泵状态(8路开关)
public static String createPumpStateOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String funCode = orderParamModel.getFunCode();
String registerAddr = orderParamModel.getRegisterAddr();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
if (StringUtils.isBlank(brand) || Constant.BRAND_ZHONG_KAI.equals(brand)) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2);
str = "33" + str + "1700000000"; //旧版继电器
// 检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);
str = str + checkSum;
} else if (Constant.BRAND_YUAN_XIANG.equals(brand)) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2);
str = str + "0300100008";
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} else if (Constant.BRAND_DING_WEI.equals(brand)) {
str = String.format("%012d", Long.parseLong(deviceAddr));
//转换位置
str = ExchangeStringUtil.changePosition(str); //表号
String strData = "";
str = "68" + str + "680102";
strData = "25C0"; //标志
// }
strData = ExchangeStringUtil.addThree(strData); //加33
str = str + strData;
//检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);//校验
str = "FEFEFE" + str + checkSum + "16";
}
} catch (Exception e) {
log.error("生成热泵状态指令出错!" + str, e);
}
}
log.info("生成热泵状态采集指令>>>>" + str);
return str.toUpperCase();
}
//状态检测
public static String createStateOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
// 0代表前面补充0,12代表长度为12,d代表参数为正数型.12位通讯地址,以0补位
str = String.format("%012d", Long.parseLong(deviceAddr));
// 转换位置
str = ExchangeStringUtil.changePosition(str);
// 拼接功能码
str = "68" + str + "680102";
String strData = "25C0";
// 加33操作
str = str + ExchangeStringUtil.addThree(strData);
// 检验和
String checkSum = ExchangeStringUtil.makeChecksum(str);
str = "FEFEFE" + str + checkSum + "16";
} catch (Exception e) {
log.error("生成状态检测指令出错!" + str, e);
}
}
return str.toUpperCase();
}
// 压变
public static String createPressureOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
str = ExchangeStringUtil.decToHex(deviceAddr); //十进制转为十六进制
str = ExchangeStringUtil.addZeroForNum(str, 2); //以0补位
if (Constant.BRAND_AU_SUN.equals(brand)) {
str = str + "0300040001"; // 新款压力变送器
} else if (Constant.BRAND_RU_YI.equals(brand)) {
str = str + "0300040001";
} else {
str = str + "0300000002"; // 压力变送器(新的协议)
}
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} catch (Exception e) {
log.info("生成压变指令出错!" + str, e);
}
}
return str.toUpperCase();
}
// 温控
public static String createTempOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String registerAddr = orderParamModel.getRegisterAddr();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2); //以0补位
// if(registerAddr.equals("")){
// str=str+"0300000002";
// }else if(registerAddr.equals("")){
// str=str+"0300000002";
// }
str = str + "0300000002";
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} catch (Exception e) {
log.error("生成温控指令出错!" + str, e);
}
}
return str.toUpperCase();
}
// 温度变送器
public static String createMulTempOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String registerAddr = orderParamModel.getRegisterAddr();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
try {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2); //以0补位
str = str + "0300280008"; //读8路温度
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} catch (Exception e) {
log.info("生成多路温度变送器指令出错!" + str, e);
}
}
return str.toUpperCase();
}
//时控设置,registerAddr 0009(L1)、000D(L2)、0011(L3) 读:010300090004、写:01100009000408+dataValue
public static String createTimeSetOrder(DeviceCodeParamEntity orderParamModel) {
String deviceAddr = orderParamModel.getDeviceAddr();
String brand = orderParamModel.getBrand();
String funCode = orderParamModel.getFunCode();
String registerAddr = orderParamModel.getRegisterAddr();
String dataValue = orderParamModel.getDataValue();
String str = "";
if (deviceAddr != null && deviceAddr.length() > 0) {
str = ExchangeStringUtil.decToHex(deviceAddr);
str = ExchangeStringUtil.addZeroForNum(str, 2); //以0补位
try {
if (!StringUtils.isBlank(funCode)) {
registerAddr = ExchangeStringUtil.addZeroForNum(registerAddr, 4); //寄存器地址
funCode = ExchangeStringUtil.addZeroForNum(funCode, 2); // 功能码
if (funCode.equals("03")) { //功能码,读
if (orderParamModel.getParam().equals("checkTime")) {
// 读取时间:0A 03 00 00 00 03 04 B0
str = str + "03" + registerAddr + "0003";
} else {
str = str + "03" + registerAddr + "0004";
}
} else if (funCode.equals("10")) {//写
if (!dataValue.equals("") && !orderParamModel.getParam().equals("checkTime")) {
str = str + "10" + registerAddr + "000408" + dataValue;
} else {
// 校验时间:0A 10 00 00 00 03 06 00 24 01 10 08 59 48 CF
// 0A 10 00 00 00 03 06 00 24 01 10 09 40 8B 95
str = str + "10" + registerAddr + "00030600" + dataValue.substring(2);
}
}
}
String checkWord = ExchangeStringUtil.getStrCRC16(str); //CRC16校验
str = str + checkWord;
} catch (Exception e) {
log.error("生成时控指令出错!" + str, e);
}
}
return str.toUpperCase();
}
// 冷量计
public static String createCloudOrder(String IP, String port, String dataCom, String cloudNum, String cloudType) {
IP = ExchangeStringUtil.ipToHex(IP);
port = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(port), 4);
dataCom = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(ExchangeStringUtil.getNumFromString(dataCom)), 2);
String str1 = IP + port + dataCom;
// 0 代表前面补充0,2 代表长度为2,d 代表参数为正数型
String str = ExchangeStringUtil.decToHex(cloudNum);
str = String.format("%02d", Long.parseLong(str));
if (cloudType.equalsIgnoreCase("4")) { //温控设备,地址为十六进制
str = str + "0300000002";
} else if (cloudType.equalsIgnoreCase("31")) { //流量计冷冻水量
str = str + "0300080002";
} else if (cloudType.equalsIgnoreCase("32")) { // 流量计出水温度
str = str + "0300490002";
} else if (cloudType.equalsIgnoreCase("33")) { // 流量计回水温度
str = str + "03004B0002";
} else if (cloudType.equalsIgnoreCase("34")) { // 流量计冷量累积量
str = str + "0300500002";
}
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(str);
int checkNum = CRC16.CRC16_MODBUS(strOrder);
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum));
checkWord = ExchangeStringUtil.addZeroForNum(checkWord, 4);
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2);
str = str + checkWord;
// 拼接字符
str = str1 + str;
str = ExchangeStringUtil.getCRCStr(str);
return str.toUpperCase();
}
/**
* // 冷水机组 指令:IP+端口+COM口+数据+modeBus校验
*
* @param chillersEntity
* @return
*/
public String createChillersOrder(ChillersEntity chillersEntity) {
String str = null;
try {
log.info(chillersEntity.toString());
// 获取IP地址,转16进制
String ip = chillersEntity.getIP();
ip = ExchangeStringUtil.ipToHex(ip);
str = ip;
// 获取端口号,转16进制
int port = chillersEntity.getPort();
String portStr = ExchangeStringUtil.decToHex(String.valueOf(port));
portStr = ExchangeStringUtil.addZeroForNum(portStr, 4);
str += portStr;
// 获取COM口
String com = ExchangeStringUtil.getNumFromString(chillersEntity.getDataCom());
String dataCom = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(com), 2);
str += dataCom;
// 获取冷水机组地址
String chillerAddr = chillersEntity.getCollectionNum();
chillerAddr = ExchangeStringUtil.decToHex(chillerAddr);
String str1 = ExchangeStringUtil.addZeroForNum(chillerAddr, 2);
// 获取功能码
String funCode = chillersEntity.getFunCode();
str1 = str1 + ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(funCode), 2);
// 寄存器地址
String registerAddr = chillersEntity.getRegisterAddress();
str1 = str1 + ExchangeStringUtil.addZeroForNum(registerAddr, 4) + "0001";
log.info(str1);
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(str1);
int checkNum = CRC16.CRC16_MODBUS(strOrder);
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum));
checkWord = ExchangeStringUtil.addZeroForNum(checkWord, 4);
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2);
str1 = str1 + checkWord;
// 拼接新的采集报文
str = str + str1;
str = ExchangeStringUtil.getCRCStr(str);
} catch (Exception e) {
e.printStackTrace();
}
log.info("发送采集数据>>>>" + str);
return str.toUpperCase();
}
// DDC 设备指令生成
// 服务端 IP(HEX) + 端口(HEX) + 设备地址号(HEX) + CRC16 校验
public static String createDDCOrder(ChillersEntity chillersEntity) {
String result = "";
// 把IP地址转为16进制
String ip = ExchangeStringUtil.ipToHex(chillersEntity.getIP());
// 端口号转为16进制
String port = ExchangeStringUtil.decToHex(String.valueOf(chillersEntity.getPort()));
// DDC地址
String ddcAddr = ExchangeStringUtil.decToHex(chillersEntity.getDdcAddr());
// 拼接成采集报文
result = ip + port + ddcAddr;
// 得出校验位后的值
result = ExchangeStringUtil.getCRCStr(result);
return result;
}
// 生成对设备操作指令参数
public void createOrderParam() {
List<DeviceInstallEntity> deviceList1;
deviceCodeParamService.selectInsertDeviceCodeParam(); //查询插入设备采集参数,包括压变、温控、温度变送器、热泵状态
deviceList1 = deviceInstallService.selectDeviceParams();//查找多个采集参数的设备,包括热泵
// System.out.println(deviceList1);
for (DeviceInstallEntity devices : deviceList1) {
List<DeviceCodeParamEntity> deviceCodeParamEntityList = new ArrayList<>();
if (devices.getDeviceType().equals("热泵")) {
DeviceCodeParamEntity deviceCodeParamEntity3 = new DeviceCodeParamEntity();
switch(devices.getBrand()) {
case "美的":
deviceCodeParamEntity3.setRegisterAddr("0007");//实际水温
deviceCodeParamEntity3.setFunCode("03");
deviceCodeParamEntity3.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity3.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity3.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity3.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity3.setBrand(devices.getBrand());
deviceCodeParamEntity3.setDataCom(devices.getDataCom());
deviceCodeParamEntity3.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity3.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity3);
break;
case "美的2":
deviceCodeParamEntity3.setRegisterAddr("0064");//实际水温
deviceCodeParamEntity3.setFunCode("03");
deviceCodeParamEntity3.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity3.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity3.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity3.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity3.setBrand(devices.getBrand());
deviceCodeParamEntity3.setDataCom(devices.getDataCom());
deviceCodeParamEntity3.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity3.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity3);
break;
case "瑞星":
deviceCodeParamEntity3.setRegisterAddr("0046");//实际水温
deviceCodeParamEntity3.setFunCode("03");
deviceCodeParamEntity3.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity3.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity3.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity3.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity3.setBrand(devices.getBrand());
deviceCodeParamEntity3.setDataCom(devices.getDataCom());
deviceCodeParamEntity3.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity3.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity3);
break;
default:
break;
}
// if (devices.getBrand().equals("美的")) {
// DeviceCodeParamEntity deviceCodeParamEntity3 = new DeviceCodeParamEntity();
// deviceCodeParamEntity3.setRegisterAddr("0007");//水温
// deviceCodeParamEntity3.setFunCode("03");
// deviceCodeParamEntity3.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity3.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity3.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity3.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity3.setBrand(devices.getBrand());
// deviceCodeParamEntity3.setDataCom(devices.getDataCom());
// deviceCodeParamEntity3.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity3.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity3);
//
// } else if (devices.getBrand().equals("美的2")) {
//
// DeviceCodeParamEntity deviceCodeParamEntity3 = new DeviceCodeParamEntity();
// deviceCodeParamEntity3.setRegisterAddr("0064");//水温
// deviceCodeParamEntity3.setFunCode("03");
// deviceCodeParamEntity3.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity3.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity3.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity3.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity3.setBrand(devices.getBrand());
// deviceCodeParamEntity3.setDataCom(devices.getDataCom());
// deviceCodeParamEntity3.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity3.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity3);
// }
}
deviceCodeParamService.insertDeviceCodeParamList(deviceCodeParamEntityList);
}
}
// 生成对设备操作指令参数
public void createOrderParam2() {
List<DeviceInstallEntity> deviceList1;
deviceCodeParamService.selectInsertDeviceCodeParam2(); //查询插入设备采集参数,包括水、电表、状态检测
deviceList1 = deviceInstallService.selectDeviceParams(); //查找多个采集参数的设备,包括热泵
System.out.println(deviceList1);
for (DeviceInstallEntity devices : deviceList1) {
List<DeviceCodeParamEntity> deviceCodeParamEntityList = new ArrayList<>();
if (devices.getDeviceType().equals("热泵")) {
DeviceCodeParamEntity deviceCodeParamEntity1 = new DeviceCodeParamEntity();
switch (devices.getBrand()) {
case "美的":
deviceCodeParamEntity1.setRegisterAddr("0641"); //运行状态
deviceCodeParamEntity1.setFunCode("03");
deviceCodeParamEntity1.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity1.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity1.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity1.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity1.setBrand(devices.getBrand());
deviceCodeParamEntity1.setDataCom(devices.getDataCom());
deviceCodeParamEntity1.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity1.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity1);//添加到列表
break;
case "美的2":
deviceCodeParamEntity1.setRegisterAddr("0BBD"); //运行状态
deviceCodeParamEntity1.setFunCode("03");
deviceCodeParamEntity1.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity1.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity1.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity1.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity1.setBrand(devices.getBrand());
deviceCodeParamEntity1.setDataCom(devices.getDataCom());
deviceCodeParamEntity1.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity1.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity1);//添加到列表
break;
case "瑞星":
deviceCodeParamEntity1.setRegisterAddr("0001"); //运行状态
deviceCodeParamEntity1.setFunCode("03");
deviceCodeParamEntity1.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity1.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity1.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity1.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity1.setBrand(devices.getBrand());
deviceCodeParamEntity1.setDataCom(devices.getDataCom());
deviceCodeParamEntity1.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity1.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity1);//添加到列表
break;
default:
break;
}
// if (devices.getBrand().equals("美的")) {
// DeviceCodeParamEntity deviceCodeParamEntity1 = new DeviceCodeParamEntity();
// deviceCodeParamEntity1.setRegisterAddr("0641"); //运行状态
// deviceCodeParamEntity1.setFunCode("03");
// deviceCodeParamEntity1.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity1.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity1.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity1.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity1.setBrand(devices.getBrand());
// deviceCodeParamEntity1.setDataCom(devices.getDataCom());
// deviceCodeParamEntity1.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity1.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity1);//添加到列表
// } else if (devices.getBrand().equals("美的2")) {
// DeviceCodeParamEntity deviceCodeParamEntity1 = new DeviceCodeParamEntity();
// deviceCodeParamEntity1.setRegisterAddr("0BBD"); //运行状态
// deviceCodeParamEntity1.setFunCode("03");
// deviceCodeParamEntity1.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity1.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity1.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity1.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity1.setBrand(devices.getBrand());
// deviceCodeParamEntity1.setDataCom(devices.getDataCom());
// deviceCodeParamEntity1.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity1.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity1);//添加到列表
// }
}
deviceCodeParamService.insertDeviceCodeParamList2(deviceCodeParamEntityList);
}
}
// 生成对设备操作指令参数
public void createOrderParam3() {
List<DeviceInstallEntity> deviceList1;
// deviceCodeParamService.selectInsertDeviceCodeParam3(); //查询插入设备采集参数-水位开关
deviceList1 = deviceInstallService.selectDeviceParams2(); //查找多个采集参数的设备,包括热泵、水位开关
System.out.println(deviceList1);
for (DeviceInstallEntity devices : deviceList1) {
List<DeviceCodeParamEntity> deviceCodeParamEntityList = new ArrayList<>();
if (devices.getDeviceType().equals("热泵")) {
DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
DeviceCodeParamEntity deviceCodeParamEntity4 = new DeviceCodeParamEntity();
switch (devices.getBrand()) {
case "美的":
deviceCodeParamEntity2.setRegisterAddr("0642");//设定温度
deviceCodeParamEntity2.setFunCode("03");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
deviceCodeParamEntity4.setRegisterAddr("000B");//故障状态
deviceCodeParamEntity4.setFunCode("03");
deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity4.setBrand(devices.getBrand());
deviceCodeParamEntity4.setDataCom(devices.getDataCom());
deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity4.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity4);
break;
case "美的2":
deviceCodeParamEntity2.setRegisterAddr("0003");//设定温度
deviceCodeParamEntity2.setFunCode("03");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
deviceCodeParamEntity4.setRegisterAddr("0BBB");//故障状态
deviceCodeParamEntity4.setFunCode("03");
deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity4.setBrand(devices.getBrand());
deviceCodeParamEntity4.setDataCom(devices.getDataCom());
deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity4.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity4);
break;
case "瑞星":
deviceCodeParamEntity2.setRegisterAddr("000A");//设定温度
deviceCodeParamEntity2.setFunCode("03");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
deviceCodeParamEntity4.setRegisterAddr("0050");//故障状态
deviceCodeParamEntity4.setFunCode("03");
deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity4.setBrand(devices.getBrand());
deviceCodeParamEntity4.setDataCom(devices.getDataCom());
deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity4.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity4);
break;
}
// if (devices.getBrand().equals("美的")) {
// DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
// deviceCodeParamEntity2.setRegisterAddr("0642");//设定温度
// deviceCodeParamEntity2.setFunCode("03");
// deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity2.setBrand(devices.getBrand());
// deviceCodeParamEntity2.setDataCom(devices.getDataCom());
// deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity2.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity2);
//
// DeviceCodeParamEntity deviceCodeParamEntity4 = new DeviceCodeParamEntity();
// deviceCodeParamEntity4.setRegisterAddr("000B");//故障状态
// deviceCodeParamEntity4.setFunCode("03");
// deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity4.setBrand(devices.getBrand());
// deviceCodeParamEntity4.setDataCom(devices.getDataCom());
// deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity4.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity4);
//
// } else if (devices.getBrand().equals("美的2")) {
//
// DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
// deviceCodeParamEntity2.setRegisterAddr("0003");//设定温度
// deviceCodeParamEntity2.setFunCode("03");
// deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity2.setBrand(devices.getBrand());
// deviceCodeParamEntity2.setDataCom(devices.getDataCom());
// deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity2.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity2);
//
// DeviceCodeParamEntity deviceCodeParamEntity4 = new DeviceCodeParamEntity();
// deviceCodeParamEntity4.setRegisterAddr("0BBB");//故障状态
// deviceCodeParamEntity4.setFunCode("03");
// deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
// deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
// deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
// deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
// deviceCodeParamEntity4.setBrand(devices.getBrand());
// deviceCodeParamEntity4.setDataCom(devices.getDataCom());
// deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
// deviceCodeParamEntity4.setParity(devices.getParity());
// deviceCodeParamEntityList.add(deviceCodeParamEntity4);
// }
}
if (devices.getDeviceType().equals("水位开关")) {
if (devices.getBrand().equals("远向")) {
DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
deviceCodeParamEntity2.setRegisterAddr("0018");//读水位设定
deviceCodeParamEntity2.setFunCode("03");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
DeviceCodeParamEntity deviceCodeParamEntity4 = new DeviceCodeParamEntity();
deviceCodeParamEntity4.setRegisterAddr("0010");//读热泵状态、上水用水状态
deviceCodeParamEntity4.setFunCode("03");
deviceCodeParamEntity4.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity4.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity4.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity4.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity4.setBrand(devices.getBrand());
deviceCodeParamEntity4.setDataCom(devices.getDataCom());
deviceCodeParamEntity4.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity4.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity4);
} else if (devices.getBrand().equals("中凯")) {
DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
deviceCodeParamEntity2.setRegisterAddr("0017");//读水位设定
deviceCodeParamEntity2.setFunCode("03");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
} else { //顶威
DeviceCodeParamEntity deviceCodeParamEntity2 = new DeviceCodeParamEntity();
deviceCodeParamEntity2.setRegisterAddr("0102");//读水位设定
deviceCodeParamEntity2.setFunCode("0102");
deviceCodeParamEntity2.setDeviceAddr(devices.getDeviceAddr());
deviceCodeParamEntity2.setDeviceName(devices.getDeviceName());
deviceCodeParamEntity2.setDeviceType(devices.getDeviceType());
deviceCodeParamEntity2.setBaudrate(devices.getBaudRate());
deviceCodeParamEntity2.setBrand(devices.getBrand());
deviceCodeParamEntity2.setDataCom(devices.getDataCom());
deviceCodeParamEntity2.setBuildingId(devices.getBuildingId());
deviceCodeParamEntity2.setParity(devices.getParity());
deviceCodeParamEntityList.add(deviceCodeParamEntity2);
}
}
deviceCodeParamService.insertDeviceCodeParamList3(deviceCodeParamEntityList);
}
}
}