GeneralDownloadDao.xml 18 KB

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