a2ea600d33d8674e4d54ea2f99eae7bff03ccf8d.svn-base 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.BisInspPlanDtlAddvcdDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd" id="bisInspPlanDtlAddvcdResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="planDtlId" column="PLAN_DTL_ID"/>
  7. <result property="adCode" column="AD_CODE"/>
  8. <result property="adName" column="AD_NAME"/>
  9. <result property="adGrad" column="AD_GRAD"/>
  10. <result property="persId" column="PERS_ID"/>
  11. <result property="intm" column="INTM"/>
  12. <result property="uptm" column="UPTM"/>
  13. <result property="dataStat" column="DATA_STAT"/>
  14. </resultMap>
  15. <sql id="table_columns">
  16. ID,
  17. PLAN_DTL_ID,
  18. AD_CODE,
  19. AD_NAME,
  20. AD_GRAD,
  21. PERS_ID,
  22. INTM,
  23. UPTM,
  24. DATA_STAT
  25. </sql>
  26. <sql id="entity_properties">
  27. #{id},
  28. #{planDtlId},
  29. #{adCode},
  30. #{adName},
  31. #{adGrad},
  32. #{persId},
  33. #{intm},
  34. #{uptm},
  35. #{dataStat}
  36. </sql>
  37. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  38. <sql id="page_where">
  39. <trim prefix="where" prefixOverrides="and | or ">
  40. <if test="planDtlId != null and planDtlId != ''">and PLAN_DTL_ID = #{planDtlId}</if>
  41. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  42. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  43. <if test="adGrad != null and adGrad != ''">and AD_GRAD = #{adGrad}</if>
  44. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  45. <if test="intm != null">and INTM = #{intm}</if>
  46. <if test="uptm != null">and UPTM = #{uptm}</if>
  47. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  48. and DATA_STAT='0'
  49. </trim>
  50. </sql>
  51. <select id="get" resultMap="bisInspPlanDtlAddvcdResultMap" parameterType="String" >
  52. select <include refid="table_columns" /> from BIS_INSP_PLAN_DTL_ADDVCD where ID = #{id}
  53. </select>
  54. <select id="getBy" resultMap="bisInspPlanDtlAddvcdResultMap">
  55. select <include refid="table_columns" /> from BIS_INSP_PLAN_DTL_ADDVCD <include refid="page_where" />
  56. </select>
  57. <select id="findAll" resultMap="bisInspPlanDtlAddvcdResultMap">
  58. select <include refid="table_columns" /> from BIS_INSP_PLAN_DTL_ADDVCD
  59. </select>
  60. <select id="findList" resultMap="bisInspPlanDtlAddvcdResultMap">
  61. select <include refid="table_columns" /> from BIS_INSP_PLAN_DTL_ADDVCD <include refid="page_where" />
  62. </select>
  63. <select id="selectCount" resultType="int" >
  64. select count(ID) from BIS_INSP_PLAN_DTL_ADDVCD <include refid="page_where" />
  65. </select>
  66. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd">
  67. insert into BIS_INSP_PLAN_DTL_ADDVCD( <include refid="table_columns" /> )
  68. values ( <include refid="entity_properties" /> )
  69. </insert>
  70. <delete id="delete" parameterType="java.lang.String">
  71. update BIS_INSP_PLAN_DTL_ADDVCD set DATA_STAT='9' where ID = #{id}
  72. </delete>
  73. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd">
  74. update BIS_INSP_PLAN_DTL_ADDVCD set DATA_STAT='9' <include refid="page_where" />
  75. </delete>
  76. <update id="deleteInFlag" parameterType="java.lang.String">
  77. update BIS_INSP_PLAN_DTL_ADDVCD set DATA_STAT = '9' where ID = #{id}
  78. </update>
  79. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd">
  80. update BIS_INSP_PLAN_DTL_ADDVCD
  81. <trim prefix="set" suffixOverrides=",">
  82. <if test="planDtlId != null and planDtlId != ''">PLAN_DTL_ID = #{planDtlId},</if>
  83. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  84. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  85. <if test="adGrad != null and adGrad != ''">AD_GRAD = #{adGrad},</if>
  86. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  87. <if test="intm != null">INTM = #{intm},</if>
  88. <if test="uptm != null">UPTM = #{uptm},</if>
  89. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  90. </trim>
  91. <where>ID = #{id}</where>
  92. </update>
  93. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd">
  94. update BIS_INSP_PLAN_DTL_ADDVCD
  95. <trim prefix="set" suffixOverrides=",">
  96. <if test="planDtlId != null and planDtlId != ''">PLAN_DTL_ID = #{planDtlId},</if>
  97. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  98. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  99. <if test="adGrad != null and adGrad != ''">AD_GRAD = #{adGrad},</if>
  100. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  101. <if test="intm != null">INTM = #{intm},</if>
  102. <if test="uptm != null">UPTM = #{uptm},</if>
  103. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  104. </trim>
  105. <include refid="page_where" />
  106. </update>
  107. <!-- 其他自定义SQL -->
  108. <insert id="batchInsert" parameterType="java.util.ArrayList">
  109. insert all into BIS_INSP_PLAN_DTL_ADDVCD(
  110. <include refid="table_columns"/>
  111. )
  112. select
  113. <foreach collection="list" item="item" index="index" separator="UNION select">
  114. #{item.id},
  115. #{item.planDtlId},
  116. #{item.adCode},
  117. #{item.adName},
  118. #{item.adGrad},
  119. #{item.persId},
  120. #{item.intm},
  121. #{item.uptm},
  122. #{item.dataStat} from dual
  123. </foreach>
  124. </insert>
  125. <select id="getByAdCodeAndTm" resultType="java.util.Map">
  126. select BIPDA.AD_CODE as AD_CODE, to_char(count(BIPDA.ID)) as COUNT
  127. from BIS_INSP_PLAN_DTL_ADDVCD BIPDA
  128. left join BIS_INSP_PLAN_DTL BIPD ON BIPD.ID = BIPDA.PLAN_DTL_ID
  129. <!-- 1周内 同一个市 -->
  130. where not (
  131. (( BIPD.ST_TM + 7-TO_CHAR((BIPD.ST_TM), 'D')+0) &lt; #{stTm} )OR
  132. (( BIPD.ST_TM + 1 - TO_CHAR((BIPD.ST_TM), 'D')+0) &gt; #{enTm} )
  133. ) and SUBSTR(BIPDA.AD_CODE, 1, 4 ) in (${adCodes}) and BIPD.DATA_STAT='0' and BIPDA.DATA_STAT='0'
  134. group by BIPDA.AD_CODE
  135. having count(BIPDA.id) &gt;= 1
  136. </select>
  137. <select id="getByAdCodeAndTmAndPlan" resultType="java.util.Map" parameterType="java.lang.String">
  138. SELECT
  139. a.chk_name as chk_name ,to_char(
  140. count( a.id))as COUN
  141. FROM
  142. BIS_INSP_PLAN_YEAR a left join BIS_INSP_PLAN_DTL b On a.id = b.plan_id Left join BIS_INSP_PLAN_DTL_ADDVCD C on C.PLAN_DTL_ID = b.id and b.DATA_STAT = '0'
  143. where to_char(#{stTm} ,'MM') = TO_CHAR (b.ST_TM ,'MM')
  144. and #{planId} = b.plan_id and SUBSTR(C.AD_CODE,1,4 )in (${adCodes})
  145. and b.DATA_STAT ='0'
  146. group by
  147. a.chk_name
  148. having
  149. count( a.id )>= 1
  150. </select>
  151. <select id="getByAdCodeAndTmList" resultType="cn.com.goldenwater.dcproj.dto.BisInspPlanDtlDto">
  152. select distinct BIPD.ID,
  153. BIPD.NM,
  154. BIPD.PLAN_ID,
  155. BIPD.ST_TM,
  156. BIPD.EN_TM,
  157. BIPD.CHK_PRJ_SIZE,
  158. BIPD.CHK_TYPE,
  159. BIPD.ONLINE_CHK,
  160. BIPD.NOTE,
  161. BIPD.PERS_ID,
  162. BIPD.INTM,
  163. BIPD.UPTM,
  164. BIPD.DATA_STAT,
  165. BIPD.CHK_CONTENT,
  166. BIPD.CHK_IMPL_DEPT
  167. from BIS_INSP_PLAN_DTL BIPD
  168. left join BIS_INSP_PLAN_DTL_ADDVCD BIPDA ON BIPD.ID = BIPDA.PLAN_DTL_ID
  169. where not (
  170. (( BIPD.ST_TM + 7-TO_CHAR((BIPD.ST_TM), 'D')+0) &lt; #{stTm} )OR
  171. (( BIPD.ST_TM + 1 - TO_CHAR((BIPD.ST_TM), 'D')+0) &gt; #{enTm} )
  172. ) and SUBSTR(BIPDA.AD_CODE, 1, 4 ) in (${adCodes}) and BIPD.DATA_STAT='0' and BIPDA.DATA_STAT='0'
  173. </select>
  174. </mapper>