Browse Source

1、广合二厂热回收系统:设备热量查询接口、设备组热量查询接口

dev_gh_ers
25604 7 days ago
parent
commit
e5e5cee85a
  1. 4
      mh-admin/src/main/java/com/mh/MHRunner.java
  2. 8
      mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyConsumptionController.java
  3. 8
      mh-admin/src/main/java/com/mh/web/controller/space/BuildingInfoController.java
  4. 10
      mh-admin/src/main/resources/application-dev.yml
  5. 2
      mh-admin/src/main/resources/application-druid.yml
  6. 10
      mh-admin/src/main/resources/application-prod.yml
  7. 10
      mh-admin/src/main/resources/application-test.yml
  8. 2
      mh-admin/src/main/resources/application.yml
  9. 14
      mh-common/src/main/java/com/mh/common/core/domain/vo/EnergyConsumptionVO.java
  10. 2
      mh-quartz/src/main/java/com/mh/quartz/task/HotWaterTask.java
  11. 84
      mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java
  12. 4
      mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java
  13. 5
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  14. 2
      mh-system/src/main/java/com/mh/system/service/energy/IEnergyQueryService.java
  15. 2
      mh-system/src/main/java/com/mh/system/service/energy/IEnergyService.java
  16. 2
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java
  17. 4
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java
  18. 107
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyServiceImpl.java
  19. 243
      mh-system/src/main/resources/mapper/system/EnergyMapper.xml

4
mh-admin/src/main/java/com/mh/MHRunner.java

@ -45,9 +45,9 @@ public class MHRunner implements ApplicationRunner {
// 初始化mqtt订阅记录
initializeMqttSubscription();
// 生成DTU采集参数
createDtuCollectionParams();
// createDtuCollectionParams();
// 启动netty服务端
startNettyServer();
// startNettyServer();
}
private void startNettyServer() {

8
mh-admin/src/main/java/com/mh/web/controller/energy/SysEnergyConsumptionController.java

@ -77,7 +77,13 @@ public class SysEnergyConsumptionController extends BaseController {
@PostMapping("/device")
public AjaxResult device(@RequestBody EnergyConsumptionVO vo) {
DateUtils.energyDateChange(vo);
return energyService.device(vo);
if (vo.getSystemType().equals("0")) {
// 冷源系统
return energyService.device(vo);
} else {
// 热回收系统
return energyService.deviceERS(vo);
}
}
}

8
mh-admin/src/main/java/com/mh/web/controller/space/BuildingInfoController.java

@ -94,11 +94,13 @@ public class BuildingInfoController extends BaseController {
* 获取楼栋管理列表内容数据
*/
@GetMapping("/hot_list")
public TableDataInfo hotWaterList()
public TableDataInfo hotWaterList(@RequestParam("systemType") String systemType)
{
List<Map<String, Object>> list = energyQueryService.queryFloorInfo();
List<Map<String, Object>> list = energyQueryService.queryFloorInfo(systemType);
// 在当前list首个坐标加个值
list.addFirst(Map.of("id", "所有", "building_name", "所有"));
if (systemType.equals("1")) {
list.addFirst(Map.of("id", "所有", "building_name", "所有"));
}
return getDataTable(list);
}

10
mh-admin/src/main/resources/application-dev.yml

@ -1,11 +1,11 @@
# 项目相关配置
mh:
# 名称
name: mz
name: gh_ers
# 版本
version: 1.0.0
# 版权年份
copyrightYear: 2024
copyrightYear: 2026
# 文件路径 示例( Windows配置D:/mh/uploadPath,Linux配置 /home/mh/uploadPath)
profile: D:/mh/uploadPath
# 获取ip地址开关
@ -63,7 +63,7 @@ spring:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
database: 1
# 密码
password:
# 连接超时时间
@ -98,7 +98,7 @@ spring:
# 主库数据源
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs
url: jdbc:postgresql://127.0.0.1:5432/eemcs_gh_ers_dev
# url: jdbc:postgresql://106.55.173.225:5505/eemcs
username: postgres
password: mh@803
@ -200,7 +200,7 @@ mqttSpring:
# port: 1883
# username: sa
# password: sa123
client-id: mqtt_mz_producer_dev
client-id: mqtt_gh_ers_producer_dev
# If the protocol is ws/wss, this value is required.
path:
# Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".

2
mh-admin/src/main/resources/application-druid.yml

@ -7,7 +7,7 @@ spring:
# 主库数据源
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw
url: jdbc:postgresql://127.0.0.1:5432/eemcs_gh_ers_dev
# url: jdbc:postgresql://127.0.0.1:5432/eemcs
username: postgres
password: mh@803

10
mh-admin/src/main/resources/application-prod.yml

@ -1,11 +1,11 @@
# 项目相关配置
mh:
# 名称
name: mz
name: gh_ers
# 版本
version: 1.0.0
# 版权年份
copyrightYear: 2024
copyrightYear: 2026
# 文件路径 示例( Windows配置D:/mh/uploadPath,Linux配置 /home/mh/uploadPath)
profile: E:/mh/uploadPath
# 获取ip地址开关
@ -63,7 +63,7 @@ spring:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 14
database: 1
# 密码
password:
# 连接超时时间
@ -98,7 +98,7 @@ spring:
# 主库数据源
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5505/eemcs
url: jdbc:postgresql://127.0.0.1:5505/eemcs_gh_ers
# url: jdbc:postgresql://127.0.0.1:5505/eemcs
username: postgres
password: mhtech@803
@ -195,7 +195,7 @@ mqttSpring:
port: 1883
username: sa
password: sa123
client-id: eemcs_mz_mqtt_pro
client-id: eemcs_gh_ers_mqtt_pro
# If the protocol is ws/wss, this value is required.
path:
# Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".

10
mh-admin/src/main/resources/application-test.yml

@ -1,11 +1,11 @@
# 项目相关配置
mh:
# 名称
name: MH
name: gh_ers
# 版本
version: 1.0.0
# 版权年份
copyrightYear: 2024
copyrightYear: 2026
# 文件路径 示例( Windows配置D:/mh/uploadPath,Linux配置 /home/mh/uploadPath)
profile: D:/mh/uploadPath
# 获取ip地址开关
@ -63,7 +63,7 @@ spring:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
database: 1
# 密码
password:
# 连接超时时间
@ -98,7 +98,7 @@ spring:
# 主库数据源
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://106.55.173.225:5505/eemcs_hw
url: jdbc:postgresql://106.55.173.225:5505/eemcs_gh_ers_dev
username: postgres
password: mhtech@803
# 从库数据源
@ -194,7 +194,7 @@ mqttSpring:
port: 2883
username: mh
password: mhtech@803
client-id: mqtt_mz_producer_dev
client-id: mqtt_gh_ers_producer_test
# If the protocol is ws/wss, this value is required.
path:
# Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".

2
mh-admin/src/main/resources/application.yml

@ -1,6 +1,6 @@
spring:
profiles:
active: prod
active: dev
# 用户配置
user:

14
mh-common/src/main/java/com/mh/common/core/domain/vo/EnergyConsumptionVO.java

@ -45,6 +45,20 @@ public class EnergyConsumptionVO implements Serializable {
*/
private String systemType;
/**
* 房间id
* @return
*/
private String houseId;
public String getHouseId() {
return houseId;
}
public void setHouseId(String houseId) {
this.houseId = houseId;
}
public String getSystemType() {
return systemType;
}

2
mh-quartz/src/main/java/com/mh/quartz/task/HotWaterTask.java

@ -180,7 +180,7 @@ public class HotWaterTask {
*/
public void calcEnergyDataDetail(String lastHourTime) {
//TODO 1、查询sql获取对应计算的楼层id、楼层名称用来当作楼栋id和楼栋名称
List<Map<String, Object>> floorInfos = energyQueryService.queryFloorInfo();
List<Map<String, Object>> floorInfos = energyQueryService.queryFloorInfo("1");
// 开始遍历
if (StringUtils.isEmpty(lastHourTime)) {
LocalDateTime now = LocalDateTime.now();

84
mh-system/src/main/java/com/mh/system/mapper/energy/EnergyMapper.java

@ -1,6 +1,7 @@
package com.mh.system.mapper.energy;
import com.mh.common.core.domain.entity.ConsumptionAnalyze;
import com.mh.common.core.domain.entity.CpmSpaceRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -19,10 +20,11 @@ public interface EnergyMapper {
/**
* 跨表查询操作
* @param startTime 开始时间
* @param endTime 结束时间
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param lastTableName 上一个表名
* @param curTableName 当前表名
* @param curTableName 当前表名
* @return
*/
@Select("<script>" +
@ -140,10 +142,11 @@ public interface EnergyMapper {
/**
* 单表查询操作
* @param startTime 开始时间
* @param endTime 结束时间
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param lastTableName 上一个表名
* @param curTableName 当前表名
* @param curTableName 当前表名
* @return
*/
@Select("<script>" +
@ -211,6 +214,7 @@ public interface EnergyMapper {
/**
* 查询能耗分析同比
*
* @param startTime
* @param endTime
* @param lastTableName
@ -235,6 +239,7 @@ public interface EnergyMapper {
/**
* 查询能耗分析同比
*
* @param startTime
* @param endTime
* @param lastTableName
@ -259,6 +264,7 @@ public interface EnergyMapper {
/**
* 查询能耗分析环比查询类型是monthyear
*
* @param startTime
* @param endTime
* @param yoyStartTime
@ -281,6 +287,7 @@ public interface EnergyMapper {
/**
* 单表查询能耗分析环比查询类型是hourday
*
* @param startTime
* @param endTime
* @param yoyStartTime
@ -303,12 +310,13 @@ public interface EnergyMapper {
/**
* 多表查询能耗分析环比查询类型是hourday
*
* @param startTime
* @param endTime
* @param yoyStartTime
* @param yoyEndTime
* @param tableName1 上一年的表
* @param tableName2 今年的表
* @param tableName1 上一年的表
* @param tableName2 今年的表
* @param dateLen
* @param paramType
* @param timeType
@ -327,6 +335,7 @@ public interface EnergyMapper {
/**
* 查询各个机房设备的用电量查询月
*
* @param startTime
* @param endTime
* @param lastTableName
@ -342,8 +351,47 @@ public interface EnergyMapper {
@Param("len") String dateLen,
@Param("deviceType") String deviceType);
/**
* 查询各个设备组合的用热量查询月
*
* @param startTime
* @param endTime
* @param lastTableName
* @param curTableName
* @param dateLen
* @param cpmSpaceRelationList
* @return
*/
List<ConsumptionAnalyze> queryDeviceERSOneTable(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("lastTableName") String lastTableName,
@Param("curTableName") String curTableName,
@Param("len") String dateLen,
@Param("cpmSpaceRelationList") List<CpmSpaceRelation> cpmSpaceRelationList,
@Param("systemType") String systemType);
/**
* 查询各个机房设备的用电量查询小时
*
* @param startTime
* @param endTime
* @param lastTableName
* @param curTableName
* @param dateLen
* @param cpmSpaceRelationList
* @return
*/
List<ConsumptionAnalyze> queryDeviceERSManyTable(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("lastTableName") String lastTableName,
@Param("curTableName") String curTableName,
@Param("len") String dateLen,
@Param("cpmSpaceRelationList") List<CpmSpaceRelation> cpmSpaceRelationList,
@Param("systemType") String systemType);
/**
* 查询各个机房设备的用电量查询小时
*
* @param startTime
* @param endTime
* @param lastTableName
@ -362,6 +410,7 @@ public interface EnergyMapper {
/**
* 查询系统分析折线图
*
* @param curTable
* @param curCopTable
* @param startTime
@ -375,6 +424,7 @@ public interface EnergyMapper {
/**
* 查询系统分析折线图
*
* @param lastTable
* @param curTable
* @param lastCopTable
@ -392,6 +442,7 @@ public interface EnergyMapper {
/**
* 查询各个设备的折线图数据
*
* @param startTime
* @param endTime
* @param lastTableName
@ -406,6 +457,23 @@ public interface EnergyMapper {
@Param("deviceType") String deviceType,
@Param("systemType") String systemType);
/**
* 查询各个设备的折线图数据
*
* @param startTime
* @param endTime
* @param lastTableName
* @param curTableName
* @param cpmSpaceRelationList
* @return
*/
List<ConsumptionAnalyze> queryDeviceERSLineManyTable(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("lastTableName") String lastTableName,
@Param("curTableName") String curTableName,
@Param("cpmSpaceRelationList") List<CpmSpaceRelation> cpmSpaceRelationList,
@Param("systemType") String systemType);
@Select("select isnull(sum(calc_value),0) from ${tableName} " +
" where device_type = 'cloud' " +
" and device_code in (select device_code from device_manage where grade >=0 and grade < 10) " +

4
mh-system/src/main/java/com/mh/system/mapper/energy/HotEnergyQueryMapper.java

@ -34,7 +34,7 @@ public interface HotEnergyQueryMapper {
" join area_info ai on " +
" bi.area_id = ai.id " +
" where " +
" ai.system_type = '1' " +
" ai.system_type = #{systemType} " +
" ) t1 " +
"join cpm_space_relation csr on " +
" csr.floor_id = t1.id " +
@ -42,7 +42,7 @@ public interface HotEnergyQueryMapper {
" csr.house_id = '' " +
"group by " +
" t1.id,t1.floor_name order by building_name")
List<Map<String, Object>> queryFloorInfo();
List<Map<String, Object>> queryFloorInfo(@Param("systemType") String systemType);
@Select("<script>" +
"select " +

5
mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

@ -357,6 +357,10 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
if (!StringUtils.isEmpty(communicationParams.getRemark())) {
queryWrapper.like("remark", communicationParams.getRemark());
}
// 只查询累积量
if (communicationParams.getGrade() != null) {
queryWrapper.eq("grade", communicationParams.getGrade());
}
// 添加时间范围
if (communicationParams.getParams() != null && !communicationParams.getParams().isEmpty()) {
String beginTimeStr = (String) communicationParams.getParams().get("beginTime");
@ -370,6 +374,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
queryWrapper.between("create_time", java.sql.Date.valueOf(beginTime), java.sql.Date.valueOf(endTime));
}
}
queryWrapper.orderByAsc("order_num");
queryWrapper.orderByDesc("cur_time");
return collectionParamsManageMapper.selectList(queryWrapper);
}

2
mh-system/src/main/java/com/mh/system/service/energy/IEnergyQueryService.java

@ -28,7 +28,7 @@ public interface IEnergyQueryService {
AjaxResult deviceTypeQuery(EnergyQueryVO page);
List<Map<String, Object>> queryFloorInfo();
List<Map<String, Object>> queryFloorInfo(String systemType);
List<DataMonth> queryEnergyDatas(String tableName, String buildingId, String lastHourTime, String dateType);

2
mh-system/src/main/java/com/mh/system/service/energy/IEnergyService.java

@ -26,4 +26,6 @@ public interface IEnergyService {
AjaxResult sys(EnergyConsumptionVO vo);
AjaxResult chillerLine(EnergyQueryVO vo);
AjaxResult deviceERS(EnergyConsumptionVO vo);
}

2
mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java

@ -245,6 +245,8 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService {
map.put("timeStr", timeStr.subList(startIndex, endIndex));
map.put("dataList", columnData);
}
// 添加总条数
map.put("total",timeStr.size());
return new ArrayList<>(map.entrySet());
}

4
mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java

@ -304,8 +304,8 @@ public class EnergyQueryServiceImpl implements IEnergyQueryService {
}
@Override
public List<Map<String, Object>> queryFloorInfo() {
return hotEnergyQueryMapper.queryFloorInfo();
public List<Map<String, Object>> queryFloorInfo(String systemType) {
return hotEnergyQueryMapper.queryFloorInfo(systemType);
}
@Override

107
mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyServiceImpl.java

@ -6,6 +6,7 @@ import com.mh.common.core.domain.ColumnData;
import com.mh.common.core.domain.ColumnFilter;
import com.mh.common.core.domain.dto.EnergyConsumptionDTO;
import com.mh.common.core.domain.entity.ConsumptionAnalyze;
import com.mh.common.core.domain.entity.CpmSpaceRelation;
import com.mh.common.core.domain.entity.DeviceTypeEnergy;
import com.mh.common.core.domain.vo.EnergyConsumptionVO;
import com.mh.common.core.domain.vo.EnergyQueryVO;
@ -15,8 +16,10 @@ import com.mh.common.utils.StringUtils;
import com.mh.common.utils.bean.BeanUtils;
import com.mh.system.mapper.energy.EnergyAnalyzeMapper;
import com.mh.system.mapper.energy.EnergyMapper;
import com.mh.system.mapper.space.CpmSpaceRelationMapper;
import com.mh.system.service.ISysDictDataService;
import com.mh.system.service.energy.IEnergyService;
import com.mh.system.service.space.ICpmSpaceRelationService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -51,6 +54,110 @@ public class EnergyServiceImpl implements IEnergyService {
@Resource
private ISysDictDataService iSysDictDataService;
@Resource
private CpmSpaceRelationMapper cpmSpaceRelationMapper;
@Override
public AjaxResult deviceERS(EnergyConsumptionVO vo) {
AtomicReference<String> lastTableName = new AtomicReference<>("data_" + vo.getTimeType());
AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType());
String timeType = vo.getTimeType();
String houseId = vo.getHouseId();
// 根据houseId获取参数类型id值
List<CpmSpaceRelation> cpmSpaceRelationList = cpmSpaceRelationMapper.selectListByHouseId(houseId);
if (cpmSpaceRelationList.isEmpty()) {
return AjaxResult.error("未查到设备组合信息");
}
ThreadPoolExecutor executor = EnergyThreadPoolService.getInstance();
CountDownLatch latch = new CountDownLatch(2);
List<Future<Map<String, Object>>> futures = new ArrayList<>();
futures.add(executor.submit(() -> {
List<ConsumptionAnalyze> consumptionAnalyzeEntities;
if ("month".equalsIgnoreCase(timeType) || "year".equalsIgnoreCase(timeType)) {
// 单表
consumptionAnalyzeEntities = energyMapper.queryDeviceERSOneTable(vo.getStartTime(), vo.getEndTime(), lastTableName.get(), curTableName.get(), getTimeLen(vo.getTimeType()), cpmSpaceRelationList, vo.getSystemType());
} else {
// 多表
lastTableName.set(lastTableName + vo.getStartTime().substring(0, 4));
curTableName.set(curTableName + vo.getEndTime().substring(0, 4));
consumptionAnalyzeEntities = energyMapper.queryDeviceERSManyTable(vo.getStartTime(), vo.getEndTime(), lastTableName.get(), curTableName.get(), getTimeLen(vo.getTimeType()), cpmSpaceRelationList, vo.getSystemType());
}
if (null == consumptionAnalyzeEntities || consumptionAnalyzeEntities.size() == 0) {
latch.countDown();
return null;
}
// 组装赋值
String[] timeStrArr = consumptionAnalyzeEntities.stream()
.map(ConsumptionAnalyze::getTimeStr)
.toArray(String[]::new);
String[] meterArr = consumptionAnalyzeEntities.stream()
.map(ConsumptionAnalyze::getCurValue)
.toArray(String[]::new);
Map<String, Object> map = new HashMap<>();
map.put("timeStrArr", timeStrArr);
map.put("meterArr", meterArr);
latch.countDown();
return map;
}));
futures.add(executor.submit(() -> {
// 折线图,都查询min表
// 多表
String lastTable = "data_min" + vo.getStartTime().substring(0, 4);
String curTable = "data_min" + vo.getEndTime().substring(0, 4);
List<ConsumptionAnalyze> consumptionAnalyzeEntities = energyMapper.queryDeviceERSLineManyTable(vo.getStartTime(), vo.getEndTime(), lastTable, curTable, cpmSpaceRelationList, vo.getSystemType());
if (null == consumptionAnalyzeEntities || consumptionAnalyzeEntities.size() == 0) {
latch.countDown();
return null;
}
// 组装赋值
String[] timeStrArr = consumptionAnalyzeEntities.stream()
.map(ConsumptionAnalyze::getTimeStr)
.toArray(String[]::new);
String[] meterArr = consumptionAnalyzeEntities.stream()
.map(ConsumptionAnalyze::getCurValue)
.toArray(String[]::new);
Map<String, Object> map = new HashMap<>();
map.put("timeStrLineArr", timeStrArr);
map.put("meterLineArr", meterArr);
latch.countDown();
return map;
}));
try {
latch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Map<String, Object> allData = new HashMap<>();
// 获取数据
for (Future<Map<String, Object>> future : futures) {
try {
Map<String, Object> map = future.get();
if (null != map) {
allData.putAll(map);
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
EnergyConsumptionDTO energyConsumptionDTO = new EnergyConsumptionDTO();
String[] titleArr = new String[]{"meter", "lineMeter"};
energyConsumptionDTO.setTitles(titleArr);
energyConsumptionDTO.setTimes((String[]) allData.get("timeStrArr"));
energyConsumptionDTO.setLineTimes((String[]) allData.get("timeStrLineArr"));
List<Map<String, Object>> listData = new ArrayList<>();
Map<String, Object> meter = new HashMap<>();
meter.put("meter", allData.get("meterArr"));
listData.add(meter);
Map<String, Object> lineMeter = new HashMap<>();
lineMeter.put("lineMeter", allData.get("meterLineArr"));
listData.add(lineMeter);
energyConsumptionDTO.setData(listData);
return AjaxResult.success(energyConsumptionDTO);
}
private static String[] getArrChillerLine(List<DeviceTypeEnergy> copLineData, String[] lineTimeStrArr) {
String[] lineCopArr = new String[lineTimeStrArr.length];
for (int i = 0; i < lineTimeStrArr.length; i++) {

243
mh-system/src/main/resources/mapper/system/EnergyMapper.xml

@ -763,6 +763,60 @@
order by timeStr
</select>
<select id="queryDeviceERSOneTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
select
SUM(coalesce(dm.calc_value, 0)) as curValue,
TO_CHAR(dm.cur_time,
<choose>
<when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
) as timeStr
from
${curTableName} dm
where
dm.cur_time >= #{startTime}::timestamp
and dm.cur_time &lt;= #{endTime}::timestamp
and dm.device_num in(
select
cpm.mt_num
from
collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where
dl.device_type = '6'
and cpm.system_type = #{systemType}
and cpm.is_use = '0'
and cpm.grade = 40
<if test="cpmSpaceRelationList != null and cpmSpaceRelationList.size() > 0">
and cpm.id in
<foreach collection="cpmSpaceRelationList" item="item" open="(" separator="," close=")">
#{item.cpmId}
</foreach>
</if>
group by
cpm.mt_num
)
group by
TO_CHAR(dm.cur_time,
<choose>
<when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
order by timeStr
</select>
<select id="queryDeviceManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
<if test="lastTableName != curTableName">
select
@ -865,6 +919,118 @@
order by timeStr
</select>
<select id="queryDeviceERSManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
<if test="lastTableName != curTableName">
select
SUM(coalesce(dm.calc_value, 0)) as curValue,
TO_CHAR(dm.cur_time,
<choose>
<when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
) as timeStr
from
${lastTableName} dm
where
dm.cur_time >= #{startTime}::timestamp
and dm.cur_time &lt;= #{endTime}::timestamp
and dm.device_num in(
select
cpm.mt_num
from
collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where
dl.device_type = '6'
<if test="systemType != null and systemType != ''">
and cpm.system_type = #{systemType}
</if>
and cpm.is_use = '0'
and cpm.grade = 40
<if test="cpmSpaceRelationList != null and cpmSpaceRelationList.size() > 0">
and cpm.id in
<foreach collection="cpmSpaceRelationList" item="item" open="(" separator="," close=")">
#{item.cpmId}
</foreach>
</if>
group by
cpm.mt_num
)
group by
TO_CHAR(dm.cur_time,
<choose>
<when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
)
union all
</if>
select
SUM(coalesce(dm.calc_value, 0)) as curValue,
TO_CHAR(dm.cur_time,
<choose>
<when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
) as timeStr
from
${curTableName} dm
where
dm.cur_time >= #{startTime}::timestamp
and dm.cur_time &lt;= #{endTime}::timestamp
and dm.device_num in(
select
cpm.mt_num
from
collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where
dl.device_type = '6'
<if test="systemType != null and systemType != ''">
and cpm.system_type = #{systemType}
</if>
and cpm.is_use = '0'
and cpm.grade = 40
<if test="cpmSpaceRelationList != null and cpmSpaceRelationList.size() > 0">
and cpm.id in
<foreach collection="cpmSpaceRelationList" item="item" open="(" separator="," close=")">
#{item.cpmId}
</foreach>
</if>
group by
cpm.mt_num
)
group by
TO_CHAR(dm.cur_time,
<choose><when test='len == 4'>'YYYY'</when>
<when test='len == 7'>'YYYY-MM'</when>
<when test='len == 10'>'YYYY-MM-DD'</when>
<when test='len == 13'>'YYYY-MM-DD HH24'</when>
<when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>
<otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>
</choose>
)
order by timeStr
</select>
<select id="queryLineDataSysByOne" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
select
sum(coalesce(calc_value,0)) as curValue,
@ -1093,4 +1259,81 @@
dm.cur_time
order by timeStr
</select>
<select id="queryDeviceERSLineManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
<if test="lastTableName != curTableName">
select
SUM(coalesce(dm.calc_value, 0)) as curValue,
dm.cur_time as timeStr
from
${lastTableName} dm
where
dm.cur_time >= #{startTime}::timestamp
and dm.cur_time &lt;= #{endTime}::timestamp
and dm.device_num in(
select
cpm.mt_num
from
collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where
dl.device_type = '6'
<if test="systemType != null and systemType != ''">
and cpm.system_type = #{systemType}
</if>
and cpm.is_use = '0'
and cpm.grade = 40
<if test="cpmSpaceRelationList != null and cpmSpaceRelationList.size() > 0">
and cpm.id in
<foreach collection="cpmSpaceRelationList" item="item" open="(" separator="," close=")">
#{item.cpmId}
</foreach>
</if>
group by
cpm.mt_num
)
group by
dm.cur_time
union all
</if>
select
SUM(coalesce(dm.calc_value, 0)) as curValue,
dm.cur_time as timeStr
from
${curTableName} dm
where
dm.cur_time >= #{startTime}::timestamp
and dm.cur_time &lt;= #{endTime}::timestamp
and dm.device_num in(
select
cpm.mt_num
from
collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where
dl.device_type = '6'
<if test="systemType != null and systemType != ''">
and cpm.system_type = #{systemType}
</if>
and cpm.is_use = '0'
and cpm.grade = 40
<if test="cpmSpaceRelationList != null and cpmSpaceRelationList.size() > 0">
and cpm.id in
<foreach collection="cpmSpaceRelationList" item="item" open="(" separator="," close=")">
#{item.cpmId}
</foreach>
</if>
group by
cpm.mt_num
)
group by
dm.cur_time
order by timeStr
</select>
</mapper>
Loading…
Cancel
Save