| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | public void setCacheData() { |
| | | |
| | | List<String> collect = list().stream().map(Light::getDeviceCode).collect(Collectors.toList()); |
| | | // collect.forEach( |
| | | // code -> { |
| | | // redisUtils.delete(DeviceRedisKey.LIGHT_DEVICE + code); |
| | | // } |
| | | // ); |
| | | List<List<String>> split = CollectionUtil.split(collect, 100); |
| | | |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = null; |
| | | List<RedisDeviceStatus> statusList = null; |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = new ArrayList<>(); |
| | | List<RedisDeviceStatus> statusList = new ArrayList<>(); |
| | | for (List<String> splist : split) { |
| | | deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist); |
| | | if (deviceStatuses != null) { |
| | |
| | | device.setStatus(0); |
| | | } else if ("OFFLINE".equals(deviceStatus.getStatus())) { |
| | | device.setStatus(1); |
| | | } else if ("UNACTIVE".equals(deviceStatus.getStatus())) { |
| | | device.setStatus(0); |
| | | } else if ("DISABLE".equals(deviceStatus.getStatus())) { |
| | | device.setStatus(0); |
| | | } else { |
| | | device.setStatus(2); |
| | | } |
| | |
| | | } |
| | | |
| | | statusList.forEach(status -> { |
| | | redisUtils.set(DeviceRedisKey.LIGHT_DEVICE + status.getDeviceId(), status); |
| | | redisUtils.set(DeviceRedisKey.LIGHT_DEVICE + status.getDeviceId(), JSON.toJSONString(status)); |
| | | }); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | A5LightSetCalendarReqInnerFrame setCalendarReqInnerFrame = |
| | | new A5LightSetCalendarReqInnerFrame(address, year % 100, month+1, day, hour, min, sec); |
| | | new A5LightSetCalendarReqInnerFrame(address, year % 100, month + 1, day, hour, min, sec); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), setCalendarReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | |
| | | Light light = getLight(deviceCode); |
| | | if (light == null) { |
| | | log.error("单灯主动同步时间请求异常,单灯信息不存在!"); |
| | | return; |
| | | } |
| | | //单灯任务信息 |
| | | LightTaskPoleRelation lightTaskPoleRelation = SpringContextHolder.getBean(LightTaskPoleRelationService.class) |