TacExprRcmmRcrdDao.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.TacExprRcmmRcrdDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd" id="tacExprRcmmRcrdResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="exprRcmmId" column="EXPR_RCMM_ID"/>
  7. <result property="state" column="STATE"/>
  8. <result property="note" column="NOTE"/>
  9. <result property="isSm" column="IS_SM"/>
  10. <result property="isMsg" column="IS_MSG"/>
  11. <result property="persId" column="PERS_ID"/>
  12. <result property="intm" column="INTM"/>
  13. <result property="uptm" column="UPTM"/>
  14. <result property="dataStat" column="DATA_STAT"/>
  15. </resultMap>
  16. <sql id="table_columns">
  17. ID,
  18. EXPR_RCMM_ID,
  19. STATE,
  20. NOTE,
  21. IS_SM,
  22. IS_MSG,
  23. PERS_ID,
  24. INTM,
  25. UPTM,
  26. DATA_STAT
  27. </sql>
  28. <sql id="entity_properties">
  29. #{id},
  30. #{exprRcmmId},
  31. #{state},
  32. #{note},
  33. #{isSm},
  34. #{isMsg},
  35. #{persId},
  36. #{intm},
  37. #{uptm},
  38. #{dataStat}
  39. </sql>
  40. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  41. <sql id="page_where">
  42. <trim prefix="where" prefixOverrides="and | or ">
  43. <if test="exprRcmmId != null and exprRcmmId != ''">and EXPR_RCMM_ID = #{exprRcmmId}</if>
  44. <if test="state != null and state != ''">and STATE = #{state}</if>
  45. <if test="note != null and note != ''">and NOTE = #{note}</if>
  46. <if test="isSm != null and isSm != ''">and IS_SM = #{isSm}</if>
  47. <if test="isMsg != null and isMsg != ''">and IS_MSG = #{isMsg}</if>
  48. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  49. <if test="intm != null">and INTM = #{intm}</if>
  50. <if test="uptm != null">and UPTM = #{uptm}</if>
  51. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  52. </trim>
  53. </sql>
  54. <select id="get" resultMap="tacExprRcmmRcrdResultMap" parameterType="String" >
  55. select <include refid="table_columns" /> from TAC_EXPR_RCMM_RCRD where ID = #{id}
  56. </select>
  57. <select id="getBy" resultMap="tacExprRcmmRcrdResultMap">
  58. select <include refid="table_columns" /> from TAC_EXPR_RCMM_RCRD <include refid="page_where" />
  59. </select>
  60. <select id="findAll" resultMap="tacExprRcmmRcrdResultMap">
  61. select <include refid="table_columns" /> from TAC_EXPR_RCMM_RCRD
  62. </select>
  63. <select id="findList" resultMap="tacExprRcmmRcrdResultMap">
  64. select <include refid="table_columns" /> from TAC_EXPR_RCMM_RCRD <include refid="page_where" />
  65. </select>
  66. <select id="selectCount" resultType="int" >
  67. select count(ID) from TAC_EXPR_RCMM_RCRD <include refid="page_where" />
  68. </select>
  69. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  70. insert into TAC_EXPR_RCMM_RCRD( <include refid="table_columns" /> )
  71. values ( <include refid="entity_properties" /> )
  72. </insert>
  73. <delete id="delete" parameterType="java.lang.String">
  74. delete from TAC_EXPR_RCMM_RCRD where ID = #{id}
  75. </delete>
  76. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  77. delete from TAC_EXPR_RCMM_RCRD <include refid="page_where" />
  78. </delete>
  79. <update id="deleteInFlag" parameterType="java.lang.String">
  80. update TAC_EXPR_RCMM_RCRD set flag_valid = 0 where ID = #{id}
  81. </update>
  82. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  83. update TAC_EXPR_RCMM_RCRD
  84. <trim prefix="set" suffixOverrides=",">
  85. <if test="exprRcmmId != null and exprRcmmId != ''">EXPR_RCMM_ID = #{exprRcmmId},</if>
  86. <if test="state != null and state != ''">STATE = #{state},</if>
  87. <if test="note != null and note != ''">NOTE = #{note},</if>
  88. <if test="isSm != null and isSm != ''">IS_SM = #{isSm},</if>
  89. <if test="isMsg != null and isMsg != ''">IS_MSG = #{isMsg},</if>
  90. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  91. <if test="intm != null">INTM = #{intm},</if>
  92. <if test="uptm != null">UPTM = #{uptm},</if>
  93. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  94. </trim>
  95. <where>ID = #{id}</where>
  96. </update>
  97. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  98. update TAC_EXPR_RCMM_RCRD
  99. <trim prefix="set" suffixOverrides=",">
  100. <if test="exprRcmmId != null and exprRcmmId != ''">EXPR_RCMM_ID = #{exprRcmmId},</if>
  101. <if test="state != null and state != ''">STATE = #{state},</if>
  102. <if test="note != null and note != ''">NOTE = #{note},</if>
  103. <if test="isSm != null and isSm != ''">IS_SM = #{isSm},</if>
  104. <if test="isMsg != null and isMsg != ''">IS_MSG = #{isMsg},</if>
  105. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  106. <if test="intm != null">INTM = #{intm},</if>
  107. <if test="uptm != null">UPTM = #{uptm},</if>
  108. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  109. </trim>
  110. <include refid="page_where" />
  111. </update>
  112. <!-- 其他自定义SQL -->
  113. <select id="getRcrdDtoList" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam" resultType="cn.com.goldenwater.dcproj.dto.TacExprRcmmRcrdDto">
  114. SELECT
  115. DISTINCT DATE_FORMAT(INTM, '%Y') as year,DATE_FORMAT(INTM, '%Y-%m-%d %H:%i') as exprTm
  116. FROM TAC_EXPR_RCMM_RCRD
  117. where 1=1
  118. <if test="year != null and year != ''">
  119. AND DATE_FORMAT(INTM, '%Y') = #{year}
  120. </if>
  121. </select>
  122. <delete id="cleanRcrdByExprTime" parameterType="cn.com.goldenwater.dcproj.dto.TacExprRcmmRcrdDto">
  123. delete from TAC_EXPR_RCMM_RCRD where date_format(INTM, '%Y-%m-%d %H:%i') = #{exprTm}
  124. </delete>
  125. <update id="updateRcrdByRcmmId" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam">
  126. update TAC_EXPR_RCMM_RCRD
  127. set
  128. state = #{state}
  129. ,note = #{note}
  130. where
  131. EXPR_RCMM_ID = #{exprRcmmId}
  132. and state is null
  133. </update>
  134. <select id="countRcrdByAdCode" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto">
  135. select
  136. ba.ad_code as code,ba.ad_name as name,b.role_type,
  137. (case when b.count is null then 0 else b.count end) as count
  138. from att_ad_x_base ba
  139. left join
  140. (
  141. select count(*) as count,a.role_type,a.code
  142. from
  143. (
  144. select substr(r.work_ad,1,2) as code,r.role_type,t.expr_rcmm_id
  145. from TAC_EXPR_RCMM_RCRD t
  146. left join TAC_EXPR_RCMM r on t.expr_rcmm_id = r.id
  147. where r.id is not null
  148. <if test="year != null and year != ''">
  149. AND DATE_FORMAT(t.INTM, '%Y') = #{year}
  150. </if>
  151. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  152. AND t.INTM &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d') AND t.INTM &lt; STR_TO_DATE(#{entm},'%Y-%m-%d')
  153. </if>
  154. ) a group by a.code,a.role_type
  155. ) b on CONCAT(SUBSTR(b.code, 1, 2), '0000000000') = ba.AD_CODE
  156. where ba.ad_grad = '2' order by ba.ad_code
  157. </select>
  158. <select id="getRcmmRcrdList" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam" resultType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  159. SELECT
  160. t.ID,
  161. t.EXPR_RCMM_ID,
  162. t.STATE,
  163. t.NOTE,
  164. t.IS_SM,
  165. t.IS_MSG,
  166. t.PERS_ID,
  167. t.INTM,
  168. t.UPTM,
  169. t.DATA_STAT,p.PERS_NAME
  170. FROM TAC_EXPR_RCMM_RCRD t
  171. LEFT JOIN BIS_INSP_ALL_RLATION_PERS p on t.pers_id = p.guid
  172. where p.guid is not null
  173. <if test="exprRcmmId != null and exprRcmmId != ''">
  174. AND t.EXPR_RCMM_ID = #{exprRcmmId}
  175. </if>
  176. <if test="state != null and state != ''">
  177. AND t.STATE = #{state}
  178. </if>
  179. </select>
  180. </mapper>