| | |
| | | return; |
| | | } |
| | | for (PowerDemandEntity demand : demandList) { |
| | | // 查询今天的最大需量 |
| | | logger.info("查询今天的最大需量"); |
| | | ApiPointValueQueryDTO pointValueQuery0 = new ApiPointValueQueryDTO(); |
| | | pointValueQuery0.setStart(dayStart); |
| | | pointValueQuery0.setEnd(nowTime); |
| | | pointValueQuery0.setPointNo(demand.getCurDemand()); |
| | | Map<String, Object> maxValue = dataPointApi.queryPointMaxValue(pointValueQuery0); |
| | | BigDecimal todayMax = BigDecimal.ZERO; |
| | | if (CollectionUtils.isEmpty(maxValue) && maxValue.containsKey(demand.getCurDemand())) { |
| | | todayMax = new BigDecimal(maxValue.get(demand.getCurDemand()).toString()); |
| | | if (CollectionUtils.isEmpty(maxValue)) { |
| | | logger.info("maxValue is empty"); |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal todayMax = new BigDecimal(maxValue.get(demand.getCurDemand()).toString()); |
| | | logger.info("todayMax=" + todayMax); |
| | | List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(pointValueQuery0); |
| | | if (CollectionUtils.isEmpty(valueList)) { |
| | | logger.info("valueList is empty"); |
| | |
| | | } |
| | | } |
| | | |
| | | // 查询本月需量发生记录 |
| | | logger.info("查询本月需量发生记录"); |
| | | BigDecimal monthMax = powerMaxdemandMainService.getMax(demand.getCode(), monStart, nowTime); |
| | | |
| | | // 保存记录 |
| | |
| | | mainEntity.setOccurTime(occurTime); |
| | | mainEntity.setMaxDemand(todayMax); |
| | | String mainId = powerMaxdemandMainService.add(mainEntity); |
| | | |
| | | Map<String, Object> params1 = new HashMap<>(); |
| | | params1.put("pCode", demand.getCode()); |
| | | List<PowerNetDropdownEntity> dropdownList = powerNetDropdownService.list(params1); |
| | | if (CollectionUtils.isEmpty(dropdownList)) { |
| | | logger.info("dropdownList is empty"); |
| | | // 插入第一层children |
| | | List<PowerMaxdemandDetEntity> detList0 = powerMaxdemandDetService.addList(mainId, demand.getName(), occurTime); |
| | | if(CollectionUtils.isEmpty(detList0)){ |
| | | logger.info("detList0 is empty"); |
| | | continue; |
| | | } |
| | | for (PowerNetDropdownEntity dropdown : dropdownList) { |
| | | if (StringUtils.isBlank(dropdown.getExt1())) { |
| | | continue; |
| | | } |
| | | Calendar calendar1 = Calendar.getInstance(); |
| | | calendar1.setTime(occurTime); |
| | | calendar1.add(Calendar.MINUTE, 1); |
| | | ApiPointValueQueryDTO pointValueQuery1 = new ApiPointValueQueryDTO(); |
| | | pointValueQuery1.setStart(occurTime); |
| | | pointValueQuery1.setEnd(calendar1.getTime()); |
| | | pointValueQuery1.setPointNo(dropdown.getExt1()); |
| | | List<ApiPointValueDTO> valueList1 = dataPointApi.queryPointHistoryValue(pointValueQuery1); |
| | | if (CollectionUtils.isEmpty(valueList1)) { |
| | | logger.info("valueList1 is empty"); |
| | | continue; |
| | | } |
| | | PowerMaxdemandDetEntity detEntity = new PowerMaxdemandDetEntity(); |
| | | detEntity.setRelId(mainId); |
| | | detEntity.setCode(dropdown.getNodeCode()); |
| | | detEntity.setName(dropdown.getNodeName()); |
| | | detEntity.setOccurTime(occurTime); |
| | | detEntity.setMaxDemand(BigDecimal.valueOf(valueList1.get(0).getV())); |
| | | powerMaxdemandDetService.add(detEntity); |
| | | for (PowerMaxdemandDetEntity detEntity : detList0) { |
| | | // 插入第二层children |
| | | powerMaxdemandDetService.addList(detEntity.getId(), detEntity.getName(), occurTime); |
| | | } |
| | | } |
| | | logger.info("RunPowerMaxdemandTask end"); |