TacAttPawpBaseDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.TacAttPawpBaseDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacAttPawpBase" id="tacAttPawpBaseResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="name" column="NAME"/>
  7. <result property="type" column="TYPE"/>
  8. <result property="admOrg" column="ADM_ORG"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="location" column="LOCATION"/>
  11. <result property="centerX" column="CENTER_X"/>
  12. <result property="centerY" column="CENTER_Y"/>
  13. <result property="gdX" column="GD_X"/>
  14. <result property="gdY" column="GD_Y"/>
  15. <result property="persId" column="PERS_ID"/>
  16. <result property="intm" column="INTM"/>
  17. <result property="uptm" column="UPTM"/>
  18. <result property="adName" column="AD_NAME"/>
  19. <result property="isPoverty" column="IS_POVERTY"/>
  20. <result property="province" column="PROVINCE"/>
  21. <result property="year" column="YEAR"/>
  22. <result property="commencementDate" column="COMMENCEMENT_DATE"/>
  23. <result property="totalInvestment" column="TOTAL_INVESTMENT"/>
  24. <result property="scale" column="SCALE"/>
  25. <result property="ptype" column="PTYPE"/>
  26. <result property="cate" column="CATE"/>
  27. <result property="stage" column="STAGE"/>
  28. </resultMap>
  29. <sql id="table_columns">
  30. ID,
  31. NAME,
  32. TYPE,
  33. ADM_ORG,
  34. AD_CODE,
  35. LOCATION,
  36. CENTER_X,
  37. CENTER_Y,
  38. GD_X,
  39. GD_Y,
  40. PERS_ID,
  41. INTM,
  42. UPTM,AD_NAME,IS_POVERTY,PROVINCE,
  43. YEAR,
  44. COMMENCEMENT_DATE,
  45. TOTAL_INVESTMENT,
  46. SCALE,PTYPE,CATE,STAGE
  47. </sql>
  48. <sql id="entity_properties">
  49. #{id}, #{name},
  50. #{type},
  51. #{admOrg},
  52. #{adCode},
  53. #{location},
  54. #{centerX},
  55. #{centerY},
  56. #{gdX},
  57. #{gdY},
  58. #{persId},
  59. #{intm},
  60. #{uptm},#{adName},#{isPoverty},#{province},
  61. #{year},#{commencementDate},#{totalInvestment}
  62. ,#{scale},#{ptype},#{cate},#{stage}
  63. </sql>
  64. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  65. <sql id="page_where">
  66. <trim prefix="where" prefixOverrides="and | or ">
  67. <if test="name != null and name != ''">and NAME like concat('%',concat(#{name},'%'))</if>
  68. <if test="type != null and type != ''">and TYPE like concat('%',concat(#{type},'%'))</if>
  69. <if test="admOrg != null and admOrg != ''">and ADM_ORG like concat('%',concat(#{admOrg},'%'))</if>
  70. <if test="adCode != null and adCode != ''">and AD_CODE like '%' || substr(#{adCode},0,4) || '%'</if>
  71. <if test="location != null and location != ''">and LOCATION like concat('%',concat(#{location},'%'))</if>
  72. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  73. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  74. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  75. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  76. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  77. <if test="intm != null">and INTM = #{intm}</if>
  78. <if test="uptm != null">and UPTM = #{uptm}</if>
  79. <if test="isPoverty != null">and IS_POVERTY = #{isPoverty}</if>
  80. <if test="adName != null">and AD_NAME = #{adName}</if>
  81. <if test="year != null and year != ''">and YEAR = #{year}</if>
  82. <if test="totalInvestment != null and totalInvestment != ''">and TOTAL_INVESTMENT = #{totalInvestment}</if>
  83. <if test="commencementDate != null">and COMMENCEMENT_DATE = #{commencementDate}</if>
  84. <include refid="choseSql"/>
  85. </trim>
  86. </sql>
  87. <sql id="choseSql">
  88. <choose>
  89. <when test="province !=null and province !=''">
  90. AND t.province=#{province}
  91. </when>
  92. <otherwise>
  93. AND t.province is null
  94. </otherwise>
  95. </choose>
  96. </sql>
  97. <select id="get" resultMap="tacAttPawpBaseResultMap" parameterType="String">
  98. select
  99. <include refid="table_columns"/>
  100. from TAC_ATT_PAWP_BASE where ID = #{id}
  101. </select>
  102. <select id="getBy" resultMap="tacAttPawpBaseResultMap">
  103. select
  104. <include refid="table_columns"/>
  105. from TAC_ATT_PAWP_BASE t
  106. <include refid="page_where"/>
  107. </select>
  108. <select id="findAll" resultMap="tacAttPawpBaseResultMap">
  109. select
  110. <include refid="table_columns"/>
  111. from TAC_ATT_PAWP_BASE
  112. </select>
  113. <select id="findList" resultMap="tacAttPawpBaseResultMap">
  114. select
  115. <include refid="table_columns"/>
  116. from TAC_ATT_PAWP_BASE t
  117. <include refid="page_where"/>
  118. </select>
  119. <select id="selectCount" resultType="int">
  120. select count(ID) from TAC_ATT_PAWP_BASE t
  121. <include refid="page_where"/>
  122. </select>
  123. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  124. insert into TAC_ATT_PAWP_BASE(
  125. <include refid="table_columns"/>
  126. )
  127. values (
  128. <include refid="entity_properties"/>
  129. )
  130. </insert>
  131. <delete id="delete" parameterType="java.lang.String">
  132. delete from TAC_ATT_PAWP_BASE where ID = #{id}
  133. </delete>
  134. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  135. delete from TAC_ATT_PAWP_BASE t
  136. <include refid="page_where"/>
  137. </delete>
  138. <update id="deleteInFlag" parameterType="java.lang.String">
  139. update TAC_ATT_PAWP_BASE set flag_valid = 0 where ID = #{id}
  140. </update>
  141. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  142. update TAC_ATT_PAWP_BASE
  143. <trim prefix="set" suffixOverrides=",">
  144. <if test="name != null and name != ''">NAME = #{name},</if>
  145. <if test="type != null and type != ''">TYPE = #{type},</if>
  146. <if test="isPoverty != null">IS_POVERTY = #{isPoverty},</if>
  147. <if test="adName != null">AD_NAME = #{adName},</if>
  148. <if test="admOrg != null">ADM_ORG = #{admOrg},</if>
  149. <if test="adCode != null">AD_CODE = #{adCode},</if>
  150. <if test="location != null">LOCATION = #{location},</if>
  151. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  152. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  153. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  154. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  155. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  156. <if test="intm != null">INTM = #{intm},</if>
  157. <if test="uptm != null">UPTM = #{uptm},</if>
  158. <if test="province != null">PROVINCE = #{province},</if>
  159. <if test="year != null and year != ''">YEAR = #{year},</if>
  160. <if test="totalInvestment != null">TOTAL_INVESTMENT = #{totalInvestment},</if>
  161. <if test="commencementDate != null">COMMENCEMENT_DATE = #{commencementDate},</if>
  162. </trim>
  163. <where>ID = #{id}</where>
  164. </update>
  165. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  166. update TAC_ATT_PAWP_BASE
  167. <trim prefix="set" suffixOverrides=",">
  168. <if test="isPoverty != null">IS_POVERTY = #{isPoverty},</if>
  169. <if test="adName != null">AD_NAME = #{adName},</if>
  170. <if test="name != null and name != ''">NAME = #{name},</if>
  171. <if test="type != null and type != ''">TYPE = #{type},</if>
  172. <if test="admOrg != null">ADM_ORG = #{admOrg},</if>
  173. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  174. <if test="location != null">LOCATION = #{location},</if>
  175. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  176. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  177. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  178. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  179. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  180. <if test="intm != null">INTM = #{intm},</if>
  181. <if test="uptm != null">UPTM = #{uptm},</if>
  182. <if test="province != null">PROVINCE = #{province},</if>
  183. <if test="year != null and year != ''">YEAR = #{year},</if>
  184. <if test="totalInvestment != null">TOTAL_INVESTMENT = #{totalInvestment},</if>
  185. <if test="commencementDate != null">COMMENCEMENT_DATE = #{commencementDate},</if>
  186. </trim>
  187. <include refid="page_where"/>
  188. </update>
  189. <!-- 其他自定义SQL -->
  190. <select id="getBaseType" parameterType="cn.com.goldenwater.dcproj.param.TacAttPawpBaseParam"
  191. resultType="java.lang.String">
  192. select DISTINCT type from TAC_ATT_PAWP_BASE t where TYPE is not null
  193. <include refid="choseSql"/>
  194. </select>
  195. <select id="getMonthPro" resultType="cn.com.goldenwater.dcproj.model.WorkInxMonth">
  196. select count(*)inxDenValue,substr(A.province,1,6)adcd,
  197. sum( CASE WHEN to_number(to_char(IN_TM,'MM'))&lt;=#{month} then 1 else 0 END )inxStatValue,
  198. round(sum( CASE WHEN to_number(to_char(IN_TM,'MM'))&lt;=#{month} then 1 else 0 END )/count(*)*100)inxPctValue,
  199. sum(case when to_char(IN_TM,'MM')=#{month} then 1 else 0 end )inxNumValue
  200. from TAC_ATT_PAWP_BASE A LEFT JOIN TAC_INSP_YEAR_BATCH_OBJ b ON A.Id=b.ojb_id
  201. where A.ad_code like '${adCode}%' and A.year=#{year} and A.province=#{province} group by A.province
  202. union all
  203. select count(*)inxDenValue,substr(ad_code,1,4)||'00'adcd,
  204. sum( CASE WHEN to_number(to_char(IN_TM,'MM'))&lt;=#{month} then 1 else 0 END )inxStatValue,
  205. round(sum( CASE WHEN to_number(to_char(IN_TM,'MM'))&lt;=#{month} then 1 else 0 END )/count(*)*100)inxPctValue,
  206. sum(case when to_char(IN_TM,'MM')=#{month} then 1 else 0 end )inxNumValue
  207. from TAC_ATT_PAWP_BASE A LEFT JOIN TAC_INSP_YEAR_BATCH_OBJ b ON A.Id=b.ojb_id
  208. where A.ad_code like '${adCode}%' and A.year=#{year} and A.province=#{province} group by substr( A.ad_code,1,4)
  209. </select>
  210. <select id="getAllPrject" resultType="cn.com.goldenwater.dcproj.model.DingChuanTacProject">
  211. select A.YEAR inspectYear,A.BATCH inspectBatch,c.AD_NAME inspectGroup,b.OBJ_ID inspectCode,OJB_NM objectName,b.ad_code objectAdcd,location objectLocation,type objectTypeName,b.intm inspectionDate,c.AD_NAME adName,c.ad_name,d.now_id stepId,b.id rgstrId
  212. from TAC_INSP_YEAR_BATCH_OBJ A
  213. LEFT JOIN TAC_PAWP_RGSTR B ON A.id=B.OBJ_ID
  214. LEFT JOIN ATT_AD_BASE C ON B.AD_CODE=C.AD_CODE
  215. JOIN (select * from TAC_PROVINCE_PLAN_TASK t where org_id='036' and now_step='整改阶段')D ON D.rgstr_id=B.ID
  216. WHERE a.PROVINCE='330000000000'
  217. AND A.YEAR=#{year}
  218. </select>
  219. <!--获取稽查省份 稽查时间 组长 专家 联系人-->
  220. <select id="getJcDescData" resultType="java.util.Map">
  221. select t.id,s.pers_id,s.year,s.batch,w.name,s.role_type,t.ad_code,t.ad_name,
  222. t.name as gc_nm,t.group_id,t.year_batch_id,t.st_tm,t.en_tm
  223. from TAC_INSP_YEAR_BATCH_GROUP_PERS s
  224. right join (
  225. select r.id,r.name,ba.AD_FULL_NAME,b.ad_code,b.ad_name,r.group_id,g.year_batch_id,g.st_tm,g.en_tm
  226. from tac_pawp_rgstr r
  227. left join ATT_AD_BASE b on substr(r.ad_code,1,2)||'0000000000' = b.ad_code
  228. left join ATT_AD_BASE ba on r.ad_code = ba.ad_code
  229. left join TAC_INSP_YEAR_BATCH_GROUP g on r.group_id = g.id
  230. where r.id =#{rgstrId}
  231. ) t on s.group_id = t.group_id
  232. left join tac_worker_b w on s.pers_id = w.id order by role_type
  233. </select>
  234. </mapper>