VVT789
2025-02-11 1578b0aad5939ff38de31350f65703ae60c2eb1b
添加综合指标统计(月、年)接口
已添加13个文件
1784 ■■■■■ 文件已修改
zhitan-admin/src/main/java/com/zhitan/web/controller/comprehensivestatistics/MonthlyComprehensiveController.java 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-admin/src/main/java/com/zhitan/web/controller/comprehensivestatistics/YearComprehensiveController.java 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/DailyReport.java 321 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/MonthlyComprehensive.java 415 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/YearComperhensive.java 214 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/mapper/MonthlyComprehensiveMapper.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/mapper/YearComprehensiveMapper.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/ImonthlyComprehensive.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/IyearComprehensive.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/impl/MonthlyComprehensiveServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/impl/YearComprehensiveServiceImpl.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/resources/mapper/comprehensivestatistics/MonthlyComprehensiveMapper.xml 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-system/src/main/resources/mapper/comprehensivestatistics/YearComprehensiveMapper.xml 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-admin/src/main/java/com/zhitan/web/controller/comprehensivestatistics/MonthlyComprehensiveController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,205 @@
package com.zhitan.web.controller.comprehensivestatistics;
import com.zhitan.common.core.controller.BaseController;
import com.zhitan.common.core.domain.AjaxResult;
import com.zhitan.common.utils.poi.ExcelUtil;
import com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive;
import com.zhitan.comprehensivestatistics.service.ImonthlyComprehensive;
import com.zhitan.model.domain.ModelNode;
import com.zhitan.model.service.IModelNodeService;
import com.zhitan.realtimedata.domain.DataItem;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
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.RestController;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * electricityPriceController
 *
 * @author sys
 * @date 2020-02-18
 */
@Slf4j
@RestController
@RequestMapping("/comprehensive/monthlyComprehensive")
@Api(value = "综合指标分析(月)controller",tags = {"综合指标分析"})
public class MonthlyComprehensiveController extends BaseController {
    @Autowired
    private IModelNodeService modelNodeService;
    @Autowired
    private ImonthlyComprehensive monthlyComprehensive;
    /*全厂能耗统计*/
    @ApiOperation(value = "获取综合指标分析(月)列表")
    @GetMapping("/list")
    public AjaxResult list(DataItem dataItem) {
        try {
            Map tableColumn =new HashMap<>();//表数据
            List<MonthlyComprehensive> dataList=new ArrayList<>();
            DateFormat df = new SimpleDateFormat("yyyy-MM");
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String aa= df.format(dataItem.getDataTime());
            String bb="";
            int i = 1;
            String beginTime=aa+"-01 00:00:00";
            dataItem.setBeginTime(sf.parse(beginTime));
            String endTime=aa+"-"+Integer.valueOf(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length()-2))+" 00:00:00";
            dataItem.setEndTime(sf.parse(endTime));
            while (i <= Integer.parseInt(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length() - 2))) {
                if (i > 9) {
                    bb = aa + "-" + i + " 00:00:00";
                } else {
                    bb = aa + "-0" + i + " 00:00:00";
                }
                MonthlyComprehensive report = new MonthlyComprehensive();
                report.setDataTime(sf.parse(bb));
                report.setValue("value" + i);
                dataList.add(report);
                tableColumn.put("value" + i, String.valueOf(i) + "日");
                i++;
            }
            MonthlyComprehensive reportList = new MonthlyComprehensive();
            List<Map> table = new ArrayList<>();
            table.add(tableColumn);
            reportList.setTablehead(table);
            ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dataItem.getIndexCode());
            if (ObjectUtils.isEmpty(modelNode)) {
                return AjaxResult.success(reportList);
            }
            List<MonthlyComprehensive> list = monthlyComprehensive.getMonthlyComprehensiveList(modelNode.getNodeId(),
                    dataList, dataItem.getBeginTime(), dataItem.getEndTime(), dataItem.getTimeType(), dataItem.getIndexStorageId());
            int count = Integer.parseInt(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length() - 2));
            list.forEach(monthlyReport -> monthlyReport.setCount(count));
            reportList.setTabledata(list);
            return AjaxResult.success(reportList);
        } catch (Exception ex) {
            logger.error("获取出错!", ex);
            return AjaxResult.error("获取出错!");
        }
    }
/**/
    /**
     * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡å›¾
     */
    @GetMapping("/listChart")
    @ApiOperation(value = "获取综合指标分析图表(月)数据")
    public AjaxResult listChart(DataItem dataItem) throws ParseException {
        DateFormat df = new SimpleDateFormat("yyyy-MM");
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String aa= df.format(dataItem.getDataTime());
        String beginTime=aa+"-01 00:00:00";
        dataItem.setBeginTime(sf.parse(beginTime));
        String endTime=aa+"-"+Integer.valueOf(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length()-2))+" 00:00:00";
        dataItem.setEndTime(sf.parse(endTime));
        List<MonthlyComprehensive> list = monthlyComprehensive.getListChart(dataItem.getIndexId(),dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getIndexStorageId());
        return AjaxResult.success(list);
    }
    public static String getLastDayOfMonth(String yearMonth) {
        int year = Integer.parseInt(yearMonth.split("-")[0]);  //å¹´
        int month = Integer.parseInt(yearMonth.split("-")[1]); //月
        Calendar cal = Calendar.getInstance();
        // è®¾ç½®å¹´ä»½
        cal.set(Calendar.YEAR, year);
        // è®¾ç½®æœˆä»½
        // cal.set(Calendar.MONTH, month - 1);
        cal.set(Calendar.MONTH, month); //设置当前月的上一个月
        // èŽ·å–æŸæœˆæœ€å¤§å¤©æ•°
        //int lastDay = cal.getActualMaximum(Calendar.DATE);
        int lastDay = cal.getMinimum(Calendar.DATE); //获取月份中的最小值,即第一天
        // è®¾ç½®æ—¥åŽ†ä¸­æœˆä»½çš„æœ€å¤§å¤©æ•°
        //cal.set(Calendar.DAY_OF_MONTH, lastDay);
        cal.set(Calendar.DAY_OF_MONTH, lastDay - 1); //上月的第一天减去1就是当月的最后一天
        // æ ¼å¼åŒ–日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(cal.getTime());
    }
    /*综合月报表导出*/
//    @Log(title = "综合月报表导出", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation(value = "综合月报表导出")
    public AjaxResult export(DataItem dataItem) {
        try {
            Map tableColumn =new HashMap<>();//表数据
            List<MonthlyComprehensive> dataList=new ArrayList<>();
            DateFormat df = new SimpleDateFormat("yyyy-MM");
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String aa= df.format(dataItem.getDataTime());
            String bb="";
            int i = 1;
            String beginTime=aa+"-01 00:00:00";
            dataItem.setBeginTime(sf.parse(beginTime));
            String endTime=aa+"-"+Integer.valueOf(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length()-2))+" 00:00:00";
            dataItem.setEndTime(sf.parse(endTime));
            while (i <= Integer.parseInt(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length() - 2))) {
                if (i > 9) {
                    bb = aa + "-" + i + " 00:00:00";
                } else {
                    bb = aa + "-0" + i + " 00:00:00";
                }
                MonthlyComprehensive report = new MonthlyComprehensive();
                report.setDataTime(sf.parse(bb));
                report.setValue("value" + i);
                dataList.add(report);
                tableColumn.put("value" + i, i + "日");
                i++;
            }
            MonthlyComprehensive reportList = new MonthlyComprehensive();
            List<Map> table = new ArrayList<>();
            table.add(tableColumn);
            reportList.setTablehead(table);
            ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dataItem.getIndexCode());
            if (ObjectUtils.isEmpty(modelNode)) {
                return AjaxResult.success(reportList);
            }
            List<MonthlyComprehensive> list = monthlyComprehensive.getMonthlyComprehensiveList(modelNode.getNodeId(), dataList,
                    dataItem.getBeginTime(), dataItem.getEndTime(), dataItem.getTimeType(), dataItem.getIndexStorageId());
            int count = Integer.parseInt(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length() - 2));
            list.forEach(monthlyReport -> monthlyReport.setCount(count));
            if (CollectionUtils.isNotEmpty(list)) {
                list.forEach(this::valueRep);
            }
            ExcelUtil<MonthlyComprehensive> util = new ExcelUtil<>(MonthlyComprehensive.class);
            return util.exportExcel(list, "综合指标分析月");
        } catch (Exception ex) {
            logger.error("获取出错!", ex);
            return AjaxResult.error("获取出错!");
        }
    }
    public void valueRep(Object dr){
        Field[] fields = dr.getClass().getDeclaredFields();
        for(Field field:fields){
            field.setAccessible(true);
            Object obj = field.getType();
            if(field.getType().getName().equals("java.lang.Double")){
                String name = field.getName();
                try {
                    if(ObjectUtils.isEmpty(field.get(dr)))
                    {
                        field.set(dr,0.00);
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
zhitan-admin/src/main/java/com/zhitan/web/controller/comprehensivestatistics/YearComprehensiveController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,152 @@
package com.zhitan.web.controller.comprehensivestatistics;
import com.zhitan.common.annotation.Log;
import com.zhitan.common.core.controller.BaseController;
import com.zhitan.common.core.domain.AjaxResult;
import com.zhitan.common.enums.BusinessType;
import com.zhitan.common.utils.poi.ExcelUtil;
import com.zhitan.comprehensivestatistics.domain.YearComperhensive;
import com.zhitan.comprehensivestatistics.service.IyearComprehensive;
import com.zhitan.model.domain.ModelNode;
import com.zhitan.model.service.IModelNodeService;
import com.zhitan.realtimedata.domain.DataItem;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
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.RestController;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
 * electricityPriceController
 *
 * @author sys
 * @date 2020-02-18
 */
@RestController
@RequestMapping("/comprehensive/yearComprehensive")
@Api(value = "综合指标分析(年)controller",tags = {"综合指标分析"})
public class YearComprehensiveController extends BaseController {
    @Autowired
    private IModelNodeService modelNodeService;
    @Autowired
    private IyearComprehensive yearComprehensive;
    /*全厂能耗统计*/
    @GetMapping("/list")
    @ApiOperation(value = "获取综合指标分析(年)列表")
    public AjaxResult list(DataItem dataItem) {
        try {
            ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dataItem.getIndexCode());
            if (ObjectUtils.isEmpty(modelNode)) {
                return AjaxResult.success("暂无数据");
            }
            List<YearComperhensive> dataList = new ArrayList<>();
            DateFormat df = new SimpleDateFormat("yyyy");
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String aa= df.format(dataItem.getBeginTime());
            String bb="";
            int i = 1;
            while (i <= 12) {
                if(i>9){
                    bb=aa+"-"+i+"-01 00:00:00";
                }else{
                    bb=aa+"-0"+i+"-01 00:00:00";
                }
                YearComperhensive report = new YearComperhensive();
                report.setDataTime(sf.parse(bb));
                report.setValue("value"+i);
                dataList.add(report);
                i++;
            }
            List<YearComperhensive> list = yearComprehensive.getYearComprehensiveList(modelNode.getNodeId(),
                    dataList,dataItem.getBeginTime(), dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getIndexStorageId());
            return AjaxResult.success(list);
        } catch (Exception ex) {
            logger.error("获取出错!", ex);
            return AjaxResult.error("获取出错!");
        }
    }
    /**
     * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡å›¾
     */
    @GetMapping("/listChart")
    @ApiOperation(value = "获取综合指标分析图表(年)数据")
    public AjaxResult listChart(DataItem dataItem){
        List<YearComperhensive> list = yearComprehensive.getListChart(dataItem.getIndexId(),dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getIndexStorageId());
        return AjaxResult.success(list);
    }
    /**
     * å¯¼å‡ºå·¥åºå•耗统计指标设置功能列表
     */
    @Log(title = "综合报表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation(value = "综合年报表导出")
    public AjaxResult export(DataItem dataItem) {
        try {
            ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dataItem.getIndexCode());
            if (ObjectUtils.isEmpty(modelNode)) {
                return AjaxResult.success("暂无数据");
            }
            List<YearComperhensive> dataList = new ArrayList<>();
            DateFormat df = new SimpleDateFormat("yyyy");
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String aa = df.format(dataItem.getBeginTime());
            String bb = "";
            int i = 1;
            while (i <= 12) {
                if(i>9){
                    bb=aa+"-"+i+"-01 00:00:00";
                }else{
                    bb=aa+"-0"+i+"-01 00:00:00";
                }
                YearComperhensive report=new YearComperhensive();
                report.setDataTime(sf.parse(bb));
                report.setValue("value"+i);
                dataList.add(report);
                i++;
            }
            List<YearComperhensive> list = yearComprehensive.getYearComprehensiveList(modelNode.getNodeId(),
                    dataList,dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getIndexStorageId());
            if(CollectionUtils.isNotEmpty(list)){
                list.forEach(this::valueRep);
            }
            ExcelUtil<YearComperhensive> util = new ExcelUtil<>(YearComperhensive.class);
            return util.exportExcel(list, "综合指标分析年");
        } catch (Exception ex) {
            logger.error("获取出错!", ex);
            return AjaxResult.error("获取出错!");
        }
    }
    public void valueRep(Object dr){
        Field[] fields = dr.getClass().getDeclaredFields();
        for(Field field:fields){
            field.setAccessible(true);
            Object obj = field.getType();
            if(field.getType().getName().equals("java.lang.Double")){
                String name = field.getName();
                try {
                    if(ObjectUtils.isEmpty(field.get(dr)))
                    {
                        field.set(dr,0.00);
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/DailyReport.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,321 @@
package com.zhitan.comprehensivestatistics.domain;
import com.zhitan.common.annotation.Excel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 *
 * @author sys
 * @date 2020-03-25
 */
public class DailyReport implements Serializable {
    private static final long serialVersionUID = 1L;
    private String indexId;
    @Excel(name = "指标名称")
    private String indexName;
    private String value;
    private Date dataTime;
    private String timeType;
    @Excel(name = "0时")
    private Double value0;
    @Excel(name = "1时")
    private Double value1;
    @Excel(name = "2时")
    private Double value2;
    @Excel(name = "3时")
    private Double value3;
    @Excel(name = "4时")
    private Double value4;
    @Excel(name = "5时")
    private Double value5;
    @Excel(name = "6时")
    private Double value6;
    @Excel(name = "7时")
    private Double value7;
    @Excel(name = "8时")
    private Double value8;
    @Excel(name = "9时")
    private Double value9;
    @Excel(name = "10时")
    private Double value10;
    @Excel(name = "11时")
    private Double value11;
    @Excel(name = "12时")
    private Double value12;
    @Excel(name = "13时")
    private Double value13;
    @Excel(name = "14时")
    private Double value14;
    @Excel(name = "15时")
    private Double value15;
    @Excel(name = "16时")
    private Double value16;
    @Excel(name = "17时")
    private Double value17;
    @Excel(name = "18时")
    private Double value18;
    @Excel(name = "19时")
    private Double value19;
    @Excel(name = "20时")
    private Double value20;
    @Excel(name = "21时")
    private Double value21;
    @Excel(name = "22时")
    private Double value22;
    @Excel(name = "23时")
    private Double value23;
    private List<Map> tablehead =new ArrayList<>();
    private List<DailyReport> tabledata =new ArrayList<>();
    public String getIndexId() {
        return indexId;
    }
    public void setIndexId(String indexId) {
        this.indexId = indexId;
    }
    public String getIndexName() {
        return indexName;
    }
    public void setIndexName(String indexName) {
        this.indexName = indexName;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getTimeType() {
        return timeType;
    }
    public void setTimeType(String timeType) {
        this.timeType = timeType;
    }
    public Date getDataTime() {
        return dataTime;
    }
    public void setDataTime(Date dataTime) {
        this.dataTime = dataTime;
    }
    public Double getValue1() {
        return value1;
    }
    public void setValue1(Double value1) {
        this.value1 = value1;
    }
    public Double getValue2() {
        return value2;
    }
    public void setValue2(Double value2) {
        this.value2 = value2;
    }
    public Double getValue3() {
        return value3;
    }
    public void setValue3(Double value3) {
        this.value3 = value3;
    }
    public Double getValue4() {
        return value4;
    }
    public void setValue4(Double value4) {
        this.value4 = value4;
    }
    public Double getValue5() {
        return value5;
    }
    public void setValue5(Double value5) {
        this.value5 = value5;
    }
    public Double getValue6() {
        return value6;
    }
    public void setValue6(Double value6) {
        this.value6 = value6;
    }
    public Double getValue7() {
        return value7;
    }
    public void setValue7(Double value7) {
        this.value7 = value7;
    }
    public Double getValue8() {
        return value8;
    }
    public void setValue8(Double value8) {
        this.value8 = value8;
    }
    public Double getValue9() {
        return value9;
    }
    public void setValue9(Double value9) {
        this.value9 = value9;
    }
    public Double getValue10() {
        return value10;
    }
    public void setValue10(Double value10) {
        this.value10 = value10;
    }
    public Double getValue11() {
        return value11;
    }
    public void setValue11(Double value11) {
        this.value11 = value11;
    }
    public Double getValue12() {
        return value12;
    }
    public void setValue12(Double value12) {
        this.value12 = value12;
    }
    public Double getValue13() {
        return value13;
    }
    public void setValue13(Double value13) {
        this.value13 = value13;
    }
    public Double getValue14() {
        return value14;
    }
    public void setValue14(Double value14) {
        this.value14 = value14;
    }
    public Double getValue15() {
        return value15;
    }
    public void setValue15(Double value15) {
        this.value15 = value15;
    }
    public Double getValue16() {
        return value16;
    }
    public void setValue16(Double value16) {
        this.value16 = value16;
    }
    public Double getValue17() {
        return value17;
    }
    public void setValue17(Double value17) {
        this.value17 = value17;
    }
    public Double getValue18() {
        return value18;
    }
    public void setValue18(Double value18) {
        this.value18 = value18;
    }
    public Double getValue19() {
        return value19;
    }
    public void setValue19(Double value19) {
        this.value19 = value19;
    }
    public Double getValue20() {
        return value20;
    }
    public void setValue20(Double value20) {
        this.value20 = value20;
    }
    public Double getValue21() {
        return value21;
    }
    public void setValue21(Double value21) {
        this.value21 = value21;
    }
    public Double getValue22() {
        return value22;
    }
    public void setValue22(Double value22) {
        this.value22 = value22;
    }
    public Double getValue23() {
        return value23;
    }
    public void setValue23(Double value23) {
        this.value23 = value23;
    }
    public Double getValue0() {
        return value0;
    }
    public void setValue0(Double value0) {
        this.value0 = value0;
    }
    public List<Map> getTablehead() {
        return tablehead;
    }
    public void setTablehead(List<Map> tablehead) {
        this.tablehead = tablehead;
    }
    public List<DailyReport> getTabledata() {
        return tabledata;
    }
    public void setTabledata(List<DailyReport> tabledata) {
        this.tabledata = tabledata;
    }
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/MonthlyComprehensive.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,415 @@
package com.zhitan.comprehensivestatistics.domain;
import com.zhitan.common.annotation.Excel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 *
 * @author sys
 * @date 2020-12-31
 */
public class MonthlyComprehensive implements Serializable {
    private static final long serialVersionUID = 1L;
    private String indexId;
    @Excel(name = "指标名称")
    private String indexName;
    private String value;
    private Date dataTime;
    private String timeType;
    private String unitId;
    @Excel(name = "1日")
    private Double value1;
    @Excel(name = "2日")
    private Double value2;
    @Excel(name = "3日")
    private Double value3;
    @Excel(name = "4日")
    private Double value4;
    @Excel(name = "5日")
    private Double value5;
    @Excel(name = "6日")
    private Double value6;
    @Excel(name = "7日")
    private Double value7;
    @Excel(name = "8日")
    private Double value8;
    @Excel(name = "9日")
    private Double value9;
    @Excel(name = "10日")
    private Double value10;
    @Excel(name = "11日")
    private Double value11;
    @Excel(name = "12日")
    private Double value12;
    @Excel(name = "13日")
    private Double value13;
    @Excel(name = "14日")
    private Double value14;
    @Excel(name = "15日")
    private Double value15;
    @Excel(name = "16日")
    private Double value16;
    @Excel(name = "17日")
    private Double value17;
    @Excel(name = "18日")
    private Double value18;
    @Excel(name = "19日")
    private Double value19;
    @Excel(name = "20日")
    private Double value20;
    @Excel(name = "21日")
    private Double value21;
    @Excel(name = "22日")
    private Double value22;
    @Excel(name = "23日")
    private Double value23;
    @Excel(name = "24日")
    private Double value24;
    @Excel(name = "25日")
    private Double value25;
    @Excel(name = "26日")
    private Double value26;
    @Excel(name = "27日")
    private Double value27;
    @Excel(name = "28日")
    private Double value28;
    @Excel(name = "29日")
    private Double value29;
    @Excel(name = "30日")
    private Double value30;
    @Excel(name = "31日")
    private Double value31;
    private String timeCode;
    private Integer count;
    private List<Map> tablehead =new ArrayList<>();
    private List<MonthlyComprehensive> tabledata =new ArrayList<>();
    public String getIndexId() {
        return indexId;
    }
    public void setIndexId(String indexId) {
        this.indexId = indexId;
    }
    public String getIndexName() {
        return indexName;
    }
    public void setIndexName(String indexName) {
        this.indexName = indexName;
    }
    public String getUnitId() {
        return unitId;
    }
    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getTimeType() {
        return timeType;
    }
    public void setTimeType(String timeType) {
        this.timeType = timeType;
    }
    public Date getDataTime() {
        return dataTime;
    }
    public void setDataTime(Date dataTime) {
        this.dataTime = dataTime;
    }
    public Double getValue1() {
        return value1;
    }
    public void setValue1(Double value1) {
        this.value1 = value1;
    }
    public Double getValue2() {
        return value2;
    }
    public void setValue2(Double value2) {
        this.value2 = value2;
    }
    public Double getValue3() {
        return value3;
    }
    public void setValue3(Double value3) {
        this.value3 = value3;
    }
    public Double getValue4() {
        return value4;
    }
    public void setValue4(Double value4) {
        this.value4 = value4;
    }
    public Double getValue5() {
        return value5;
    }
    public void setValue5(Double value5) {
        this.value5 = value5;
    }
    public Double getValue6() {
        return value6;
    }
    public void setValue6(Double value6) {
        this.value6 = value6;
    }
    public Double getValue7() {
        return value7;
    }
    public void setValue7(Double value7) {
        this.value7 = value7;
    }
    public Double getValue8() {
        return value8;
    }
    public void setValue8(Double value8) {
        this.value8 = value8;
    }
    public Double getValue9() {
        return value9;
    }
    public void setValue9(Double value9) {
        this.value9 = value9;
    }
    public Double getValue10() {
        return value10;
    }
    public void setValue10(Double value10) {
        this.value10 = value10;
    }
    public Double getValue11() {
        return value11;
    }
    public void setValue11(Double value11) {
        this.value11 = value11;
    }
    public Double getValue12() {
        return value12;
    }
    public void setValue12(Double value12) {
        this.value12 = value12;
    }
    public Double getValue13() {
        return value13;
    }
    public void setValue13(Double value13) {
        this.value13 = value13;
    }
    public Double getValue14() {
        return value14;
    }
    public void setValue14(Double value14) {
        this.value14 = value14;
    }
    public Double getValue15() {
        return value15;
    }
    public void setValue15(Double value15) {
        this.value15 = value15;
    }
    public Double getValue16() {
        return value16;
    }
    public void setValue16(Double value16) {
        this.value16 = value16;
    }
    public Double getValue17() {
        return value17;
    }
    public void setValue17(Double value17) {
        this.value17 = value17;
    }
    public Double getValue18() {
        return value18;
    }
    public void setValue18(Double value18) {
        this.value18 = value18;
    }
    public Double getValue19() {
        return value19;
    }
    public void setValue19(Double value19) {
        this.value19 = value19;
    }
    public Double getValue20() {
        return value20;
    }
    public void setValue20(Double value20) {
        this.value20 = value20;
    }
    public Double getValue21() {
        return value21;
    }
    public void setValue21(Double value21) {
        this.value21 = value21;
    }
    public Double getValue22() {
        return value22;
    }
    public void setValue22(Double value22) {
        this.value22 = value22;
    }
    public Double getValue23() {
        return value23;
    }
    public void setValue23(Double value23) {
        this.value23 = value23;
    }
    public Double getValue24() {
        return value24;
    }
    public void setValue24(Double value24) {
        this.value24 = value24;
    }
    public Double getValue25() {
        return value25;
    }
    public void setValue25(Double value25) {
        this.value25 = value25;
    }
    public Double getValue26() {
        return value26;
    }
    public void setValue26(Double value26) {
        this.value26 = value26;
    }
    public Double getValue27() {
        return value27;
    }
    public void setValue27(Double value27) {
        this.value27 = value27;
    }
    public Double getValue28() {
        return value28;
    }
    public void setValue28(Double value28) {
        this.value28 = value28;
    }
    public Double getValue29() {
        return value29;
    }
    public void setValue29(Double value29) {
        this.value29 = value29;
    }
    public Double getValue30() {
        return value30;
    }
    public void setValue30(Double value30) {
        this.value30 = value30;
    }
    public Double getValue31() {
        return value31;
    }
    public void setValue31(Double value31) {
        this.value31 = value31;
    }
    public List<Map> getTablehead() {
        return tablehead;
    }
    public void setTablehead(List<Map> tablehead) {
        this.tablehead = tablehead;
    }
    public List<MonthlyComprehensive> getTabledata() {
        return tabledata;
    }
    public void setTabledata(List<MonthlyComprehensive> tabledata) {
        this.tabledata = tabledata;
    }
    public String getTimeCode() {
        return timeCode;
    }
    public void setTimeCode(String timeCode) {
        this.timeCode = timeCode;
    }
    public Integer getCount() {
        return count;
    }
    public void setCount(Integer count) {
        this.count = count;
    }
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/domain/YearComperhensive.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,214 @@
package com.zhitan.comprehensivestatistics.domain;
import com.zhitan.common.annotation.Excel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 *
 * @author sys
 * @date 2020-03-25
 */
public class YearComperhensive implements Serializable {
    private static final long serialVersionUID = 1L;
    private String indexId;
    @Excel(name = "指标名称")
    private String indexName;
    private String value;
    private Date dataTime;
    private String timeType;
    private String unitId;
    @Excel(name = "1月")
    private Double value1;
    @Excel(name = "2月")
    private Double value2;
    @Excel(name = "3月")
    private Double value3;
    @Excel(name = "4月")
    private Double value4;
    @Excel(name = "5月")
    private Double value5;
    @Excel(name = "6月")
    private Double value6;
    @Excel(name = "7月")
    private Double value7;
    @Excel(name = "8月")
    private Double value8;
    @Excel(name = "9月")
    private Double value9;
    @Excel(name = "10月")
    private Double value10;
    @Excel(name = "11月")
    private Double value11;
    @Excel(name = "12月")
    private Double value12;
    private String timeCode;
    private List<Map> tablehead =new ArrayList<>();
    private List<DailyReport> tabledata =new ArrayList<>();
    public String getIndexId() {
        return indexId;
    }
    public void setIndexId(String indexId) {
        this.indexId = indexId;
    }
    public String getIndexName() {
        return indexName;
    }
    public void setIndexName(String indexName) {
        this.indexName = indexName;
    }
    public String getUnitId() {
        return unitId;
    }
    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getTimeType() {
        return timeType;
    }
    public void setTimeType(String timeType) {
        this.timeType = timeType;
    }
    public Date getDataTime() {
        return dataTime;
    }
    public void setDataTime(Date dataTime) {
        this.dataTime = dataTime;
    }
    public Double getValue1() {
        return value1;
    }
    public void setValue1(Double value1) {
        this.value1 = value1;
    }
    public Double getValue2() {
        return value2;
    }
    public void setValue2(Double value2) {
        this.value2 = value2;
    }
    public Double getValue3() {
        return value3;
    }
    public void setValue3(Double value3) {
        this.value3 = value3;
    }
    public Double getValue4() {
        return value4;
    }
    public void setValue4(Double value4) {
        this.value4 = value4;
    }
    public Double getValue5() {
        return value5;
    }
    public void setValue5(Double value5) {
        this.value5 = value5;
    }
    public Double getValue6() {
        return value6;
    }
    public void setValue6(Double value6) {
        this.value6 = value6;
    }
    public Double getValue7() {
        return value7;
    }
    public void setValue7(Double value7) {
        this.value7 = value7;
    }
    public Double getValue8() {
        return value8;
    }
    public void setValue8(Double value8) {
        this.value8 = value8;
    }
    public Double getValue9() {
        return value9;
    }
    public void setValue9(Double value9) {
        this.value9 = value9;
    }
    public Double getValue10() {
        return value10;
    }
    public void setValue10(Double value10) {
        this.value10 = value10;
    }
    public Double getValue11() {
        return value11;
    }
    public void setValue11(Double value11) {
        this.value11 = value11;
    }
    public Double getValue12() {
        return value12;
    }
    public void setValue12(Double value12) {
        this.value12 = value12;
    }
    public String getTimeCode() {
        return timeCode;
    }
    public void setTimeCode(String timeCode) {
        this.timeCode = timeCode;
    }
    public List<Map> getTablehead() {
        return tablehead;
    }
    public void setTablehead(List<Map> tablehead) {
        this.tablehead = tablehead;
    }
    public List<DailyReport> getTabledata() {
        return tabledata;
    }
    public void setTabledata(List<DailyReport> tabledata) {
        this.tabledata = tabledata;
    }
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/mapper/MonthlyComprehensiveMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package com.zhitan.comprehensivestatistics.mapper;
import com.zhitan.common.enums.TimeType;
import com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
 * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ æœˆ
 *
 * @author sys
 * @date 2020-03-25
 */
public interface MonthlyComprehensiveMapper {
    /**
     * èŽ·å–ç»¼åˆæŒ‡æ ‡åˆ†æžï¼ˆæœˆï¼‰åˆ—è¡¨
     *
     * @param nodeId
     * @param dataList
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    public List<MonthlyComprehensive> getMonthlyComprehensiveList(@Param("nodeId") String nodeId,
                                                                  @Param("dataList") List<MonthlyComprehensive> dataList,
                                                                  @Param("beginTime") Date beginTime,
                                                                  @Param("endTime") Date endTime,
                                                                  @Param("timeType") TimeType timeType,
                                                                  @Param("indexStorageId") String indexStorageId);
    /**
     * èŽ·å–ç»¼åˆæŒ‡æ ‡åˆ†æžå›¾è¡¨ï¼ˆæœˆï¼‰æ•°æ®
     *
     * @param indexId
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<MonthlyComprehensive> getListChart(@Param("indexId") String indexId,
                                            @Param("beginTime") Date beginTime,
                                            @Param("endTime") Date endTime,
                                            @Param("timeType") TimeType timeType,
                                            @Param("indexStorageId") String indexStorageId);
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/mapper/YearComprehensiveMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package com.zhitan.comprehensivestatistics.mapper;
import com.zhitan.common.enums.TimeType;
import com.zhitan.comprehensivestatistics.domain.YearComperhensive;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
 * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ å¹´
 *
 * @author sys
 * @date 2020-03-25
 */
public interface YearComprehensiveMapper {
    /**
     * èŽ·å–å¹´æ•°æ®
     *
     * @param nodeId
     * @param dataList
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    public List<YearComperhensive> getYearComprehensiveList(@Param("nodeId") String nodeId,
                                                            @Param("dataList") List<YearComperhensive> dataList,
                                                            @Param("beginTime") Date beginTime,
                                                            @Param("endTime") Date endTime,
                                                            @Param("timeType") TimeType timeType,
                                                            @Param("indexStorageId") String indexStorageId);
    /**
     * èŽ·å–å¹´æ•°æ®-chart
     *
     * @param indexId
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<YearComperhensive> getListChart(@Param("indexId") String indexId,
                                            @Param("beginTime") Date beginTime,
                                            @Param("endTime") Date endTime,
                                            @Param("timeType") TimeType timeType,
                                            @Param("indexStorageId") String indexStorageId);
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/ImonthlyComprehensive.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
package com.zhitan.comprehensivestatistics.service;
import com.zhitan.common.enums.TimeType;
import com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive;
import java.util.Date;
import java.util.List;
/**
 * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ æœˆ
 *
 * @author sys
 * @date 2020-03-25
 */
public interface ImonthlyComprehensive {
    /**
     * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ æœˆ
     *
     * @param nodeId
     * @param dataList
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<MonthlyComprehensive> getMonthlyComprehensiveList(String nodeId, List<MonthlyComprehensive> dataList, Date beginTime, Date endTime, TimeType timeType, String indexStorageId);
    /**
     * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ æœˆ
     *
     * @param indexId
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<MonthlyComprehensive> getListChart(String indexId, Date beginTime, Date endTime, TimeType timeType, String indexStorageId);
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/IyearComprehensive.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package com.zhitan.comprehensivestatistics.service;
import com.zhitan.common.enums.TimeType;
import com.zhitan.comprehensivestatistics.domain.YearComperhensive;
import java.util.Date;
import java.util.List;
/**
 * å…¨åŽ‚ç»¼åˆèƒ½è€—ç»Ÿè®¡ å¹´
 *
 * @author sys
 * @date 2020-03-25
 */
public interface IyearComprehensive {
    /**
     * èŽ·å–ç»¼åˆæŒ‡æ ‡åˆ†æžï¼ˆå¹´ï¼‰åˆ—è¡¨
     *
     * @param nodeId
     * @param dataList
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<YearComperhensive> getYearComprehensiveList(String nodeId, List<YearComperhensive> dataList,
                                                            Date beginTime, Date endTime, TimeType timeType, String indexStorageId);
    /**
     * èŽ·å–ç»¼åˆæŒ‡æ ‡åˆ†æžï¼ˆå¹´ï¼‰å›¾è¡¨æ•°æ®
     *
     * @param indexId
     * @param beginTime
     * @param endTime
     * @param timeType
     * @param indexStorageId
     * @return
     */
    List<YearComperhensive> getListChart(String indexId, Date beginTime, Date endTime, TimeType timeType, String indexStorageId);
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/impl/MonthlyComprehensiveServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package com.zhitan.comprehensivestatistics.service.impl;
import com.zhitan.common.enums.TimeType;
import com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive;
import com.zhitan.comprehensivestatistics.mapper.MonthlyComprehensiveMapper;
import com.zhitan.comprehensivestatistics.service.ImonthlyComprehensive;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
 * ä¸šåŠ¡å±‚å¤„ç†
 *
 * @author sys
 * @date 2020-03-25
 */
@Service
public class MonthlyComprehensiveServiceImpl implements ImonthlyComprehensive {
    @Resource
    private MonthlyComprehensiveMapper monthMapper;
    public List<MonthlyComprehensive> getMonthlyComprehensiveList(String nodeId, List<MonthlyComprehensive> dataList,
                                                                  Date beginTime, Date endTime, TimeType timeType, String indexStorageId){
        if (StringUtils.isNotEmpty(nodeId)) {
            return monthMapper.getMonthlyComprehensiveList(nodeId, dataList, beginTime, endTime, timeType, indexStorageId);
        }
        return Collections.emptyList();
    }
    @Override
    public List<MonthlyComprehensive> getListChart(String indexId, Date beginTime, Date endTime, TimeType timeType, String indexStorageId){
        if (indexId != null && !indexId.isEmpty()) {
            return monthMapper.getListChart(indexId,beginTime,endTime,timeType,indexStorageId);
        }
        return Collections.emptyList();
    }
}
zhitan-system/src/main/java/com/zhitan/comprehensivestatistics/service/impl/YearComprehensiveServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.zhitan.comprehensivestatistics.service.impl;
import cn.hutool.core.date.DateUtil;
import com.zhitan.common.constant.CommonConst;
import com.zhitan.common.enums.TimeType;
import com.zhitan.common.utils.DateTimeUtil;
import com.zhitan.comprehensivestatistics.domain.YearComperhensive;
import com.zhitan.comprehensivestatistics.mapper.YearComprehensiveMapper;
import com.zhitan.comprehensivestatistics.service.IyearComprehensive;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
 * ä¸šåŠ¡å±‚å¤„ç†
 *
 * @author sys
 * @date 2020-03-25
 */
@Service
public class YearComprehensiveServiceImpl implements IyearComprehensive {
    @Resource
    private YearComprehensiveMapper yearMapper;
    @Override
    public List<YearComperhensive> getYearComprehensiveList(String nodeId, List<YearComperhensive> dataList,
                                                            Date beginTime, Date endTime, TimeType timeType, String indexStorageId){
        if (StringUtils.isNotEmpty(nodeId)) {
            return yearMapper.getYearComprehensiveList(nodeId, dataList, beginTime, endTime, timeType, indexStorageId);
        }
        return Collections.emptyList();
    }
    @Override
    public List<YearComperhensive> getListChart(String indexId, Date beginTime, Date endTime, TimeType timeType, String indexStorageId){
        List<YearComperhensive> dataList = new ArrayList<>();
        if (StringUtils.isNotEmpty(indexId)) {
            List<YearComperhensive> listChart = yearMapper.getListChart(indexId, beginTime, endTime, timeType, indexStorageId);
            if (CollectionUtils.isNotEmpty(listChart)) {
                Date date = new Date();
                YearComperhensive first = listChart.get(CommonConst.DIGIT_0);
                Map<String, YearComperhensive> listChartMap = yearMapper.getListChart(indexId, beginTime, endTime, timeType, indexStorageId)
                        .stream().collect(Collectors.toMap(YearComperhensive::getTimeCode, prot -> prot));
                while (beginTime.before(date)) {
                    YearComperhensive yearComperhensive = new YearComperhensive();
                    String format = CommonConst.WORD_M + DateUtil.format(beginTime, DateTimeUtil.COMMON_PATTERN_MONTH);
                    YearComperhensive item = listChartMap.get(format);
                    if (ObjectUtils.isNotEmpty(item)) {
                        yearComperhensive = item;
                    } else {
                        yearComperhensive.setTimeCode(format);
                        yearComperhensive.setIndexId(indexId);
                        yearComperhensive.setTimeType(timeType.name());
                        yearComperhensive.setUnitId(first.getUnitId());
                        yearComperhensive.setIndexName(first.getIndexName());
                    }
                    dataList.add(yearComperhensive);
                    beginTime = DateUtil.offsetMonth(beginTime, CommonConst.DIGIT_1);
                }
            }
        }
        return dataList;
    }
}
zhitan-system/src/main/resources/mapper/comprehensivestatistics/MonthlyComprehensiveMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhitan.comprehensivestatistics.mapper.MonthlyComprehensiveMapper">
    <resultMap id="dataItemMap" type="com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive">
        <result column="index_id" property="indexId"/>
        <result column="index_name" property="indexName"/>
        <result column="time_type" property="timeType"/>
        <result column="time_code" property="timeCode"/>
        <result column="unit_id" property="unitId"/>
        <result column="value1" property="value1"/>
        <result column="value2" property="value2"/>
        <result column="value3" property="value3"/>
        <result column="value4" property="value4"/>
        <result column="value5" property="value5"/>
        <result column="value6" property="value6"/>
        <result column="value7" property="value7"/>
        <result column="value8" property="value8"/>
        <result column="value9" property="value9"/>
        <result column="value10" property="value10"/>
        <result column="value11" property="value11"/>
        <result column="value12" property="value12"/>
        <result column="value13" property="value13"/>
        <result column="value14" property="value14"/>
        <result column="value15" property="value15"/>
        <result column="value16" property="value16"/>
        <result column="value17" property="value17"/>
        <result column="value18" property="value18"/>
        <result column="value19" property="value19"/>
        <result column="value20" property="value20"/>
        <result column="value21" property="value21"/>
        <result column="value22" property="value22"/>
        <result column="value23" property="value23"/>
        <result column="value24" property="value24"/>
        <result column="value25" property="value25"/>
        <result column="value26" property="value26"/>
        <result column="value27" property="value27"/>
        <result column="value28" property="value28"/>
        <result column="value29" property="value29"/>
        <result column="value30" property="value30"/>
        <result column="value31" property="value31"/>
    </resultMap>
    <!--全厂能耗统计-->
    <select id="getMonthlyComprehensiveList" resultMap="dataItemMap">
        SELECT
            aa.index_id,
            aa.index_name,
        <foreach item="item" index="index" collection="dataList">
            COALESCE ( MAX ( CASE WHEN data_time = #{item.dataTime} THEN "value" END ), null ) AS ${item.value},
        </foreach>
            aa.time_type,
            aa.order_num orderNum
        FROM
        (
            SELECT
                ni.index_id,
                ei."name" AS "index_name",
                di."value",
                di.data_time,
                di.time_type,
                mn.order_num
            FROM
                model_node mn
                LEFT JOIN node_index ni ON ni.node_id = mn.node_id
                LEFT JOIN energy_index ei ON ei.index_id = ni.index_id
                LEFT JOIN data_item di ON ni.index_id = di.index_id
            WHERE
                mn.parent_id = #{nodeId}
                AND di.data_time >= #{beginTime}
                AND di.data_time &lt;= #{endTime}
                AND di.time_type = #{timeType}
            <if test="indexStorageId !='' and indexStorageId !=null">
                and ei.energy_id=#{indexStorageId}
            </if>
        ) aa
        GROUP BY
        aa.index_id, aa.index_name, aa.time_type, aa.order_num
        ORDER BY aa.order_num ASC
    </select>
    <select id="getListChart" resultMap="dataItemMap">
        SELECT
            di.index_id,
            ci.name AS "index_name",
            ci.unit_id,
            di."value",
            di.data_time,
            di.time_type,
            di.time_code
        FROM
        data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id
        WHERE
            di.index_id =#{indexId}
            AND di.data_time &lt;= #{endTime}
            AND di.data_time >= #{beginTime}
            AND di.time_type = #{timeType}
        ORDER BY
            di.time_code;
    </select>
</mapper>
zhitan-system/src/main/resources/mapper/comprehensivestatistics/YearComprehensiveMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhitan.comprehensivestatistics.mapper.YearComprehensiveMapper">
    <resultMap id="dataItemMap" type="com.zhitan.comprehensivestatistics.domain.YearComperhensive">
        <result column="index_id" property="indexId"/>
        <result column="index_name" property="indexName"/>
        <result column="time_type" property="timeType"/>
        <result column="time_code" property="timeCode"/>
        <result column="unit_id" property="unitId"/>
        <result column="value1" property="value1"/>
        <result column="value2" property="value2"/>
        <result column="value3" property="value3"/>
        <result column="value4" property="value4"/>
        <result column="value5" property="value5"/>
        <result column="value6" property="value6"/>
        <result column="value7" property="value7"/>
        <result column="value8" property="value8"/>
        <result column="value9" property="value9"/>
        <result column="value10" property="value10"/>
        <result column="value11" property="value11"/>
        <result column="value12" property="value12"/>
    </resultMap>
    <!--全厂能耗统计-->
    <select id="getYearComprehensiveList" resultMap="dataItemMap">
        SELECT
            aa.index_id,
            aa.index_name,
            <foreach item="item" index="index" collection="dataList">
                COALESCE ( MAX ( CASE WHEN data_time = #{item.dataTime} THEN "value" END ), null ) AS ${item.value},
            </foreach>
            aa.time_type,
            aa.order_num orderNum
        FROM
        (
            SELECT
                ni.index_id,
                ei."name" AS "index_name",
                di."value",
                di.data_time,
                di.time_type,
                mn.order_num
            FROM
                model_node mn
                LEFT JOIN node_index ni ON ni.node_id = mn.node_id
                LEFT JOIN energy_index ei ON ei.index_id = ni.index_id
                LEFT JOIN data_item di ON ni.index_id = di.index_id
            WHERE
                mn.parent_id = #{nodeId}
                AND di.data_time >= #{beginTime}
                AND di.data_time &lt;= #{endTime}
                AND di.time_type = #{timeType}
            <if test="indexStorageId !='' and indexStorageId !=null">
                and ei.energy_id=#{indexStorageId}
            </if>
        ) aa
        GROUP BY aa.index_id, aa.index_name, aa.time_type, aa.order_num
        ORDER BY aa.order_num ASC
    </select>
    <select id="getListChart" resultMap="dataItemMap">
        SELECT
            di.index_id,
            ci.name AS "index_name",
            ci.unit_id,
            di."value",
            di.data_time,
            di.time_type,
            di.time_code
        FROM
        data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id
        WHERE
            di.index_id =#{indexId}
            AND di.data_time &lt; #{endTime}
            AND di.data_time >= #{beginTime}
            AND di.time_type = #{timeType}
        ORDER BY
            di.time_code;
    </select>
</mapper>