| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.sandu.ximon.admin.localMQTT.callback.StatusMqttCallBack.localMqttConnectStatusMap; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 16:00 |
| | |
| | | |
| | | // 获取最近的上报时间 |
| | | List<String> deviceCodeList = listLight.stream().map(Light::getDeviceCode).collect(Collectors.toList()); |
| | | //拆分list |
| | | |
| | | // //拆分list |
| | | List<List<String>> split = CollectionUtil.split(deviceCodeList, 100); |
| | | |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = null; |
| | |
| | | */ |
| | | public Light getLight(String deviceCode) { |
| | | Light one = getOne(Wrappers.<Light>lambdaQuery().eq(Light::getDeviceCode, deviceCode)); |
| | | Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode)); |
| | | if (o != null) { |
| | | one.setOnlineStatus(1); |
| | | if (one == null) { |
| | | return null; |
| | | } else { |
| | | one.setOnlineStatus(0); |
| | | Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode)); |
| | | if (o != null) { |
| | | one.setOnlineStatus(1); |
| | | } else { |
| | | one.setOnlineStatus(0); |
| | | } |
| | | return one; |
| | | } |
| | | return one; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (LightControlParam param : paramList) { |
| | | A5LightBrightnessReqInnerFrame lightControlFrame = new A5LightBrightnessReqInnerFrame(param.getBrightness(), param.getLightAddress()); |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), lightControlFrame); |
| | | A5LightBrightnessReqInnerFrame |
| | | lightControlFrame = new A5LightBrightnessReqInnerFrame(param.getBrightness(), param.getLightAddress()); |
| | | A5Frame a5Frame = new A5Frame( |
| | | A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), |
| | | lightControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A5LightBrightnessRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a5Frame, A5LightBrightnessRespInnerFrame.class); |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC |
| | | (param.getDeviceCode(), a5Frame, A5LightBrightnessRespInnerFrame.class); |
| | | //存储控制帧指令 |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "单灯帧-亮度控制", a5Frame, frame); |
| | | |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), setCalendarReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame; |
| | | |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a5Frame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getDeviceCode(), "单灯帧-设置日历", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | public void timeSynchronizationInitiative(String deviceCode, String lightAddress) { |
| | | //单灯信息 |
| | | Light light = getLight(deviceCode); |
| | | if (light == null) { |
| | | log.error("单灯主动同步时间请求异常,单灯信息不存在!"); |
| | | } |
| | | // if (light == null) { |
| | | // log.error("单灯主动同步时间请求异常,单灯信息不存在!"); |
| | | // return; |
| | | // } |
| | | //单灯任务信息 |
| | | LightTaskPoleRelation lightTaskPoleRelation = SpringContextHolder.getBean(LightTaskPoleRelationService.class) |
| | | .getOne(Wrappers.lambdaQuery(LightTaskPoleRelation.class) |
| | |
| | | count++; |
| | | } |
| | | if (haveTime) { |
| | | try { |
| | | long longTime = cal.getTimeInMillis() - System.currentTimeMillis(); |
| | | log.error("睡眠时间(毫秒):" + longTime); |
| | | Thread.sleep(longTime); |
| | | SetCalendar(light.getLightId(), lightAddress); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | log.error("存在定时任务:" + light.getLightId()+","+light.getDeviceCode()); |
| | | // try { |
| | | // long longTime = cal.getTimeInMillis() - System.currentTimeMillis(); |
| | | // log.error("睡眠时间(毫秒):" + longTime); |
| | | // Thread.sleep(longTime); |
| | | // SetCalendar(light.getLightId(), lightAddress); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | } else { |
| | | log.error("灯杆ID为:" + light.getLightId() + ",灯头地址为:" + lightAddress + "没有找到可同步的时间,请检查任务!"); |
| | | } |