add 实时数据、车间看板-单能源实时数据与近24小时趋势接口

maser
yinq 2 months ago
parent 17c66730e1
commit 11efd452d3

@ -69,4 +69,6 @@ public interface EmsRecordAirInstantMapper
* @return * @return
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
} }

@ -16,47 +16,47 @@ import com.os.ems.report.domain.RealTimeDataBo;
public interface EmsRecordDnbInstantMapper public interface EmsRecordDnbInstantMapper
{ {
/** /**
* * 查询çµå®žææ°æ<EFBFBD>?
* *
* @param objId * @param objId çµå®žææ°æ<EFBFBD>®ä¸»é?
* @return * @return çµå®žææ°æ<EFBFBD>?
*/ */
public EmsRecordDnbInstant selectEmsRecordDnbInstantByObjId(Long objId); public EmsRecordDnbInstant selectEmsRecordDnbInstantByObjId(Long objId);
/** /**
* * 查询çµå®žææ°æ<EFBFBD>®åˆè¡?
* *
* @param emsRecordDnbInstant * @param emsRecordDnbInstant çµå®žææ°æ<EFBFBD>?
* @return * @return çµå®žææ°æ<EFBFBD>®éå<EFBFBD>?
*/ */
public List<EmsRecordDnbInstant> selectEmsRecordDnbInstantList(EmsRecordDnbInstant emsRecordDnbInstant); public List<EmsRecordDnbInstant> selectEmsRecordDnbInstantList(EmsRecordDnbInstant emsRecordDnbInstant);
/** /**
* * æ°å¢žçµå®žææ°æ<EFBFBD>?
* *
* @param emsRecordDnbInstant * @param emsRecordDnbInstant çµå®žææ°æ<EFBFBD>?
* @return * @return
*/ */
public int insertEmsRecordDnbInstant(EmsRecordDnbInstant emsRecordDnbInstant); public int insertEmsRecordDnbInstant(EmsRecordDnbInstant emsRecordDnbInstant);
/** /**
* * ä¿®æ¹çµå®žææ°æ<EFBFBD>?
* *
* @param emsRecordDnbInstant * @param emsRecordDnbInstant çµå®žææ°æ<EFBFBD>?
* @return * @return
*/ */
public int updateEmsRecordDnbInstant(EmsRecordDnbInstant emsRecordDnbInstant); public int updateEmsRecordDnbInstant(EmsRecordDnbInstant emsRecordDnbInstant);
/** /**
* * 删é¤çµå®žææ°æ<EFBFBD>?
* *
* @param objId * @param objId çµå®žææ°æ<EFBFBD>®ä¸»é?
* @return * @return
*/ */
public int deleteEmsRecordDnbInstantByObjId(Long objId); public int deleteEmsRecordDnbInstantByObjId(Long objId);
/** /**
* * æ¹é<EFBFBD>删é¤çµå®žææ°æ<EFBFBD>?
* *
* @param objIds * @param objIds
* @return * @return
@ -64,7 +64,7 @@ public interface EmsRecordDnbInstantMapper
public int deleteEmsRecordDnbInstantByObjIds(Long[] objIds); public int deleteEmsRecordDnbInstantByObjIds(Long[] objIds);
/** /**
* * 查询çµå®žææ°æ<EFBFBD>?
* @param emsRecordDnbInstant * @param emsRecordDnbInstant
* @return * @return
*/ */
@ -78,4 +78,6 @@ public interface EmsRecordDnbInstantMapper
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
} }

@ -69,4 +69,6 @@ public interface EmsRecordNitrogenInstantMapper
* @return * @return
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
} }

@ -69,4 +69,6 @@ public interface EmsRecordSteamInstantMapper {
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
} }

@ -15,47 +15,47 @@ import com.os.ems.report.domain.RealTimeDataBo;
public interface EmsRecordWaterInstantMapper public interface EmsRecordWaterInstantMapper
{ {
/** /**
* * æŸ¥è¯¢æ°´å®žææ°æ<EFBFBD>?
* *
* @param objId * @param objId æ°´å®žææ°æ<EFBFBD>®ä¸»é?
* @return * @return æ°´å®žææ°æ<EFBFBD>?
*/ */
public EmsRecordWaterInstant selectEmsRecordWaterInstantByObjId(Long objId); public EmsRecordWaterInstant selectEmsRecordWaterInstantByObjId(Long objId);
/** /**
* * æŸ¥è¯¢æ°´å®žææ°æ<EFBFBD>®åˆè¡?
* *
* @param emsRecordWaterInstant * @param emsRecordWaterInstant æ°´å®žææ°æ<EFBFBD>?
* @return * @return æ°´å®žææ°æ<EFBFBD>®éå<EFBFBD>?
*/ */
public List<EmsRecordWaterInstant> selectEmsRecordWaterInstantList(EmsRecordWaterInstant emsRecordWaterInstant); public List<EmsRecordWaterInstant> selectEmsRecordWaterInstantList(EmsRecordWaterInstant emsRecordWaterInstant);
/** /**
* * æ°å¢žæ°´å®žææ°æ<EFBFBD>?
* *
* @param emsRecordWaterInstant * @param emsRecordWaterInstant æ°´å®žææ°æ<EFBFBD>?
* @return * @return
*/ */
public int insertEmsRecordWaterInstant(EmsRecordWaterInstant emsRecordWaterInstant); public int insertEmsRecordWaterInstant(EmsRecordWaterInstant emsRecordWaterInstant);
/** /**
* * ä¿®æ¹æ°´å®žææ°æ<EFBFBD>?
* *
* @param emsRecordWaterInstant * @param emsRecordWaterInstant æ°´å®žææ°æ<EFBFBD>?
* @return * @return
*/ */
public int updateEmsRecordWaterInstant(EmsRecordWaterInstant emsRecordWaterInstant); public int updateEmsRecordWaterInstant(EmsRecordWaterInstant emsRecordWaterInstant);
/** /**
* * åˆ é¤æ°´å®žææ°æ<EFBFBD>?
* *
* @param objId * @param objId æ°´å®žææ°æ<EFBFBD>®ä¸»é?
* @return * @return
*/ */
public int deleteEmsRecordWaterInstantByObjId(Long objId); public int deleteEmsRecordWaterInstantByObjId(Long objId);
/** /**
* * æ¹é<EFBFBD>åˆ é¤æ°´å®žææ°æ<EFBFBD>?
* *
* @param objIds * @param objIds
* @return * @return
@ -70,4 +70,6 @@ public interface EmsRecordWaterInstantMapper
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
} }

@ -42,6 +42,17 @@ public class EmsBoardController extends BaseController {
return success(list); return success(list);
} }
/**
* 线
* @param hashMap
* @return
*/
@GetMapping("/realTimeDataByEnergy")
public AjaxResult realTimeDataByEnergy(@RequestParam(required = false) Map hashMap) {
List<RealTimeDataBo> list = emsBoardService.realTimeDataByEnergy(hashMap);
return success(list);
}
/** /**
* - * -
* @param hashMap * @param hashMap
@ -119,5 +130,16 @@ public class EmsBoardController extends BaseController {
return success(result); return success(result);
} }
/**
* -24
* @param hashMap
* @return
*/
@GetMapping("/workshopEnergyBoard")
public AjaxResult workshopEnergyBoard(@RequestParam(required = false) Map hashMap) {
HashMap<String, Object> result = emsBoardService.workshopEnergyBoard(hashMap);
return success(result);
}
} }

@ -71,4 +71,11 @@ public interface EmsReportMapper
* @return * @return
*/ */
List<Map<String, Object>> selectWorkshopTodayPerDevice(HashMap<String, Object> hashMap); List<Map<String, Object>> selectWorkshopTodayPerDevice(HashMap<String, Object> hashMap);
/**
* 24
* @param hashMap
* @return
*/
List<Map<String, Object>> selectWorkshop24hPerDeviceTrend(HashMap<String, Object> hashMap);
} }

@ -1,6 +1,8 @@
package com.os.ems.report.mapper; package com.os.ems.report.mapper;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointAir; import com.os.ems.report.domain.EmsReportPointAir;
/** /**
@ -58,5 +60,19 @@ public interface EmsReportPointAirMapper
* @return * @return
*/ */
public int deleteEmsReportPointAirByObjIds(Long[] objIds); public int deleteEmsReportPointAirByObjIds(Long[] objIds);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitTotalConsumption(Map hashMap);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitDateConsumption(Map hashMap);
} }

@ -1,6 +1,8 @@
package com.os.ems.report.mapper; package com.os.ems.report.mapper;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointNitrogen; import com.os.ems.report.domain.EmsReportPointNitrogen;
/** /**
@ -58,5 +60,19 @@ public interface EmsReportPointNitrogenMapper
* @return * @return
*/ */
public int deleteEmsReportPointNitrogenByObjIds(Long[] objIds); public int deleteEmsReportPointNitrogenByObjIds(Long[] objIds);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitTotalConsumption(Map hashMap);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitDateConsumption(Map hashMap);
} }

@ -1,6 +1,8 @@
package com.os.ems.report.mapper; package com.os.ems.report.mapper;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointSteam; import com.os.ems.report.domain.EmsReportPointSteam;
@ -58,4 +60,18 @@ public interface EmsReportPointSteamMapper {
* @return * @return
*/ */
public int deleteEmsReportPointSteamByObjIds(Long[] objIds); public int deleteEmsReportPointSteamByObjIds(Long[] objIds);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitTotalConsumption(Map hashMap);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitDateConsumption(Map hashMap);
} }

@ -1,6 +1,8 @@
package com.os.ems.report.mapper; package com.os.ems.report.mapper;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointWater; import com.os.ems.report.domain.EmsReportPointWater;
/** /**
@ -58,4 +60,18 @@ public interface EmsReportPointWaterMapper
* @return * @return
*/ */
public int deleteEmsReportPointWaterByObjIds(Long[] objIds); public int deleteEmsReportPointWaterByObjIds(Long[] objIds);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitTotalConsumption(Map hashMap);
/**
*
* @param hashMap
* @return
*/
List<HashMap<String, String>> selectWorkUnitDateConsumption(Map hashMap);
} }

@ -24,6 +24,13 @@ public interface IEmsBoardService {
*/ */
List<RealTimeDataBo> realTimeDataList(Map hashMap); List<RealTimeDataBo> realTimeDataList(Map hashMap);
/**
* 线
* @param hashMap
* @return
*/
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
/** /**
* - * -
* @param hashMap * @param hashMap
@ -72,4 +79,11 @@ public interface IEmsBoardService {
* @return * @return
*/ */
HashMap<String, Object> workshopColumns(Map hashMap); HashMap<String, Object> workshopColumns(Map hashMap);
/**
* -24
* @param hashMap
* @return
*/
HashMap<String, Object> workshopEnergyBoard(Map hashMap);
} }

@ -15,13 +15,20 @@ import com.os.ems.report.domain.EnergyStatisticalReport;
import com.os.ems.report.domain.PeaksValleysConsumptionReport; import com.os.ems.report.domain.PeaksValleysConsumptionReport;
import com.os.ems.report.domain.RealTimeDataBo; import com.os.ems.report.domain.RealTimeDataBo;
import com.os.ems.report.mapper.EmsReportMapper; import com.os.ems.report.mapper.EmsReportMapper;
import com.os.ems.report.mapper.EmsReportPointAirMapper;
import com.os.ems.report.mapper.EmsReportPointDnbMapper; import com.os.ems.report.mapper.EmsReportPointDnbMapper;
import com.os.ems.report.mapper.EmsReportPointNitrogenMapper;
import com.os.ems.report.mapper.EmsReportPointSteamMapper;
import com.os.ems.report.mapper.EmsReportPointWaterMapper;
import com.os.ems.report.service.IEmsBoardService; import com.os.ems.report.service.IEmsBoardService;
import com.os.ems.report.service.IEmsReportService; import com.os.ems.report.service.IEmsReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -58,6 +65,18 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Autowired @Autowired
private EmsReportPointDnbMapper emsReportPointDnbMapper; private EmsReportPointDnbMapper emsReportPointDnbMapper;
@Autowired
private EmsReportPointWaterMapper emsReportPointWaterMapper;
@Autowired
private EmsReportPointSteamMapper emsReportPointSteamMapper;
@Autowired
private EmsReportPointAirMapper emsReportPointAirMapper;
@Autowired
private EmsReportPointNitrogenMapper emsReportPointNitrogenMapper;
@Autowired @Autowired
private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper; private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper;
@ -73,6 +92,9 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Autowired @Autowired
private EmsReportMapper emsReportMapper; private EmsReportMapper emsReportMapper;
@Autowired
private IEmsReportService emsReportService;
/** /**
* *
* *
@ -101,6 +123,27 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
return reportList; return reportList;
} }
@Override
public List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap) {
if (!hashMap.containsKey("monitorType")) {
return null;
}
String monitorType = String.valueOf(hashMap.get("monitorType"));
List<RealTimeDataBo> reportList = new ArrayList<>();
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
reportList = emsRecordDnbInstantMapper.realTimeDataByEnergy(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_WATER)) {
reportList = emsRecordWaterInstantMapper.realTimeDataByEnergy(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_STEAM)) {
reportList = emsRecordSteamInstantMapper.realTimeDataByEnergy(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_Air)) {
reportList = emsRecordAirInstantMapper.realTimeDataByEnergy(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_NITROGEN)) {
reportList = emsRecordNitrogenInstantMapper.realTimeDataByEnergy(hashMap);
}
return reportList;
}
/** /**
* - * -
* @param hashMap * @param hashMap
@ -114,6 +157,7 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
List<EmsBaseCollectDeviceInfo> deviceInfoList = emsBaseCollectDeviceInfoMapper.selectEmsBaseCollectDeviceInfoList(deviceInfo); List<EmsBaseCollectDeviceInfo> deviceInfoList = emsBaseCollectDeviceInfoMapper.selectEmsBaseCollectDeviceInfoList(deviceInfo);
EmsBaseMonitorInfo monitorInfo = new EmsBaseMonitorInfo(); EmsBaseMonitorInfo monitorInfo = new EmsBaseMonitorInfo();
monitorInfo.setIsAmmeter(EmsConstants.EMS_IS_AMMETER_NO); monitorInfo.setIsAmmeter(EmsConstants.EMS_IS_AMMETER_NO);
monitorInfo.setMonitorStatus(0L);
List<EmsBaseMonitorInfo> monitorInfoList = emsBaseMonitorInfoMapper.selectEmsBaseMonitorInfoList(monitorInfo); List<EmsBaseMonitorInfo> monitorInfoList = emsBaseMonitorInfoMapper.selectEmsBaseMonitorInfoList(monitorInfo);
Long dnbSum = 0L; Long dnbSum = 0L;
Long waterSum = 0L; Long waterSum = 0L;
@ -163,6 +207,14 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
hashMap.put("endCollectTime", monthEnd); hashMap.put("endCollectTime", monthEnd);
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) { if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
reportList = emsReportPointDnbMapper.selectWorkUnitTotalConsumption(hashMap); reportList = emsReportPointDnbMapper.selectWorkUnitTotalConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_WATER)) {
reportList = emsReportPointWaterMapper.selectWorkUnitTotalConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_STEAM)) {
reportList = emsReportPointSteamMapper.selectWorkUnitTotalConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_Air)) {
reportList = emsReportPointAirMapper.selectWorkUnitTotalConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_NITROGEN)) {
reportList = emsReportPointNitrogenMapper.selectWorkUnitTotalConsumption(hashMap);
} }
result.put("ranking", reportList); result.put("ranking", reportList);
result.put("statistics", reportList); result.put("statistics", reportList);
@ -177,7 +229,46 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override @Override
public HashMap<String, Object> peaksValleysConsumption(Map hashMap) { public HashMap<String, Object> peaksValleysConsumption(Map hashMap) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
List<HashMap<String, String>> reportList = emsReportPointDnbMapper.peaksValleysConsumption(hashMap); if (hashMap == null) {
hashMap = new HashMap();
}
String monitorType = String.valueOf(hashMap.getOrDefault("monitorType", EmsConstants.EMS_ENERGY_TYPE_DNB));
Map<String, String> dateTimeRanges = DateUtils.getDateTimeRanges();
String currentTime = dateTimeRanges.get("currentTime");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String beginTime = LocalDateTime.parse(dateTimeRanges.get("todayStart"), formatter).minusDays(6).format(formatter);
HashMap<String, Object> queryMap = new HashMap<>();
queryMap.put("energyType", monitorType);
queryMap.put("dateType", 10);
queryMap.put("beginCollectTime", beginTime);
queryMap.put("endCollectTime", currentTime);
queryMap.put("excludeObjId", 1);
List<EnergyStatisticalReport> sourceList = emsReportService.energyStatisticalReportList(queryMap);
if (sourceList == null) {
sourceList = new ArrayList<>();
}
// 按 日期+统计单元 聚合,供前端饼图/柱图使用
Map<String, BigDecimal> groupedMap = new LinkedHashMap<>();
for (EnergyStatisticalReport item : sourceList) {
String date = item.getBeginTime();
String unitName = item.getWorkUnitName();
String key = date + "|" + unitName;
BigDecimal expend = item.getExpend() == null ? BigDecimal.ZERO : item.getExpend();
groupedMap.put(key, groupedMap.getOrDefault(key, BigDecimal.ZERO).add(expend));
}
List<HashMap<String, String>> reportList = new ArrayList<>();
for (Map.Entry<String, BigDecimal> entry : groupedMap.entrySet()) {
String[] keyPart = entry.getKey().split("\\|", 2);
HashMap<String, String> row = new HashMap<>();
row.put("date", keyPart[0]);
row.put("unitName", keyPart.length > 1 ? keyPart[1] : "");
row.put("expend", entry.getValue().setScale(2, RoundingMode.HALF_UP).toPlainString());
reportList.add(row);
}
result.put("reportList", reportList); result.put("reportList", reportList);
return result; return result;
} }
@ -190,16 +281,32 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override @Override
public HashMap<String, Object> fiveConsumptionStatistics(Map hashMap) { public HashMap<String, Object> fiveConsumptionStatistics(Map hashMap) {
HashMap<String, Object> result = new LinkedHashMap<>(); HashMap<String, Object> result = new LinkedHashMap<>();
result.put("dnbSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random())))); Map<String, String> dateTimeRanges = DateUtils.getDateTimeRanges();
result.put("waterSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random())))); String todayStart = dateTimeRanges.get("todayStart");
result.put("steamSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random())))); String currentTime = dateTimeRanges.get("currentTime");
result.put("airSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random())))); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
result.put("nitrogenSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random())))); String yesterdayStart = LocalDateTime.parse(todayStart, formatter).minusDays(1).format(formatter);
result.put("dnbRate", new BigDecimal(String.format("%.2f", 100 * Math.random()))); String yesterdayCurrentTime = LocalDateTime.parse(currentTime, formatter).minusDays(1).format(formatter);
result.put("waterRate", new BigDecimal(String.format("%.2f", 100 * Math.random())));
result.put("steamRate", new BigDecimal(String.format("%.2f", -100 * Math.random()))); Map<String, BigDecimal> currentMap = getTodayConsumptionMap(todayStart, currentTime);
result.put("airRate", new BigDecimal(String.format("%.2f", 100 * Math.random()))); Map<String, BigDecimal> yesterdayMap = getTodayConsumptionMap(yesterdayStart, yesterdayCurrentTime);
result.put("nitrogenRate", new BigDecimal(String.format("%.2f", -100 * Math.random())));
BigDecimal dnbSum = currentMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_DNB, BigDecimal.ZERO);
BigDecimal waterSum = currentMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_WATER, BigDecimal.ZERO);
BigDecimal steamSum = currentMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_STEAM, BigDecimal.ZERO);
BigDecimal airSum = currentMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_Air, BigDecimal.ZERO);
BigDecimal nitrogenSum = currentMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, BigDecimal.ZERO);
result.put("dnbSum", dnbSum);
result.put("waterSum", waterSum);
result.put("steamSum", steamSum);
result.put("airSum", airSum);
result.put("nitrogenSum", nitrogenSum);
result.put("dnbRate", calculateRate(dnbSum, yesterdayMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_DNB, BigDecimal.ZERO)));
result.put("waterRate", calculateRate(waterSum, yesterdayMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_WATER, BigDecimal.ZERO)));
result.put("steamRate", calculateRate(steamSum, yesterdayMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_STEAM, BigDecimal.ZERO)));
result.put("airRate", calculateRate(airSum, yesterdayMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_Air, BigDecimal.ZERO)));
result.put("nitrogenRate", calculateRate(nitrogenSum, yesterdayMap.getOrDefault(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, BigDecimal.ZERO)));
return result; return result;
} }
@ -238,6 +345,14 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
} }
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) { if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
reportList = emsReportPointDnbMapper.selectWorkUnitDateConsumption(hashMap); reportList = emsReportPointDnbMapper.selectWorkUnitDateConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_WATER)) {
reportList = emsReportPointWaterMapper.selectWorkUnitDateConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_STEAM)) {
reportList = emsReportPointSteamMapper.selectWorkUnitDateConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_Air)) {
reportList = emsReportPointAirMapper.selectWorkUnitDateConsumption(hashMap);
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_NITROGEN)) {
reportList = emsReportPointNitrogenMapper.selectWorkUnitDateConsumption(hashMap);
} }
result.put("reportList", reportList); result.put("reportList", reportList);
return result; return result;
@ -260,12 +375,33 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override @Override
public HashMap<String, Object> workshopColumns(Map hashMap) { public HashMap<String, Object> workshopColumns(Map hashMap) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = workshopEnergyBoard(hashMap);
Object column = result.get("column");
List<Map<String, Object>> columns = new ArrayList<>();
if (column instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> col = (Map<String, Object>) column;
columns.add(col);
}
result.put("columns", columns);
return result;
}
@Override
public HashMap<String, Object> workshopEnergyBoard(Map hashMap) {
Map<String, String> dateTimeRanges = DateUtils.getDateTimeRanges(); Map<String, String> dateTimeRanges = DateUtils.getDateTimeRanges();
String monitorType = hashMap != null && hashMap.get("monitorType") != null
? String.valueOf(hashMap.get("monitorType"))
: EmsConstants.EMS_ENERGY_TYPE_DNB;
return buildWorkshopEnergyBoardResult(monitorType, dateTimeRanges);
}
private HashMap<String, Object> buildWorkshopEnergyBoardResult(String monitorType, Map<String, String> dateTimeRanges) {
HashMap<String, Object> result = new HashMap<>();
HashMap<String, Object> query = new HashMap<>(); HashMap<String, Object> query = new HashMap<>();
query.put("monitorType", monitorType);
query.put("beginCollectTime", dateTimeRanges.get("todayStart")); query.put("beginCollectTime", dateTimeRanges.get("todayStart"));
query.put("endCollectTime", dateTimeRanges.get("currentTime")); query.put("endCollectTime", dateTimeRanges.get("currentTime"));
List<Map<String, Object>> latestRows = emsReportMapper.selectWorkshopLatestRows(query); List<Map<String, Object>> latestRows = emsReportMapper.selectWorkshopLatestRows(query);
List<Map<String, Object>> consumptionList = emsReportMapper.selectWorkshopTodayConsumption(query); List<Map<String, Object>> consumptionList = emsReportMapper.selectWorkshopTodayConsumption(query);
List<Map<String, Object>> perDeviceList = emsReportMapper.selectWorkshopTodayPerDevice(query); List<Map<String, Object>> perDeviceList = emsReportMapper.selectWorkshopTodayPerDevice(query);
@ -283,27 +419,26 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
perDeviceConsumption.put(type + "_" + code, toBigDecimal(row.get("rowTodayConsumption"))); perDeviceConsumption.put(type + "_" + code, toBigDecimal(row.get("rowTodayConsumption")));
} }
LinkedHashMap<String, Map<String, Object>> colMap = new LinkedHashMap<>(); Map<String, Object> column = createColumn(
colMap.put(EmsConstants.EMS_ENERGY_TYPE_DNB, createColumn(EmsConstants.EMS_ENERGY_TYPE_DNB, "电", "kWh", consumptionMap)); monitorType,
colMap.put(EmsConstants.EMS_ENERGY_TYPE_WATER, createColumn(EmsConstants.EMS_ENERGY_TYPE_WATER, "水", "m³", consumptionMap)); getEnergyName(monitorType),
colMap.put(EmsConstants.EMS_ENERGY_TYPE_STEAM, createColumn(EmsConstants.EMS_ENERGY_TYPE_STEAM, "蒸汽", "t", consumptionMap)); getEnergyUnit(monitorType),
colMap.put(EmsConstants.EMS_ENERGY_TYPE_Air, createColumn(EmsConstants.EMS_ENERGY_TYPE_Air, "压缩空气", "m³", consumptionMap)); consumptionMap
colMap.put(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, createColumn(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, "氮气", "m³", consumptionMap)); );
@SuppressWarnings("unchecked")
List<Map<String, Object>> rows = (List<Map<String, Object>>) column.get("rows");
for (Map<String, Object> row : latestRows) { for (Map<String, Object> row : latestRows) {
String type = String.valueOf(row.get("monitorType")); String type = String.valueOf(row.get("monitorType"));
Map<String, Object> col = colMap.get(type); if (!Objects.equals(type, monitorType)) {
if (col == null) {
continue; continue;
} }
String code = String.valueOf(row.get("monitorCode")); String code = String.valueOf(row.get("monitorCode"));
row.put("rowTodayConsumption", perDeviceConsumption.getOrDefault(type + "_" + code, BigDecimal.ZERO)); row.put("rowTodayConsumption", perDeviceConsumption.getOrDefault(type + "_" + code, BigDecimal.ZERO));
@SuppressWarnings("unchecked")
List<Map<String, Object>> rows = (List<Map<String, Object>>) col.get("rows");
rows.add(row); rows.add(row);
} }
result.put("columns", new ArrayList<>(colMap.values())); result.put("column", column);
result.put("trend24h", build24hTrendByDevice(monitorType, dateTimeRanges.get("currentTime")));
return result; return result;
} }
@ -317,6 +452,133 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
return col; return col;
} }
private String getEnergyName(String monitorType) {
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_WATER)) {
return "水";
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_STEAM)) {
return "蒸汽";
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_Air)) {
return "压缩空气";
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_NITROGEN)) {
return "氮气";
}
return "电";
}
private String getEnergyUnit(String monitorType) {
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
return "kWh";
} else if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_STEAM)) {
return "t";
}
return "m³";
}
private List<Map<String, Object>> build24hTrendByDevice(String monitorType, String currentTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter keyFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH");
DateTimeFormatter showFormatter = DateTimeFormatter.ofPattern("MM-dd HH:00");
LocalDateTime now = LocalDateTime.parse(currentTime, formatter);
LocalDateTime endHour = now.withMinute(0).withSecond(0).withNano(0).minusHours(1);
LocalDateTime begin = endHour.minusHours(23);
LocalDateTime queryEnd = endHour.plusHours(1).minusSeconds(1);
List<Map<String, Object>> reportList = queryTrendByRange(monitorType, begin, queryEnd, formatter);
if (reportList == null || reportList.isEmpty()) {
reportList = queryTrendByRange(monitorType, queryEnd.minusDays(7), queryEnd, formatter);
if (reportList == null || reportList.isEmpty()) {
return new ArrayList<>();
}
LocalDateTime maxTime = resolveMaxTime(reportList, keyFormatter);
if (maxTime != null) {
endHour = maxTime;
begin = endHour.minusHours(23);
}
}
Set<String> slotSet = new HashSet<>();
List<String> slots = new ArrayList<>();
for (int i = 0; i < 24; i++) {
LocalDateTime slot = begin.plusHours(i);
String key = slot.format(keyFormatter);
slots.add(key);
slotSet.add(key);
}
LinkedHashMap<String, Map<String, Object>> deviceMap = new LinkedHashMap<>();
if (reportList != null) {
for (Map<String, Object> row : reportList) {
String monitorCode = String.valueOf(row.get("monitorCode"));
String monitorName = String.valueOf(row.get("monitorName"));
String timeKey = String.valueOf(row.get("timeKey"));
if (!slotSet.contains(timeKey)) {
continue;
}
BigDecimal expend = toBigDecimal(row.get("expend")).setScale(2, RoundingMode.HALF_UP);
Map<String, Object> item = deviceMap.computeIfAbsent(monitorCode, k -> {
Map<String, Object> m = new HashMap<>();
m.put("monitorCode", monitorCode);
m.put("monitorName", monitorName);
m.put("data", new HashMap<String, BigDecimal>());
return m;
});
@SuppressWarnings("unchecked")
Map<String, BigDecimal> data = (Map<String, BigDecimal>) item.get("data");
data.put(timeKey, expend);
}
}
List<Map<String, Object>> trend = new ArrayList<>();
for (Map<String, Object> item : deviceMap.values()) {
@SuppressWarnings("unchecked")
Map<String, BigDecimal> data = (Map<String, BigDecimal>) item.get("data");
List<Map<String, Object>> points = new ArrayList<>();
for (String slot : slots) {
Map<String, Object> point = new HashMap<>();
point.put("timeKey", slot);
LocalDateTime time = LocalDateTime.parse(slot + ":00:00", formatter);
point.put("time", time.format(showFormatter));
point.put("expend", data.getOrDefault(slot, BigDecimal.ZERO));
points.add(point);
}
Map<String, Object> series = new HashMap<>();
series.put("monitorCode", item.get("monitorCode"));
series.put("monitorName", item.get("monitorName"));
series.put("points", points);
trend.add(series);
}
return trend;
}
private List<Map<String, Object>> queryTrendByRange(String monitorType, LocalDateTime begin, LocalDateTime end, DateTimeFormatter formatter) {
HashMap<String, Object> trendQuery = new HashMap<>();
trendQuery.put("monitorType", monitorType);
trendQuery.put("beginCollectTime", begin.format(formatter));
trendQuery.put("endCollectTime", end.format(formatter));
return emsReportMapper.selectWorkshop24hPerDeviceTrend(trendQuery);
}
private LocalDateTime resolveMaxTime(List<Map<String, Object>> reportList, DateTimeFormatter keyFormatter) {
LocalDateTime max = null;
for (Map<String, Object> row : reportList) {
Object timeKeyObj = row.get("timeKey");
if (timeKeyObj == null) {
continue;
}
try {
LocalDateTime current = LocalDateTime.parse(String.valueOf(timeKeyObj), keyFormatter);
if (max == null || current.isAfter(max)) {
max = current;
}
} catch (Exception ignored) {
// 跳过异常时间格式,避免影响整批趋势生成
}
}
return max;
}
private BigDecimal toBigDecimal(Object value) { private BigDecimal toBigDecimal(Object value) {
if (value == null) { if (value == null) {
return BigDecimal.ZERO; return BigDecimal.ZERO;
@ -327,5 +589,28 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
return new BigDecimal(String.valueOf(value)); return new BigDecimal(String.valueOf(value));
} }
private BigDecimal calculateRate(BigDecimal current, BigDecimal previous) {
if (previous == null || previous.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO;
}
return current.subtract(previous)
.divide(previous, 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
.setScale(2, RoundingMode.HALF_UP);
}
private Map<String, BigDecimal> getTodayConsumptionMap(String beginCollectTime, String endCollectTime) {
HashMap<String, Object> query = new HashMap<>();
query.put("beginCollectTime", beginCollectTime);
query.put("endCollectTime", endCollectTime);
List<Map<String, Object>> consumptionList = emsReportMapper.selectWorkshopTodayConsumption(query);
Map<String, BigDecimal> resultMap = new HashMap<>();
for (Map<String, Object> row : consumptionList) {
String type = String.valueOf(row.get("monitorType"));
resultMap.put(type, toBigDecimal(row.get("todayConsumption")));
}
return resultMap;
}
} }

@ -114,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ebli.monitor_code monitorCode, ebli.monitor_code monitorCode,
ebmi.monitor_name monitorName, ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType, ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime, rk.collect_time collectTime,
rk.flux_flow fluxFlow, rk.flux_flow fluxFlow,
rk.steam_flow steamFlow, rk.steam_flow steamFlow,
@ -130,8 +131,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where> <where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if> <if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where> </where>
order by ebli.parent_id, ebli.obj_id order by ebli.parent_id, ebli.obj_id
</select> </select>
<select id="realTimeDataByEnergy" resultType="com.os.ems.report.domain.RealTimeDataBo">
SELECT ebmi.obj_id objId,
ebmi.parent_id parentId,
ebmi.monitor_code monitorCode,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.flux_flow fluxFlow,
rk.steam_flow steamFlow,
rk.temperature,
rk.press,
rk.density
FROM ems_base_monitor_info ebmi
JOIN (SELECT *
FROM (SELECT *,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY obj_id DESC) AS rn
FROM ems_record_air_instant) t
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where>
order by ebmi.parent_id, ebmi.obj_id
</select>
</mapper> </mapper>

@ -186,10 +186,41 @@
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where> <where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if> <if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where> </where>
order by ebli.parent_id, ebli.obj_id order by ebli.parent_id, ebli.obj_id
</select> </select>
<select id="realTimeDataByEnergy" resultType="com.os.ems.report.domain.RealTimeDataBo">
SELECT ebmi.obj_id objId,
ebmi.parent_id parentId,
ebmi.monitor_code monitorCode,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.v_a vA,
rk.v_b vB,
rk.v_c vC,
rk.i_a iA,
rk.i_b iB,
rk.i_c iC,
rk.glys,
rk.zxyg,
rk.fxyg
FROM ems_base_monitor_info ebmi
JOIN (SELECT *
FROM (SELECT *,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY obj_id DESC) AS rn
FROM ems_record_dnb_instant) t
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where>
order by ebmi.parent_id, ebmi.obj_id
</select>
</mapper> </mapper>

@ -122,6 +122,7 @@
ebli.monitor_code monitorCode, ebli.monitor_code monitorCode,
ebmi.monitor_name monitorName, ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType, ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime, rk.collect_time collectTime,
rk.flux_flow fluxFlow, rk.flux_flow fluxFlow,
rk.steam_flow steamFlow, rk.steam_flow steamFlow,
@ -138,7 +139,34 @@
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where> <where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if> <if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where> </where>
order by ebli.parent_id, ebli.obj_id order by ebli.parent_id, ebli.obj_id
</select> </select>
<select id="realTimeDataByEnergy" resultType="com.os.ems.report.domain.RealTimeDataBo">
SELECT ebmi.obj_id objId,
ebmi.parent_id parentId,
ebmi.monitor_code monitorCode,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.flux_flow fluxFlow,
rk.steam_flow steamFlow,
rk.temperature,
rk.press,
rk.purity
FROM ems_base_monitor_info ebmi
JOIN (SELECT *
FROM (SELECT *,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY obj_id DESC) AS rn
FROM ems_record_nitrogen_instant) t
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where>
order by ebmi.parent_id, ebmi.obj_id
</select>
</mapper> </mapper>

@ -134,6 +134,7 @@
ebli.monitor_code monitorCode, ebli.monitor_code monitorCode,
ebmi.monitor_name monitorName, ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType, ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime, rk.collect_time collectTime,
rk.flux_flow fluxFlow, rk.flux_flow fluxFlow,
rk.steam_flow steamFlow, rk.steam_flow steamFlow,
@ -150,8 +151,35 @@
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where> <where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if> <if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where> </where>
order by ebli.parent_id, ebli.obj_id order by ebli.parent_id, ebli.obj_id
</select> </select>
<select id="realTimeDataByEnergy" resultType="com.os.ems.report.domain.RealTimeDataBo">
SELECT ebmi.obj_id objId,
ebmi.parent_id parentId,
ebmi.monitor_code monitorCode,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.flux_flow fluxFlow,
rk.steam_flow steamFlow,
rk.temperature,
rk.press,
rk.density
FROM ems_base_monitor_info ebmi
JOIN (SELECT *
FROM (SELECT *,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY obj_id DESC) AS rn
FROM ems_record_steam_instant) t
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where>
order by ebmi.parent_id, ebmi.obj_id
</select>
</mapper> </mapper>

@ -101,6 +101,7 @@
ebli.monitor_code monitorCode, ebli.monitor_code monitorCode,
ebmi.monitor_name monitorName, ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType, ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime, rk.collect_time collectTime,
rk.flux_flow fluxFlow, rk.flux_flow fluxFlow,
rk.water_flow waterFlow rk.water_flow waterFlow
@ -114,9 +115,33 @@
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where> <where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if> <if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where> </where>
order by ebli.parent_id, ebli.obj_id order by ebli.parent_id, ebli.obj_id
</select> </select>
<select id="realTimeDataByEnergy" resultType="com.os.ems.report.domain.RealTimeDataBo">
SELECT ebmi.obj_id objId,
ebmi.parent_id parentId,
ebmi.monitor_code monitorCode,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.flux_flow fluxFlow,
rk.water_flow waterFlow
FROM ems_base_monitor_info ebmi
JOIN (SELECT *
FROM (SELECT *,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY obj_id DESC) AS rn
FROM ems_record_water_instant) t
WHERE t.rn = 1) rk ON rk.monitor_code = ebmi.monitor_code
<where>
<if test="monitorType != null and monitorType != ''">and ebmi.monitor_type = #{monitorType}</if>
<if test="isAmmeter != null and isAmmeter != ''">and ebmi.is_ammeter = #{isAmmeter}</if>
</where>
order by ebmi.parent_id, ebmi.obj_id
</select>
</mapper> </mapper>

@ -20,6 +20,9 @@
LEFT JOIN ems_report_point_dnb RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE LEFT JOIN ems_report_point_dnb RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="excludeObjId != null and excludeObjId != ''">
and WU.obj_id != #{excludeObjId}
</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
@ -49,6 +52,9 @@
LEFT JOIN ems_report_point_water RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE LEFT JOIN ems_report_point_water RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="excludeObjId != null and excludeObjId != ''">
and WU.obj_id != #{excludeObjId}
</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
@ -78,6 +84,9 @@
LEFT JOIN ems_report_point_steam RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE LEFT JOIN ems_report_point_steam RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="excludeObjId != null and excludeObjId != ''">
and WU.obj_id != #{excludeObjId}
</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
@ -107,6 +116,9 @@
LEFT JOIN ems_report_point_air RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE LEFT JOIN ems_report_point_air RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="excludeObjId != null and excludeObjId != ''">
and WU.obj_id != #{excludeObjId}
</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
@ -136,6 +148,9 @@
LEFT JOIN ems_report_point_nitrogen RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE LEFT JOIN ems_report_point_nitrogen RPD ON RPD.MONITOR_CODE = MWU.MONITOR_CODE
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="excludeObjId != null and excludeObjId != ''">
and WU.obj_id != #{excludeObjId}
</if>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
@ -203,212 +218,243 @@
x.realtimeUnit x.realtimeUnit
FROM ( FROM (
SELECT CAST('2' AS VARCHAR(4)) monitorType, SELECT CAST('2' AS VARCHAR(4)) monitorType,
t.monitor_code monitorCode, t.monitor_code monitorCode,
bmi.monitor_name monitorName, bmi.monitor_name monitorName,
NULL instantFlow, NULL instantFlow,
t.zxyg cumulativeFlow, t.zxyg cumulativeFlow,
t.vA vA, t.vA vA,
t.vB vB, t.vB vB,
t.vC vC, t.vC vC,
t.iA iA, t.iA iA,
t.iB iB, t.iB iB,
t.iC iC, t.iC iC,
NULL instantUnit, NULL instantUnit,
'kWh' realtimeUnit 'kWh' realtimeUnit
FROM ( FROM (
SELECT monitor_code, SELECT monitor_code, zxyg, v_a AS vA, v_b AS vB, v_c AS vC, i_a AS iA, i_b AS iB, i_c AS iC,
zxyg,
v_a AS vA,
v_b AS vB,
v_c AS vC,
i_a AS iA,
i_b AS iB,
i_c AS iC,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn
FROM ems_record_dnb_instant FROM ems_record_dnb_instant
) t ) t
LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.rn = 1 WHERE t.rn = 1 AND bmi.monitor_type = 2 AND bmi.is_ammeter = '1'
AND bmi.monitor_type = 2
AND bmi.is_ammeter = '1'
UNION ALL UNION ALL
SELECT CAST('3' AS VARCHAR(4)) monitorType, SELECT CAST('3' AS VARCHAR(4)),
t.monitor_code monitorCode, t.monitor_code,
bmi.monitor_name monitorName, bmi.monitor_name,
t.flux_flow instantFlow, t.flux_flow,
t.water_flow cumulativeFlow, t.water_flow,
NULL vA, NULL, NULL, NULL, NULL, NULL, NULL,
NULL vB, 'm³/h',
NULL vC, 'm³'
NULL iA,
NULL iB,
NULL iC,
'm³/h' instantUnit,
'm³' realtimeUnit
FROM ( FROM (
SELECT monitor_code, flux_flow, water_flow, SELECT monitor_code, flux_flow, water_flow,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn
FROM ems_record_water_instant FROM ems_record_water_instant
) t ) t
LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.rn = 1 WHERE t.rn = 1 AND bmi.monitor_type = 3 AND bmi.is_ammeter = '1'
AND bmi.monitor_type = 3
AND bmi.is_ammeter = '1'
UNION ALL UNION ALL
SELECT CAST('4' AS VARCHAR(4)) monitorType, SELECT CAST('4' AS VARCHAR(4)),
t.monitor_code monitorCode, t.monitor_code,
bmi.monitor_name monitorName, bmi.monitor_name,
t.flux_flow instantFlow, t.flux_flow,
t.steam_flow cumulativeFlow, t.steam_flow,
NULL vA, NULL, NULL, NULL, NULL, NULL, NULL,
NULL vB, 't/h',
NULL vC, 't'
NULL iA,
NULL iB,
NULL iC,
't/h' instantUnit,
't' realtimeUnit
FROM ( FROM (
SELECT monitor_code, flux_flow, steam_flow, SELECT monitor_code, flux_flow, steam_flow,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn
FROM ems_record_steam_instant FROM ems_record_steam_instant
) t ) t
LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.rn = 1 WHERE t.rn = 1 AND bmi.monitor_type = 4 AND bmi.is_ammeter = '1'
AND bmi.monitor_type = 4
AND bmi.is_ammeter = '1'
UNION ALL UNION ALL
SELECT CAST('5' AS VARCHAR(4)) monitorType, SELECT CAST('5' AS VARCHAR(4)),
t.monitor_code monitorCode, t.monitor_code,
bmi.monitor_name monitorName, bmi.monitor_name,
t.flux_flow instantFlow, t.flux_flow,
t.steam_flow cumulativeFlow, t.steam_flow,
NULL vA, NULL, NULL, NULL, NULL, NULL, NULL,
NULL vB, 'm³/h',
NULL vC, 'm³'
NULL iA,
NULL iB,
NULL iC,
'm³/h' instantUnit,
'm³' realtimeUnit
FROM ( FROM (
SELECT monitor_code, flux_flow, steam_flow, SELECT monitor_code, flux_flow, steam_flow,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn
FROM ems_record_air_instant FROM ems_record_air_instant
) t ) t
LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.rn = 1 WHERE t.rn = 1 AND bmi.monitor_type = 5 AND bmi.is_ammeter = '1'
AND bmi.monitor_type = 5
AND bmi.is_ammeter = '1'
UNION ALL UNION ALL
SELECT CAST('6' AS VARCHAR(4)) monitorType, SELECT CAST('6' AS VARCHAR(4)),
t.monitor_code monitorCode, t.monitor_code,
bmi.monitor_name monitorName, bmi.monitor_name,
t.flux_flow instantFlow, t.flux_flow,
t.steam_flow cumulativeFlow, t.steam_flow,
NULL vA, NULL, NULL, NULL, NULL, NULL, NULL,
NULL vB, 'm³/h',
NULL vC, 'm³'
NULL iA,
NULL iB,
NULL iC,
'm³/h' instantUnit,
'm³' realtimeUnit
FROM ( FROM (
SELECT monitor_code, flux_flow, steam_flow, SELECT monitor_code, flux_flow, steam_flow,
ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn ROW_NUMBER() OVER (PARTITION BY monitor_code ORDER BY collect_time DESC, obj_id DESC) rn
FROM ems_record_nitrogen_instant FROM ems_record_nitrogen_instant
) t ) t
LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code LEFT JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.rn = 1 WHERE t.rn = 1 AND bmi.monitor_type = 6 AND bmi.is_ammeter = '1'
AND bmi.monitor_type = 6
AND bmi.is_ammeter = '1'
) x ) x
<if test="monitorType != null and monitorType != ''">
WHERE x.monitorType = CAST(#{monitorType} AS VARCHAR(4))
</if>
ORDER BY x.monitorType, x.monitorCode ORDER BY x.monitorType, x.monitorCode
</select> </select>
<select id="selectWorkshopTodayPerDevice" resultType="java.util.HashMap" parameterType="java.util.HashMap"> <select id="selectWorkshopTodayPerDevice" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT CAST('2' AS VARCHAR(4)) monitorType, SELECT x.monitorType, x.monitorCode, x.rowTodayConsumption
monitor_code monitorCode, FROM (
CAST(CASE WHEN MAX(zxyg) - MIN(zxyg) > 0 THEN MAX(zxyg) - MIN(zxyg) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption SELECT CAST('2' AS VARCHAR(4)) monitorType, monitor_code monitorCode,
FROM ems_record_dnb_instant CAST(CASE WHEN MAX(zxyg) - MIN(zxyg) > 0 THEN MAX(zxyg) - MIN(zxyg) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} FROM ems_record_dnb_instant
GROUP BY monitor_code WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code
UNION ALL UNION ALL
SELECT CAST('3' AS VARCHAR(4)) monitorType, SELECT CAST('3' AS VARCHAR(4)), monitor_code,
monitor_code monitorCode, CAST(CASE WHEN MAX(water_flow) - MIN(water_flow) > 0 THEN MAX(water_flow) - MIN(water_flow) ELSE 0 END AS DECIMAL(18, 2))
CAST(CASE WHEN MAX(water_flow) - MIN(water_flow) > 0 THEN MAX(water_flow) - MIN(water_flow) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption FROM ems_record_water_instant
FROM ems_record_water_instant WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} GROUP BY monitor_code
GROUP BY monitor_code UNION ALL
SELECT CAST('4' AS VARCHAR(4)), monitor_code,
UNION ALL CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2))
SELECT CAST('4' AS VARCHAR(4)) monitorType, FROM ems_record_steam_instant
monitor_code monitorCode, WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption GROUP BY monitor_code
FROM ems_record_steam_instant UNION ALL
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} SELECT CAST('5' AS VARCHAR(4)), monitor_code,
GROUP BY monitor_code CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2))
FROM ems_record_air_instant
UNION ALL WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
SELECT CAST('5' AS VARCHAR(4)) monitorType, GROUP BY monitor_code
monitor_code monitorCode, UNION ALL
CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption SELECT CAST('6' AS VARCHAR(4)), monitor_code,
FROM ems_record_air_instant CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2))
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} FROM ems_record_nitrogen_instant
GROUP BY monitor_code WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code
UNION ALL ) x
SELECT CAST('6' AS VARCHAR(4)) monitorType, <if test="monitorType != null and monitorType != ''">
monitor_code monitorCode, WHERE x.monitorType = CAST(#{monitorType} AS VARCHAR(4))
CAST(CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END AS DECIMAL(18, 2)) rowTodayConsumption </if>
FROM ems_record_nitrogen_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code
</select> </select>
<select id="selectWorkshopTodayConsumption" resultType="java.util.HashMap" parameterType="java.util.HashMap"> <select id="selectWorkshopTodayConsumption" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT monitorType, CAST(SUM(val) AS DECIMAL(18, 2)) todayConsumption SELECT y.monitorType, CAST(SUM(y.val) AS DECIMAL(18, 2)) todayConsumption
FROM ( FROM (
SELECT CAST('2' AS VARCHAR(4)) monitorType, SELECT CAST('2' AS VARCHAR(4)) monitorType,
CASE WHEN MAX(zxyg) - MIN(zxyg) > 0 THEN MAX(zxyg) - MIN(zxyg) ELSE 0 END val CASE WHEN MAX(zxyg) - MIN(zxyg) > 0 THEN MAX(zxyg) - MIN(zxyg) ELSE 0 END val
FROM ems_record_dnb_instant FROM ems_record_dnb_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code GROUP BY monitor_code
UNION ALL UNION ALL
SELECT CAST('3' AS VARCHAR(4)) monitorType, SELECT CAST('3' AS VARCHAR(4)),
CASE WHEN MAX(water_flow) - MIN(water_flow) > 0 THEN MAX(water_flow) - MIN(water_flow) ELSE 0 END val CASE WHEN MAX(water_flow) - MIN(water_flow) > 0 THEN MAX(water_flow) - MIN(water_flow) ELSE 0 END
FROM ems_record_water_instant FROM ems_record_water_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code GROUP BY monitor_code
UNION ALL UNION ALL
SELECT CAST('4' AS VARCHAR(4)) monitorType, SELECT CAST('4' AS VARCHAR(4)),
CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END val CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END
FROM ems_record_steam_instant FROM ems_record_steam_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code GROUP BY monitor_code
UNION ALL UNION ALL
SELECT CAST('5' AS VARCHAR(4)) monitorType, SELECT CAST('5' AS VARCHAR(4)),
CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END val CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END
FROM ems_record_air_instant FROM ems_record_air_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code GROUP BY monitor_code
UNION ALL UNION ALL
SELECT CAST('6' AS VARCHAR(4)) monitorType, SELECT CAST('6' AS VARCHAR(4)),
CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END val CASE WHEN MAX(steam_flow) - MIN(steam_flow) > 0 THEN MAX(steam_flow) - MIN(steam_flow) ELSE 0 END
FROM ems_record_nitrogen_instant FROM ems_record_nitrogen_instant
WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime} WHERE collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
GROUP BY monitor_code GROUP BY monitor_code
) t ) y
GROUP BY monitorType <if test="monitorType != null and monitorType != ''">
WHERE y.monitorType = CAST(#{monitorType} AS VARCHAR(4))
</if>
GROUP BY y.monitorType
</select>
<select id="selectWorkshop24hPerDeviceTrend" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT x.monitorType,
x.monitorCode,
x.monitorName,
x.timeKey,
x.expend
FROM (
SELECT CAST('2' AS VARCHAR(4)) monitorType,
bmi.monitor_code monitorCode,
bmi.monitor_name monitorName,
CONVERT(VARCHAR(13), t.collect_time, 120) timeKey,
CAST(CASE WHEN MAX(t.zxyg) - MIN(t.zxyg) > 0 THEN MAX(t.zxyg) - MIN(t.zxyg) ELSE 0 END AS DECIMAL(18, 2)) expend
FROM ems_record_dnb_instant t
JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
AND bmi.monitor_type = 2
AND bmi.is_ammeter = '1'
GROUP BY bmi.monitor_code, bmi.monitor_name, CONVERT(VARCHAR(13), t.collect_time, 120)
UNION ALL
SELECT CAST('3' AS VARCHAR(4)),
bmi.monitor_code,
bmi.monitor_name,
CONVERT(VARCHAR(13), t.collect_time, 120),
CAST(CASE WHEN MAX(t.water_flow) - MIN(t.water_flow) > 0 THEN MAX(t.water_flow) - MIN(t.water_flow) ELSE 0 END AS DECIMAL(18, 2))
FROM ems_record_water_instant t
JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
AND bmi.monitor_type = 3
AND bmi.is_ammeter = '1'
GROUP BY bmi.monitor_code, bmi.monitor_name, CONVERT(VARCHAR(13), t.collect_time, 120)
UNION ALL
SELECT CAST('4' AS VARCHAR(4)),
bmi.monitor_code,
bmi.monitor_name,
CONVERT(VARCHAR(13), t.collect_time, 120),
CAST(CASE WHEN MAX(t.steam_flow) - MIN(t.steam_flow) > 0 THEN MAX(t.steam_flow) - MIN(t.steam_flow) ELSE 0 END AS DECIMAL(18, 2))
FROM ems_record_steam_instant t
JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
AND bmi.monitor_type = 4
AND bmi.is_ammeter = '1'
GROUP BY bmi.monitor_code, bmi.monitor_name, CONVERT(VARCHAR(13), t.collect_time, 120)
UNION ALL
SELECT CAST('5' AS VARCHAR(4)),
bmi.monitor_code,
bmi.monitor_name,
CONVERT(VARCHAR(13), t.collect_time, 120),
CAST(CASE WHEN MAX(t.steam_flow) - MIN(t.steam_flow) > 0 THEN MAX(t.steam_flow) - MIN(t.steam_flow) ELSE 0 END AS DECIMAL(18, 2))
FROM ems_record_air_instant t
JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
AND bmi.monitor_type = 5
AND bmi.is_ammeter = '1'
GROUP BY bmi.monitor_code, bmi.monitor_name, CONVERT(VARCHAR(13), t.collect_time, 120)
UNION ALL
SELECT CAST('6' AS VARCHAR(4)),
bmi.monitor_code,
bmi.monitor_name,
CONVERT(VARCHAR(13), t.collect_time, 120),
CAST(CASE WHEN MAX(t.steam_flow) - MIN(t.steam_flow) > 0 THEN MAX(t.steam_flow) - MIN(t.steam_flow) ELSE 0 END AS DECIMAL(18, 2))
FROM ems_record_nitrogen_instant t
JOIN ems_base_monitor_info bmi ON bmi.monitor_code = t.monitor_code
WHERE t.collect_time BETWEEN #{beginCollectTime} AND #{endCollectTime}
AND bmi.monitor_type = 6
AND bmi.is_ammeter = '1'
GROUP BY bmi.monitor_code, bmi.monitor_name, CONVERT(VARCHAR(13), t.collect_time, 120)
) x
<if test="monitorType != null and monitorType != ''">
WHERE x.monitorType = CAST(#{monitorType} AS VARCHAR(4))
</if>
ORDER BY x.monitorCode, x.timeKey
</select> </select>
</mapper> </mapper>

@ -120,4 +120,43 @@
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="selectWorkUnitTotalConsumption" resultType="java.util.HashMap">
SELECT WU.WORK_UNIT_CODE workUnitCode,
WU.WORK_UNIT_NAME workUnitName,
ISNULL(ex.expend, 0) expend
FROM ems_base_work_unit wu
LEFT JOIN
(SELECT mwu.work_unit_code, SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend
FROM ems_base_monitor_work_unit mwu
LEFT JOIN ems_report_point_air rpd on rpd.monitor_code = mwu.monitor_code
WHERE 1=1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
group by mwu.work_unit_code) ex ON ex.work_unit_code = wu.work_unit_code
ORDER BY ex.expend DESC
</select>
<select id="selectWorkUnitDateConsumption" resultType="java.util.HashMap">
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
SELECT ex.date,
ISNULL(SUM(ex.expend), 0) expend
FROM (SELECT mwu.work_unit_code,
SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend,
LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB) date
FROM ems_report_point_air rpd
LEFT JOIN ems_base_monitor_work_unit mwu on rpd.monitor_code = mwu.monitor_code
CROSS JOIN DT
WHERE 1 = 1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex
LEFT JOIN ems_base_work_unit wu
ON ex.work_unit_code = wu.work_unit_code
WHERE wu.parent_id = 0
GROUP BY ex.date
ORDER BY ex.date
</select>
</mapper> </mapper>

@ -187,7 +187,7 @@
GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex
LEFT JOIN ems_base_work_unit wu LEFT JOIN ems_base_work_unit wu
ON ex.work_unit_code = wu.work_unit_code ON ex.work_unit_code = wu.work_unit_code
WHERE wu.parent_id = 1 WHERE wu.parent_id = 0
GROUP BY ex.date GROUP BY ex.date
ORDER BY ex.date ORDER BY ex.date
</select> </select>

@ -120,4 +120,43 @@
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="selectWorkUnitTotalConsumption" resultType="java.util.HashMap">
SELECT WU.WORK_UNIT_CODE workUnitCode,
WU.WORK_UNIT_NAME workUnitName,
ISNULL(ex.expend, 0) expend
FROM ems_base_work_unit wu
LEFT JOIN
(SELECT mwu.work_unit_code, SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend
FROM ems_base_monitor_work_unit mwu
LEFT JOIN ems_report_point_nitrogen rpd on rpd.monitor_code = mwu.monitor_code
WHERE 1=1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
group by mwu.work_unit_code) ex ON ex.work_unit_code = wu.work_unit_code
ORDER BY ex.expend DESC
</select>
<select id="selectWorkUnitDateConsumption" resultType="java.util.HashMap">
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
SELECT ex.date,
ISNULL(SUM(ex.expend), 0) expend
FROM (SELECT mwu.work_unit_code,
SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend,
LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB) date
FROM ems_report_point_nitrogen rpd
LEFT JOIN ems_base_monitor_work_unit mwu on rpd.monitor_code = mwu.monitor_code
CROSS JOIN DT
WHERE 1 = 1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex
LEFT JOIN ems_base_work_unit wu
ON ex.work_unit_code = wu.work_unit_code
WHERE wu.parent_id = 0
GROUP BY ex.date
ORDER BY ex.date
</select>
</mapper> </mapper>

@ -124,4 +124,43 @@
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="selectWorkUnitTotalConsumption" resultType="java.util.HashMap">
SELECT WU.WORK_UNIT_CODE workUnitCode,
WU.WORK_UNIT_NAME workUnitName,
ISNULL(ex.expend, 0) expend
FROM ems_base_work_unit wu
LEFT JOIN
(SELECT mwu.work_unit_code, SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend
FROM ems_base_monitor_work_unit mwu
LEFT JOIN ems_report_point_steam rpd on rpd.monitor_code = mwu.monitor_code
WHERE 1=1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
group by mwu.work_unit_code) ex ON ex.work_unit_code = wu.work_unit_code
ORDER BY ex.expend DESC
</select>
<select id="selectWorkUnitDateConsumption" resultType="java.util.HashMap">
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
SELECT ex.date,
ISNULL(SUM(ex.expend), 0) expend
FROM (SELECT mwu.work_unit_code,
SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend,
LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB) date
FROM ems_report_point_steam rpd
LEFT JOIN ems_base_monitor_work_unit mwu on rpd.monitor_code = mwu.monitor_code
CROSS JOIN DT
WHERE 1 = 1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex
LEFT JOIN ems_base_work_unit wu
ON ex.work_unit_code = wu.work_unit_code
WHERE wu.parent_id = 0
GROUP BY ex.date
ORDER BY ex.date
</select>
</mapper> </mapper>

@ -120,4 +120,43 @@
#{objId} #{objId}
</foreach> </foreach>
</delete> </delete>
<select id="selectWorkUnitTotalConsumption" resultType="java.util.HashMap">
SELECT WU.WORK_UNIT_CODE workUnitCode,
WU.WORK_UNIT_NAME workUnitName,
ISNULL(ex.expend, 0) expend
FROM ems_base_work_unit wu
LEFT JOIN
(SELECT mwu.work_unit_code, SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend
FROM ems_base_monitor_work_unit mwu
LEFT JOIN ems_report_point_water rpd on rpd.monitor_code = mwu.monitor_code
WHERE 1=1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
group by mwu.work_unit_code) ex ON ex.work_unit_code = wu.work_unit_code
ORDER BY ex.expend DESC
</select>
<select id="selectWorkUnitDateConsumption" resultType="java.util.HashMap">
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
SELECT ex.date,
ISNULL(SUM(ex.expend), 0) expend
FROM (SELECT mwu.work_unit_code,
SUM(rpd.expend * (IIF(mwu.formula_mode = 0, 1, 0)) * mwu.proportion) expend,
LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB) date
FROM ems_report_point_water rpd
LEFT JOIN ems_base_monitor_work_unit mwu on rpd.monitor_code = mwu.monitor_code
CROSS JOIN DT
WHERE 1 = 1
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
AND FORMAT(rpd.begin_time, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if>
GROUP BY mwu.work_unit_code, LEFT(CONVERT(VARCHAR, rpd.begin_time, 120), DT.TIMESUB)) ex
LEFT JOIN ems_base_work_unit wu
ON ex.work_unit_code = wu.work_unit_code
WHERE wu.parent_id = 0
GROUP BY ex.date
ORDER BY ex.date
</select>
</mapper> </mapper>
Loading…
Cancel
Save