| | |
| | | @Autowired |
| | | private PowerDemandService powerDemandService; |
| | | |
| | | @Autowired |
| | | private PowerAdjustedFactorService powerAdjustedFactorService; |
| | | |
| | | @Resource |
| | | private DataPointApi dataPointApi; |
| | | |
| | |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/net-factor/historyData") |
| | | @PostMapping("/net-factor/history") |
| | | @Operation(summary = "功率因数-根据nodeName获取最近1440min历史数据,月最大,最小值") |
| | | public CommonResult<PowerHistoryDTO> getPowerHistoryData(@RequestParam Map<String, Object> params) { |
| | | |
| | | PowerNetFactorEntity powerNetFactor = powerNetFactorService.list(params).get(0); |
| | | public CommonResult<PowerHistoryDTO> getPowerHistoryData(@RequestBody Map<String, Object> params) { |
| | | String nodeName = (String) params.get("nodeName"); |
| | | if (StringUtils.isBlank(nodeName)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | String queryType = (String) params.get("queryType"); |
| | | if (StringUtils.isBlank(queryType)) { |
| | | return CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST); |
| | | } |
| | | PowerNetFactorEntity powerNetFactor = powerNetFactorService.getByNodeName(nodeName); |
| | | PowerHistoryDTO result = new PowerHistoryDTO(); |
| | | if (powerNetFactor == null) { |
| | | return success(result); |
| | |
| | | |
| | | ApiPointValueQueryDTO apiPointValueQueryDTO = new ApiPointValueQueryDTO(); |
| | | String pointNo = ""; |
| | | Date start = null; |
| | | Date end = null; |
| | | |
| | | switch (params.get("queryType").toString()) { |
| | | case "p": |
| | | switch (queryType.toUpperCase()) { |
| | | case "P": |
| | | pointNo = powerNetFactor.getCurP(); |
| | | |
| | | case "q": |
| | | break; |
| | | case "Q": |
| | | pointNo = powerNetFactor.getCurQ(); |
| | | |
| | | case "cos": |
| | | break; |
| | | case "COS": |
| | | pointNo = powerNetFactor.getCurCos(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | //查询图表 |
| | | String startTimeStr =(String) params.get("startTime"); |
| | | String endTimeStr =(String) params.get("endTime"); |
| | | apiPointValueQueryDTO.setPointNo(pointNo); |
| | | Calendar calendar0 = Calendar.getInstance(); |
| | | calendar0.set(Calendar.MILLISECOND, 0); |
| | | calendar0.set(Calendar.SECOND, 0); |
| | | Date end = calendar0.getTime(); |
| | | calendar0.add(Calendar.MINUTE, -1440); |
| | | Date start = calendar0.getTime(); |
| | | |
| | | SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | if (params.get("startTime") != null) { |
| | | if (StringUtils.isNotBlank(startTimeStr)) { |
| | | try { |
| | | start = ft.parse(params.get("startTime").toString()); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else { |
| | | start = new Date(System.currentTimeMillis() - 1440L * 60 * 1000); |
| | | } |
| | | apiPointValueQueryDTO.setStart(start); |
| | | if (params.get("endTime") != null) { |
| | | if (StringUtils.isNotBlank(endTimeStr)) { |
| | | try { |
| | | end = ft.parse(params.get("endTime").toString()); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else { |
| | | end = new Date(); |
| | | } |
| | | apiPointValueQueryDTO.setEnd(end); |
| | | List<ApiPointValueDTO> chartData = dataPointApi.queryPointHistoryValue(apiPointValueQueryDTO); |
| | |
| | | data.add(value); |
| | | dataList.add(data); |
| | | } |
| | | List<String> categories = DateUtils.getTimeScale(start, end, 5); |
| | | List<String> categories = DateUtils.getTimeScale(start, end, 60); |
| | | result.setCategories(categories); |
| | | result.setDataList(dataList); |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @GetMapping("/adjust-factor") |
| | | @Operation(summary = "负荷移植-调整后的功率因数与无功倒送量") |
| | | public CommonResult<Map<String, Double>> getPowerAdjustFactor(@RequestParam Map<String, Object> params) { |
| | | List<PowerAdjustedFactorEntity> list = powerAdjustedFactorService.list(params); |
| | | List<PowerAdjustedFactorDTO> dtoList = ConvertUtils.sourceToTarget(list, PowerAdjustedFactorDTO.class); |
| | | Map<String, Double> result = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return success(result); |
| | | } |
| | | List<String> points = new ArrayList<>(); |
| | | Map<String, Object> dataMap = new HashMap<>(); |
| | | for (PowerAdjustedFactorDTO dto : dtoList) { |
| | | points.add(dto.getPointNo()); |
| | | } |
| | | dataMap = dataPointApi.queryPointsRealValue(points); |
| | | for (PowerAdjustedFactorDTO powerAdjustedFactorDTO : dtoList) { |
| | | result.put(powerAdjustedFactorDTO.getName(), Double.parseDouble(dataMap.get(powerAdjustedFactorDTO.getPointNo()).toString())); |
| | | } |
| | | return success(result); |
| | | } |
| | | } |