2021与蓝度共同重构项目,服务端
liuhaonan
2021-12-15 3e93229314ae6072f7bd82a30fa647644b1d185a
细节调整
已修改15个文件
已删除7个文件
653 ■■■■ 文件已修改
dao/src/main/java/com/sandu/ximon/dao/domain/Groups.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LCD.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LEDProgram.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LampPost.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/Pole.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/SOS.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/SingleLampData.java 82 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/GroupMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/PoleBindingMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/SingleLampDataMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/GroupMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LEDProgramMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/PoleMapper.xml 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/SingleLampDataMapper.xml 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/GroupController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LampPostController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/ReceiveParam.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/GroupService.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LampPostService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/Groups.java
ÎļþÒÑɾ³ý
dao/src/main/java/com/sandu/ximon/dao/domain/LCD.java
ÎļþÒÑɾ³ý
dao/src/main/java/com/sandu/ximon/dao/domain/LEDProgram.java
@@ -35,7 +35,7 @@
    private Integer kind;
    private String programUel;
    private String programUrl;
    private LocalDateTime createTime;
dao/src/main/java/com/sandu/ximon/dao/domain/LampPost.java
@@ -28,9 +28,11 @@
    private String name;
    /*所属客户*/
    @TableField(updateStrategy = FieldStrategy.IGNORED )
    private String belongsClient;
    /*客户id*/
    @TableField(updateStrategy = FieldStrategy.IGNORED )
    private Long clientId;
    /*路灯位置*/
@@ -47,6 +49,7 @@
    private String macCode;
    /*分组*/
    @TableField(updateStrategy = FieldStrategy.IGNORED )
    private String lampGroup;
    /*状态*/
dao/src/main/java/com/sandu/ximon/dao/domain/Pole.java
@@ -73,6 +73,11 @@
    private String deviceCode;
    /**
     * ç¯æ†åœ¨çº¿çŠ¶æ€
     */
    private String onLineState;
    /**
     * ç»‘定设备数量
     */
    private Integer bindingCount;
dao/src/main/java/com/sandu/ximon/dao/domain/SOS.java
ÎļþÒÑɾ³ý
dao/src/main/java/com/sandu/ximon/dao/domain/SingleLampData.java
@@ -1,58 +1,96 @@
package com.sandu.ximon.dao.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
 * å•灯数据
 * å•灯监控数据表
 * @TableName single_lamp_data
 */
@TableName(value ="single_lamp_data")
@Data
public class SingleLampData implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     *
     */
    private Long userId;
    /*灯杆名称*/
    /**
     * ç¯æ†åç§°
     */
    private String lampName;
    /*市电电压*/
    /**
     * å¸‚电电压
     */
    private Double mainsVoltage;
    /*市电电流*/
    /**
     * å¸‚电电流
     */
    private Double mainsCurrent;
    /*设备温度*/
    /**
     * è®¾å¤‡æ¸©åº¦
     */
    private Double temperature;
    /*功率因数*/
    /**
     * åŠŸçŽ‡å› æ•°
     */
    private Double powerFactor;
    /*有功功率*/
    /**
     * IMEI号
     */
    private String imei;
    /**
     * ICCID号
     */
    private String iccId;
    /**
     * æœ‰åŠŸåŠŸçŽ‡
     */
    private Integer activePower;
    /*本次亮灯时间*/
    /**
     * æœ¬æ¬¡äº®ç¯æ—¶é—´
     */
    private LocalDateTime lightingTime;
    /*本次用电量*/
    private Double electricityConsumption;
    /**
     * æœ¬æ¬¡ç”¨ç”µé‡
     */
    private Double electricityEonsumption;
    /*总用电量*/
    private Double totalAlectricityConsumption;
    /**
     * æ€»ç”¨ç”µé‡
     */
    private Double totalElectricityEonsumption;
    /*灯杆亮度*/
    /**
     * ç¯æ†äº®åº¦
     */
    private Double lightPoleBrightness;
    /*更新时间*/
    /**
     * æ›´æ–°æ—¶é—´
     */
    private LocalDateTime updateTime;
}
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}
dao/src/main/java/com/sandu/ximon/dao/mapper/GroupMapper.java
ÎļþÒÑɾ³ý
dao/src/main/java/com/sandu/ximon/dao/mapper/PoleBindingMapper.java
@@ -2,10 +2,12 @@
import com.sandu.ximon.dao.domain.PoleBinding;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * @Entity com.sandu.ximon.dao.domain.PoleBinding
 */
@Mapper
public interface PoleBindingMapper extends BaseMapper<PoleBinding> {
}
dao/src/main/java/com/sandu/ximon/dao/mapper/SingleLampDataMapper.java
@@ -1,9 +1,17 @@
package com.sandu.ximon.dao.mapper;
import com.sandu.common.domain.BaseMapper;
import com.sandu.ximon.dao.domain.SingleLampData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * @Entity com.sandu.ximon.dao.domain.SingleLampData
 */
@Mapper
public interface SingleLampDataMapper extends BaseMapper<SingleLampData> {
}
dao/src/main/resources/mapper/GroupMapper.xml
ÎļþÒÑɾ³ý
dao/src/main/resources/mapper/LEDProgramMapper.xml
@@ -11,6 +11,7 @@
        <result property="size" column="size" jdbcType="DOUBLE"/>
        <result property="pixel" column="pixel" jdbcType="VARCHAR"/>
        <result property="kind" column="kind" jdbcType="INTEGER"/>
        <result property="programUrl" column="program_url" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
dao/src/main/resources/mapper/PoleMapper.xml
@@ -5,27 +5,30 @@
<mapper namespace="com.sandu.ximon.dao.mapper.PoleMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Pole">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="poleCode" column="pole_code" jdbcType="BIGINT"/>
            <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
            <result property="clientId" column="client_id" jdbcType="BIGINT"/>
            <result property="province" column="province" jdbcType="VARCHAR"/>
            <result property="city" column="city" jdbcType="VARCHAR"/>
            <result property="region" column="region" jdbcType="VARCHAR"/>
            <result property="address" column="address" jdbcType="VARCHAR"/>
            <result property="lon" column="lon" jdbcType="DECIMAL"/>
            <result property="lat" column="lat" jdbcType="DECIMAL"/>
            <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
            <result property="bindingCount" column="binding_count" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="poleCode" column="pole_code" jdbcType="BIGINT"/>
        <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
        <result property="clientId" column="client_id" jdbcType="BIGINT"/>
        <result property="province" column="province" jdbcType="VARCHAR"/>
        <result property="city" column="city" jdbcType="VARCHAR"/>
        <result property="region" column="region" jdbcType="VARCHAR"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="lon" column="lon" jdbcType="DECIMAL"/>
        <result property="lat" column="lat" jdbcType="DECIMAL"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="onLineState" column="on_line_state" jdbcType="VARCHAR"/>
        <result property="bindingCount" column="binding_count" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,pole_code,pole_name,
        id
        ,pole_code,pole_name,
        client_id,province,city,
        region,address,lon,
        lat,device_code,binding_count,
        lat,device_code,
         binding_count,on_line_state,
        create_time,update_time
    </sql>
</mapper>
dao/src/main/resources/mapper/SingleLampDataMapper.xml
@@ -5,19 +5,22 @@
<mapper namespace="com.sandu.ximon.dao.mapper.SingleLampDataMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.SingleLampData">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <id property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="lampName" column="lamp_name" jdbcType="VARCHAR"/>
        <result property="mainsVoltage" column="mains_voltage" jdbcType="DOUBLE"/>
        <result property="mainsCurrent" column="mains_current" jdbcType="DOUBLE"/>
        <result property="temperature" column="temperature" jdbcType="DOUBLE"/>
        <result property="powerFactor" column="power_factor" jdbcType="DOUBLE"/>
        <result property="activePower" column="active_power" jdbcType="INTEGER"/>
        <result property="lightingTime" column="lighting_time" jdbcType="TIMESTAMP"/>
        <result property="electricityConsumption" column="electricity_eonsumption" jdbcType="DOUBLE"/>
        <result property="totalAlectricityConsumption" column="total_electricity_eonsumption" jdbcType="DOUBLE"/>
        <result property="lightPoleBrightness" column="light_pole_brightness" jdbcType="DOUBLE"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="lampName" column="lamp_name" jdbcType="VARCHAR"/>
            <result property="mainsVoltage" column="mains_voltage" jdbcType="DOUBLE"/>
            <result property="mainsCurrent" column="mains_current" jdbcType="DOUBLE"/>
            <result property="temperature" column="temperature" jdbcType="DOUBLE"/>
            <result property="powerFactor" column="power_factor" jdbcType="DOUBLE"/>
            <result property="imei" column="imei" jdbcType="VARCHAR"/>
            <result property="iccId" column="icc_Id" jdbcType="VARCHAR"/>
            <result property="activePower" column="active_power" jdbcType="INTEGER"/>
            <result property="lightingTime" column="lighting_time" jdbcType="TIMESTAMP"/>
            <result property="electricityEonsumption" column="electricity_eonsumption" jdbcType="DOUBLE"/>
            <result property="totalElectricityEonsumption" column="total_electricity_eonsumption" jdbcType="DOUBLE"/>
            <result property="lightPoleBrightness" column="light_pole_brightness" jdbcType="DOUBLE"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
</mapper>
</mapper>
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/GroupController.java
ÎļþÒÑɾ³ý
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LampPostController.java
@@ -81,12 +81,10 @@
        LambdaQueryWrapper<LampPost> wrapper = Wrappers.lambdaQuery(LampPost.class);
        if(receiveParam.getKeyWord()!=null){
            wrapper.like(LampPost::getLampId,receiveParam.getKeyWord())
                    .or(lampPostLambdaQueryWrapper -> {
                        lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord());
                    });
                    .or(lampPostLambdaQueryWrapper -> lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord()));
        }
        List<LampPost> lsit= poleService.list(wrapper);
        return ResponseUtil.success(lsit);
        List<LampPost> list= poleService.list(wrapper);
        return ResponseUtil.success(list);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -55,6 +55,30 @@
        return ResponseUtil.success(list);
    }
    @GetMapping("listPoleAndState")
    public ResponseVO<Object> listPoleAndState() {
        return ResponseUtil.success(poleService.queryStatesAndList());
    }
    /**
     * è®¾ç½®ä¸‰å…ƒç 
     */
    @PostMapping("/setMac")
    public ResponseVO<Object> setMac(@PathVariable Long poleId) {
        return ResponseUtil.success(poleService.setMac(poleId));
    }
    /**
     * æ¢å¤ç¯æ†å‡ºåŽ‚è®¾ç½®
     */
    @PostMapping("/poleReset")
    public ResponseVO<Object> poleReset(@PathVariable Long poleId) {
        return ResponseUtil.success(poleService.poleReset(poleId));
    }
    /**
     * ç¯æ†ç»‘定设备
     */
ximon-admin/src/main/java/com/sandu/ximon/admin/param/ReceiveParam.java
@@ -2,6 +2,9 @@
import lombok.Data;
/**
 * é€šç”¨çš„一个接收类
 */
@Data
public class ReceiveParam {
@@ -12,4 +15,12 @@
   private Integer kind;
   private String keyWord;
   private Integer lampPostType;
   private Integer lampPostState;
   private Integer bindState;
   private String groupName;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/GroupService.java
ÎļþÒÑɾ³ý
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LampPostService.java
@@ -132,6 +132,7 @@
                                    .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
            if ("00".equals(rebootFrame.getPayload())) {
                lampPost.setMacCode(uniqueMac);
                save= save(lampPost);
                System.out.println("重启成功");
@@ -202,6 +203,7 @@
        for (Long id : Id
        ) {
            lampPostMapper.serGroup(group, id);
        }
        // return updateBatchById(update);
@@ -229,7 +231,7 @@
                    post.setOnLineState(deviceStatus.getStatus());
                }
            }
            MacCodes.add(post.getMacCode());
          //  MacCodes.add(post.getMacCode());
        }
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java
@@ -6,7 +6,6 @@
import com.sandu.ximon.admin.param.PoleGroupParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.domain.PoleGroup;
import com.sandu.ximon.dao.mapper.GroupMapper;
import com.sandu.ximon.dao.mapper.PoleGroupMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -1,14 +1,30 @@
package com.sandu.ximon.admin.service;
import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse;
import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.redis.RedisService;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.A1Frame;
import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder;
import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.param.PoleParam;
import com.sandu.ximon.admin.redis.LightKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.PoleMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -16,7 +32,9 @@
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * ç¯æ†ç›¸å…³
@@ -79,6 +97,42 @@
        return Long.parseLong(sb.toString());
    }
    /**
     * æŸ¥è¯¢ç¯æ†çš„在线状态并赋值
     *
     * @return
     */
    public List<Pole> queryStatesAndList() {
        // List<LampPost> list = list(Wrappers.lambdaQuery(LampPost.class).eq(LampPost::getClientId, SecurityUtils.getUserId()));
        //List<Pole> list = list(Wrappers.lambdaQuery(Pole.class));
        List<Pole> list = new ArrayList<>();
        if (SecurityUtils.getClientId() == null) {
            list = list(Wrappers.lambdaQuery(Pole.class));
        } else {
            list = list(Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()));
        }
        List<String> MacCodes = new ArrayList<>();
        for (Pole post : list) {
            MacCodes.add(post.getDeviceCode());
        }
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(MacCodes);
        for (Pole post : list) {
            for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) {
                if (post.getDeviceCode().equals(deviceStatus.getDeviceName())) {
                    post.setOnLineState(deviceStatus.getStatus());
                }
            }
            //  MacCodes.add(post.getDeviceCode());
        }
        return list;
    }
    /**
     * ç¯æ†ç»‘定设备
     *
@@ -91,6 +145,136 @@
        if (pole == null) {
            throw new BusinessException("未找到该灯杆");
        }
        return poleBindingService.bindPole( poleId,  param);
        return poleBindingService.bindPole(poleId, param);
    }
    /**
     * ç¯æ†æ¢å¤å‡ºåŽ‚è®¾ç½®
     *
     * @param id
     * @return
     */
    public boolean poleReset(Long id) {
        Pole byId = getById(id);
        String deviceName = byId.getDeviceCode();
        if (byId == null) {
            throw new BusinessException("未找到该灯杆");
        }
        if (deviceName.isEmpty()) {
            throw new BusinessException("该灯杆Mca为空");
        }
        IRequestFrame build = FrameBuilder.builderA5()
                .orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode())
                .innerFrame(new A5LightResetReqInnerFrame())
                .build();
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(deviceName, build);
        System.out.println(commonFrame.toString());
        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(deviceName,
                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
        if ("00".equals(rebootFrame.getPayload())) {
            System.out.println("重启成功");
        }
        CommonFrame result = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(deviceName,
                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
        boolean b = false;
        if ("00".equals(result.getPayload())) {
            byId.setDeviceCode(null);
            b = updateById(byId);
            System.out.println("重启成功");
        }
        return b;
    }
    /**
     * ç»™ç¯æ†æ³¨å†Œä¸‰å…ƒç 
     */
    public boolean setMac(Long poleId) {
        Pole pole = getById(poleId);
        if (pole == null) {
            throw new BusinessException("未找到该灯杆");
        }
        boolean setMac = false;
        String baseMac = "baseDevice";
        A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac, a1Frame);
        if (commonFrame == null) {
            throw new BusinessException("读取设备唯一ID失败");
        }
        A1DeviceMacRespInnerFrame a1DeviceMacRespInnerFrame = new A1DeviceMacRespInnerFrame().transformFrame(commonFrame.getPayload());
        log.info(commonFrame.toString());
        String uniqueMac = a1DeviceMacRespInnerFrame.getMac();
        uniqueMac = uniqueMac.toLowerCase();
        log.info("唯一码{}", uniqueMac);
        // 2  ä»Žé˜¿é‡Œæ³¨å†Œ
        MainBoardInvokeSyncService.getInstance().registerDevice(uniqueMac);
        // 3  èŽ·å–è®¾å¤‡è¯¦æƒ…
        QueryDeviceDetailResponse.Data deviceDetail = MainBoardInvokeSyncService.getInstance().queryDeviceDetail(uniqueMac, null);
        if (deviceDetail == null) {
            throw new BusinessException("注册失败");
        }
        log.info(deviceDetail.toString());
        // 4   é…ç½®Mac①
        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> productKeyResp = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac,
                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(MainBoardInvokeSyncService.getInstance().getProductKey()))
                                .orderType(A1OrderEnum.REQUEST_SET_PRODUCT_KEY.getCode()).build(),
                        A1TernaryCodeRespInnerFrame.class);
        A1TernaryCodeRespInnerFrame responseInnerFrame = productKeyResp.getResponseInnerFrame();
        if (!MainBoardInvokeSyncService.getInstance().getProductKey().equals(responseInnerFrame.getTernaryCode())) {
            throw new BusinessException("设备配置ProductKey失败");
        }
        // 5   é…ç½®Mac②
        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac,
                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(uniqueMac))
                                .orderType(A1OrderEnum.REQUEST_SET_DEVICE_NAME.getCode()).build(),
                        A1TernaryCodeRespInnerFrame.class);
        A1TernaryCodeRespInnerFrame deviceNameFrame = responseCommonFrame.getResponseInnerFrame();
        if (!uniqueMac.equals(deviceNameFrame.getTernaryCode())) {
            throw new BusinessException("设备配置名失败");
        }
        // 6  é…ç½®Mac③
        WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> wrapResponseCommonFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac,
                        FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(deviceDetail.getDeviceSecret()))
                                .orderType(A1OrderEnum.REQUEST_SET_DEVICE_SECRET.getCode()).build(),
                        A1TernaryCodeRespInnerFrame.class);
        A1TernaryCodeRespInnerFrame deviceSecretFrame = wrapResponseCommonFrame.getResponseInnerFrame();
        if (!deviceDetail.getDeviceSecret().equals(deviceSecretFrame.getTernaryCode())) {
            throw new BusinessException("设备密钥失败");
        }
        // 7  é‡å¯è®¾å¤‡  å¹¶ä½¿ç”¨æ–°çš„Mac
        CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac,
                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
        if ("00".equals(rebootFrame.getPayload())) {
            pole.setDeviceCode(uniqueMac);
            setMac = updateById(pole);
            System.out.println("重启成功");
        }
        return setMac;
    }
}