|
@@ -0,0 +1,331 @@
|
|
|
+<?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">
|
|
|
+<mapper namespace="com.zcxk.dao.MeterReadRecordMapper">
|
|
|
+ <resultMap id="BaseResultMap" type="com.zcxk.entity.MeterReadRecord">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ <id column="id" property="id" />
|
|
|
+ <result column="read_date" property="readDate" />
|
|
|
+ <result column="site_id" property="siteId" />
|
|
|
+ <result column="sys_id" property="sysId" />
|
|
|
+ <result column="province" property="province" />
|
|
|
+ <result column="city" property="city" />
|
|
|
+ <result column="region" property="region" />
|
|
|
+ <result column="community" property="community" />
|
|
|
+ <result column="customer_id" property="customerId" />
|
|
|
+ <result column="concentrator_id" property="concentratorId" />
|
|
|
+ <result column="collector_id" property="collectorId" />
|
|
|
+ <result column="building_id" property="buildingId" />
|
|
|
+ <result column="location" property="location" />
|
|
|
+ <result column="device_type_id" property="deviceTypeId" />
|
|
|
+ <result column="device_id" property="deviceId" />
|
|
|
+ <result column="device_no" property="deviceNo" />
|
|
|
+ <result column="meter_no" property="meterNo" />
|
|
|
+ <result column="meter_file_no" property="meterFileNo" />
|
|
|
+ <result column="read_time" property="readTime" />
|
|
|
+ <result column="read_status" property="readStatus" />
|
|
|
+ <result column="read_data" property="readData" />
|
|
|
+ <result column="last_valid" property="lastValid" />
|
|
|
+ <result column="last_cost" property="lastCost" />
|
|
|
+ <result column="status" property="status" />
|
|
|
+ <result column="date_create" property="dateCreate" />
|
|
|
+ <result column="date_update" property="dateUpdate" />
|
|
|
+ <result column="create_by" property="createBy" />
|
|
|
+ <result column="update_by" property="updateBy" />
|
|
|
+ </resultMap>
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ id, read_date, site_id, sys_id, province, city, region, community, customer_id, concentrator_id,
|
|
|
+ collector_id, building_id, `location`, device_type_id, device_id, device_no, meter_no,
|
|
|
+ meter_file_no, read_time, read_status, read_data, last_valid, last_cost, `status`,
|
|
|
+ date_create, date_update, create_by, update_by
|
|
|
+ </sql>
|
|
|
+ <insert id="insertSelective" parameterType="com.zcxk.entity.MeterReadRecord">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ insert into sc_meter_read_record
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="id != null">
|
|
|
+ id,
|
|
|
+ </if>
|
|
|
+ <if test="readDate != null">
|
|
|
+ read_date,
|
|
|
+ </if>
|
|
|
+ <if test="siteId != null">
|
|
|
+ site_id,
|
|
|
+ </if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ sys_id,
|
|
|
+ </if>
|
|
|
+ <if test="province != null">
|
|
|
+ province,
|
|
|
+ </if>
|
|
|
+ <if test="city != null">
|
|
|
+ city,
|
|
|
+ </if>
|
|
|
+ <if test="region != null">
|
|
|
+ region,
|
|
|
+ </if>
|
|
|
+ <if test="community != null">
|
|
|
+ community,
|
|
|
+ </if>
|
|
|
+ <if test="customerId != null">
|
|
|
+ customer_id,
|
|
|
+ </if>
|
|
|
+ <if test="concentratorId != null">
|
|
|
+ concentrator_id,
|
|
|
+ </if>
|
|
|
+ <if test="collectorId != null">
|
|
|
+ collector_id,
|
|
|
+ </if>
|
|
|
+ <if test="buildingId != null">
|
|
|
+ building_id,
|
|
|
+ </if>
|
|
|
+ <if test="location != null">
|
|
|
+ `location`,
|
|
|
+ </if>
|
|
|
+ <if test="deviceTypeId != null">
|
|
|
+ device_type_id,
|
|
|
+ </if>
|
|
|
+ <if test="deviceId != null">
|
|
|
+ device_id,
|
|
|
+ </if>
|
|
|
+ <if test="deviceNo != null">
|
|
|
+ device_no,
|
|
|
+ </if>
|
|
|
+ <if test="meterNo != null">
|
|
|
+ meter_no,
|
|
|
+ </if>
|
|
|
+ <if test="meterFileNo != null">
|
|
|
+ meter_file_no,
|
|
|
+ </if>
|
|
|
+ <if test="readTime != null">
|
|
|
+ read_time,
|
|
|
+ </if>
|
|
|
+ <if test="readStatus != null">
|
|
|
+ read_status,
|
|
|
+ </if>
|
|
|
+ <if test="readData != null">
|
|
|
+ read_data,
|
|
|
+ </if>
|
|
|
+ <if test="lastValid != null">
|
|
|
+ last_valid,
|
|
|
+ </if>
|
|
|
+ <if test="lastCost != null">
|
|
|
+ last_cost,
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ `status`,
|
|
|
+ </if>
|
|
|
+ <if test="dateCreate != null">
|
|
|
+ date_create,
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null">
|
|
|
+ date_update,
|
|
|
+ </if>
|
|
|
+ <if test="createBy != null">
|
|
|
+ create_by,
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null">
|
|
|
+ update_by,
|
|
|
+ </if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="id != null">
|
|
|
+ #{id},
|
|
|
+ </if>
|
|
|
+ <if test="readDate != null">
|
|
|
+ #{readDate},
|
|
|
+ </if>
|
|
|
+ <if test="siteId != null">
|
|
|
+ #{siteId},
|
|
|
+ </if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ #{sysId},
|
|
|
+ </if>
|
|
|
+ <if test="province != null">
|
|
|
+ #{province},
|
|
|
+ </if>
|
|
|
+ <if test="city != null">
|
|
|
+ #{city},
|
|
|
+ </if>
|
|
|
+ <if test="region != null">
|
|
|
+ #{region},
|
|
|
+ </if>
|
|
|
+ <if test="community != null">
|
|
|
+ #{community},
|
|
|
+ </if>
|
|
|
+ <if test="customerId != null">
|
|
|
+ #{customerId},
|
|
|
+ </if>
|
|
|
+ <if test="concentratorId != null">
|
|
|
+ #{concentratorId},
|
|
|
+ </if>
|
|
|
+ <if test="collectorId != null">
|
|
|
+ #{collectorId},
|
|
|
+ </if>
|
|
|
+ <if test="buildingId != null">
|
|
|
+ #{buildingId},
|
|
|
+ </if>
|
|
|
+ <if test="location != null">
|
|
|
+ #{location},
|
|
|
+ </if>
|
|
|
+ <if test="deviceTypeId != null">
|
|
|
+ #{deviceTypeId},
|
|
|
+ </if>
|
|
|
+ <if test="deviceId != null">
|
|
|
+ #{deviceId},
|
|
|
+ </if>
|
|
|
+ <if test="deviceNo != null">
|
|
|
+ #{deviceNo},
|
|
|
+ </if>
|
|
|
+ <if test="meterNo != null">
|
|
|
+ #{meterNo},
|
|
|
+ </if>
|
|
|
+ <if test="meterFileNo != null">
|
|
|
+ #{meterFileNo},
|
|
|
+ </if>
|
|
|
+ <if test="readTime != null">
|
|
|
+ #{readTime},
|
|
|
+ </if>
|
|
|
+ <if test="readStatus != null">
|
|
|
+ #{readStatus},
|
|
|
+ </if>
|
|
|
+ <if test="readData != null">
|
|
|
+ #{readData},
|
|
|
+ </if>
|
|
|
+ <if test="lastValid != null">
|
|
|
+ #{lastValid},
|
|
|
+ </if>
|
|
|
+ <if test="lastCost != null">
|
|
|
+ #{lastCost},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ #{status},
|
|
|
+ </if>
|
|
|
+ <if test="dateCreate != null">
|
|
|
+ #{dateCreate},
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null">
|
|
|
+ #{dateUpdate},
|
|
|
+ </if>
|
|
|
+ <if test="createBy != null">
|
|
|
+ #{createBy},
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null">
|
|
|
+ #{updateBy},
|
|
|
+ </if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+ <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.water.entity.MeterReadRecord">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ update sc_meter_read_record
|
|
|
+ <set>
|
|
|
+ <if test="readDate != null">
|
|
|
+ read_date = #{readDate},
|
|
|
+ </if>
|
|
|
+ <if test="siteId != null">
|
|
|
+ site_id = #{siteId},
|
|
|
+ </if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ sys_id = #{sysId},
|
|
|
+ </if>
|
|
|
+ <if test="province != null">
|
|
|
+ province = #{province},
|
|
|
+ </if>
|
|
|
+ <if test="city != null">
|
|
|
+ city = #{city},
|
|
|
+ </if>
|
|
|
+ <if test="region != null">
|
|
|
+ region = #{region},
|
|
|
+ </if>
|
|
|
+ <if test="community != null">
|
|
|
+ community = #{community},
|
|
|
+ </if>
|
|
|
+ <if test="customerId != null">
|
|
|
+ customer_id = #{customerId},
|
|
|
+ </if>
|
|
|
+ <if test="concentratorId != null">
|
|
|
+ concentrator_id = #{concentratorId},
|
|
|
+ </if>
|
|
|
+ <if test="collectorId != null">
|
|
|
+ collector_id = #{collectorId},
|
|
|
+ </if>
|
|
|
+ <if test="buildingId != null">
|
|
|
+ building_id = #{buildingId},
|
|
|
+ </if>
|
|
|
+ <if test="location != null">
|
|
|
+ `location` = #{location},
|
|
|
+ </if>
|
|
|
+ <if test="deviceTypeId != null">
|
|
|
+ device_type_id = #{deviceTypeId},
|
|
|
+ </if>
|
|
|
+ <if test="deviceId != null">
|
|
|
+ device_id = #{deviceId},
|
|
|
+ </if>
|
|
|
+ <if test="deviceNo != null">
|
|
|
+ device_no = #{deviceNo},
|
|
|
+ </if>
|
|
|
+ <if test="meterNo != null">
|
|
|
+ meter_no = #{meterNo},
|
|
|
+ </if>
|
|
|
+ <if test="meterFileNo != null">
|
|
|
+ meter_file_no = #{meterFileNo},
|
|
|
+ </if>
|
|
|
+ <if test="readTime != null">
|
|
|
+ read_time = #{readTime},
|
|
|
+ </if>
|
|
|
+ <if test="readStatus != null">
|
|
|
+ read_status = #{readStatus},
|
|
|
+ </if>
|
|
|
+ <if test="readData != null">
|
|
|
+ read_data = #{readData},
|
|
|
+ </if>
|
|
|
+ <if test="lastValid != null">
|
|
|
+ last_valid = #{lastValid},
|
|
|
+ </if>
|
|
|
+ <if test="lastCost != null">
|
|
|
+ last_cost = #{lastCost},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ `status` = #{status},
|
|
|
+ </if>
|
|
|
+ <if test="dateCreate != null">
|
|
|
+ date_create = #{dateCreate},
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null">
|
|
|
+ date_update = #{dateUpdate},
|
|
|
+ </if>
|
|
|
+ <if test="createBy != null">
|
|
|
+ create_by = #{createBy},
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null">
|
|
|
+ update_by = #{updateBy},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+ <select id="getDeviceVolume" resultType="java.lang.Double">
|
|
|
+ select ifnull(sum(last_cost),0) from sc_meter_read_record
|
|
|
+ where status = 1 and device_id = #{deviceId} and
|
|
|
+ read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
|
|
|
+ </select>
|
|
|
+ <select id="getRealTimeUseWater" resultType="com.zcxk.dto.UseWaterDto">
|
|
|
+ select read_date as date,last_cost as use_volume from sc_meter_read_record
|
|
|
+ where status = 1 and device_id = #{deviceId} and
|
|
|
+ read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
|
|
|
+ order by read_data asc
|
|
|
+ </select>
|
|
|
+ <select id="getUseWaterByMonth" resultType="com.zcxk.dto.UseWaterDto">
|
|
|
+ SELECT DATE_FORMAT(read_date,'%Y%m') as date,sum(last_cost) as useVolume FROM sc_meter_read_record
|
|
|
+ where status = 1 and device_id = #{deviceId}
|
|
|
+ and read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
|
|
|
+ GROUP BY date
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryNotWaterConsumptionDays" resultType="java.lang.Integer">
|
|
|
+ SELECT to_days(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day) ,'%Y%m%d')) - to_days(read_date) FROM sc_meter_read_record WHERE device_id = #{deviceId} and last_cost > 0 ORDER BY read_date DESC LIMIT 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="exceedConsumption" resultType="java.lang.Boolean">
|
|
|
+ SELECT last_cost > (read_data * 0.3) FROM sc_meter_read_record WHERE device_id = #{deviceId} and read_date = #{date}
|
|
|
+ </select>
|
|
|
+</mapper>
|