|
|
|
@ -43,6 +43,7 @@ import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO;
|
|
|
|
|
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
@ -83,6 +84,8 @@ public class TargetServiceImpl implements TargetService {
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
private final GenerateService generateService; |
|
|
|
|
|
|
|
|
|
private final OverDetailsService overDetailsService; |
|
|
|
|
|
|
|
|
|
private final IOperAccessTaskService accessTaskService; |
|
|
|
@ -114,6 +117,8 @@ public class TargetServiceImpl implements TargetService {
|
|
|
|
|
|
|
|
|
|
private final static String load_waterpump_real_key = "hzims:operation:loadwaterpump:real:key"; |
|
|
|
|
|
|
|
|
|
private final static String recent_year_power_data = "hzims:operation:key:power:data"; |
|
|
|
|
|
|
|
|
|
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; |
|
|
|
|
|
|
|
|
|
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; |
|
|
|
@ -1205,4 +1210,103 @@ public class TargetServiceImpl implements TargetService {
|
|
|
|
|
pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords())); |
|
|
|
|
return pages; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 水电关联-发电详情 |
|
|
|
|
* @param stationName |
|
|
|
|
* @param type |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<HydropowerTargetDetailVo> hydropowerTargetDetail(String stationName, Long type) { |
|
|
|
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
.eq(StationEntity::getName,stationName)); |
|
|
|
|
if(ObjectUtil.isEmpty(station)){ |
|
|
|
|
throw new ServiceException("站点信息不存在!"); |
|
|
|
|
} |
|
|
|
|
if(HomePageConstant.YEAR.equals(type)){ |
|
|
|
|
// 站点近年发电数据
|
|
|
|
|
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
|
// 填报发电量
|
|
|
|
|
List<PowerMonthVo> powerMonths = generateService.fillPowerMon(station.getCode()); |
|
|
|
|
return powerMonths.stream().map(mon->{ |
|
|
|
|
HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo(); |
|
|
|
|
detail.setTime(mon.getStrMonth()); |
|
|
|
|
if(MapUtils.isEmpty(powerMap)){ |
|
|
|
|
detail.setElectric(Double.valueOf(mon.getPower())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
// 发电量
|
|
|
|
|
Map<String,Float> monMap = powerMap.get(station.getId()); |
|
|
|
|
if(MapUtils.isEmpty(monMap)){ |
|
|
|
|
detail.setElectric(Double.valueOf(mon.getPower())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
detail.setElectric((double) (monMap.get(mon.getStrMonth()) + mon.getPower())); |
|
|
|
|
return detail; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
}else if(HomePageConstant.MON.equals(type)){ |
|
|
|
|
// 指标数据
|
|
|
|
|
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
|
|
|
|
// 填报发电量
|
|
|
|
|
List<GenerationPowerVo> powerDays = generateService.fillPowerDay(station.getCode()); |
|
|
|
|
return powerDays.stream().map(day->{ |
|
|
|
|
HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo(); |
|
|
|
|
detail.setTime(day.getDate()); |
|
|
|
|
if(CollectionUtil.isEmpty(targets)){ |
|
|
|
|
detail.setElectric(Double.valueOf(day.getGenerate())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(stationTargets)){ |
|
|
|
|
detail.setElectric(Double.valueOf(day.getGenerate())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
List<GenerationPowerVo> generations = stationTargets.get(0).getGenerationPowerVoList(); |
|
|
|
|
if(CollectionUtil.isEmpty(generations)){ |
|
|
|
|
detail.setElectric(Double.valueOf(day.getGenerate())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
List<GenerationPowerVo> dayGenerations = generations.stream().filter(generation -> generation.getDate().equals(day.getDate())).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(dayGenerations)){ |
|
|
|
|
detail.setElectric(Double.valueOf(day.getGenerate())); |
|
|
|
|
return detail; |
|
|
|
|
} |
|
|
|
|
detail.setElectric((double) (day.getGenerate() + dayGenerations.get(0).getGenerate())); |
|
|
|
|
return detail; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
}else{ |
|
|
|
|
throw new ServiceException("查询数据类型不支持!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取近年月份集合 |
|
|
|
|
* @param year |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<String> mons(int year, int endMoth, boolean nextMon) { |
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
// 开始日期
|
|
|
|
|
Calendar endCal = Calendar.getInstance(); |
|
|
|
|
endCal.setTime(new Date()); |
|
|
|
|
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); |
|
|
|
|
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
Calendar startCal = Calendar.getInstance(); |
|
|
|
|
startCal.setTime(new Date()); |
|
|
|
|
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); |
|
|
|
|
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); |
|
|
|
|
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); |
|
|
|
|
// 获取日期之间的月份
|
|
|
|
|
while (endCal.after(startCal)) { |
|
|
|
|
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
startCal.add(Calendar.MONTH, 1); |
|
|
|
|
} |
|
|
|
|
if(nextMon){ |
|
|
|
|
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
} |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|