123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <?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.bz.smart_city.dao.ConcentratorMapper">
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Concentrator">
- <!--@mbg.generated-->
- <!--@Table sc_concentrator-->
- <id column="id" property="id" />
- <result column="site_id" property="siteId" />
- <result column="customer_id" property="customerId" />
- <result column="serial_number" property="serialNumber" />
- <result column="name" property="name" />
- <result column="type" property="type" />
- <result column="province" property="province" />
- <result column="city" property="city" />
- <result column="region" property="region" />
- <result column="building_id" property="buildingId" />
- <result column="address" property="address" />
- <result column="device_status" property="deviceStatus" />
- <result column="device_type" property="deviceType" />
- <result column="baud_rate" property="baudRate" />
- <result column="ip" property="ip" />
- <result column="port" property="port" />
- <result column="sim_no" property="simNo" />
- <result column="date_create" property="dateCreate" />
- <result column="date_update" property="dateUpdate" />
- <result column="create_by" property="createBy" />
- <result column="update_by" property="updateBy" />
- <result column="status" property="status" />
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id, site_id, customer_id, serial_number, `name`, `type`, province, city, region,
- building_id, address, device_status, device_type, baud_rate, ip, port, sim_no, date_create,
- date_update, create_by, update_by, `status`
- </sql>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.Concentrator" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_concentrator
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- site_id,
- </if>
- <if test="customerId != null">
- customer_id,
- </if>
- <if test="serialNumber != null">
- serial_number,
- </if>
- <if test="name != null">
- `name`,
- </if>
- <if test="type != null">
- `type`,
- </if>
- <if test="province != null">
- province,
- </if>
- <if test="city != null">
- city,
- </if>
- <if test="region != null">
- region,
- </if>
- <if test="buildingId != null">
- building_id,
- </if>
- <if test="address != null">
- address,
- </if>
- <if test="deviceStatus != null">
- device_status,
- </if>
- <if test="deviceType != null">
- device_type,
- </if>
- <if test="baudRate != null">
- baud_rate,
- </if>
- <if test="ip != null">
- ip,
- </if>
- <if test="port != null">
- port,
- </if>
- <if test="simNo != null">
- sim_no,
- </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>
- <if test="status != null">
- `status`,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- #{siteId},
- </if>
- <if test="customerId != null">
- #{customerId},
- </if>
- <if test="serialNumber != null">
- #{serialNumber},
- </if>
- <if test="name != null">
- #{name},
- </if>
- <if test="type != null">
- #{type},
- </if>
- <if test="province != null">
- #{province},
- </if>
- <if test="city != null">
- #{city},
- </if>
- <if test="region != null">
- #{region},
- </if>
- <if test="buildingId != null">
- #{buildingId},
- </if>
- <if test="address != null">
- #{address},
- </if>
- <if test="deviceStatus != null">
- #{deviceStatus},
- </if>
- <if test="deviceType != null">
- #{deviceType},
- </if>
- <if test="baudRate != null">
- #{baudRate},
- </if>
- <if test="ip != null">
- #{ip},
- </if>
- <if test="port != null">
- #{port},
- </if>
- <if test="simNo != null">
- #{simNo},
- </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>
- <if test="status != null">
- #{status},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.Concentrator">
- <!--@mbg.generated-->
- update sc_concentrator
- <set>
- <if test="siteId != null">
- site_id = #{siteId},
- </if>
- <if test="customerId != null">
- customer_id = #{customerId},
- </if>
- <if test="serialNumber != null">
- serial_number = #{serialNumber},
- </if>
- <if test="name != null">
- `name` = #{name},
- </if>
- <if test="type != null">
- `type` = #{type},
- </if>
- <if test="province != null">
- province = #{province},
- </if>
- <if test="city != null">
- city = #{city},
- </if>
- <if test="region != null">
- region = #{region},
- </if>
- <if test="buildingId != null">
- building_id = #{buildingId},
- </if>
- <if test="address != null">
- address = #{address},
- </if>
- <if test="deviceStatus != null">
- device_status = #{deviceStatus},
- </if>
- <if test="deviceType != null">
- device_type = #{deviceType},
- </if>
- <if test="baudRate != null">
- baud_rate = #{baudRate},
- </if>
- <if test="ip != null">
- ip = #{ip},
- </if>
- <if test="port != null">
- port = #{port},
- </if>
- <if test="simNo != null">
- sim_no = #{simNo},
- </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>
- <if test="status != null">
- `status` = #{status},
- </if>
- </set>
- where id = #{id}
- </update>
- <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_concentrator
- (site_id, customer_id, serial_number, `name`, `type`, province, city, region, building_id,
- address, device_status, device_type, baud_rate, ip, port, sim_no, date_create,
- date_update, create_by, update_by, `status`)
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.siteId}, #{item.customerId}, #{item.serialNumber}, #{item.name}, #{item.type},
- #{item.province}, #{item.city}, #{item.region}, #{item.buildingId}, #{item.address},
- #{item.deviceStatus}, #{item.deviceType}, #{item.baudRate}, #{item.ip}, #{item.port},
- #{item.simNo}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, #{item.updateBy},
- #{item.status})
- </foreach>
- </insert>
- <select id="getList" resultType="com.bz.smart_city.dto.ConcentratorDto">
- select
- scon.*,
- (select count(1) from sc_channel_number where status = 1 and concentrator_id = scon.id) as channel_num,
- (select count(1) from sc_collector where status = 1 and concentrator_id = scon.id) as collector_num,
- (select count(1) from sc_water_related_device where status = 1 and concentrator_id = scon.id) as device_num,
- sc.customer_name,
- sdt.equipment_type,
- sdt.model,
- sdm.name manufacturer_name,
- sb.name as building_name,
- sb.community
- from sc_concentrator scon
- left join sc_customer sc on(sc.id = scon.customer_id)
- left join sc_device_type sdt on (sdt.id = scon.device_type)
- left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id )
- left join sc_building sb on (sb.id = scon.building_id)
- where scon.status = 1
- <if test="siteId != null"> and scon.site_id = #{siteId}</if>
- <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
- <if test="deviceStatus != null"> and scon.device_status = #{deviceStatus}</if>
- <if test="customerId != null"> and scon.customer_id = #{customerId}</if>
- <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
- <if test="provinceId != null"> and sb.province = #{provinceId}</if>
- <if test="cityId != null"> and sb.city = #{cityId}</if>
- <if test="regionId != null"> and sb.region = #{regionId}</if>
- <if test="communityId != null"> and sb.community = #{communityId}</if>
- <if test="buildingId != null"> and sb.id = #{buildingId}</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- order by scon.date_create desc
- </select>
- <select id="findList" resultType="com.bz.smart_city.dto.ConcentratorDto">
- select
- scon.*
- from sc_concentrator scon
- where scon.status = 1
- <if test="siteId != null"> and scon.site_id = #{siteId}</if>
- <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and scon.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="getAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community,
- b.longitude,
- b.latitude,
- t1.device_count
- from sc_building b
- right join (
- select scon.building_id,count(1) as device_count
- from sc_concentrator scon
- where scon.status = 1
- <if test="siteId != null"> and scon.site_id = #{siteId}</if>
- <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
- <if test="deviceStatus != null"> and scon.device_status = #{deviceStatus}</if>
- <if test="customerId != null"> and scon.customer_id = #{customerId}</if>
- <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and scon.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- GROUP BY scon.building_id
- ) t1 on (t1.building_id = b.id)
- where b.status = 1
- </select>
- <select id="findBySerialNumberUnique" resultType="int">
- select count(1) from sc_concentrator where status = 1 and serial_number = #{serialNumber}
- <if test="id != null"> and id != #{id}</if>
- </select>
- <resultMap id="lazyLoadConcentrator" type="com.bz.smart_city.dto.ConcentratorDto" extends="BaseResultMap">
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="serial_number" property="serialNumber" jdbcType="VARCHAR"/>
- <collection property="channelNumberList" ofType="com.bz.smart_city.entity.ChannelNumber" select="com.bz.smart_city.dao.ChannelNumberMapper.getList"
- column="id"></collection>
- <collection property="collectorList" ofType="com.bz.smart_city.entity.Collector" select="com.bz.smart_city.dao.CollectorMapper.findList"
- column="id"></collection>
- </resultMap>
- <select id="getLazyList" resultMap="lazyLoadConcentrator">
- select
- id,
- serial_number
- from sc_concentrator where status = 1 and site_id = #{siteId}
- <if test="customerIds != null and customerIds.size() != 0">
- and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="findName" resultMap="BaseResultMap">
- select id,serial_number from sc_concentrator where status = 1 and site_id = #{siteId} and serial_number = #{serialNumber}
- </select>
- <select id="findById" resultMap="BaseResultMap">
- select * from sc_concentrator where status = 1 and id = #{concentratorId}
- </select>
- </mapper>
|