Browse Source

1、中央空调能耗管理:能源分析,能耗总览查询接口测试;

dev
mh 4 months ago
parent
commit
fecfb41985
  1. 6
      mh-admin/src/main/java/com/mh/web/controller/device/DeviceInOutManageController.java
  2. 35
      mh-common/src/main/java/com/mh/common/core/domain/vo/EnergyQueryVO.java
  3. 12
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  4. 172
      mh-system/src/main/java/com/mh/system/mapper/energy/EnergyAnalyzeMapper.java
  5. 78
      mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java
  6. 2
      mh-system/src/main/java/com/mh/system/service/device/IDeviceInOutManageService.java
  7. 15
      mh-system/src/main/java/com/mh/system/service/device/impl/DeviceInOutManageServiceImpl.java
  8. 14
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyAnalyzeServiceImpl.java
  9. 8
      mh-system/src/main/java/com/mh/system/service/energy/impl/EnergyQueryServiceImpl.java
  10. 267
      mh-system/src/main/resources/mapper/system/EnergyMapper.xml

6
mh-admin/src/main/java/com/mh/web/controller/device/DeviceInOutManageController.java

@ -56,11 +56,9 @@ public class DeviceInOutManageController extends BaseController {
@PreAuthorize("@ss.hasPermi('device:spareInOut:add')") @PreAuthorize("@ss.hasPermi('device:spareInOut:add')")
@Log(title = "备品/备件出入库管理流水记录管理", businessType = BusinessType.INSERT) @Log(title = "备品/备件出入库管理流水记录管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody DeviceInOutManage deviceInOutManage) public AjaxResult add(@Validated @RequestBody List<DeviceInOutManage> deviceInOutManage)
{ {
deviceInOutManage.setCreateBy(getUsername()); return toAjax(deviceInOutManageService.insertDeviceInOutManage(deviceInOutManage, getUsername()));
deviceInOutManage.setCreateTime(new Date());
return toAjax(deviceInOutManageService.insertDeviceInOutManage(deviceInOutManage));
} }
// /** // /**

35
mh-common/src/main/java/com/mh/common/core/domain/vo/EnergyQueryVO.java

@ -1,9 +1,11 @@
package com.mh.common.core.domain.vo; package com.mh.common.core.domain.vo;
import com.mh.common.core.domain.BaseEntity; import com.mh.common.core.domain.BaseEntity;
import com.mh.common.core.domain.ColumnFilter;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @author LJF * @author LJF
@ -41,6 +43,36 @@ public class EnergyQueryVO extends BaseEntity implements Serializable {
*/ */
private String paramType; private String paramType;
private List<ColumnFilter> searchParams;
private int pageNum;
private int pageSize;
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public List<ColumnFilter> getSearchParams() {
return searchParams;
}
public void setSearchParams(List<ColumnFilter> searchParams) {
this.searchParams = searchParams;
}
public String getTimeType() { public String getTimeType() {
return timeType; return timeType;
} }
@ -89,6 +121,9 @@ public class EnergyQueryVO extends BaseEntity implements Serializable {
.append("endTime", endTime) .append("endTime", endTime)
.append("deviceType", deviceType) .append("deviceType", deviceType)
.append("paramType", paramType) .append("paramType", paramType)
.append("searchParams", searchParams)
.append("pageNum", pageNum)
.append("pageSize", pageSize)
.toString(); .toString();
} }
} }

12
mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java

@ -50,9 +50,17 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
"</script>") "</script>")
List<CollectionParamsManage> getDeviceByOther(@Param("deviceNum") String deviceNum); List<CollectionParamsManage> getDeviceByOther(@Param("deviceNum") String deviceNum);
@Select("select count(1) from collection_params_manage where grade >= #{grade} and grade < #{grade}+20 and mt_type like concat('%',#{mtType},'%') ") @Select("select " +
" count(1) " +
"from " +
" collection_params_manage cpm " +
" join device_ledger dl " +
" on cpm.device_ledger_id = dl.id " +
" and dl.device_type = #{deviceType} " +
" and cpm.grade = #{grade} " +
" and cpm.mt_is_sum = 0")
int selectSummary(@Param("grade") int grade, int selectSummary(@Param("grade") int grade,
@Param("mtType") String deviceType); @Param("deviceType") String deviceType);
@Select("select id from collection_params_manage where mt_code = #{registerAddr} and mt_type = #{mtType} limit 1 ") @Select("select id from collection_params_manage where mt_code = #{registerAddr} and mt_type = #{mtType} limit 1 ")
String selectIdByMtCodeAndType(@Param("registerAddr") String registerAddr, String selectIdByMtCodeAndType(@Param("registerAddr") String registerAddr,

172
mh-system/src/main/java/com/mh/system/mapper/energy/EnergyAnalyzeMapper.java

@ -122,32 +122,44 @@ public interface EnergyAnalyzeMapper {
@Param("paramType") String paramType); @Param("paramType") String paramType);
@Select("<script>" + @Select("<script>" +
"select " + "SELECT " +
" sum(isnull(dh.calc_value, 0)) as calcValue, " + " SUM(COALESCE(dh.calc_value, 0)) AS calcValue, " +
" convert(varchar(${len}), " + " TO_CHAR(dh.cur_time, " +
" dh.cur_time, " + " <choose>" +
" 120) as timeStr, " + " <when test='len == 4'>'YYYY'</when>" +
" dh.device_num as deviceNum, " + " <when test='len == 7'>'YYYY-MM'</when>" +
" dm.remark " + " <when test='len == 10'>'YYYY-MM-DD'</when>" +
"from " + " <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, " +
" dh.device_num AS deviceNum, " +
" dm.other_name as remark " +
"FROM " +
" ${lastTableName} dh " + " ${lastTableName} dh " +
"join device_manage dm " + "JOIN collection_params_manage dm ON dh.device_num = dm.mt_num " +
"on " + "WHERE " +
" dh.device_num = dm.device_num " + " dh.cur_time &gt;= #{startTime}::timestamp " +
"where " + " AND dh.cur_time &lt;= #{endTime}::timestamp " +
" dh.cur_time >= #{startTime} " + " AND dh.device_num IN " +
" and dh.cur_time &lt;= #{endTime} " + " <foreach collection='params' item='item' open='(' separator=',' close=')'>" +
" and dh.device_num in " +
"<foreach collection='params' item='item' open='(' separator=',' close=')'>" +
" #{item} " + " #{item} " +
"</foreach>" + " </foreach> " +
"group by " + "GROUP BY " +
" convert(varchar(${len}), " + " TO_CHAR(dh.cur_time, " +
" dh.cur_time, " + " <choose>" +
" 120), " + " <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>" +
" ), " +
" dh.device_num, " + " dh.device_num, " +
" dm.remark " + " dm.other_name " +
"</script>" ) "</script>")
List<DeviceTypeEnergy> queryDeviceOneTable(@Param("startTime") String startTime, List<DeviceTypeEnergy> queryDeviceOneTable(@Param("startTime") String startTime,
@Param("endTime") String endTime, @Param("endTime") String endTime,
@Param("lastTableName") String lastTableName, @Param("lastTableName") String lastTableName,
@ -156,57 +168,81 @@ public interface EnergyAnalyzeMapper {
@Param("params") List<Object> params); @Param("params") List<Object> params);
@Select("<script>" + @Select("<script>" +
"select " + "SELECT " +
" sum(isnull(dh.calc_value, 0)) as calcValue, " + " SUM(COALESCE(dh.calc_value, 0)) AS calcValue, " +
" convert(varchar(${len}), " + " TO_CHAR(dh.cur_time, " +
" dh.cur_time, " + " <choose>" +
" 120) as timeStr, " + " <when test='len == 4'>'YYYY'</when>" +
" dh.device_num as deviceNum, " + " <when test='len == 7'>'YYYY-MM'</when>" +
" dm.remark " + " <when test='len == 10'>'YYYY-MM-DD'</when>" +
"from " + " <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, " +
" dh.device_num AS deviceNum, " +
" dm.other_name as remark " +
"FROM " +
" ${lastTableName} dh " + " ${lastTableName} dh " +
"join device_manage dm " + "JOIN collection_params_manage dm ON dh.device_num = dm.mt_num " +
"on " + "WHERE " +
" dh.device_num = dm.device_num " + " dh.cur_time &gt;= #{startTime}::timestamp " +
"where " + " AND dh.cur_time &lt;= #{endTime}::timestamp " +
" dh.cur_time >= #{startTime} " + " AND dh.device_num IN " +
" and dh.cur_time &lt;= #{endTime} " + " <foreach collection='params' item='item' open='(' separator=',' close=')'>" +
" and dh.device_num in " + " #{item} " +
"<foreach collection='params' item='item' open='(' separator=',' close=')'>" + " </foreach> " +
" #{item.value} " + "GROUP BY " +
"</foreach>" + " TO_CHAR(dh.cur_time, " +
"group by " + " <choose>" +
" convert(varchar(${len}), " + " <when test='len == 4'>'YYYY'</when>" +
" dh.cur_time, " + " <when test='len == 7'>'YYYY-MM'</when>" +
" 120), " + " <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>" +
" ), " +
" dh.device_num, " + " dh.device_num, " +
" dm.remark " + " dm.other_name " +
"union all " + "union all " +
"select " + "SELECT " +
" sum(isnull(dh.calc_value, 0)) as calcValue, " + " SUM(COALESCE(dh.calc_value, 0)) AS calcValue, " +
" convert(varchar(${len}), " + " TO_CHAR(dh.cur_time, " +
" dh.cur_time, " + " <choose>" +
" 120) as timeStr, " + " <when test='len == 4'>'YYYY'</when>" +
" dh.device_num as deviceNum, " + " <when test='len == 7'>'YYYY-MM'</when>" +
" dm.remark " + " <when test='len == 10'>'YYYY-MM-DD'</when>" +
"from " + " <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, " +
" dh.device_num AS deviceNum, " +
" dm.other_name as remark " +
"FROM " +
" ${curTableName} dh " + " ${curTableName} dh " +
"join device_manage dm " + "JOIN collection_params_manage dm ON dh.device_num = dm.mt_num " +
"on " + "WHERE " +
" dh.device_num = dm.device_num " + " dh.cur_time &gt;= #{startTime}::timestamp " +
"where " + " AND dh.cur_time &lt;= #{endTime}::timestamp " +
" dh.cur_time >= #{startTime} " + " AND dh.device_num IN " +
" and dh.cur_time &lt;= #{endTime} " + " <foreach collection='params' item='item' open='(' separator=',' close=')'>" +
" and dh.device_num in " +
"<foreach collection='params' item='item' open='(' separator=',' close=')'>" +
" #{item} " + " #{item} " +
"</foreach>" + " </foreach> " +
"group by " + "GROUP BY " +
" convert(varchar(${len}), " + " TO_CHAR(dh.cur_time, " +
" dh.cur_time, " + " <choose>" +
" 120), " + " <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>" +
" ), " +
" dh.device_num, " + " dh.device_num, " +
" dm.remark " + " dm.other_name " +
"</script>" ) "</script>" )
List<DeviceTypeEnergy> queryDeviceManyTable(@Param("startTime") String startTime, List<DeviceTypeEnergy> queryDeviceManyTable(@Param("startTime") String startTime,
@Param("endTime") String endTime, @Param("endTime") String endTime,

78
mh-system/src/main/java/com/mh/system/mapper/energy/EnergyQueryMapper.java

@ -118,42 +118,52 @@ public interface EnergyQueryMapper {
* @return * @return
*/ */
@Select("<script>" + @Select("<script>" +
"select sum(calc_value) as curValue,device_type as deviceType,convert(varchar(${len}), cur_time, 120) as timeStr from ${lastTableName} dy " + "select " +
" where cur_time >= #{startTime} and cur_time &lt;= #{endTime} " + " sum(dm.calc_value) as curValue, " +
"<if test='paramType != null and paramType != \"\"'>" + " CASE dm.device_type " +
" and device_type = #{paramType}" + " WHEN '5' THEN 'meter' " +
"</if>" + " WHEN '6' THEN 'cloud' " +
"<if test='haveMeter==true and haveCloud == true'>" + " ELSE 'Unknown' " +
" and exists ( " + " END as deviceType," +
" 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 &gt;= #{startTime}::timestamp " +
" AND dm.cur_time &lt;= #{endTime}::timestamp " +
" and device_num in ( " +
" select " + " select " +
" 1 " + " device_num " +
" from " +
" device_manage " +
" where " +
" device_num = dy.device_num and grade &lt; 50 and grade >=40 and (device_type like '%meter%' or device_type like '%cloud%') " +
" )" +
"</if>" +
"<if test='haveCloud==true and haveMeter==false'>" +
" and exists ( " +
" select " +
" 1 " +
" from " + " from " +
" device_manage " + " collection_params_manage cpm " +
" where " + " join device_ledger dl " +
" device_num = dy.device_num and grade &lt; 50 and grade >=40 and device_type like '%cloud%' " + "on " +
" )" + " cpm.device_ledger_id = dl.id " +
"</if>" + " and dl.device_type in ('5', '6') " +
"<if test='haveCloud==false and haveMeter==true'>" + ") " +
" and exists ( " + "group by " +
" select " + " device_type, " +
" 1 " + " TO_CHAR(dm.cur_time, " +
" from " + " <choose>" +
" device_manage " + " <when test='len == 4'>'YYYY'</when>" +
" where " + " <when test='len == 7'>'YYYY-MM'</when>" +
" device_num = dy.device_num and grade &lt; 50 and grade >=40 and device_type like '%meter%' " + " <when test='len == 10'>'YYYY-MM-DD'</when>" +
" )" + " <when test='len == 13'>'YYYY-MM-DD HH24'</when>" +
"</if>" + " <when test='len == 16'>'YYYY-MM-DD HH24:MI'</when>" +
" group by device_type,convert(varchar(${len}), cur_time, 120)" + " <otherwise>'YYYY-MM-DD HH24:MI:SS'</otherwise>" +
" </choose>" +
" ) " +
"order by " +
" timeStr " +
"</script>") "</script>")
List<ConsumptionAnalyze> queryOneTable(@Param("startTime") String startTime, List<ConsumptionAnalyze> queryOneTable(@Param("startTime") String startTime,
@Param("endTime") String endTime, @Param("endTime") String endTime,

2
mh-system/src/main/java/com/mh/system/service/device/IDeviceInOutManageService.java

@ -17,7 +17,7 @@ public interface IDeviceInOutManageService {
DeviceInOutManage selectDeviceInOutManageById(String spareId); DeviceInOutManage selectDeviceInOutManageById(String spareId);
int insertDeviceInOutManage(DeviceInOutManage deviceInOutManage); int insertDeviceInOutManage(List<DeviceInOutManage> deviceInOutManage, String createBy);
int updateDeviceInOutManage(DeviceInOutManage deviceInOutManage); int updateDeviceInOutManage(DeviceInOutManage deviceInOutManage);

15
mh-system/src/main/java/com/mh/system/service/device/impl/DeviceInOutManageServiceImpl.java

@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -71,7 +72,12 @@ public class DeviceInOutManageServiceImpl implements IDeviceInOutManageService {
@Transactional @Transactional
@Override @Override
public int insertDeviceInOutManage(DeviceInOutManage deviceInOutManage) { public int insertDeviceInOutManage(List<DeviceInOutManage> deviceInOutManageList, String createBy) {
Date date = new Date();
int result = 0;
for (DeviceInOutManage deviceInOutManage : deviceInOutManageList) {
deviceInOutManage.setCreateBy(createBy);
deviceInOutManage.setCreateTime(date);
// 获取当前库存量 // 获取当前库存量
String sparePartsId = deviceInOutManage.getSparePartsId(); String sparePartsId = deviceInOutManage.getSparePartsId();
SparePartsManage sparePartsManage = sparePartsManageMapper.selectById(sparePartsId); SparePartsManage sparePartsManage = sparePartsManageMapper.selectById(sparePartsId);
@ -83,13 +89,14 @@ public class DeviceInOutManageServiceImpl implements IDeviceInOutManageService {
int intOutNum = deviceInOutManage.getIntOutNum(); int intOutNum = deviceInOutManage.getIntOutNum();
if (deviceInOutManage.getOperaType() == 0) { if (deviceInOutManage.getOperaType() == 0) {
inventoryLevels = inventoryLevels + intOutNum; inventoryLevels = inventoryLevels + intOutNum;
sparePartsManageMapper.updateInventoryLevels(deviceInOutManage.getSparePartsId(), inventoryLevels, deviceInOutManage.getCreateBy());
} else if (deviceInOutManage.getOperaType() == 1) { } else if (deviceInOutManage.getOperaType() == 1) {
inventoryLevels = inventoryLevels - intOutNum; inventoryLevels = inventoryLevels - intOutNum;
sparePartsManageMapper.updateInventoryLevels(deviceInOutManage.getSparePartsId(), -intOutNum, deviceInOutManage.getCreateBy());
} }
sparePartsManageMapper.updateInventoryLevels(deviceInOutManage.getSparePartsId(), inventoryLevels, deviceInOutManage.getCreateBy());
deviceInOutManage.setInventoryLevels(inventoryLevels); deviceInOutManage.setInventoryLevels(inventoryLevels);
return deviceInOutManageMapper.insert(deviceInOutManage); result = result + deviceInOutManageMapper.insert(deviceInOutManage);
}
return result;
} }
@Override @Override

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

@ -147,11 +147,11 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService {
public List<Map.Entry<String, Object>> deviceAnalyze(EnergyQueryVO vo) { public List<Map.Entry<String, Object>> deviceAnalyze(EnergyQueryVO vo) {
DateUtils.sysEnergyDateChange(vo); DateUtils.sysEnergyDateChange(vo);
// 获取参数 // 获取参数
Map<String, Object> paramsMap = vo.getParams(); List<ColumnFilter> paramsMap = vo.getSearchParams();
List<Object> params = new ArrayList<>(paramsMap.values()); if (paramsMap.isEmpty()) {
if (params.isEmpty()) {
return List.of(); return List.of();
} }
List<Object> params = paramsMap.stream().map(ColumnFilter::getValue).collect(Collectors.toList());
AtomicReference<String> lastTableName = new AtomicReference<>("data_" + vo.getTimeType()); AtomicReference<String> lastTableName = new AtomicReference<>("data_" + vo.getTimeType());
AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType()); AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType());
String timeType = vo.getTimeType(); String timeType = vo.getTimeType();
@ -196,8 +196,8 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService {
break; break;
} }
} }
int pageNum = Integer.parseInt(String.valueOf(vo.getParams().get("pageNum"))); int pageNum = Integer.parseInt(String.valueOf(vo.getPageNum()));
int pageSize = Integer.parseInt(String.valueOf(vo.getParams().get("pageSize"))); int pageSize = Integer.parseInt(String.valueOf(vo.getPageSize()));
if (pageNum != 0) { if (pageNum != 0) {
int startIndex = (pageNum-1)*pageSize; int startIndex = (pageNum-1)*pageSize;
int endIndex = Math.min(pageNum * pageSize, timeStr.size()); int endIndex = Math.min(pageNum * pageSize, timeStr.size());
@ -209,8 +209,8 @@ public class EnergyAnalyzeServiceImpl implements EnergyAnalyzeService {
columnData.add(column); columnData.add(column);
i++; i++;
} }
int pageNum = Integer.parseInt(String.valueOf(vo.getParams().get("pageNum"))); int pageNum = Integer.parseInt(String.valueOf(vo.getPageNum()));
int pageSize = Integer.parseInt(String.valueOf(vo.getParams().get("pageSize"))); int pageSize = Integer.parseInt(String.valueOf(vo.getPageSize()));
Map<String, Object> map = new JSONObject(); Map<String, Object> map = new JSONObject();
map.put("title", title); map.put("title", title);
if (pageNum == 0) { if (pageNum == 0) {

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

@ -40,8 +40,8 @@ public class EnergyQueryServiceImpl implements IEnergyQueryService {
AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType()); AtomicReference<String> curTableName = new AtomicReference<>("data_" + vo.getTimeType());
String timeType = vo.getTimeType(); String timeType = vo.getTimeType();
// 判断是否有总表 // 判断是否有总表
boolean haveMeter = collectionParamsManageMapper.selectSummary(40, "meter") != 0; boolean haveMeter = collectionParamsManageMapper.selectSummary(40, "5") != 0;
boolean haveCloud = collectionParamsManageMapper.selectSummary(40, "cloud") != 0; boolean haveCloud = collectionParamsManageMapper.selectSummary(40, "6") != 0;
List<ConsumptionAnalyze> consumptionAnalyzeEntities = null; List<ConsumptionAnalyze> consumptionAnalyzeEntities = null;
// 表格数据 // 表格数据
if ("month".equalsIgnoreCase(timeType) || "year".equalsIgnoreCase(timeType)) { if ("month".equalsIgnoreCase(timeType) || "year".equalsIgnoreCase(timeType)) {
@ -101,8 +101,8 @@ public class EnergyQueryServiceImpl implements IEnergyQueryService {
} }
// 表格数据 // 表格数据
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
int pageNum = Integer.parseInt(String.valueOf(vo.getParams().get("pageNum"))); int pageNum = vo.getPageNum();
int pageSize = Integer.parseInt(String.valueOf(vo.getParams().get("pageSize"))); int pageSize = vo.getPageSize();
if (pageNum == 0) { if (pageNum == 0) {
map.put("coldArr", coldArr); map.put("coldArr", coldArr);
map.put("meterArr", meterArr); map.put("meterArr", meterArr);

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

@ -489,119 +489,139 @@
<select id="queryDeviceOneTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze"> <select id="queryDeviceOneTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
select select
sum(calc_value) as curValue, SUM(coalesce(dm.calc_value, 0)) as curValue,
device_type as deviceType, TO_CHAR(dm.cur_time,
convert(varchar(${len}), <choose>
cur_time, <when test='len == 4'>'YYYY'</when>
120) as timeStr <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 from
${curTableName} dy ${curTableName} dm
where where
cur_time >= #{startTime} dm.cur_time >= #{startTime}::timestamp
and cur_time &lt;= #{endTime} and dm.cur_time &lt;= #{endTime}::timestamp
and device_type = 'meter' and dm.device_type in(
and exists (
select select
1 cpm.mt_type
from from
device_manage collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where where
device_num = dy.device_num dl.device_type = '5'
<if test="deviceType != null and deviceType != '' and deviceType == 'chiller'"> and cpm.terminal_device_type = #{deviceType}
and grade &lt; 10 group by
</if> cpm.mt_type
<if test="deviceType != null and deviceType != '' and deviceType == 'chilledWaterPump'">
and grade &lt; 20 and grade >=10
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingPump'">
and grade &lt; 30 and grade >=20
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingTower'">
and grade &lt; 40 and grade >=30
</if>
) )
group by group by
device_type, TO_CHAR(dm.cur_time,
convert(varchar(${len}), <choose>
cur_time, <when test='len == 4'>'YYYY'</when>
120) <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 order by timeStr
</select> </select>
<select id="queryDeviceManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze"> <select id="queryDeviceManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
<if test="lastTableName != curTableName"> <if test="lastTableName != curTableName">
select select
sum(calc_value) as curValue, SUM(coalesce(dm.calc_value, 0)) as curValue,
convert(varchar(${len}), TO_CHAR(dm.cur_time,
cur_time, <choose>
120) as timeStr <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 from
${lastTableName} dy ${lastTableName} dm
where where
cur_time >= #{startTime} dm.cur_time >= #{startTime}::timestamp
and cur_time &lt;= #{endTime} and dm.cur_time &lt;= #{endTime}::timestamp
and device_type = 'meter' and dm.device_type in(
and exists (
select select
1 cpm.mt_type
from from
device_manage collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where where
device_num = dy.device_num dl.device_type = '5'
<if test="deviceType != null and deviceType != '' and deviceType == 'chiller'"> and cpm.terminal_device_type = #{deviceType}
and grade &lt; 10 group by
</if> cpm.mt_type
<if test="deviceType != null and deviceType != '' and deviceType == 'chilledWaterPump'">
and grade &lt; 20 and grade >=10
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingPump'">
and grade &lt; 30 and grade >=20
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingTower'">
and grade &lt; 40 and grade >=30
</if>
) )
group by group by
convert(varchar(${len}), TO_CHAR(dm.cur_time,
cur_time, <choose>
120) <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 union all
</if> </if>
select select
sum(calc_value) as curValue, SUM(coalesce(dm.calc_value, 0)) as curValue,
convert(varchar(${len}), TO_CHAR(dm.cur_time,
cur_time, <choose>
120) as timeStr <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 from
${curTableName} dy ${curTableName} dm
where where
cur_time >= #{startTime} dm.cur_time >= #{startTime}::timestamp
and cur_time &lt;= #{endTime} and dm.cur_time &lt;= #{endTime}::timestamp
and device_type = 'meter' and dm.device_type in(
and exists (
select select
1 cpm.mt_type
from from
device_manage collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where where
device_num = dy.device_num dl.device_type = '5'
<if test="deviceType != null and deviceType != '' and deviceType == 'chiller'"> and cpm.terminal_device_type = #{deviceType}
and grade &lt; 10 group by
</if> cpm.mt_type
<if test="deviceType != null and deviceType != '' and deviceType == 'chilledWaterPump'">
and grade &lt; 20 and grade >=10
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingPump'">
and grade &lt; 30 and grade >=20
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingTower'">
and grade &lt; 40 and grade >=30
</if>
) )
group by group by
convert(varchar(${len}), TO_CHAR(dm.cur_time,
cur_time, <choose><when test='len == 4'>'YYYY'</when>
120) <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 order by timeStr
</select> </select>
@ -736,68 +756,57 @@
<select id="queryDeviceLineManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze"> <select id="queryDeviceLineManyTable" resultType="com.mh.common.core.domain.entity.ConsumptionAnalyze">
<if test="lastTableName != curTableName"> <if test="lastTableName != curTableName">
select select
sum(calc_value) as curValue, SUM(coalesce(dm.calc_value, 0)) as curValue,
cur_time as timeStr dm.cur_time as timeStr
from from
${lastTableName} dy ${lastTableName} dm
where where
cur_time >= #{startTime} dm.cur_time >= #{startTime}::timestamp
and cur_time &lt;= #{endTime} and dm.cur_time &lt;= #{endTime}::timestamp
and device_type = 'meter' and dm.device_type in(
and exists (
select select
1 cpm.mt_type
from from
device_manage collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where where
device_num = dy.device_num dl.device_type = '5'
<if test="deviceType != null and deviceType != '' and deviceType == 'chiller'"> and cpm.terminal_device_type = #{deviceType}
and grade &lt; 10 group by
</if> cpm.mt_type
<if test="deviceType != null and deviceType != '' and deviceType == 'chilledWaterPump'">
and grade &lt; 20 and grade >=10
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingPump'">
and grade &lt; 30 and grade >=20
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingTower'">
and grade &lt; 40 and grade >=30
</if>
) )
group by cur_time group by
dm.cur_time
union all union all
</if> </if>
select select
sum(calc_value) as curValue, SUM(coalesce(dm.calc_value, 0)) as curValue,
cur_time as timeStr dm.cur_time as timeStr
from from
${curTableName} dy ${curTableName} dm
where where
cur_time >= #{startTime} dm.cur_time >= #{startTime}::timestamp
and cur_time &lt;= #{endTime} and dm.cur_time &lt;= #{endTime}::timestamp
and device_type = 'meter' and dm.device_type in(
and exists (
select select
1 cpm.mt_type
from from
device_manage collection_params_manage cpm
join
device_ledger dl
on
cpm.device_ledger_id = dl.id
where where
device_num = dy.device_num dl.device_type = '5'
<if test="deviceType != null and deviceType != '' and deviceType == 'chiller'"> and cpm.terminal_device_type = #{deviceType}
and grade &lt; 10 group by
</if> cpm.mt_type
<if test="deviceType != null and deviceType != '' and deviceType == 'chilledWaterPump'">
and grade &lt; 20 and grade >=10
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingPump'">
and grade &lt; 30 and grade >=20
</if>
<if test="deviceType != null and deviceType != '' and deviceType == 'coolingTower'">
and grade &lt; 40 and grade >=30
</if>
) )
group by group by
cur_time dm.cur_time
order by timeStr order by timeStr
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save