|
@@ -1,37 +1,49 @@
|
|
|
<?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.MeterDeviceMapper">
|
|
|
-
|
|
|
+
|
|
|
<resultMap type="com.ruoyi.ems.domain.MeterDevice" id="meterDeviceResult">
|
|
|
- <result property="id" column="id" />
|
|
|
- <result property="areaCode" column="area_code" />
|
|
|
- <result property="deviceCode" column="device_code" />
|
|
|
- <result property="deviceName" column="device_name" />
|
|
|
- <result property="location" column="location" />
|
|
|
- <result property="locationRef" column="location_ref" />
|
|
|
- <result property="meterCls" column="meter_cls" />
|
|
|
- <result property="objTag" column="obj_tag" />
|
|
|
- <result property="colCycle" column="col_cycle" />
|
|
|
- <result property="colMode" column="col_mode" />
|
|
|
- <result property="magnification" column="magnification" />
|
|
|
- <result property="specDesc" column="spec_desc" />
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="areaCode" column="area_code"/>
|
|
|
+ <result property="deviceCode" column="device_code"/>
|
|
|
+ <result property="deviceName" column="device_name"/>
|
|
|
+ <result property="location" column="location"/>
|
|
|
+ <result property="locationRef" column="location_ref"/>
|
|
|
+ <result property="meterCls" column="meter_cls"/>
|
|
|
+ <result property="objTag" column="obj_tag"/>
|
|
|
+ <result property="colCycle" column="col_cycle"/>
|
|
|
+ <result property="colMode" column="col_mode"/>
|
|
|
+ <result property="magnification" column="magnification"/>
|
|
|
+ <result property="specDesc" column="spec_desc"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectMeterDeviceVo">
|
|
|
- select id, area_code, device_code, device_name, location, location_ref, meter_cls, obj_tag, col_cycle, col_mode, magnification, spec_desc from adm_meter_device
|
|
|
+ select id,
|
|
|
+ area_code,
|
|
|
+ device_code,
|
|
|
+ device_name,
|
|
|
+ location,
|
|
|
+ location_ref,
|
|
|
+ meter_cls,
|
|
|
+ obj_tag,
|
|
|
+ col_cycle,
|
|
|
+ col_mode,
|
|
|
+ magnification,
|
|
|
+ spec_desc
|
|
|
+ from adm_meter_device
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectMeterDeviceList" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="meterDeviceResult">
|
|
|
<include refid="selectMeterDeviceVo"/>
|
|
|
<where>
|
|
|
- <if test="deviceCode != null and deviceCode != ''"> and device_code = #{deviceCode}</if>
|
|
|
- <if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
|
|
- <if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
|
|
|
- <if test="meterCls != null and meterCls != ''"> and meter_cls = #{meterCls}</if>
|
|
|
- <if test="objTag != null and objTag != ''"> and obj_tag = #{objTag}</if>
|
|
|
- <if test="colMode != null "> and col_mode = #{colMode}</if>
|
|
|
+ <if test="deviceCode != null and deviceCode != ''">and device_code = #{deviceCode}</if>
|
|
|
+ <if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
|
|
|
+ <if test="areaCode != null and areaCode != ''">and area_code = #{areaCode}</if>
|
|
|
+ <if test="meterCls != null and meterCls != ''">and meter_cls = #{meterCls}</if>
|
|
|
+ <if test="objTag != null and objTag != ''">and obj_tag = #{objTag}</if>
|
|
|
+ <if test="colMode != null ">and col_mode = #{colMode}</if>
|
|
|
<if test="locationRef != null and locationRef != '' and areaCodes != null">
|
|
|
and `location_ref` in
|
|
|
<foreach item="areaCode" collection="areaCodes" open="(" separator="," close=")">
|
|
@@ -43,15 +55,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectByModel" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="meterDeviceResult">
|
|
|
select
|
|
|
- m.id, m.area_code, m.device_code, m.device_name, m.location, m.location_ref, m.meter_cls, m.obj_tag, m.col_cycle, m.col_mode, m.magnification, m.spec_desc
|
|
|
+ m.id, m.area_code, m.device_code, m.device_name, m.location, m.location_ref, m.meter_cls, m.obj_tag,
|
|
|
+ m.col_cycle, m.col_mode, m.magnification, m.spec_desc
|
|
|
from adm_meter_device m
|
|
|
left join adm_ems_device d on m.device_code = d.device_code
|
|
|
<where>
|
|
|
d.device_model = #{deviceModel}
|
|
|
- <if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
|
|
|
- <if test="meterCls != null and meterCls != ''"> and meter_cls = #{meterCls}</if>
|
|
|
- <if test="objTag != null and objTag != ''"> and obj_tag = #{objTag}</if>
|
|
|
- <if test="colMode != null "> and col_mode = #{colMode}</if>
|
|
|
+ <if test="areaCode != null and areaCode != ''">and area_code = #{areaCode}</if>
|
|
|
+ <if test="meterCls != null and meterCls != ''">and meter_cls = #{meterCls}</if>
|
|
|
+ <if test="objTag != null and objTag != ''">and obj_tag = #{objTag}</if>
|
|
|
+ <if test="colMode != null ">and col_mode = #{colMode}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
@@ -60,25 +73,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
where id = #{id}
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectMeterDeviceByCode" resultMap="meterDeviceResult">
|
|
|
+ <select id="selectMeterDeviceByCode" resultMap="meterDeviceResult">
|
|
|
<include refid="selectMeterDeviceVo"/>
|
|
|
where device_code = #{deviceCode}
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectMeterDeviceByObj" resultMap="meterDeviceResult">
|
|
|
- select
|
|
|
- m.id, m.area_code, m.device_code, m.device_name, m.location, m.location_ref, m.meter_cls, m.obj_tag, m.col_cycle, m.col_mode, m.magnification, m.spec_desc
|
|
|
+ <select id="selectMeterDeviceByObj" resultMap="meterDeviceResult">
|
|
|
+ select m.id,
|
|
|
+ m.area_code,
|
|
|
+ m.device_code,
|
|
|
+ m.device_name,
|
|
|
+ m.location,
|
|
|
+ m.location_ref,
|
|
|
+ m.meter_cls,
|
|
|
+ m.obj_tag,
|
|
|
+ m.col_cycle,
|
|
|
+ m.col_mode,
|
|
|
+ m.magnification,
|
|
|
+ m.spec_desc
|
|
|
from adm_meter_device m
|
|
|
where m.area_code = #{areaCode}
|
|
|
and m.meter_cls = #{meterCls}
|
|
|
and m.device_code in
|
|
|
- (select
|
|
|
- r.meter_device from adm_meter_boundary_rel r
|
|
|
+ (select r.meter_device
|
|
|
+ from adm_meter_boundary_rel r
|
|
|
where r.boundary_obj = #{boundaryObj}
|
|
|
and r.obj_type = #{objType})
|
|
|
</select>
|
|
|
-
|
|
|
- <insert id="insertMeterDevice" parameterType="com.ruoyi.ems.domain.MeterDevice" useGeneratedKeys="true" keyProperty="id">
|
|
|
+
|
|
|
+ <insert id="insertMeterDevice" parameterType="com.ruoyi.ems.domain.MeterDevice" useGeneratedKeys="true"
|
|
|
+ keyProperty="id">
|
|
|
insert into adm_meter_device
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="areaCode != null and areaCode != ''">area_code,</if>
|
|
@@ -92,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="colMode != null">col_mode,</if>
|
|
|
<if test="magnification != null">magnification,</if>
|
|
|
<if test="specDesc != null">spec_desc,</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
|
|
<if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
|
|
@@ -105,7 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="colMode != null">#{colMode},</if>
|
|
|
<if test="magnification != null">#{magnification},</if>
|
|
|
<if test="specDesc != null">#{specDesc},</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateMeterDevice" parameterType="com.ruoyi.ems.domain.MeterDevice">
|
|
@@ -127,13 +151,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</update>
|
|
|
|
|
|
<delete id="deleteMeterDeviceById" parameterType="Long">
|
|
|
- delete from adm_meter_device where id = #{id}
|
|
|
+ delete
|
|
|
+ from adm_meter_device
|
|
|
+ where id = #{id}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteMeterDeviceByIds" parameterType="String">
|
|
|
- delete from adm_meter_device where id in
|
|
|
+ delete from adm_meter_device where id in
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
#{id}
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
+
|
|
|
+ <select id="countMeterDeviceByObj" parameterType="MeterDevice" resultType="java.lang.Integer">
|
|
|
+ select
|
|
|
+ count(*)
|
|
|
+ from adm_meter_device m
|
|
|
+ where
|
|
|
+ col_mode = 0
|
|
|
+ <if test="areaCode != null and areaCode != ''">and m.area_code = #{areaCode}</if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="countOnlineMeterDeviceByObj" parameterType="ElecMeterH" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ count(DISTINCT aemh.device_code)
|
|
|
+ from
|
|
|
+ adm_elec_meter_h aemh
|
|
|
+ inner join adm_meter_device aed on aed.device_code = aemh.device_code and aed.col_mode = 0
|
|
|
+ <where>
|
|
|
+ <if test="areaCode != null and areaCode != ''">and aemh.area_code = #{areaCode}</if>
|
|
|
+ <if test="startRecTime != null and startRecTime != ''">and aemh.date = #{startRecTime}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|