FmsLandMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.yunfeiyun.agmp.fms.mapper.FmsLandMapper">
  6. <sql id="selectFmsLandVo">
  7. select landId, landName, landArea, landBlockcount, landDevcount, landManager, landTel, landLocation, landRemark,
  8. landLatitude, landLongitude, landSeqfrom FmsLand
  9. </sql>
  10. <!-- <sql id="selectFmsLandHasResVo">-->
  11. <!-- select l.*,-->
  12. <!-- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,-->
  13. <!-- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds-->
  14. <!-- from FmsLand l-->
  15. <!-- </sql>-->
  16. <sql id="selectFmsLandHasResVo">
  17. SELECT l.landId, l.landName, l.landArea, l.landBlockcount, l.landManager, l.landTel, l.landLocation,
  18. l.landRemark, l.landLatitude, l.landLongitude,l.landSeq,
  19. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,
  20. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds,
  21. (SELECT COUNT(tmnlandId) FROM TmnLand tl WHERE tl.landId = l.landId) landDevcount,
  22. (SELECT u.userName FROM SysUser u WHERE u.userId = l.landManager) landManagerName
  23. from FmsLand l
  24. </sql>
  25. <select id="selectFmsLandList" parameterType="FmsLand" resultType="FmsLand">
  26. SELECT l.landId, l.landName, l.landArea, bc.landBlockcount, l.landManager, l.landTel, l.landLocation,
  27. l.landRemark, l.landLatitude, l.landLongitude,l.landSeq,l.tid,
  28. (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,
  29. (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds,
  30. (SELECT COUNT(tmnlandId) FROM TmnLand tl WHERE tl.landId = l.landId) landDevcount,
  31. (SELECT u.userName FROM SysUser u WHERE u.userId = l.landManager) landManagerName
  32. from FmsLand l
  33. LEFT JOIN (
  34. select count(landId) as landBlockcount,landId from FmsBlock where tid = #{tid} GROUP BY landId
  35. ) bc on bc.landId = l.landId
  36. <where>
  37. <if test="landId != null ">and l.landId = #{landId}</if>
  38. <if test="landName != null and landName != ''">and landName like concat('%', #{landName}, '%')</if>
  39. <if test="landNameEq != null and landNameEq != ''">and landName = #{landNameEq}</if>
  40. <if test="landArea != null ">and landArea = #{landArea}</if>
  41. <if test="landBlockcount != null ">and landBlockcount = #{landBlockcount}</if>
  42. <if test="landDevcount != null ">and landDevcount = #{landDevcount}</if>
  43. <if test="landManager != null and landManager != ''">and landManager = #{landManager}</if>
  44. <if test="landTel != null and landTel != ''">and landTel = #{landTel}</if>
  45. <if test="landLocation != null and landLocation != ''">and landLocation = #{landLocation}</if>
  46. <if test="landRemark != null and landRemark != ''">and landRemark = #{landRemark}</if>
  47. <if test="dataFilter == true and landIds !=null and landIds.size()>0">
  48. and l.landId in
  49. <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
  50. #{landId}
  51. </foreach>
  52. </if>
  53. and l.tid = #{tid}
  54. </where>
  55. order by l.landSeq
  56. </select>
  57. <select id="selectFmsLandByLandId" parameterType="String" resultType="FmsLand">
  58. <include refid="selectFmsLandHasResVo"/>
  59. where landId = #{landId} and tid = #{tid}
  60. </select>
  61. <select id="selectFmsLandTotal" parameterType="FmsLand" resultType="FmsLandTotalResVo">
  62. SELECT count(1) count, sum(landArea) landAreaSum, sum(landBlockcountSum) landBlockcountSum,
  63. (
  64. SELECT COUNT(tmnlandId) FROM TmnLand tl
  65. LEFT JOIN IotDevice idv on idv.devBid = tl.tmnId
  66. <where>
  67. idv.devDelstatus = '0' and tl.tid = #{tid}
  68. <if test="landId != null and landId != ''">and tl.landId = #{landId}</if>
  69. <if test="dataFilter == true and landIds !=null and landIds.size()>0">
  70. and tl.landId in
  71. <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
  72. #{landId}
  73. </foreach>
  74. </if>
  75. </where>
  76. ) landDevcountSum
  77. from FmsLand fl
  78. LEFT JOIN (select count(blockId) as landBlockcountSum,landId from FmsBlock GROUP BY landId ) fb on
  79. fb.landId = fl.landId
  80. <where>
  81. fl.tid = #{tid}
  82. <if test="landId != null and landId != ''">and fl.landId = #{landId}</if>
  83. <if test="dataFilter == true and landIds !=null and landIds.size()>0">
  84. and fl.landId in
  85. <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
  86. #{landId}
  87. </foreach>
  88. </if>
  89. </where>
  90. </select>
  91. <select id="selectDevCount" parameterType="FmsLand" resultType="int">
  92. SELECT COUNT(1) FROM (SELECT COUNT(tmnId) count FROM TmnLand
  93. <where>
  94. tid = #{tid}
  95. <if test="landId != null and landId != ''">and landId = #{landId}</if>
  96. <if test="dataFilter == true and landIds !=null and landIds.size()>0">
  97. and landId in
  98. <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
  99. #{landId}
  100. </foreach>
  101. </if>
  102. </where>
  103. GROUP BY tmnId
  104. ) tb
  105. </select>
  106. <insert id="insertFmsLand" parameterType="FmsLand">
  107. insert into FmsLand
  108. <trim prefix="(" suffix=")" suffixOverrides=",">
  109. <if test="landId != null">landId,</if>
  110. <if test="landName != null">landName,</if>
  111. <if test="landArea != null">landArea,</if>
  112. <if test="landBlockcount != null">landBlockcount,</if>
  113. <if test="landDevcount != null">landDevcount,</if>
  114. <if test="landManager != null">landManager,</if>
  115. <if test="landTel != null">landTel,</if>
  116. <if test="landLocation != null">landLocation,</if>
  117. <if test="landRemark != null">landRemark,</if>
  118. <if test="landLatitude != null">landLatitude,</if>
  119. <if test="landLongitude != null">landLongitude,</if>
  120. <if test="landSeq !=null">landSeq,</if>
  121. <if test="tid != null">tid,</if>
  122. </trim>
  123. <trim prefix="values (" suffix=")" suffixOverrides=",">
  124. <if test="landId != null">#{landId},</if>
  125. <if test="landName != null">#{landName},</if>
  126. <if test="landArea != null">#{landArea},</if>
  127. <if test="landBlockcount != null">#{landBlockcount},</if>
  128. <if test="landDevcount != null">#{landDevcount},</if>
  129. <if test="landManager != null">#{landManager},</if>
  130. <if test="landTel != null">#{landTel},</if>
  131. <if test="landLocation != null">#{landLocation},</if>
  132. <if test="landRemark != null">#{landRemark},</if>
  133. <if test="landLatitude != null">#{landLatitude},</if>
  134. <if test="landLongitude != null">#{landLongitude},</if>
  135. <if test="landSeq != null">#{landSeq},</if>
  136. <if test="tid != null">#{tid},</if>
  137. </trim>
  138. </insert>
  139. <update id="updateFmsLand" parameterType="FmsLand">
  140. update FmsLand
  141. <trim prefix="SET" suffixOverrides=",">
  142. <if test="landName != null">landName = #{landName},</if>
  143. <if test="landArea != null">landArea = #{landArea},</if>
  144. <if test="landBlockcount != null">landBlockcount = #{landBlockcount},</if>
  145. <if test="landDevcount != null">landDevcount = #{landDevcount},</if>
  146. <if test="landManager != null">landManager = #{landManager},</if>
  147. <if test="landTel != null">landTel = #{landTel},</if>
  148. <if test="landLocation != null">landLocation = #{landLocation},</if>
  149. <if test="landRemark != null">landRemark = #{landRemark},</if>
  150. <if test="landLatitude != null">landLatitude = #{landLatitude},</if>
  151. <if test="landLongitude != null">landLongitude = #{landLongitude},</if>
  152. <if test="landSeq != null">landSeq =#{landSeq},</if>
  153. </trim>
  154. where landId = #{landId} and tid = #{tid}
  155. </update>
  156. <update id="updateFmsLandBatch">
  157. <foreach collection="list" item="fmsLand" separator=";">
  158. update FmsLand
  159. <trim prefix="SET" suffixOverrides=",">
  160. <if test="fmsLand.landName != null">landName = #{fmsLand.landName},</if>
  161. <if test="fmsLand.landArea != null">landArea = #{fmsLand.landArea},</if>
  162. <if test="fmsLand.landBlockcount != null">landBlockcount = #{fmsLand.landBlockcount},</if>
  163. <if test="fmsLand.landDevcount != null">landDevcount = #{fmsLand.landDevcount},</if>
  164. <if test="fmsLand.landManager != null">landManager = #{fmsLand.landManager},</if>
  165. <if test="fmsLand.landTel != null">landTel = #{fmsLand.landTel},</if>
  166. <if test="fmsLand.landLocation != null">landLocation = #{fmsLand.landLocation},</if>
  167. <if test="fmsLand.landRemark != null">landRemark = #{fmsLand.landRemark},</if>
  168. <if test="fmsLand.landLatitude != null">landLatitude = #{fmsLand.landLatitude},</if>
  169. <if test="fmsLand.landLongitude != null">landLongitude = #{fmsLand.landLongitude},</if>
  170. <if test="fmsLand.landSeq != null">landSeq =#{fmsLand.landSeq},</if>
  171. <if test="tid != null and tid !='' and tid != '-1'">
  172. and tid = #{fmsLand.tid}
  173. </if>
  174. </trim>
  175. where landId = #{fmsLand.landId} and tid = #{fmsLand.tid}
  176. </foreach>
  177. </update>
  178. <delete id="deleteFmsLandByLandId" parameterType="String">
  179. delete from FmsLand where landId = #{landId} and tid = #{tid}
  180. </delete>
  181. <delete id="deleteFmsLandByLandIds" parameterType="String">
  182. delete from FmsLand where landId in
  183. <foreach item="landId" collection="array" open="(" separator="," close=")">
  184. #{landId}
  185. </foreach>
  186. and tid = #{tid}
  187. </delete>
  188. <select id="selectFmsLandByTarcecodeapplyno" parameterType="String" resultType="FmsLand">
  189. SELECT
  190. l.*
  191. FROM
  192. FmsLand l
  193. LEFT JOIn FmsTask t on t.landId = l.landId
  194. LEFT JOIN FmsTaskpick tp on tp.taskId = t.taskId
  195. where tp.pickNo = #{tarcecodeapplyno}
  196. and l.tid = #{tid}
  197. </select>
  198. <select id="selectFmsLandDeviceList" parameterType="TmnLandDeviceListReqVo"
  199. resultType="com.yunfeiyun.agmp.fms.domain.resvo.TmnLandDeviceInfoResVo">
  200. SELECT
  201. tb.tmnId, tb.tmnName, tb.tmnBizcode, tb.tmnType, tb.tmnLongitude, tb.tmnLatitude, tb.tmnCreateddate,
  202. tb.tmnStatus, tb.tmnUpdateddate, tb.tmnAddress
  203. FROM TmnLand AS tl
  204. LEFT JOIN TmnBase AS tb ON tl.tmnId = tb.tmnId
  205. <where>
  206. tl.landId = #{landId} and tl.tid = #{tid}
  207. <if test="tmnTypes !=null">
  208. and tb.tmnType in
  209. <foreach item="ty" collection="tmnTypes" open="(" separator="," close=")">
  210. #{ty}
  211. </foreach>
  212. </if>
  213. </where>
  214. </select>
  215. <select id="selectUserManagerWarehouseLandIds" resultType="java.lang.String">
  216. (
  217. SELECT
  218. landId
  219. FROM
  220. FmsLand
  221. WHERE
  222. landManager = #{userId}
  223. and tid = #{tid}
  224. )
  225. UNION ALL
  226. (
  227. SELECT
  228. landId
  229. FROM
  230. FmsLandHouse
  231. WHERE
  232. warehouseId IN ( SELECT warehouseId FROM WmsWarehouse WHERE warehouseManager = #{userId} and tid = #{tid})
  233. and tid = #{tid}
  234. )
  235. </select>
  236. <select id="selectFmsLandListByDeviceBind" resultType="FmsLandListByDeviceBindResVo">
  237. SELECT f.landId, f.landName, COUNT(t.tmnId) as devNum
  238. FROM FmsLand AS f
  239. LEFT JOIN (
  240. SELECT t.*
  241. FROM TmnLand AS t
  242. LEFT JOIN IotDevice AS d ON d.devBid = t.tmnId
  243. WHERE d.devDelstatus = '0' AND (NOT ((t.landId IS NULL) OR (t.landId = '') OR (d.devBid IS NULL)))
  244. and t.tid = #{tid}
  245. GROUP BY t.tmnId, t.landId
  246. ) AS t ON f.landId = t.landId
  247. GROUP BY f.landId
  248. </select>
  249. </mapper>