|
@@ -1,59 +1,57 @@
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
<!DOCTYPE mapper
|
|
|
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.ruoyi.ems.mapper.EmsElecStoreHMapper">
|
|
|
|
|
|
<resultMap type="com.ruoyi.ems.domain.ElecStoreH" id="StoreHResult">
|
|
|
- <result property="id" column="id" />
|
|
|
- <result property="areaCode" column="area_code" />
|
|
|
- <result property="areaName" column="area_name" />
|
|
|
- <result property="areaShortName" column="area_short_name" />
|
|
|
- <result property="facsCode" column="facs_code" />
|
|
|
- <result property="facsName" column="facs_name" />
|
|
|
- <result property="recordTime" column="record_time" />
|
|
|
- <result property="date" column="date" />
|
|
|
- <result property="time" column="time" />
|
|
|
- <result property="timeIndex" column="time_index" />
|
|
|
- <result property="chargeElecQuantity" column="charge_elec_quantity" />
|
|
|
- <result property="dischargeElecQuantity" column="discharge_elec_quantity" />
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="areaCode" column="area_code"/>
|
|
|
+ <result property="areaName" column="area_name"/>
|
|
|
+ <result property="areaShortName" column="area_short_name"/>
|
|
|
+ <result property="facsCode" column="facs_code"/>
|
|
|
+ <result property="facsName" column="facs_name"/>
|
|
|
+ <result property="recordTime" column="record_time"/>
|
|
|
+ <result property="date" column="date"/>
|
|
|
+ <result property="time" column="time"/>
|
|
|
+ <result property="timeIndex" column="time_index"/>
|
|
|
+ <result property="chargeElecQuantity" column="charge_elec_quantity"/>
|
|
|
+ <result property="dischargeElecQuantity" column="discharge_elec_quantity"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<resultMap type="com.ruoyi.ems.model.ElecStoreSta" id="StoreHSumResult">
|
|
|
- <result property="time" column="time" />
|
|
|
- <result property="timeIndex" column="time_index" />
|
|
|
- <result property="chargeElecQuantity" column="charge_elec_quantity" />
|
|
|
- <result property="dischargeElecQuantity" column="discharge_elec_quantity" />
|
|
|
+ <result property="time" column="time"/>
|
|
|
+ <result property="timeIndex" column="time_index"/>
|
|
|
+ <result property="chargeElecQuantity" column="charge_elec_quantity"/>
|
|
|
+ <result property="dischargeElecQuantity" column="discharge_elec_quantity"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectStoreHVo">
|
|
|
- SELECT
|
|
|
- st.id,
|
|
|
- st.area_code,
|
|
|
- area.area_name,
|
|
|
- area.short_name as area_short_name,
|
|
|
- facs.facs_name,
|
|
|
- st.facs_code,
|
|
|
- st.`record_time`,
|
|
|
- st.`date`,
|
|
|
- st.`time`,
|
|
|
- st.time_index,
|
|
|
- st.charge_elec_quantity,
|
|
|
- st.discharge_elec_quantity
|
|
|
- FROM
|
|
|
- adm_ems_elec_store_h st
|
|
|
- LEFT JOIN adm_ems_facs facs ON st.facs_code = facs.facs_code
|
|
|
- LEFT JOIN adm_area area ON st.area_code = area.area_code
|
|
|
+ SELECT st.id,
|
|
|
+ st.area_code,
|
|
|
+ area.area_name,
|
|
|
+ area.short_name as area_short_name,
|
|
|
+ facs.facs_name,
|
|
|
+ st.facs_code,
|
|
|
+ st.`record_time`,
|
|
|
+ st.`date`,
|
|
|
+ st.`time`,
|
|
|
+ st.time_index,
|
|
|
+ st.charge_elec_quantity,
|
|
|
+ st.discharge_elec_quantity
|
|
|
+ FROM adm_ems_elec_store_h st
|
|
|
+ LEFT JOIN adm_ems_facs facs ON st.facs_code = facs.facs_code
|
|
|
+ LEFT JOIN adm_area area ON st.area_code = area.area_code
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectStoreHList" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
|
|
|
<include refid="selectStoreHVo"/>
|
|
|
<where>
|
|
|
- <if test="areaCode != null and areaCode != ''"> and st.area_code = #{areaCode}</if>
|
|
|
- <if test="facsCode != null and facsCode != ''"> and st.facs_code = #{facsCode}</if>
|
|
|
- <if test="date != null "> and st.`date` = #{date}</if>
|
|
|
- <if test="chargeElecQuantity != null "> and st.charge_elec_quantity = #{chargeElecQuantity}</if>
|
|
|
- <if test="dischargeElecQuantity != null "> and st.discharge_elec_quantity = #{dischargeElecQuantity}</if>
|
|
|
+ <if test="areaCode != null and areaCode != ''">and st.area_code = #{areaCode}</if>
|
|
|
+ <if test="facsCode != null and facsCode != ''">and st.facs_code = #{facsCode}</if>
|
|
|
+ <if test="date != null ">and st.`date` = #{date}</if>
|
|
|
+ <if test="chargeElecQuantity != null ">and st.charge_elec_quantity = #{chargeElecQuantity}</if>
|
|
|
+ <if test="dischargeElecQuantity != null ">and st.discharge_elec_quantity = #{dischargeElecQuantity}</if>
|
|
|
<if test="startRecTime != null and startRecTime != '' and endRecTime != null and endRecTime !=''">
|
|
|
and st.`record_time` >= #{startRecTime} and st.`record_time` <= #{endRecTime}
|
|
|
</if>
|
|
@@ -62,7 +60,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
st.`time` DESC,
|
|
|
st.`time_index`
|
|
|
</select>
|
|
|
-
|
|
|
+ <select id="selectStoreHByDataRange" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
|
|
|
+ SELECT
|
|
|
+ sum(st.charge_elec_quantity) charge_elec_quantity,
|
|
|
+ sum(st.discharge_elec_quantity) discharge_elec_quantity
|
|
|
+ FROM adm_ems_elec_store_h st
|
|
|
+ <where>
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and st.area_code = #{areaCode}</if>
|
|
|
+ <if test="startRecTime != null and startRecTime !='' ">and st.`date` like concat(#{startRecTime},'%')</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <select id="selectStorageIndex" resultType="EmsElecStoreIndex">
|
|
|
+ SELECT
|
|
|
+ SUM(aeesi.current_capacity) current_capacity
|
|
|
+ FROM (SELECT MAX(id) id
|
|
|
+ FROM adm_ems_elec_store_index storeIndex
|
|
|
+ <where>
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and storeIndex.area_code =
|
|
|
+ #{areaCode}
|
|
|
+ </if>
|
|
|
+ <if test="startRecTime != null and startRecTime !='' ">and storeIndex.`date` like concat(#{startRecTime},'%')</if>
|
|
|
+ </where>
|
|
|
+ group by facs_code) AS latest_records
|
|
|
+ inner join adm_ems_elec_store_index aeesi on latest_records.id = aeesi.id
|
|
|
+ </select>
|
|
|
<select id="selectStoreHAllArea" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
|
|
|
SELECT facCategory.`code` facs_code,
|
|
|
facCategory.`name` facs_name,
|
|
@@ -90,15 +111,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectStoreDayList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="StoreHResult">
|
|
|
SELECT
|
|
|
- <if test="facsSubCategory != null and facsSubCategory !=''">
|
|
|
- sc.`name` as facs_name,
|
|
|
- </if>
|
|
|
- <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
|
|
|
- s.area_code,
|
|
|
- </if>
|
|
|
- s.`date`,
|
|
|
- sum(COALESCE(s.`charge_elec_quantity`, 0)) charge_elec_quantity,
|
|
|
- sum(COALESCE(s.`discharge_elec_quantity`, 0)) discharge_elec_quantity
|
|
|
+ <if test="facsSubCategory != null and facsSubCategory !=''">
|
|
|
+ sc.`name` as facs_name,
|
|
|
+ </if>
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
|
|
|
+ s.area_code,
|
|
|
+ </if>
|
|
|
+ s.`date`,
|
|
|
+ sum(COALESCE(s.`charge_elec_quantity`, 0)) charge_elec_quantity,
|
|
|
+ sum(COALESCE(s.`discharge_elec_quantity`, 0)) discharge_elec_quantity
|
|
|
FROM adm_ems_elec_store_h s
|
|
|
<if test="facsSubCategory != null and facsSubCategory !=''">
|
|
|
LEFT JOIN adm_ems_facs f ON s.`facs_code` = f.`facs_code`
|
|
@@ -125,24 +146,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
|
|
|
|
<select id="selectStoreHSumDate" parameterType="java.lang.String" resultMap="StoreHSumResult">
|
|
|
- SELECT
|
|
|
- st.`date` as `time`,
|
|
|
- sum(st.charge_elec_quantity) as charge_elec_quantity,
|
|
|
- sum(st.discharge_elec_quantity) as discharge_elec_quantity
|
|
|
- FROM
|
|
|
- adm_ems_elec_store_h st
|
|
|
+ SELECT st.`date` as `time`,
|
|
|
+ sum(st.charge_elec_quantity) as charge_elec_quantity,
|
|
|
+ sum(st.discharge_elec_quantity) as discharge_elec_quantity
|
|
|
+ FROM adm_ems_elec_store_h st
|
|
|
where st.`date` = #{date}
|
|
|
group by st.`date`
|
|
|
</select>
|
|
|
|
|
|
<select id="selectStoreHSumHour" parameterType="java.lang.String" resultMap="StoreHSumResult">
|
|
|
- SELECT
|
|
|
- st.`time`,
|
|
|
- st.`time_index`,
|
|
|
- sum(st.charge_elec_quantity) as charge_elec_quantity,
|
|
|
- sum(st.discharge_elec_quantity) as discharge_elec_quantity
|
|
|
- FROM
|
|
|
- adm_ems_elec_store_h st
|
|
|
+ SELECT st.`time`,
|
|
|
+ st.`time_index`,
|
|
|
+ sum(st.charge_elec_quantity) as charge_elec_quantity,
|
|
|
+ sum(st.discharge_elec_quantity) as discharge_elec_quantity
|
|
|
+ FROM adm_ems_elec_store_h st
|
|
|
where st.`date` = #{date}
|
|
|
group by st.`time`
|
|
|
</select>
|
|
@@ -158,7 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="timeIndex != null">time_index,</if>
|
|
|
<if test="chargeElecQuantity != null">charge_elec_quantity,</if>
|
|
|
<if test="dischargeElecQuantity != null">discharge_elec_quantity,</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
|
|
<if test="facsCode != null and facsCode != ''">#{facsCode},</if>
|
|
@@ -168,7 +185,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="timeIndex != null">#{timeIndex},</if>
|
|
|
<if test="chargeElecQuantity != null">#{chargeElecQuantity},</if>
|
|
|
<if test="dischargeElecQuantity != null">#{dischargeElecQuantity},</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateStoreH" parameterType="com.ruoyi.ems.domain.ElecStoreH">
|
|
@@ -187,7 +204,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</update>
|
|
|
|
|
|
<delete id="deleteStoreHById" parameterType="Long">
|
|
|
- delete from adm_ems_elec_store_h where id = #{id}
|
|
|
+ delete
|
|
|
+ from adm_ems_elec_store_h
|
|
|
+ where id = #{id}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteStoreHByIds" parameterType="String">
|