ImportExcelDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. where FIND_IN_SET(t2.id, getSubNodes_bis_insp_all((select group_concat(t.id)
  83. from bis_insp_all_rlation t
  84. where t.persid =#{persId} group by t.persid),1,0) ) &gt; 0
  85. </select>
  86. <select id="selectCount" resultType="int">
  87. select count(ID) from BIS_INSP_ALL
  88. <include refid="page_where"/>
  89. </select>
  90. <select id="selectMax" resultType="String">
  91. select Max(ID) as id from BIS_INSP_ALL
  92. <include refid="page_where"/>
  93. </select>
  94. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  95. insert into BIS_INSP_ALL(
  96. <include refid="table_columns"/>
  97. )
  98. values (
  99. <include refid="entity_properties"/>
  100. )
  101. </insert>
  102. <delete id="delete" parameterType="java.lang.String">
  103. delete from BIS_INSP_ALL where ID = #{id}
  104. </delete>
  105. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  106. delete from BIS_INSP_ALL
  107. <include refid="page_where"/>
  108. </delete>
  109. <update id="deleteInFlag" parameterType="java.lang.String">
  110. update BIS_INSP_ALL set flag_valid = 0 where ID = #{id}
  111. </update>
  112. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  113. update BIS_INSP_ALL
  114. <trim prefix="set" suffixOverrides=",">
  115. <if test="pid != null and pid != ''">PID = #{pid},</if>
  116. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  117. <if test="sttm != null">STTM = #{sttm},</if>
  118. <if test="entm != null">ENTM = #{entm},</if>
  119. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  120. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  121. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  122. </trim>
  123. <where>ID = #{id}</where>
  124. </update>
  125. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAll">
  126. update BIS_INSP_ALL
  127. <trim prefix="set" suffixOverrides=",">
  128. <if test="pid != null and pid != ''">PID = #{pid},</if>
  129. <if test="pnm != null and pnm != ''">PNM = #{pnm},</if>
  130. <if test="sttm != null">STTM = #{sttm},</if>
  131. <if test="entm != null">ENTM = #{entm},</if>
  132. <if test="inspMnth != null">INSP_MNTH = #{inspMnth},</if>
  133. <if test="inspYear != null">INSP_YEAR = #{inspYear},</if>
  134. <if test="inspTask != null">INSP_TASK = #{inspTask},</if>
  135. </trim>
  136. <include refid="page_where"/>
  137. </update>
  138. <!-- 其他自定义SQL -->
  139. <sql id="orgIdSql">
  140. <choose>
  141. <when test="orgId !=null and orgId !=''">
  142. and ORG_ID=#{orgId}
  143. </when>
  144. <otherwise>
  145. and ORG_ID is null
  146. </otherwise>
  147. </choose>
  148. </sql>
  149. <!--查询子id最大的对象 参数 001-->
  150. <select id="getMaxOne" resultMap="ImportExcelResultMap">
  151. select Max(id) as id from BIS_INSP_ALL t where t.pid = #{pid}
  152. </select>
  153. <select id="getAllNode" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  154. select id,pid,pnm,sttm,entm from
  155. BIS_INSP_ALL t where
  156. id in (${inIdsSql})
  157. <if test="orgType !=null and orgType != ''">
  158. and ID LIKE concat(#{orgType},'%')
  159. </if>
  160. <if test="orgType !=null and orgType != ''">
  161. and ID LIKE concat(#{orgType},'%')
  162. </if>
  163. order by id
  164. </select>
  165. <select id="getAllNodeByLevel" resultType="cn.com.goldenwater.dcproj.model.BisInspAll">
  166. select id,pid,pnm,sttm,entm from
  167. BIS_INSP_ALL t where
  168. id in (${inIdsSql})
  169. <if test="objType !=null and objType != ''">
  170. and ID LIKE concat(#{objType},'%')
  171. </if>
  172. <if test="level !=null and level != ''">
  173. and length(ID) >= #{level}
  174. </if>
  175. order by ID
  176. </select>
  177. <select id="BisInspAllObjById" resultType="cn.com.goldenwater.dcproj.model.BisInspAllNode">
  178. select RGSTR_ID as id,ID as pid,OBJ_NM AS pnm,OBJ_ID from
  179. VIEW_REG_BASE t
  180. where
  181. 1 = 1
  182. <if test="id !=null and id != ''">
  183. and ID = #{id}
  184. </if>
  185. order by OBJ_NM
  186. </select>
  187. <delete id="deleteAll" parameterType="String">
  188. DELETE FROM BIS_INSP_ALL WHERE ID LIKE '${id}%'
  189. </delete>
  190. <select id="getUserByOrg" resultType="java.util.HashMap">
  191. SELECT
  192. a.ID,
  193. a.PID,
  194. a.PNM,
  195. d.PNM AS pidnm,
  196. b.PERTYPE,
  197. c.GUID,
  198. c.ORG_ID,
  199. c.PERS_NAME,
  200. c.BORN_DATE,
  201. c.PLST,
  202. c.SCHOOL,
  203. c.SPECIALTY,
  204. c.TELNUMB,
  205. c.FAXNUMB,
  206. c.ADM_DUTY,
  207. c.ORG_NM,
  208. c.MOBILENUMB,
  209. c.IDNM,
  210. c.DPNM,
  211. c.DPPOST,
  212. c.EMAIL,
  213. c.REMARK,
  214. c.IMGURL
  215. FROM
  216. (
  217. SELECT
  218. ID,
  219. PID,
  220. PNM,
  221. STTM,
  222. ENTM
  223. FROM
  224. BIS_INSP_ALL
  225. WHERE FIND_IN_SET(ID ,getSubNodes_bis_insp_all(#{objType},1,0) ) &gt; 0
  226. ) a
  227. LEFT JOIN BIS_INSP_ALL_RLATION b ON a.ID = b.id
  228. LEFT JOIN BIS_INSP_ALL_RLATION_PERS c ON b.PERSID = c.GUID
  229. LEFT JOIN BIS_INSP_ALL d ON a.PID = d.ID
  230. WHERE length(a.ID) = 12
  231. ORDER BY
  232. a.ID,b.PERTYPE desc
  233. </select>
  234. <!--导出模块获取流域树 水库1,人饮2,水毁3 三棵树-->
  235. <select id="getNodeByPidAndCode" resultType="java.util.LinkedHashMap">
  236. <choose>
  237. <when test="pid.length() >= 12">
  238. select distinct '' "id", obj.nm "pnm",
  239. obj.code "code", obj.nm "nm",obj.ptype "pType",obj.obj_id "objId",rgstr.eng_id "engId"
  240. from BIS_INSP_ALL_OBJ obj left join BIS_INSP_VILL_RGSTR rgstr
  241. on obj.obj_id = rgstr.obj_id
  242. where
  243. obj.id = #{pid}
  244. <!--instr((select group_concat(code) from BIS_INSP_ALL_OBJ where id = #{pid}),obj.code) > 0-->
  245. <if test="type !=null and type == '2'.toString()">
  246. and rgstr.eng_id is not null
  247. </if>
  248. <if test="type !=null and type == '1'.toString()">
  249. and rgstr.eng_id = 'non'
  250. </if>
  251. <if test="type !=null and type == '3'.toString()">
  252. and rgstr.eng_id = 'non'
  253. </if>
  254. </when>
  255. <otherwise>
  256. SELECT distinct
  257. ia.id "id", ia.pnm "pnm"
  258. FROM BIS_INSP_ALL ia
  259. LEFT JOIN BIS_INSP_ALL_OBJ ar ON ia.id = ar.id
  260. WHERE ia.pid LIKE concat(#{pid},'%')
  261. AND length(ia.id) = length(#{pid})+3
  262. <if test="pid !=null and pid.length() >= 9 and code !=null and code !=''">
  263. <choose>
  264. <when test="type !=null and type=='3'.toString()">
  265. AND instr(#{code},substr((select loc_ad from BIS_INSP_WTDST where wtdst_id = ar.code),1,2))
  266. > 0
  267. </when>
  268. <otherwise>
  269. AND instr(#{code},substr(code,1,2)) > 0
  270. </otherwise>
  271. </choose>
  272. </if>
  273. ORDER BY ia.id
  274. </otherwise>
  275. </choose>
  276. </select>
  277. <select id="getOldGroupInfo" resultType="java.util.Map" parameterType="java.util.Map">
  278. 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
  279. from BIS_INSP_RSVR_RGSTR a
  280. left join bis_insp_all_obj b on a.obj_id = b.obj_id
  281. left join bis_insp_all c on b.id = c.id
  282. where a.intm > c.entm and c.insp_mnth = #{inspMnth}
  283. order by c.id,b.code
  284. </select>
  285. </mapper>