BisInspFscPblmDao.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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.BisInspFscPblmDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspFscPblm" id="bisInspFscPblmResultMap">
  5. <result property="name" column="NAME"/>
  6. <result property="type" column="TYPE"/>
  7. <result property="admOrg" column="ADM_ORG"/>
  8. <result property="basName" column="BAS_NAME"/>
  9. <result property="province" column="PROVINCE"/>
  10. <result property="city" column="CITY"/>
  11. <result property="country" column="COUNTRY"/>
  12. <result property="groupName" column="GROUP_NAME"/>
  13. <result property="persName" column="PERS_NAME"/>
  14. <result property="id" column="ID"/>
  15. <result property="rgstrId" column="RGSTR_ID"/>
  16. <result property="aUnit" column="A_UNIT"/>
  17. <result property="pblmDesc" column="PBLM_DESC"/>
  18. <result property="pblmImgSum" column="PBLM_IMG_SUM"/>
  19. <result property="pblmImgNum" column="PBLM_IMG_NUM"/>
  20. <result property="rectConc" column="RECT_CONC"/>
  21. <result property="rectMeas" column="RECT_MEAS"/>
  22. <result property="rectImgSum" column="RECT_IMG_SUM"/>
  23. <result property="rectImgNum" column="RECT_IMG_NUM"/>
  24. <result property="fdTm" column="FD_TM"/>
  25. <result property="rectLead" column="RECT_LEAD"/>
  26. <result property="rectMemb" column="RECT_MEMB"/>
  27. <result property="rectTm" column="RECT_TM"/>
  28. <result property="note" column="NOTE"/>
  29. <result property="dataStat" column="DATA_STAT"/>
  30. <result property="persId" column="PERS_ID"/>
  31. <result property="groupId" column="GROUP_ID"/>
  32. <result property="inTm" column="IN_TM"/>
  33. <result property="upTm" column="UP_TM"/>
  34. </resultMap>
  35. <sql id="table_columns">
  36. ID,
  37. RGSTR_ID,
  38. A_UNIT,
  39. PBLM_DESC,
  40. PBLM_IMG_SUM,
  41. PBLM_IMG_NUM,
  42. RECT_CONC,
  43. RECT_MEAS,
  44. RECT_IMG_SUM,
  45. RECT_IMG_NUM,
  46. FD_TM,
  47. RECT_LEAD,
  48. RECT_MEMB,
  49. RECT_TM,
  50. NOTE,
  51. DATA_STAT,
  52. PERS_ID,
  53. GROUP_ID,
  54. IN_TM,
  55. UP_TM
  56. </sql>
  57. <sql id="entity_properties">
  58. #{id},
  59. #{rgstrId},
  60. #{aUnit},
  61. #{pblmDesc},
  62. #{pblmImgSum},
  63. #{pblmImgNum},
  64. #{rectConc},
  65. #{rectMeas},
  66. #{rectImgSum},
  67. #{rectImgNum},
  68. #{fdTm},
  69. #{rectLead},
  70. #{rectMemb},
  71. #{rectTm},
  72. #{note},
  73. #{dataStat},
  74. #{persId},
  75. #{groupId},
  76. #{inTm},
  77. #{upTm}
  78. </sql>
  79. <sql id="entity_properties_item">
  80. #{item.id},
  81. #{item.rgstrId},
  82. #{item.aUnit},
  83. #{item.pblmDesc},
  84. #{item.pblmImgSum},
  85. #{item.pblmImgNum},
  86. #{item.rectConc},
  87. #{item.rectMeas},
  88. #{item.rectImgSum},
  89. #{item.rectImgNum},
  90. #{item.fdTm},
  91. #{item.rectLead},
  92. #{item.rectMemb},
  93. #{item.rectTm},
  94. #{item.note},
  95. #{item.dataStat},
  96. #{item.persId},
  97. #{item.groupId},
  98. #{item.inTm},
  99. #{item.upTm}
  100. </sql>
  101. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  102. <sql id="page_where">
  103. <trim prefix="where" prefixOverrides="and | or ">
  104. <if test="rgstrId != null and rgstrId != ''">and RGSTR_ID = #{rgstrId}</if>
  105. <if test="aUnit != null and aUnit != ''">and A_UNIT = #{aUnit}</if>
  106. <if test="pblmDesc != null and pblmDesc != ''">and PBLM_DESC = #{pblmDesc}</if>
  107. <if test="pblmImgSum != null and pblmImgSum != ''">and PBLM_IMG_SUM = #{pblmImgSum}</if>
  108. <if test="pblmImgNum != null and pblmImgNum != ''">and PBLM_IMG_NUM = #{pblmImgNum}</if>
  109. <if test="rectConc != null and rectConc != ''">and RECT_CONC = #{rectConc}</if>
  110. <if test="rectMeas != null and rectMeas != ''">and RECT_MEAS = #{rectMeas}</if>
  111. <if test="rectImgSum != null and rectImgSum != ''">and RECT_IMG_SUM = #{rectImgSum}</if>
  112. <if test="rectImgNum != null and rectImgNum != ''">and RECT_IMG_NUM = #{rectImgNum}</if>
  113. <if test="fdTm != null">and FD_TM = #{fdTm}</if>
  114. <if test="rectLead != null and rectLead != ''">and RECT_LEAD = #{rectLead}</if>
  115. <if test="rectMemb != null and rectMemb != ''">and RECT_MEMB = #{rectMemb}</if>
  116. <if test="rectTm != null">and RECT_TM = #{rectTm}</if>
  117. <if test="note != null and note != ''">and NOTE = #{note}</if>
  118. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  119. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  120. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  121. <if test="inTm != null">and IN_TM = #{inTm}</if>
  122. <if test="upTm != null">and UP_TM = #{upTm}</if>
  123. </trim>
  124. </sql>
  125. <select id="get" resultMap="bisInspFscPblmResultMap" parameterType="String">
  126. select
  127. <include refid="table_columns"/>
  128. from BIS_INSP_FSC_PBLM where ID = #{id}
  129. </select>
  130. <select id="getBy" resultMap="bisInspFscPblmResultMap">
  131. select
  132. <include refid="table_columns"/>
  133. from BIS_INSP_FSC_PBLM
  134. <include refid="page_where"/>
  135. </select>
  136. <select id="findAll" resultMap="bisInspFscPblmResultMap">
  137. select
  138. <include refid="table_columns"/>
  139. from BIS_INSP_FSC_PBLM
  140. </select>
  141. <select id="findList" resultMap="bisInspFscPblmResultMap">
  142. select
  143. <include refid="table_columns"/>
  144. from BIS_INSP_FSC_PBLM
  145. <include refid="page_where"/>
  146. </select>
  147. <sql id="choseSql">
  148. <choose>
  149. <when test="province !=null and province !=''">
  150. and B.province like '${province}%'
  151. </when>
  152. <otherwise>
  153. and B.province is null
  154. </otherwise>
  155. </choose>
  156. </sql>
  157. <select id="findPageList" resultMap="bisInspFscPblmResultMap">
  158. SELECT B.NAME,
  159. B.TYPE,
  160. B.ADM_ORG,
  161. H.BAS_NAME,
  162. G.AD_NAME AS PROVINCE,
  163. F.AD_NAME AS CITY,
  164. E.AD_NAME AS COUNTRY,
  165. D.ID AS GROUP_ID,
  166. D.PNM AS GROUP_NAME,
  167. A.ID,
  168. A.RGSTR_ID,
  169. A.A_UNIT,
  170. A.PBLM_DESC,
  171. A.PBLM_IMG_SUM,
  172. A.PBLM_IMG_NUM,
  173. A.RECT_CONC,
  174. A.RECT_MEAS,
  175. A.RECT_IMG_SUM,
  176. A.RECT_IMG_NUM,
  177. A.FD_TM,
  178. A.RECT_LEAD,
  179. A.RECT_MEMB,
  180. A.RECT_TM,
  181. A.NOTE,
  182. A.DATA_STAT,
  183. A.PERS_ID,
  184. A.IN_TM,
  185. A.UP_TM
  186. FROM BIS_INSP_FSC_PBLM A
  187. LEFT JOIN BIS_INSP_FSC_RGSTR B
  188. ON A.RGSTR_ID = B.ID
  189. LEFT JOIN BIS_INSP_ALL_OBJ C
  190. ON B.OBJ_ID = C.OBJ_ID
  191. LEFT JOIN BIS_INSP_ALL D
  192. ON C.ID = D.ID
  193. LEFT JOIN ATT_AD_X_BASE E
  194. ON B.AD_CODE = E.AD_CODE
  195. AND E.AD_GRAD = '4'
  196. LEFT JOIN ATT_AD_X_BASE F
  197. ON CONCAT(SUBSTR(B.AD_CODE, 0, 4), '00000000') = F.AD_CODE
  198. AND F.AD_GRAD = '3'
  199. LEFT JOIN ATT_AD_X_BASE G
  200. ON CONCAT(SUBSTR(B.AD_CODE, 0, 2), '0000000000') = G.AD_CODE
  201. AND G.AD_GRAD = '2'
  202. LEFT JOIN ATT_BAS_BASE H
  203. ON B.ADM_ORG = H.BAS_CODE
  204. <trim prefix="where" prefixOverrides="and | or ">
  205. 1=1
  206. <if test="rgstrId != null and rgstrId != ''">and A.RGSTR_ID = #{rgstrId}</if>
  207. <if test="aUnit != null and aUnit != ''">and A.A_UNIT LIKE CONCAT('%',CONCAT(#{aUnit},'%'))</if>
  208. <if test="pblmDesc != null and pblmDesc != ''">and A.PBLM_DESC LIKE CONCAT('%',CONCAT(#{pblmDesc},'%'))</if>
  209. <if test="pblmImgSum != null and pblmImgSum != ''">and A.PBLM_IMG_SUM = #{pblmImgSum}</if>
  210. <if test="pblmImgNum != null and pblmImgNum != ''">and A.PBLM_IMG_NUM = #{pblmImgNum}</if>
  211. <if test="rectConc != null and rectConc != ''">and A.RECT_CONC = #{rectConc}</if>
  212. <if test="rectMeas != null and rectMeas != ''">and A.RECT_MEAS LIKE CONCAT('%',CONCAT(#{rectMeas},'%'))</if>
  213. <if test="rectImgSum != null and rectImgSum != ''">and A.RECT_IMG_SUM = #{rectImgSum}</if>
  214. <if test="rectImgNum != null and rectImgNum != ''">and A.RECT_IMG_NUM = #{rectImgNum}</if>
  215. <if test="fdTm != null">and A.FD_TM = #{fdTm}</if>
  216. <if test="rectLead != null and rectLead != ''">and A.RECT_LEAD LIKE CONCAT('%',CONCAT(#{rectLead},'%'))</if>
  217. <if test="rectMemb != null and rectMemb != ''">and A.RECT_MEMB LIKE CONCAT('%',CONCAT(#{rectMemb},'%'))</if>
  218. <if test="rectTm != null">and A.RECT_TM = #{rectTm}</if>
  219. <if test="note != null and note != ''">and A.NOTE = #{note}</if>
  220. <if test="dataStat != null and dataStat != ''">and A.DATA_STAT = #{dataStat}</if>
  221. <if test="groupId != null and groupId != ''">and D.ID = #{groupId}</if>
  222. <if test="orgIds != null and orgIds != ''">and D.ID IN
  223. <foreach item="item" index="index" collection="orgIds.split(',')" open="(" separator="," close=")">
  224. '${item}'
  225. </foreach>
  226. </if>
  227. <if test="adCode != null and adCode != ''">and B.AD_CODE LIKE CONCAT(#{adCode},'%')</if>
  228. <if test="adName != null and adName != ''">and E.AD_FULL_NAME LIKE CONCAT('%',CONCAT(#{adName},'%'))</if>
  229. <if test="startTime != null">
  230. <if test='tmType =="1" or tmType =="" or tmType ==null'>
  231. and A.FD_TM &gt;= #{startTime}
  232. </if>
  233. <if test='tmType =="2"'>
  234. and A.RECT_TM &gt;= #{startTime}
  235. </if>
  236. </if>
  237. <if test="endTime != null">
  238. <if test='tmType =="1" or tmType =="" or tmType ==null'>
  239. and A.FD_TM &lt;= #{endTime}
  240. </if>
  241. <if test='tmType =="2"'>
  242. and A.RECT_TM &lt;= #{endTime}
  243. </if>
  244. </if>
  245. <if test="inTm != null">and A.IN_TM = #{inTm}</if>
  246. <if test="upTm != null">and A.UP_TM = #{upTm}</if>
  247. <if test="persId != null and persId != ''">and
  248. REGEXP_LIKE(
  249. D.Id,'^('||
  250. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  251. AND ID LIKE '009%'
  252. <include refid="choseSql"/>
  253. )>0 then
  254. (SELECT LISTAGG(id, '|') as
  255. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  256. AND ID LIKE '009%'
  257. <include refid="choseSql"/> GROUP BY PERSID
  258. )
  259. else (select 'non' from dual) end)
  260. ||')')
  261. </if>
  262. <if test="persName != null and persName != ''">
  263. AND J.PERS_NAME LIKE CONCAT('%',CONCAT(#{persName},'%'))
  264. </if>
  265. <if test="name != null and name != ''">and B.NAME LIKE CONCAT('%',CONCAT(#{name},'%'))</if>
  266. <if test="groupName != null and groupName != ''">and D.PNM LIKE CONCAT('%',CONCAT(#{groupName},'%'))</if>
  267. </trim>
  268. </select>
  269. <select id="selectCount" resultType="int">
  270. select count(ID) from BIS_INSP_FSC_PBLM
  271. <include refid="page_where"/>
  272. </select>
  273. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscPblm">
  274. insert into BIS_INSP_FSC_PBLM(
  275. <include refid="table_columns"/>
  276. )
  277. values (
  278. <include refid="entity_properties"/>
  279. )
  280. </insert>
  281. <delete id="delete" parameterType="java.lang.String">
  282. delete from BIS_INSP_FSC_PBLM where ID = #{id}
  283. </delete>
  284. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscPblm">
  285. delete from BIS_INSP_FSC_PBLM
  286. <include refid="page_where"/>
  287. </delete>
  288. <update id="deleteInFlag" parameterType="java.lang.String">
  289. update BIS_INSP_FSC_PBLM set flag_valid = 0 where ID = #{id}
  290. </update>
  291. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscPblm">
  292. update BIS_INSP_FSC_PBLM
  293. <trim prefix="set" suffixOverrides=",">
  294. <if test="rgstrId != null and rgstrId != ''">RGSTR_ID = #{rgstrId},</if>
  295. <if test="aUnit != null and aUnit != ''">A_UNIT = #{aUnit},</if>
  296. <if test="pblmDesc != null and pblmDesc != ''">PBLM_DESC = #{pblmDesc},</if>
  297. <if test="pblmImgSum != null and pblmImgSum != ''">PBLM_IMG_SUM = #{pblmImgSum},</if>
  298. <if test="pblmImgNum != null and pblmImgNum != ''">PBLM_IMG_NUM = #{pblmImgNum},</if>
  299. <if test="rectConc != null and rectConc != ''">RECT_CONC = #{rectConc},</if>
  300. <if test="rectMeas != null and rectMeas != ''">RECT_MEAS = #{rectMeas},</if>
  301. <if test="rectImgSum != null and rectImgSum != ''">RECT_IMG_SUM = #{rectImgSum},</if>
  302. <if test="rectImgNum != null and rectImgNum != ''">RECT_IMG_NUM = #{rectImgNum},</if>
  303. <if test="fdTm != null">FD_TM = #{fdTm},</if>
  304. <if test="rectLead != null and rectLead != ''">RECT_LEAD = #{rectLead},</if>
  305. <if test="rectMemb != null and rectMemb != ''">RECT_MEMB = #{rectMemb},</if>
  306. <if test="rectTm != null">RECT_TM = #{rectTm},</if>
  307. <if test="note != null and note != ''">NOTE = #{note},</if>
  308. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  309. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  310. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  311. <if test="inTm != null">IN_TM = #{inTm},</if>
  312. <if test="upTm != null">UP_TM = #{upTm},</if>
  313. </trim>
  314. <where>ID = #{id}</where>
  315. </update>
  316. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscPblm">
  317. update BIS_INSP_FSC_PBLM
  318. <trim prefix="set" suffixOverrides=",">
  319. <if test="rgstrId != null and rgstrId != ''">RGSTR_ID = #{rgstrId},</if>
  320. <if test="aUnit != null and aUnit != ''">A_UNIT = #{aUnit},</if>
  321. <if test="pblmDesc != null and pblmDesc != ''">PBLM_DESC = #{pblmDesc},</if>
  322. <if test="pblmImgSum != null and pblmImgSum != ''">PBLM_IMG_SUM = #{pblmImgSum},</if>
  323. <if test="pblmImgNum != null and pblmImgNum != ''">PBLM_IMG_NUM = #{pblmImgNum},</if>
  324. <if test="rectConc != null and rectConc != ''">RECT_CONC = #{rectConc},</if>
  325. <if test="rectMeas != null and rectMeas != ''">RECT_MEAS = #{rectMeas},</if>
  326. <if test="rectImgSum != null and rectImgSum != ''">RECT_IMG_SUM = #{rectImgSum},</if>
  327. <if test="rectImgNum != null and rectImgNum != ''">RECT_IMG_NUM = #{rectImgNum},</if>
  328. <if test="fdTm != null">FD_TM = #{fdTm},</if>
  329. <if test="rectLead != null and rectLead != ''">RECT_LEAD = #{rectLead},</if>
  330. <if test="rectMemb != null and rectMemb != ''">RECT_MEMB = #{rectMemb},</if>
  331. <if test="rectTm != null">RECT_TM = #{rectTm},</if>
  332. <if test="note != null and note != ''">NOTE = #{note},</if>
  333. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  334. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  335. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  336. <if test="inTm != null">IN_TM = #{inTm},</if>
  337. <if test="upTm != null">UP_TM = #{upTm},</if>
  338. </trim>
  339. <include refid="page_where"/>
  340. </update>
  341. <!-- 其他自定义SQL -->
  342. <insert id="insertList" parameterType="java.util.List" useGeneratedKeys="false">
  343. insert into BIS_INSP_FSC_PBLM(
  344. <include refid="table_columns"/>
  345. )
  346. select t.* from (
  347. <foreach collection="list" item="item" index="index" separator="union all">
  348. select
  349. <include refid="entity_properties_item"/>
  350. from dual
  351. </foreach>
  352. ) t
  353. </insert>
  354. <select id="findPblmList" parameterType="cn.com.goldenwater.dcproj.param.FileParam"
  355. resultType="cn.com.goldenwater.dcproj.dto.BisInspFscPblmDto">
  356. select x.id as groupObjId,x.name,x.ad_full_name,x.riverName,x.type,x.adm_org org,p.* from (
  357. select * from (
  358. select A.*,b.id as rgstrId,CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END AS fscState,(case when b.name is
  359. null then to_char(c.name) else b.name end) as name,b.type,b.IN_TM,b.UP_TM,
  360. c.id as baseId,b.adm_org,
  361. (case when b.location is null then c.location else b.location end) as location,ia.pnm groupName,ria.pnm
  362. riverName,ad.ad_full_name from BIS_INSP_ALL_OBJ A join BIS_INSP_FSC_RGSTR B on A.Obj_Id = B.Obj_Id left join
  363. att_fsc_base c on a.code = c.id
  364. left join ATT_AD_X_BASE ad on b.ad_code = ad.ad_code LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  365. left join BIS_INSP_ALL ria on substr(A.ID,0,6) = ria.id
  366. where 1 = 1
  367. <if test="adName != null and adName != ''">and ad.AD_FULL_NAME LIKE '%${adName}%'</if>
  368. <if test="groupId != null and groupId != ''">and A.id = #{groupId}</if>
  369. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  370. AND B.IN_TM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD') AND B.UP_TM &lt; TO_DATE(#{entm},'YYYY-MM-DD')+1
  371. </if>
  372. and
  373. REGEXP_LIKE(
  374. A.Id,'^('||
  375. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{presId})>0 then
  376. (SELECT LISTAGG(id, '|') as
  377. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{presId} GROUP BY PERSID)
  378. else (select 'non' from dual) end)
  379. ||')')
  380. ) where 1 = 1
  381. <if test="state != null and state != ''">
  382. and fscState in (${state})
  383. </if>
  384. <if test="name != null and name != ''">
  385. and name like '%${name}%'
  386. </if>
  387. ) x left join BIS_INSP_FSC_PBLM p on x.rgstrId = p.rgstr_id
  388. </select>
  389. </mapper>