|
|
@@ -0,0 +1,139 @@
|
|
|
+<?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.yunfeiyun.agmp.iotm.web.mapper.IotDeviceBindMapper">
|
|
|
+
|
|
|
+ <select id="selectIotDeviceBindList" parameterType="IotDeviceBindListReqVo" resultType="IotDeviceBindVo">
|
|
|
+ SELECT *, COUNT(f.landId) AS landNum, COUNT(f.blockId) AS blockNum
|
|
|
+ FROM (
|
|
|
+ SELECT d.devBid, d.devtypeBid, dt.devtypeName, d.devCode, d.devName, t.tmnlandId, t.landId, ft.landName,
|
|
|
+ b.tmnblockId, b.blockId, fb.blockName, t.tmnlandAssigndate, b.tmnblockAssigndate
|
|
|
+ FROM IotDevice AS d
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT *
|
|
|
+ FROM TmnLand AS t
|
|
|
+ WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))
|
|
|
+ ) AS t ON t.tmnId = d.devBid
|
|
|
+ LEFT JOIN IotDevicetype AS dt on dt.devtypeBid = d.devtypeBid
|
|
|
+ LEFT JOIN FmsLand AS ft ON t.landId = ft.landId
|
|
|
+ LEFT JOIN TmnBlock AS b ON d.devBid = b.tmnId
|
|
|
+ LEFT JOIN FmsBlock AS fb ON b.blockId = fb.blockId
|
|
|
+ <where>
|
|
|
+ d.devDelstatus = '0' and tid = #{tid}
|
|
|
+ <if test="devtypeBid != null and devtypeBid != ''">and d.devtypeBid = #{devtypeBid}</if>
|
|
|
+ <if test="devCode != null and devCode != ''">
|
|
|
+ and (
|
|
|
+ (d.devCode like concat('%', #{devCode}, '%')) or (d.devName like concat('%', #{devCode}, '%'))
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="devName != null and devName != ''">and d.devName like concat('%', #{devName}, '%')</if>
|
|
|
+ <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
|
|
|
+ <if test="blockId != null and blockId != ''">and b.blockId = #{blockId}</if>
|
|
|
+ <if test="bindStatus != null and bindStatus != ''">
|
|
|
+ <if test="bindStatus == 0">
|
|
|
+ AND t.landId IS NULL
|
|
|
+ </if>
|
|
|
+ <if test="bindStatus == 1">
|
|
|
+ AND (NOT t.landId IS NULL)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ <if test="devtypePidList != null and devtypePidList.size() > 0">
|
|
|
+ and dt.devtypePid in
|
|
|
+ <foreach collection="devtypePidList" item="devtypePid" open="(" separator="," close=")">
|
|
|
+ #{devtypePid}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY d.devBid, t.landId, b.blockId
|
|
|
+ ) AS f
|
|
|
+ <if test="isGroupBy">
|
|
|
+ GROUP BY f.devBid
|
|
|
+ HAVING NOT (landNum = 0 AND blockNum != 0)
|
|
|
+ </if>
|
|
|
+ ORDER BY f.tmnlandAssigndate DESC, f.tmnblockAssigndate DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectIotDeviceBindDetailList" parameterType="IotDeviceBindListReqVo" resultType="IotDeviceBindVo">
|
|
|
+ SELECT d.devBid, d.devtypeBid, d.devCode, d.devName, t.tmnlandId, t.landId, ft.landName,
|
|
|
+ b.tmnblockId, b.blockId, fb.blockName
|
|
|
+ FROM IotDevice AS d
|
|
|
+ LEFT JOIN TmnLand AS t ON d.devBid = t.tmnId
|
|
|
+ LEFT JOIN FmsLand AS ft ON t.landId = ft.landId
|
|
|
+ LEFT JOIN TmnBlock AS b ON d.devBid = b.tmnId
|
|
|
+ LEFT JOIN FmsBlock AS fb ON b.blockId = fb.blockId
|
|
|
+ <where>
|
|
|
+ d.devDelstatus = '0' and tid = #{tid}
|
|
|
+ <if test="devBidList != null and devBidList.size() > 0">
|
|
|
+ and d.devBid in
|
|
|
+ <foreach collection="devBidList" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="landId != null and landId != ''">and t.landId = #{landId}</if>
|
|
|
+ <if test="blockId != null and blockId != ''">and b.blockId = #{blockId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY d.devBid, t.landId, b.blockId
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- <select id="selectDeviceBindStatistic" resultType="IotDeviceBindStatisticVo">-->
|
|
|
+<!-- SELECT dt.devtypeBid, dt.devtypeName, COUNT(*) AS devTypeNum, (-->
|
|
|
+<!-- SELECT count(*) AS bindNum-->
|
|
|
+<!-- FROM (-->
|
|
|
+<!-- SELECT d.devBid, t.landId-->
|
|
|
+<!-- FROM IotDevice AS d-->
|
|
|
+<!-- LEFT JOIN (-->
|
|
|
+<!-- SELECT *-->
|
|
|
+<!-- FROM TmnLand AS t-->
|
|
|
+<!-- WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))-->
|
|
|
+<!-- ) AS t ON t.tmnId = d.devBid-->
|
|
|
+<!-- WHERE d.devDelstatus = '0' AND NOT t.landId IS NULL-->
|
|
|
+<!-- GROUP BY d.devBid-->
|
|
|
+<!-- ) AS df-->
|
|
|
+<!-- ) AS bindNum-->
|
|
|
+<!-- FROM IotDevice AS d-->
|
|
|
+<!-- LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
|
|
|
+<!-- where d.devDelstatus = '0' AND NOT ((dt.devtypeBid IS NULL) OR (dt.devtypeBid = ''))-->
|
|
|
+<!-- GROUP BY dt.devtypeBid-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
+<!-- <select id="selectDeviceBindStatisticByLandId" parameterType="IotDeviceBindListReqVo"-->
|
|
|
+<!-- resultType="IotDeviceBindStatisticVo">-->
|
|
|
+<!-- SELECT dt.devtypeBid, dt.devtypeName, COUNT(*) AS devTypeNum, (-->
|
|
|
+<!-- SELECT count(*) AS bindNum-->
|
|
|
+<!-- FROM (-->
|
|
|
+<!-- SELECT d.devBid, t.landId-->
|
|
|
+<!-- FROM IotDevice AS d-->
|
|
|
+<!-- LEFT JOIN (-->
|
|
|
+<!-- SELECT *-->
|
|
|
+<!-- FROM TmnLand AS t-->
|
|
|
+<!-- WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))-->
|
|
|
+<!-- ) AS t ON t.tmnId = d.devBid-->
|
|
|
+<!-- WHERE d.devDelstatus = '0' AND NOT t.landId IS NULL-->
|
|
|
+<!-- GROUP BY d.devBid-->
|
|
|
+<!-- ) AS df-->
|
|
|
+<!-- ) AS bindNum-->
|
|
|
+<!-- FROM IotDevice AS d-->
|
|
|
+<!-- LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
|
|
|
+<!-- left join TmnLand on TmnLand.tmnId = d.devBid-->
|
|
|
+<!-- where d.devDelstatus = '0' AND NOT ((dt.devtypeBid IS NULL) OR (dt.devtypeBid = ''))-->
|
|
|
+<!-- <if test="landId != null and landId != ''">and TmnLand.landId = #{landId}</if>-->
|
|
|
+<!-- GROUP BY dt.devtypeBid-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
+<!-- <select id="selectIotDeviceBindListBylandIdAndBlock"-->
|
|
|
+<!-- resultType="com.yunfeiyun.agmp.iotm.device.domain.dtovo.IotDeviceBindVo">-->
|
|
|
+
|
|
|
+<!-- SELECT d.devBid, d.devtypeBid, d.devCode, d.devName, fb.landId, fl.landName,-->
|
|
|
+<!-- fb.blockId, fb.blockName,dt.devtypeName from IotDevice d-->
|
|
|
+<!-- LEFT JOIN TmnBase b ON d.devBid = b.tmnId-->
|
|
|
+<!-- left join TmnBlock a on a.tmnId=d.devBid-->
|
|
|
+<!-- LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
|
|
|
+<!-- LEFT JOIN FmsBlock AS fb ON a.blockId = fb.blockId-->
|
|
|
+<!-- left join FmsLand as fl on fl.landId=fb.landId-->
|
|
|
+
|
|
|
+<!-- where d.devDelstatus = '0' and a.blockId is not null and a.blockId !=''-->
|
|
|
+<!-- and a.blockId = #{blockId}-->
|
|
|
+
|
|
|
+<!-- </select>-->
|
|
|
+</mapper>
|