| | |
| | | public List<LightBo> listLight(int pageNo, int pageSize, String keyword) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | |
| | | // PageHelper.startPage(pageNo, pageSize); |
| | | PageHelper.startPage(pageNo, pageSize); |
| | | |
| | | List<LightBo> listLight = baseMapper.listLight(clientId, keyword); |
| | | |
| | |
| | | //拆分list |
| | | List<List<String>> split = CollectionUtil.split(deviceCodeList, 100); |
| | | |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses=null; |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = null; |
| | | for (List<String> splist : split) { |
| | | deviceStatuses=MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist); |
| | | deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist); |
| | | if (deviceStatuses != null) { |
| | | for (LightBo lightBo : listLight) { |
| | | for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) { |
| | | |
| | | if (lightBo.getDeviceCode() != null && lightBo.getDeviceCode().equals(deviceStatus.getDeviceName())) { |
| | | if("ONLINE".equals(deviceStatus.getStatus()) ){ |
| | | if ("ONLINE".equals(deviceStatus.getStatus())) { |
| | | lightBo.setOnlineStatus(0); |
| | | }else if("OFFLINE".equals(deviceStatus.getStatus())){ |
| | | } else if ("OFFLINE".equals(deviceStatus.getStatus())) { |
| | | lightBo.setOnlineStatus(1); |
| | | }else { |
| | | } else { |
| | | lightBo.setOnlineStatus(2); |
| | | } |
| | | |
| | |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A5LightBrightnessRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a5Frame, A5LightBrightnessRespInnerFrame.class); |
| | | //存储控制帧指令 |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "单灯帧-亮度控制", a5Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | |
| | | currentWeekValue = 7; |
| | | } |
| | | map = new LinkedHashMap(); |
| | | map.put("time",localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | map.put("time", localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | map.put("value", getlist(currentWeekValue)); |
| | | temp.add(map); |
| | | } |
| | |
| | | currentWeekValue = 7; |
| | | } |
| | | map = new LinkedHashMap(); |
| | | map.put("time",localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | map.put("time", localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | map.put("value", getlistEnergy(currentWeekValue)); |
| | | temp.add(map); |
| | | } |
| | |
| | | */ |
| | | } |
| | | |
| | | /** |
| | | * 单个任务一天的节能率 |
| | | * |
| | | * @return |
| | | */ |
| | | public BigDecimal jisuan(LightTaskDto Task) { |
| | | final BigDecimal[] bigDecimalResult = {new BigDecimal(0.00)}; |
| | | /** |
| | | * 节能率计算开始 |
| | | */ |
| | | //TODO |
| | | ControlLightCommandVO startTime = parseSwitchLightCommand(Task.getOpenOrder()); |
| | | ControlLightCommandVO endTime = parseSwitchLightCommand(Task.getCloseOrder()); |
| | | //存放节能率 |
| | | //获取到单灯任务的节能率 |
| | | if (Task.getControlOrder() != null && !Task.getControlOrder().isEmpty()) {//有控等指令 拆分计算 |
| | | List<ControlLightCommandVO> controlLightCommandVOS = parseControlLightCommand(Task.getControlOrder()); |
| | | |
| | | for (int i = 0; i < controlLightCommandVOS.size(); i++) { |
| | | BigDecimal bigDecimal = calculateEnergySaving(startTime, controlLightCommandVOS.get(i)); |
| | | bigDecimalResult[0] = bigDecimalResult[0].add(bigDecimal); |
| | | if (controlLightCommandVOS.size() == (i + 1)) { |
| | | BigDecimal bigDecimal1 = calculateEnergySaving(controlLightCommandVOS.get(i), endTime); |
| | | bigDecimalResult[0] = bigDecimalResult[0].add(bigDecimal1); |
| | | break; |
| | | } |
| | | startTime = controlLightCommandVOS.get(i); |
| | | // saving.add(bigDecimal); |
| | | } |
| | | } else {//无控灯指令 直接计算 |
| | | BigDecimal bigDecimal = calculateEnergySaving(startTime, endTime); |
| | | // saving.add(bigDecimal); |
| | | bigDecimalResult[0] = bigDecimalResult[0].add(bigDecimal); |
| | | } |
| | | return bigDecimalResult[0]; |
| | | |
| | | /** |
| | | * 节能率计算结束 |
| | | */ |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 一天的能耗 |
| | |
| | | for (int i = 0; i < controlLightCommandVOS.size(); i++) { |
| | | //得到时长*亮度 |
| | | BigDecimal bigEnergy1 = calculateEnergyConsumption(startTime, controlLightCommandVOS.get(i)); |
| | | // //计算能耗(总 时长*亮度*功率) |
| | | BigDecimal totalEnergy = totalEnergy(bigEnergy1, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy); |
| | | // BigDecimal totalEnergy4 = totalEnergy(bigEnergy1, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | // bigEnergy[0] = bigEnergy[0].add(totalEnergy4); |
| | | //判断 Energy==0 则不计算 |
| | | if (bigEnergy1.compareTo(new BigDecimal(0)) != 0) { |
| | | //计算能耗(总 时长*亮度*功率) |
| | | BigDecimal totalEnergy = totalEnergy(bigEnergy1, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy); |
| | | } |
| | | if (controlLightCommandVOS.size() == (i + 1)) { |
| | | BigDecimal bigEnergy2 = calculateEnergyConsumption(controlLightCommandVOS.get(i), endTime); |
| | | |
| | | System.out.println(bigEnergy2 + "时长*亮度==========================="); |
| | | |
| | | //计算能耗(总 时长*亮度*功率) |
| | | BigDecimal totalEnergy3 = totalEnergy(bigEnergy2, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | // saving.add(bigDecimal1); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy3); |
| | | if (bigEnergy2.compareTo(new BigDecimal(0)) != 0) { |
| | | BigDecimal totalEnergy3 = totalEnergy(bigEnergy2, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy3); |
| | | } |
| | | break; |
| | | } |
| | | startTime = controlLightCommandVOS.get(i); |
| | |
| | | //计算能耗(部分 时长*亮度) |
| | | BigDecimal Energy = calculateEnergyConsumption(startTime, endTime); |
| | | //计算能耗(总 时长*亮度*功率) |
| | | BigDecimal totalEnergy = totalEnergy(Energy, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | //判断 Energy==0 则不计算 |
| | | if (Energy.compareTo(new BigDecimal(0)) != 0) { |
| | | BigDecimal totalEnergy = totalEnergy(Energy, Task.getLightAdress(), poleTaskLightPowerBos); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy); |
| | | } |
| | | |
| | | // saving.add(bigDecimal); |
| | | bigEnergy[0] = bigEnergy[0].add(totalEnergy); |
| | | |
| | | } |
| | | }); |
| | | return bigEnergy[0]; |