鞍钢鲅鱼圈能源管控系统后端代码
潘志宝
3 天以前 5015682d384a3d7ea8c3343e74b895e4466bb2de
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -362,11 +362,18 @@
        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);
@@ -374,40 +381,45 @@
        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);