6c7d3a9caafe61bfd6cd4381059ffd8ecfe67d90.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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.TacInspYearBatchDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacInspYearBatch" id="tacInspYearBatchResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="year" column="YEAR"/>
  7. <result property="batch" column="BATCH"/>
  8. <result property="isAreaGroup" column="IS_AREA_GROUP"/>
  9. <result property="isPersGroup" column="IS_PERS_GROUP"/>
  10. <result property="isAppraisal" column="IS_APPRAISAL"/>
  11. <result property="persId" column="PERS_ID"/>
  12. <result property="inTm" column="IN_TM"/>
  13. <result property="upTm" column="UP_TM"/>
  14. <result property="dataStat" column="DATA_STAT"/>
  15. <result property="province" column="PROVINCE"/>
  16. <result property="type" column="TYPE"/>
  17. </resultMap>
  18. <sql id="table_columns">
  19. ID,
  20. YEAR,
  21. BATCH,
  22. IS_AREA_GROUP,
  23. IS_PERS_GROUP,
  24. IS_APPRAISAL,
  25. PERS_ID,
  26. IN_TM,
  27. UP_TM,
  28. DATA_STAT,PROVINCE,TYPE
  29. </sql>
  30. <sql id="entity_properties">
  31. #{id},
  32. #{year},
  33. #{batch},
  34. #{isAreaGroup},
  35. #{isPersGroup},
  36. #{isAppraisal},
  37. #{persId},
  38. #{inTm},
  39. #{upTm},
  40. #{dataStat},#{province},#{type}
  41. </sql>
  42. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  43. <sql id="page_where">
  44. <trim prefix="where" prefixOverrides="and | or ">
  45. <if test="year != null and year != ''">and YEAR = #{year}</if>
  46. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  47. <if test="isAreaGroup != null and isAreaGroup != ''">and IS_AREA_GROUP = #{isAreaGroup}</if>
  48. <if test="isPersGroup != null and isPersGroup != ''">and IS_PERS_GROUP = #{isPersGroup}</if>
  49. <if test="isAppraisal != null and isAppraisal != ''">and IS_APPRAISAL = #{isAppraisal}</if>
  50. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  51. <if test="inTm != null">and IN_TM = #{inTm}</if>
  52. <if test="upTm != null">and UP_TM = #{upTm}</if>
  53. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  54. <if test="type != null and type != ''">and TYPE = #{type}</if>
  55. <include refid="choseSql"/>
  56. </trim>
  57. </sql>
  58. <sql id="choseSql" >
  59. <trim>
  60. <choose>
  61. <when test="province !=null and province !=''">
  62. and t.province=#{province}
  63. </when>
  64. <otherwise>
  65. and t.province is null
  66. </otherwise>
  67. </choose>
  68. </trim>
  69. </sql>
  70. <select id="get" resultMap="tacInspYearBatchResultMap" parameterType="String" >
  71. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH where ID = #{id}
  72. </select>
  73. <select id="getBy" resultMap="tacInspYearBatchResultMap">
  74. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
  75. </select>
  76. <select id="findAll" resultMap="tacInspYearBatchResultMap">
  77. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH
  78. </select>
  79. <select id="findList" resultMap="tacInspYearBatchResultMap">
  80. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
  81. </select>
  82. <select id="selectCount" resultType="int" >
  83. select count(ID) from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
  84. </select>
  85. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
  86. insert into TAC_INSP_YEAR_BATCH( <include refid="table_columns" /> )
  87. values ( <include refid="entity_properties" /> )
  88. </insert>
  89. <delete id="delete" parameterType="java.lang.String">
  90. delete from TAC_INSP_YEAR_BATCH where ID = #{id}
  91. </delete>
  92. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
  93. delete from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
  94. </delete>
  95. <update id="deleteInFlag" parameterType="java.lang.String">
  96. update TAC_INSP_YEAR_BATCH set flag_valid = 0 where ID = #{id}
  97. </update>
  98. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
  99. update TAC_INSP_YEAR_BATCH
  100. <trim prefix="set" suffixOverrides=",">
  101. <if test="year != null and year != ''">YEAR = #{year},</if>
  102. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  103. <if test="isAreaGroup != null and isAreaGroup != ''">IS_AREA_GROUP = #{isAreaGroup},</if>
  104. <if test="isPersGroup != null and isPersGroup != ''">IS_PERS_GROUP = #{isPersGroup},</if>
  105. <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
  106. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  107. <if test="inTm != null">IN_TM = #{inTm},</if>
  108. <if test="upTm != null">UP_TM = #{upTm},</if>
  109. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  110. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  111. <if test="type != null and type != ''">TYPE = #{type},</if>
  112. </trim>
  113. <where>ID = #{id}</where>
  114. </update>
  115. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
  116. update TAC_INSP_YEAR_BATCH
  117. <trim prefix="set" suffixOverrides=",">
  118. <if test="year != null and year != ''">YEAR = #{year},</if>
  119. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  120. <if test="isAreaGroup != null and isAreaGroup != ''">IS_AREA_GROUP = #{isAreaGroup},</if>
  121. <if test="isPersGroup != null and isPersGroup != ''">IS_PERS_GROUP = #{isPersGroup},</if>
  122. <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
  123. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  124. <if test="inTm != null">IN_TM = #{inTm},</if>
  125. <if test="upTm != null">UP_TM = #{upTm},</if>
  126. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  127. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  128. <if test="type != null and type != ''">TYPE = #{type},</if>
  129. </trim>
  130. <include refid="page_where" />
  131. </update>
  132. <!-- 其他自定义SQL -->
  133. <select id="getTacInspYearBatchList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  134. SELECT T.* FROM TAC_INSP_YEAR_BATCH T
  135. <where>
  136. <include refid="choseSql"/>
  137. <if test="dataStat != null and dataStat != ''">
  138. AND t.data_stat = #{dataStat}
  139. </if>
  140. <if test="year != null">
  141. AND t.year = #{year}
  142. </if>
  143. <if test="batch != null">
  144. AND t.batch = #{batch}
  145. </if>
  146. <if test="id != null and id != ''">
  147. and t.id = #{id}
  148. </if>
  149. </where>
  150. ORDER BY T.IN_TM DESC
  151. </select>
  152. <select id="getTacInspBatchByPersId" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  153. select t.* from TAC_INSP_YEAR_BATCH t
  154. where
  155. REGEXP_LIKE(
  156. t.id,'^('||
  157. ( case when(SELECT count(year_batch_id) from TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId})>0 then
  158. (SELECT replace(LISTAGG(year_batch_id, ',') as
  159. id FROM TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId} GROUP BY year_batch_id)
  160. else (select 'non' from dual) end)
  161. ||')')
  162. <include refid="choseSql"/>
  163. <if test="dataStat != null and dataStat != ''">
  164. AND t.data_stat = #{dataStat}
  165. </if>
  166. <if test="year != null">
  167. AND t.year = #{year}
  168. </if>
  169. <if test="batch != null">
  170. AND t.batch = #{batch}
  171. </if>
  172. order by t.IN_TM desc
  173. </select>
  174. <select id="getBatchList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  175. select t.*,p.id as persAreaId from TAC_INSP_YEAR_BATCH t left join TAC_INSP_PERS_AREA_PRIS p on t.id = p.year_batch_id
  176. where 1=1
  177. <include refid="choseSql"/>
  178. <if test="dataStat != null and dataStat != ''">
  179. AND t.data_stat = #{dataStat}
  180. </if>
  181. <if test="years != null and years != ''">
  182. AND t.year in (${years})
  183. </if>
  184. <if test="year != null and year != ''">
  185. and t.year = #{year}
  186. </if>
  187. <if test="batchs != null and batchs != ''">
  188. AND t.batch in (${batchs})
  189. </if>
  190. order by t.batch asc
  191. </select>
  192. <select id="countGroupAndPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  193. select b.*,c.persCount from (
  194. select a.year,a.batch,count(*) as groupCount from (
  195. select distinct t.year,t.batch,t.group_id from tac_insp_year_batch_group_pers t where t.group_id is not null
  196. and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
  197. <if test="year != null">
  198. and t.year = #{year}
  199. </if>
  200. <if test="batch != null">
  201. and t.batch = #{batch}
  202. </if>
  203. <if test="adCode != null and adCode != ''">
  204. and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/> )
  205. </if>
  206. <if test="type != null and type != ''">
  207. and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type}
  208. <include refid="choseSql"/>
  209. )
  210. </if>
  211. ) a group by a.batch,a.year
  212. ) b left join (
  213. select t.batch,t.year,count(*) as persCount from tac_insp_year_batch_group_pers t where t.group_id is not null
  214. and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
  215. <if test="year != null">
  216. and t.year = #{year}
  217. </if>
  218. <if test="batch != null">
  219. and t.batch = #{batch}
  220. </if>
  221. <if test="adCode != null and adCode != ''">
  222. and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/>)
  223. </if>
  224. <if test="type != null and type != ''">
  225. and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
  226. </if>
  227. group by t.batch,t.year
  228. ) c on b.batch = c.batch
  229. </select>
  230. <select id="countRoleTypeAndPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  231. select a.*,b.ctCount from (
  232. select b.year,b.role_type,count(*) as persCount from (
  233. select distinct t.year,t.ROLE_TYPE,t.pers_id from tac_insp_year_batch_group_pers t where t.pers_id is not null and t.group_id is not null
  234. and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
  235. <if test="year != null">
  236. and t.year = #{year}
  237. </if>
  238. <if test="batch != null">
  239. and t.batch = #{batch}
  240. </if>
  241. <if test="adCode != null and adCode != ''">
  242. and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/>)
  243. </if>
  244. <if test="type != null and type != ''">
  245. and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
  246. </if>
  247. ) b group by b.year,b.role_type
  248. ) a left join (
  249. select t.year,t.role_type,count(*) as ctCount from tac_insp_year_batch_group_pers t where t.pers_id is not null and t.group_id is not null
  250. and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
  251. <if test="year != null">
  252. and t.year = #{year}
  253. </if>
  254. <if test="batch != null">
  255. and t.batch = #{batch}
  256. </if>
  257. <if test="adCode != null and adCode != ''">
  258. and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/> )
  259. </if>
  260. <if test="type != null and type != ''">
  261. and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
  262. </if>
  263. group by t.year,t.role_type
  264. ) b on a.year = b.year and a.role_type = b.role_type
  265. </select>
  266. <select id="countArea" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  267. select t.year,
  268. LISTAGG(t.year || '年第' || t.batch || '批次,稽察时间 ' ||
  269. case when to_char(t.up_tm, 'yyyy-MM-dd') is null then '无' else to_char(t.up_tm, 'yyyy-MM-dd') end, ',')
  270. WITHIN GROUP (ORDER BY t.year,t.ad_code,t.ad_name)
  271. as detail,
  272. t.ad_code,
  273. t.ad_name,
  274. count(*) as count
  275. from tac_insp_year_batch_area t
  276. where 1 = 1
  277. <include refid="choseSql"/>
  278. <if test="year != null">
  279. and t.year = #{year}
  280. </if>
  281. <if test="batch != null">
  282. and t.batch = #{batch}
  283. </if>
  284. <if test="adCode != null and adCode != ''">
  285. and t.ad_code like '${adCode}%'
  286. </if>
  287. <if test="type != null and type != ''">
  288. and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/>)
  289. </if>
  290. group by t.year,t.ad_code,t.ad_name
  291. </select>
  292. <select id="getAllCountPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  293. select count(*) as count from (
  294. select DISTINCT pers_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t where t.pers_id is not null and t.group_id is not NULL
  295. and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
  296. <if test="year != null">
  297. and t.year = #{year}
  298. </if>
  299. <if test="batch != null">
  300. and t.batch = #{batch}
  301. </if>
  302. <if test="adCode != null and adCode != ''">
  303. and t.group_id in (select group_id from tac_insp_year_batch_area t where adCode = #{adCode}
  304. <include refid="choseSql"/>
  305. )
  306. </if>
  307. <if test="type != null and type != ''">
  308. and t.group_id in (select group_id from tac_pawp_rgstr t where type = #{type} <include refid="choseSql"/> )
  309. </if>
  310. )
  311. </select>
  312. <select id="countObjByYear" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
  313. select count(*) as count, t.type as name from (
  314. select t.* from TAC_INSP_YEAR_BATCH t where t.type is not null
  315. <if test="persId != null and persId != ''">
  316. and t.id in (select year_batch_id FROM TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID in (select id from tac_worker_b b where b.login_id = #{persId}))
  317. </if>
  318. <if test="year != null">
  319. and t.year = #{year}
  320. </if>
  321. <if test="batch != null">
  322. and t.batch = #{batch}
  323. </if>
  324. <include refid="choseSql"/>
  325. ) t group by t.type
  326. </select>
  327. </mapper>