BisInspAllDao.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. where find_in_set (t2.id ,getSubNodes_bis_insp_all((select group_concat(t.id)
  149. from bis_insp_all_rlation t
  150. where t.persid =#{persId}
  151. <include refid="selSql"/>
  152. group by t.persid
  153. ) ,1,0) ) &gt; 0
  154. </select>
  155. <select id="findExistList" parameterType="cn.com.goldenwater.dcproj.param.BisInspAllParam"
  156. resultType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  157. select distinct id,substr(o.id,4,length(o.id)) as org_id from bis_insp_all_rlation o where o.id like '___${orgId}%' and
  158. persid=#{persId}
  159. <choose>
  160. <when test="province !=null and province !=''">
  161. and o.ad_code=#{province}
  162. </when>
  163. <otherwise>
  164. and o.ad_code is null
  165. </otherwise>
  166. </choose>
  167. </select>
  168. <select id="selectCount" resultType="int">
  169. select count(ID) from BIS_INSP_ALL t
  170. <include refid="page_where"/>
  171. <include refid="selSql"/>
  172. </select>
  173. <select id="selectMax" resultType="String">
  174. select Max(ID) as id from BIS_INSP_ALL
  175. <include refid="page_where"/>
  176. </select>
  177. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  178. insert into BIS_INSP_ALL(
  179. <include refid="table_columns"/>
  180. )
  181. values (
  182. <include refid="entity_properties"/>
  183. )
  184. </insert>
  185. <delete id="delete" parameterType="java.lang.String">
  186. delete from BIS_INSP_ALL where ID = #{id}
  187. </delete>
  188. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  189. delete from BIS_INSP_ALL
  190. <include refid="page_where"/>
  191. </delete>
  192. <update id="deleteInFlag" parameterType="java.lang.String">
  193. update BIS_INSP_ALL set flag_valid = 0 where ID = #{id}
  194. </update>
  195. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  196. update BIS_INSP_ALL
  197. <trim prefix="set" suffixOverrides=",">
  198. <if test="pid != null and pid != ''">PID = #{pid},</if>
  199. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  200. <if test="sttm != null">STTM = #{sttm},</if>
  201. <if test="entm != null">ENTM = #{entm},</if>
  202. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  203. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  204. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  205. <if test="impData != null">IMP_DATA = #{impData},</if>
  206. <if test="chkType != null and chkType != ''">CHK_TYPE = #{chkType},</if>
  207. <if test="leadDep != null and leadDep != ''">LEAD_DEP = #{leadDep},</if>
  208. <if test="chkForm != null and chkForm != ''">CHK_FORM = #{chkForm},</if>
  209. <if test="yearTaskId != null and yearTaskId != ''">YEAR_TASK_ID = #{yearTaskId},</if>
  210. <if test="isPlan != null and isPlan != ''">IS_PLAN = #{isPlan},</if>
  211. <if test="quantity != null">QUANTITY = #{quantity},</if>
  212. <if test="note != null and note != ''">NOTE = #{note},</if>
  213. </trim>
  214. <where>ID = #{id}</where>
  215. </update>
  216. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  217. update BIS_INSP_ALL
  218. <trim prefix="set" suffixOverrides=",">
  219. <if test="pid != null and pid != ''">PID = #{pid},</if>
  220. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  221. <if test="sttm != null">STTM = #{sttm},</if>
  222. <if test="entm != null">ENTM = #{entm},</if>
  223. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  224. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  225. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  226. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  227. <if test="impData != null">IMP_DATA = #{impData},</if>
  228. <if test="chkType != null and chkType != ''">CHK_TYPE = #{chkType},</if>
  229. <if test="leadDep != null and leadDep != ''">LEAD_DEP = #{leadDep},</if>
  230. <if test="chkForm != null and chkForm != ''">CHK_FORM = #{chkForm},</if>
  231. <if test="yearTaskId != null and yearTaskId != ''">YEAR_TASK_ID = #{yearTaskId},</if>
  232. <if test="isPlan != null and isPlan != ''">IS_PLAN = #{isPlan},</if>
  233. <if test="quantity != null">QUANTITY = #{quantity},</if>
  234. <if test="note != null and note != ''">NOTE = #{note},</if>
  235. </trim>
  236. <include refid="page_where"/>
  237. </update>
  238. <!-- 其他自定义SQL -->
  239. <!--查询子id最大的对象 参数 001-->
  240. <select id="getMaxOne" resultMap="bisInspAllResultMap">
  241. select Max(id) as id from BIS_INSP_ALL t where t.pid = #{pid}
  242. </select>
  243. <select id="getAllNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  244. select DISTINCT w.* from (
  245. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  246. where SUBSTR(a.id,1,6)=t.ID
  247. <include refid="selSql"/>
  248. and t.persid=#{userid} and length(t.ID)=6
  249. <if test="orgType !=null and orgType != ''">
  250. and a.ID LIKE concat(#{orgType},'%')
  251. </if>
  252. UNION ALL
  253. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  254. where SUBSTR(a.id,1,9)=t.ID
  255. <include refid="selSql"/>
  256. and t.persid=#{userid} and LENGTH(t.id)=9
  257. <if test="orgType !=null and orgType != ''">
  258. and a.ID LIKE concat(#{orgType},'%')
  259. </if>
  260. UNION ALL
  261. select a.*,t.PERSID,t.AD_CODE from bis_insp_all a ,bis_insp_all_rlation t
  262. where a.id=t.ID
  263. <include refid="selSql"/>
  264. and t.persid=#{userid} and LENGTH(t.id)=12
  265. <if test="orgType !=null and orgType != ''">
  266. and a.ID LIKE concat(#{orgType},'%')
  267. </if>
  268. ) w where 1=1
  269. <if test="orgType !=null and orgType != ''">
  270. and ID LIKE concat(#{orgType},'%')
  271. </if>
  272. <if test="tabType =='2'.toString()">
  273. and entm &lt; DATE_ADD( STR_TO_DATE(#{nowTime},'%Y-%m-%d'), INTERVAL 1 day )
  274. </if>
  275. <if test="tabType =='1'.toString()">
  276. and entm &gt;=STR_TO_DATE(#{nowTime},'%Y-%m-%d')
  277. </if>
  278. <if test="year !=null and year != ''">
  279. and INSP_YEAR=#{year}
  280. </if>
  281. <if test="curYear !=null and curYear != ''">
  282. and ((DATE_FORMAT(STTM,'%Y') = #{curYear}) OR (DATE_FORMAT(ENTM,'%Y') = #{curYear}))
  283. </if>
  284. <if test="yearTaskId !=null and yearTaskId != ''">
  285. and (YEAR_TASK_ID=#{yearTaskId} or length(id)=6)
  286. </if>
  287. <if test="leadDep !=null and leadDep != ''">
  288. and lead_dep LIKE CONCAT('%', CONCAT(#{leadDep}, '%') )
  289. </if>
  290. order by id
  291. </select>
  292. <select id="BisInspAllObjById" resultType="cn.com.goldenwater.dcproj.model.BisInspAllNode">
  293. select RGSTR_ID as id,ID as pid,OBJ_NM AS pnm,OBJ_ID,AD_CODE,code from
  294. VIEW_REG_BASE t
  295. where
  296. 1 = 1
  297. <include refid="choseSql"/>
  298. <if test="id !=null and id != ''">
  299. and ID = #{id}
  300. </if>
  301. order by OBJ_NM
  302. </select>
  303. <sql id="choseSql">
  304. <choose>
  305. <when test="province !=null and province !=''">
  306. and ad_code like '%${province}%'
  307. </when>
  308. <otherwise>
  309. and ad_code is null
  310. </otherwise>
  311. </choose>
  312. </sql>
  313. <select id="getAllNodeByLevel" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  314. select id,pid,pnm,sttm,entm from
  315. BIS_INSP_ALL t where
  316. REGEXP_LIKE(
  317. Id, concat('^(',
  318. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  319. <include refid="choseSql"/>
  320. )>0 then
  321. (SELECT group_concat(id separator '|') as id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{persId}
  322. <include refid="choseSql"/>
  323. GROUP BY PERSID
  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
  370. WHERE find_in_set(ID, getSubNodes_bis_insp_all(#{objType},1,0)) &gt; 0
  371. ) a
  372. LEFT JOIN BIS_INSP_ALL_RLATION t ON a.ID = t.id
  373. LEFT JOIN BIS_INSP_ALL_RLATION_PERS c ON t.PERSID = c.GUID
  374. LEFT JOIN BIS_INSP_ALL d ON a.PID = d.ID
  375. WHERE length(a.ID) = 12
  376. <include refid="selSql"/>
  377. ORDER BY
  378. a.ID,b.PERTYPE desc
  379. </select>
  380. <sql id="objSql">
  381. <choose>
  382. <when test="province !=null and province !=''">
  383. and obj.ad_code=#{province}
  384. </when>
  385. <otherwise>
  386. and obj.ad_code is null
  387. </otherwise>
  388. </choose>
  389. </sql>
  390. <!--导出模块获取流域树 水库1,人饮2,水毁3 三棵树-->
  391. <select id="getNodeByPidAndCode" resultType="java.util.LinkedHashMap">
  392. <choose>
  393. <when test="pid.length() >= 12">
  394. select distinct '' "id", obj.nm "pnm",
  395. obj.code "code", obj.nm "nm",obj.ptype "pType",obj.obj_id "objId",rgstr.eng_id "engId"
  396. from BIS_INSP_ALL_OBJ obj left join BIS_INSP_VILL_RGSTR rgstr
  397. on obj.obj_id = rgstr.obj_id
  398. where
  399. obj.id = #{pid}
  400. <!--instr((select LISTAGG(code, ',') WITHIN GROUP(ORDER BY id) from BIS_INSP_ALL_OBJ where id = #{pid}),obj.code) > 0-->
  401. <if test="type !=null and type == '2'.toString()">
  402. and rgstr.eng_id is not null
  403. </if>
  404. <include refid="objSql"/>
  405. <if test="type !=null and type == '1'.toString()">
  406. and rgstr.eng_id = 'non'
  407. </if>
  408. <if test="type !=null and type == '3'.toString()">
  409. and rgstr.eng_id = 'non'
  410. </if>
  411. </when>
  412. <otherwise>
  413. SELECT distinct
  414. ia.id "id", ia.pnm "pnm"
  415. FROM BIS_INSP_ALL ia
  416. LEFT JOIN BIS_INSP_ALL_OBJ obj ON ia.id = obj.id
  417. WHERE ia.pid LIKE concat(#{pid}, '%')
  418. AND length(ia.id) = length(#{pid})+3
  419. <include refid="objSql"/>
  420. <if test="pid !=null and pid.length() >= 9 and code !=null and code !=''">
  421. <choose>
  422. <when test="type !=null and type=='3'.toString()">
  423. AND instr(#{code},substr((select loc_ad from BIS_INSP_WTDST where wtdst_id = obj.code),1,2))
  424. > 0
  425. </when>
  426. <otherwise>
  427. AND instr(#{code},substr(code,1,2)) > 0
  428. </otherwise>
  429. </choose>
  430. </if>
  431. ORDER BY ia.id
  432. </otherwise>
  433. </choose>
  434. </select>
  435. <select id="getAllNodeById" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  436. select id,pid,pnm,sttm,entm from BIS_INSP_ALL where id in (${id})
  437. </select>
  438. <select id="countSysMsg" parameterType="String" resultType="cn.com.goldenwater.dcproj.dto.DataDto">
  439. select sum(ducha_type) as ducha_type,sum(ducha_group) as ducha_group,sum(ducha_pers) as ducha_pers,
  440. sum(ducha_obj) as ducha_obj,sum(ducha_pblm) as ducha_pblm from (
  441. select count(distinct substr(t.id,1,3)) as ducha_type,0 as ducha_group,0 as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  442. from bis_insp_all t where length(t.id)=12 and t.sttm &lt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d')
  443. and t.entm &gt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d') and t.id like '___${orgId}%'
  444. union all
  445. select 0 as ducha_type,count(t.id) as ducha_group,0 as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  446. from bis_insp_all t where length(t.id)=12 and t.sttm &lt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d')
  447. and t.entm &gt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d') and t.id like '___${orgId}%'
  448. union all
  449. select 0 as ducha_type,0 as ducha_group,count(distinct r.persid ) as ducha_pers,0 as ducha_obj,0 as ducha_pblm
  450. from bis_insp_all t,bis_insp_all_rlation r where length(t.id)=12 and t.id=r.id
  451. and t.sttm &lt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d')
  452. and t.entm &gt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d') and t.id like '___${orgId}%'
  453. union all
  454. select 0 as ducha_type,0 as ducha_group,0 as ducha_pers,count(r.code ) as ducha_obj,0 as ducha_pblm
  455. from bis_insp_all t,bis_insp_all_obj r where t.id=r.id and t.sttm &lt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d')
  456. and t.entm &gt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d') and t.id like '___${orgId}%'
  457. union all
  458. select 0 as ducha_type,0 as ducha_group,0 as ducha_pers,0 as ducha_obj,count(m.pblm_id ) as ducha_pblm
  459. 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
  460. and t.sttm &lt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d')
  461. and t.entm &gt;= STR_TO_DATE(#{nowTIme},'%Y-%m-%d') and t.id like '___${orgId}%'
  462. ) w
  463. </select>
  464. <select id="countUserLine" resultType="cn.com.goldenwater.dcproj.dto.UserLineDto">
  465. select sum(pers_total) as pers_total,sum(active_user) as active_user,org_id from (
  466. select count(g.pers_id) as pers_total,0 as active_user,g.org_id from bis_insp_all_rlation_pers
  467. t,bis_insp_pers_org g
  468. where t.guid=g.pers_id
  469. <choose>
  470. <when test="orgId !=null and orgId !=''">
  471. and g.org_id=#{orgId}
  472. </when>
  473. <otherwise>
  474. and g.org_id is null
  475. </otherwise>
  476. </choose>
  477. group by g.org_id
  478. union all
  479. select 0 as pers_total,count(distinct s.guid) as active_user,o.org_id from bis_insp_all_rlation_pers
  480. s,bis_insp_pers_org o,bis_insp_log g
  481. where s.guid =g.user_id and s.guid=o.pers_id
  482. <choose>
  483. <when test="orgId !=null and orgId !=''">
  484. and o.org_id=#{orgId}
  485. </when>
  486. <otherwise>
  487. and o.org_id is null
  488. </otherwise>
  489. </choose>
  490. group by o.org_id
  491. ) w group by org_id
  492. </select>
  493. <select id="countUserLine2" resultType="cn.com.goldenwater.dcproj.dto.UserLineDto">
  494. select sum(pers_total) as pers_total,sum(active_user) as active_user,org_id from (
  495. select count(g.pers_id) as pers_total,0 as active_user,g.org_id from bis_insp_all_rlation_pers
  496. t,bis_insp_pers_org g
  497. where t.guid=g.pers_id
  498. <if test="orgId !=null and orgId !=''">
  499. and g.org_id=#{orgId}
  500. </if>
  501. group by g.org_id
  502. union all
  503. select 0 as pers_total,count(distinct s.guid) as active_user,o.org_id from bis_insp_all_rlation_pers
  504. s,bis_insp_pers_org o,bis_insp_log g
  505. where s.guid =g.user_id and s.guid=o.pers_id
  506. <if test="orgId !=null and orgId !=''">
  507. and o.org_id=#{orgId}
  508. </if>
  509. group by o.org_id
  510. ) w group by org_id
  511. </select>
  512. <select id="findOrgMsg" resultType="cn.com.goldenwater.dcproj.dto.OrgDto">
  513. select t.org_id,t.org_nm
  514. from bis_insp_org t
  515. where t.org_pid='1'
  516. </select>
  517. <select id="listByName" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  518. SELECT
  519. @rownum := @rownum + 1 id, O.*
  520. FROM (
  521. SElECT
  522. '000' PID, PNM, cast(group_concat(ID separator ',') as char) AS "code"
  523. FROM BIS_INSP_ALL
  524. WHERE
  525. PID IN (${pTypes})
  526. AND LENGTH(ID) = #{length}
  527. GROUP BY PNM
  528. ORDER BY cast(group_concat(ID separator ',') as char)
  529. ) o
  530. ,(select @rownum := 0 ) r
  531. </select>
  532. <select id="listByMap" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllDto">
  533. SELECT distinct C.*, T.NAME AS OBJ_TYPE_NAME, CT.PNM PPNM
  534. FROM BIS_INSP_ALL C
  535. LEFT JOIN BIS_INSP_ALL CT ON CT.ID = C.PID
  536. JOIN (select * FROM ATT_INSP_TYPE where code IN (select INSP_TYPE FROM REL_ORG_INSP_TYPE
  537. <where>
  538. <if test="orgId != null and orgId != '' ">
  539. AND ORG_ID = #{orgId}
  540. </if>
  541. </where>
  542. )) T ON SUBSTR(C.ID, 1, 3) = T.CODE
  543. LEFT JOIN BIS_INSP_ALL_OBJ O ON O.ID = C.ID
  544. <where>
  545. length(C.ID) = 12
  546. <if test="depm != null and depm.size() > 0 ">
  547. AND SUBSTR(C.ID, 1, 3) IN (SELECT PTYPE FROM ATT_INSP_TYPE_DUTY where DUTY_DEP IN
  548. <foreach item="item" index="index" collection="depm" open="(" separator="," close=")">
  549. '${item}'
  550. </foreach>
  551. )
  552. </if>
  553. <if test="adCode != null and adCode != ''">and O.OBJ_AD_CODE like concat(#{adCode}, '%')</if>
  554. <if test="length != null and length != ''">and length(C.ID) = #{length}</if>
  555. <if test="id != null and id != ''">and C.ID like '%${id}%'</if>
  556. <if test="pnm != null and pnm != ''">and C.pnm like '%${pnm}%'</if>
  557. <if test="objTypeName != null and objTypeName != ''">and T.NAME like '%${objTypeName}%'</if>
  558. <if test="ppnm != null and ppnm != ''">and CT.PNM like '%${ppnm}%'</if>
  559. <if test="orgId != null and orgId != '' ">AND C.ID LIKE '___${orgId}%'</if>
  560. <if test='objType != null and objType != ""'>and cast(SUBSTR(C.ID, 1, 3) as SIGNED ) = #{objType}</if>
  561. <if test='sttm != null and sttm != "" and entm != null and entm != "" '>
  562. AND C.STTM &gt;= STR_TO_DATE(#{sttm}, '%Y-%m-%d')
  563. AND C.STTM &lt; DATE_ADD( STR_TO_DATE(#{entm}, '%Y-%m-%d') , INTERVAL 1 day )
  564. </if>
  565. </where>
  566. order by C.ID
  567. </select>
  568. <select id="listByMap2" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllDto">
  569. SELECT distinct C.*
  570. FROM BIS_INSP_ALL C
  571. <where>
  572. <if test="length != null and length != ''">and length(C.ID) = #{length}</if>
  573. <if test="id != null and id != ''">and C.ID like '%${id}%'</if>
  574. <if test='pnm != null and pnm != ""'>and C.pnm like '%${pnm}%'</if>
  575. <if test='year != null and year != ""'>and DATE_FORMAT(C.STTM, '%Y') = #{year}</if>
  576. <if test='sttm != null and sttm != "" and entm != null and entm != "" '>
  577. AND STR_TO_DATE(DATE_FORMAT(C.STTM, '%Y-%m-%d'), '%Y-%m-%d') &gt;= STR_TO_DATE(#{sttm}, '%Y-%m-%d')
  578. AND STR_TO_DATE(DATE_FORMAT(C.ENTM, '%Y-%m-%d'), '%Y-%m-%d') &lt; DATE_ADD( STR_TO_DATE(#{entm}, '%Y-%m-%d') , INTERVAL 1 day )
  579. </if>
  580. </where>
  581. order by C.ID
  582. </select>
  583. <select id="getYearById" resultType="java.lang.String">
  584. SELECT DISTINCT
  585. year
  586. FROM
  587. (
  588. SELECT
  589. DISTINCT DATE_FORMAT(STTM, '%Y') year
  590. FROM BIS_INSP_ALL
  591. where ID LIKE '${id}%'
  592. order by STTM
  593. ) a WHERE year IS NOT NULL
  594. </select>
  595. <select id="getPersDcWork" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  596. 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
  597. </select>
  598. <!--首页 四川 批次数汇总 督查批次统计 批次 类型 组数 督查人员数、区域数、对象数 -->
  599. <select id="getInspBatchNum" resultType="java.util.Map">
  600. select AB.ID , AB.PNM, AB.INSP_TYPE, T.NAME,
  601. IFNULL(COUNT(DISTINCT CASE WHEN AG.ID is not null THEN AG.ID END ),0) as GROUP_NUM ,
  602. IFNULL(COUNT(DISTINCT CASE WHEN AR.PERSID is not null THEN AR.PERSID END ),0) as PERS_NUM ,
  603. IFNULL(COUNT(DISTINCT CASE WHEN SA.AREA_ID is not null THEN SA.AREA_ID END ),0) as AREA_NUM ,
  604. IFNULL(COUNT(DISTINCT CASE WHEN AO.OBJ_ID is not null THEN AO.OBJ_ID END ),0) as OBJ_NUM
  605. from BIS_INSP_ALL AB
  606. 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
  607. LEFT JOIN BIS_INSP_ALL AG on AG.PID = AB.ID
  608. LEFT JOIN BIS_INSP_ALL_RLATION AR ON AR.ID = AG.ID
  609. LEFT JOIN BIS_INSP_SEL_AREA SA ON SA.ID = AG.ID
  610. LEFT JOIN BIS_INSP_ALL_OBJ AO ON AO.ID = AG.ID
  611. <where>
  612. LENGTH(AB.ID) = 9
  613. <if test=' null != orgId and "" !=orgId' >
  614. AND AB.ID like '___${orgId}%'
  615. </if>
  616. <if test=' null != adCode and "" !=adCode' >
  617. AND AB.PROVINCE like '${adCode}%'
  618. </if>
  619. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  620. AND STR_TO_DATE(DATE_FORMAT(AB.STTM, '%Y-%m-%d'), '%Y-%m-%d') &gt;= STR_TO_DATE(#{sttm}, '%Y-%m-%d')
  621. AND STR_TO_DATE(DATE_FORMAT(AB.INTM, '%Y-%m-%d'), '%Y-%m-%d') &lt; DATE_ADD( STR_TO_DATE(#{entm}, '%Y-%m-%d') , INTERVAL 1 day )
  622. </if>
  623. <if test=' null != pnm and "" !=pnm' >
  624. AND AB.PNM like '%${pnm}%'
  625. </if>
  626. <if test=' null != objType and "" !=objType' >
  627. AND AB.ID like '${objType}%'
  628. </if>
  629. <if test=' null != objTypeName and "" !=objTypeName' >
  630. AND T.NAME like '%${objTypeName}%'
  631. </if>
  632. </where>
  633. group by AB.ID , AB.PNM, AB.INSP_TYPE, T.NAME
  634. </select>
  635. </mapper>