change - add能源预览

main
yinq 5 months ago
parent 20ff254a9d
commit 8967584402

@ -19,7 +19,7 @@ import java.util.Map;
/** /**
* import java.util.List;Controller * Controller
* *
* @author Yinq * @author Yinq
* @date 2024-05-22 * @date 2024-05-22
@ -75,4 +75,17 @@ public class EmsReportController extends BaseController {
util.exportExcel(response, list, "峰平谷耗量报表" ); util.exportExcel(response, list, "峰平谷耗量报表" );
} }
/**
*
* @param hashMap
* @return
*/
@GetMapping("/energyPreviewReportList")
@ResponseBody
public AjaxResult energyPreviewReportList(@RequestParam(required = false) Map hashMap) {
List<Map<String, Object>> list = emsReportService.energyPreviewReportList(hashMap);
return success(list);
}
} }

@ -17,11 +17,11 @@ public interface EmsReportMapper
{ {
/** /**
* *
* @param hashMap * @param hashMap
* @return * @return
*/ */
List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap); List<EnergyStatisticalReport> energyStatisticalDnbReportList(Map hashMap);
/** /**
* *

@ -28,4 +28,11 @@ public interface IEmsReportService {
* @return * @return
*/ */
List<PeaksValleysConsumptionReport> peaksValleysConsumptionReportList(Map hashMap); List<PeaksValleysConsumptionReport> peaksValleysConsumptionReportList(Map hashMap);
/**
*
* @param hashMap
* @return
*/
List<Map<String, Object>> energyPreviewReportList(Map hashMap);
} }

@ -1,5 +1,10 @@
package com.os.ems.report.service.impl; package com.os.ems.report.service.impl;
import com.os.common.utils.StringUtils;
import com.os.ems.base.domain.EmsBaseMonitorWorkUnit;
import com.os.ems.base.domain.EmsBaseWorkUnit;
import com.os.ems.base.mapper.EmsBaseMonitorWorkUnitMapper;
import com.os.ems.base.mapper.EmsBaseWorkUnitMapper;
import com.os.ems.report.domain.EnergyStatisticalReport; import com.os.ems.report.domain.EnergyStatisticalReport;
import com.os.ems.report.domain.PeaksValleysConsumptionReport; import com.os.ems.report.domain.PeaksValleysConsumptionReport;
import com.os.ems.report.mapper.EmsReportMapper; import com.os.ems.report.mapper.EmsReportMapper;
@ -7,8 +12,9 @@ import com.os.ems.report.service.IEmsReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.math.BigDecimal;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
/** /**
@ -22,28 +28,84 @@ public class EmsReportServiceImpl implements IEmsReportService {
@Autowired @Autowired
private EmsReportMapper emsReportMapper; private EmsReportMapper emsReportMapper;
@Autowired
private EmsBaseMonitorWorkUnitMapper emsBaseMonitorWorkUnitMapper;
@Autowired
private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper;
/** /**
* *
*
* @param hashMap * @param hashMap
* @return * @return
*/ */
@Override @Override
public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) { public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) {
if (!hashMap.containsKey("dateType")){ if (!hashMap.containsKey("dateType") && !hashMap.containsKey("energyType")) {
return null; return null;
} }
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType")))); hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
return emsReportMapper.energyStatisticalReportList(hashMap); List<EnergyStatisticalReport> reportList = new ArrayList<>();
if (Objects.equals(String.valueOf(hashMap.get("energyType")), "2")){
reportList = emsReportMapper.energyStatisticalDnbReportList(hashMap);
}
return reportList;
} }
/** /**
* *
*
* @param hashMap * @param hashMap
* @return * @return
*/ */
@Override @Override
public List<PeaksValleysConsumptionReport> peaksValleysConsumptionReportList(Map hashMap) { public List<PeaksValleysConsumptionReport> peaksValleysConsumptionReportList(Map hashMap) {
if (!hashMap.containsKey("dateType")) {
return null;
}
return emsReportMapper.peaksValleysConsumptionReportList(hashMap); return emsReportMapper.peaksValleysConsumptionReportList(hashMap);
} }
/**
*
*
* @param hashMap
* @return
*/
@Override
public List<Map<String, Object>> energyPreviewReportList(Map hashMap) {
List<Map<String, Object>> resultList = new ArrayList<>();
if (!hashMap.containsKey("startTime") || !hashMap.containsKey("endTime")) {
return resultList;
}
EmsBaseWorkUnit workUnit = new EmsBaseWorkUnit();
List<EmsBaseWorkUnit> workUnits = emsBaseWorkUnitMapper.selectEmsBaseWorkUnitList(workUnit);
HashMap<String, String> selectMap = new HashMap<>();
selectMap.put("dateType", String.valueOf(hashMap.get("dateType")));
selectMap.put("energyType", String.valueOf(hashMap.get("energyType")));
selectMap.put("beginCollectTime", String.valueOf(hashMap.get("startTime")));
selectMap.put("endCollectTime", String.valueOf(hashMap.get("endTime")));
for (EmsBaseWorkUnit unit : workUnits) {
HashMap<String, Object> typeResultMap = new HashMap<>();
typeResultMap.put("unitName", unit.getWorkUnitName());
selectMap.put("workUnitCode", unit.getWorkUnitCode());
List<EnergyStatisticalReport> reportList = this.energyStatisticalReportList(selectMap);
BigDecimal expendSum = new BigDecimal(0);
for (EnergyStatisticalReport report : reportList) {
typeResultMap.put("expend" + report.getBeginTime(), report.getExpend());
expendSum = expendSum.add(report.getExpend());
}
typeResultMap.put("expendSum", expendSum.toPlainString());
resultList.add(typeResultMap);
}
return resultList;
}
} }

@ -59,6 +59,7 @@
<if test="updatedBy != null and updatedBy != ''">and ebmwu.updated_by = #{updatedBy}</if> <if test="updatedBy != null and updatedBy != ''">and ebmwu.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and ebmwu.updated_time = #{updatedTime}</if> <if test="updatedTime != null ">and ebmwu.updated_time = #{updatedTime}</if>
</where> </where>
order by ebwu.work_unit_type, ebmwu.work_unit_code, ebmwu.monitor_code
</select> </select>
<select id="selectEmsBaseMonitorWorkUnitByObjId" parameterType="Long" resultMap="EmsBaseMonitorWorkUnitResult"> <select id="selectEmsBaseMonitorWorkUnitByObjId" parameterType="Long" resultMap="EmsBaseMonitorWorkUnitResult">

@ -1,47 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.os.ems.base.mapper.EmsBaseWorkUnitMapper"> <mapper namespace="com.os.ems.base.mapper.EmsBaseWorkUnitMapper">
<resultMap type="EmsBaseWorkUnit" id="EmsBaseWorkUnitResult"> <resultMap type="EmsBaseWorkUnit" id="EmsBaseWorkUnitResult">
<result property="objId" column="obj_id" /> <result property="objId" column="obj_id"/>
<result property="workUnitCode" column="work_unit_code" /> <result property="workUnitCode" column="work_unit_code"/>
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id"/>
<result property="workUnitName" column="work_unit_name" /> <result property="workUnitName" column="work_unit_name"/>
<result property="workUnitAddress" column="work_unit_address" /> <result property="workUnitAddress" column="work_unit_address"/>
<result property="ancestors" column="ancestors" /> <result property="ancestors" column="ancestors"/>
<result property="workUnitSort" column="work_unit_sort" /> <result property="workUnitSort" column="work_unit_sort"/>
<result property="productLineCode" column="product_line_code" /> <result property="productLineCode" column="product_line_code"/>
<result property="workUnitType" column="work_unit_type" /> <result property="workUnitType" column="work_unit_type"/>
<result property="isFlag" column="is_flag" /> <result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by" /> <result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time" /> <result property="createdTime" column="created_time"/>
<result property="updatedBy" column="updated_by" /> <result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time" /> <result property="updatedTime" column="updated_time"/>
</resultMap> </resultMap>
<sql id="selectEmsBaseWorkUnitVo"> <sql id="selectEmsBaseWorkUnitVo">
select obj_id, work_unit_code, parent_id, work_unit_name, work_unit_address, ancestors, work_unit_sort, product_line_code, work_unit_type, is_flag, created_by, created_time, updated_by, updated_time from ems_base_work_unit select obj_id,
work_unit_code,
parent_id,
work_unit_name,
work_unit_address,
ancestors,
work_unit_sort,
product_line_code,
work_unit_type,
is_flag,
created_by,
created_time,
updated_by,
updated_time
from ems_base_work_unit
</sql> </sql>
<select id="selectEmsBaseWorkUnitList" parameterType="EmsBaseWorkUnit" resultMap="EmsBaseWorkUnitResult"> <select id="selectEmsBaseWorkUnitList" parameterType="EmsBaseWorkUnit" resultMap="EmsBaseWorkUnitResult">
<include refid="selectEmsBaseWorkUnitVo"/> <include refid="selectEmsBaseWorkUnitVo"/>
<where> <where>
<if test="workUnitCode != null and workUnitCode != ''"> and work_unit_code = #{workUnitCode}</if> <if test="workUnitCode != null and workUnitCode != ''">and work_unit_code = #{workUnitCode}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if> <if test="parentId != null ">and parent_id = #{parentId}</if>
<if test="workUnitName != null and workUnitName != ''"> and work_unit_name like concat('%', #{workUnitName}, '%')</if> <if test="workUnitName != null and workUnitName != ''">and work_unit_name like concat('%', #{workUnitName},
<if test="workUnitAddress != null and workUnitAddress != ''"> and work_unit_address = #{workUnitAddress}</if> '%')
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if> </if>
<if test="workUnitSort != null "> and work_unit_sort = #{workUnitSort}</if> <if test="workUnitAddress != null and workUnitAddress != ''">and work_unit_address = #{workUnitAddress}
<if test="productLineCode != null and productLineCode != ''"> and product_line_code = #{productLineCode}</if> </if>
<if test="workUnitType != null "> and work_unit_type = #{workUnitType}</if> <if test="ancestors != null and ancestors != ''">and ancestors = #{ancestors}</if>
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if> <if test="workUnitSort != null ">and work_unit_sort = #{workUnitSort}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if> <if test="productLineCode != null and productLineCode != ''">and product_line_code = #{productLineCode}
<if test="createdTime != null "> and created_time = #{createdTime}</if> </if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if> <if test="workUnitType != null ">and work_unit_type = #{workUnitType}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if> <if test="isFlag != null and isFlag != ''">and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and created_by = #{createdBy}</if>
<if test="createdTime != null ">and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and updated_time = #{updatedTime}</if>
</where> </where>
order by work_unit_type, work_unit_code
</select> </select>
<select id="selectEmsBaseWorkUnitByObjId" parameterType="Long" resultMap="EmsBaseWorkUnitResult"> <select id="selectEmsBaseWorkUnitByObjId" parameterType="Long" resultMap="EmsBaseWorkUnitResult">
@ -104,7 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteEmsBaseWorkUnitByObjId" parameterType="Long"> <delete id="deleteEmsBaseWorkUnitByObjId" parameterType="Long">
delete from ems_base_work_unit where obj_id = #{objId} delete
from ems_base_work_unit
where obj_id = #{objId}
</delete> </delete>
<delete id="deleteEmsBaseWorkUnitByObjIds" parameterType="String"> <delete id="deleteEmsBaseWorkUnitByObjIds" parameterType="String">

@ -5,7 +5,7 @@
<mapper namespace="com.os.ems.report.mapper.EmsReportMapper"> <mapper namespace="com.os.ems.report.mapper.EmsReportMapper">
<select id="energyStatisticalReportList" resultType="com.os.ems.report.domain.EnergyStatisticalReport" <select id="energyStatisticalDnbReportList" resultType="com.os.ems.report.domain.EnergyStatisticalReport"
parameterType="java.util.HashMap"> parameterType="java.util.HashMap">
WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB) WITH DT AS (SELECT CAST(#{timeSub} AS INT) TIMESUB)
SELECT WU.WORK_UNIT_CODE workUnitCode, SELECT WU.WORK_UNIT_CODE workUnitCode,
@ -20,7 +20,7 @@
CROSS JOIN DT CROSS JOIN DT
WHERE RPD.EXPEND IS NOT NULL WHERE RPD.EXPEND IS NOT NULL
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''"> <if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd') between #{beginCollectTime} and #{endCollectTime} and FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss') between #{beginCollectTime} and #{endCollectTime}
</if> </if>
<if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if> <if test="workUnitCode != null and workUnitCode != ''">and WU.WORK_UNIT_CODE = #{workUnitCode}</if>
GROUP BY WU.WORK_UNIT_CODE, WU.WORK_UNIT_NAME, SUBSTRING(FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss'), 1, DT.TIMESUB) GROUP BY WU.WORK_UNIT_CODE, WU.WORK_UNIT_NAME, SUBSTRING(FORMAT(RPD.BEGIN_TIME, 'yyyy-MM-dd HH:mm:ss'), 1, DT.TIMESUB)
@ -34,7 +34,9 @@
sum(expend * dnb_price) price sum(expend * dnb_price) price
FROM ( FROM (
SELECT erpd.monitor_code, SELECT erpd.monitor_code,
CONVERT(VARCHAR(10), erpd.begin_time, 120) pointTime, <if test="dateType == 10">CONVERT(VARCHAR(10), erpd.begin_time, 120) pointTime,</if>
<if test="dateType == 7">CONVERT(VARCHAR(7), erpd.begin_time, 120) pointTime,</if>
<if test="dateType == 4">CONVERT(VARCHAR(4), erpd.begin_time, 120) pointTime,</if>
NULLIF(erpd.expend, 0) expend, NULLIF(erpd.expend, 0) expend,
case case
when ebsp.price_type = 0 then '尖峰' when ebsp.price_type = 0 then '尖峰'

Loading…
Cancel
Save