鞍钢鲅鱼圈能源管控系统后端代码
dongyukun
4 天以前 23b9c4e1023c4566ccb179f16fcb2abef9ac1a5e
ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -60,6 +60,9 @@
    @Autowired
    private PowerDemandService powerDemandService;
    @Autowired
    private PowerAdjustedFactorService powerAdjustedFactorService;
    @Resource
    private DataPointApi dataPointApi;
@@ -338,11 +341,9 @@
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                Date start = calendar.getTime();
                calendar.add(Calendar.MONTH, 1);
                Date end = calendar.getTime();
                ApiPointValueQueryDTO apiPointValueQueryDTO = new ApiPointValueQueryDTO();
                apiPointValueQueryDTO.setStart(start);
                apiPointValueQueryDTO.setEnd(end);
                apiPointValueQueryDTO.setEnd(new Date());
                apiPointValueQueryDTO.setPointNo(dto.getMaxDemand());
                List<ApiPointValueDTO> monthValues = dataPointApi.queryPointHistoryValue(apiPointValueQueryDTO);
@@ -361,7 +362,7 @@
        return success(result);
    }
    @GetMapping("/power/historyData")
    @GetMapping("/net-factor/historyData")
    @Operation(summary = "功率因数-根据nodeName获取最近1440min历史数据,月最大,最小值")
    public CommonResult<PowerHistoryDTO> getPowerHistoryData(@RequestParam Map<String, Object> params) {
@@ -386,7 +387,7 @@
            case "cos":
                pointNo = powerNetFactor.getCurCos();
        }
        //查询图表
        apiPointValueQueryDTO.setPointNo(pointNo);
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (params.get("startTime") != null) {
@@ -422,13 +423,34 @@
        List<String> categories = DateUtils.getTimeScale(start, end, 5);
        result.setCategories(categories);
        result.setDataList(dataList);
        result.setMax(getMax(dataList));
        result.setMin(getMin(dataList));
        //查询月最大最小值
        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);
        start = calendar.getTime();
        apiPointValueQueryDTO.setStart(start);
        apiPointValueQueryDTO.setEnd(new Date());
        List<ApiPointValueDTO> monthChartData = dataPointApi.queryPointHistoryValue(apiPointValueQueryDTO);
        List<List<Object>> monthDataList = new ArrayList<>();
        for (ApiPointValueDTO dto : monthChartData) {
            List<Object> data = new ArrayList<>();
            String time = ft.format(dto.getT());
            double value = dto.getV();
            data.add(time);
            data.add(value);
            monthDataList.add(data);
        }
        result.setMax(getMax(monthDataList));
        result.setMin(getMin(monthDataList));
        return success(result);
    }
    private double getMax(List<List<Object>> dataList) {
        double result = 0;
    private double getMin(List<List<Object>> dataList) {
        double result = Double.parseDouble(dataList.get(0).get(1).toString());
        for (int i = 0; i < dataList.size() - 1; i++) {
            if (result > Double.parseDouble(dataList.get(i).get(1).toString())) {
                result = Double.parseDouble(dataList.get(i).get(1).toString());
@@ -437,7 +459,7 @@
        return result;
    }
    private double getMin(List<List<Object>> dataList) {
    private double getMax(List<List<Object>> dataList) {
        double result = 0;
        for (int i = 0; i < dataList.size() - 1; i++) {
            if (result < Double.parseDouble(dataList.get(i).get(1).toString())) {
@@ -446,4 +468,25 @@
        }
        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);
    }
}