|
@@ -0,0 +1,317 @@
|
|
|
+<?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.zoniot.ccrc.dao.DeviceTypeMapper">
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <resultMap id="BaseResultMap" type="com.zoniot.ccrc.entity.DeviceType">
|
|
|
+ <result column="id" property="id" jdbcType="INTEGER"/>
|
|
|
+ <result column="equipment_type" property="equipmentType" jdbcType="VARCHAR"/>
|
|
|
+ <result column="model" property="model" jdbcType="VARCHAR"/>
|
|
|
+ <result column="manufacturer_id" property="manufacturerId" jdbcType="INTEGER"/>
|
|
|
+ <result column="device_type" property="deviceType" jdbcType="INTEGER"/>
|
|
|
+ <result column="status" property="status" jdbcType="INTEGER"/>
|
|
|
+ <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
|
|
|
+ <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
|
|
+ <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
|
|
|
+ <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
|
|
+ <result column="is_valve" property="isValve" jdbcType="INTEGER"/>
|
|
|
+ <result column="is_register" property="isRegister" jdbcType="INTEGER"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ id,
|
|
|
+ equipment_type,
|
|
|
+ model,
|
|
|
+ manufacturer_id,
|
|
|
+ device_type,
|
|
|
+ status,
|
|
|
+ create_date,
|
|
|
+ create_by,
|
|
|
+ update_date,
|
|
|
+ update_by,
|
|
|
+ is_valve,
|
|
|
+ is_register
|
|
|
+</sql>
|
|
|
+
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <insert id="insert" useGeneratedKeys="true" keyProperty="deviceType.id">
|
|
|
+ INSERT INTO sc_device_type (
|
|
|
+ id,
|
|
|
+ equipment_type,
|
|
|
+ model
|
|
|
+ ) VALUES (
|
|
|
+ #{deviceType.id,jdbcType=INTEGER},
|
|
|
+ #{deviceType.equipmentType,jdbcType=VARCHAR},
|
|
|
+ #{deviceType.model,jdbcType=VARCHAR}
|
|
|
+ )
|
|
|
+</insert>
|
|
|
+
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <insert id="insertSelective" useGeneratedKeys="true" keyProperty="deviceType.id">
|
|
|
+ INSERT INTO sc_device_type
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="deviceType.id!=null"> id,</if>
|
|
|
+ <if test="deviceType.equipmentType!=null"> equipment_type,</if>
|
|
|
+ <if test="deviceType.model!=null"> model</if>
|
|
|
+ </trim>
|
|
|
+ VALUES
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="deviceType.id!=null"> #{deviceType.id,jdbcType=INTEGER},</if>
|
|
|
+ <if test="deviceType.equipmentType!=null"> #{deviceType.equipmentType,jdbcType=VARCHAR},</if>
|
|
|
+ <if test="deviceType.model!=null"> #{deviceType.model,jdbcType=VARCHAR}</if>
|
|
|
+ </trim>
|
|
|
+</insert>
|
|
|
+
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <insert id="insertList">
|
|
|
+ INSERT INTO sc_device_type(
|
|
|
+ id,
|
|
|
+ equipment_type,
|
|
|
+ model
|
|
|
+ )VALUES
|
|
|
+ <foreach collection="deviceTypes" item="deviceType" index="index" separator=",">
|
|
|
+ (
|
|
|
+ #{deviceType.id,jdbcType=INTEGER},
|
|
|
+ #{deviceType.equipmentType,jdbcType=VARCHAR},
|
|
|
+ #{deviceType.model,jdbcType=VARCHAR}
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+</insert>
|
|
|
+
|
|
|
+ <!--auto generated Code-->
|
|
|
+ <update id="updateByPrimaryKeySelective">
|
|
|
+ UPDATE sc_device_type
|
|
|
+ <set>
|
|
|
+ <if test="deviceType.id != null"> id = #{deviceType.id,jdbcType=INTEGER},</if>
|
|
|
+ <if test="deviceType.equipmentType != null"> equipment_type = #{deviceType.equipmentType,jdbcType=VARCHAR},</if>
|
|
|
+ <if test="deviceType.model != null"> model = #{deviceType.model,jdbcType=VARCHAR}</if>
|
|
|
+ </set>
|
|
|
+ WHERE id = #{deviceType.id,jdbcType=INTEGER}
|
|
|
+ </update>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <select id="deleteQueryByManufacturerId" resultType="java.lang.Integer">
|
|
|
+ select id from sc_device_type where status = 1 and manufacturer_id = #{manufacturerId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!--auto generated by codehelper on 2018-12-19-->
|
|
|
+ <select id="findByid" resultMap="BaseResultMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sc_device_type
|
|
|
+ where id=#{id,jdbcType=INTEGER}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getDeviceTypeList" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ select
|
|
|
+ sdt.*,
|
|
|
+ sdm.name as manufacturer_name
|
|
|
+ from sc_device_type sdt
|
|
|
+ left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
|
|
|
+ where sdt.status = 1
|
|
|
+ <if test="sysId != null"> and sdt.id in (
|
|
|
+ select device_type_id from sc_channel_device_type_use scdtu where scdtu.status = 1
|
|
|
+ and scdtu.channel_id = #{sysId}
|
|
|
+ )</if>
|
|
|
+ <if test="type != null"> and sdt.device_type = #{type}</if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- <select id="getTreeData" resultType="com.bz.smart_city.dto.TreeDataDto">
|
|
|
+ select id,name as label,name as `value`
|
|
|
+ from sc_device_manufacturer
|
|
|
+ where status = 1
|
|
|
+ <if test="type != null"> and type = #{type}</if>
|
|
|
+ and id in(
|
|
|
+ select sdt.manufacturer_id
|
|
|
+ from sc_device_type sdt
|
|
|
+ where sdt.status = 1
|
|
|
+ <if test="type != null"> and sdt.device_type = #{type}</if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ and sdt.id in(
|
|
|
+ SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{sysId}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by manufacturer_id
|
|
|
+ )
|
|
|
+ </select>-->
|
|
|
+
|
|
|
+ <select id="getTreeData" resultType="com.zoniot.ccrc.dto.TreeDataDto">
|
|
|
+ select id,name as label,name as `value`
|
|
|
+ from sc_device_manufacturer
|
|
|
+ where status = 1
|
|
|
+ <if test="type != null"> and type = #{type}</if>
|
|
|
+ and id in(
|
|
|
+ select sdt.manufacturer_id
|
|
|
+ from sc_device_type sdt
|
|
|
+ where sdt.status = 1
|
|
|
+ <if test="type != null"> and sdt.device_type = #{type}</if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ and sdt.id in(
|
|
|
+ SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{sysId}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by manufacturer_id
|
|
|
+ )
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <resultMap id="lazyLoadDeviceType" type="com.zoniot.ccrc.dto.TreeDataDto" extends="BaseResultMap">
|
|
|
+ <collection property="children" ofType="com.zoniot.ccrc.dto.TreeDataDto" select="com.zoniot.ccrc.dao.DeviceTypeMapper.getTreeDataByManufacturerId"
|
|
|
+ column="id">
|
|
|
+ </collection>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap id="TreeDataDtoMap" type="com.zoniot.ccrc.dto.TreeDataDto">
|
|
|
+ <id column="id" property="id" jdbcType="INTEGER"/>
|
|
|
+ <result column="equipment_type" property="label" jdbcType="VARCHAR"/>
|
|
|
+ <result column="equipment_type" property="value" jdbcType="VARCHAR"/>
|
|
|
+ <collection property="children" ofType="com.zoniot.ccrc.dto.TreeDataDto">
|
|
|
+ <id column="id" property="id" jdbcType="INTEGER"/>
|
|
|
+ <result column="model" property="label" jdbcType="VARCHAR"/>
|
|
|
+ <result column="model" property="value" jdbcType="VARCHAR"/>
|
|
|
+ </collection>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="getTreeDataByManufacturerId" resultMap="TreeDataDtoMap">
|
|
|
+ select sdt.id,sdt.equipment_type,sdt.model
|
|
|
+ from sc_device_type sdt
|
|
|
+ where status=1 and manufacturer_id = #{manufacturerId}
|
|
|
+ <if test="channelId != null">
|
|
|
+ and sdt.id in(
|
|
|
+ SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{channelId}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findDeviceTypeUnique" resultType="int">
|
|
|
+ select count(1) from sc_device_type where status = 1
|
|
|
+ and manufacturer_id = #{manufacturerId} and equipment_type = #{equipmentType} and model = #{model}
|
|
|
+ <if test="id != null"> and id != #{id}</if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryList" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ equipment_type,
|
|
|
+ model,
|
|
|
+ manufacturer_id,
|
|
|
+ device_type,
|
|
|
+ STATUS,
|
|
|
+ create_date,
|
|
|
+ create_by,
|
|
|
+ period,
|
|
|
+ expression,
|
|
|
+ update_date,
|
|
|
+ update_by
|
|
|
+ FROM
|
|
|
+ sc_device_type
|
|
|
+ WHERE
|
|
|
+ `status` = 1
|
|
|
+ </select>
|
|
|
+ <select id="getWaterMeterType" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ SELECT
|
|
|
+ dt.id as id,
|
|
|
+ dt.model as model,
|
|
|
+ dt.equipment_type as equipment_type,
|
|
|
+ dt.device_type as device_type,
|
|
|
+ dt.manufacturer_id,
|
|
|
+ dm.`name` as manufacturer_name,
|
|
|
+ w.parent_id as meter_type
|
|
|
+ FROM
|
|
|
+ sc_device_type dt
|
|
|
+ left join sc_device_manufacturer dm on (dt.manufacturer_id = dm.id and dm.`status` = 1)
|
|
|
+ inner join sc_w_meter_type w on (w.device_type_id = dt.id and w.`status` = 1)
|
|
|
+ WHERE
|
|
|
+ dt.`status` = 1
|
|
|
+ <if test = "parentId != null and parentId != 0" >
|
|
|
+ and w.parent_id = #{parentId}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+ <select id="getConditionWithDeviceType" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ SELECT
|
|
|
+ dt.id as id,
|
|
|
+ dt.model as model,
|
|
|
+ dt.equipment_type as equipment_type,
|
|
|
+ dt.device_type as device_type,
|
|
|
+ dm.`name` as manufacturer_name
|
|
|
+ FROM
|
|
|
+ sc_device_type dt
|
|
|
+ left join sc_device_manufacturer dm on (dt.manufacturer_id = dm.id and dm.`status` = 1)
|
|
|
+ WHERE
|
|
|
+ dt.`status` = 1
|
|
|
+ <if test="buildingIds == null or buildingIds.length == 0">
|
|
|
+ AND exists (
|
|
|
+ select
|
|
|
+ 1
|
|
|
+ from
|
|
|
+ sc_channel_device_type_use dtu
|
|
|
+ where dtu.status = 1
|
|
|
+ <if test = "channelId != null ">
|
|
|
+ AND dtu.channel_id = #{channelId}
|
|
|
+ </if>
|
|
|
+ and dtu.device_type_id = dt.id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="buildingIds != null and buildingIds.length != 0">
|
|
|
+ AND EXISTS (
|
|
|
+ SELECT
|
|
|
+ 1
|
|
|
+ FROM
|
|
|
+ sc_device d
|
|
|
+ LEFT JOIN sc_building b ON ( b.id = d.building_id AND b.`status` = 1 )
|
|
|
+ WHERE
|
|
|
+ d.STATUS = 1
|
|
|
+ <if test = "siteId != null ">
|
|
|
+ AND d.site_id = #{siteId}
|
|
|
+ </if>
|
|
|
+ <if test = "channelId != null ">
|
|
|
+ AND d.sys_id = #{channelId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+
|
|
|
+ AND d.building_id IN
|
|
|
+ <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item} </foreach>
|
|
|
+ AND d.device_type = dt.id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findByIds" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ select
|
|
|
+ sdt.id,
|
|
|
+ sdt.equipment_type,
|
|
|
+ sdt.model,
|
|
|
+ sdt.manufacturer_id,
|
|
|
+ sdt.device_type,sdm.name as manufacturer_name,
|
|
|
+ w.parent_id as meter_type
|
|
|
+ from sc_device_type sdt
|
|
|
+ left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
|
|
|
+ left join sc_w_meter_type w on (w.device_type_id = sdt.id and w.status = 1)
|
|
|
+ where sdt.status = 1
|
|
|
+ <if test="deviceTypeIds != null and deviceTypeIds.size() != 0">
|
|
|
+ and sdt.id in
|
|
|
+ <foreach collection="deviceTypeIds" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+ <select id="getByName" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ select id,equipment_type,model,manufacturer_id,device_type from sc_device_type where status = 1
|
|
|
+ and equipment_type = #{deviceTypeName} and model =#{deviceTypeModel} limit 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getById" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
|
|
|
+ select
|
|
|
+ sdt.*,
|
|
|
+ sdm.en_name as en_manufacturer_name
|
|
|
+ from sc_device_type sdt
|
|
|
+ left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
|
|
|
+ where sdt.status = 1 and sdt.id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findByDeviceTypeId" resultMap="lazyLoadMeasuringPoint">
|
|
|
+ select id,equipment_type,model,manufacturer_id,device_type from sc_device_type where status = 1
|
|
|
+ and id = #{deviceTypeId}
|
|
|
+ </select>
|
|
|
+</mapper>
|
|
|
+
|