| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | /** |
| | | * 给灯杆注册三元码 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map setMac(String baseMac) { |
| | | |
| | | A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame()); |
| | |
| | | StoreOperationRecordsUtils.storeInnerFrameData(baseMac, "重启设备", build4, rebootFrame); |
| | | |
| | | if ("00".equals(rebootFrame.getPayload())) { |
| | | // pole.setDeviceCode(uniqueMac); |
| | | |
| | | // setMac = updateById(pole); |
| | | |
| | | System.out.println("重启成功"); |
| | | } |
| | | |
| | |
| | | if (pole == null) { |
| | | pole = new Pole(); |
| | | } |
| | | /* String type = uniqueMac.substring(uniqueMac.length() - 2, uniqueMac.length()); |
| | | String Code = uniqueMac.substring(0, uniqueMac.length() - 2);*/ |
| | | pole.setDeviceCode(uniqueMac); |
| | | pole.setPoleName(uniqueMac); |
| | | /* int i = Integer.parseInt(strm);*/ |
| | | if ("00".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | | pole.setDeviceType(0); |
| | | } else if ("01".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | |
| | | } |
| | | |
| | | pole.setPoleCode(generatePoleCode()); |
| | | // setMac = save(pole); |
| | | |
| | | boolean result = saveOrUpdate(pole); |
| | | |
| | | if (result) { |
| | | Light light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | } |
| | | |
| | | /** |
| | | * 实体灯杆注册日志记录开始 |
| | | */ |
| | | String content = "{灯杆ID:" + pole.getId() + ",灯杆编号:" + pole.getPoleCode() + ",灯杆名称:" + pole.getPoleName() + ",灯杆类型:" + pole.getDeviceType() + ",灯杆MAC:" + pole.getDeviceCode() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "实体灯杆注册", content); |
| | | // String content = "{灯杆ID:" + pole.getId() + ",灯杆编号:" + pole.getPoleCode() + ",灯杆名称:" + pole.getPoleName() + ",灯杆类型:" + pole.getDeviceType() + ",灯杆MAC:" + pole.getDeviceCode() + " }"; |
| | | // StoreOperationRecordsUtils.storeOperationData(null, null, "实体灯杆注册", content); |
| | | /** |
| | | * 实体灯杆注册日志记录结束 |
| | | */ |
| | | Map map = new HashMap(); |
| | | if (result) { |
| | | if (true) { |
| | | map.put("mac", uniqueMac); |
| | | } else { |
| | | map.put("mac", -1); |