| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -114,6 +114,9 @@ public class RealTargetServiceImpl implements RealTargetService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final static String recent_year_power_data = "hzims:operation:key:power:data"; | 
					 | 
					 | 
					 | 
						private final static String recent_year_power_data = "hzims:operation:key:power:data"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private final static String recent_year_power_data_test = "hzims:operation:key:power:data:test"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; | 
					 | 
					 | 
					 | 
						private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; | 
					 | 
					 | 
					 | 
						private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; | 
					 | 
					 | 
					 | 
						private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -1275,72 +1278,87 @@ public class RealTargetServiceImpl implements RealTargetService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Override | 
					 | 
					 | 
					 | 
						@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
						public void loadPowerDataNew(String param, List<Integer> types, Integer serveType, int year) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void loadPowerDataNew(List<Integer> types, Integer serveType, int year) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 站点查询
 | 
					 | 
					 | 
					 | 
							// 站点查询
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{ | 
					 | 
					 | 
					 | 
							List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								eq(StationEntity::getDataOrigin,"0"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (ObjectUtil.isNotEmpty(serveType)) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									eq(StationEntity::getServeType, serveType); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (CollectionUtil.isNotEmpty(types)) { | 
					 | 
					 | 
					 | 
								if (CollectionUtil.isNotEmpty(types)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									in(StationEntity::getType, types); | 
					 | 
					 | 
					 | 
									in(StationEntity::getType, types); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}}); | 
					 | 
					 | 
					 | 
							}}); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 设备信息
 | 
					 | 
					 | 
					 | 
							// 设备信息
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							List<EminfoAndEmParamVo> devices  = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), | 
					 | 
					 | 
					 | 
							List<EminfoAndEmParamVo> devices  = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									new TypeReference<List<EminfoAndEmParamVo>>() {}); | 
					 | 
					 | 
					 | 
							}); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 结束时间
 | 
					 | 
					 | 
					 | 
							// 开始时间
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Calendar calendar = Calendar.getInstance(); | 
					 | 
					 | 
					 | 
							Calendar calendar = Calendar.getInstance(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); | 
					 | 
					 | 
					 | 
							calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); | 
					 | 
					 | 
					 | 
							calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; | 
					 | 
					 | 
					 | 
							String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							LocalDateTime endTime = LocalDateTime.parse(end); | 
					 | 
					 | 
					 | 
							// 结束日期
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 开始时间
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); | 
					 | 
					 | 
					 | 
							calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); | 
					 | 
					 | 
					 | 
							calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; | 
					 | 
					 | 
					 | 
							String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							LocalDateTime startTime = LocalDateTime.parse(end); | 
					 | 
					 | 
					 | 
							// 存储数据map :<站点id,<月份,发电量>>
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 存储数据map:<站点id, <月份, 发电量>>
 | 
					 | 
					 | 
					 | 
							Map<Long, Map<String, Float>> powerMap = new CopyOnWriteMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Map<Long, Map<String, Float>> powerMap = new HashMap<>(); | 
					 | 
					 | 
					 | 
							// 将站点切割
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							stationList.forEach(station -> { | 
					 | 
					 | 
					 | 
							int limit = countStep(stations.size()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								List<PowerMonthVo> datas = new ArrayList<>(); | 
					 | 
					 | 
					 | 
							List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							CountDownLatch countDownLatch = new CountDownLatch(limits.size()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							for(List<StationEntity> item : limits){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								pool.submit(()->{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									item.forEach(station->{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										// 站点设备集合
 | 
					 | 
					 | 
					 | 
										// 站点设备集合
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); | 
					 | 
					 | 
					 | 
										List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								log.info("load_power_data station :" + station.getCode() + "==== device :" + stationDevices); | 
					 | 
					 | 
					 | 
										Map<String, Float> generateMap = this.lastReduceFirst(station,stationDevices,start,end); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (CollectionUtil.isNotEmpty(devices)) { | 
					 | 
					 | 
					 | 
										if(MapUtils.isEmpty(generateMap)){ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									stationDevices.forEach(device -> { | 
					 | 
					 | 
					 | 
											return; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										ReductionDataDTO reductionDataDTO = new ReductionDataDTO(); | 
					 | 
					 | 
					 | 
										} | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setDeviceCode(device.getEmCode()); | 
					 | 
					 | 
					 | 
										powerMap.put(station.getId(),generateMap); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setSaveTimeType(5); | 
					 | 
					 | 
					 | 
									}); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setTimeInterval(1); | 
					 | 
					 | 
					 | 
									countDownLatch.countDown(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setBeginTime(startTime); | 
					 | 
					 | 
					 | 
									log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setEndTime(endTime); | 
					 | 
					 | 
					 | 
								}); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										reductionDataDTO.setNeedPage(false); | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										Result<ReductionDataVO> reductionDataVOResult = deviceDataClient.pageDeviceCodeAndSignages(reductionDataDTO); | 
					 | 
					 | 
					 | 
							} | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										if (!reductionDataVOResult.isSuccess() || CollectionUtil.isEmpty(reductionDataVOResult.getData().getDataList())) { | 
					 | 
					 | 
					 | 
							//所有模板数据获取完成后释放锁
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								countDownLatch.await(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} catch (InterruptedException e) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								e.printStackTrace(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								Thread.currentThread().interrupt(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							redisTemplate.opsForValue().set(recent_year_power_data_test, JSONObject.toJSONString(powerMap)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private Map<String, Float> lastReduceFirst(StationEntity station, List<EminfoAndEmParamVo> devices, String start, String end) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							List<PowerMonthVo> datas = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							// 设备采集发电量
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							if(CollectionUtil.isNotEmpty(devices)){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								devices.forEach(device->{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									List<Map<String, String>>  records = dataService.lastFirstBySignage(start,end,7,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if(CollectionUtil.isEmpty(records)){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										return; | 
					 | 
					 | 
					 | 
										return; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									} | 
					 | 
					 | 
					 | 
									} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										List<Map<String, String>> dataList = reductionDataVOResult.getData().getDataList(); | 
					 | 
					 | 
					 | 
									datas.addAll(records.stream().map(record -> { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										datas.addAll(dataList.stream().map(data -> { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										PowerMonthVo generate = new PowerMonthVo(); | 
					 | 
					 | 
					 | 
										PowerMonthVo generate = new PowerMonthVo(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
											Date time = DateUtil.parse(data.get("ts"), "yyyy-MM-dd HH:mm:ss.s"); | 
					 | 
					 | 
					 | 
										Date time = DateUtil.parse(record.get("ts"), "yyyy-MM-dd HH:mm:ss.s"); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); | 
					 | 
					 | 
					 | 
										generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//						generate.setPower(Float.parseFloat(Optional.ofNullable(data.get(HomePageConstant.HYDROPOWER_GENERATE_POWER))
 | 
					 | 
					 | 
					 | 
										String val = record.get(HomePageConstant.HYDROPOWER_GENERATE_POWER); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//								.orElse("0")) * device.getRideCount());
 | 
					 | 
					 | 
					 | 
										if(StringUtil.isEmpty(val)){ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
											generate.setPower(0f); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
										}else{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
											generate.setPower(Float.parseFloat(String.valueOf(Double.parseDouble(val) * device.getRideCount()))); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
										} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										return generate; | 
					 | 
					 | 
					 | 
										return generate; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									}).collect(Collectors.toList())); | 
					 | 
					 | 
					 | 
									}).collect(Collectors.toList())); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								}); | 
					 | 
					 | 
					 | 
								}); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// 补充填报数据
 | 
					 | 
					 | 
					 | 
							// 补充填报数据
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							datas.addAll(this.generateFill(station,start,end)); | 
					 | 
					 | 
					 | 
							datas.addAll(this.generateFill(station,start,end)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (CollectionUtil.isEmpty(datas)) { | 
					 | 
					 | 
					 | 
							if(CollectionUtil.isEmpty(datas)){ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									return; | 
					 | 
					 | 
					 | 
								return null; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								Map<String, Float> map = datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); | 
					 | 
					 | 
					 | 
							return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								powerMap.put(station.getId(), map); | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							redisTemplate.opsForValue().set(recent_year_power_data, powerMap); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						/** | 
					 | 
					 | 
					 | 
						/** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |