|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.modules.baseSpace.entity.Space;
|
|
import org.jeecg.modules.baseSpace.entity.Space;
|
|
|
|
+import org.jeecg.modules.baseSpace.entity.SpaceDto;
|
|
|
|
+import org.jeecg.modules.baseSpace.mapper.SpaceMapper;
|
|
import org.jeecg.modules.baseSpace.service.ISpaceService;
|
|
import org.jeecg.modules.baseSpace.service.ISpaceService;
|
|
import org.jeecg.modules.dataCurrent.entity.DataCurrent;
|
|
import org.jeecg.modules.dataCurrent.entity.DataCurrent;
|
|
import org.jeecg.modules.dataCurrent.mapper.DataCurrentMapper;
|
|
import org.jeecg.modules.dataCurrent.mapper.DataCurrentMapper;
|
|
@@ -18,6 +20,7 @@ import org.jeecg.modules.elecfeeBase.mapper.ElecfeeBaseMapper;
|
|
import org.jeecg.modules.emsStatistics.entity.EmsStatistics;
|
|
import org.jeecg.modules.emsStatistics.entity.EmsStatistics;
|
|
import org.jeecg.modules.emsStatistics.mapper.EmsStatisticsMapper;
|
|
import org.jeecg.modules.emsStatistics.mapper.EmsStatisticsMapper;
|
|
import org.jeecg.modules.emsStatistics.service.IEmsStatisticsService;
|
|
import org.jeecg.modules.emsStatistics.service.IEmsStatisticsService;
|
|
|
|
+import org.jeecg.modules.energyItem.entity.EnergyItem;
|
|
import org.jeecg.modules.energyItem.mapper.EnergyItemMapper;
|
|
import org.jeecg.modules.energyItem.mapper.EnergyItemMapper;
|
|
import org.jeecg.modules.equipmentStatus.entity.EquipmentStatus;
|
|
import org.jeecg.modules.equipmentStatus.entity.EquipmentStatus;
|
|
import org.jeecg.modules.equipmentStatus.mapper.EquipmentStatusMapper;
|
|
import org.jeecg.modules.equipmentStatus.mapper.EquipmentStatusMapper;
|
|
@@ -27,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
|
+import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.temporal.IsoFields;
|
|
import java.time.temporal.IsoFields;
|
|
@@ -65,6 +69,9 @@ public class EmsStatisticsServiceImpl implements IEmsStatisticsService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private EquipmentStatusMapper equipmentStatusMapper;
|
|
private EquipmentStatusMapper equipmentStatusMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SpaceMapper spaceMapper;
|
|
/**
|
|
/**
|
|
* 能耗总览
|
|
* 能耗总览
|
|
*
|
|
*
|
|
@@ -328,8 +335,101 @@ public class EmsStatisticsServiceImpl implements IEmsStatisticsService {
|
|
* @param yearMonth 年月
|
|
* @param yearMonth 年月
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result<Object> savingAnalysis(String spaceId, String yearMonth) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public Result<Object> savingAnalysis(String spaceId, String yearMonth) throws ParseException {
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ LambdaQueryWrapper<TpmEquipment> eq = new LambdaQueryWrapper<TpmEquipment>()
|
|
|
|
+ .eq(TpmEquipment::getSpaceid, spaceId)
|
|
|
|
+ .select(TpmEquipment::getId);
|
|
|
|
+ List<TpmEquipment> equipments = equipmentMapper.selectList(eq);
|
|
|
|
+ List<String> equipmentids = new ArrayList<>();
|
|
|
|
+ if (equipments != null && !equipments.isEmpty()) {
|
|
|
|
+ equipmentids = equipments.stream().map(TpmEquipment::getId).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ System.out.println(equipmentids);
|
|
|
|
+ // 区域基本信息
|
|
|
|
+ SpaceDto energySpace = spaceMapper.selectSpaceById(spaceId);
|
|
|
|
+ // 当前日期
|
|
|
|
+ Date currentdate = DateUtils.parseDate(DateUtils.parseDateToStr("yyyy-MM-dd", new Date()), "yyyy-MM-dd");
|
|
|
|
+
|
|
|
|
+ // 获取年月的最后一天
|
|
|
|
+ String thisdate = DateUtils.getLastDay(yearMonth.substring(0,4), yearMonth.substring(5));
|
|
|
|
+ Integer lastday = Integer.parseInt(thisdate.substring(8));
|
|
|
|
+
|
|
|
|
+ // 循环获取相关信息,进行数据分析、节能分析趋势
|
|
|
|
+ List<Integer> monthDate = new ArrayList<>();
|
|
|
|
+ List<Float> jienengData = new ArrayList<>();
|
|
|
|
+ List<Float> chaobiaoData = new ArrayList<>();
|
|
|
|
+ List<Float> jihuaData = new ArrayList<>();
|
|
|
|
+ List<Float> leijiData = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ float shijiAll = 0f;
|
|
|
|
+ float jihuaAll = 0f;
|
|
|
|
+ float leijiAll = 0f;
|
|
|
|
+
|
|
|
|
+ Integer jienengAmount = 0;
|
|
|
|
+
|
|
|
|
+ for (int i = 1; i <= lastday; i++) {
|
|
|
|
+ monthDate.add(i);
|
|
|
|
+ String day = i < 10 ? yearMonth + "-0" + i : yearMonth + "-" + i;
|
|
|
|
+ List<EmsStatistics> yongnengList = new ArrayList<>();
|
|
|
|
+ // 如果选择的是整个厂区、配电室的,则只需要获取配电室的几个表的信息即可
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ EmsStatistics statisticsParams1 = new EmsStatistics();
|
|
|
|
+ List<String> equip1 = new ArrayList<>();
|
|
|
|
+ equip1.add("301156882513921L");
|
|
|
|
+ yongnengList = emsStatisticsMapper.selectEnergyByDay(equip1, day);
|
|
|
|
+ }
|
|
|
|
+ else if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ // 去掉配电室的几个表
|
|
|
|
+ equipmentids.remove("301156882513921L");
|
|
|
|
+ equipmentids.remove("301156930748417L");
|
|
|
|
+ equipmentids.remove("301156947525633L");
|
|
|
|
+ equipmentids.remove("301156962205697L");
|
|
|
|
+ yongnengList = emsStatisticsMapper.selectEnergyByDay(equipmentids, day);
|
|
|
|
+ }
|
|
|
|
+ float shiji = yongnengList.get(0).getHowManyValue();
|
|
|
|
+ float jihua = yongnengList.get(1).getHowManyValue();
|
|
|
|
+
|
|
|
|
+ // 实际用能、计划用能、累计节能
|
|
|
|
+ shijiAll += shiji;
|
|
|
|
+ jihuaAll += jihua;
|
|
|
|
+ if (currentdate.after(DateUtils.parseDate(day, "yyyy-MM-dd"))) {
|
|
|
|
+ leijiAll += jihua - shiji;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (shiji > jihua) {
|
|
|
|
+ // 实际能耗(超标)
|
|
|
|
+ chaobiaoData.add(shiji);
|
|
|
|
+ jienengData.add(0f);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // 实际能耗(节能)
|
|
|
|
+ jienengAmount++;
|
|
|
|
+ chaobiaoData.add(0f);
|
|
|
|
+ jienengData.add(shiji);
|
|
|
|
+ }
|
|
|
|
+// // 计划用能
|
|
|
|
+ jihuaData.add(jihua);
|
|
|
|
+ // 累计节能
|
|
|
|
+ leijiData.add(leijiAll);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ map.put("monthDate", monthDate);
|
|
|
|
+
|
|
|
|
+ map.put("shijiAll", shijiAll);
|
|
|
|
+ map.put("jihuaAll", jihuaAll);
|
|
|
|
+ map.put("leijiAll", leijiAll);
|
|
|
|
+
|
|
|
|
+ map.put("jienengData", jienengData);
|
|
|
|
+ map.put("chaobiaoData", chaobiaoData);
|
|
|
|
+ map.put("jihuaData", jihuaData);
|
|
|
|
+ map.put("leijiData", leijiData);
|
|
|
|
+
|
|
|
|
+ map.put("anlysis", "节能趋势:与计划能耗相比,有 " + jienengAmount + "个 周期为节能状态,有 " + (lastday - jienengAmount) +
|
|
|
|
+ "个 周期为耗能状态,与计划耗能相差 " + leijiAll + " kWh,整体状态为 " +
|
|
|
|
+ (leijiAll > 0 ? "节能" : "耗能"));
|
|
|
|
+
|
|
|
|
+ return Result.OK(map);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -342,7 +442,77 @@ public class EmsStatisticsServiceImpl implements IEmsStatisticsService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result<Object> ranking(String spaceId, String beginTime, String endTime) {
|
|
public Result<Object> ranking(String spaceId, String beginTime, String endTime) {
|
|
- return null;
|
|
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ LambdaQueryWrapper<TpmEquipment> eq = new LambdaQueryWrapper<TpmEquipment>()
|
|
|
|
+ .eq(TpmEquipment::getSpaceid, spaceId)
|
|
|
|
+ .select(TpmEquipment::getId);
|
|
|
|
+ List<TpmEquipment> equipments = equipmentMapper.selectList(eq);
|
|
|
|
+ List<String> equipmentids = new ArrayList<>();
|
|
|
|
+ if (equipments != null && !equipments.isEmpty()) {
|
|
|
|
+ equipmentids = equipments.stream().map(TpmEquipment::getId).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ System.out.println(equipmentids);
|
|
|
|
+ // 区域基本信息
|
|
|
|
+ SpaceDto energySpace = spaceMapper.selectSpaceById(spaceId);
|
|
|
|
+
|
|
|
|
+ // 获取今年能耗
|
|
|
|
+ List<EmsStatistics> thisYearList = new ArrayList<>();
|
|
|
|
+ // 如果选择的是整个厂区、配电室的,则只需要获取配电室的几个表的信息即可
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum())) {
|
|
|
|
+ // 加上配电室的几个表
|
|
|
|
+ equipmentids.remove("301156882513921L");
|
|
|
|
+ equipmentids.remove("301156930748417L");
|
|
|
|
+ equipmentids.remove("301156947525633L");
|
|
|
|
+ equipmentids.remove("301156962205697L");
|
|
|
|
+ }
|
|
|
|
+ else if ("AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ equipmentids = new ArrayList<>();
|
|
|
|
+ // 去掉配电室的几个表
|
|
|
|
+ equipmentids.add("301156882513921L");
|
|
|
|
+ equipmentids.add("301156930748417L");
|
|
|
|
+ equipmentids.add("301156947525633L");
|
|
|
|
+ equipmentids.add("301156962205697L");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ thisYearList = emsStatisticsMapper.selectRankByEquipmentAndYearmonth(equipmentids, beginTime, endTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> equipnames = new ArrayList<>(); // 名称
|
|
|
|
+ List<Float> equipelecs = new ArrayList<>(); // 能耗
|
|
|
|
+ if (thisYearList != null && thisYearList.size() > 0) {
|
|
|
|
+ // 计算今年总能耗
|
|
|
|
+ Float allElec = (float) thisYearList.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < thisYearList.size(); i++) {
|
|
|
|
+ equipnames.add(thisYearList.get(i).getEquipmentname());
|
|
|
|
+ equipelecs.add(thisYearList.get(i).getHowManyValue());
|
|
|
|
+
|
|
|
|
+ // 获取去年能耗
|
|
|
|
+ Integer lastYear = Integer.parseInt(beginTime.substring(0, 4)) - 1;
|
|
|
|
+ String lastBeginTime = lastYear + "-" + beginTime.substring(5);
|
|
|
|
+ String lastEndTime = lastYear + "-" + endTime.substring(5);
|
|
|
|
+ Float lastElectricity = emsStatisticsMapper.selectAllElecByEquipmentAndYearmonth(thisYearList.get(i).getEquipmentid(), lastBeginTime, lastEndTime);
|
|
|
|
+ thisYearList.get(i).setHowManyValue2(lastElectricity == null ? 0f : lastElectricity);
|
|
|
|
+
|
|
|
|
+ // 计算占比
|
|
|
|
+ float otherValue = (float)Math.round((thisYearList.get(i).getHowManyValue() / allElec) * 10000) / 100f;
|
|
|
|
+ thisYearList.get(i).setOtherValue(otherValue);
|
|
|
|
+
|
|
|
|
+ // 计算同比增长率
|
|
|
|
+ float thisElectricity = thisYearList.get(i).getHowManyValue();
|
|
|
|
+ float otherValue2 = 0f;
|
|
|
|
+ if (lastElectricity != null) {
|
|
|
|
+ otherValue2 = (float) Math.round(((thisElectricity - lastElectricity) / lastElectricity) * 10000) / 100f;
|
|
|
|
+ }
|
|
|
|
+ thisYearList.get(i).setOtherValue2(otherValue2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put("yuanquName", equipnames);
|
|
|
|
+ map.put("numbers", equipelecs);
|
|
|
|
+ map.put("tableData", thisYearList);
|
|
|
|
+
|
|
|
|
+ return Result.OK(map);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -353,8 +523,218 @@ public class EmsStatisticsServiceImpl implements IEmsStatisticsService {
|
|
* @return 分析统计
|
|
* @return 分析统计
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result<Object> itemizedEnergy(String spaceId, String day) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public Result<Object> itemizedEnergy(String spaceId, String day) throws ParseException {
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ // 设置当前的时间戳
|
|
|
|
+ Date thisDay = DateUtils.parseDate(day, "yyyy-MM-dd");
|
|
|
|
+ calendar.setTime(thisDay);
|
|
|
|
+ // 设置星期一为一周开始的第一天
|
|
|
|
+ calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
|
+ // 获得当前日期所属周
|
|
|
|
+ // *********我草,这个不行,跟mysql获取到的不一致,得用下面一个,但是下面一个跟中国的周好像也不一致
|
|
|
|
+ // int week = calendar.get(Calendar.WEEK_OF_YEAR);
|
|
|
|
+ LocalDate localDate = LocalDate.parse(day);
|
|
|
|
+ int week = localDate.get (IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
|
|
|
+ // 获得当前日期所属月
|
|
|
|
+ int month = calendar.get(calendar.MONTH) + 1;
|
|
|
|
+ // 获得当前日期所属年
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
+
|
|
|
|
+ // 区域基本信息
|
|
|
|
+ SpaceDto energySpace = spaceMapper.selectSpaceById(spaceId);
|
|
|
|
+ // 设备ID
|
|
|
|
+ List<String> equipmentids = new ArrayList<>();
|
|
|
|
+ // 如果选择的是整个厂区、配电室的,则只需要获取总控表的信息即可
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ EmsStatistics statisticsParams1 = new EmsStatistics();
|
|
|
|
+ equipmentids.add("301156882513921");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ LambdaQueryWrapper<TpmEquipment> eq = new LambdaQueryWrapper<TpmEquipment>()
|
|
|
|
+ .eq(TpmEquipment::getSpaceid, spaceId)
|
|
|
|
+ .select(TpmEquipment::getId);
|
|
|
|
+ List<TpmEquipment> equipments = equipmentMapper.selectList(eq);
|
|
|
|
+ if (equipments != null && !equipments.isEmpty()) {
|
|
|
|
+ equipmentids = equipments.stream().map(TpmEquipment::getId).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ System.out.println(equipmentids);
|
|
|
|
+ // 去掉配电室的几个表
|
|
|
|
+ equipmentids.remove("301156882513921");
|
|
|
|
+ equipmentids.remove("301156930748417");
|
|
|
|
+ equipmentids.remove("301156947525633");
|
|
|
|
+ equipmentids.remove("301156962205697");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 能耗分项
|
|
|
|
+ List<String> itemList = getEnergyItem("电");
|
|
|
|
+ map.put("items", itemList);
|
|
|
|
+
|
|
|
|
+ // 当天数据
|
|
|
|
+ String lastDay = DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.addDays(thisDay, -1)); // 获取昨日
|
|
|
|
+ List<EmsStatistics> dayStatistics = new ArrayList<>();
|
|
|
|
+ List<EmsStatistics> lastDayStatistics = new ArrayList<>();
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ dayStatistics = emsStatisticsMapper.selectItemByEquipidAndDayTotal(equipmentids, day);
|
|
|
|
+ lastDayStatistics = emsStatisticsMapper.selectItemByEquipidAndDayTotal(equipmentids, lastDay);
|
|
|
|
+ }
|
|
|
|
+ else if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ dayStatistics = emsStatisticsMapper.selectItemByEquipidAndDay(equipmentids, day);
|
|
|
|
+ lastDayStatistics = emsStatisticsMapper.selectItemByEquipidAndDay(equipmentids, lastDay);
|
|
|
|
+ }
|
|
|
|
+ if (dayStatistics != null) {
|
|
|
|
+ double thisDaySum = dayStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics thisDayStatis = new EmsStatistics();
|
|
|
|
+ thisDayStatis.setType("当日用能");
|
|
|
|
+ thisDayStatis.setHowManyValue((float) thisDaySum);
|
|
|
|
+ dayStatistics.add(thisDayStatis);
|
|
|
|
+
|
|
|
|
+ double lastDaySum = lastDayStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics lastDayStatis = new EmsStatistics();
|
|
|
|
+ lastDayStatis.setType("昨日用能");
|
|
|
|
+ lastDayStatis.setHowManyValue((float) lastDaySum);
|
|
|
|
+ dayStatistics.add(lastDayStatis);
|
|
|
|
+
|
|
|
|
+ double chain = 0;
|
|
|
|
+ if (lastDaySum != 0) {
|
|
|
|
+ chain = Math.round(((thisDaySum - lastDaySum) / lastDaySum) * 10000) / 100f;
|
|
|
|
+ }
|
|
|
|
+ EmsStatistics chainStatis = new EmsStatistics();
|
|
|
|
+ chainStatis.setType("环比");
|
|
|
|
+ chainStatis.setHowManyValue((float) chain);
|
|
|
|
+ dayStatistics.add(chainStatis);
|
|
|
|
+ }
|
|
|
|
+ map.put("dayStatistics", dayStatistics);
|
|
|
|
+
|
|
|
|
+ // 当周数据
|
|
|
|
+ Date lastWeekDay = DateUtils.addWeeks(thisDay, -1);
|
|
|
|
+ calendar.setTime(lastWeekDay);
|
|
|
|
+ int lastWeekYear = calendar.get(Calendar.YEAR);
|
|
|
|
+ LocalDate localDate1 = LocalDate.parse(DateUtils.parseDateToStr("yyyy-MM-dd",lastWeekDay));
|
|
|
|
+ int lastWeek = localDate1.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
|
|
|
+
|
|
|
|
+ List<EmsStatistics> weekStatistics = new ArrayList<>();
|
|
|
|
+ List<EmsStatistics> lastWeekStatistics = new ArrayList<>();
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ weekStatistics = emsStatisticsMapper.selectItemByEquipidAndYearweekTotal(equipmentids, year, week);
|
|
|
|
+ lastWeekStatistics = emsStatisticsMapper.selectItemByEquipidAndYearweekTotal(equipmentids, lastWeekYear, lastWeek);
|
|
|
|
+ }
|
|
|
|
+ else if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ weekStatistics = emsStatisticsMapper.selectItemByEquipidAndYearweek(equipmentids, year, week);
|
|
|
|
+ lastWeekStatistics = emsStatisticsMapper.selectItemByEquipidAndYearweek(equipmentids, lastWeekYear, lastWeek);
|
|
|
|
+ }
|
|
|
|
+ if (weekStatistics != null) {
|
|
|
|
+ double thisWeekSum = weekStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics thisWeekStatis = new EmsStatistics();
|
|
|
|
+ thisWeekStatis.setType("当周用能");
|
|
|
|
+ thisWeekStatis.setHowManyValue((float) thisWeekSum);
|
|
|
|
+ weekStatistics.add(thisWeekStatis);
|
|
|
|
+
|
|
|
|
+ double lastWeekSum = lastWeekStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics lastWeekStatis = new EmsStatistics();
|
|
|
|
+ lastWeekStatis.setType("上周用能");
|
|
|
|
+ lastWeekStatis.setHowManyValue((float) lastWeekSum);
|
|
|
|
+ weekStatistics.add(lastWeekStatis);
|
|
|
|
+
|
|
|
|
+ double chain = 0;
|
|
|
|
+ if (lastWeekSum != 0) {
|
|
|
|
+ chain = Math.round(((thisWeekSum - lastWeekSum) / lastWeekSum) * 10000) / 100f;
|
|
|
|
+ }
|
|
|
|
+ EmsStatistics chainStatis = new EmsStatistics();
|
|
|
|
+ chainStatis.setType("环比");
|
|
|
|
+ chainStatis.setHowManyValue((float) chain);
|
|
|
|
+ weekStatistics.add(chainStatis);
|
|
|
|
+ }
|
|
|
|
+ map.put("weekStatistics", weekStatistics);
|
|
|
|
+
|
|
|
|
+ // 当月数据
|
|
|
|
+ Date lastMonthDay = DateUtils.addMonths(thisDay, -1);
|
|
|
|
+ calendar.setTime(lastMonthDay);
|
|
|
|
+ int lastMonth = calendar.get(calendar.MONTH) + 1;
|
|
|
|
+ int lastMonthYear = calendar.get(Calendar.YEAR);
|
|
|
|
+ List<EmsStatistics> monthStatistics = new ArrayList<>();
|
|
|
|
+ List<EmsStatistics> lastMonthStatistics = new ArrayList<>();
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ monthStatistics = emsStatisticsMapper.selectItemByEquipidAndYearmonthTotal(equipmentids, year, month);
|
|
|
|
+ lastMonthStatistics = emsStatisticsMapper.selectItemByEquipidAndYearmonthTotal(equipmentids, lastMonthYear, lastMonth);
|
|
|
|
+ }
|
|
|
|
+ else if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ monthStatistics = emsStatisticsMapper.selectItemByEquipidAndYearmonth(equipmentids, year, month);
|
|
|
|
+ lastMonthStatistics = emsStatisticsMapper.selectItemByEquipidAndYearmonth(equipmentids, lastMonthYear, lastMonth);
|
|
|
|
+ }
|
|
|
|
+ if (monthStatistics != null) {
|
|
|
|
+ double thisMonthSum = monthStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics thisMonthStatis = new EmsStatistics();
|
|
|
|
+ thisMonthStatis.setType("当月用能");
|
|
|
|
+ thisMonthStatis.setHowManyValue((float) thisMonthSum);
|
|
|
|
+ monthStatistics.add(thisMonthStatis);
|
|
|
|
+
|
|
|
|
+ double lastMonthSum = lastMonthStatistics.stream().mapToDouble(EmsStatistics::getHowManyValue).sum();
|
|
|
|
+ EmsStatistics lastMonthStatis = new EmsStatistics();
|
|
|
|
+ lastMonthStatis.setType("上月用能");
|
|
|
|
+ lastMonthStatis.setHowManyValue((float) lastMonthSum);
|
|
|
|
+ monthStatistics.add(lastMonthStatis);
|
|
|
|
+
|
|
|
|
+ double chain = 0;
|
|
|
|
+ if (lastMonthSum != 0) {
|
|
|
|
+ chain = Math.round(((thisMonthSum - lastMonthSum) / lastMonthSum) * 10000) / 100f;
|
|
|
|
+ }
|
|
|
|
+ EmsStatistics chainStatis = new EmsStatistics();
|
|
|
|
+ chainStatis.setType("环比");
|
|
|
|
+ chainStatis.setHowManyValue((float) chain);
|
|
|
|
+ monthStatistics.add(chainStatis);
|
|
|
|
+ }
|
|
|
|
+ map.put("monthStatistics", monthStatistics);
|
|
|
|
+
|
|
|
|
+ // 用能趋势
|
|
|
|
+ List<String> hours = DateUtils.getDaySplitHour();
|
|
|
|
+ map.put("hours", hours);
|
|
|
|
+
|
|
|
|
+ List<Float> dongli = new ArrayList<>();
|
|
|
|
+ List<Float> zhaoming = new ArrayList<>();
|
|
|
|
+ List<Float> kongtiao = new ArrayList<>();
|
|
|
|
+ List<Float> qita = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < hours.size(); i++) {
|
|
|
|
+ dongli.add(0f);
|
|
|
|
+ zhaoming.add(0f);
|
|
|
|
+ kongtiao.add(0f);
|
|
|
|
+ qita.add(0f);
|
|
|
|
+ List<EmsStatistics> hourStatis = new ArrayList<>();
|
|
|
|
+ // 如果选择的是整个厂区、配电室的,需要修改算法
|
|
|
|
+ if ("AREA0002".equals(energySpace.getSerialnum()) || "AREA0015".equals(energySpace.getSerialnum())) {
|
|
|
|
+ hourStatis = emsStatisticsMapper.selectItemByEquipidAndDaytimeTotal(equipmentids, day, hours.get(i) + ":00", hours.get(i).substring(0,2) + ":59:59");
|
|
|
|
+ }
|
|
|
|
+ else if (equipmentids != null && equipmentids.size() > 0) {
|
|
|
|
+ hourStatis = emsStatisticsMapper.selectItemByEquipidAndDaytime(equipmentids, day, hours.get(i) + ":00", hours.get(i).substring(0,2) + ":59:59");
|
|
|
|
+ }
|
|
|
|
+ if (hourStatis != null && hourStatis.size() > 0) {
|
|
|
|
+ for (EmsStatistics hoursta : hourStatis) {
|
|
|
|
+ switch (hoursta.getEquipmentname()) {
|
|
|
|
+ case "动力用电":
|
|
|
|
+ dongli.set(i, hoursta.getHowManyValue());
|
|
|
|
+ break;
|
|
|
|
+ case "照明用电":
|
|
|
|
+ zhaoming.set(i, hoursta.getHowManyValue());
|
|
|
|
+ break;
|
|
|
|
+ case "空调用电":
|
|
|
|
+ kongtiao.set(i, hoursta.getHowManyValue());
|
|
|
|
+ break;
|
|
|
|
+ case "其它用电":
|
|
|
|
+ qita.set(i, hoursta.getHowManyValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put("dongli", dongli);
|
|
|
|
+ map.put("zhaoming", zhaoming);
|
|
|
|
+ map.put("kongtiao", kongtiao);
|
|
|
|
+ map.put("qita", qita);
|
|
|
|
+
|
|
|
|
+ return Result.OK(map);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -487,4 +867,24 @@ public class EmsStatisticsServiceImpl implements IEmsStatisticsService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取分项
|
|
|
|
+ * @param energytypename 能源分类名称
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<String> getEnergyItem(String energytypename) {
|
|
|
|
+ List<String> rtn = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ EnergyItem energyItem = new EnergyItem();
|
|
|
|
+ energyItem.setEnergytypename(energytypename);
|
|
|
|
+ List<EnergyItem> itemList = energyItemMapper.selectEmsEnergyItemList(energyItem);
|
|
|
|
+ System.out.println(itemList);
|
|
|
|
+ if (itemList != null && itemList.size() > 0) {
|
|
|
|
+ for (int i = 0; i < itemList.size(); i++) {
|
|
|
|
+ rtn.add(itemList.get(i).getEnergyitemname());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rtn;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|