jiazx0107@163.com
2023-12-14 231cdeb9b7a55ba08fb8cffda35f5535b9292873
src/main/java/com/fzzy/protocol/zldz/analysis/AnalysisConf.java
@@ -1,5 +1,7 @@
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;
@@ -25,11 +27,11 @@
     * 解析分机配置信息
     *
     * @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();
@@ -58,8 +60,9 @@
        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);
@@ -77,20 +80,18 @@
        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;
@@ -98,34 +99,33 @@
        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);
    }
    /**