TacInspYearBatchAreaDao.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.TacInspYearBatchAreaDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea" id="tacInspYearBatchAreaResultMap">
  5. <result property="inTm" column="IN_TM"/>
  6. <result property="upTm" column="UP_TM"/>
  7. <result property="dataStat" column="DATA_STAT"/>
  8. <result property="id" column="ID"/>
  9. <result property="yearBatchId" column="YEAR_BATCH_ID"/>
  10. <result property="year" column="YEAR"/>
  11. <result property="batch" column="BATCH"/>
  12. <result property="groupId" column="GROUP_ID"/>
  13. <result property="groupNm" column="GROUP_NM"/>
  14. <result property="adCode" column="AD_CODE"/>
  15. <result property="adName" column="AD_NAME"/>
  16. <result property="persId" column="PERS_ID"/>
  17. <result property="province" column="PROVINCE"/>
  18. </resultMap>
  19. <sql id="table_columns">
  20. IN_TM,
  21. UP_TM,
  22. DATA_STAT,
  23. ID,
  24. YEAR_BATCH_ID,
  25. YEAR,
  26. BATCH,
  27. GROUP_ID,
  28. GROUP_NM,
  29. AD_CODE,
  30. AD_NAME,
  31. PERS_ID,PROVINCE
  32. </sql>
  33. <sql id="entity_properties">
  34. #{inTm},
  35. #{upTm},
  36. #{dataStat},
  37. #{id},
  38. #{yearBatchId},
  39. #{year},
  40. #{batch},
  41. #{groupId},
  42. #{groupNm},
  43. #{adCode},
  44. #{adName},
  45. #{persId},#{province}
  46. </sql>
  47. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  48. <sql id="page_where">
  49. <trim prefix="where" prefixOverrides="and | or ">
  50. <if test="upTm != null">and UP_TM = #{upTm}</if>
  51. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  52. <if test="id != null and id != ''">and ID = #{id}</if>
  53. <if test="yearBatchId != null and yearBatchId != ''">and YEAR_BATCH_ID = #{yearBatchId}</if>
  54. <if test="year != null and year != ''">and YEAR = #{year}</if>
  55. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  56. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  57. <if test="groupNm != null and groupNm != ''">and GROUP_NM = #{groupNm}</if>
  58. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  59. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  60. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  61. <include refid="choseSql"/>
  62. </trim>
  63. </sql>
  64. <sql id="choseSql">
  65. <choose>
  66. <when test="province !=null and province !=''">
  67. AND t.province like concat(#{province},'%')
  68. </when>
  69. <otherwise>
  70. AND t.province is null
  71. </otherwise>
  72. </choose>
  73. </sql>
  74. <select id="get" resultMap="tacInspYearBatchAreaResultMap" parameterType="String" >
  75. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_AREA where ID = #{id}
  76. </select>
  77. <select id="getBy" resultMap="tacInspYearBatchAreaResultMap">
  78. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_AREA t <include refid="page_where" />
  79. </select>
  80. <select id="findAll" resultMap="tacInspYearBatchAreaResultMap">
  81. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_AREA
  82. </select>
  83. <select id="findList" resultMap="tacInspYearBatchAreaResultMap">
  84. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_AREA t <include refid="page_where" />
  85. </select>
  86. <select id="selectCount" resultType="int" >
  87. select count(ID) from TAC_INSP_YEAR_BATCH_AREA t <include refid="page_where" />
  88. </select>
  89. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  90. insert into TAC_INSP_YEAR_BATCH_AREA( <include refid="table_columns" /> )
  91. values ( <include refid="entity_properties" /> )
  92. </insert>
  93. <delete id="delete" parameterType="java.lang.String">
  94. delete from TAC_INSP_YEAR_BATCH_AREA where ID = #{id}
  95. </delete>
  96. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  97. delete from TAC_INSP_YEAR_BATCH_AREA t <include refid="page_where" />
  98. </delete>
  99. <update id="deleteInFlag" parameterType="java.lang.String">
  100. update TAC_INSP_YEAR_BATCH_AREA set flag_valid = 0 where ID = #{id}
  101. </update>
  102. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  103. update TAC_INSP_YEAR_BATCH_AREA
  104. <trim prefix="set" suffixOverrides=",">
  105. <if test="upTm != null">UP_TM = #{upTm},</if>
  106. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  107. <if test="id != null and id != ''">ID = #{id},</if>
  108. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  109. <if test="year != null and year != ''">YEAR = #{year},</if>
  110. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  111. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  112. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  113. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  114. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  115. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  116. <if test="province != null ">PROVINCE = #{province},</if>
  117. </trim>
  118. <where>ID = #{id}</where>
  119. </update>
  120. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  121. update TAC_INSP_YEAR_BATCH_AREA
  122. <trim prefix="set" suffixOverrides=",">
  123. <if test="upTm != null">UP_TM = #{upTm},</if>
  124. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  125. <if test="id != null and id != ''">ID = #{id},</if>
  126. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  127. <if test="year != null and year != ''">YEAR = #{year},</if>
  128. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  129. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  130. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  131. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  132. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  133. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  134. <if test="province != null ">PROVINCE = #{province},</if>
  135. </trim>
  136. <include refid="page_where" />
  137. </update>
  138. <!-- 其他自定义SQL -->
  139. <select id="getAreaListById" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchAreaParam" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  140. select * from TAC_INSP_YEAR_BATCH_AREA t
  141. where t.group_id in (select group_id from tac_insp_year_batch_group_pers p,tac_insp_year_batch h where p.year_batch_id=h.id and h.data_stat='0'
  142. and p.pers_id = #{workerbId}
  143. <if test="years != null and years != ''">
  144. and p.year in (${years})
  145. </if>
  146. <include refid="choseSql"/>
  147. <if test="year != null">
  148. and t.year = #{year}
  149. </if>
  150. <if test="batch != null">
  151. and t.batch = #{batch}
  152. </if>
  153. <if test="batchs != null and batchs != ''">
  154. and p.batch in (${batchs})
  155. </if>
  156. )
  157. </select>
  158. <!-- 其他自定义SQL -->
  159. <select id="areasListByBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchAreaParam" resultType="java.util.HashMap">
  160. select area.BATCH as "batch", listagg(area.AD_NAME, ',') as "adName"
  161. from (select distinct t.BATCH, t.AD_NAME
  162. from TAC_INSP_YEAR_BATCH_AREA t
  163. where t.year_batch_id in (SELECT id FROM TAC_INSP_YEAR_BATCH)
  164. <include refid="choseSql"/>
  165. <if test="year != null">
  166. and t.year = #{year}
  167. </if>)area
  168. group by area.BATCH,area.AD_NAME
  169. </select>
  170. <select id="countAdcodeAuditByYear" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchAreaParam">
  171. select count(*)as count,a.ad_code as code,a.ad_name as name from (
  172. select t.* from TAC_INSP_YEAR_BATCH_AREA t where t.year = #{year}
  173. <if test="persId != null and persId != ''">
  174. and t.group_id in (select group_id from tac_insp_year_batch_group_pers p where p.pers_id in (select id from tac_worker_b where login_id = #{persId}))
  175. </if>
  176. <if test="batch != null">
  177. and t.batch = #{batch}
  178. </if>
  179. <include refid="choseSql"/>
  180. ) a group by a.ad_code,a.ad_name order by a.ad_code
  181. </select>
  182. <select id="getAdNameList" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchAreaParam">
  183. SELECT distinct t.Ad_name as name,'1' as value,t.year,t.batch from TAC_INSP_YEAR_BATCH_AREA t where t.group_id in (${groupId})
  184. <include refid="choseSql"/>
  185. </select>
  186. <select id="listByMap" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchArea">
  187. SELECT DISTINCT Y.*,O.OJB_NM
  188. FROM TAC_INSP_YEAR_BATCH_AREA Y
  189. JOIN TAC_INSP_YEAR_BATCH_OBJ O ON Y.GROUP_ID = O.GROUP_ID
  190. <where>
  191. <if test="province != null and province != ''">
  192. and Y.PROVINCE = #{province}
  193. </if>
  194. <if test="year != null and year != ''">
  195. and Y.YEAR like '%' || #{year} || '%'
  196. </if>
  197. <if test="batch != null and batch != ''">
  198. and Y.BATCH like '%' || #{batch} || '%'
  199. </if>
  200. <if test="groupNm != null and groupNm != ''">
  201. and Y.GROUP_NM like '%' || #{groupNm} || '%'
  202. </if>
  203. <if test="adName != null and adName != ''">
  204. and Y.AD_NAME like '%' || #{adName} || '%'
  205. </if>
  206. <if test="inTm != null and inTm != ''">
  207. and Y.IN_TM like '%' || #{inTm} || '%'
  208. </if>
  209. <if test="upTm != null and upTm != ''">
  210. and Y.UP_TM like '%' || #{upTm} || '%'
  211. </if>
  212. <if test="ojbNm != null and ojbNm != ''">
  213. and O.OJB_NM like '%' || #{ojbNm} || '%'
  214. </if>
  215. </where>
  216. </select>
  217. </mapper>