TacInspYearBatchGroupDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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.TacInspYearBatchGroupDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup" id="tacInspYearBatchGroupResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="yearBatchId" column="YEAR_BATCH_ID"/>
  7. <result property="year" column="YEAR"/>
  8. <result property="batch" column="BATCH"/>
  9. <result property="groupNm" column="GROUP_NM"/>
  10. <result property="audContent" column="AUD_CONTENT"/>
  11. <result property="tenet" column="TENET"/>
  12. <result property="isAppraisal" column="IS_APPRAISAL"/>
  13. <result property="audUnits" column="AUD_UNITS"/>
  14. <result property="audCategory" column="AUD_CATEGORY"/>
  15. <result property="remark" column="REMARK"/>
  16. <result property="persId" column="PERS_ID"/>
  17. <result property="inTm" column="IN_TM"/>
  18. <result property="upTm" column="UP_TM"/>
  19. <result property="dataStat" column="DATA_STAT"/>
  20. <result property="pris" column="PRIS"/>
  21. <result property="stTm" column="ST_TM"/>
  22. <result property="enTm" column="EN_TM"/>
  23. <result property="confirmer" column="CONFIRMER"/>
  24. </resultMap>
  25. <sql id="table_columns">
  26. ID,
  27. YEAR_BATCH_ID,
  28. YEAR,
  29. BATCH,
  30. GROUP_NM,
  31. AUD_CONTENT,
  32. TENET,
  33. IS_APPRAISAL,
  34. AUD_UNITS,
  35. AUD_CATEGORY,
  36. REMARK,
  37. PERS_ID,
  38. IN_TM,
  39. UP_TM,
  40. DATA_STAT,
  41. PRIS,
  42. ST_TM,
  43. EN_TM,
  44. CONFIRMER
  45. </sql>
  46. <sql id="entity_properties">
  47. #{id},
  48. #{yearBatchId},
  49. #{year},
  50. #{batch},
  51. #{groupNm},
  52. #{audContent},
  53. #{tenet},
  54. #{isAppraisal},
  55. #{audUnits},
  56. #{audCategory},
  57. #{remark},
  58. #{persId},
  59. #{inTm},
  60. #{upTm},
  61. #{dataStat},
  62. #{pris},
  63. #{stTm},#{enTm},
  64. #{confirmer}
  65. </sql>
  66. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  67. <sql id="page_where">
  68. <trim prefix="where" prefixOverrides="and | or ">
  69. <if test="yearBatchId != null and yearBatchId != ''">and YEAR_BATCH_ID = #{yearBatchId}</if>
  70. <if test="year != null and year != ''">and YEAR = #{year}</if>
  71. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  72. <if test="groupNm != null and groupNm != ''">and GROUP_NM = #{groupNm}</if>
  73. <if test="audContent != null and audContent != ''">and AUD_CONTENT = #{audContent}</if>
  74. <if test="tenet != null and tenet != ''">and TENET = #{tenet}</if>
  75. <if test="isAppraisal != null and isAppraisal != ''">and IS_APPRAISAL = #{isAppraisal}</if>
  76. <if test="audUnits != null and audUnits != ''">and AUD_UNITS = #{audUnits}</if>
  77. <if test="audCategory != null and audCategory != ''">and AUD_CATEGORY = #{audCategory}</if>
  78. <if test="remark != null and remark != ''">and REMARK = #{remark}</if>
  79. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  80. <if test="inTm != null">and IN_TM = #{inTm}</if>
  81. <if test="upTm != null">and UP_TM = #{upTm}</if>
  82. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  83. <if test="pris != null and pris != ''">and PRIS = #{pris}</if>
  84. <if test="confirmer != null and confirmer != ''">and CONFIRMER = #{confirmer}</if>
  85. </trim>
  86. </sql>
  87. <select id="get" resultMap="tacInspYearBatchGroupResultMap" parameterType="String" >
  88. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_GROUP where ID = #{id}
  89. </select>
  90. <select id="getBy" resultMap="tacInspYearBatchGroupResultMap">
  91. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_GROUP <include refid="page_where" />
  92. </select>
  93. <select id="findAll" resultMap="tacInspYearBatchGroupResultMap">
  94. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_GROUP
  95. </select>
  96. <sql id="choseSql">
  97. <choose>
  98. <when test="province !=null and province !=''">
  99. and t.province like concat(#{province},'%')
  100. </when>
  101. <otherwise>
  102. and t.province is null
  103. </otherwise>
  104. </choose>
  105. </sql>
  106. <select id="findList" resultMap="tacInspYearBatchGroupResultMap">
  107. select p.* from TAC_INSP_YEAR_BATCH_GROUP p ,TAC_INSP_YEAR_BATCH t where p.year_batch_id=t.id
  108. <include refid="choseSql"/>
  109. <if test="yearBatchId != null and yearBatchId != ''">and p.YEAR_BATCH_ID = #{yearBatchId}</if>
  110. <if test="year != null and year != ''">and p.YEAR = #{year}</if>
  111. <if test="batch != null and batch != ''">and p.BATCH = #{batch}</if>
  112. <if test="groupNm != null and groupNm != ''">and p.GROUP_NM = #{groupNm}</if>
  113. <if test="audContent != null and audContent != ''">and p.AUD_CONTENT = #{audContent}</if>
  114. <if test="tenet != null and tenet != ''">and p.TENET = #{tenet}</if>
  115. <if test="isAppraisal != null and isAppraisal != ''">and p.IS_APPRAISAL = #{isAppraisal}</if>
  116. <if test="audUnits != null and audUnits != ''">and p.AUD_UNITS = #{audUnits}</if>
  117. <if test="audCategory != null and audCategory != ''">and p.AUD_CATEGORY = #{audCategory}</if>
  118. <if test="remark != null and remark != ''">and p.REMARK = #{remark}</if>
  119. <if test="persId != null and persId != ''">and p.PERS_ID = #{persId}</if>
  120. <if test="inTm != null">and p.IN_TM = #{inTm}</if>
  121. <if test="upTm != null">and p.UP_TM = #{upTm}</if>
  122. <if test="dataStat != null and dataStat != ''">and p.DATA_STAT = #{dataStat}</if>
  123. <if test="pris != null and pris != ''">and p.PRIS = #{pris}</if>
  124. <if test="confirmer != null and confirmer != ''">and CONFIRMER = #{confirmer}</if>
  125. </select>
  126. <select id="selectCount" resultType="int" >
  127. select count(ID) from TAC_INSP_YEAR_BATCH_GROUP <include refid="page_where" />
  128. </select>
  129. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  130. insert into TAC_INSP_YEAR_BATCH_GROUP( <include refid="table_columns" /> )
  131. values ( <include refid="entity_properties" /> )
  132. </insert>
  133. <delete id="delete" parameterType="java.lang.String">
  134. delete from TAC_INSP_YEAR_BATCH_GROUP where ID = #{id}
  135. </delete>
  136. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  137. delete from TAC_INSP_YEAR_BATCH_GROUP <include refid="page_where" />
  138. </delete>
  139. <update id="deleteInFlag" parameterType="java.lang.String">
  140. update TAC_INSP_YEAR_BATCH_GROUP set flag_valid = 0 where ID = #{id}
  141. </update>
  142. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  143. update TAC_INSP_YEAR_BATCH_GROUP
  144. <trim prefix="set" suffixOverrides=",">
  145. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  146. <if test="year != null and year != ''">YEAR = #{year},</if>
  147. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  148. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  149. <if test="audContent != null and audContent != ''">AUD_CONTENT = #{audContent},</if>
  150. <if test="tenet != null and tenet != ''">TENET = #{tenet},</if>
  151. <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
  152. <if test="audUnits != null and audUnits != ''">AUD_UNITS = #{audUnits},</if>
  153. <if test="audCategory != null and audCategory != ''">AUD_CATEGORY = #{audCategory},</if>
  154. <if test="remark != null and remark != ''">REMARK = #{remark},</if>
  155. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  156. <if test="inTm != null">IN_TM = #{inTm},</if>
  157. <if test="upTm != null">UP_TM = #{upTm},</if>
  158. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  159. <if test="pris != null and pris != ''">PRIS = #{pris},</if>
  160. <if test="stTm != null">ST_TM = #{stTm},</if>
  161. <if test="enTm != null">EN_TM = #{enTm},</if>
  162. <if test="confirmer != null">CONFIRMER = #{confirmer},</if>
  163. </trim>
  164. <where>ID = #{id}</where>
  165. </update>
  166. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  167. update TAC_INSP_YEAR_BATCH_GROUP
  168. <trim prefix="set" suffixOverrides=",">
  169. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  170. <if test="year != null and year != ''">YEAR = #{year},</if>
  171. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  172. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  173. <if test="audContent != null and audContent != ''">AUD_CONTENT = #{audContent},</if>
  174. <if test="tenet != null and tenet != ''">TENET = #{tenet},</if>
  175. <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
  176. <if test="audUnits != null and audUnits != ''">AUD_UNITS = #{audUnits},</if>
  177. <if test="audCategory != null and audCategory != ''">AUD_CATEGORY = #{audCategory},</if>
  178. <if test="remark != null and remark != ''">REMARK = #{remark},</if>
  179. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  180. <if test="inTm != null">IN_TM = #{inTm},</if>
  181. <if test="upTm != null">UP_TM = #{upTm},</if>
  182. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  183. <if test="pris != null and pris != ''">PRIS = #{pris},</if>
  184. <if test="stTm != null">ST_TM = #{stTm},</if>
  185. <if test="enTm != null">EN_TM = #{enTm},</if>
  186. <if test="confirmer != null">CONFIRMER = #{confirmer},</if>
  187. </trim>
  188. <include refid="page_where" />
  189. </update>
  190. <!-- 其他自定义SQL -->
  191. <select id="getMaxGourpNum" resultType="java.lang.String" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam">
  192. select max(GROUP_NM) from TAC_INSP_YEAR_BATCH_GROUP where YEAR_BATCH_ID = #{yearBatchId}
  193. </select>
  194. <select id="getGroupListByPersId" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam">
  195. select t.*,'group' as flag from TAC_INSP_YEAR_BATCH_GROUP t
  196. where 1=1
  197. <if test="persId != null and persId != ''">
  198. REGEXP_LIKE(
  199. t.id,CONCAT('^(',
  200. ( case when(SELECT count(group_id) from TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId})>0 then
  201. (SELECT GROUP_CONCAT(group_id ORDER BY PERS_ID SEPARATOR '|' ) as
  202. id FROM TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId})
  203. else (select 'non' from dual) end)
  204. ,')'))
  205. </if>
  206. <if test="workerId != null and workerId != ''">
  207. AND t.id in (SELECT group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{workerId})
  208. </if>
  209. <if test="year != null">
  210. AND t.year = #{year}
  211. </if>
  212. <if test="batch != null">
  213. AND t.batch = #{batch}
  214. </if>
  215. <if test="yearBatchId != null and yearBatchId != ''">
  216. and t.year_batch_id = #{yearBatchId}
  217. </if>
  218. </select>
  219. <select id="getGroupListApp" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam">
  220. select t.* from TAC_INSP_YEAR_BATCH_GROUP t
  221. where 1=1
  222. <if test="persId != null and persId != ''">
  223. and t.id in (
  224. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID in (select t.id from TAC_WORKER_B t where t.login_id = #{persId}
  225. <include refid="choseSql"/>
  226. )
  227. )
  228. </if>
  229. <if test="loginId != null and loginId != ''">
  230. and t.id in (
  231. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID in (select t.id from TAC_WORKER_B t where t.login_id = #{loginId}
  232. <include refid="choseSql"/>
  233. )
  234. )
  235. </if>
  236. <if test="year != null and year != ''">
  237. and t.year = #{year}
  238. </if>
  239. <if test="batch != null and batch != ''">
  240. and t.batch = #{batch}
  241. </if>
  242. order by in_tm DESC
  243. </select>
  244. <update id="updateByBatchId" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  245. update TAC_INSP_YEAR_BATCH_GROUP t
  246. set t.st_tm = #{stTm},t.en_tm = #{enTm} where t.year_batch_id = #{yearBatchId}
  247. </update>
  248. <select id="getCurrentGroupList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam">
  249. select t.* from TAC_INSP_YEAR_BATCH_GROUP t left join TAC_INSP_YEAR_BATCH b on t.YEAR_BATCH_ID = b.id
  250. where 1=1
  251. <if test="useCurrTm != null and useCurrTm != ''">
  252. and t.st_tm &lt; sysdate() and t.en_tm &gt; sysdate()
  253. </if>
  254. <if test="useCurrTm == null">
  255. and t.en_tm &lt; sysdate()
  256. </if>
  257. <if test="persId != null and persId != ''">
  258. and t.id in (
  259. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID = (select b.id from TAC_WORKER_B b where b.login_id = #{persId})
  260. )
  261. </if>
  262. <if test="year != null">
  263. and t.year = #{year}
  264. </if>
  265. <choose>
  266. <when test="province !=null and province !=''">
  267. and b.province=#{province}
  268. </when>
  269. <otherwise>
  270. and b.province is null
  271. </otherwise>
  272. </choose>
  273. order by t.batch DESC
  274. </select>
  275. <select id="getGradeGroupList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup">
  276. select
  277. t.ID,
  278. t.YEAR_BATCH_ID,
  279. t.YEAR,
  280. t.BATCH,
  281. t.GROUP_NM,
  282. t.AUD_CONTENT,
  283. t.TENET,
  284. t.IS_APPRAISAL,
  285. t.AUD_UNITS,
  286. t.AUD_CATEGORY,
  287. t.REMARK,
  288. t.PERS_ID,
  289. t.IN_TM,
  290. t.UP_TM,
  291. t.DATA_STAT,
  292. t.PRIS,
  293. t.ST_TM,
  294. t.EN_TM,
  295. b.PERS_ID AS TAC_PERS_ID
  296. from TAC_INSP_YEAR_BATCH_GROUP t
  297. inner join (
  298. select distinct group_id,pers_id from TAC_INSP_YEAR_BATCH_GROUP_PERS
  299. where pers_id = (select id from TAC_WORKER_B where login_id = #{persId}) and group_id is not null
  300. ) b on t.id = b.group_id
  301. <where>
  302. <if test="year != null">
  303. t.year = #{year}
  304. </if>
  305. </where>
  306. </select>
  307. </mapper>