| | |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.exception.ErrorCode; |
| | | import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.error; |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private PowerMaxdemandMainService powerMaxDemandMainService; |
| | | |
| | | @Autowired |
| | | private PowerMaxdemandDetService powerMaxdemandDetService; |
| | | |
| | |
| | | @GetMapping("/capacitor-status/list") |
| | | @Operation(summary = "功率因数-电容器投退状态") |
| | | public CommonResult<List<PowerCapacitorStatusDTO>> getPowerCapacitorStatusList(@RequestParam Map<String, Object> params) { |
| | | List<PowerCapacitorStatusDTO> result = new ArrayList<>(); |
| | | List<PowerCapacitorStatusEntity> list = powerCapacitorStatusService.list(params); |
| | | return success(ConvertUtils.sourceToTarget(list, PowerCapacitorStatusDTO.class)); |
| | | for (PowerCapacitorStatusEntity entity : list) { |
| | | PowerCapacitorStatusDTO dto = new PowerCapacitorStatusDTO(); |
| | | dto.setId(entity.getId()); |
| | | dto.setName(entity.getName()); |
| | | dto.setRemark(entity.getRemark()); |
| | | dto.setMainCount(DecimalUtil.toBigDecimal(entity.getMainCount()).intValue()); |
| | | dto.setChildCount(DecimalUtil.toBigDecimal(entity.getChildCount()).intValue()); |
| | | int onCount = 0; |
| | | Map<String, Object> params1 = new HashMap<>(); |
| | | params1.put("statusId", entity.getId()); |
| | | List<PowerCapacitorDetEntity> detList = powerCapacitorDetService.list(params1); |
| | | if (CollectionUtils.isEmpty(detList)) { |
| | | dto.setOnCount(onCount); |
| | | continue; |
| | | } |
| | | List<String> points = new ArrayList<>(); |
| | | Map<String, Object> pointsRealValue = new HashMap<>(); |
| | | for (PowerCapacitorDetEntity det : detList) { |
| | | if (StringUtils.isNotBlank(det.getPointNo())) { |
| | | points.add(det.getPointNo()); |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(points)) { |
| | | pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | } |
| | | for (PowerCapacitorDetEntity det : detList) { |
| | | if (StringUtils.isBlank(det.getId())) { |
| | | continue; |
| | | } |
| | | Object obj = pointsRealValue.get(det.getPointNo()); |
| | | if (obj == null) { |
| | | continue; |
| | | } |
| | | BigDecimal pv = new BigDecimal(obj.toString()); |
| | | if (pv.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | onCount ++; |
| | | } |
| | | dto.setOnCount(onCount); |
| | | result.add(dto); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/capacitor-det/list") |
| | |
| | | public CommonResult<List<PowerCapacitorDetDTO>> getPowerCapacitorDetList(@RequestParam Map<String, Object> params) { |
| | | List<PowerCapacitorDetEntity> list = powerCapacitorDetService.list(params); |
| | | log.info("list.size=" + list.size()); |
| | | List<String> points = list.stream().map(item -> { |
| | | return item.getPointNo(); |
| | | }).collect(Collectors.toList()); |
| | | List<String> points = new ArrayList<>(); |
| | | Map<String, Object> pointsRealValue = new HashMap<>(); |
| | | for (PowerCapacitorDetEntity det : list) { |
| | | if (StringUtils.isNotBlank(det.getPointNo())) { |
| | | points.add(det.getPointNo()); |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(points)) { |
| | | pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | } |
| | |
| | | apiPointValueQueryDTO.setEnd(new Date()); |
| | | List<ApiPointValueDTO> monthChartData = dataPointApi.queryPointHistoryValue(apiPointValueQueryDTO); |
| | | List<Double> monthValues = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(monthChartData)) { |
| | | if (!CollectionUtils.isEmpty(monthChartData)) { |
| | | monthValues = monthChartData.stream().map(item -> item.getV()).collect(Collectors.toList()); |
| | | result.setMax(monthValues.stream().max(Double::compareTo).get()); |
| | | result.setMin(monthValues.stream().min(Double::compareTo).get()); |
| | |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/power-maxdemand/page") |
| | | @PostMapping("/power-maxdemand/page") |
| | | @Operation(summary = "负荷移植-最大需量发生记录分页") |
| | | public CommonResult<PageResult<PowerMaxDemandMainDTO>> getPowerMaxDemandMainPage(@Validated PowerMaxDemandMainPageReqVO reqVO) { |
| | | public CommonResult<PageResult<PowerMaxDemandMainDTO>> getPowerMaxDemandMainPage(@RequestBody PowerMaxDemandMainPageReqVO reqVO) { |
| | | if (StringUtils.isBlank(reqVO.getCode())) { |
| | | log.info("code is blank"); |
| | | return error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | PageResult<PowerMaxdemandMainEntity> page = powerMaxDemandMainService.page(reqVO); |
| | | PageResult<PowerMaxDemandMainDTO> result = BeanUtils.toBean(page, PowerMaxDemandMainDTO.class); |
| | | /*List<String> parentIds = result.getList() |
| | | .stream() |
| | | .map(PowerMaxDemandMainDTO::getId) |
| | | .collect(Collectors.toList()); |
| | | List<PowerMaxdemandDetEntity> children = powerMaxdemandDetService.selectListByRelIds(parentIds); |
| | | Map<String, List<PowerMaxdemandDetEntity>> childrenMap = children.stream() |
| | | .collect(Collectors.groupingBy(PowerMaxdemandDetEntity::getRelId));*/ |
| | | result.getList().forEach(dto0 -> { |
| | | List<PowerMaxdemandDetEntity> detList0 = powerMaxdemandDetService.selectListByRelId(dto0.getId(), dto0.getOccurTime()); |
| | | dto0.setChildren(ConvertUtils.sourceToTarget(detList0, PowerMaxdemandDetDTO.class)); |
| | | if (CollectionUtils.isEmpty(dto0.getChildren())) { |
| | | if (!CollectionUtils.isEmpty(dto0.getChildren())) { |
| | | dto0.getChildren().forEach(dto1 -> { |
| | | List<PowerMaxdemandDetEntity> detList1 = powerMaxdemandDetService.selectListByRelId(dto1.getId(), dto1.getOccurTime()); |
| | | dto1.setChildren(ConvertUtils.sourceToTarget(detList1, PowerMaxdemandDetDTO.class)); |
| | |
| | | }); |
| | | return success(result); |
| | | } |
| | | |
| | | @PostMapping("/power-maxdemand/det-list") |
| | | @Operation(summary = "负荷移植-最大需量发生记录详情") |
| | | public CommonResult<List<PowerMaxdemandDetDTO>> getPowerMaxDemandDetList(@RequestParam Map<String, Object> params) { |
| | | String relId = (String) params.get("relId"); |
| | | if (StringUtils.isBlank(relId)) { |
| | | return error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | List<PowerMaxdemandDetEntity> list = powerMaxdemandDetService.selectListByRelId(relId); |
| | | return success(ConvertUtils.sourceToTarget(list, PowerMaxdemandDetDTO.class)); |
| | | } |
| | | } |