TacPblmRectDao.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.TacPblmRectDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacPblmRect" id="tacPblmRectResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="year" column="YEAR"/>
  7. <result property="batch" column="BATCH"/>
  8. <result property="title" column="TITLE"/>
  9. <result property="nub" column="NUB"/>
  10. <result property="explain" column="EXPLAIN"/>
  11. <result property="printTm" column="PRINT_TM"/>
  12. <result property="closeTm" column="CLOSE_TM"/>
  13. <result property="sndOrgSize" column="SND_ORG_SIZE"/>
  14. <result property="prjctSize" column="PRJCT_SIZE"/>
  15. <result property="pblmSize" column="PBLM_SIZE"/>
  16. <result property="persId" column="PERS_ID"/>
  17. <result property="persName" column="PERS_NAME"/>
  18. <result property="intm" column="INTM"/>
  19. <result property="uptm" column="UPTM"/>
  20. <result property="dataStat" column="DATA_STAT"/>
  21. <result property="fileId" column="FILE_ID"/>
  22. <result property="fileName" column="FILE_NAME"/>
  23. <result property="filePath" column="FILE_PATH"/>
  24. <result property="sendAll" column="SEND_ALL"/>
  25. </resultMap>
  26. <sql id="table_columns">
  27. ID,
  28. `YEAR`,
  29. BATCH,
  30. TITLE,
  31. NUB,
  32. `EXPLAIN`,
  33. PRINT_TM,
  34. CLOSE_TM,
  35. SND_ORG_SIZE,
  36. PRJCT_SIZE,
  37. PBLM_SIZE,
  38. PERS_ID,
  39. PERS_NAME,
  40. INTM,
  41. UPTM,
  42. DATA_STAT
  43. </sql>
  44. <sql id="entity_properties">
  45. #{id},
  46. #{year},
  47. #{batch},
  48. #{title},
  49. #{nub},
  50. #{explain},
  51. #{printTm},
  52. #{closeTm},
  53. #{sndOrgSize},
  54. #{prjctSize},
  55. #{pblmSize},
  56. #{persId},
  57. #{persName},
  58. #{intm},
  59. #{uptm},
  60. #{dataStat}
  61. </sql>
  62. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  63. <sql id="page_where">
  64. <trim prefix="where" prefixOverrides="and | or ">
  65. <if test="year != null and year != ''">and `YEAR` = #{year}</if>
  66. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  67. <if test="title != null and title != ''">and TITLE = #{title}</if>
  68. <if test="nub != null and nub != ''">and NUB = #{nub}</if>
  69. <if test="explain != null and explain != ''">and `EXPLAIN` = #{explain}</if>
  70. <if test="printTm != null">and PRINT_TM = #{printTm}</if>
  71. <if test="closeTm != null">and CLOSE_TM = #{closeTm}</if>
  72. <if test="sndOrgSize != null and sndOrgSize != ''">and SND_ORG_SIZE = #{sndOrgSize}</if>
  73. <if test="prjctSize != null and prjctSize != ''">and PRJCT_SIZE = #{prjctSize}</if>
  74. <if test="pblmSize != null and pblmSize != ''">and PBLM_SIZE = #{pblmSize}</if>
  75. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  76. <if test="persName != null and persName != ''">and PERS_NAME = #{persName}</if>
  77. <if test="intm != null">and INTM = #{intm}</if>
  78. <if test="uptm != null">and UPTM = #{uptm}</if>
  79. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  80. and DATA_STAT='0'
  81. </trim>
  82. </sql>
  83. <select id="get" resultMap="tacPblmRectResultMap" parameterType="String">
  84. select A.*,B.FILE_NAME,B.ID FILE_ID,B.FILE_PATH,
  85. (case when (select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id)=0 then '0' when (select count(*) from TAC_PBLM_RECT_ORG c where c.state in ('1','2') and c.rect_id=a.id)=(select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id) then '1' else '0' end)SEND_ALL
  86. from tac_pblm_rect A LEFT JOIN GW_COM_FILE B ON A.ID=B.BIZ_ID where A.ID = #{id}
  87. </select>
  88. <select id="getBy" resultMap="tacPblmRectResultMap">
  89. select A.*,B.FILE_NAME,B.ID FILE_ID,B.FILE_PATH,
  90. (case when (select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id)=0 then '0' when (select count(*) from TAC_PBLM_RECT_ORG c where c.state in ('1','2') and c.rect_id=a.id)=(select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id) then '1' else '0' end)SEND_ALL
  91. from tac_pblm_rect A LEFT JOIN GW_COM_FILE B ON A.ID=B.BIZ_ID
  92. <include refid="page_where"/>
  93. </select>
  94. <select id="findAll" resultMap="tacPblmRectResultMap">
  95. select
  96. <include refid="table_columns"/>
  97. from TAC_PBLM_RECT
  98. </select>
  99. <select id="findList" resultMap="tacPblmRectResultMap">
  100. select A.*,B.FILE_NAME,B.ID FILE_ID,B.FILE_PATH,
  101. (case when (select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id)=0 then '0' when (select count(*) from TAC_PBLM_RECT_ORG c where c.state in ('1','2') and c.rect_id=a.id)=(select count(*) from TAC_PBLM_RECT_ORG d where d.rect_id=a.id) then '1' else '0' end)SEND_ALL
  102. from tac_pblm_rect A LEFT JOIN GW_COM_FILE B ON A.ID=B.BIZ_ID
  103. <include refid="page_where"/>
  104. ORDER BY YEAR,BATCH
  105. </select>
  106. <select id="selectCount" resultType="int">
  107. select count(ID) from TAC_PBLM_RECT
  108. <include refid="page_where"/>
  109. </select>
  110. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacPblmRect">
  111. insert into TAC_PBLM_RECT(
  112. <include refid="table_columns"/>
  113. )
  114. values (
  115. <include refid="entity_properties"/>
  116. )
  117. </insert>
  118. <delete id="delete" parameterType="java.lang.String">
  119. update TAC_PBLM_RECT set DATA_STAT='9' where ID = #{id}
  120. </delete>
  121. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacPblmRect">
  122. update TAC_PBLM_RECT set DATA_STAT='9'
  123. <include refid="page_where"/>
  124. </delete>
  125. <update id="deleteInFlag" parameterType="java.lang.String">
  126. update TAC_PBLM_RECT set DATA_STAT='9' set flag_valid = 0 where ID = #{id}
  127. </update>
  128. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacPblmRect">
  129. update TAC_PBLM_RECT
  130. <trim prefix="set" suffixOverrides=",">
  131. <if test="year != null and year != ''">YEAR = #{year},</if>
  132. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  133. <if test="title != null and title != ''">TITLE = #{title},</if>
  134. <if test="nub != null and nub != ''">NUB = #{nub},</if>
  135. <if test="explain != null and explain != ''">`EXPLAIN` = #{explain},</if>
  136. <if test="printTm != null">PRINT_TM = #{printTm},</if>
  137. <if test="closeTm != null">CLOSE_TM = #{closeTm},</if>
  138. <if test="sndOrgSize != null and sndOrgSize != ''">SND_ORG_SIZE = #{sndOrgSize},</if>
  139. <if test="prjctSize != null and prjctSize != ''">PRJCT_SIZE = #{prjctSize},</if>
  140. <if test="pblmSize != null and pblmSize != ''">PBLM_SIZE = #{pblmSize},</if>
  141. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  142. <if test="persName != null and persName != ''">PERS_NAME = #{persName},</if>
  143. <if test="intm != null">INTM = #{intm},</if>
  144. <if test="uptm != null">UPTM = #{uptm},</if>
  145. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  146. </trim>
  147. <where>ID = #{id}</where>
  148. </update>
  149. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacPblmRect">
  150. update TAC_PBLM_RECT
  151. <trim prefix="set" suffixOverrides=",">
  152. <if test="year != null and year != ''">YEAR = #{year},</if>
  153. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  154. <if test="title != null and title != ''">TITLE = #{title},</if>
  155. <if test="nub != null and nub != ''">NUB = #{nub},</if>
  156. <if test="explain != null and explain != ''">`EXPLAIN` = #{explain},</if>
  157. <if test="printTm != null">PRINT_TM = #{printTm},</if>
  158. <if test="closeTm != null">CLOSE_TM = #{closeTm},</if>
  159. <if test="sndOrgSize != null and sndOrgSize != ''">SND_ORG_SIZE = #{sndOrgSize},</if>
  160. <if test="prjctSize != null and prjctSize != ''">PRJCT_SIZE = #{prjctSize},</if>
  161. <if test="pblmSize != null and pblmSize != ''">PBLM_SIZE = #{pblmSize},</if>
  162. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  163. <if test="persName != null and persName != ''">PERS_NAME = #{persName},</if>
  164. <if test="intm != null">INTM = #{intm},</if>
  165. <if test="uptm != null">UPTM = #{uptm},</if>
  166. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  167. </trim>
  168. <include refid="page_where"/>
  169. </update>
  170. <!-- 其他自定义SQL -->
  171. <select id="getYear" resultType="cn.com.goldenwater.dcproj.model.TacInspYear">
  172. SELECT DISTINCT YEAR,YEAR ID FROM TAC_INSP_YEAR_BATCH WHERE ID IN ( SELECT A.year_batch_id FROM
  173. TAC_INSP_YEAR_BATCH_GROUP_PERS A JOIN
  174. TAC_INSP_YEAR_BATCH_AREA B ON A.GROUP_ID=B.GROUP_ID WHERE 1=1
  175. <if test="persId != null and persId != ''">
  176. and A.PERS_ID=#{persId}
  177. </if>
  178. ) ORDER BY YEAR
  179. </select>
  180. <select id="getBatchByYearPersId" resultType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  181. SELECT
  182. batch,
  183. max(id) id
  184. FROM
  185. TAC_INSP_YEAR_BATCH
  186. WHERE
  187. year = #{year}
  188. AND PROVINCE IS NOT NULL
  189. group by BATCH
  190. ORDER BY BATCH
  191. </select>
  192. </mapper>