2021与蓝度共同重构项目,服务端
liuhaonan
2022-01-07 9d25f1f915995603754646933934da945eb138d2
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -207,14 +207,14 @@
     */
    public boolean setMac(Long poleId) {
        Pole pole = getById(poleId);
        if (pole == null) {
    public boolean setMac(String baseMac) {
        //Pole pole = getById(poleId);
       /* if (pole == null) {
            throw new BusinessException("未找到该灯杆");
        }
        }*/
        boolean setMac = false;
        String baseMac = "baseDevice";
       // String baseMac = "baseDevice";
        A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame());
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance()
                .sendRRPC(baseMac, a1Frame);
@@ -225,6 +225,10 @@
        log.info(commonFrame.toString());
        String uniqueMac = a1DeviceMacRespInnerFrame.getMac();
        uniqueMac = uniqueMac.toLowerCase();
        if(uniqueMac.isEmpty()){
            throw new BusinessException("读取设备唯一ID失败!");
        }
        log.info("唯一码{}", uniqueMac);
        // 2  从阿里注册
@@ -277,12 +281,23 @@
                        FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame())
                                .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build());
        if ("00".equals(rebootFrame.getPayload())) {
            pole.setDeviceCode(uniqueMac);
          //  pole.setDeviceCode(uniqueMac);
            setMac = updateById(pole);
           // setMac = updateById(pole);
            System.out.println("重启成功");
        }
        Pole pole=new Pole();
        String strh = uniqueMac.substring(uniqueMac.length() -2,uniqueMac.length());
        pole.setDeviceCode(strh);
        pole.setPoleName(strh);
        String strm = uniqueMac.substring(0,uniqueMac.length()-2);
        int i = Integer.parseInt(strm);
        pole.setPoleCode(generatePoleCode());
        pole.setDeviceType(i);
        setMac= save(pole);
        return setMac;
    }