| | |
| | | @Autowired |
| | | private PowerMaxdemandDetService powerMaxdemandDetService; |
| | | |
| | | public static final String VALUE = "value"; |
| | | |
| | | public static final String TIME = "time"; |
| | | |
| | | @GetMapping("/net-factor/list") |
| | | @Operation(summary = "功率因数-电网拓扑") |
| | | public CommonResult<List<PowerNetFactorDTO>> getPowerNetFactorList(@RequestParam Map<String, Object> params) { |
| | |
| | | @GetMapping("/demand/list") |
| | | @Operation(summary = "负荷移植-月最大需量,实测需量,有功功率") |
| | | public CommonResult<List<PowerDemandDTO>> getPowerDemandList(@RequestParam Map<String, Object> params) { |
| | | List<PowerDemandDTO> result = new ArrayList<>(); |
| | | List<PowerDemandEntity> list = powerDemandService.list(params); |
| | | List<PowerDemandDTO> result = ConvertUtils.sourceToTarget(list, PowerDemandDTO.class); |
| | | if (CollectionUtils.isEmpty(result)) { |
| | | return success(result); |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | Date start = calendar.getTime(); |
| | | Date end = new Date(); |
| | | |
| | | for (PowerDemandDTO dto : result) { |
| | | for (PowerDemandEntity entity : list) { |
| | | PowerDemandDTO demandDTO = new PowerDemandDTO(); |
| | | demandDTO.setId(entity.getId()); |
| | | demandDTO.setCode(entity.getCode()); |
| | | demandDTO.setName(entity.getName()); |
| | | |
| | | List<String> points = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(dto.getCurDemand())) { |
| | | points.add(dto.getCurDemand()); |
| | | if (StringUtils.isNotBlank(entity.getCurDemand())) { |
| | | points.add(entity.getCurDemand()); |
| | | } |
| | | if (StringUtils.isNotBlank(dto.getActivePower())) { |
| | | points.add(dto.getActivePower()); |
| | | if (StringUtils.isNotBlank(entity.getActivePower())) { |
| | | points.add(entity.getActivePower()); |
| | | } |
| | | if (!CollectionUtils.isEmpty(points)) { |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | if (pointsRealValue.get(dto.getCurDemand()) != null) { |
| | | dto.setCurDemand(pointsRealValue.get(dto.getCurDemand()).toString()); |
| | | if (pointsRealValue.get(entity.getCurDemand()) != null) { |
| | | demandDTO.setCurDemand(new BigDecimal(pointsRealValue.get(entity.getCurDemand()).toString())); |
| | | } |
| | | if (pointsRealValue.get(dto.getActivePower()) != null) { |
| | | dto.setActivePower(pointsRealValue.get(dto.getActivePower()).toString()); |
| | | if (pointsRealValue.get(entity.getActivePower()) != null) { |
| | | demandDTO.setActivePower(new BigDecimal(pointsRealValue.get(entity.getActivePower()).toString())); |
| | | } |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(dto.getMaxDemand())) { |
| | | Date start = calendar.getTime(); |
| | | if (!StringUtils.isEmpty(entity.getMaxDemand())) { |
| | | ApiPointValueQueryDTO apiPointValueQueryDTO = new ApiPointValueQueryDTO(); |
| | | apiPointValueQueryDTO.setStart(start); |
| | | apiPointValueQueryDTO.setPointNo(dto.getMaxDemand()); |
| | | Map<String, Object> maxValue = dataPointApi.queryPointMaxValue(apiPointValueQueryDTO); |
| | | apiPointValueQueryDTO.setEnd(end); |
| | | apiPointValueQueryDTO.setPointNo(entity.getMaxDemand()); |
| | | Map<String, Object> maxValue = dataPointApi.queryPointMaxTimeValue(apiPointValueQueryDTO); |
| | | if (maxValue != null) { |
| | | dto.setMaxDemand(maxValue.get(dto.getMaxDemand()) == null ? "" : maxValue.get(dto.getMaxDemand()).toString()); |
| | | demandDTO.setMaxDemand(new BigDecimal(maxValue.get(VALUE).toString())); |
| | | demandDTO.setOccurTime(DateUtils.parse( maxValue.get(TIME).toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | } |
| | | |
| | | } |
| | | result.add(demandDTO); |
| | | } |
| | | return success(result); |
| | | } |