cd7f991d35aa6a2ce07be02c507f0aefd2952fbc.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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.BisInspAllDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspAll" id="bisInspAllResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="pid" column="PID"/>
  7. <result property="pnm" column="PNM"/>
  8. <result property="sttm" column="STTM"/>
  9. <result property="entm" column="ENTM"/>
  10. <result property="inspYear" column="INSP_YEAR"/>
  11. <result property="inspMnth" column="INSP_MNTH"/>
  12. <result property="inspTask" column="INSP_TASK"/>
  13. <result property="impData" column="IMP_DATA"/>
  14. <result property="province" column="PROVINCE"/>
  15. <result property="chkType" column="CHK_TYPE"/>
  16. <result property="leadDep" column="LEAD_DEP"/>
  17. <result property="chkForm" column="CHK_FORM"/>
  18. <result property="yearTaskId" column="YEAR_TASK_ID"/>
  19. <result property="isPlan" column="IS_PLAN"/>
  20. <result property="quantity" column="QUANTITY"/>
  21. <result property="planDpId" column="PLAN_DP_ID"/>
  22. <result property="note" column="NOTE"/>
  23. </resultMap>
  24. <select id="listInspType" resultType="cn.com.goldenwater.dcproj.model.InspType">
  25. select code,name,ptype,in_tm,up_tm from att_insp_type order BY code
  26. </select>
  27. <sql id="table_columns">
  28. ID,
  29. PID,
  30. PNM,
  31. STTM,
  32. ENTM,INSP_YEAR,INSP_MNTH,INSP_TASK,IMP_DATA,PROVINCE,CHK_TYPE,
  33. LEAD_DEP,
  34. CHK_FORM,
  35. YEAR_TASK_ID,
  36. IS_PLAN,
  37. ORG_ID,
  38. QUANTITY,
  39. PLAN_DP_ID,
  40. NOTE
  41. </sql>
  42. <sql id="entity_properties">
  43. #{id},
  44. #{pid},
  45. #{pnm},
  46. #{sttm},
  47. #{entm},#{inspYear},#{inspMnth},#{inspTask},#{impData},#{province},
  48. #{chkType},
  49. #{leadDep},
  50. #{chkForm},
  51. #{yearTaskId},
  52. #{isPlan},
  53. #{orgId},
  54. #{quantity},
  55. #{planDpId},
  56. #{note}
  57. </sql>
  58. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  59. <sql id="page_where">
  60. <trim prefix="where" prefixOverrides="and | or ">
  61. <if test="id != null and id != ''">and ID LIKE concat(#{id},'%')</if>
  62. <if test="pid != null and pid != ''">and PID = #{pid}</if>
  63. <if test="pnm != null and pnm != ''">and PNM like concat('%',concat(#{pnm},'%'))</if>
  64. <if test="sttm != null">and STTM = #{sttm}</if>
  65. <if test="entm != null">and ENTM = #{entm}</if>
  66. <if test="inspMnth != null and inspMnth != ''">and INSP_MNTH = #{inspMnth}</if>
  67. <if test="inspYear != null and inspYear != ''">and INSP_YEAR = #{inspYear}</if>
  68. <if test="chkType != null and chkType != ''">and CHK_TYPE = #{chkType}</if>
  69. <if test="leadDep != null and leadDep != ''">and LEAD_DEP = #{leadDep}</if>
  70. <if test="chkForm != null and chkForm != ''">and CHK_FORM = #{chkForm}</if>
  71. <if test="yearTaskId != null and yearTaskId != ''">and YEAR_TASK_ID = #{yearTaskId}</if>
  72. <if test="isPlan != null and isPlan != ''">and IS_PLAN = #{isPlan}</if>
  73. <if test="quantity != null">and QUANTITY = #{quantity}</if>
  74. <if test="planDpId != null and planDpId != ''">and PLAN_DP_ID = #{planDpId}</if>
  75. <if test="note != null and note != ''">and NOTE = #{note}</if>
  76. </trim>
  77. </sql>
  78. <select id="getOne" resultMap="bisInspAllResultMap">
  79. select * from BIS_INSP_ALL a where a.id in (select ID from bis_insp_all_obj j where j.nm like '%${nm}%')
  80. <if test="id != null and id != ''">and ID LIKE concat(#{id},'%')</if>
  81. <if test="pid != null and pid != ''">and PID = #{pid}</if>
  82. <if test="pnm != null and pnm != ''">and PNM like concat('%',concat(#{pnm},'%'))</if>
  83. <if test="sttm != null">and STTM = #{sttm}</if>
  84. <if test="entm != null">and ENTM = #{entm}</if>
  85. <if test="inspMnth != null and inspMnth != ''">and INSP_MNTH = #{inspMnth}</if>
  86. <if test="inspYear != null and inspYear != ''">and INSP_YEAR = #{inspYear}</if>
  87. <if test="chkType != null and chkType != ''">and CHK_TYPE = #{chkType}</if>
  88. <if test="leadDep != null and leadDep != ''">and LEAD_DEP = #{leadDep}</if>
  89. <if test="chkForm != null and chkForm != ''">and CHK_FORM = #{chkForm}</if>
  90. <if test="yearTaskId != null and yearTaskId != ''">and YEAR_TASK_ID = #{yearTaskId}</if>
  91. <if test="chkType != null and chkType != ''">and CHK_TYPE = #{chkType}</if>
  92. <if test="leadDep != null and leadDep != ''">and LEAD_DEP = #{leadDep}</if>
  93. <if test="chkForm != null and chkForm != ''">and CHK_FORM = #{chkForm}</if>
  94. <if test="yearTaskId != null and yearTaskId != ''">and YEAR_TASK_ID = #{yearTaskId}</if>
  95. <if test="isPlan != null and isPlan != ''">and IS_PLAN = #{isPlan}</if>
  96. <if test="quantity != null">and QUANTITY = #{quantity}</if>
  97. <if test="planDpId != null and planDpId != ''">and PLAN_DP_ID = #{planDpId}</if>
  98. <if test="note != null and note != ''">and NOTE = #{note}</if>
  99. </select>
  100. <select id="get" resultMap="bisInspAllResultMap" parameterType="String">
  101. select
  102. <include refid="table_columns"/>
  103. from BIS_INSP_ALL where ID = #{id}
  104. </select>
  105. <select id="getBy" resultMap="bisInspAllResultMap">
  106. select
  107. <include refid="table_columns"/>
  108. from BIS_INSP_ALL
  109. <include refid="page_where"/>
  110. </select>
  111. <select id="findAll" resultMap="bisInspAllResultMap">
  112. select
  113. <include refid="table_columns"/>
  114. from BIS_INSP_ALL
  115. </select>
  116. <select id="findAreas" resultMap="bisInspAllResultMap">
  117. select bas_code as id,bas_name as pnm from ATT_BAS_BASE order by bas_code
  118. </select>
  119. <select id="findList" resultMap="bisInspAllResultMap">
  120. select
  121. <include refid="table_columns"/>
  122. from BIS_INSP_ALL
  123. <include refid="page_where"/>
  124. </select>
  125. <sql id="selSql">
  126. <choose>
  127. <when test="province !=null and province !=''">
  128. and t.ad_code=#{province}
  129. </when>
  130. <otherwise>
  131. and t.ad_code is null
  132. </otherwise>
  133. </choose>
  134. </sql>
  135. <select id="findNodeByPersId" resultMap="bisInspAllResultMap">
  136. select DISTINCT t2.ID,t2.PID,t2.PNM,t2.STTM,t2.ENTM
  137. from (
  138. select * from bis_insp_all o where 1=1
  139. <choose>
  140. <when test="province !=null and province !=''">
  141. and o.province=#{province}
  142. </when>
  143. <otherwise>
  144. and o.province is null
  145. </otherwise>
  146. </choose>
  147. ) t2
  148. start with t2.id in
  149. (select t.id
  150. from bis_insp_all_rlation t
  151. where t.persid =#{persId}
  152. <include refid="selSql"/>
  153. )
  154. connect by t2.pid = prior t2.id
  155. </select>
  156. <select id="findExistList" parameterType="cn.com.goldenwater.dcproj.param.BisInspAllParam"
  157. resultType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  158. select distinct id,substr(o.id,4) as org_id from bis_insp_all_rlation o where o.id like '___${orgId}%' and
  159. persid=#{persId}
  160. <choose>
  161. <when test="province !=null and province !=''">
  162. and o.ad_code=#{province}
  163. </when>
  164. <otherwise>
  165. and o.ad_code is null
  166. </otherwise>
  167. </choose>
  168. </select>
  169. <select id="selectCount" resultType="int">
  170. select count(ID) from BIS_INSP_ALL t
  171. <include refid="page_where"/>
  172. <include refid="selSql"/>
  173. </select>
  174. <select id="selectMax" resultType="String">
  175. select Max(ID) as id from BIS_INSP_ALL
  176. <include refid="page_where"/>
  177. </select>
  178. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  179. insert into BIS_INSP_ALL(
  180. <include refid="table_columns"/>
  181. )
  182. values (
  183. <include refid="entity_properties"/>
  184. )
  185. </insert>
  186. <delete id="delete" parameterType="java.lang.String">
  187. delete from BIS_INSP_ALL where ID = #{id}
  188. </delete>
  189. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  190. delete from BIS_INSP_ALL
  191. <include refid="page_where"/>
  192. </delete>
  193. <update id="deleteInFlag" parameterType="java.lang.String">
  194. update BIS_INSP_ALL set flag_valid = 0 where ID = #{id}
  195. </update>
  196. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  197. update BIS_INSP_ALL
  198. <trim prefix="set" suffixOverrides=",">
  199. <if test="pid != null and pid != ''">PID = #{pid},</if>
  200. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  201. <if test="sttm != null">STTM = #{sttm},</if>
  202. <if test="entm != null">ENTM = #{entm},</if>
  203. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  204. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  205. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  206. <if test="impData != null">IMP_DATA = #{impData},</if>
  207. <if test="chkType != null and chkType != ''">CHK_TYPE = #{chkType},</if>
  208. <if test="leadDep != null and leadDep != ''">LEAD_DEP = #{leadDep},</if>
  209. <if test="chkForm != null and chkForm != ''">CHK_FORM = #{chkForm},</if>
  210. <if test="yearTaskId != null and yearTaskId != ''">YEAR_TASK_ID = #{yearTaskId},</if>
  211. <if test="isPlan != null and isPlan != ''">IS_PLAN = #{isPlan},</if>
  212. <if test="quantity != null">QUANTITY = #{quantity},</if>
  213. <if test="note != null and note != ''">NOTE = #{note},</if>
  214. </trim>
  215. <where>ID = #{id}</where>
  216. </update>
  217. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  218. update BIS_INSP_ALL
  219. <trim prefix="set" suffixOverrides=",">
  220. <if test="pid != null and pid != ''">PID = #{pid},</if>
  221. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  222. <if test="sttm != null">STTM = #{sttm},</if>
  223. <if test="entm != null">ENTM = #{entm},</if>
  224. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  225. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  226. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  227. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  228. <if test="impData != null">IMP_DATA = #{impData},</if>
  229. <if test="chkType != null and chkType != ''">CHK_TYPE = #{chkType},</if>
  230. <if test="leadDep != null and leadDep != ''">LEAD_DEP = #{leadDep},</if>
  231. <if test="chkForm != null and chkForm != ''">CHK_FORM = #{chkForm},</if>
  232. <if test="yearTaskId != null and yearTaskId != ''">YEAR_TASK_ID = #{yearTaskId},</if>
  233. <if test="isPlan != null and isPlan != ''">IS_PLAN = #{isPlan},</if>
  234. <if test="quantity != null">QUANTITY = #{quantity},</if>
  235. <if test="note != null and note != ''">NOTE = #{note},</if>
  236. </trim>
  237. <include refid="page_where"/>
  238. </update>
  239. <!-- 其他自定义SQL -->
  240. <!--查询子id最大的对象 参数 001-->
  241. <select id="getMaxOne" resultMap="bisInspAllResultMap">
  242. select Max(id) as id from BIS_INSP_ALL t where t.pid = #{pid}
  243. </select>
  244. <select id="getAllNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  245. select DISTINCT w.* from (
  246. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  247. where SUBSTR(a.id,1,6)=t.ID
  248. <include refid="selSql"/>
  249. and t.persid=#{userid} and length(t.ID)=6
  250. <if test="orgType !=null and orgType != ''">
  251. and a.ID LIKE concat(#{orgType},'%')
  252. </if>
  253. UNION ALL
  254. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  255. where SUBSTR(a.id,1,9)=t.ID
  256. <include refid="selSql"/>
  257. and t.persid=#{userid} and LENGTH(t.id)=9
  258. <if test="orgType !=null and orgType != ''">
  259. and a.ID LIKE concat(#{orgType},'%')
  260. </if>
  261. UNION ALL
  262. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  263. where a.id=t.ID
  264. <include refid="selSql"/>
  265. and t.persid=#{userid} and LENGTH(t.id)=12
  266. <if test="orgType !=null and orgType != ''">
  267. and a.ID LIKE concat(#{orgType},'%')
  268. </if>
  269. ) w where 1=1
  270. <if test="orgType !=null and orgType != ''">
  271. and ID LIKE concat(#{orgType},'%')
  272. </if>
  273. <if test="tabType =='2'.toString()">
  274. and entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  275. </if>
  276. <if test="tabType =='1'.toString()">
  277. and entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  278. </if>
  279. <if test="year !=null and year != ''">
  280. and INSP_YEAR=#{year}
  281. </if>
  282. <if test="curYear !=null and curYear != ''">
  283. and ((TO_CHAR(STTM,'YYYY') = #{curYear}) OR (TO_CHAR(ENTM,'YYYY') = #{curYear}))
  284. </if>
  285. <if test="yearTaskId !=null and yearTaskId != ''">
  286. and (YEAR_TASK_ID=#{yearTaskId} or length(id)=6)
  287. </if>
  288. <if test="leadDep !=null and leadDep != ''">
  289. and lead_dep LIKE CONCAT('%', CONCAT(#{leadDep}, '%') )
  290. </if>
  291. order by id
  292. </select>
  293. <select id="BisInspAllObjById" resultType="cn.com.goldenwater.dcproj.model.BisInspAllNode">
  294. select RGSTR_ID as id,ID as pid,OBJ_NM AS pnm,OBJ_ID,AD_CODE,code from
  295. VIEW_REG_BASE t
  296. where
  297. 1 = 1
  298. <include refid="choseSql"/>
  299. <if test="id !=null and id != ''">
  300. and ID = #{id}
  301. </if>
  302. order by OBJ_NM
  303. </select>
  304. <sql id="choseSql">
  305. <choose>
  306. <when test="province !=null and province !=''">
  307. and ad_code like '%${province}%'
  308. </when>
  309. <otherwise>
  310. and ad_code is null
  311. </otherwise>
  312. </choose>
  313. </sql>
  314. <select id="getAllNodeByLevel" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  315. select id,pid,pnm,sttm,entm from
  316. BIS_INSP_ALL t where
  317. REGEXP_LIKE(
  318. Id,'^('||
  319. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  320. <include refid="choseSql"/>
  321. )>0 then
  322. (SELECT LISTAGG(id, '|') WITHIN GROUP(ORDER BY PERSID) as id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  323. <include refid="choseSql"/>
  324. )
  325. else (select 'non' from dual) end)
  326. ||')')
  327. <if test="objType !=null and objType != ''">
  328. and ID LIKE concat(#{objType},'%')
  329. </if>
  330. <if test="level !=null and level != ''">
  331. and length(ID) >= #{level}
  332. </if>
  333. order by ID
  334. </select>
  335. <select id="getUserByOrg" resultType="java.util.HashMap">
  336. SELECT
  337. a.ID,
  338. a.PID,
  339. a.PNM,
  340. d.PNM AS pidnm,
  341. t.PERTYPE,
  342. c.GUID,
  343. c.ORG_ID,
  344. c.PERS_NAME,
  345. c.BORN_DATE,
  346. c.PLST,
  347. c.SCHOOL,
  348. c.SPECIALTY,
  349. c.TELNUMB,
  350. c.FAXNUMB,
  351. c.ADM_DUTY,
  352. c.ORG_NM,
  353. c.MOBILENUMB,
  354. c.IDNM,
  355. c.DPNM,
  356. c.DPPOST,
  357. c.EMAIL,
  358. c.REMARK,
  359. c.IMGURL
  360. FROM
  361. (
  362. SELECT
  363. ID,
  364. PID,
  365. PNM,
  366. STTM,
  367. ENTM
  368. FROM
  369. BIS_INSP_ALL a START WITH a.id = #{objType} connect BY prior a.ID = a.PID
  370. ) a
  371. LEFT JOIN BIS_INSP_ALL_RLATION t ON a.ID = t.id
  372. LEFT JOIN BIS_INSP_ALL_RLATION_PERS c ON t.PERSID = c.GUID
  373. LEFT JOIN BIS_INSP_ALL d ON a.PID = d.ID
  374. WHERE length(a.ID) = 12
  375. <include refid="selSql"/>
  376. ORDER BY
  377. a.ID,b.PERTYPE desc
  378. </select>
  379. <sql id="objSql">
  380. <choose>
  381. <when test="province !=null and province !=''">
  382. and obj.ad_code=#{province}
  383. </when>
  384. <otherwise>
  385. and obj.ad_code is null
  386. </otherwise>
  387. </choose>
  388. </sql>
  389. <!--导出模块获取流域树 水库1,人饮2,水毁3 三棵树-->
  390. <select id="getNodeByPidAndCode" resultType="java.util.LinkedHashMap">
  391. <choose>
  392. <when test="pid.length() >= 12">
  393. select distinct '' "id", obj.nm "pnm",
  394. obj.code "code", obj.nm "nm",obj.ptype "pType",obj.obj_id "objId",rgstr.eng_id "engId"
  395. from BIS_INSP_ALL_OBJ obj left join BIS_INSP_VILL_RGSTR rgstr
  396. on obj.obj_id = rgstr.obj_id
  397. where
  398. obj.id = #{pid}
  399. <!--instr((select LISTAGG(code, ',') WITHIN GROUP(ORDER BY id) from BIS_INSP_ALL_OBJ where id = #{pid}),obj.code) > 0-->
  400. <if test="type !=null and type == '2'.toString()">
  401. and rgstr.eng_id is not null
  402. </if>
  403. <include refid="objSql"/>
  404. <if test="type !=null and type == '1'.toString()">
  405. and rgstr.eng_id = 'non'
  406. </if>
  407. <if test="type !=null and type == '3'.toString()">
  408. and rgstr.eng_id = 'non'
  409. </if>
  410. </when>
  411. <otherwise>
  412. SELECT distinct
  413. ia.id "id", ia.pnm "pnm"
  414. FROM BIS_INSP_ALL ia
  415. LEFT JOIN BIS_INSP_ALL_OBJ obj ON ia.id = obj.id
  416. WHERE ia.pid LIKE #{pid}||'%'
  417. AND length(ia.id) = length(#{pid})+3
  418. <include refid="objSql"/>
  419. <if test="pid !=null and pid.length() >= 9 and code !=null and code !=''">
  420. <choose>
  421. <when test="type !=null and type=='3'.toString()">
  422. AND instr(#{code},substr((select loc_ad from BIS_INSP_WTDST where wtdst_id = obj.code),0,2))
  423. > 0
  424. </when>
  425. <otherwise>
  426. AND instr(#{code},substr(code,0,2)) > 0
  427. </otherwise>
  428. </choose>
  429. </if>
  430. ORDER BY ia.id
  431. </otherwise>
  432. </choose>
  433. </select>
  434. <select id="getAllNodeById" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  435. select id,pid,pnm,sttm,entm from BIS_INSP_ALL where id in (${id})
  436. </select>
  437. <select id="countSysMsg" parameterType="String" resultType="cn.com.goldenwater.dcproj.dto.DataDto">
  438. select sum(ducha_type) as ducha_type,sum(ducha_group) as ducha_group,sum(ducha_pers) as ducha_pers,
  439. sum(ducha_obj) as ducha_obj,sum(ducha_pblm) as ducha_pblm from (
  440. select count(distinct substr(t.id,0,3)) as ducha_type,0 as ducha_group,0 as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  441. from bis_insp_all t where length(t.id)=12 and t.sttm &lt;= to_date(#{nowTIme},'yyyy-MM-dd')
  442. and t.entm &gt;= to_date(#{nowTIme},'yyyy-MM-dd') and t.id like '___${orgId}%'
  443. union all
  444. select 0 as ducha_type,count(t.id) as ducha_group,0 as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  445. from bis_insp_all t where length(t.id)=12 and t.sttm &lt;= to_date(#{nowTIme},'yyyy-MM-dd')
  446. and t.entm &gt;= to_date(#{nowTIme},'yyyy-MM-dd') and t.id like '___${orgId}%'
  447. union all
  448. select 0 as ducha_type,0 as ducha_group,count(distinct r.persid ) as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  449. from bis_insp_all t,bis_insp_all_rlation r where length(t.id)=12 and t.id=r.id
  450. and t.sttm &lt;= to_date(#{nowTIme},'yyyy-MM-dd')
  451. and t.entm &gt;= to_date(#{nowTIme},'yyyy-MM-dd') and t.id like '___${orgId}%'
  452. union all
  453. select 0 as ducha_type,0 as ducha_group,0 as ducha_pers,count(r.code ) as ducha_obj,0 as ducha_pblm
  454. from bis_insp_all t,bis_insp_all_obj r where t.id=r.id and t.sttm &lt;= to_date(#{nowTIme},'yyyy-MM-dd')
  455. and t.entm &gt;= to_date(#{nowTIme},'yyyy-MM-dd') and t.id like '___${orgId}%'
  456. union all
  457. select 0 as ducha_type,0 as ducha_group,0 as ducha_pers,0 as ducha_obj,count(m.pblm_id ) as ducha_pblm
  458. from bis_insp_all t,bis_insp_all_obj r,bis_insp_pblm m where t.id=r.id and r.obj_id=m.obj_id
  459. and t.sttm &lt;= to_date(#{nowTIme},'yyyy-MM-dd')
  460. and t.entm &gt;= to_date(#{nowTIme},'yyyy-MM-dd') and t.id like '___${orgId}%'
  461. ) w
  462. </select>
  463. <select id="countUserLine" resultType="cn.com.goldenwater.dcproj.dto.UserLineDto">
  464. select sum(pers_total) as pers_total,sum(active_user) as active_user,org_id from (
  465. select count(g.pers_id) as pers_total,0 as active_user,g.org_id from bis_insp_all_rlation_pers
  466. t,bis_insp_pers_org g
  467. where t.guid=g.pers_id
  468. <choose>
  469. <when test="orgId !=null and orgId !=''">
  470. and g.org_id=#{orgId}
  471. </when>
  472. <otherwise>
  473. and g.org_id is null
  474. </otherwise>
  475. </choose>
  476. group by g.org_id
  477. union all
  478. select 0 as pers_total,count(distinct s.guid) as active_user,o.org_id from bis_insp_all_rlation_pers
  479. s,bis_insp_pers_org o,bis_insp_log g
  480. where s.guid =g.user_id and s.guid=o.pers_id
  481. <choose>
  482. <when test="orgId !=null and orgId !=''">
  483. and o.org_id=#{orgId}
  484. </when>
  485. <otherwise>
  486. and o.org_id is null
  487. </otherwise>
  488. </choose>
  489. group by o.org_id
  490. ) w group by org_id
  491. </select>
  492. <select id="countUserLine2" resultType="cn.com.goldenwater.dcproj.dto.UserLineDto">
  493. select sum(pers_total) as pers_total,sum(active_user) as active_user,org_id from (
  494. select count(g.pers_id) as pers_total,0 as active_user,g.org_id from bis_insp_all_rlation_pers
  495. t,bis_insp_pers_org g
  496. where t.guid=g.pers_id
  497. <if test="orgId !=null and orgId !=''">
  498. and g.org_id=#{orgId}
  499. </if>
  500. group by g.org_id
  501. union all
  502. select 0 as pers_total,count(distinct s.guid) as active_user,o.org_id from bis_insp_all_rlation_pers
  503. s,bis_insp_pers_org o,bis_insp_log g
  504. where s.guid =g.user_id and s.guid=o.pers_id
  505. <if test="orgId !=null and orgId !=''">
  506. and o.org_id=#{orgId}
  507. </if>
  508. group by o.org_id
  509. ) w group by org_id
  510. </select>
  511. <select id="findOrgMsg" resultType="cn.com.goldenwater.dcproj.dto.OrgDto">
  512. select t.org_id,t.org_nm
  513. from bis_insp_org t
  514. where t.org_pid='1'
  515. </select>
  516. <select id="listByName" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  517. SELECT
  518. rownum id, O.*
  519. FROM (
  520. SElECT
  521. '000' PID, PNM, TO_CHAR(LISTAGG(ID, ',') WITHIN GROUP(ORDER BY PNM)) AS "code"
  522. FROM BIS_INSP_ALL
  523. WHERE
  524. PID IN (${pTypes})
  525. AND LENGTH(ID) = #{length}
  526. GROUP BY PNM
  527. ORDER BY TO_CHAR(LISTAGG(ID, ',') WITHIN GROUP(ORDER BY PNM))
  528. ) o
  529. </select>
  530. <select id="listByMap" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllDto">
  531. SELECT distinct C.*, T.NAME AS OBJ_TYPE_NAME, CT.PNM PPNM
  532. FROM BIS_INSP_ALL C
  533. LEFT JOIN BIS_INSP_ALL CT ON CT.ID = C.PID
  534. JOIN (select * FROM ATT_INSP_TYPE where code IN (select INSP_TYPE FROM REL_ORG_INSP_TYPE
  535. <where>
  536. <if test="orgId != null and orgId != '' ">
  537. AND ORG_ID = #{orgId}
  538. </if>
  539. </where>
  540. )) T ON SUBSTR(C.ID, 0, 3) = T.CODE
  541. LEFT JOIN BIS_INSP_ALL_OBJ O ON O.ID = C.ID
  542. <where>
  543. length(C.ID) = 12
  544. <if test="depm != null and depm.size() > 0 ">
  545. AND SUBSTR(C.ID, 0, 3) IN (SELECT PTYPE FROM ATT_INSP_TYPE_DUTY where DUTY_DEP IN
  546. <foreach item="item" index="index" collection="depm" open="(" separator="," close=")">
  547. '${item}'
  548. </foreach>
  549. )
  550. </if>
  551. <if test="adCode != null and adCode != ''">and O.OBJ_AD_CODE like concat(#{adCode}, '%')</if>
  552. <if test="length != null and length != ''">and length(C.ID) = #{length}</if>
  553. <if test="id != null and id != ''">and C.ID like '%${id}%'</if>
  554. <if test="pnm != null and pnm != ''">and C.pnm like '%${pnm}%'</if>
  555. <if test="objTypeName != null and objTypeName != ''">and T.NAME like '%${objTypeName}%'</if>
  556. <if test="ppnm != null and ppnm != ''">and CT.PNM like '%${ppnm}%'</if>
  557. <if test="orgId != null and orgId != '' ">AND C.ID LIKE '___${orgId}%'</if>
  558. <if test="objType != null and objType != ''">and TO_NUMBER(SUBSTR(C.ID, 0, 3)) = #{objType}</if>
  559. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  560. AND C.STTM &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  561. AND C.STTM &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  562. </if>
  563. </where>
  564. order by C.ID
  565. </select>
  566. <select id="listByMap2" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllDto">
  567. SELECT distinct C.*
  568. FROM BIS_INSP_ALL C
  569. <where>
  570. <if test="length != null and length != ''">and length(C.ID) = #{length}</if>
  571. <if test="id != null and id != ''">and C.ID like '%${id}%'</if>
  572. <if test="pnm != null and pnm != ''">and C.pnm like '%${pnm}%'</if>
  573. <if test="year != null and year != ''">and TO_CHAR(C.STTM, 'YYYY') = #{year}</if>
  574. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  575. AND TO_DATE(TO_CHAR(C.STTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  576. AND TO_DATE(TO_CHAR(C.ENTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  577. </if>
  578. </where>
  579. order by C.ID
  580. </select>
  581. <select id="getYearById" resultType="java.lang.String">
  582. SELECT DISTINCT
  583. year
  584. FROM
  585. (
  586. SELECT
  587. DISTINCT TO_CHAR(STTM, 'yyyy') year
  588. FROM BIS_INSP_ALL
  589. where ID LIKE '${id}%'
  590. order by STTM
  591. ) WHERE year IS NOT NULL
  592. </select>
  593. <select id="getPersDcWork" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  594. select A.*,b.pertype from bis_insp_all A JOIN bis_insp_all_rlation B ON A.ID=B.ID WHERE b.persid=#{persId} AND LENGTH(B.ID)=12
  595. </select>
  596. <!--首页 四川 批次数汇总 督查批次统计 批次 类型 组数 督查人员数、区域数、对象数 -->
  597. <select id="getInspBatchNum" resultType="java.util.Map">
  598. select AB.ID , AB.PNM, AB.INSP_TYPE, T.NAME,
  599. NVL(COUNT(DISTINCT CASE WHEN AG.ID is not null THEN AG.ID END ),0) as GROUP_NUM ,
  600. NVL(COUNT(DISTINCT CASE WHEN AR.PERSID is not null THEN AR.PERSID END ),0) as PERS_NUM ,
  601. NVL(COUNT(DISTINCT CASE WHEN SA.AREA_ID is not null THEN SA.AREA_ID END ),0) as AREA_NUM ,
  602. NVL(COUNT(DISTINCT CASE WHEN AO.OBJ_ID is not null THEN AO.OBJ_ID END ),0) as OBJ_NUM
  603. from BIS_INSP_ALL AB
  604. JOIN (select CODE,NAME, PTYPE FROM ATT_INSP_TYPE where code IN (select INSP_TYPE FROM REL_ORG_INSP_TYPE where org_id = #{orgId} )) T ON substr(AB.ID,1,3) = T.CODE
  605. LEFT JOIN BIS_INSP_ALL AG on AG.PID = AB.ID
  606. LEFT JOIN BIS_INSP_ALL_RLATION AR ON AR.ID = AG.ID
  607. LEFT JOIN BIS_INSP_SEL_AREA SA ON SA.ID = AG.ID
  608. LEFT JOIN BIS_INSP_ALL_OBJ AO ON AO.ID = AG.ID
  609. <where>
  610. LENGTH(AB.ID) = 9
  611. <if test=' null != orgId and "" !=orgId' >
  612. AND AB.ID like '___${orgId}%'
  613. </if>
  614. <if test=' null != adCode and "" !=adCode' >
  615. AND AB.PROVINCE like '${adCode}%'
  616. </if>
  617. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  618. AND TO_DATE(TO_CHAR(AB.STTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  619. AND TO_DATE(TO_CHAR(AB.INTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  620. </if>
  621. <if test=' null != pnm and "" !=pnm' >
  622. AND AB.PNM like '%${pnm}%'
  623. </if>
  624. <if test=' null != objType and "" !=objType' >
  625. AND AB.ID like '${objType}%'
  626. </if>
  627. <if test=' null != objTypeName and "" !=objTypeName' >
  628. AND T.NAME like '%${objTypeName}%'
  629. </if>
  630. </where>
  631. group by AB.ID , AB.PNM, AB.INSP_TYPE, T.NAME
  632. </select>
  633. </mapper>