ImportExcelDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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.ImportExcelDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspAll" id="ImportExcelResultMap">
  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. </resultMap>
  14. <sql id="table_columns">
  15. ID,
  16. PID,
  17. PNM,
  18. STTM,
  19. ENTM,INSP_YEAR,INSP_MNTH,INSP_TASK
  20. </sql>
  21. <sql id="entity_properties">
  22. #{id},
  23. #{pid},
  24. #{pnm},
  25. #{sttm},
  26. #{entm},#{inspYear},#{inspMnth},#{inspTask}
  27. </sql>
  28. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  29. <sql id="page_where">
  30. <trim prefix="where" prefixOverrides="and | or ">
  31. <if test="id != null and id != ''">and ID LIKE concat(#{id},'%')</if>
  32. <if test="pid != null and pid != ''">and PID = #{pid}</if>
  33. <if test="pnm != null and pnm != ''">and PNM like concat('%',concat(#{pnm},'%'))</if>
  34. <if test="sttm != null">and STTM = #{sttm}</if>
  35. <if test="entm != null">and ENTM = #{entm}</if>
  36. <if test="inspMnth != null and inspMnth != ''">and INSP_MNTH = #{inspMnth}</if>
  37. <if test="inspYear != null and inspYear != ''">and INSP_YEAR = #{inspYear}</if>
  38. </trim>
  39. </sql>
  40. <select id="getOne" resultMap="ImportExcelResultMap">
  41. select * from BIS_INSP_ALL a where a.id in (select ID from bis_insp_all_obj j where j.nm like '%${nm}%')
  42. <if test="id != null and id != ''">and ID LIKE concat(#{id},'%')</if>
  43. <if test="pid != null and pid != ''">and PID = #{pid}</if>
  44. <if test="pnm != null and pnm != ''">and PNM like concat('%',concat(#{pnm},'%'))</if>
  45. <if test="sttm != null">and STTM = #{sttm}</if>
  46. <if test="entm != null">and ENTM = #{entm}</if>
  47. <if test="inspMnth != null and inspMnth != ''">and INSP_MNTH = #{inspMnth}</if>
  48. <if test="inspYear != null and inspYear != ''">and INSP_YEAR = #{inspYear}</if>
  49. </select>
  50. <select id="get" resultMap="ImportExcelResultMap" parameterType="String">
  51. select
  52. <include refid="table_columns"/>
  53. from BIS_INSP_ALL where ID = #{id}
  54. </select>
  55. <select id="getBy" resultMap="ImportExcelResultMap">
  56. select
  57. <include refid="table_columns"/>
  58. from BIS_INSP_ALL
  59. <include refid="page_where"/>
  60. </select>
  61. <select id="findAll" resultMap="ImportExcelResultMap">
  62. select
  63. <include refid="table_columns"/>
  64. from BIS_INSP_ALL
  65. </select>
  66. <select id="findAreas" resultMap="ImportExcelResultMap">
  67. select bas_code as id,bas_name as pnm from ATT_BAS_BASE order by bas_code
  68. </select>
  69. <select id="findList" resultMap="ImportExcelResultMap">
  70. select
  71. <include refid="table_columns"/>
  72. from BIS_INSP_ALL
  73. <include refid="page_where"/>
  74. </select>
  75. <select id="findBasinList" resultMap="ImportExcelResultMap">
  76. select distinct substr(t.id,4,3) id,t.pnm from bis_insp_all t
  77. <include refid="page_where"/>
  78. </select>
  79. <select id="findNodeByPersId" resultMap="ImportExcelResultMap">
  80. select DISTINCT t2.ID,t2.PID,t2.PNM,t2.STTM,t2.ENTM
  81. from bis_insp_all t2
  82. start with t2.id in
  83. (select t.id
  84. from bis_insp_all_rlation t
  85. where t.persid =#{persId})
  86. connect by t2.pid = prior t2.id
  87. </select>
  88. <select id="selectCount" resultType="int">
  89. select count(ID) from BIS_INSP_ALL
  90. <include refid="page_where"/>
  91. </select>
  92. <select id="selectMax" resultType="String">
  93. select Max(ID) as id from BIS_INSP_ALL
  94. <include refid="page_where"/>
  95. </select>
  96. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  97. insert into BIS_INSP_ALL(
  98. <include refid="table_columns"/>
  99. )
  100. values (
  101. <include refid="entity_properties"/>
  102. )
  103. </insert>
  104. <delete id="delete" parameterType="java.lang.String">
  105. delete from BIS_INSP_ALL where ID = #{id}
  106. </delete>
  107. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  108. delete from BIS_INSP_ALL
  109. <include refid="page_where"/>
  110. </delete>
  111. <update id="deleteInFlag" parameterType="java.lang.String">
  112. update BIS_INSP_ALL set flag_valid = 0 where ID = #{id}
  113. </update>
  114. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  115. update BIS_INSP_ALL
  116. <trim prefix="set" suffixOverrides=",">
  117. <if test="pid != null and pid != ''">PID = #{pid},</if>
  118. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  119. <if test="sttm != null">STTM = #{sttm},</if>
  120. <if test="entm != null">ENTM = #{entm},</if>
  121. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  122. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  123. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  124. </trim>
  125. <where>ID = #{id}</where>
  126. </update>
  127. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  128. update BIS_INSP_ALL
  129. <trim prefix="set" suffixOverrides=",">
  130. <if test="pid != null and pid != ''">PID = #{pid},</if>
  131. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  132. <if test="sttm != null">STTM = #{sttm},</if>
  133. <if test="entm != null">ENTM = #{entm},</if>
  134. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  135. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  136. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  137. </trim>
  138. <include refid="page_where"/>
  139. </update>
  140. <!-- 其他自定义SQL -->
  141. <sql id="orgIdSql">
  142. <choose>
  143. <when test="orgId !=null and orgId !=''">
  144. and ORG_ID=#{orgId}
  145. </when>
  146. <otherwise>
  147. and ORG_ID is null
  148. </otherwise>
  149. </choose>
  150. </sql>
  151. <!--查询子id最大的对象 参数 001-->
  152. <select id="getMaxOne" resultMap="ImportExcelResultMap">
  153. select Max(id) as id from BIS_INSP_ALL t where t.pid = #{pid}
  154. </select>
  155. <select id="getAllNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  156. select id,pid,pnm,sttm,entm from
  157. BIS_INSP_ALL t where
  158. REGEXP_LIKE(
  159. Id,'^('||
  160. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} <include refid="orgIdSql"/> )>0 then
  161. (SELECT LISTAGG(id, '|') as
  162. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{userid} <include refid="orgIdSql"/> GROUP BY PERSID)
  163. else (select 'non' from dual) end)
  164. ||')')
  165. <if test="orgType !=null and orgType != ''">
  166. and ID LIKE concat(#{orgType},'%')
  167. </if>
  168. <if test="orgType !=null and orgType != ''">
  169. and ID LIKE concat(#{orgType},'%')
  170. </if>
  171. order by id
  172. </select>
  173. <select id="getAllNodeByLevel" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  174. select id,pid,pnm,sttm,entm from
  175. BIS_INSP_ALL t where
  176. REGEXP_LIKE(
  177. Id,'^('||
  178. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{persId} <include refid="orgIdSql"/>)>0 then
  179. (SELECT LISTAGG(id, '|') as
  180. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{persId} <include refid="orgIdSql"/> GROUP BY PERSID)
  181. else (select 'non' from dual) end)
  182. ||')')
  183. <if test="objType !=null and objType != ''">
  184. and ID LIKE concat(#{objType},'%')
  185. </if>
  186. <if test="level !=null and level != ''">
  187. and length(ID) >= #{level}
  188. </if>
  189. order by ID
  190. </select>
  191. <select id="BisInspAllObjById" resultType="cn.com.goldenwater.dcproj.model.BisInspAllNode">
  192. select RGSTR_ID as id,ID as pid,OBJ_NM AS pnm,OBJ_ID from
  193. VIEW_REG_BASE t
  194. where
  195. 1 = 1
  196. <if test="id !=null and id != ''">
  197. and ID = #{id}
  198. </if>
  199. order by OBJ_NM
  200. </select>
  201. <delete id="deleteAll" parameterType="String">
  202. DELETE FROM BIS_INSP_ALL WHERE ID LIKE '${id}%'
  203. </delete>
  204. <select id="getUserByOrg" resultType="java.util.HashMap">
  205. SELECT
  206. a.ID,
  207. a.PID,
  208. a.PNM,
  209. d.PNM AS pidnm,
  210. b.PERTYPE,
  211. c.GUID,
  212. c.ORG_ID,
  213. c.PERS_NAME,
  214. c.BORN_DATE,
  215. c.PLST,
  216. c.SCHOOL,
  217. c.SPECIALTY,
  218. c.TELNUMB,
  219. c.FAXNUMB,
  220. c.ADM_DUTY,
  221. c.ORG_NM,
  222. c.MOBILENUMB,
  223. c.IDNM,
  224. c.DPNM,
  225. c.DPPOST,
  226. c.EMAIL,
  227. c.REMARK,
  228. c.IMGURL
  229. FROM
  230. (
  231. SELECT
  232. ID,
  233. PID,
  234. PNM,
  235. STTM,
  236. ENTM
  237. FROM
  238. BIS_INSP_ALL a START WITH a.id = #{objType} connect BY prior a.ID = a.PID
  239. ) a
  240. LEFT JOIN BIS_INSP_ALL_RLATION b ON a.ID = b.id
  241. LEFT JOIN BIS_INSP_ALL_RLATION_PERS c ON b.PERSID = c.GUID
  242. LEFT JOIN BIS_INSP_ALL d ON a.PID = d.ID
  243. WHERE length(a.ID) = 12
  244. ORDER BY
  245. a.ID,b.PERTYPE desc
  246. </select>
  247. <!--导出模块获取流域树 水库1,人饮2,水毁3 三棵树-->
  248. <select id="getNodeByPidAndCode" resultType="java.util.LinkedHashMap">
  249. <choose>
  250. <when test="pid.length() >= 12">
  251. select distinct '' "id", obj.nm "pnm",
  252. obj.code "code", obj.nm "nm",obj.ptype "pType",obj.obj_id "objId",rgstr.eng_id "engId"
  253. from BIS_INSP_ALL_OBJ obj left join BIS_INSP_VILL_RGSTR rgstr
  254. on obj.obj_id = rgstr.obj_id
  255. where
  256. obj.id = #{pid}
  257. <!--instr((select LISTAGG(code, ',') WITHIN GROUP(ORDER BY id) from BIS_INSP_ALL_OBJ where id = #{pid}),obj.code) > 0-->
  258. <if test="type !=null and type == '2'.toString()">
  259. and rgstr.eng_id is not null
  260. </if>
  261. <if test="type !=null and type == '1'.toString()">
  262. and rgstr.eng_id = 'non'
  263. </if>
  264. <if test="type !=null and type == '3'.toString()">
  265. and rgstr.eng_id = 'non'
  266. </if>
  267. </when>
  268. <otherwise>
  269. SELECT distinct
  270. ia.id "id", ia.pnm "pnm"
  271. FROM BIS_INSP_ALL ia
  272. LEFT JOIN BIS_INSP_ALL_OBJ ar ON ia.id = ar.id
  273. WHERE ia.pid LIKE #{pid}||'%'
  274. AND length(ia.id) = length(#{pid})+3
  275. <if test="pid !=null and pid.length() >= 9 and code !=null and code !=''">
  276. <choose>
  277. <when test="type !=null and type=='3'.toString()">
  278. AND instr(#{code},substr((select loc_ad from BIS_INSP_WTDST where wtdst_id = ar.code),0,2))
  279. > 0
  280. </when>
  281. <otherwise>
  282. AND instr(#{code},substr(code,0,2)) > 0
  283. </otherwise>
  284. </choose>
  285. </if>
  286. ORDER BY ia.id
  287. </otherwise>
  288. </choose>
  289. </select>
  290. <select id="getOldGroupInfo" resultType="java.util.Map" parameterType="java.util.Map">
  291. select c.id,c.pnm,c.sttm,c.entm,c.intm,c.insp_year,c.insp_mnth,b.obj_id,b.code,b.nm,b.obj_intm,a.intm,a.uptm
  292. from BIS_INSP_RSVR_RGSTR a
  293. left join bis_insp_all_obj b on a.obj_id = b.obj_id
  294. left join bis_insp_all c on b.id = c.id
  295. where a.intm > c.entm and c.insp_mnth = #{inspMnth}
  296. order by c.id,b.code
  297. </select>
  298. </mapper>