BisInspGnrlRgstrDao.xml 13 KB

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