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

maser
yinq 2 months ago
parent 17c66730e1
commit 11efd452d3

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

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

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

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

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

@ -42,6 +42,17 @@ public class EmsBoardController extends BaseController {
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
@ -119,5 +130,16 @@ public class EmsBoardController extends BaseController {
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
*/
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointAir;
/**
@ -58,5 +60,19 @@ public interface EmsReportPointAirMapper
* @return
*/
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointNitrogen;
/**
@ -58,5 +60,19 @@ public interface EmsReportPointNitrogenMapper
* @return
*/
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointSteam;
@ -58,4 +60,18 @@ public interface EmsReportPointSteamMapper {
* @return
*/
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.os.ems.report.domain.EmsReportPointWater;
/**
@ -58,4 +60,18 @@ public interface EmsReportPointWaterMapper
* @return
*/
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);
/**
* 线
* @param hashMap
* @return
*/
List<RealTimeDataBo> realTimeDataByEnergy(Map hashMap);
/**
* -
* @param hashMap
@ -72,4 +79,11 @@ public interface IEmsBoardService {
* @return
*/
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.RealTimeDataBo;
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.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.IEmsReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -58,6 +65,18 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Autowired
private EmsReportPointDnbMapper emsReportPointDnbMapper;
@Autowired
private EmsReportPointWaterMapper emsReportPointWaterMapper;
@Autowired
private EmsReportPointSteamMapper emsReportPointSteamMapper;
@Autowired
private EmsReportPointAirMapper emsReportPointAirMapper;
@Autowired
private EmsReportPointNitrogenMapper emsReportPointNitrogenMapper;
@Autowired
private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper;
@ -73,6 +92,9 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Autowired
private EmsReportMapper emsReportMapper;
@Autowired
private IEmsReportService emsReportService;
/**
*
*
@ -101,6 +123,27 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
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
@ -114,6 +157,7 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
List<EmsBaseCollectDeviceInfo> deviceInfoList = emsBaseCollectDeviceInfoMapper.selectEmsBaseCollectDeviceInfoList(deviceInfo);
EmsBaseMonitorInfo monitorInfo = new EmsBaseMonitorInfo();
monitorInfo.setIsAmmeter(EmsConstants.EMS_IS_AMMETER_NO);
monitorInfo.setMonitorStatus(0L);
List<EmsBaseMonitorInfo> monitorInfoList = emsBaseMonitorInfoMapper.selectEmsBaseMonitorInfoList(monitorInfo);
Long dnbSum = 0L;
Long waterSum = 0L;
@ -163,6 +207,14 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
hashMap.put("endCollectTime", monthEnd);
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
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("statistics", reportList);
@ -177,7 +229,46 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override
public HashMap<String, Object> peaksValleysConsumption(Map 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);
return result;
}
@ -190,16 +281,32 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override
public HashMap<String, Object> fiveConsumptionStatistics(Map hashMap) {
HashMap<String, Object> result = new LinkedHashMap<>();
result.put("dnbSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random()))));
result.put("waterSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random()))));
result.put("steamSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random()))));
result.put("airSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random()))));
result.put("nitrogenSum", new BigDecimal(String.format("%.2f", Math.random() * Math.round(10000 * Math.random()))));
result.put("dnbRate", new BigDecimal(String.format("%.2f", 100 * Math.random())));
result.put("waterRate", new BigDecimal(String.format("%.2f", 100 * Math.random())));
result.put("steamRate", new BigDecimal(String.format("%.2f", -100 * Math.random())));
result.put("airRate", new BigDecimal(String.format("%.2f", 100 * Math.random())));
result.put("nitrogenRate", new BigDecimal(String.format("%.2f", -100 * Math.random())));
Map<String, String> dateTimeRanges = DateUtils.getDateTimeRanges();
String todayStart = dateTimeRanges.get("todayStart");
String currentTime = dateTimeRanges.get("currentTime");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String yesterdayStart = LocalDateTime.parse(todayStart, formatter).minusDays(1).format(formatter);
String yesterdayCurrentTime = LocalDateTime.parse(currentTime, formatter).minusDays(1).format(formatter);
Map<String, BigDecimal> currentMap = getTodayConsumptionMap(todayStart, currentTime);
Map<String, BigDecimal> yesterdayMap = getTodayConsumptionMap(yesterdayStart, yesterdayCurrentTime);
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;
}
@ -238,6 +345,14 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
}
if (Objects.equals(monitorType, EmsConstants.EMS_ENERGY_TYPE_DNB)) {
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);
return result;
@ -260,12 +375,33 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
@Override
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();
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<>();
query.put("monitorType", monitorType);
query.put("beginCollectTime", dateTimeRanges.get("todayStart"));
query.put("endCollectTime", dateTimeRanges.get("currentTime"));
List<Map<String, Object>> latestRows = emsReportMapper.selectWorkshopLatestRows(query);
List<Map<String, Object>> consumptionList = emsReportMapper.selectWorkshopTodayConsumption(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")));
}
LinkedHashMap<String, Map<String, Object>> colMap = new LinkedHashMap<>();
colMap.put(EmsConstants.EMS_ENERGY_TYPE_DNB, createColumn(EmsConstants.EMS_ENERGY_TYPE_DNB, "电", "kWh", consumptionMap));
colMap.put(EmsConstants.EMS_ENERGY_TYPE_WATER, createColumn(EmsConstants.EMS_ENERGY_TYPE_WATER, "水", "m³", consumptionMap));
colMap.put(EmsConstants.EMS_ENERGY_TYPE_STEAM, createColumn(EmsConstants.EMS_ENERGY_TYPE_STEAM, "蒸汽", "t", consumptionMap));
colMap.put(EmsConstants.EMS_ENERGY_TYPE_Air, createColumn(EmsConstants.EMS_ENERGY_TYPE_Air, "压缩空气", "m³", consumptionMap));
colMap.put(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, createColumn(EmsConstants.EMS_ENERGY_TYPE_NITROGEN, "氮气", "m³", consumptionMap));
Map<String, Object> column = createColumn(
monitorType,
getEnergyName(monitorType),
getEnergyUnit(monitorType),
consumptionMap
);
@SuppressWarnings("unchecked")
List<Map<String, Object>> rows = (List<Map<String, Object>>) column.get("rows");
for (Map<String, Object> row : latestRows) {
String type = String.valueOf(row.get("monitorType"));
Map<String, Object> col = colMap.get(type);
if (col == null) {
if (!Objects.equals(type, monitorType)) {
continue;
}
String code = String.valueOf(row.get("monitorCode"));
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);
}
result.put("columns", new ArrayList<>(colMap.values()));
result.put("column", column);
result.put("trend24h", build24hTrendByDevice(monitorType, dateTimeRanges.get("currentTime")));
return result;
}
@ -317,6 +452,133 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
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) {
if (value == null) {
return BigDecimal.ZERO;
@ -327,5 +589,28 @@ public class EmsBoardServiceImpl implements IEmsBoardService {
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,
ebmi.monitor_name monitorName,
ebmi.monitor_type monitorType,
ebmi.is_ammeter isAmmeter,
rk.collect_time collectTime,
rk.flux_flow fluxFlow,
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>
<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 ebli.parent_id, ebli.obj_id
</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>

@ -186,10 +186,41 @@
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 ebli.parent_id, ebli.obj_id
</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>

@ -122,6 +122,7 @@
ebli.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,
@ -138,7 +139,34 @@
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 ebli.parent_id, ebli.obj_id
</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>

@ -134,6 +134,7 @@
ebli.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,
@ -150,8 +151,35 @@
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 ebli.parent_id, ebli.obj_id
</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>

@ -101,6 +101,7 @@
ebli.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
@ -114,9 +115,33 @@
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 ebli.parent_id, ebli.obj_id
</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>

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

@ -120,4 +120,43 @@
#{objId}
</foreach>
</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>

@ -187,7 +187,7 @@
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 = 1
WHERE wu.parent_id = 0
GROUP BY ex.date
ORDER BY ex.date
</select>

@ -120,4 +120,43 @@
#{objId}
</foreach>
</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>

@ -124,4 +124,43 @@
#{objId}
</foreach>
</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>

@ -120,4 +120,43 @@
#{objId}
</foreach>
</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>
Loading…
Cancel
Save