123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <?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>
- </mapper>
|