| | |
| | | */ |
| | | |
| | | |
| | | 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); |
| | |
| | | log.info(commonFrame.toString()); |
| | | String uniqueMac = a1DeviceMacRespInnerFrame.getMac(); |
| | | uniqueMac = uniqueMac.toLowerCase(); |
| | | |
| | | if(uniqueMac.isEmpty()){ |
| | | throw new BusinessException("读取设备唯一ID失败!"); |
| | | } |
| | | log.info("唯一码{}", uniqueMac); |
| | | |
| | | // 2 从阿里注册 |
| | |
| | | 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; |
| | | } |
| | | |