123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?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.huaxu.zoniot.dao.WaterMeterMapper">
- <resultMap id="BaseResultMap" type="com.huaxu.zoniot.entity.WaterMeter">
- <id column="device_id" jdbcType="BIGINT" property="deviceId" />
- <result column="water_meter_type" jdbcType="INTEGER" property="waterMeterType" />
- <result column="site_id" jdbcType="INTEGER" property="siteId" />
- <result column="sys_id" jdbcType="INTEGER" property="sysId" />
- <result column="province" jdbcType="INTEGER" property="province" />
- <result column="city" jdbcType="INTEGER" property="city" />
- <result column="region" jdbcType="INTEGER" property="region" />
- <result column="community" jdbcType="INTEGER" property="community" />
- <result column="customer_id" jdbcType="INTEGER" property="customerId" />
- <result column="concentrator_id" jdbcType="INTEGER" property="concentratorId" />
- <result column="collector_id" jdbcType="INTEGER" property="collectorId" />
- <result column="building_id" jdbcType="INTEGER" property="buildingId" />
- <result column="location" jdbcType="VARCHAR" property="location" />
- <result column="device_type_id" jdbcType="INTEGER" property="deviceTypeId" />
- <result column="device_id" jdbcType="BIGINT" property="deviceId" />
- <result column="device_no" jdbcType="VARCHAR" property="deviceNo" />
- <result column="meter_no" jdbcType="VARCHAR" property="meterNo" />
- <result column="meter_file_no" jdbcType="VARCHAR" property="meterFileNo" />
- <result column="reading_measuring_code" jdbcType="VARCHAR" property="readingMeasuringCode" />
- <result column="valve_measuring_code" jdbcType="VARCHAR" property="valveMeasuringCode" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="date_create" jdbcType="TIMESTAMP" property="dateCreate" />
- <result column="date_update" jdbcType="TIMESTAMP" property="dateUpdate" />
- <result column="create_by" jdbcType="VARCHAR" property="createBy" />
- <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
- <result column="community_name" jdbcType="VARCHAR" property="communityName" />
- <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
- <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
- <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
- <result column="city_name" jdbcType="VARCHAR" property="cityName"/>
- <result column="region_name" jdbcType="VARCHAR" property="regionName" />
- <result column="concentrator_no" jdbcType="VARCHAR" property="concentratorNo" />
- <result column="collector_no" jdbcType="VARCHAR" property="collectorNo" />
- <result column="device_type_name" jdbcType="VARCHAR" property="deviceTypeName"/>
- <result column="manufacturer_id" jdbcType="INTEGER" property="manufacturerId" />
- <result column="manufacturer_name" jdbcType="VARCHAR" property="manufacturerName" />
- </resultMap>
- <insert id="insert" keyProperty="waterMeter.id">
- INSERT INTO sc_device (
- id,
- device_no,
- device_type,
- sys_id,
- site_id,
- building_id,
- loc_desc,
- manufacturer_id,
- device_status,
- `status`,
- create_by,
- update_by,
- date_create,
- date_update,
- water_meter_no,
- water_meter_file_no,
- customer_id,
- register_status
- ) VALUES (
- #{waterMeter.deviceId,jdbcType=BIGINT},
- #{waterMeter.deviceNo,jdbcType=VARCHAR},
- #{waterMeter.deviceTypeId,jdbcType=BIGINT},
- #{waterMeter.sysId,jdbcType=BIGINT},
- #{waterMeter.siteId,jdbcType=BIGINT},
- #{waterMeter.buildingId,jdbcType=BIGINT},
- #{waterMeter.location,jdbcType=VARCHAR},
- #{waterMeter.manufacturerId,jdbcType=BIGINT},
- #{waterMeter.deviceStatus,jdbcType=INTEGER},
- #{waterMeter.status,jdbcType=INTEGER},
- #{waterMeter.createBy,jdbcType=VARCHAR},
- #{waterMeter.updateBy,jdbcType=VARCHAR},
- #{waterMeter.dateCreate,jdbcType=TIMESTAMP},
- #{waterMeter.dateUpdate,jdbcType=TIMESTAMP},
- #{waterMeter.meterNo,jdbcType=VARCHAR},
- #{waterMeter.meterFileNo,jdbcType=VARCHAR},
- #{waterMeter.customerId,jdbcType=INTEGER},
- #{waterMeter.registerStatus,jdbcType=INTEGER}
- )
- </insert>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- device_id ,water_meter_type,device_no, site_id, sys_id, building_id,
- province, city, region, community, customer_id, meter_no, meter_file_no,
- device_type_id, concentrator_id,collector_id, `location`,valve_measuring_code,
- reading_measuring_code,date_create
- </sql>
- <sql id="Base_Meter_Query_Column">
- d.id as device_id ,
- wmt.parent_id as water_meter_type ,
- d.device_no as device_no ,
- d.site_id as site_id ,
- d.sys_id as sys_id ,
- d.building_id as building_id ,
- b.province as province ,
- b.city as city ,
- b.region as region,
- b.community as community ,
- d.customer_id as customer_id ,
- d.water_meter_no as meter_no ,
- d.water_meter_file_no as meter_file_no,
- d.device_type as device_type_id ,
- wrd.concentrator_id as concentrator_id ,
- wrd.collector_id as collector_id ,
- d.loc_desc as location,
- wmt.valve_measuring_code as valve_measuring_code ,
- wmt.reading_measuring_code as reading_measuring_code,
- d.date_create as date_create,
- b.`name` as building_name,
- c.`name` as community_name ,
- p.name as province_name,
- cc.name as city_name,
- r.`name` as region_name,
- con.serial_number as concentrator_no,
- col.collector_no as collector_no,
- concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
- d.manufacturer_id as manufacturer_id ,
- m.`name` as manufacturer_name,
- cu.customer_name as customer_name,
- cn.channel_name as channel_name ,
- wrd.channel_number_id as channel_number_id
- </sql>
- <sql id="Base_Meter_Query_Where">
- d.`status` = 1
- and wmt.`status` = 1
- and wmt.valve_measuring_code is not null
- and wmt.reading_measuring_code is not null
- and wmt.parent_id in (1,2)
- </sql>
- <sql id = "Base_Meter_Query">
- SELECT
- <include refid="Base_Meter_Query_Column" />
- FROM
- <include refid="Base_Meter_Query_Table"></include>
- WHERE
- <include refid="Base_Meter_Query_Where" />
- </sql>
- <sql id="Base_Meter_Query_Table">
- sc_w_meter_type wmt
- left join sc_device d on (d.`status` = 1 and wmt.device_type_id = d.device_type)
- left join sc_water_related_device wrd on (wrd.device_id =d.id)
- left join sc_building b on (d.building_id = b.id)
- LEFT JOIN sc_community c on (b.community = c.id )
- LEFT JOIN sc_area p on (c.province = p.id)
- LEFT JOIN sc_area cc on (c.city = cc.id)
- LEFT JOIN sc_area r on (c.region =r.id)
- LEFT JOIN sc_concentrator con on (con.id = wrd.concentrator_id)
- LEFT JOIN sc_collector col on (col.id = wrd.collector_id)
- left join sc_device_type dt on (d.device_type = dt.id)
- left join sc_device_manufacturer m on (d.manufacturer_id = m.id)
- left join sc_customer cu on (cu.id = d.customer_id)
- left join sc_channel_number cn on(cn.id = wrd.channel_number_id)
- </sql>
- <select id="findAllWaterMeterList" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- </select>
- <select id="findWaterMeterListWithPage" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- order by d.id asc
- limit #{start,jdbcType=INTEGER},#{offset,jdbcType=INTEGER}
- </select>
- <select id="findWaterMeterById" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.id = #{deviceId,jdbcType=BIGINT}
- </select>
- <select id="findWaterMeterByDeviceNo" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.device_no = #{deviceNo,jdbcType=VARCHAR}
- limit 1
- </select>
- <select id="countWaterMeter" resultType="java.lang.Long">
- select
- count(1)
- from
- <include refid="Base_Meter_Query_Table"></include>
- WHERE
- <include refid="Base_Meter_Query_Where" />
- </select>
- <select id="countWaterMeterByShard" resultType="java.lang.Long">
- select
- count(1)
- from (
- <include refid="Base_Meter_Query" />
- limit #{shardBegin,jdbcType=INTEGER},#{shardSize,jdbcType=INTEGER}
- ) tmp
- </select>
- <select id="findShardWaterMeterListWithPage" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from (
- <include refid="Base_Meter_Query" />
- order by d.id asc
- limit #{shardBegin,jdbcType=INTEGER},#{shardSize,jdbcType=INTEGER}
- ) tmp
- limit #{start,jdbcType=INTEGER},#{offset,jdbcType=INTEGER}
- </select>
- <select id="findWaterMeterByDeviceNoAndCustomerId" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.device_no = #{deviceNo,jdbcType=VARCHAR}
- and d.customer_id = #{customerId,jdbcType=INTEGER}
- limit 1
- </select>
- <select id="findWaterMeterByMeterNoAndCustomerId" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.water_meter_no = #{meterNo,jdbcType=VARCHAR}
- and d.customer_id = #{customerId,jdbcType=INTEGER}
- limit 1
- </select>
- <select id="findWaterMeterByDeviceNoList" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.customer_id = #{customerId,jdbcType=INTEGER}
- and d.device_no in <foreach collection="deviceNoList" item="deviceNo" open="(" close=")" separator=",">#{deviceNo}</foreach>
- </select>
- <select id="findWaterMeterByDeviceNoAndChildrenCustomer" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.device_no in <foreach collection="deviceNoList" item="deviceNo" open="(" close=")" separator=",">#{deviceNo}</foreach>
- and d.customer_id in
- <foreach collection="customerList" item="customerId" open="(" close=")" separator=",">
- #{customerId}
- </foreach>
- </select>
- <select id="findWaterMeterByDeviceNoAndCustomerList" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- and d.device_no = #{deviceNo,jdbcType=INTEGER}
- and d.customer_id in
- <foreach collection="customerList" item="customerId" open="(" close=")" separator=",">
- #{customerId}
- </foreach>
- </select>
- <select id="getMeterListByRange" resultMap="BaseResultMap">
- <include refid="Base_Meter_Query" />
- AND d.sys_id != - 99
- <if test="customers != null and customers != '' ">
- AND FIND_IN_SET( d.customer_id, #{customers} )
- </if>
- <if test="communitys != null and communitys != '' ">
- AND FIND_IN_SET( c.id, #{communitys} )
- </if>
- <if test="buildings != null and buildings != '' ">
- AND FIND_IN_SET( d.building_id, #{buildings} )
- </if>
- <if test="channels != null and channels != '' ">
- AND FIND_IN_SET( d.sys_id, #{channels} )
- </if>
- <if test="deviceTypes != null and deviceTypes != '' ">
- AND FIND_IN_SET( d.device_type, #{deviceTypes} )
- </if>
- </select>
- <insert id="batchInsert" keyProperty="waterMeter.id" parameterType="map">
- INSERT INTO sc_device (
- id,
- device_no,
- device_type,
- sys_id,
- site_id,
- building_id,
- loc_desc,
- manufacturer_id,
- device_status,
- `status`,
- create_by,
- update_by,
- date_create,
- date_update,
- water_meter_no,
- water_meter_file_no,
- customer_id,
- register_status
- ) VALUES
- <foreach collection="list" item="item" separator=",">(
- #{item.deviceId,jdbcType=BIGINT},
- #{item.deviceNo,jdbcType=VARCHAR},
- #{item.deviceTypeId,jdbcType=BIGINT},
- #{item.sysId,jdbcType=BIGINT},
- #{item.siteId,jdbcType=BIGINT},
- #{item.buildingId,jdbcType=BIGINT},
- #{item.location,jdbcType=VARCHAR},
- #{item.manufacturerId,jdbcType=BIGINT},
- #{item.deviceStatus,jdbcType=INTEGER},
- #{item.status,jdbcType=INTEGER},
- #{item.createBy,jdbcType=VARCHAR},
- #{item.updateBy,jdbcType=VARCHAR},
- #{item.dateCreate,jdbcType=TIMESTAMP},
- #{item.dateUpdate,jdbcType=TIMESTAMP},
- #{item.meterNo,jdbcType=VARCHAR},
- #{item.meterFileNo,jdbcType=VARCHAR},
- #{item.customerId,jdbcType=INTEGER},
- #{item.registerStatus,jdbcType=INTEGER}
- )
- </foreach>
- </insert>
- <select id="getPushMeterList" resultType="java.util.HashMap">
- SELECT
- d.id AS deviceId,
- d.device_no AS deviceNo,
- cast(d.status as SIGNED ) AS status,
- dt.equipment_type AS deviceType,
- DATE_FORMAT( d.date_create, '%Y-%m-%d' ) AS dateCreate,
- ifnull(m.factory,f.`name`) as factory,
- m.user_name AS userName,
- if(LENGTH(trim(ifnull(ll.new_meter_start,'0')))>0 ,ifnull(ll.new_meter_start,'0'),'0') AS beginWSV,
- ifnull(m.area_name,c.`name`) AS areaName,
- d.loc_desc AS location,
- d.water_meter_no AS meterNumber,
- ifnull(m.meter_no,d.water_meter_no) as meter_no,
- ifnull(m.user_address,b.`name`) AS userAddress,
- m.user_no AS userNumber,
- m.user_phone AS userPhone,
- DATE_FORMAT(m.archive_time,'%Y-%m-%d') AS archiveTime,
- m.caliber
- FROM
- sc_device d
- Left JOIN sc_install_list ll on (d.id = ll.device_id and ll.status =1 )
- LEFT JOIN sc_meter_info m ON ( CONCAT('91000',d.water_meter_no) = m.meter_no )
- LEFT JOIN sc_device_type dt ON ( d.device_type = dt.id )
- LEFT JOIN sc_building b on (d.building_id =b.id)
- LEFT JOIN sc_community c on (b.community = c.id)
- left join sc_device_manufacturer f on (dt.manufacturer_id = f.id)
- where d.sys_id != -99
- <if test="customers != null and customers != '' ">
- AND FIND_IN_SET( d.customer_id, #{customers} )
- </if>
- <if test="communitys != null and communitys != '' ">
- AND FIND_IN_SET( c.id, #{communitys} )
- </if>
- <if test="buildings != null and buildings != '' ">
- AND FIND_IN_SET( d.building_id, #{buildings} )
- </if>
- <if test="channels != null and channels != '' ">
- AND FIND_IN_SET( d.sys_id, #{channels} )
- </if>
- <if test="deviceTypes != null and deviceTypes != '' ">
- AND FIND_IN_SET( d.device_type, #{deviceTypes} )
- </if>
- <if test="status != null">
- AND d.status = #{status}
- </if>
- and d.date_update > #{beginDate ,jdbcType=TIMESTAMP }
- and d.date_update <![CDATA[ <= ]]> #{endDate ,jdbcType=TIMESTAMP }
- </select>
- </mapper>
|