GeneralDownloadDao.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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.GeneralDownloadDao">
  4. <select id="getCodeByEngId" resultType="string">
  5. select code from BIS_INSP_ALL_OBJ o left join BIS_INSP_VILL_RGSTR r on o.obj_id = r.obj_id
  6. where r.eng_id = #{engId} and rownum = 1
  7. </select>
  8. <select id="getCodeById" resultType="map">
  9. select * from BIS_INSP_ALL_OBJ where id = #{id}
  10. </select>
  11. <select id="getRyNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  12. select distinct rgstr.eng_id id, obj.id pid, obj.nm pnm
  13. from BIS_INSP_ALL_OBJ obj left join BIS_INSP_VILL_RGSTR rgstr
  14. on obj.obj_id = rgstr.obj_id
  15. WHERE ENG_ID IS NOT NULL
  16. AND ID LIKE '002%' ORDER BY ID
  17. </select>
  18. <select id="getNodeProvincialExceptGroup" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  19. SELECT * FROM (
  20. SELECT
  21. ID,PID,PNM,STTM,ENTM
  22. FROM BIS_INSP_ALL T
  23. WHERE LENGTH(ID) &lt; 12
  24. AND REGEXP_LIKE(
  25. Id,'^('||
  26. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0 then
  27. (SELECT LISTAGG(id, '|') as
  28. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  29. else (select 'non' from dual) end)
  30. ||')')
  31. <if test="province != null and province != ''">
  32. AND T.PROVINCE LIKE '${province}%'
  33. </if>
  34. <if test="year != null and year != ''">
  35. AND ( TO_CHAR(T.STTM, 'yyyy') = #{year} OR LENGTH(ID) = 6 )
  36. </if>
  37. AND ID LIKE '${orgType}%'
  38. <if test="level == '3'.toString()">
  39. UNION
  40. select DISTINCT b.ad_code id,substr(t.id,0,9) pid,b.ad_name pnm,null sttm,null entm from BIS_INSP_SEL_AREA t
  41. left join ATT_AD_BASE b on substr(t.ad_code,0,4)||'00000000' = b.ad_code
  42. where t.id like '${orgType}%'
  43. and REGEXP_LIKE(
  44. t.id,'^('||
  45. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  46. then
  47. (SELECT LISTAGG(id, '|') as
  48. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  49. else (select 'non' from dual) end)
  50. ||')')
  51. <if test="province != null and province != ''">
  52. And t.ad_code like '${province}%'
  53. </if>
  54. </if>
  55. <if test="level == '4'.toString()">
  56. UNION
  57. select DISTINCT b.ad_code || substr(id,0,9) id,substr(t.id,0,9) pid,b.ad_name pnm,null sttm,null entm from
  58. BIS_INSP_SEL_AREA t
  59. left join ATT_AD_BASE b on substr(t.ad_code,0,4)||'00000000' = b.ad_code
  60. where t.id like '${orgType}%'
  61. and REGEXP_LIKE(
  62. t.id,'^('||
  63. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  64. then
  65. (SELECT LISTAGG(id, '|') as
  66. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  67. else (select 'non' from dual) end)
  68. ||')')
  69. <if test="province != null and province != ''">
  70. And t.ad_code like '${province}%'
  71. </if>
  72. UNION
  73. select DISTINCT b.ad_code id,b.ad_fcode || substr(t.id,0,9) pid,b.ad_name pnm,null sttm,null entm from
  74. BIS_INSP_SEL_AREA t
  75. left join ATT_AD_BASE b on substr(t.ad_code,0,6)||'000000' = b.ad_code
  76. where t.id like '${orgType}%' and length(rtrim(t.ad_code,'00')) &gt;= 5
  77. and REGEXP_LIKE(
  78. t.id,'^('||
  79. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  80. then
  81. (SELECT LISTAGG(id, '|') as
  82. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  83. else (select 'non' from dual) end)
  84. ||')')
  85. <if test="province != null and province != ''">
  86. And t.ad_code like '${province}%'
  87. </if>
  88. </if>
  89. ) order by id
  90. </select>
  91. <select id="getRyNodeProvincial" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  92. select * from (
  93. select id,pid,pnm,sttm,entm from
  94. BIS_INSP_ALL t where
  95. REGEXP_LIKE(
  96. Id,'^('||
  97. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0 then
  98. (SELECT LISTAGG(id, '|') as
  99. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  100. else (select 'non' from dual) end)
  101. ||')')
  102. <if test="level == '1'.toString()">
  103. AND LENGTH(id) &lt;=6
  104. </if>
  105. <if test="province != null and province != ''">
  106. And t.province like '${province}%'
  107. </if>
  108. AND ID LIKE '${orgType}%'
  109. <if test="orgType != '001' and orgType != '006' and orgType !='036' and orgType !='022'and orgType !='023'">
  110. UNION
  111. select b.ad_code id,substr(id,0,6) pid,b.ad_name pnm,null as sttm,null as entm
  112. from BIS_INSP_ALL_OBJ o left join ATT_AD_X_BASE b on substr(o.code,0,2)||'0000000000' = b.ad_code
  113. where
  114. REGEXP_LIKE(
  115. o.id,'^('||
  116. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  117. then
  118. (SELECT LISTAGG(id, '|') as
  119. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  120. else (select 'non' from dual) end)
  121. ||')')
  122. AND o.id like '${orgType}%'
  123. </if>
  124. <if test="level == '3'.toString()">
  125. UNION
  126. select distinct b.ad_code id,o.id as pid,b.ad_name pnm,null as sttm,null as entm
  127. from BIS_INSP_ALL_OBJ o left join ATT_AD_X_BASE b on substr(o.code,0,4)||'00000000' = b.ad_code
  128. left join (select distinct substr(ad_code,0,4) as ad_code,id from BIS_INSP_SEL_AREA where id like
  129. '${orgType}%') c on c.id = o.id
  130. where
  131. REGEXP_LIKE(
  132. o.id,'^('||
  133. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  134. then
  135. (SELECT LISTAGG(id, '|') as
  136. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  137. else (select 'non' from dual) end)
  138. ||')')
  139. AND o.id like '${orgType}%'
  140. AND o.id IS NOT NULL
  141. and substr(o.code,0,4) = c.ad_code
  142. <if test="province != null and province != ''">
  143. And c.ad_code like '${province}%'
  144. </if>
  145. </if>
  146. <if test="level == '4'.toString()">
  147. UNION
  148. select distinct b.ad_code||o.id as id,o.id pid,b.ad_name pnm,null as sttm,null as entm
  149. from BIS_INSP_ALL_OBJ o left join ATT_AD_X_BASE b on substr(o.code,0,4)||'00000000' = b.ad_code
  150. left join (select distinct substr(ad_code,0,4) as ad_code,id from BIS_INSP_SEL_AREA where id like
  151. '${orgType}%') c on c.id = o.id
  152. where
  153. REGEXP_LIKE(
  154. o.id,'^('||
  155. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  156. then
  157. (SELECT LISTAGG(id, '|') as
  158. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  159. else (select 'non' from dual) end)
  160. ||')')
  161. AND o.id like '${orgType}%'
  162. AND o.id IS NOT NULL
  163. and substr(o.code,0,4) = c.ad_code
  164. <if test="province != null and province != ''">
  165. And c.ad_code like '${province}%'
  166. </if>
  167. UNION
  168. select distinct b.ad_code id,b.ad_fcode || o.id as pid,b.ad_name pnm,null as sttm,null as entm
  169. from BIS_INSP_ALL_OBJ o left join ATT_AD_X_BASE b on substr(o.code,0,6)||'000000' = b.ad_code
  170. left join (select distinct substr(ad_code,0,4) as ad_code,id from BIS_INSP_SEL_AREA where id like
  171. '${orgType}%') c on c.id = o.id
  172. where
  173. REGEXP_LIKE(
  174. o.id,'^('||
  175. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%')>0
  176. then
  177. (SELECT LISTAGG(id, '|') as
  178. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '${orgType}%' GROUP BY PERSID)
  179. else (select 'non' from dual) end)
  180. ||')')
  181. AND o.id like '${orgType}%'
  182. AND o.id IS NOT NULL
  183. and substr(o.code,0,4) = c.ad_code
  184. <if test="province != null and province != ''">
  185. And c.ad_code like '${province}%'
  186. </if>
  187. </if>
  188. ) order by id
  189. </select>
  190. <select id="getRsraqgNodeProvincial" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  191. select * from (
  192. select id,pid,pnm,sttm,entm from
  193. BIS_INSP_ALL t where
  194. REGEXP_LIKE(
  195. Id,'^('||
  196. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%')>0 then
  197. (SELECT LISTAGG(id, '|') as
  198. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%' GROUP BY PERSID)
  199. else (select 'non' from dual) end)
  200. ||')')
  201. <if test="level == '1'.toString()">
  202. AND LENGTH(id) &lt;=6
  203. </if>
  204. <if test="province != null and province != ''">
  205. And t.province like '${province}%'
  206. </if>
  207. AND ID LIKE '023%'
  208. <if test="level == '3'.toString()">
  209. UNION
  210. select distinct o.code id,o.id as pid,o.nm pnm,null as sttm,null as entm
  211. from BIS_INSP_ALL_OBJ o
  212. where
  213. REGEXP_LIKE(
  214. o.id,'^('||
  215. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%')>0 then
  216. (SELECT LISTAGG(id, '|') as
  217. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%' GROUP BY PERSID)
  218. else (select 'non' from dual) end)
  219. ||')')
  220. AND o.id like '023%'
  221. AND o.id IS NOT NULL
  222. <if test="province != null and province != ''">
  223. And o.code like '${province}%'
  224. </if>
  225. </if>
  226. <if test="level == '4'.toString()">
  227. UNION
  228. select distinct o.code||o.id id,o.id as pid,o.nm pnm,null as sttm,null as entm
  229. from BIS_INSP_ALL_OBJ o
  230. where
  231. REGEXP_LIKE(
  232. o.id,'^('||
  233. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%')>0 then
  234. (SELECT LISTAGG(id, '|') as
  235. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%' GROUP BY PERSID)
  236. else (select 'non' from dual) end)
  237. ||')')
  238. AND o.id like '023%'
  239. AND o.id IS NOT NULL
  240. <if test="province != null and province != ''">
  241. And o.code like '${province}%'
  242. </if>
  243. UNION
  244. select distinct c.Ad_code id,t.ad_code || o.id as pid,c.ad_name pnm,null as sttm,null as entm
  245. from BIS_INSP_ALL_OBJ o left join BIS_INSP_RSRAQG_RGSTR t on o.obj_id = t.obj_id left join
  246. BIS_INSP_RSRAQG_RGSTR_COUNTY c on c.rgstr_id = t.id
  247. where
  248. REGEXP_LIKE(
  249. o.id,'^('||
  250. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%')>0 then
  251. (SELECT LISTAGG(id, '|') as
  252. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} and id like '023%' GROUP BY PERSID)
  253. else (select 'non' from dual) end)
  254. ||')')
  255. AND o.id like '023%'
  256. AND o.id IS NOT NULL
  257. <if test="province != null and province != ''">
  258. And o.code like '${province}%'
  259. </if>
  260. </if>
  261. ) order by id
  262. </select>
  263. <select id="getSzyNodeProvincial" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  264. select * from (
  265. SELECT ID,PID,PNM,STTM,ENTM FROM
  266. (select distinct substr(id,4,3) id, '001'as pid, pnm, sttm, entm,
  267. row_number() over(partition by substr(id,4,3) order by pnm) as rn
  268. from BIS_INSP_ALL t
  269. where REGEXP_LIKE(Id,
  270. '^(' || (case
  271. when (SELECT count(id)
  272. from BIS_INSP_ALL_RLATION
  273. WHERE PERSID = #{userid}) > 0 then
  274. (SELECT LISTAGG(id, '|') as id
  275. FROM BIS_INSP_ALL_RLATION
  276. WHERE PERSID = #{userid} GROUP BY PERSID)
  277. else
  278. (select 'non' from dual)
  279. end) || ')')
  280. AND LENGTH(id) = 6
  281. AND (ID LIKE '012%' or ID LIKE '013%' or ID LIKE '014%' or ID LIKE '015%' OR ID LIKE '016%')
  282. )
  283. WHERE RN = 1
  284. UNION
  285. SELECT '001' AS ID,'0' AS PID,'水资源督查' as pnm,null as sttm,null as entm from dual
  286. UNION
  287. select distinct b.ad_code id,
  288. substr(id, 4, 3) pid,
  289. b.ad_name pnm,
  290. null as sttm,
  291. null as entm
  292. from BIS_INSP_ALL_OBJ o
  293. left join ATT_AD_X_BASE b
  294. on substr(o.code, 0, 2) || '0000000000' = b.ad_code
  295. where REGEXP_LIKE(o.id,
  296. '^(' || (case
  297. when (SELECT count(id)
  298. from BIS_INSP_ALL_RLATION
  299. WHERE PERSID = #{userid}) > 0 then
  300. (SELECT LISTAGG(id, '|') as id
  301. FROM BIS_INSP_ALL_RLATION
  302. WHERE PERSID = #{userid} GROUP BY PERSID)
  303. else
  304. (select 'non' from dual)
  305. end) || ')')
  306. AND (o.id like '012%' or o.id LIKE '013%' or o.id LIKE '014%' or o.id LIKE '015%' OR o.id LIKE '016%')
  307. AND b.ad_name is not null
  308. ) order by id
  309. </select>
  310. <select id="getLyNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  311. select id,pid,pnm,sttm,entm from BIS_INSP_ALL where id in (
  312. select substr(id,0,6) id from
  313. BIS_INSP_ALL t where
  314. REGEXP_LIKE(
  315. Id,'^('||
  316. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID = #{userid}
  317. <include refid="orgIdSql"/>
  318. )>0 then
  319. (SELECT LISTAGG(id, '|') as
  320. id FROM BIS_INSP_ALL_RLATION WHERE PERSID = #{userid}
  321. <include refid="orgIdSql"/> GROUP BY PERSID
  322. )
  323. else (select 'non' from dual) end)
  324. ||')')
  325. AND ID like '${orgType}%'
  326. ) order by id
  327. </select>
  328. <select id="getGcNode" resultType="cn.com.goldenwater.dcproj.model.BisInspKeyRegister"
  329. parameterType="cn.com.goldenwater.dcproj.param.TypeParam">
  330. SELECT * FROM (
  331. select A.CODE,A.ID nodeId,
  332. A.NM,
  333. '4' PTYPE,
  334. B.PTYPE ETYPE,
  335. B.STWKTM ,
  336. B.PLANTM ,
  337. B.ESTAPP,
  338. B.ENG_STA,
  339. B.BUID_TIME_YEAR,
  340. B.lgtd,
  341. B.lttd,
  342. B.lgtd_pc,
  343. B.lttd_pc,
  344. A.OBJ_ID,B.ID ID,
  345. (case when b.State is null then '0' else b.state end)STATE,
  346. (case when b.State is null then '0' else b.state end)wtdstState,
  347. d.nm oneUnitNm,d.id oneUnitId
  348. ,B.INTM
  349. from BIS_INSP_ALL_OBJ
  350. A LEFT JOIN BIS_INSP_KEY_REGISTER B ON A.OBJ_ID=B.OBJ_ID
  351. LEFT JOIN ATT_EMPWTPRJ_BASE C ON A.CODE=C.ID
  352. LEFT JOIN (SELECT * FROM ATT_MAMPU_INFO WHERE LEV='1') D ON D.REG_ID=B.ID
  353. where A.ptype=#{pType}
  354. and REGEXP_LIKE(
  355. A.Id,'^('||
  356. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{presId}
  357. <include refid="orgIdSql"/>
  358. )>0 then
  359. (SELECT LISTAGG(id, '|') as
  360. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{presId}
  361. <include refid="orgIdSql"/> GROUP BY PERSID
  362. )
  363. else (select 'non' from dual) end)
  364. ||')')
  365. ) A WHERE a.PTYPE=#{pType}
  366. order by nodeId asc
  367. </select>
  368. <sql id="orgIdSql">
  369. <choose>
  370. <when test="orgId !=null and orgId !=''">
  371. and ORG_ID=#{orgId}
  372. </when>
  373. <otherwise>
  374. and ORG_ID is null
  375. </otherwise>
  376. </choose>
  377. </sql>
  378. </mapper>