| | |
| | | package com.fzzy.protocol.zldz.analysis; |
| | | |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiCommonDevice; |
| | | import com.fzzy.api.utils.BytesUtil; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.service.GatewayDeviceService; |
| | |
| | | * 解析分机配置信息 |
| | | * |
| | | * @param message |
| | | * @param ser |
| | | * @param device |
| | | */ |
| | | public void analysis8816(ReMessage message, GatewayDevice ser) { |
| | | public void analysis8816(ReMessage message, GatewayDevice device, ApiCommonDevice commonDevice) { |
| | | |
| | | log.debug("分机---->>>平台:消息类型=8816-----{}", ser.getDeviceName()); |
| | | log.debug("分机---->>>平台:消息类型=8816-----{}", device.getDeviceName()); |
| | | |
| | | String content = message.getBody().getContent(); |
| | | |
| | |
| | | len = 1; |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | | |
| | | // 层数 |
| | | //层 -行 -列 |
| | | String cable = ""; |
| | | // 层数 |
| | | start = 6; |
| | | len = 1; |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | | cable += "-" + BytesUtil.hexToInt(temp); |
| | | |
| | | //层 - 行 - 列 配置 |
| | | ser.setCableRule(cable); |
| | | |
| | | // 电缆制式 |
| | | start = 9; |
| | | len = 1; |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | | ser.setCableFormat("0" + BytesUtil.hexToInt(temp)); |
| | | device.setCableFormat("0" + BytesUtil.hexToInt(temp)); |
| | | |
| | | // 电缆类型 |
| | | start = 10; |
| | | len = 1; |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | | ser.setCableType("0" + BytesUtil.hexToInt(temp)); |
| | | device.setCableType("0" + BytesUtil.hexToInt(temp)); |
| | | |
| | | // 供电模式 |
| | | start = 11; |
| | |
| | | temp = content.substring(start * 2, start * 2 + len * 2); |
| | | //ser.setPowerModel("0" + BytesUtil.hexToInt(temp)); |
| | | |
| | | String msg = ser.getDeviceName() + " 远程获取配置成功,请刷新数据查看!"; |
| | | |
| | | // 组织编码 |
| | | start = 12; |
| | | temp = content.substring(start * 2); |
| | | if (readTag == 1) {// 表示写的成功返回 |
| | | ser.setOrgId(ser.getOrgId()); |
| | | msg = ser.getDeviceName() + " 远程写入成功,请刷新数据查看!"; |
| | | } else { |
| | | ser.setOrgId(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) + ""); |
| | | if (readTag != 1) {// 表示写的成功返回 |
| | | device.setOrgId(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) + ""); |
| | | } |
| | | |
| | | if (null == ser.getDeviceSn()) { |
| | | ser.setDeviceSn(ser.getId()); |
| | | } |
| | | ser.setIp(message.getIp()); |
| | | ser.setPort(message.getPort()); |
| | | device.setIp(message.getIp()); |
| | | device.setPort(message.getPort()); |
| | | |
| | | // 开始列默认=1 |
| | | if (ser.getCableStart() == 0) { |
| | | ser.setCableStart(1); |
| | | if (null == device.getCableStart()) { |
| | | device.setCableStart("1"); |
| | | } |
| | | |
| | | log.info("分机---->>>平台:分机配置解析完成---{},更新到服服务器", |
| | | ser.getDeviceName()); |
| | | device.getDeviceName()); |
| | | |
| | | //更新设备信息 |
| | | gatewayDeviceService.updateData(ser); |
| | | gatewayDeviceService.updateData(device); |
| | | |
| | | //更新连接设备信息 |
| | | commonDevice.setSn(device.getDeviceSn()); |
| | | commonDevice.setCable(cable); |
| | | commonDevice.setOrgId(device.getOrgId()); |
| | | Constant.updateCache(commonDevice); |
| | | } |
| | | |
| | | /** |