|
@@ -0,0 +1,325 @@
|
|
|
+<?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
|
|
|
+ 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>
|
|
|
+ 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>
|
|
|
+ </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>
|
|
|
+ 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>
|
|
|
+</mapper>
|