BisInspGnrlRgstrDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.com.goldenwater.dcproj.dao.BisInspGnrlRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspGnrlRgstr" id="bisInspGnrlRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="adName" column="AD_NAME"/>
  10. <result property="loc" column="LOC"/>
  11. <result property="note" column="NOTE"/>
  12. <result property="state" column="STATE"/>
  13. <result property="centerX" column="CENTER_X"/>
  14. <result property="centerY" column="CENTER_Y"/>
  15. <result property="gdX" column="GD_X"/>
  16. <result property="gdY" column="GD_Y"/>
  17. <result property="intm" column="INTM"/>
  18. <result property="uptm" column="UPTM"/>
  19. <result property="dataStat" column="DATA_STAT"/>
  20. <result property="type" column="TYPE"/>
  21. </resultMap>
  22. <sql id="table_columns">
  23. ID,
  24. OBJ_ID,
  25. NM,
  26. AD_CODE,
  27. AD_NAME,
  28. LOC,
  29. NOTE,
  30. STATE,
  31. CENTER_X,
  32. CENTER_Y,
  33. GD_X,
  34. GD_Y,
  35. INTM,
  36. UPTM,
  37. DATA_STAT,
  38. TYPE
  39. </sql>
  40. <sql id="entity_properties">
  41. #{id},
  42. #{objId},
  43. #{nm},
  44. #{adCode},
  45. #{adName},
  46. #{loc},
  47. #{note},
  48. #{state},
  49. #{centerX},
  50. #{centerY},
  51. #{gdX},
  52. #{gdY},
  53. #{intm},
  54. #{uptm},
  55. #{dataStat},
  56. #{type}
  57. </sql>
  58. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  59. <sql id="page_where">
  60. <trim prefix="where" prefixOverrides="and | or ">
  61. <if test="type != null and type != ''">
  62. and TYPE = #{type}
  63. </if>
  64. <if test="objId != null and objId != ''">
  65. and OBJ_ID = #{objId}
  66. </if>
  67. <if test="nm != null and nm != ''">
  68. and NM = #{nm}
  69. </if>
  70. <if test="adCode != null and adCode != ''">
  71. and AD_CODE = #{adCode}
  72. </if>
  73. <if test="adName != null and adName != ''">
  74. and AD_NAME = #{adName}
  75. </if>
  76. <if test="loc != null and loc != ''">
  77. and LOC = #{loc}
  78. </if>
  79. <if test="note != null and note != ''">
  80. and NOTE = #{note}
  81. </if>
  82. <if test="state != null and state != ''">
  83. and STATE = #{state}
  84. </if>
  85. <if test="centerX != null and centerX != ''">
  86. and CENTER_X = #{centerX}
  87. </if>
  88. <if test="centerY != null and centerY != ''">
  89. and CENTER_Y = #{centerY}
  90. </if>
  91. <if test="gdX != null and gdX != ''">
  92. and GD_X = #{gdX}
  93. </if>
  94. <if test="gdY != null and gdY != ''">
  95. and GD_Y = #{gdY}
  96. </if>
  97. <if test="intm != null">
  98. and INTM = #{intm}
  99. </if>
  100. <if test="uptm != null">
  101. and UPTM = #{uptm}
  102. </if>
  103. <if test="dataStat != null and dataStat != ''">
  104. and DATA_STAT = #{dataStat}
  105. </if>
  106. and DATA_STAT='0'
  107. </trim>
  108. </sql>
  109. <select id="get" resultMap="bisInspGnrlRgstrResultMap" parameterType="String">
  110. select
  111. <include refid="table_columns"/>
  112. from BIS_INSP_GNRL_RGSTR where ID = #{id}
  113. </select>
  114. <select id="getBy" resultMap="bisInspGnrlRgstrResultMap">
  115. select
  116. <include refid="table_columns"/>
  117. from BIS_INSP_GNRL_RGSTR
  118. <include refid="page_where"/>
  119. </select>
  120. <select id="findAll" resultMap="bisInspGnrlRgstrResultMap">
  121. select
  122. <include refid="table_columns"/>
  123. from BIS_INSP_GNRL_RGSTR
  124. </select>
  125. <select id="findList" resultMap="bisInspGnrlRgstrResultMap">
  126. select
  127. <include refid="table_columns"/>
  128. from BIS_INSP_GNRL_RGSTR
  129. <include refid="page_where"/>
  130. </select>
  131. <select id="selectCount" resultType="int">
  132. select count(ID) from BIS_INSP_GNRL_RGSTR
  133. <include refid="page_where"/>
  134. </select>
  135. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspGnrlRgstr">
  136. insert into BIS_INSP_GNRL_RGSTR(
  137. <include refid="table_columns"/>
  138. )
  139. values (
  140. <include refid="entity_properties"/>
  141. )
  142. </insert>
  143. <delete id="delete" parameterType="java.lang.String">
  144. update BIS_INSP_GNRL_RGSTR set DATA_STAT='9' where ID = #{id}
  145. </delete>
  146. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspGnrlRgstr">
  147. update BIS_INSP_GNRL_RGSTR set DATA_STAT='9'
  148. <include refid="page_where"/>
  149. </delete>
  150. <update id="deleteInFlag" parameterType="java.lang.String">
  151. update BIS_INSP_GNRL_RGSTR set DATA_STAT = '9' where ID = #{id}
  152. </update>
  153. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspGnrlRgstr">
  154. update BIS_INSP_GNRL_RGSTR
  155. <trim prefix="set" suffixOverrides=",">
  156. <if test="type != null and type != ''">TYPE = #{type},</if>
  157. <if test="objId != null and objId != ''">OBJ_ID
  158. = #{objId},
  159. </if>
  160. <if test="nm != null and nm != ''">NM
  161. = #{nm},
  162. </if>
  163. <if test="adCode != null and adCode != ''">AD_CODE
  164. = #{adCode},
  165. </if>
  166. <if test="adName != null and adName != ''">AD_NAME
  167. = #{adName},
  168. </if>
  169. <if test="loc != null and loc != ''">LOC
  170. = #{loc},
  171. </if>
  172. <if test="note != null and note != ''">NOTE
  173. = #{note},
  174. </if>
  175. <if test="state != null and state != ''">STATE
  176. = #{state},
  177. </if>
  178. <if test="centerX != null and centerX != ''">CENTER_X
  179. = #{centerX},
  180. </if>
  181. <if test="centerY != null and centerY != ''">CENTER_Y
  182. = #{centerY},
  183. </if>
  184. <if test="gdX != null and gdX != ''">GD_X
  185. = #{gdX},
  186. </if>
  187. <if test="gdY != null and gdY != ''">GD_Y
  188. = #{gdY},
  189. </if>
  190. <if test="intm != null">INTM
  191. = #{intm},
  192. </if>
  193. <if test="uptm != null">UPTM
  194. = #{uptm},
  195. </if>
  196. <if test="dataStat != null and dataStat != ''">DATA_STAT
  197. = #{dataStat},
  198. </if>
  199. </trim>
  200. <where>ID = #{id}</where>
  201. </update>
  202. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspGnrlRgstr">
  203. update BIS_INSP_GNRL_RGSTR
  204. <trim prefix="set" suffixOverrides=",">
  205. <if test="type != null and type != ''">TYPE = #{type},</if>
  206. <if test="objId != null and objId != ''">OBJ_ID
  207. = #{objId},
  208. </if>
  209. <if test="nm != null and nm != ''">NM
  210. = #{nm},
  211. </if>
  212. <if test="adCode != null and adCode != ''">AD_CODE
  213. = #{adCode},
  214. </if>
  215. <if test="adName != null and adName != ''">AD_NAME
  216. = #{adName},
  217. </if>
  218. <if test="loc != null and loc != ''">LOC
  219. = #{loc},
  220. </if>
  221. <if test="note != null and note != ''">NOTE
  222. = #{note},
  223. </if>
  224. <if test="state != null and state != ''">STATE
  225. = #{state},
  226. </if>
  227. <if test="centerX != null and centerX != ''">CENTER_X
  228. = #{centerX},
  229. </if>
  230. <if test="centerY != null and centerY != ''">CENTER_Y
  231. = #{centerY},
  232. </if>
  233. <if test="gdX != null and gdX != ''">GD_X
  234. = #{gdX},
  235. </if>
  236. <if test="gdY != null and gdY != ''">GD_Y
  237. = #{gdY},
  238. </if>
  239. <if test="intm != null">INTM
  240. = #{intm},
  241. </if>
  242. <if test="uptm != null">UPTM
  243. = #{uptm},
  244. </if>
  245. <if test="dataStat != null and dataStat != ''">DATA_STAT
  246. = #{dataStat},
  247. </if>
  248. </trim>
  249. <include refid="page_where"/>
  250. </update>
  251. <!-- 其他自定义SQL -->
  252. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspGnrlRgstrDto">
  253. SELECT * FROM (
  254. select ia.province,
  255. A.CODE, A.ID nodeId, A.NM, A.ptype, aw.AD_FULL_NAME, ia.pnm groupName,
  256. B.id as rgstrId, (case when b.STATE is null then '0' else b.state end) STATE,
  257. B.ID,
  258. B.OBJ_ID,
  259. B.AD_CODE,
  260. B.AD_NAME,
  261. B.LOC,
  262. B.NOTE,
  263. B.CENTER_X,
  264. B.CENTER_Y,
  265. B.GD_X,
  266. B.GD_Y,
  267. B.INTM,
  268. B.UPTM,
  269. B.TYPE,
  270. B.DATA_STAT
  271. FROM BIS_INSP_ALL_OBJ A
  272. JOIN BIS_INSP_GNRL_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  273. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  274. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  275. <where>
  276. <if test="adCodes ==null or adCodes ==''">
  277. <choose>
  278. <when test='isAll =="1"'>
  279. </when>
  280. <otherwise>
  281. AND A.ID IN (
  282. SELECT DISTINCT wq.ID FROM (
  283. SELECT P.ID FROM BIS_INSP_ALL P
  284. WHERE FIND_IN_SET(P.ID, getSubNodes_bis_insp_all((SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  285. WHERE A.PERSID = #{presId} AND A.Type=#{pType} and length(A.id) in (3,6,9) group by A.PERSID ),0,0)) &gt; 0
  286. UNION ALL
  287. SELECT P.ID FROM BIS_INSP_ALL P WHERE P.ID IN (SELECT ID FROM BIS_INSP_ALL_RLATION A
  288. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  289. ) wq
  290. )
  291. </otherwise>
  292. </choose>
  293. </if>
  294. <if test="adCodes !=null and adCodes !=''">
  295. AND
  296. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  297. B.AD_CODE LIKE CONCAT('${item}','%')
  298. </foreach>
  299. </if>
  300. </where>
  301. ) A
  302. <where>
  303. <if test="prjType !=null and prjType !=''">AND TYPE = #{prjType}</if>
  304. <if test="id !=null and id !=''">and nodeId like '${id}%'</if>
  305. <if test="plnaId !=null and plnaId !=''">and nodeId like '${plnaId}%'</if>
  306. <if test="groupId != null and groupId != ''">and nodeId like '${groupId}%'</if>
  307. <if test="code !=null and code !=''">and code = #{code}</if>
  308. <if test="nm !=null and nm !=''">and nm like '%${nm}%'</if>
  309. <if test="state !=null and state !=''">and STATE in (${state})</if>
  310. <if test="adName != null and adName != ''">and AD_NAME like '%${adName}%'</if>
  311. <if test="sttm != null and sttm != ''">and Intm &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  312. <if test="entm != null and entm != ''">and Intm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)</if>
  313. <if test="adCode != null and adCode != ''">and AD_CODE LIKE '${adCode}%'</if>
  314. </where>
  315. order by nodeId, AD_CODE, ID
  316. <if test="orderBy != null and orderBy != ''">
  317. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  318. </if>
  319. </select>
  320. </mapper>