123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <?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.zcxk.smartcity.data.access.dao.DeviceMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.zcxk.smartcity.data.access.entity.Device">
- <result column="id" property="id" jdbcType="BIGINT"/>
- <result column="device_no" property="deviceNo" jdbcType="VARCHAR"/>
- <result column="device_type" property="deviceType" jdbcType="BIGINT"/>
- <result column="device_category" property="deviceCategory" jdbcType="INTEGER"/>
- <result column="is_water" property="isWater" jdbcType="INTEGER"/>
- <result column="sys_id" property="sysId" jdbcType="BIGINT"/>
- <result column="site_id" property="siteId" jdbcType="BIGINT"/>
- <result column="building_id" property="buildingId" jdbcType="BIGINT"/>
- <result column="community" property="communityId" jdbcType="INTEGER"/>
- <result column="floor" property="floorId" jdbcType="INTEGER"/>
- <result column="loc_desc" property="locDesc" jdbcType="VARCHAR"/>
- <result column="related_device_no" property="relatedDeviceNo" jdbcType="BIGINT"/>
- <result column="manufacturer_id" property="manufacturerId" jdbcType="BIGINT"/>
- <result column="device_status" property="deviceStatus" jdbcType="INTEGER"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="is_tag" property="isTag" jdbcType="INTEGER"/>
- <result column="is_card" property="isCard" jdbcType="INTEGER"/>
- <result column="is_lora_meter" property="isLoraMeter" jdbcType="INTEGER"/>
- <result column="x_coordinates" property="xCoordinates" jdbcType="DECIMAL"/>
- <result column="y_coordinates" property="yCoordinates" jdbcType="DECIMAL"/>
- <result column="customer_id" property="customerId" jdbcType="INTEGER"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
- <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- id,
- device_no,
- device_type,
- sys_id,
- site_id,
- building_id,
- floor,
- loc_desc,
- related_device_no,
- manufacturer_id,
- device_status,
- status,
- is_tag,
- x_coordinates,
- y_coordinates,
- create_by,
- update_by,
- date_create,
- date_update
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="device.id">
- INSERT INTO sc_device (
- id,
- device_no,
- device_type,
- sys_id,
- site_id,
- building_id,
- floor,
- loc_desc,
- related_device_no,
- manufacturer_id,
- device_status,
- status,
- is_tag,
- x_coordinates,
- y_coordinates,
- create_by,
- update_by,
- date_create,
- date_update
- ) VALUES (
- #{device.id,jdbcType=BIGINT},
- #{device.deviceNo,jdbcType=VARCHAR},
- #{device.deviceType,jdbcType=BIGINT},
- #{device.sysId,jdbcType=BIGINT},
- #{device.siteId,jdbcType=BIGINT},
- #{device.buildingId,jdbcType=BIGINT},
- #{device.floorId,jdbcType=INTEGER},
- #{device.locDesc,jdbcType=VARCHAR},
- #{device.relatedDeviceNo,jdbcType=BIGINT},
- #{device.manufacturerId,jdbcType=BIGINT},
- #{device.deviceStatus,jdbcType=INTEGER},
- #{device.status,jdbcType=INTEGER},
- #{device.isTag,jdbcType=INTEGER},
- #{device.xCoordinates,jdbcType=DECIMAL},
- #{device.yCoordinates,jdbcType=DECIMAL},
- #{device.createBy,jdbcType=VARCHAR},
- #{device.updateBy,jdbcType=VARCHAR},
- #{device.dateCreate,jdbcType=TIMESTAMP},
- #{device.dateUpdate,jdbcType=TIMESTAMP}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="device.id">
- INSERT INTO sc_device
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="device.id!=null"> id,</if>
- <if test="device.deviceNo!=null"> device_no,</if>
- <if test="device.deviceType!=null"> device_type,</if>
- <if test="device.sysId!=null"> sys_id,</if>
- <if test="device.siteId!=null"> site_id,</if>
- <if test="device.buildingId!=null"> building_id,</if>
- <if test="device.floorId!=null"> floor,</if>
- <if test="device.locDesc!=null"> loc_desc,</if>
- <if test="device.relatedDeviceNo!=null"> related_device_no,</if>
- <if test="device.manufacturerId!=null"> manufacturer_id,</if>
- <if test="device.deviceStatus!=null"> device_status,</if>
- <if test="device.status!=null"> status,</if>
- <if test="device.isTag!=null"> is_tag,</if>
- <if test="device.xCoordinates!=null"> x_coordinates,</if>
- <if test="device.yCoordinates!=null"> y_coordinates,</if>
- <if test="device.createBy!=null"> create_by,</if>
- <if test="device.updateBy!=null"> update_by,</if>
- <if test="device.dateCreate!=null"> date_create,</if>
- <if test="device.dateUpdate!=null"> date_update,</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="device.id!=null">#{device.id,jdbcType=BIGINT},
- </if>
- <if test="device.deviceNo!=null">#{device.deviceNo,jdbcType=VARCHAR},
- </if>
- <if test="device.deviceType!=null">#{device.deviceType,jdbcType=BIGINT},
- </if>
- <if test="device.sysId!=null">#{device.sysId,jdbcType=BIGINT},
- </if>
- <if test="device.siteId!=null">#{device.siteId,jdbcType=BIGINT},
- </if>
- <if test="device.buildingId!=null">#{device.buildingId,jdbcType=BIGINT},
- </if>
- <if test="device.floorId!=null">#{device.floorId,jdbcType=INTEGER},
- </if>
- <if test="device.locDesc!=null">#{device.locDesc,jdbcType=VARCHAR},
- </if>
- <if test="device.relatedDeviceNo!=null">#{device.relatedDeviceNo,jdbcType=BIGINT},
- </if>
- <if test="device.manufacturerId!=null">#{device.manufacturerId,jdbcType=BIGINT},
- </if>
- <if test="device.deviceStatus!=null">#{device.deviceStatus,jdbcType=INTEGER},
- </if>
- <if test="device.status!=null">#{device.status,jdbcType=INTEGER},
- </if>
- <if test="device.isTag!=null">#{device.isTag,jdbcType=INTEGER},
- </if>
- <if test="device.xCoordinates!=null">#{device.xCoordinates,jdbcType=DECIMAL},
- </if>
- <if test="device.yCoordinates!=null">#{device.yCoordinates,jdbcType=DECIMAL},
- </if>
- <if test="device.createBy!=null">#{device.createBy,jdbcType=VARCHAR},
- </if>
- <if test="device.updateBy!=null">#{device.updateBy,jdbcType=VARCHAR},
- </if>
- <if test="device.dateCreate!=null">#{device.dateCreate,jdbcType=TIMESTAMP},
- </if>
- <if test="device.dateUpdate!=null">#{device.dateUpdate,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- INSERT INTO sc_device (
- id,
- device_no,
- device_type,
- sys_id,
- site_id,
- building_id,
- floor,
- loc_desc,
- related_device_no,
- manufacturer_id,
- device_status,
- status,
- is_tag,
- x_coordinates,
- y_coordinates,
- create_by,
- update_by,
- date_create,
- date_update
- )VALUES
- <foreach collection="devices" item="device" index="index" separator=",">
- (
- #{device.id,jdbcType=BIGINT},
- #{device.deviceNo,jdbcType=VARCHAR},
- #{device.deviceType,jdbcType=BIGINT},
- #{device.sysId,jdbcType=BIGINT},
- #{device.siteId,jdbcType=BIGINT},
- #{device.buildingId,jdbcType=BIGINT},
- #{device.floorId,jdbcType=INTEGER},
- #{device.locDesc,jdbcType=VARCHAR},
- #{device.relatedDeviceNo,jdbcType=BIGINT},
- #{device.manufacturerId,jdbcType=BIGINT},
- #{device.deviceStatus,jdbcType=INTEGER},
- #{device.status,jdbcType=INTEGER},
- #{device.isTag,jdbcType=INTEGER},
- #{device.xCoordinates,jdbcType=DECIMAL},
- #{device.yCoordinates,jdbcType=DECIMAL},
- #{device.createBy,jdbcType=VARCHAR},
- #{device.updateBy,jdbcType=VARCHAR},
- #{device.dateCreate,jdbcType=TIMESTAMP},
- #{device.dateUpdate,jdbcType=TIMESTAMP}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_device
- <set>
- <if test="device.deviceNo != null"> device_no= #{device.deviceNo,jdbcType=VARCHAR},</if>
- <if test="device.deviceType != null"> device_type= #{device.deviceType,jdbcType=BIGINT},</if>
- <if test="device.sysId != null"> sys_id= #{device.sysId,jdbcType=BIGINT},</if>
- <if test="device.siteId != null"> site_id= #{device.siteId,jdbcType=BIGINT},</if>
- <if test="device.buildingId != null"> building_id= #{device.buildingId,jdbcType=BIGINT},</if>
- <if test="device.floorId != null"> floor= #{device.floorId,jdbcType=INTEGER},</if>
- <if test="device.locDesc != null"> loc_desc= #{device.locDesc,jdbcType=VARCHAR},</if>
- <if test="device.relatedDeviceNo != null"> related_device_no= #{device.relatedDeviceNo,jdbcType=BIGINT},</if>
- <if test="device.manufacturerId != null"> manufacturer_id= #{device.manufacturerId,jdbcType=BIGINT},</if>
- <if test="device.deviceStatus != null"> device_status= #{device.deviceStatus,jdbcType=INTEGER},</if>
- <if test="device.status != null"> status= #{device.status,jdbcType=INTEGER},</if>
- <if test="device.isTag != null"> is_tag= #{device.isTag,jdbcType=INTEGER},</if>
- <if test="device.xCoordinates != null"> x_coordinates= #{device.xCoordinates,jdbcType=DECIMAL},</if>
- <if test="device.yCoordinates != null"> y_coordinates= #{device.yCoordinates,jdbcType=DECIMAL},</if>
- <if test="device.lastReceiveTime != null"> last_receive_time= #{device.lastReceiveTime,jdbcType=TIMESTAMP}</if>
- </set>
- WHERE id = #{device.id,jdbcType=BIGINT}
- </update>
- <select id="findByDeviceNo" resultMap="BaseResultMap">
- SELECT
- CASE WHEN
- ext.id IS NOT NULL THEN
- 1 ELSE 0
- END AS is_card,
- CASE WHEN
- c.id IS NOT NULL THEN
- 1 ELSE 0
- END AS is_lora_meter,
- d.id,
- d.device_no,
- d.device_no,
- d.water_meter_no,
- d.device_type,
- d.sys_id,
- d.site_id,
- d.building_id,
- d.floor,
- d.loc_desc,
- d.related_device_no,
- d.manufacturer_id,
- d.device_status,
- d.STATUS,
- d.is_tag,
- d.x_coordinates,
- d.y_coordinates,
- d.customer_id,
- b.community,
- IF
- ( mt.id IS NOT NULL, 1, 0 ) AS is_water,
- dt.device_type AS device_category,
- dt.equipment_type AS equipment_type
- FROM
- sc_device d
- LEFT JOIN sc_device_extend_info ext ON ( d.id = ext.device_id AND ext.extend_type_name = 'category' AND ext.extend_value = 'jobCard' AND ext.`status` = '1' )
- 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_w_meter_type mt ON ( d.device_type = mt.device_type_id)
- LEFT JOIN sc_channel_device_type_use tu on ( d.device_type = tu.device_type_id and tu.`status` = 1 )
- left join sc_channel c on (tu.channel_id = c.id and c.channel_code = 'lora_meter' and c.`status` = 1)
- WHERE
- d.STATUS = 1
- AND d.device_no = #{deviceNo} limit 1
- </select>
- <select id="findByMeterNo" resultMap="BaseResultMap">
- SELECT
- CASE WHEN
- ext.id IS NOT NULL THEN
- 1 ELSE 0
- END AS is_card,
- CASE WHEN
- c.id IS NOT NULL THEN
- 1 ELSE 0
- END AS is_lora_meter,
- d.id,
- d.device_no,
- d.device_no,
- d.water_meter_no,
- d.device_type,
- d.sys_id,
- d.site_id,
- d.building_id,
- d.floor,
- d.loc_desc,
- d.related_device_no,
- d.manufacturer_id,
- d.device_status,
- d.STATUS,
- d.is_tag,
- d.x_coordinates,
- d.y_coordinates,
- d.customer_id,
- b.community,
- IF
- ( mt.id IS NOT NULL, 1, 0 ) AS is_water,
- dt.device_type AS device_category,
- dt.equipment_type AS equipment_type
- FROM
- sc_device d
- LEFT JOIN sc_device_extend_info ext ON ( d.id = ext.device_id AND ext.extend_type_name = 'category' AND ext.extend_value = 'jobCard' AND ext.`status` = '1' )
- 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_w_meter_type mt ON ( d.device_type = mt.device_type_id)
- LEFT JOIN sc_channel_device_type_use tu on ( d.device_type = tu.device_type_id and tu.`status` = 1 )
- left join sc_channel c on (tu.channel_id = c.id and c.channel_code = 'lora_meter' and c.`status` = 1)
- WHERE
- d.STATUS = 1
- AND d.water_meter_no = #{meterNo,jdbcType=VARCHAR} limit 1
- </select>
- <update id="updateDeviceErrorDays">
- update sc_water_meter_error_days set days = #{days} , last_error_type = null where device_id = #{deviceId}
- </update>
- </mapper>
|