|
|
|
@ -99,7 +99,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void thisDayPowerGeneration(String param) { |
|
|
|
|
String month = DateUtil.format(new Date(),"yyyy-MM") ; |
|
|
|
|
String month = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); |
|
|
|
|
// 步骤1.水电、光伏站点
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC))); |
|
|
|
|
|
|
|
|
@ -107,7 +107,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); |
|
|
|
|
|
|
|
|
|
// 步骤3.站点-设备当日发电量
|
|
|
|
|
this.refreshDayGeneration(stations,devices,month + "-01"); |
|
|
|
|
this.refreshDayGeneration(stations,devices,month); |
|
|
|
|
|
|
|
|
|
// 步骤4.近3年的当月发电量
|
|
|
|
|
this.thirtyMonthGenerate(stations,month); |
|
|
|
@ -194,22 +194,20 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
* 更新近3年的当月发电量 |
|
|
|
|
*/ |
|
|
|
|
private void thirtyMonthGenerate(List<StationEntity> stations,String month) { |
|
|
|
|
String queryMonth = DateUtil.format(DateUtil.parse(month,DateUtil.PATTERN_DATE),"yyyy-MM"); |
|
|
|
|
// 步骤1.查询设备当月累计发电量
|
|
|
|
|
List<ThirtyGenerationEntity> generations = thirtyGenerateService.list(Wrappers.<ThirtyGenerationEntity>lambdaQuery().like(ThirtyGenerationEntity::getStrDay,month)); |
|
|
|
|
List<ThirtyGenerationEntity> generations = thirtyGenerateService.list(Wrappers.<ThirtyGenerationEntity>lambdaQuery().like(ThirtyGenerationEntity::getStrDay,queryMonth)); |
|
|
|
|
|
|
|
|
|
// 步骤2.删除近3年当月发电量
|
|
|
|
|
threeGenerateService.deletemMonthGenerate(month + "-01"); |
|
|
|
|
// 步骤2.删除近3年当月发电量,清除填报发电量
|
|
|
|
|
threeGenerateService.deletemMonthGenerate(queryMonth + "-01"); |
|
|
|
|
|
|
|
|
|
// 步骤3.将当月累计发电量新增表
|
|
|
|
|
this.saveThreeMonthGenerate(generations,month); |
|
|
|
|
|
|
|
|
|
// 步骤4.清除填报发电量
|
|
|
|
|
threeGenerateService.deleteFillGenerate(); |
|
|
|
|
|
|
|
|
|
// 步骤5.清除超出30日发电量
|
|
|
|
|
// 步骤4.清除超出30日发电量
|
|
|
|
|
thirtyGenerateService.deleteDayGenerate(month); |
|
|
|
|
|
|
|
|
|
// 步骤6.重新补充填报发电量
|
|
|
|
|
// 步骤5.重新补充填报发电量
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); |
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
@ -231,20 +229,21 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
if(CollectionUtil.isEmpty(generations)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
threeGenerateService.saveBatch(generations.stream().collect(Collectors.groupingBy(ThirtyGenerationEntity::getDeviceCode)).entrySet().stream().map(entry->{ |
|
|
|
|
threeGenerateService.saveBatch(generations.stream().collect(Collectors.groupingBy(ThirtyGenerationEntity::getDeviceCode)).values().stream().map(thirtyGenerationEntities -> { |
|
|
|
|
ThreeGenerationEntity generate = new ThreeGenerationEntity(); |
|
|
|
|
generate.setStationId(entry.getValue().get(0).getStationId()); |
|
|
|
|
generate.setStationName(entry.getValue().get(0).getStationName()); |
|
|
|
|
generate.setDeviceCode(entry.getValue().get(0).getDeviceCode()); |
|
|
|
|
generate.setDeviceName(entry.getValue().get(0).getDeviceName()); |
|
|
|
|
generate.setTenantId(entry.getValue().get(0).getTenantId()); |
|
|
|
|
generate.setCreateDept(entry.getValue().get(0).getCreateDept()); |
|
|
|
|
generate.setCreateUser(entry.getValue().get(0).getCreateUser()); |
|
|
|
|
generate.setUpdateUser(entry.getValue().get(0).getUpdateUser()); |
|
|
|
|
String strMonth = month + "-01"; |
|
|
|
|
generate.setStationId(thirtyGenerationEntities.get(0).getStationId()); |
|
|
|
|
generate.setStationName(thirtyGenerationEntities.get(0).getStationName()); |
|
|
|
|
generate.setDeviceCode(thirtyGenerationEntities.get(0).getDeviceCode()); |
|
|
|
|
generate.setDeviceName(thirtyGenerationEntities.get(0).getDeviceName()); |
|
|
|
|
generate.setTenantId(thirtyGenerationEntities.get(0).getTenantId()); |
|
|
|
|
generate.setCreateDept(thirtyGenerationEntities.get(0).getCreateDept()); |
|
|
|
|
generate.setCreateUser(thirtyGenerationEntities.get(0).getCreateUser()); |
|
|
|
|
generate.setUpdateUser(thirtyGenerationEntities.get(0).getUpdateUser()); |
|
|
|
|
Date date = DateUtil.parse(month, DateUtil.PATTERN_DATE); |
|
|
|
|
String strMonth = DateUtil.format(date, "yyyy-MM") + "-01"; |
|
|
|
|
generate.setStrMonth(strMonth); |
|
|
|
|
generate.setMonth(DateUtil.parse(strMonth,DateUtil.PATTERN_DATE).getMonth() + 1); |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(entry.getValue().stream().mapToDouble(o->o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
generate.setMonth(date.getMonth() + 1); |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
return generate; |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
@ -293,7 +292,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); |
|
|
|
|
generate.setDay(time.getDay()); |
|
|
|
|
generate.setDay(time.getDate()); |
|
|
|
|
if(StringUtil.isEmpty(record.getVal())){ |
|
|
|
|
generate.setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
@ -421,7 +420,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
generation.setCreateUser(station.getCreateUser()); |
|
|
|
|
generation.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
generation.setStrMonth(power.getStrMonth()); |
|
|
|
|
generation.setMonth(power.getMonth()); |
|
|
|
|
Date date = DateUtil.parse(power.getStrMonth(),DateUtil.PATTERN_DATE); |
|
|
|
|
generation.setMonth(date.getMonth() + 1); |
|
|
|
|
if(power.getPower() <= 0){ |
|
|
|
|
generation.setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|