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 <= #{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 <= #{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 <= #{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 < #{endTime} AND di.data_time >= #{beginTime} AND di.time_type = #{timeType} ORDER BY di.time_code; </select> </mapper>