PowerAnalysisNewController.java 13.1 KB
package com.skua.modules.dataAnalysis.controller;

import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.util.DateUtils;
import com.skua.modules.dataAnalysis.service.IPowerAnalysisNewService;
import com.skua.modules.dataAnalysis.vo.OperationMonthVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags="能耗分析")
@RestController
@RequestMapping("/v1/dataAnalysis/power")
public class PowerAnalysisNewController {

    @Autowired
    private IPowerAnalysisNewService operationMonthService;

    /**
     * 电耗分析
     */
    @AutoLog(value = "电耗分析详情")
    @ApiOperation(value = "电耗分析详情", notes = "电耗分析详情")
    @GetMapping(value = "/powerConsumptionAnalysis")
    public Result powerConsumptionAnalysis(OperationMonthVO operationMonthVO) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerConsumptionAnalysis(operationMonthVO);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析详情列表
     */
    @AutoLog(value = "电耗分析详情列表")
    @ApiOperation(value = "电耗分析详情列表", notes = "电耗分析详情列表")
    @GetMapping(value = "/powerConsumptionList")
    public Result powerConsumptionList(String startTime, String endTime, String factoryId) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerConsumptionList(startTime, endTime,factoryId);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析
     */
    @AutoLog(value = "电耗分析电耗分布情况")
    @ApiOperation(value = "电耗分析电耗分布情况", notes = "电耗分析电耗分布情况")
    @GetMapping(value = "/powerConsumptionDistribution")
    public Result powerConsumptionDistribution(OperationMonthVO operationMonthVO) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerConsumptionDistribution(operationMonthVO);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析电耗分布情况列表
     */
    @AutoLog(value = "电耗分析电耗分布情况列表")
    @ApiOperation(value = "电耗分析电耗分布情况列表", notes = "电耗分析电耗分布情况列表")
    @GetMapping(value = "/powerConsumptionDistributionList")
    public Result powerConsumptionDistributionList(String time, String type) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerConsumptionDistributionList(type, time);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析关联分析
     */
    @AutoLog(value = "电耗分析关联分析")
    @ApiOperation(value = "电耗分析关联分析", notes = "电耗分析关联分析")
    @GetMapping(value = "/powerAssociation")
    public Result powerAssociation(OperationMonthVO operationMonthVO) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerAssociation(operationMonthVO);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析吨水电耗曲线图
     */
    @AutoLog(value = "电耗分析吨水电耗曲线图")
    @ApiOperation(value = "电耗分析吨水电耗曲线图", notes = "电耗分析吨水电耗曲线图")
    @GetMapping(value = "/powerDSDHCurve")
    public Result powerDSDHCurve(String time, String type, String id) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerDSDHCurve(id, type, time);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 单位污染物削减电耗
     */
    @AutoLog(value = "电耗分析单位污染物削减电耗")
    @ApiOperation(value = "电耗分析单位污染物削减电耗", notes = "电耗分析单位污染物削减电耗")
    @GetMapping(value = "/powerCutDown")
    public Result powerCutDown(String time) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerCutDown(time);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析根据厂站单位污染物削减电耗
     */
    @AutoLog(value = "电耗分析根据厂站单位污染物削减电耗")
    @ApiOperation(value = "电耗分析根据厂站单位污染物削减电耗", notes = "电耗分析根据厂站单位污染物削减电耗")
    @GetMapping(value = "/powerCutDownByFac")
    public Result powerCutDownByFac(String startTime, String endTime, String factoryId) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerCutDownByFac(startTime, endTime, factoryId);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析获取所有单位污染物削减电耗列表
     */
    @AutoLog(value = "电耗分析获取所有单位污染物削减电耗列表")
    @ApiOperation(value = "电耗分析获取所有单位污染物削减电耗列表", notes = "电耗分析获取所有单位污染物削减电耗列表")
    @GetMapping(value = "/powerCutDownAllList")
    public Result powerCutDownAllList(String time) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerCutDownAllList(time);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 电耗分析根据厂站获取所有单位污染物削减电耗列表
     */
    @AutoLog(value = "电耗分析根据厂站获取所有单位污染物削减电耗列表")
    @ApiOperation(value = "电耗分析根据厂站获取所有单位污染物削减电耗列表", notes = "电耗分析根据厂站获取所有单位污染物削减电耗列表")
    @GetMapping(value = "/powerCutDownAllListByFac")
    public Result powerCutDownAllListByFac(String startTime, String endTime, String factoryId) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerCutDownAllListByFac(startTime, endTime, factoryId);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }
    /**
     * 电耗分析根据厂站获取所有单位污染物削减电耗列表
     */
    @AutoLog(value = "电耗分析根据厂站获取所有单位污染物削减电耗详情")
    @ApiOperation(value = "电耗分析根据厂站获取所有单位污染物削减电耗详情", notes = "电耗分析根据厂站获取所有单位污染物削减电耗详情")
    @GetMapping(value = "/powerCutDownListByFac")
    public Result powerCutDownListByFac(String startTime, String endTime, String factoryId) {
        Result result = new Result();
        Map<String, Object> resultMap = operationMonthService.powerCutDownListByFac(startTime, endTime, factoryId);
        result.setSuccess(true);
        result.setResult(resultMap);
        return result;
    }

    /**
     * 查詢月度公司级电耗统计
     *
     * @return
     */
    @AutoLog(value = "查詢月度公司级电耗统计")
    @ApiOperation(value = "查詢月度公司级电耗统计", notes = "查詢月度公司级电耗统计")
    @RequestMapping(value = "/queryMonthHDLData", method = RequestMethod.GET)
    public Result<List<Map<String, Object>>> queryMonthHDLData(String startTime,String endTime) {
        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isEmpty(startTime)){
            startTime = endTime+"-01";
            endTime = endTime+"-31";
        }
        List<Map<String, Object>> data = operationMonthService.queryMonthHDLData(null,startTime,endTime);
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }

    /**
     * 查詢公司级电耗近半年曲线
     *
     * @return
     */
    @AutoLog(value = "查詢公司级电耗近半年曲线")
    @ApiOperation(value = "查詢公司级电耗近半年曲线", notes = "查詢公司级电耗近半年曲线")
    @RequestMapping(value = "/queryHDLByYear", method = RequestMethod.GET)
    public Result<List<Map<String, String>>> queryHDLByYear(String startTime,String endTime) {
        Result<List<Map<String, String>>> result = new Result<>();

        String startDate = startTime;
        String endDate = endTime;
        if (StringUtils.isEmpty(startDate)) {
            if (StringUtils.isEmpty(startDate)){
                Date date = DateUtils.str2Date(endDate, DateUtils.yyyyMM);
                Date date1 = new Date(date.getTime() - 13176000000L);
                startDate = DateUtils.date2Str(date1,DateUtils.yyyyMM);
            }
        }
        List<Map<String, String>> data = operationMonthService.queryHDLByYear(null,startDate+"-01",endDate+"-31");
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }


    /**
     * 查询各公司电耗详情
     *
     * @return
     */
    @AutoLog(value = "查询各公司电耗详情")
    @ApiOperation(value = "查询各公司电耗详情", notes = "查询各公司电耗详情")
    @RequestMapping(value = "/queryHDLDetails", method = RequestMethod.GET)
    public Result<List<Map<String, Object>>> queryHDLDetails(String startTime, String endTime) {
        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isEmpty(startTime)){
            startTime = endTime+"-01";
            endTime = endTime+"-31";
        }
        List<Map<String, Object>> data = operationMonthService.queryHDLDetails(null,startTime,endTime);
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }


    /**
     * 查詢月度厂级电耗统计
     *
     * @return
     */
    @AutoLog(value = "查詢月度厂级电耗统计")
    @ApiOperation(value = "查詢月度厂级电耗统计", notes = "查詢月度厂级电耗统计")
    @RequestMapping(value = "/queryMonthHDLDataByParentId", method = RequestMethod.GET)
    public Result<List<Map<String, Object>>> queryMonthHDLDataByParentId(String parentId,String startTime,String endTime) {
        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isEmpty(startTime)){
            startTime = endTime+"-01";
            endTime = endTime+"-31";
        }
        List<Map<String, Object>> data = operationMonthService.queryMonthHDLData(parentId,startTime,endTime);
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }


    /**
     * 查詢公司级电耗近半年曲线
     *
     * @return
     */
    @AutoLog(value = "查詢厂级电耗近半年曲线")
    @ApiOperation(value = "查詢厂级电耗近半年曲线", notes = "查詢厂级电耗近半年曲线")
    @RequestMapping(value = "/queryHDLYearByParentId", method = RequestMethod.GET)
    public Result<List<Map<String, String>>> queryHDLYearByFactoryId(String factoryId,String startTime,String endTime) {
        Result<List<Map<String, String>>> result = new Result<>();

        String startDate = startTime;
        String endDate = endTime;
        if (StringUtils.isEmpty(startDate)) {
            if (StringUtils.isEmpty(startDate)){
                Date date = DateUtils.str2Date(endDate, DateUtils.yyyyMM);
                Date date1 = new Date(date.getTime() - 13176000000L);
                startDate = DateUtils.date2Str(date1,DateUtils.yyyyMM);
            }
        }
        List<Map<String, String>> data = operationMonthService.queryHDLByYear(factoryId,startDate+"-01",endDate+"-31");
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }

    /**
     * 查询各公司电耗详情
     *
     * @return
     */
    @AutoLog(value = "根据公司查询厂级电耗详情")
    @ApiOperation(value = "根据公司查询厂级电耗详情", notes = "根据公司查询厂级电耗详情")
    @RequestMapping(value = "/queryHDLDetailsByParentId", method = RequestMethod.GET)
    public Result<List<Map<String, Object>>> queryHDLDetailsByParentId(String parentId,String startTime, String endTime) {
        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isEmpty(startTime)){
            startTime = endTime+"-01";
            endTime = endTime+"-31";
        }
        List<Map<String, Object>> data = operationMonthService.queryHDLDetails(parentId,startTime,endTime);
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }

}