From 1ad212f3bb062a711d6626ed94e7ae12e5cd8b9c Mon Sep 17 00:00:00 2001 From: z1415143022 <z1415143022@163.com> Date: 星期五, 21 三月 2025 01:51:13 +0800 Subject: [PATCH] 工序能耗分析 --- zhitan-system/src/main/resources/mapper/dailyprocessenergy/DailyProcessEnergyMapper.xml | 87 ++ zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/MonthlyProcessEnergyServiceImpl.java | 43 + zhitan-system/src/main/java/com/zhitan/processenergy/mapper/MonthlyProcessEnergyMapper.java | 47 + zhitan-system/src/main/resources/mapper/dailyprocessenergy/MonthlyProcessEnergyMapper.xml | 95 +++ zhitan-system/src/main/java/com/zhitan/processenergy/domain/MonthlyProcessEnergy.java | 427 +++++++++++++ zhitan-system/src/main/java/com/zhitan/processenergy/domain/YearProcessEnergy.java | 237 +++++++ zhitan-system/src/main/java/com/zhitan/processenergy/dto/DataItemQueryDTO.java | 28 zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/DailyProcessEnergyServiceImpl.java | 39 + zhitan-system/src/main/resources/mapper/dailyprocessenergy/YearProcessEnergyMapper.xml | 81 ++ zhitan-system/src/main/java/com/zhitan/processenergy/domain/DailyProcessEnergy.java | 74 ++ zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/MonthlyProcessEnergyController.java | 135 ++++ zhitan-system/src/main/java/com/zhitan/processenergy/mapper/DailyProcessEnergyMapper.java | 48 + zhitan-system/src/main/java/com/zhitan/processenergy/service/IDailyProcessEnergyService.java | 38 + zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/DailyProcessEnergyController.java | 90 ++ zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/YearProcessEnergyController.java | 74 ++ zhitan-system/src/main/java/com/zhitan/processenergy/mapper/YearProcessEnergyMapper.java | 46 + zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/YearProcessEnergyServiceImpl.java | 59 + zhitan-system/src/main/java/com/zhitan/processenergy/service/IMonthlyProcessEnergyService.java | 19 zhitan-system/src/main/java/com/zhitan/processenergy/service/IYearProcessEnergyService.java | 26 zhitan-common/src/main/java/com/zhitan/common/utils/DateTimeUtil.java | 118 ++ 20 files changed, 1,783 insertions(+), 28 deletions(-) diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/DailyProcessEnergyController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/DailyProcessEnergyController.java new file mode 100644 index 0000000..45c2acf --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/DailyProcessEnergyController.java @@ -0,0 +1,90 @@ +package com.zhitan.web.controller.processenergy; + +import com.zhitan.basicdata.domain.FacilityArchives; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.model.domain.EnergyIndex; +import com.zhitan.model.domain.ModelNode; +import com.zhitan.model.service.IModelNodeService; +import com.zhitan.processenergy.domain.DailyProcessEnergy; +import com.zhitan.processenergy.service.IDailyProcessEnergyService; +import com.zhitan.realtimedata.domain.DataItem; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.CollectionUtils; +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.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 宸ュ簭鑳借�� 鏃� + */ +@RestController +@RequestMapping("/processEnergy/dailyProcessEnergy") +@Api(value = "宸ュ簭鑳借�楃粺璁★紙鏃ワ級", tags = {"宸ュ簭鑳借�楃粺璁�"}) +public class DailyProcessEnergyController extends BaseController { + + @Autowired + private IModelNodeService modelNodeService; + + @Autowired + private IDailyProcessEnergyService dailyProcessEnergy; + + @GetMapping("/list") + @ApiOperation(value = "宸ュ簭鑳借�楃粺璁★紙鏃ワ級鍒楄〃") + public AjaxResult list(DataItem dataItem) throws ParseException{ + List<ModelNode> nodeId = modelNodeService.getModelNodeByModelCode(dataItem.getIndexCode()); + if(CollectionUtils.isEmpty(nodeId)){ + return success(new ArrayList<>()); + } + List<EnergyIndex> energyList = modelNodeService.getSettingIndex(nodeId.get(0).getNodeId()); + if(CollectionUtils.isEmpty(energyList)){ + return success(new ArrayList<>()); + } + List<String> indexIds = energyList.stream().map(EnergyIndex::getIndexId).collect(Collectors.toList()); + List<DailyProcessEnergy> dataList = new ArrayList<>(); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String aa= df.format(dataItem.getDataTime()); + String bb=""; + int i = 0; + dataItem.setBeginTime(dataItem.getDataTime()); + String endTime=aa+" 24:00:00"; + dataItem.setEndTime(sf.parse(endTime)); + while (i < 24) { + if(i>9){ + bb=aa+" "+i+":00:00"; + }else{ + bb=aa+" 0"+i+":00:00"; + } + DailyProcessEnergy report=new DailyProcessEnergy(); + report.setDataTime(sf.parse(bb)); + report.setValue("value"+i); + dataList.add(report); + i++; + } + List<DailyProcessEnergy> list = dailyProcessEnergy.getDailyProcessEnergyList(indexIds, dataList,dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getEnergyType()); + return success(list); + } + + @GetMapping("/listChart") + @ApiOperation(value = "宸ュ簭鑳借�楋紙鏃ワ級鍥捐〃") + public AjaxResult listChart(DataItem dataItem) throws ParseException { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String aa= df.format(dataItem.getDataTime()); + dataItem.setBeginTime(dataItem.getDataTime()); + String endTime=aa+" 24:00:00"; + dataItem.setEndTime(sf.parse(endTime)); + List<DailyProcessEnergy> list = dailyProcessEnergy.getListChart(dataItem.getIndexId(),dataItem.getBeginTime(),dataItem.getEndTime(), dataItem.getTimeType(),dataItem.getEnergyType()); + return AjaxResult.success(list); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/MonthlyProcessEnergyController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/MonthlyProcessEnergyController.java new file mode 100644 index 0000000..5b809f0 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/MonthlyProcessEnergyController.java @@ -0,0 +1,135 @@ +package com.zhitan.web.controller.processenergy; + +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.model.domain.EnergyIndex; +import com.zhitan.model.domain.ModelNode; +import com.zhitan.model.service.IModelNodeService; +import com.zhitan.processenergy.domain.MonthlyProcessEnergy; +import com.zhitan.processenergy.service.IMonthlyProcessEnergyService; +import com.zhitan.realtimedata.domain.DataItem; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.CollectionUtils; +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.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 宸ュ簭鑳借�� 鏈� + */ +@RestController +@RequestMapping("/processEnergy/monthlyProcessEnergy") +@Api(value = "宸ュ簭鑳借�楃粺璁★紙鏈堬級", tags = {"宸ュ簭鑳借�楃粺璁�"}) +public class MonthlyProcessEnergyController extends BaseController { + + @Autowired + private IModelNodeService modelNodeService; + @Autowired + private IMonthlyProcessEnergyService monthlyProcessEnergyService; + + /** + * + * @param dataItem + * @return + * @throws ParseException + */ + @GetMapping("/list") + @ApiOperation(value = "宸ュ簭鑳借�楃粺璁★紙鏈堬級") + public AjaxResult list(DataItem dataItem) throws ParseException { + List<MonthlyProcessEnergy> dataList = new ArrayList<>(); + + Map tableColumn = new HashMap<>();//琛ㄦ暟鎹� + 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.valueOf(getLastDayOfMonth(aa).substring(getLastDayOfMonth(aa).length() - 2))) { + if (i > 9) { + bb = aa + "-" + i + " 00:00:00"; + } else { + bb = aa + "-0" + i + " 00:00:00"; + } + MonthlyProcessEnergy report = new MonthlyProcessEnergy(); + report.setDataTime(sf.parse(bb)); + report.setValue("value" + i); + dataList.add(report); + tableColumn.put("value" + i, String.valueOf(i) + "鏃�"); + i++; + } + List<Map> table = new ArrayList<>(); + MonthlyProcessEnergy reportList = new MonthlyProcessEnergy(); + table.add(tableColumn); + reportList.setTablehead(table); + List<ModelNode> nodeId = modelNodeService.getModelNodeByModelCode(dataItem.getIndexCode()); + if (CollectionUtils.isEmpty(nodeId)) { + return success(new ArrayList<>()); + } + List<EnergyIndex> energyList = modelNodeService.getSettingIndex(nodeId.get(0).getNodeId()); + if (CollectionUtils.isEmpty(energyList)) { + return success(new ArrayList<>()); + } + List<String> indexIds = energyList.stream().map(EnergyIndex::getIndexId).collect(Collectors.toList()); + + List<MonthlyProcessEnergy> list = monthlyProcessEnergyService.getMonthlyProcessEnergy(indexIds, dataList, dataItem.getBeginTime(), dataItem.getEndTime(), dataItem.getTimeType(), dataItem.getEnergyType()); + + return success(list); + } + + /** + * + * @param dataItem + * @return + * @throws ParseException + */ + @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<MonthlyProcessEnergy> list = monthlyProcessEnergyService.getListChart(dataItem.getIndexId(), dataItem.getBeginTime(), dataItem.getEndTime(), dataItem.getTimeType(), dataItem.getEnergyType()); + return AjaxResult.success(list); + } + + /** + * + * @param yearMonth + * @return + */ + 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()); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/YearProcessEnergyController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/YearProcessEnergyController.java new file mode 100644 index 0000000..54c988e --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/processenergy/YearProcessEnergyController.java @@ -0,0 +1,74 @@ +package com.zhitan.web.controller.processenergy; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.utils.DateTimeUtil; +import com.zhitan.common.utils.TypeTime; +import com.zhitan.model.domain.EnergyIndex; +import com.zhitan.model.domain.ModelNode; +import com.zhitan.model.service.IModelNodeService; +import com.zhitan.processenergy.domain.YearProcessEnergy; +import com.zhitan.processenergy.service.IYearProcessEnergyService; +import com.zhitan.realtimedata.domain.dto.DataItemQueryDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.CollectionUtils; +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.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 宸ュ簭鑳借�� 骞� + * + * + */ +@RestController +@RequestMapping("/processEnergy/YearProcessEnergy") +@Api(value = "宸ュ簭鑳借�楃粺璁★紙骞达級", tags = {"宸ュ簭鑳借�楃粺璁�"}) +public class YearProcessEnergyController extends BaseController { + + @Autowired + private IModelNodeService modelNodeService; + + @Autowired + private IYearProcessEnergyService yearProcessEnergyService; + + @GetMapping("/list") + @ApiOperation(value = "宸ュ簭鑳借�楃粺璁★紙骞达級鍒楄〃") + private AjaxResult list(DataItemQueryDTO dataItem) throws ParseException{ + List<ModelNode> nodeId = modelNodeService.getModelNodeByModelCode(dataItem.getIndexCode()); + if(CollectionUtils.isEmpty(nodeId)){ + return success(new ArrayList<>()); + } + List<EnergyIndex> energyList = modelNodeService.getSettingIndex(nodeId.get(0).getNodeId()); + if(CollectionUtils.isEmpty(energyList)){ + return success(new ArrayList<>()); + } + List<String> indexIds = energyList.stream().map(EnergyIndex::getIndexId).collect(Collectors.toList()); + + Date convertTime = DateTimeUtil.getTypeTime(dataItem.getTimeType(), dataItem.getDataTime()); + DateTime beginTime = DateUtil.beginOfYear(convertTime); + DateTime endTime = DateUtil.endOfYear(convertTime); + + List<TypeTime> typeTimeList = DateTimeUtil.getDateTimeList(dataItem.getTimeType(),convertTime); + + List<YearProcessEnergy> list = yearProcessEnergyService.getYearProcessEnergy(indexIds, typeTimeList,beginTime,endTime, dataItem.getTimeType(),dataItem.getEnergyType()); + return success(list); + } + + @GetMapping("/listChart") + @ApiOperation(value = "宸ュ簭鑳借�楋紙骞达級鍥捐〃") + public AjaxResult listChart(DataItemQueryDTO queryDto) { + List<YearProcessEnergy> list = yearProcessEnergyService.getListChart(queryDto); + return AjaxResult.success(list); + } +} diff --git a/zhitan-common/src/main/java/com/zhitan/common/utils/DateTimeUtil.java b/zhitan-common/src/main/java/com/zhitan/common/utils/DateTimeUtil.java index 48091c1..c359f6a 100644 --- a/zhitan-common/src/main/java/com/zhitan/common/utils/DateTimeUtil.java +++ b/zhitan-common/src/main/java/com/zhitan/common/utils/DateTimeUtil.java @@ -11,6 +11,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; + /** * @Description: 鏃堕棿宸ュ叿绫� * @author: yxw @@ -639,6 +640,35 @@ } /** + * 鏍规嵁鏃堕棿绫诲瀷鎶婂瓧绗︿覆杞垚瀵瑰簲鐨勬椂闂� + * timeType="HOUR",time="2025-02-01"锛岃繑鍥�"2025-02-01 01:00:00" + * timeType="DAY",time="2025-02"锛岃繑鍥�"2025-02-01 01:00:00" + * timeType="MONTH",time="2025"锛岃繑鍥�"2025-02-01 01:00:00" + * + * @param timeType 鏃堕棿绫诲瀷 + * @param time 鏃堕棿瀛楃涓� + * @return + */ + public static Date getTypeTime(String timeType, String time) { + Date dt = null; + timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); + switch (timeType) { + case TimeTypeConst.TIME_TYPE_HOUR: + dt = toDateTime(time, COMMON_PATTERN_TO_DAY); + break; + case TimeTypeConst.TIME_TYPE_DAY: + dt = toDateTime(time, COMMON_PATTERN_TO_MONTH); + break; + case TimeTypeConst.TIME_TYPE_MONTH: + dt = toDateTime(time, COMMON_PATTERN_YEAR); + break; + default: + break; + } + return dt; + } + + /** * 鏍规嵁鏃堕棿绫诲瀷鎶婅繛缁殑鏃ユ湡瀛楃涓茶浆鎴愬搴旂殑鏃堕棿 锛�202303銆�20230303銆�2023030301銆�202303030101锛� * * @param timeType 鏃堕棿绫诲瀷 @@ -702,7 +732,7 @@ * @param val 璁$畻鍊� * @return */ - public static Date productionCycleCal(Date date, String cycleType,int val) { + public static Date productionCycleCal(Date date, String cycleType, int val) { Date momDate = date; switch (cycleType) { case TimeTypeConst.TIME_TYPE_HOUR: @@ -742,42 +772,74 @@ } return momDate; } - public static List<TypeTime> getDateTimeList(String timeType,Date dataTime){ - List<TypeTime> resultlist = new ArrayList<>(); + + /** + * 閫氳繃鏃堕棿绫诲瀷杩斿洖瀵瑰簲鐨勬椂闂磍ist + * <p> + * 鍙傛暟锛� + * timeType="YEAR",dataTime="2025-01-01 00:00:00" + * timeType="MONTH",dataTime="2025-01-01 00:00:00" + * timeType="DAY",dataTime="2025-01-01 00:00:00" + * 杩斿洖鏍煎紡锛� + * [ + * {"datatime":"2025-01-01 00:00:00","value":"value1"}, + * {"datatime":"2025-02-01 00:00:00","value":"value2"}, + * {"datatime":"2025-03-01 00:00:00","value":"value3"}, + * {"datatime":"2025-04-01 00:00:00","value":"value4"}, + * {"datatime":"2025-05-01 00:00:00","value":"value5"}, + * {"datatime":"2025-06-01 00:00:00","value":"value6"}, + * {"datatime":"2025-07-01 00:00:00","value":"value7"}, + * {"datatime":"2025-08-01 00:00:00","value":"value8"}, + * {"datatime":"2025-09-01 00:00:00","value":"value9"}, + * {"datatime":"2025-10-01 00:00:00","value":"value10"}, + * {"datatime":"2025-11-01 00:00:00","value":"value11"}, + * {"datatime":"2025-12-01 00:00:00","value":"value12"} + * ] + * + * @param timeType + * @param dataTime + * @return + */ + public static List<TypeTime> getDateTimeList(String timeType, Date dataTime) { + + List<TypeTime> resultList = new ArrayList<>(); + Date beginTime = DateUtil.beginOfDay(dataTime); - switch (timeType){ - case TimeTypeConst.TIME_TYPE_DAY: - for(int i = 0;i<24;i++){ + switch (timeType) { + case TimeTypeConst.TIME_TYPE_HOUR: + for (int i = 1; i <= 24; i++) { TypeTime typeTime = new TypeTime(); - typeTime.setDataTime(DateUtil.format(beginTime,COMMON_PATTERN)); - typeTime.setDateTime(DateTimeUtil.toDateTime(typeTime.getDataTime())); - typeTime.setTimeCode(CommonConst.WORD_H + DateUtil.format(beginTime,COMMON_PATTERN_HOUR)); + typeTime.setDataTime(DateUtil.format(beginTime, COMMON_PATTERN)); + typeTime.setTimeCode(CommonConst.WORD_H + DateUtil.format(beginTime, COMMON_PATTERN_HOUR)); + typeTime.setDateTime(beginTime); typeTime.setValue("value" + i); - resultlist.add(typeTime); - beginTime = addHours(beginTime,1); + resultList.add(typeTime); + beginTime = addHours(beginTime, 1); + } + break; + case TimeTypeConst.TIME_TYPE_DAY: + for (int i = 1; i <= 31; i++) { + TypeTime typeTime = new TypeTime(); + typeTime.setDataTime(DateUtil.format(beginTime, COMMON_PATTERN)); + typeTime.setTimeCode(CommonConst.WORD_D + DateUtil.format(beginTime, COMMON_PATTERN_DAY)); + typeTime.setDateTime(beginTime); + typeTime.setValue("value" + i); + resultList.add(typeTime); + beginTime = addDays(beginTime, 1); } break; case TimeTypeConst.TIME_TYPE_MONTH: - for(int i = 0;i<31;i++){ + for (int i = 1; i <= 12; i++) { TypeTime typeTime = new TypeTime(); - typeTime.setDataTime(DateUtil.format(beginTime,COMMON_PATTERN)); - typeTime.setTimeCode(CommonConst.WORD_D + DateUtil.format(beginTime,COMMON_PATTERN_DAY)); + typeTime.setDataTime(DateUtil.format(beginTime, COMMON_PATTERN)); + typeTime.setTimeCode(CommonConst.WORD_M + DateUtil.format(beginTime, COMMON_PATTERN_MONTH)); + typeTime.setDateTime(beginTime); typeTime.setValue("value" + i); - resultlist.add(typeTime); - beginTime = addHours(beginTime,1); - } - break; - case TimeTypeConst.TIME_TYPE_YEAR: - for(int i = 0;i<12;i++){ - TypeTime typeTime = new TypeTime(); - typeTime.setDataTime(DateUtil.format(beginTime,COMMON_PATTERN)); - typeTime.setTimeCode(CommonConst.WORD_M + DateUtil.format(beginTime,COMMON_PATTERN_MONTH)); - typeTime.setValue("value" + i); - resultlist.add(typeTime); - beginTime = addHours(beginTime,1); + resultList.add(typeTime); + beginTime = addMonths(beginTime, 1); } break; } - return resultlist; - } + return resultList; + } } diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/domain/DailyProcessEnergy.java b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/DailyProcessEnergy.java new file mode 100644 index 0000000..5899f2a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/DailyProcessEnergy.java @@ -0,0 +1,74 @@ +package com.zhitan.processenergy.domain; + +import com.zhitan.common.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + * @date 2021-01-11 + */ +@Data +public class DailyProcessEnergy 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 timeCode; + 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 = "0鏃�") + private Double value0; +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/domain/MonthlyProcessEnergy.java b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/MonthlyProcessEnergy.java new file mode 100644 index 0000000..4cfff4c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/MonthlyProcessEnergy.java @@ -0,0 +1,427 @@ +package com.zhitan.processenergy.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 2021-01-11 + */ +public class MonthlyProcessEnergy 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 timeCode; + @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 Integer count; + private String unitId; + /** 鎬昏褰曟暟 */ + private long total; + private List<Map> tablehead =new ArrayList<>(); + private List<MonthlyProcessEnergy> tabledata =new ArrayList<MonthlyProcessEnergy>(); + 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 getTimeCode() { + return timeCode; + } + + public void setTimeCode(String timeCode) { + this.timeCode = timeCode; + } + + 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<MonthlyProcessEnergy> getTabledata() { + return tabledata; + } + + public void setTabledata(List<MonthlyProcessEnergy> tabledata) { + this.tabledata = tabledata; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/domain/YearProcessEnergy.java b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/YearProcessEnergy.java new file mode 100644 index 0000000..e48f5ac --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/domain/YearProcessEnergy.java @@ -0,0 +1,237 @@ +package com.zhitan.processenergy.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 2021-01-11 + */ +public class YearProcessEnergy 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 timeCode; + @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 Integer count; + private String unitId; + /** 鎬昏褰曟暟 */ + private long total; + private List<Map> tablehead =new ArrayList<>(); + private List<YearProcessEnergy> tabledata =new ArrayList<YearProcessEnergy>(); + 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 getTimeCode() { + return timeCode; + } + + public void setTimeCode(String timeCode) { + this.timeCode = timeCode; + } + + 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 List<Map> getTablehead() { + return tablehead; + } + + public void setTablehead(List<Map> tablehead) { + this.tablehead = tablehead; + } + public List<YearProcessEnergy> getTabledata() { + return tabledata; + } + + public void setTabledata(List<YearProcessEnergy> tabledata) { + this.tabledata = tabledata; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/dto/DataItemQueryDTO.java b/zhitan-system/src/main/java/com/zhitan/processenergy/dto/DataItemQueryDTO.java new file mode 100644 index 0000000..b9a69c7 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/dto/DataItemQueryDTO.java @@ -0,0 +1,28 @@ +package com.zhitan.processenergy.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍛ㄦ湡鏁版嵁椤�. + */ +@Data +public class DataItemQueryDTO { + + + @ApiModelProperty(value = "鎸囨爣id") + private String indexId; + + @ApiModelProperty(value = "妯″瀷code") + private String indexCode; + + @ApiModelProperty(value = "鏃堕棿瀛楃涓�") + private String dataTime; + + @ApiModelProperty(value = "鏃堕棿绫诲瀷") + private String timeType; + + @ApiModelProperty(value = "鑳芥簮绫诲瀷") + private String energyType; + +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/DailyProcessEnergyMapper.java b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/DailyProcessEnergyMapper.java new file mode 100644 index 0000000..0c3af6f --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/DailyProcessEnergyMapper.java @@ -0,0 +1,48 @@ +package com.zhitan.processenergy.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.processenergy.domain.DailyProcessEnergy; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + */ +public interface DailyProcessEnergyMapper extends BaseMapper<DailyProcessEnergy> { + + /** + * + * @param indexIds + * @param dataList + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<DailyProcessEnergy> getDailyProcessEnergyList(@Param("indexIds") List<String> indexIds, + @Param("dataList") List<DailyProcessEnergy> dataList, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType, + @Param("indexStorageId") String indexStorageId); + + /** + * + * @param indexId + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<DailyProcessEnergy> getListChart(@Param("indexId") String indexId, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType, + @Param("indexStorageId") String indexStorageId); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/MonthlyProcessEnergyMapper.java b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/MonthlyProcessEnergyMapper.java new file mode 100644 index 0000000..2447aa7 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/MonthlyProcessEnergyMapper.java @@ -0,0 +1,47 @@ +package com.zhitan.processenergy.mapper; + +import com.zhitan.processenergy.domain.MonthlyProcessEnergy; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + */ +public interface MonthlyProcessEnergyMapper { + + /** + * + * @param indexIds + * @param dataList + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<MonthlyProcessEnergy> getMonthlyProcessEnergy(@Param("indexIds") List<String> indexIds, + @Param("dataList") List<MonthlyProcessEnergy> dataList, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType, + @Param("indexStorageId") String indexStorageId); + + /** + * + * @param indexId + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<MonthlyProcessEnergy> getListChart(@Param("indexId") String indexId, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType, + @Param("indexStorageId") String indexStorageId); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/YearProcessEnergyMapper.java b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/YearProcessEnergyMapper.java new file mode 100644 index 0000000..7bd7292 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/mapper/YearProcessEnergyMapper.java @@ -0,0 +1,46 @@ +package com.zhitan.processenergy.mapper; + +import com.zhitan.common.utils.TypeTime; +import com.zhitan.processenergy.domain.YearProcessEnergy; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + */ +public interface YearProcessEnergyMapper { + + /** + * + * @param indexIds + * @param dataList + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<YearProcessEnergy> getYearProcessEnergy(@Param("indexIds") List<String> indexIds, + @Param("dataList") List<TypeTime> dataList, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType, + @Param("indexStorageId") String indexStorageId); + + /** + * + * @param indexId + * @param beginTime + * @param endTime + * @param timeType + * @return + */ + List<YearProcessEnergy> getListChart(@Param("indexId") String indexId, + @Param("beginTime") Date beginTime, + @Param("endTime") Date endTime, + @Param("timeType") String timeType); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/IDailyProcessEnergyService.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IDailyProcessEnergyService.java new file mode 100644 index 0000000..3164ded --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IDailyProcessEnergyService.java @@ -0,0 +1,38 @@ +package com.zhitan.processenergy.service; + +import com.zhitan.processenergy.domain.DailyProcessEnergy; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + * @date 2021-01-11 + */ +public interface IDailyProcessEnergyService { + + /** + * + * @param indexIds + * @param dataList + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<DailyProcessEnergy> getDailyProcessEnergyList(List<String> indexIds, List<DailyProcessEnergy> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId); + + /** + * + * @param indexId + * @param beginTime + * @param endTime + * @param timeType + * @param indexStorageId + * @return + */ + List<DailyProcessEnergy> getListChart(String indexId, Date beginTime, Date endTime, String timeType, String indexStorageId); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/IMonthlyProcessEnergyService.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IMonthlyProcessEnergyService.java new file mode 100644 index 0000000..a05ed47 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IMonthlyProcessEnergyService.java @@ -0,0 +1,19 @@ +package com.zhitan.processenergy.service; + +import com.zhitan.common.enums.TimeType; +import com.zhitan.processenergy.domain.MonthlyProcessEnergy; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + * @date 2021-01-11 + */ +public interface IMonthlyProcessEnergyService { + public List<MonthlyProcessEnergy> getMonthlyProcessEnergy(List<String> indexIds, List<MonthlyProcessEnergy> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId); + + List<MonthlyProcessEnergy> getListChart(String indexId, Date beginTime, Date endTime, String timeType, String indexStorageId); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/IYearProcessEnergyService.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IYearProcessEnergyService.java new file mode 100644 index 0000000..0c8baac --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/IYearProcessEnergyService.java @@ -0,0 +1,26 @@ +package com.zhitan.processenergy.service; + +import com.zhitan.common.utils.TypeTime; +import com.zhitan.processenergy.domain.YearProcessEnergy; +import com.zhitan.realtimedata.domain.dto.DataItemQueryDTO; + +import java.util.Date; +import java.util.List; + +/** + *宸ュ簭鑳借�� 鏃� + * + * @author sys + * @date 2021-01-11 + */ +public interface IYearProcessEnergyService { + + List<YearProcessEnergy> getYearProcessEnergy(List<String> indexIds, List<TypeTime> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId); + + /** + * + * @param queryDto + * @return + */ + List<YearProcessEnergy> getListChart(DataItemQueryDTO queryDto); +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/DailyProcessEnergyServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/DailyProcessEnergyServiceImpl.java new file mode 100644 index 0000000..e4ee415 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/DailyProcessEnergyServiceImpl.java @@ -0,0 +1,39 @@ +package com.zhitan.processenergy.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhitan.processenergy.domain.DailyProcessEnergy; +import com.zhitan.processenergy.mapper.DailyProcessEnergyMapper; +import com.zhitan.processenergy.service.IDailyProcessEnergyService; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.Date; +import java.util.List; + + +/** + *閲嶇偣璁惧鑳借�楃粺璁� 鏃� + * + * @author sys + * @date 2021-01-11 + */ +@Service +public class DailyProcessEnergyServiceImpl extends ServiceImpl<DailyProcessEnergyMapper,DailyProcessEnergy> implements IDailyProcessEnergyService { + + + @Override + public List<DailyProcessEnergy> getDailyProcessEnergyList(List<String> indexIds, List<DailyProcessEnergy> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId){ + if (indexIds != null && !indexIds.isEmpty()){ + return baseMapper.getDailyProcessEnergyList(indexIds, dataList, beginTime, endTime, timeType, indexStorageId); + } + return Collections.emptyList(); + } + + @Override + public List<DailyProcessEnergy> getListChart(String indexId, Date beginTime, Date endTime, String timeType, String indexStorageId){ + if (indexId != null && !indexId.isEmpty()) { + return baseMapper.getListChart(indexId,beginTime,endTime,timeType,indexStorageId); + } + return Collections.emptyList(); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/MonthlyProcessEnergyServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/MonthlyProcessEnergyServiceImpl.java new file mode 100644 index 0000000..8016462 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/MonthlyProcessEnergyServiceImpl.java @@ -0,0 +1,43 @@ +package com.zhitan.processenergy.service.impl; + +import com.zhitan.common.enums.TimeType; +import com.zhitan.processenergy.domain.MonthlyProcessEnergy; +import com.zhitan.processenergy.mapper.MonthlyProcessEnergyMapper; +import com.zhitan.processenergy.service.IMonthlyProcessEnergyService; +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 2021-01-11 + */ +@Service +public class MonthlyProcessEnergyServiceImpl implements IMonthlyProcessEnergyService { + + @Resource + private MonthlyProcessEnergyMapper monthlyProcessEnergyMapper; + + @Override + public List<MonthlyProcessEnergy> getMonthlyProcessEnergy(List<String> indexIds, List<MonthlyProcessEnergy> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId){ + if (indexIds != null && !indexIds.isEmpty()){ + return monthlyProcessEnergyMapper.getMonthlyProcessEnergy(indexIds, dataList, beginTime, endTime, timeType, indexStorageId); + } + return Collections.emptyList(); + } + + @Override + public List<MonthlyProcessEnergy> getListChart(String indexId, Date beginTime, Date endTime, String timeType, String indexStorageId){ + if (indexId != null && !indexId.isEmpty()) { + return monthlyProcessEnergyMapper.getListChart(indexId,beginTime,endTime,timeType,indexStorageId); + } + return Collections.emptyList(); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/YearProcessEnergyServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/YearProcessEnergyServiceImpl.java new file mode 100644 index 0000000..4f992b0 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/processenergy/service/impl/YearProcessEnergyServiceImpl.java @@ -0,0 +1,59 @@ +package com.zhitan.processenergy.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.zhitan.common.utils.DateTimeUtil; +import com.zhitan.common.utils.TypeTime; +import com.zhitan.processenergy.domain.YearProcessEnergy; +import com.zhitan.processenergy.mapper.YearProcessEnergyMapper; +import com.zhitan.processenergy.service.IYearProcessEnergyService; +import com.zhitan.realtimedata.domain.dto.DataItemQueryDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.annotation.Resources; +import java.util.Collections; +import java.util.Date; +import java.util.List; + + +/** + *閲嶇偣璁惧鑳借�楃粺璁� 骞� + * + * @author sys + * @date 2021-01-11 + */ +@Service +public class YearProcessEnergyServiceImpl implements IYearProcessEnergyService { + + @Resource + private YearProcessEnergyMapper yearProcessEnergyMapper; + + @Override + public List<YearProcessEnergy> getYearProcessEnergy(List<String> indexIds, List<TypeTime> dataList, Date beginTime, Date endTime, String timeType, String indexStorageId){ + if (indexIds != null && !indexIds.isEmpty()) { + return yearProcessEnergyMapper.getYearProcessEnergy(indexIds, dataList, beginTime, endTime, timeType, indexStorageId); + } + return Collections.emptyList(); + } + + /** + * + * @param queryDto + * @return + */ + @Override + public List<YearProcessEnergy> getListChart(DataItemQueryDTO queryDto) { + + if(ObjectUtil.isEmpty(queryDto.getIndexId())) { + return Collections.emptyList(); + } + + Date convertTime = DateTimeUtil.getTypeTime(queryDto.getTimeType(), queryDto.getDataTime()); + DateTime beginTime = DateUtil.beginOfYear(convertTime); + DateTime endTime = DateUtil.endOfYear(convertTime); + return yearProcessEnergyMapper.getListChart(queryDto.getIndexId(),beginTime,endTime,queryDto.getTimeType()); + } +} diff --git a/zhitan-system/src/main/resources/mapper/dailyprocessenergy/DailyProcessEnergyMapper.xml b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/DailyProcessEnergyMapper.xml new file mode 100644 index 0000000..4c64306 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/DailyProcessEnergyMapper.xml @@ -0,0 +1,87 @@ +<?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.processenergy.mapper.DailyProcessEnergyMapper"> + <resultMap id="dataItemMap" type="com.zhitan.processenergy.domain.DailyProcessEnergy"> + <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="value0" property="value0"/> + </resultMap> + <select id="getDailyProcessEnergyList" resultMap="dataItemMap"> + SELECT + aa.index_id, + aa.index_name, + <foreach item="item" index="index" collection="dataList"> + MAX ( CASE WHEN data_time = #{item.dataTime} THEN "value" END ) AS ${item.value}, + </foreach> + aa.time_type + FROM + ( + SELECT + ci.index_id, + ci.NAME AS "index_name", + di."value", + di.data_time, + di.time_type + FROM + data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id + LEFT JOIN facility_archives f ON f."id"=ci.equipment + WHERE + di.data_time >= #{beginTime} + AND di.data_time < #{endTime} + AND di.index_id IN <foreach item="indexId" index="index" collection="indexIds" open="(" separator="," close=")">#{indexId} </foreach> + AND di.time_type = #{timeType} + <if test="indexStorageId !='' and indexStorageId !=null"> + and ci.equipment=#{indexStorageId} + </if> + ) aa + GROUP BY + aa.index_id,aa.index_name,aa.time_type + </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.data_time + </select> +</mapper> diff --git a/zhitan-system/src/main/resources/mapper/dailyprocessenergy/MonthlyProcessEnergyMapper.xml b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/MonthlyProcessEnergyMapper.xml new file mode 100644 index 0000000..91e3016 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/MonthlyProcessEnergyMapper.xml @@ -0,0 +1,95 @@ +<?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.processenergy.mapper.MonthlyProcessEnergyMapper"> + <resultMap id="dataItemMap" type="com.zhitan.processenergy.domain.MonthlyProcessEnergy"> + <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="getMonthlyProcessEnergy" resultMap="dataItemMap"> + SELECT + aa.index_id, + aa.index_name, + <foreach item="item" index="index" collection="dataList"> + MAX ( CASE WHEN data_time = #{item.dataTime} THEN "value" END ) AS ${item.value}, + </foreach> + aa.time_type + FROM + ( + SELECT + ci.index_id, + ci.NAME AS "index_name", + di."value", + di.data_time, + di.time_type + FROM + data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id + LEFT JOIN facility_archives f ON f."id"=ci.equipment + WHERE + di.data_time >= #{beginTime} + AND di.data_time < #{endTime} + AND di.index_id IN <foreach item="indexId" index="index" collection="indexIds" open="(" separator="," close=")">#{indexId} </foreach> + AND di.time_type = #{timeType} + <if test="indexStorageId !='' and indexStorageId !=null"> + and ci.equipment=#{indexStorageId} + </if> + ) aa + GROUP BY + aa.index_id,aa.index_name,aa.time_type + </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 >= #{beginTime} + AND di.data_time < #{endTime} + AND di.time_type = #{timeType} + order by di.data_time + </select> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/dailyprocessenergy/YearProcessEnergyMapper.xml b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/YearProcessEnergyMapper.xml new file mode 100644 index 0000000..d94512b --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/dailyprocessenergy/YearProcessEnergyMapper.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.processenergy.mapper.YearProcessEnergyMapper"> + <resultMap id="dataItemMap" type="com.zhitan.processenergy.domain.YearProcessEnergy"> + <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="getYearProcessEnergy" resultMap="dataItemMap"> + SELECT + aa.index_id, + aa.index_name, + <foreach item="item" index="index" collection="dataList"> + MAX ( CASE WHEN data_time = #{item.dateTime} THEN "value" END ) AS ${item.value}, + </foreach> + aa.time_type + FROM + ( + SELECT + ci.index_id, + ci.NAME AS "index_name", + di."value", + di.data_time, + di.time_type + FROM + data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id + LEFT JOIN facility_archives f ON f."id"=ci.equipment + WHERE + di.data_time >= #{beginTime} + AND di.data_time < #{endTime} + AND di.index_id IN <foreach item="indexId" index="index" collection="indexIds" open="(" separator="," close=")">#{indexId} </foreach> + AND di.time_type = #{timeType} + <if test="indexStorageId !='' and indexStorageId !=null"> + and ci.equipment=#{indexStorageId} + </if> + ) aa + GROUP BY + aa.index_id,aa.index_name,aa.time_type + </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.time_type = #{timeType} + <if test="endTime != null"> + AND di.data_time < #{endTime} + </if> + <if test="beginTime != null"> + AND di.data_time >= #{beginTime} + </if> + order by di.data_time + </select> + +</mapper> \ No newline at end of file -- Gitblit v1.9.3