TacInspYearBatchObjDao.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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.TacInspYearBatchObjDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj" id="tacInspYearBatchObjResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="yearBatchId" column="YEAR_BATCH_ID"/>
  7. <result property="year" column="YEAR"/>
  8. <result property="batch" column="BATCH"/>
  9. <result property="groupId" column="GROUP_ID"/>
  10. <result property="groupNm" column="GROUP_NM"/>
  11. <result property="ojbId" column="OJB_ID"/>
  12. <result property="ojbNm" column="OJB_NM"/>
  13. <result property="persId" column="PERS_ID"/>
  14. <result property="inTm" column="IN_TM"/>
  15. <result property="upTm" column="UP_TM"/>
  16. <result property="dataStat" column="DATA_STAT"/>
  17. <result property="province" column="PROVINCE"/>
  18. <result property="sn" column="SN"/>
  19. </resultMap>
  20. <sql id="table_columns">
  21. ID,
  22. YEAR_BATCH_ID,
  23. YEAR,
  24. BATCH,
  25. GROUP_ID,
  26. GROUP_NM,
  27. OJB_ID,
  28. OJB_NM,
  29. PERS_ID,
  30. IN_TM,
  31. UP_TM,
  32. DATA_STAT,PROVINCE,SN
  33. </sql>
  34. <sql id="entity_properties">
  35. #{id},
  36. #{yearBatchId},
  37. #{year},
  38. #{batch},
  39. #{groupId},
  40. #{groupNm},
  41. #{ojbId},
  42. #{ojbNm},
  43. #{persId},
  44. #{inTm},
  45. #{upTm},
  46. #{dataStat},#{province},#{sn}
  47. </sql>
  48. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  49. <sql id="page_where">
  50. <trim prefix="where" prefixOverrides="and | or ">
  51. <if test="yearBatchId != null and yearBatchId != ''">and YEAR_BATCH_ID = #{yearBatchId}</if>
  52. <if test="year != null and year != ''">and YEAR = #{year}</if>
  53. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  54. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  55. <if test="groupNm != null and groupNm != ''">and GROUP_NM = #{groupNm}</if>
  56. <if test="ojbId != null and ojbId != ''">and OJB_ID = #{ojbId}</if>
  57. <if test="ojbNm != null and ojbNm != ''">and OJB_NM = #{ojbNm}</if>
  58. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  59. <if test="inTm != null">and IN_TM = #{inTm}</if>
  60. <if test="upTm != null">and UP_TM = #{upTm}</if>
  61. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  62. <include refid="choseSql"/>
  63. </trim>
  64. </sql>
  65. <sql id="choseSql">
  66. <choose>
  67. <when test="province !=null and province !=''">
  68. AND t.PROVINCE=#{province}
  69. </when>
  70. <otherwise>
  71. AND t.PROVINCE is null
  72. </otherwise>
  73. </choose>
  74. </sql>
  75. <select id="get" resultMap="tacInspYearBatchObjResultMap" parameterType="String" >
  76. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_OBJ where ID = #{id}
  77. </select>
  78. <select id="getBy" resultMap="tacInspYearBatchObjResultMap">
  79. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_OBJ t <include refid="page_where" />
  80. </select>
  81. <select id="findAll" resultMap="tacInspYearBatchObjResultMap">
  82. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_OBJ
  83. </select>
  84. <select id="findList" resultMap="tacInspYearBatchObjResultMap">
  85. select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH_OBJ t <include refid="page_where" />
  86. order by t.sn asc
  87. </select>
  88. <select id="getObjAndType" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  89. select t.*,r.TYPE as TYPE from TAC_INSP_YEAR_BATCH_OBJ t left join tac_pawp_rgstr r on t.id = r.obj_id
  90. where 1=1
  91. <if test="yearBatchId != null and yearBatchId != ''">and t.YEAR_BATCH_ID = #{yearBatchId}</if>
  92. <if test="year != null and year != ''">and t.YEAR = #{year}</if>
  93. <if test="batch != null and batch != ''">and t.BATCH = #{batch}</if>
  94. <if test="groupId != null and groupId != ''">and t.GROUP_ID = #{groupId}</if>
  95. <if test="groupNm != null and groupNm != ''">and t.GROUP_NM = #{groupNm}</if>
  96. <if test="ojbId != null and ojbId != ''">and t.OJB_ID = #{ojbId}</if>
  97. <if test="ojbNm != null and ojbNm != ''">and t.OJB_NM = #{ojbNm}</if>
  98. <if test="persId != null and persId != ''">and t.PERS_ID = #{persId}</if>
  99. <if test="inTm != null">and t.IN_TM = #{inTm}</if>
  100. <if test="upTm != null">and t.UP_TM = #{upTm}</if>
  101. <if test="dataStat != null and dataStat != ''">and t.DATA_STAT = #{dataStat}</if>
  102. order by t.sn asc
  103. </select>
  104. <select id="selectCount" resultType="int" >
  105. select count(ID) from TAC_INSP_YEAR_BATCH_OBJ t <include refid="page_where" />
  106. </select>
  107. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  108. insert into TAC_INSP_YEAR_BATCH_OBJ( <include refid="table_columns" /> )
  109. values ( <include refid="entity_properties" /> )
  110. </insert>
  111. <delete id="delete" parameterType="java.lang.String">
  112. delete from TAC_INSP_YEAR_BATCH_OBJ where ID = #{id}
  113. </delete>
  114. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  115. delete from TAC_INSP_YEAR_BATCH_OBJ t <include refid="page_where" />
  116. </delete>
  117. <update id="deleteInFlag" parameterType="java.lang.String">
  118. update TAC_INSP_YEAR_BATCH_OBJ set flag_valid = 0 where ID = #{id}
  119. </update>
  120. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  121. update TAC_INSP_YEAR_BATCH_OBJ
  122. <trim prefix="set" suffixOverrides=",">
  123. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  124. <if test="year != null and year != ''">YEAR = #{year},</if>
  125. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  126. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  127. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  128. <if test="ojbId != null and ojbId != ''">OJB_ID = #{ojbId},</if>
  129. <if test="ojbNm != null and ojbNm != ''">OJB_NM = #{ojbNm},</if>
  130. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  131. <if test="inTm != null">IN_TM = #{inTm},</if>
  132. <if test="upTm != null">UP_TM = #{upTm},</if>
  133. <if test="sn != null">SN = #{sn},</if>
  134. <if test="province != null">PROVINCE = #{province},</if>
  135. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  136. </trim>
  137. <where>ID = #{id}</where>
  138. </update>
  139. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  140. update TAC_INSP_YEAR_BATCH_OBJ
  141. <trim prefix="set" suffixOverrides=",">
  142. <if test="yearBatchId != null and yearBatchId != ''">YEAR_BATCH_ID = #{yearBatchId},</if>
  143. <if test="year != null and year != ''">YEAR = #{year},</if>
  144. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  145. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  146. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  147. <if test="ojbId != null and ojbId != ''">OJB_ID = #{ojbId},</if>
  148. <if test="ojbNm != null and ojbNm != ''">OJB_NM = #{ojbNm},</if>
  149. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  150. <if test="inTm != null">IN_TM = #{inTm},</if>
  151. <if test="province != null">PROVINCE = #{province},</if>
  152. <if test="sn != null">SN = #{sn},</if>
  153. <if test="upTm != null">UP_TM = #{upTm},</if>
  154. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  155. </trim>
  156. <include refid="page_where" />
  157. </update>
  158. <!-- 其他自定义SQL -->
  159. <select id="getObjList" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto">
  160. select t.year_batch_id,t.year,t.batch,t.GROUP_NM,rg.*,'8' as ptype,t.OJB_NM from TAC_INSP_YEAR_BATCH_OBJ t left join Tac_Pawp_Rgstr rg on t.id = rg.OBj_ID
  161. where 1=1
  162. <if test="persId != null and persId != ''">
  163. and t.group_id in (
  164. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID in (
  165. select b.id from TAC_WORKER_B b where b.login_id = #{persId}
  166. <trim>
  167. <choose>
  168. <when test="province !=null and province !=''">
  169. AND b.PROVINCE=#{province}
  170. </when>
  171. <otherwise>
  172. AND b.PROVINCE is null
  173. </otherwise>
  174. </choose>
  175. </trim>
  176. )
  177. )
  178. </if>
  179. <include refid="choseSql"/>
  180. <if test="yearBatchId != null and yearBatchId != ''">
  181. and t.year_batch_id = #{yearBatchId}
  182. </if>
  183. <if test="year != null and year != ''">
  184. and t.year = #{year}
  185. </if>
  186. <if test="batch != null and batch != ''">
  187. and t.batch = #{batch}
  188. </if>
  189. <if test="adCode != null and adCode != ''">
  190. and rg.ad_code like concat('%' ,substr(#{adCode},1,4) , '%')
  191. </if>
  192. <if test="groupId != null and groupId != ''">
  193. and t.group_id = #{groupId}
  194. </if>
  195. <if test="ojbNm != null and ojbNm != ''">
  196. and t.ojb_nm like '%${ojbNm}%'
  197. </if>
  198. <if test="state != null and state != ''">
  199. and rg.state = #{state}
  200. </if>
  201. <if test="type != null and type != ''">
  202. and rg.type = #{type}
  203. </if>
  204. order by INTM desc
  205. </select>
  206. <!-- 山东稽察 汇总成果 增加在批次下选择项目 -->
  207. <select id="objslistbybatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto">
  208. select t.YEAR_BATCH_ID, t.GROUP_ID, t.OJB_ID as OBJ_ID, t.OJB_NM from TAC_INSP_YEAR_BATCH_OBJ t
  209. left join Tac_Pawp_Rgstr rg on t.id = rg.OBj_ID
  210. where 1=1
  211. <include refid="choseSql"/>
  212. <if test="yearBatchId != null and yearBatchId != ''">
  213. and t.year_batch_id = #{yearBatchId}
  214. </if>
  215. <if test="year != null and year != ''">
  216. and t.year = #{year}
  217. </if>
  218. <if test="batch != null and batch != ''">
  219. and t.batch = #{batch}
  220. </if>
  221. <if test="adCode != null and adCode != ''">
  222. and rg.ad_code like concat('%',concat(substr(#{adCode},1,4), '%'))
  223. </if>
  224. <if test="groupId != null and groupId != ''">
  225. and t.group_id = #{groupId}
  226. </if>
  227. <if test="ojbNm != null and ojbNm != ''">
  228. and t.ojb_nm like '%${ojbNm}%'
  229. </if>
  230. <if test="state != null and state != ''">
  231. and rg.state = #{state}
  232. </if>
  233. <if test="type != null and type != ''">
  234. and rg.type = #{type}
  235. </if>
  236. order by t.SN asc
  237. </select>
  238. <select id="getBaseNotInGroupByGroupId" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  239. select distinct * from (
  240. select t.* from TAC_ATT_PAWP_BASE t where t.id not in (
  241. select OJB_ID from TAC_INSP_YEAR_BATCH_OBJ t where group_id = #{groupId}
  242. <include refid="choseSql"/>
  243. )
  244. <include refid="choseSql"/>
  245. <if test="ojbNm != null and ojbNm != ''">and t.name LIKE '%${ojbNm}%'</if>
  246. <if test="engSta != null and engSta != ''">and t.type LIKE '%${engSta}%'</if>
  247. ) w where 1=1
  248. <if test="adCode != null and adCode != ''">and ${adCode}</if>
  249. ORDER BY
  250. <if test="orderBy != null and orderBy != ''">${orderBy},</if>
  251. ad_code,name
  252. </select>
  253. <select id="getObjTreeList" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatchObj">
  254. select r.ad_code,t.*,r.id as rgstrId,(case when r.state is null then '0' else r.state end) state,r.TASK_ID taskId from TAC_INSP_YEAR_BATCH_OBJ t
  255. join TAC_INSP_YEAR_BATCH h on t.year_batch_id=h.id join tac_pawp_rgstr r on t.id = r.obj_id
  256. where 1=1
  257. <if test="persId != null and persId != ''">
  258. and t.group_id in (
  259. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID in (select b.id from TAC_WORKER_B b where b.login_id = #{persId}
  260. <if test=' "1" == isEval'>
  261. <!-- 外聘稽查专家测评 isExternal 是否外聘 0否 1是 -->
  262. AND b.IS_EXTERNAL != '1'
  263. </if>
  264. )
  265. <!-- 外聘稽查专家测评 稽查专家、助理、组长、特派员 -->
  266. <if test=' "1" == isEval'>
  267. AND t.PERS_ID in (select WORKERID from tac_worker_type where TYPE='1' and FIND_IN_SET(VALUE ,'11,12,13,14,15,16,19,20,21') )
  268. </if>
  269. <!--专家组长测评 稽查专家、助理、特派员 -->
  270. <if test=' "2" == isEval'>
  271. AND t.PERS_ID in (select WORKERID from tac_worker_type where TYPE='1' and FIND_IN_SET(VALUE ,'11,12,13,14,15,16,19,21') )
  272. </if>
  273. )
  274. </if>
  275. <include refid="choseSql"/>
  276. <if test="year != null and year != ''">
  277. and t.year = #{year}
  278. </if>
  279. <if test="batch != null and batch != ''">
  280. and t.batch = #{batch}
  281. </if>
  282. order by t.year desc,t.batch desc,cast(t.group_nm as unsigned)
  283. </select>
  284. <select id="getObjListByPersId" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam" resultType="cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto">
  285. select * from (
  286. select rg.id,
  287. rg.obj_id,
  288. rg.name,
  289. rg.ADM_ORG,
  290. rg.LOCATION,
  291. rg.type,
  292. rg.ITME_DESC,
  293. rg.ITME_EVAL,
  294. rg.ad_code,
  295. (case when rg.CENTER_X is null then ba.CENTER_X else rg.CENTER_X end) CENTER_X,
  296. (case when rg.CENTER_Y is null then ba.CENTER_Y else rg.CENTER_Y end) CENTER_Y,
  297. (case when rg.GD_X is null then ba.GD_X else rg.GD_X end) GD_X,
  298. (case when rg.GD_Y is null then ba.GD_Y else rg.GD_Y end) GD_Y,
  299. rg.state,t.ojb_id as baseId,t.year,t.batch,t.group_id,t.YEAR_BATCH_ID
  300. from TAC_INSP_YEAR_BATCH_OBJ t left join Tac_Pawp_Rgstr rg on t.id = rg.OBj_ID left join TAC_ATT_PAWP_BASE ba on t.OJB_ID = ba.id
  301. where 1=1
  302. <if test="persId != null and persId != ''">
  303. and t.group_id in (
  304. select t.group_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t WHERE PERS_ID in (select b.id from TAC_WORKER_B b where b.login_id = #{persId})
  305. )
  306. </if>
  307. <include refid="choseSql"/>
  308. <if test="year != null">
  309. and t.year = #{year}
  310. </if>
  311. <if test="batch != null">
  312. and t.batch = #{batch}
  313. </if>
  314. <if test="adCode != null and adCode != ''">
  315. and rg.ad_Code like '${adCode}%'
  316. </if>
  317. <if test="type != null and type != ''">
  318. and rg.type = #{type}
  319. </if>
  320. <if test="name != null and name != ''">
  321. and rg.name like '%${name}%'
  322. </if>
  323. <if test="ojbId != null and ojbId != ''">
  324. and t.ojb_id = #{ojbId}
  325. </if>
  326. ) t where 1=1
  327. <if test="maxLgtd != null and maxLgtd != '' and minLgtd != null and minLgtd != ''">and t.CENTER_X BETWEEN
  328. #{minLgtd} AND #{maxLgtd}
  329. </if>
  330. <if test="maxLttd != null and maxLttd != '' and minLttd != null and minLttd != ''">and t.CENTER_Y BETWEEN
  331. #{minLttd} AND #{maxLttd}
  332. </if>
  333. <if test="maxcenterXGd != null and maxcenterXGd != '' and mincenterXGd != null and mincenterXGd != ''">and
  334. t.GD_X BETWEEN #{mincenterXGd} AND #{maxcenterXGd}
  335. </if>
  336. <if test="maxcenterYGd != null and maxcenterYGd != '' and mincenterYGd != null and mincenterYGd != ''">and
  337. t.GD_Y BETWEEN #{mincenterYGd} AND #{maxcenterYGd}
  338. </if>
  339. </select>
  340. <select id="getObjListByGroupIdList" resultType="String">
  341. select ID from TAC_INSP_YEAR_BATCH_OBJ
  342. where group_id in
  343. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  344. #{item}
  345. </foreach>
  346. </select>
  347. </mapper>