DcPageOfficeLyzzRportDao.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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.DcPageOfficeLyzzReportDao">
  4. <!-- 根据节点获取 派出督查组及人员情况-->
  5. <select id="getGroupAndPerson" resultType="java.util.HashMap">
  6. select
  7. <choose>
  8. <when test="id.length()==6">
  9. substr(t.id,1,6)
  10. </when>
  11. <when test="id.length()==9">
  12. substr(t.id,1,9)
  13. </when>
  14. <otherwise>
  15. t.id
  16. </otherwise>
  17. </choose> id,
  18. (select pnm from BIS_INSP_ALL q where q.id=
  19. <choose>
  20. <when test="id.length()==6">
  21. substr(t.id,1,6)
  22. </when>
  23. <when test="id.length()==9">
  24. substr(t.id,1,9)
  25. </when>
  26. <otherwise>
  27. t.id
  28. </otherwise>
  29. </choose>
  30. ) pnm,
  31. (SELECT COUNT(DISTINCT ID) FROM BIS_INSP_ALL_RLATION WHERE ID like CONCAT(#{id}, '%') AND LENGTH(ID)=12) dcz_con,
  32. (SELECT COUNT(DISTINCT PERSID) FROM BIS_INSP_ALL_RLATION WHERE ID like CONCAT(#{id}, '%')) ry_con,
  33. count(distinct (case when instr(t1.ADM_DUTY,'局长')>0 then t1.id else null end )) jz_con,
  34. count(distinct (case when instr(t1.ADM_DUTY,'处长')>0 then t1.id else null end )) cz_con
  35. from
  36. (SELECT *
  37. FROM BIS_INSP_ALL
  38. <where>
  39. <choose>
  40. <when test="id.length()==6">
  41. and substr(id,1,6) = #{id}
  42. </when>
  43. <when test="id.length()==9">
  44. and substr(id,1,9) = #{id}
  45. </when>
  46. <otherwise>
  47. and id = #{id}
  48. </otherwise>
  49. </choose>
  50. </where>
  51. ) T
  52. LEFT JOIN
  53. (
  54. SELECT
  55. Q.ID,Q1.PERS_NAME,Q1.ORG_NM,Q1.DPPOST,Q.PERTYPE,Q1.ADM_DUTY
  56. FROM BIS_INSP_ALL_RLATION Q
  57. INNER JOIN BIS_INSP_ALL_RLATION_PERS Q1 ON Q.PERSID=Q1.GUID
  58. WHERE LENGTH(Q.ID)=12
  59. ) T1 ON T.ID = T1.ID
  60. <choose>
  61. <when test="id.length()==6">
  62. GROUP BY SUBSTR(T.ID,1,6)
  63. </when>
  64. <when test="id.length()==9">
  65. GROUP BY SUBSTR(T.ID,1,9)
  66. </when>
  67. <otherwise>
  68. GROUP BY T.ID
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <!-- 根据节点获取 派出督查组及人员情况(未使用)-->
  73. <select id="getGroupAndPerson1" resultType="java.util.HashMap">
  74. SELECT
  75. count(DISTINCT ID) jianchazu,
  76. count(DISTINCT GUID) zong_renyuan,
  77. count(DISTINCT (case when instr(ADM_DUTY,'局长')>0 then id else null end )) jz_con,
  78. count(DISTINCT (case when instr(ADM_DUTY,'处长')>0 then id else null end )) cz_con
  79. FROM
  80. (
  81. SELECT a.ID, p.GUID, p.ADM_DUTY
  82. FROM
  83. (
  84. SELECT ID FROM BIS_INSP_ALL WHERE ID LIKE CONCAT( #{id}, '%') AND lengthb(ID) = 12
  85. ) a
  86. LEFT JOIN BIS_INSP_ALL_RLATION r ON a.ID = r.ID
  87. LEFT JOIN BIS_INSP_ALL_RLATION_PERS p ON r.PERSID = p.GUID
  88. )
  89. </select>
  90. <!--督查水库数量及分布情况-->
  91. <select id="getRsvrDis" resultType="java.util.HashMap">
  92. select
  93. ifnull(count(1),0) con,
  94. ifnull(sum(case t.Eng_Scal when '4' then 1 else 0 end ),0) xiao1,
  95. ifnull(sum(case t.Eng_Scal when '5' then 1 else 0 end ),0) xiao2,
  96. ifnull(count(distinct substr(t.ad_code,1,2)),0) sheng1,
  97. ifnull(count(distinct substr(t.ad_code,1,4)),0) shi1,
  98. ifnull(count(distinct substr(t.ad_code,1,6)),0) xian1
  99. from BIS_INSP_RSVR_RGSTR t
  100. left join BIS_INSP_ALL_OBJ t1 on t.obj_id=t1.obj_id
  101. where t.eng_scal in ('4', '5')
  102. and t.STATE = '2'
  103. and length(t1.id)=12
  104. <choose>
  105. <when test="id.length()==6">
  106. and substr(t1.id,1,6) = #{id}
  107. </when>
  108. <when test="id.length()==9">
  109. and substr(t1.id,1,9) = #{id}
  110. </when>
  111. <otherwise>
  112. and t1.id = #{id}
  113. </otherwise>
  114. </choose>
  115. </select>
  116. <!--检查水库总体情况-->
  117. <select id="getRsvrChk" resultType="java.util.HashMap">
  118. select
  119. ifnull(sum(case when c.SAFE_COMMENT = '1' then 1 else 0 end),0) normal,
  120. ifnull(sum(case when c.SAFE_COMMENT = '2' then 1 else 0 end),0) danger,
  121. ifnull(sum(case when c.SAFE_COMMENT = '3' then 1 else 0 end),0) unable
  122. from
  123. (select obj_id, rgstr_id, eng_scal, ad_code, STATE from BIS_INSP_RSVR_RGSTR) a
  124. left join
  125. BIS_INSP_ALL_OBJ b on a.obj_id = b.obj_id
  126. left join
  127. BIS_INSP_SAFE_EXT_MANAGE c on a.rgstr_id = c.rgstr_id
  128. where
  129. a.eng_scal in ('4', '5')
  130. and a.STATE = '2'
  131. and length(b.id) = 12
  132. <choose>
  133. <when test="id.length()==6">
  134. and substr(b.id,1,6) = #{id}
  135. </when>
  136. <when test="id.length()==9">
  137. and substr(b.id,1,9) = #{id}
  138. </when>
  139. <otherwise>
  140. and b.id = #{id}
  141. </otherwise>
  142. </choose>
  143. </select>
  144. <!--效益发挥情况-->
  145. <select id="getRsvrBenef" resultType="java.util.HashMap">
  146. select
  147. sum(case when c.IF_EFFECTIVE = '1' then 1 else 0 end) benefit,
  148. sum(case when c.IF_EFFECTIVE = '2' then 1 else 0 end) nbenefit,
  149. sum(ifnull(c.WSFDWS, 0)) WSFDWS,
  150. sum(ifnull(c.HAS_SET_MAIN_FL, 0)) HASSETMAINFL
  151. from
  152. (select obj_id, rgstr_id, eng_scal, ad_code, STATE from BIS_INSP_RSVR_RGSTR) a
  153. left join
  154. BIS_INSP_ALL_OBJ b on a.obj_id = b.obj_id
  155. left join
  156. BIS_INSP_RSVR_BENEFITS c on a.rgstr_id = c.rgstr_id
  157. where
  158. a.eng_scal in ('4', '5')
  159. and a.STATE = '2'
  160. and length(b.id) = 12
  161. <choose>
  162. <when test="id.length()==6">
  163. and substr(b.id,1,6) = #{id}
  164. </when>
  165. <when test="id.length()==9">
  166. and substr(b.id,1,9) = #{id}
  167. </when>
  168. <otherwise>
  169. and b.id = #{id}
  170. </otherwise>
  171. </choose>
  172. </select>
  173. <!--“三个责任人”落实履职情况-->
  174. <select id="getRsvrZrr" resultType="java.util.HashMap">
  175. select
  176. ifnull(count(distinct (case when e.POOR_COUNTRY='1' then substr(a.ad_code,1,6) else null end)),0) POORCOUNTRY,
  177. ifnull(count(1),0) con,
  178. sum(case when d.Has_Wiun_Wao_Leg_Pers='1' then 1 else 0 end) Has_Wiun_Wao_Leg_Pers,
  179. sum(case when d.WIUN_WAO_LEG_PERS_TRAIN='1' then 1 else 0 end) Has_Wiun_Wao_Leg_Pers_TRAIN,
  180. sum(case when d.Wiun_Wao_Leg_Pers_Resu='1' then 1 else 0 end) Wiun_Wao_Leg_Pers_Resu1,
  181. sum(case when d.Wiun_Wao_Leg_Pers_Resu='2' then 1 else 0 end) Wiun_Wao_Leg_Pers_Resu2,
  182. sum(case when d.Wiun_Wao_Leg_Pers_Resu='3' then 1 else 0 end) Wiun_Wao_Leg_Pers_Resu3,
  183. sum(case when d.Has_Tech_Pers='1' then 1 else 0 end) Has_Tech_Pers,
  184. sum(case when d.Has_Tech_Pers='2' then 1 else 0 end) Has_NO_Tech_Pers,
  185. sum(case when d.TECH_PERS_TRAIN='1' then 1 else 0 end) Has_Tech_Pers_TRAIN,
  186. sum(case when d.Tech_Pers_Resu='1' then 1 else 0 end) Tech_Pers_Resu1,
  187. sum(case when d.Tech_Pers_Resu='2' then 1 else 0 end) Tech_Pers_Resu2,
  188. sum(case when d.Tech_Pers_Resu='3' then 1 else 0 end) Tech_Pers_Resu3,
  189. sum(case when d.Has_Patrol_Pers='1' then 1 else 0 end) Has_Patrol_Pers,
  190. sum(case when d.PATROL_PERS_TRAIN='1' then 1 else 0 end) Has_Patrol_Pers_TRAIN,
  191. sum(case when d.Patrol_Pers_Resu='1' then 1 else 0 end) Patrol_Pers_Resu1,
  192. sum(case when d.Patrol_Pers_Resu='2' then 1 else 0 end) Patrol_Pers_Resu2,
  193. sum(case when d.Patrol_Pers_Resu='3' then 1 else 0 end) Patrol_Pers_Resu3,
  194. sum(case when d.HAS_ATTEND_TRAIN='1' then 1 else 0 end) HAS_ATTEND_TRAIN,
  195. <!--“三个重点环节”建设落实情况-->
  196. sum(case when c.RAIN_FORC='1' then 1 else 0 end) RAIN_FORC1,
  197. sum(case when c.RAIN_FORC='2' and c.RAIN_FORC_NOTE = '1' then 1 else 0 end) RAIN_FORC2,
  198. sum(case when c.RAIN_FORC='2' and c.RAIN_FORC_NOTE = '2' then 1 else 0 end) RAIN_FORC3,
  199. sum(case when c.SCH_PLAN_SAME_EXTA='1' then 1 else 0 end) SCH_PLAN_SAME_EXTA1,
  200. sum(case when c.SCH_PLAN_SAME_EXTA='2' then 1 else 0 end) SCH_PLAN_SAME_EXTA2,
  201. sum(case when c.SCH_PLAN_SAME_APPR='1' then 1 else 0 end) SCH_PLAN_SAME_APPR1,
  202. sum(case when c.SCH_PLAN_SAME_APPR='2' then 1 else 0 end) SCH_PLAN_SAME_APPR2,
  203. sum(case when c.SCH_PLAN_SAME_SPEED='1' then 1 else 0 end) SCH_PLAN_SAME_SPEED1,
  204. sum(case when c.SCH_PLAN_SAME_SPEED='2' then 1 else 0 end) SCH_PLAN_SAME_SPEED2,
  205. sum(case when c.SCH_PLAN_SAME_SPEED='3' then 1 else 0 end) SCH_PLAN_SAME_SPEED3,
  206. sum(case when c.EMER_PLAN_SAME_EXTA='1' then 1 else 0 end) EMER_PLAN_SAME_EXTA1,
  207. sum(case when c.EMER_PLAN_SAME_EXTA='2' then 1 else 0 end) EMER_PLAN_SAME_EXTA2,
  208. sum(case when c.EMER_PLAN_SAME_APPR='1' then 1 else 0 end) EMER_PLAN_SAME_APPR1,
  209. sum(case when c.EMER_PLAN_SAME_APPR='2' then 1 else 0 end) EMER_PLAN_SAME_APPR2,
  210. sum(case when c.EMER_PLAN_SAME_EME='1' then 1 else 0 end) EMER_PLAN_SAME_EME1,
  211. sum(case when c.EMER_PLAN_SAME_EME='2' then 1 else 0 end) EMER_PLAN_SAME_EME2,
  212. sum(case when c.EMER_PLAN_SAME_SPEED='1' then 1 else 0 end) EMER_PLAN_SAME_SPEED1,
  213. sum(case when c.EMER_PLAN_SAME_SPEED='2' then 1 else 0 end) EMER_PLAN_SAME_SPEED2,
  214. sum(case when c.EMER_PLAN_SAME_SPEED='3' then 1 else 0 end) EMER_PLAN_SAME_SPEED3,
  215. <!--运行管理情况-->
  216. sum(case when e.IF_FSLTDZ_RUN='1' then 1 else 0 end) IF_FSLTDZ_RUN1,
  217. sum(case when e.IF_FSLTDZ_RUN='2' then 1 else 0 end) IF_FSLTDZ_RUN2,
  218. sum(case when e.IF_FSLTDZ_NO='1' then 1 else 0 end) IF_FSLTDZ_NO1,
  219. sum(case when e.IF_FSLTDZ_NO='2' then 1 else 0 end) IF_FSLTDZ_NO2,
  220. sum(case when e.HAS_WD_EMNIC='2' then 1 else 0 end) HAS_WD_EMNIC2,
  221. sum(case when e.IF_DAM_WARN_LOGO='2' then 1 else 0 end) IF_DAM_WARN_LOGO2,
  222. sum(case when e.IF_MANAGE_REG_REL='1' then 1 else 0 end) IF_MANAGE_REG_REL1,
  223. sum(case when e.IF_MANAGE_REG_REL='2' then 1 else 0 end) IF_MANAGE_REG_REL2,
  224. sum(case when e.IF_MANAGE_REG='2' then 1 else 0 end) IF_MANAGE_REG2,
  225. sum(case when e.IF_DAM_WARN_LOGO='1' then 1 else 0 end) IF_DAM_WARN_LOGO1,
  226. <!--工程实体情况-->
  227. sum(case when f.DISK_RUN_INFO='1' then 1 else 0 end) DISK_RUN_INFO1,
  228. sum(case when f.DISK_RUN_INFO='2' then 1 else 0 end) DISK_RUN_INFO2,
  229. sum(case when f.DISK_RUN_INFO='3' then 1 else 0 end) DISK_RUN_INFO3,
  230. sum(case when e.LEAK_MAKE_SAFE='1' then 1 else 0 end) LEAK_MAKE_SAFE1,
  231. sum(case when e.HAS_ASTABLE='1' then 1 else 0 end) HAS_ASTABLE1,
  232. sum(case when f.HAS_SET_MAIN_FL='1' then 1 else 0 end) HAS_SET_MAIN_FL1,
  233. sum(case when f.IS_MAIN_FL_NORMAL='1' then 1 else 0 end) IS_MAIN_FL_NORMAL1,
  234. sum(case when f.IS_MAIN_FL_NORMAL='3' then 1 else 0 end) IS_MAIN_FL_NORMAL2,
  235. sum(case when f.IS_MAIN_FL_NORMAL='2' then 1 else 0 end) IS_MAIN_FL_NORMAL3,
  236. sum(case when instr(e.WAGA_DANG_DESC,'边墙失稳')>0 then 1 else 0 end) WAGA_DANG_DESC_SHIWEN,
  237. sum(case when instr(e.WAGA_DANG_DESC,'冲刷坝体及下游坝脚')>0 then 1 else 0 end) WAGA_DANG_DESC_CHONGSHUA,
  238. sum(case when f.HAS_SET_POUR_FL='1' then 1 else 0 end) HAS_SET_POUR_FL1,
  239. sum(case when f.POUR_FY_IS_NORMAL='1' then 1 else 0 end) POUR_FY_IS_NORMAL1,
  240. sum(case when f.POUR_FY_IS_NORMAL='3' then 1 else 0 end) POUR_FY_IS_NORMAL2,
  241. sum(case when f.POUR_FY_IS_NORMAL='2' then 1 else 0 end) POUR_FY_IS_NORMAL3,
  242. <!--安全鉴定情况-->
  243. sum(case when f.IF_DAM_SAFE='1' then 1 else 0 end) EXT_DAM_SAFE_APPR1,
  244. sum(case when f.IF_DAM_SAFE='2' then 1 else 0 end) EXT_DAM_SAFE_APPR2,
  245. sum(case when f.IF_DAM_SAFE='2' and f.IF_DAM_SAFE_REQ='2' then 1 else 0 end) EXT_DAM_SAFE_APPR3,
  246. sum(case when f.IF_DAM_SAFE='1' and f.IF_DAM_SAFE_RUL='1' then 1 else 0 end) DAM_SAFE_APPR_REQUIRE1,
  247. sum(case when f.IF_DAM_SAFE='1' and (f.IF_DAM_SAFE_RUL='2' or nullif(f.IF_DAM_SAFE_RUL,'') is null) then 1 else
  248. 0 end) DAM_SAFE_APPR_REQUIRE2,
  249. sum(case when f.IF_DAM_SAFE='1' and f.IF_DAM_SAFE_DEP_RUL='1' then 1 else 0 end) IF_DAM_SAFE_DEP_RUL1,
  250. sum(case when f.IF_DAM_SAFE='1' and (f.IF_DAM_SAFE_DEP_RUL='2' or nullif(f.IF_DAM_SAFE_DEP_RUL,'') is null) then
  251. 1 else 0 end) IF_DAM_SAFE_DEP_RUL2,
  252. <!--除险加固情况-->
  253. sum(case when f.IF_DAM_SAFE_THR='1' then 1 else 0 end) IF_FSLTDZ1,
  254. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_FORCE='1' then 1 else 0 end) IF_FSLTDZ2,
  255. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_FORCE='2' then 1 else 0 end) IF_FSLTDZ3,
  256. sum(case when f.IF_DAM_SAFE_THR='1' and f.REIN_FORCE_RUN='1' then 1 else 0 end) REIN_FORCE_RUN1,
  257. sum(case when f.IF_DAM_SAFE_THR='1' and f.REIN_FORCE_RUN='2' then 1 else 0 end) REIN_FORCE_RUN2,
  258. sum(case when f.IF_DAM_SAFE_THR='1' and f.REIN_FORCE_RUN2='1' then 1 else 0 end) REIN_FORCE_RUN21,
  259. sum(case when f.IF_DAM_SAFE_THR='1' and f.REIN_FORCE_RUN3='1' then 1 else 0 end) IF_COMPLATE_ACC1,
  260. sum(case when f.IF_DAM_SAFE_THR='1' and f.REIN_FORCE_RUN3='2' then 1 else 0 end) IF_COMPLATE_ACC2,
  261. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_IMP_GVE='1' then 1 else 0 end) IF_REIN_IMP_GVE1,
  262. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_IMP_GVE='2' then 1 else 0 end) IF_REIN_IMP_GVE2,
  263. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_IMP_PLAN='1' then 1 else 0 end) IF_REIN_IMP_PLAN1,
  264. sum(case when f.IF_DAM_SAFE_THR='1' and f.IF_REIN_IMP_PLAN='2' then 1 else 0 end) IF_REIN_IMP_PLAN2
  265. FROM
  266. (SELECT obj_id,rgstr_id,eng_scal,ad_code, STATE FROM BIS_INSP_RSVR_RGSTR) a
  267. LEFT JOIN
  268. BIS_INSP_ALL_OBJ b on a.obj_id = b.obj_id
  269. LEFT JOIN
  270. BIS_INSP_BASE_EXT c on a.rgstr_id = c.rgstr_id
  271. LEFT JOIN
  272. BIS_INSP_BASE_PRES_EXT d on a.rgstr_id = d.rgstr_id
  273. LEFT JOIN
  274. BIS_INSP_SAFE_EXT_MANAGE e on a.rgstr_id = e.rgstr_id
  275. LEFT JOIN
  276. BIS_INSP_RSVR_PROJECT f on a.rgstr_id = f.rgstr_id
  277. WHERE
  278. a.eng_scal in ('4','5')
  279. AND a.STATE = '2'
  280. AND length(b.id)=12
  281. AND b.id like '001%'
  282. <choose>
  283. <when test="id.length()==6">
  284. and substr(b.id,1,6) = #{id}
  285. </when>
  286. <when test="id.length()==9">
  287. and substr(b.id,1,9) = #{id}
  288. </when>
  289. <otherwise>
  290. and b.id = #{id}
  291. </otherwise>
  292. </choose>
  293. </select>
  294. <!--检查发现的主要问题-->
  295. <select id="getQTypeCount" resultType="java.util.HashMap">
  296. select
  297. sum(case when c.INSP_PBLM_CATE='3' then 1 else 0 end) INSP_PBLM_CATE0,
  298. sum(case when c.INSP_PBLM_CATE='2' then 1 else 0 end) INSP_PBLM_CATE1,
  299. sum(case when c.INSP_PBLM_CATE='1' then 1 else 0 end) INSP_PBLM_CATE2,
  300. sum(case when c.INSP_PBLM_CATE='0' then 1 else 0 end) INSP_PBLM_CATE3
  301. from
  302. BIS_INSP_ALL_OBJ b
  303. left join
  304. (select obj_id,rgstr_id,eng_scal, STATE from BIS_INSP_RSVR_RGSTR) a on a.obj_id = b.obj_id
  305. left join
  306. BIS_INSP_PBLM c on a.rgstr_id = c.REGID
  307. where
  308. a.eng_scal in ('4','5')
  309. and a.STATE = '2'
  310. and length(b.id)=12 and b.id like '001%'
  311. <choose>
  312. <when test="id.length()==6">
  313. and substr(b.id,1,6) = #{id}
  314. </when>
  315. <when test="id.length()==9">
  316. and substr(b.id,1,9) = #{id}
  317. </when>
  318. <otherwise>
  319. and b.id = #{id}
  320. </otherwise>
  321. </choose>
  322. </select>
  323. <select id="getRsvrQrr" resultType="cn.com.goldenwater.dcproj.param.RsvrQrrParam">
  324. select
  325. a.ad_code adCode, e.AD_FULL_NAME adFullName,
  326. count(1) con,
  327. sum(case when d.Has_Wiun_Wao_Leg_Pers='2' then 1 else 0 end) notWiunWaoLegPers,
  328. sum(case when d.Has_Tech_Pers='2' then 1 else 0 end) noTechPers,
  329. sum(case when d.Has_Patrol_Pers='2' then 1 else 0 end) notPatrolPers,
  330. sum(case when d.HAS_ATTEND_TRAIN='2' then 1 else 0 end) notAttendTrain
  331. from
  332. (select
  333. obj_id,rgstr_id,eng_scal,ad_code, STATE
  334. from BIS_INSP_RSVR_RGSTR) a
  335. left join
  336. BIS_INSP_ALL_OBJ b on a.obj_id = b.obj_id
  337. left join
  338. BIS_INSP_BASE_EXT c on a.rgstr_id = c.rgstr_id
  339. left join
  340. BIS_INSP_BASE_PRES_EXT d on a.rgstr_id = d.rgstr_id
  341. left join
  342. att_ad_x_base e on a.ad_code = e.ad_code
  343. where
  344. a.eng_scal in ('4','5')
  345. and a.STATE = '2'
  346. and length(b.id)=12 and b.id like '001%'
  347. <choose>
  348. <when test="id.length()==6">
  349. and substr(b.id,1,6) = #{id}
  350. </when>
  351. <when test="id.length()==9">
  352. and substr(b.id,1,9) = #{id}
  353. </when>
  354. <otherwise>
  355. and b.id = #{id}
  356. </otherwise>
  357. </choose>
  358. GROUP BY a.ad_code, e.AD_FULL_NAME
  359. </select>
  360. </mapper>