TacExprRcmmRcrdDao.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 DISTINCT TO_CHAR(INTM, 'yyyy') as year,TO_CHAR(INTM, 'yyyy-MM-dd HH24:mi') as exprTm FROM TAC_EXPR_RCMM_RCRD
  115. where 1=1
  116. <if test="year != null and year != ''">
  117. AND TO_CHAR(INTM, 'yyyy') = #{year}
  118. </if>
  119. </select>
  120. <delete id="cleanRcrdByExprTime" parameterType="cn.com.goldenwater.dcproj.dto.TacExprRcmmRcrdDto">
  121. delete from TAC_EXPR_RCMM_RCRD where to_char(INTM, 'yyyy-MM-dd HH24:mm') = #{exprTm}
  122. </delete>
  123. <update id="updateRcrdByRcmmId" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam">
  124. update TAC_EXPR_RCMM_RCRD set state = #{state}
  125. ,note = #{note}
  126. where EXPR_RCMM_ID = #{exprRcmmId} and state is null
  127. </update>
  128. <select id="countRcrdByAdCode" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto">
  129. select ba.ad_code as code,ba.ad_name as name,b.role_type,(case when b.count is null then 0 else b.count end)as count from att_ad_x_base ba left join (
  130. select count(*) as count,a.role_type,a.code from (
  131. select substr(r.work_ad,1,2) as code,r.role_type,t.expr_rcmm_id from TAC_EXPR_RCMM_RCRD t left join TAC_EXPR_RCMM r on t.expr_rcmm_id = r.id
  132. where r.id is not null
  133. <if test="year != null and year != ''">
  134. AND TO_CHAR(t.INTM, 'yyyy') = #{year}
  135. </if>
  136. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  137. AND t.INTM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD') AND t.INTM &lt; TO_DATE(#{entm},'YYYY-MM-DD')+1
  138. </if>
  139. ) a group by a.code,a.role_type
  140. ) b on CONCAT(SUBSTR(b.code, 0, 2), '0000000000') = ba.AD_CODE
  141. where ba.ad_grad = '2' order by ba.ad_code
  142. </select>
  143. <select id="getRcmmRcrdList" parameterType="cn.com.goldenwater.dcproj.param.TacExprRcmmRcrdParam" resultType="cn.com.goldenwater.dcproj.model.TacExprRcmmRcrd">
  144. SELECT t.ID,
  145. t.EXPR_RCMM_ID,
  146. t.STATE,
  147. t.NOTE,
  148. t.IS_SM,
  149. t.IS_MSG,
  150. t.PERS_ID,
  151. t.INTM,
  152. t.UPTM,
  153. t.DATA_STAT,p.PERS_NAME FROM TAC_EXPR_RCMM_RCRD t LEFT JOIN BIS_INSP_ALL_RLATION_PERS p on t.pers_id = p.guid where p.guid is not null
  154. <if test="exprRcmmId != null and exprRcmmId != ''">
  155. AND t.EXPR_RCMM_ID = #{exprRcmmId}
  156. </if>
  157. <if test="state != null and state != ''">
  158. AND t.STATE = #{state}
  159. </if>
  160. </select>
  161. </mapper>