StockLandDao.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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="platform.modules.company.dao.StockLandDao">
  4. <!--存量土地,待审核,jiangjz-->
  5. <select id="findPageInfo" resultType="platform.modules.company.entity.StockLand">
  6. SELECT
  7. a.id,
  8. a.company_id,
  9. a.apply_no,
  10. a.apply_type,
  11. a.apply_status,
  12. a.approve_status,
  13. a.create_time,
  14. a.update_time,
  15. b.company_name as company_name,
  16. c.NAME AS apply_type_name,
  17. d.NAME AS approve_status_name,
  18. hour(timediff(date_add(IFNULL(a.update_time,a.create_time),interval 5 day),NOW())) as overTime,
  19. g.NEXTCHECKER as nextChecker,
  20. g.create_time as create_date
  21. FROM
  22. c_stock_land_apply a
  23. LEFT JOIN y_company b ON a.company_id = b.id
  24. LEFT JOIN dictionary_item c ON a.apply_type = c.value
  25. LEFT JOIN dictionary_item d ON a.approve_status = d.value
  26. LEFT JOIN dictionary_type e ON e.id = c.tid
  27. LEFT JOIN dictionary_type f ON f.id = d.tid
  28. LEFT JOIN z_approval g on g.APPLY_ID = a.id
  29. LEFT JOIN z_user zUser on zUser.id = a.create_by
  30. WHERE
  31. a.del_flag = '0' AND e.id = '1' and f.id='2'
  32. and (
  33. nextChecker = #{condition.userId}
  34. or
  35. nextChecker LIKE CONCAT(CONCAT(#{condition.userId},','), '%')
  36. or
  37. nextChecker LIKE CONCAT(CONCAT('%,',#{condition.userId}), ',%')
  38. )
  39. and g.create_time in (select max(CREATE_TIME)from z_approval where del_flag=0 group by APPLY_ID )
  40. and a.approve_status in
  41. <foreach collection="condition.apply_status" index="index" item="item" open="(" separator="," close=")">
  42. #{item}
  43. </foreach>
  44. <if test="condition.approve_status != null and condition.approve_status!=''">
  45. and a.approve_status = #{condition.approve_status}
  46. </if>
  47. <if test="condition.apply_type != null and condition.apply_type!=''">
  48. and a.apply_type = #{condition.apply_type}
  49. </if>
  50. <if test="condition.keyword != null and condition.keyword!=''">
  51. and a.apply_no LIKE CONCAT ('%',#{condition.keyword},'%')
  52. </if>
  53. <if test="condition.applyUserType!=null and condition.applyUserType!=''">
  54. and zUser.user_type = #{condition.applyUserType}
  55. </if>
  56. order by IFNULL(a.update_time,a.create_time) desc
  57. </select>
  58. <!-- 街道审核列表 -->
  59. <select id="findApprovePageInfo" resultType="platform.modules.company.entity.StockLand">
  60. SELECT DISTINCT
  61. a.id,
  62. a.company_id,
  63. a.apply_no,
  64. a.apply_type,
  65. a.apply_status,
  66. a.approve_status,
  67. a.process_status,
  68. a.create_time,
  69. a.temporary_state,
  70. a.create_by
  71. FROM
  72. c_stock_land_apply a
  73. LEFT JOIN z_approval approval on approval.apply_id = a.id
  74. LEFT JOIN z_user zUser on zUser.id = a.create_by
  75. LEFT JOIN y_company c on a.company_id = c.id
  76. WHERE
  77. a.del_flag = '0' and a.approve_status is not null
  78. <if test="request.keyword!=null and request.keyword!=''">
  79. and c.company_name LIKE CONCAT ('%',#{request.keyword},'%')
  80. </if>
  81. <if test="request.street_id!=null and request.street_id!=''">
  82. <!-- and a.street_id=#{request.street_id} -->
  83. and a.building_street_id=#{request.street_id}
  84. </if>
  85. <if test="searchCondition.apply_type!=null and searchCondition.apply_type!=''">
  86. and a.apply_type=#{searchCondition.apply_type}
  87. </if>
  88. <if test="searchCondition.apply_status!=null and searchCondition.apply_status!=''">
  89. and a.apply_status=#{searchCondition.apply_status}
  90. </if>
  91. <if test="searchCondition.approve_status!=null and searchCondition.approve_status!=''">
  92. and a.approve_status=#{searchCondition.approve_status}
  93. </if>
  94. <if test="searchCondition.applyUserType!=null and searchCondition.applyUserType!=''">
  95. and zUser.user_type = #{searchCondition.applyUserType}
  96. </if>
  97. <if test="searchCondition.isPendingAudit == 1"><!-- 为1 ,取待审核数据-->
  98. and a.id in (
  99. SELECT DISTINCT APPLY_ID FROM z_approval WHERE (NEXTCHECKER = #{approvalCondition.nextchecker}
  100. or NEXTCHECKER LIKE CONCAT(#{approvalCondition.nextchecker}, ',%')
  101. or NEXTCHECKER LIKE CONCAT(CONCAT('%,',#{approvalCondition.nextchecker}), ',%'))
  102. and (
  103. id in
  104. (
  105. select temp.maxId from (select APPLY_ID,max(id) maxId
  106. from z_approval
  107. <if test="approvalCondition.type != null and approvalCondition.type != '' ">
  108. where type = #{approvalCondition.type}
  109. </if>
  110. and del_flag = 0
  111. GROUP BY APPLY_ID
  112. ) temp )
  113. )
  114. )
  115. </if>
  116. <if test="searchCondition.isPendingAudit == 0"><!-- 为0 ,取已审核数据-->
  117. and a.id not in (
  118. SELECT DISTINCT APPLY_ID FROM z_approval WHERE (NEXTCHECKER = #{approvalCondition.nextchecker}
  119. or NEXTCHECKER LIKE CONCAT(#{approvalCondition.nextchecker}, ',%')
  120. or NEXTCHECKER LIKE CONCAT(CONCAT('%,',#{approvalCondition.nextchecker}), ',%'))
  121. and (
  122. id in
  123. (
  124. select temp.maxId from (select APPLY_ID,max(id) maxId
  125. from z_approval
  126. <if test="approvalCondition.type != null and approvalCondition.type != '' ">
  127. where type = #{approvalCondition.type}
  128. </if>
  129. and del_flag = 0
  130. GROUP BY APPLY_ID
  131. ) temp )
  132. )
  133. )
  134. </if>
  135. order by create_time desc
  136. </select>
  137. <!-- 存量用地 已审核 jiangjz-->
  138. <select id="findApprovalPageInfo" resultType="platform.modules.company.entity.StockLand">
  139. SELECT
  140. DISTINCT id,
  141. company_id,
  142. apply_no,
  143. apply_type,
  144. apply_status,
  145. approve_status,
  146. create_time,
  147. company_name as company_name,
  148. apply_type_name,
  149. approve_status_name,
  150. overTime,
  151. update_time
  152. from (
  153. SELECT
  154. a.id,
  155. a.company_id,
  156. a.apply_no,
  157. a.apply_type,
  158. a.apply_status,
  159. a.approve_status,
  160. a.create_time,
  161. a.update_time,
  162. b.company_name as company_name,
  163. c.NAME AS apply_type_name,
  164. d.NAME AS approve_status_name,
  165. g.CHECKER,
  166. g.DEAL_TIME as deal_time,
  167. hour(timediff(date_add(IFNULL(a.update_time,a.create_time),interval 5 day),NOW())) as overTime
  168. FROM
  169. c_stock_land_apply a
  170. LEFT JOIN y_company b ON a.company_id = b.id
  171. LEFT JOIN dictionary_item c ON a.apply_type = c.value
  172. LEFT JOIN dictionary_item d ON a.approve_status = d.value
  173. LEFT JOIN dictionary_type e ON e.id = c.tid
  174. LEFT JOIN dictionary_type f ON f.id = d.tid
  175. left join z_approval g on g.APPLY_ID = a.id
  176. LEFT JOIN z_user zUser on zUser.id = a.create_by
  177. WHERE
  178. a.del_flag = '0' AND e.id = '1' and f.id='2' and CHECKER is not null
  179. and (
  180. (
  181. CHECKER = #{condition.userId}
  182. or
  183. CHECKER LIKE CONCAT(CONCAT(#{condition.userId},','), '%')
  184. or
  185. CHECKER LIKE CONCAT(CONCAT('%,',#{condition.userId}), ',%')
  186. )
  187. <if test=" condition.checker_ids!=null ">
  188. OR ( CHECKER in
  189. <foreach collection="condition.checker_ids" index="index" item="item" open="(" separator="," close=")">
  190. #{item}
  191. </foreach>
  192. )
  193. </if>
  194. )
  195. <if test="condition.applyUserType!=null and condition.applyUserType!=''">
  196. and zUser.user_type = #{condition.applyUserType}
  197. </if>
  198. and g.del_flag = 0
  199. ) q
  200. WHERE 1=1
  201. <if test="condition.approve_status != null and condition.approve_status!=''">
  202. and q.approve_status=#{condition.approve_status}
  203. </if>
  204. <if test="condition.apply_type != null and condition.apply_type!=''">
  205. and q.apply_type=#{condition.apply_type}
  206. </if>
  207. <if test="condition.keyword != null and condition.keyword!=''">
  208. and q.apply_no LIKE CONCAT ('%',#{condition.keyword},'%')
  209. </if>
  210. order by IFNULL(update_time,create_time) desc
  211. </select>
  212. <update id="updateTempporaryStateToNull">
  213. update c_stock_land_apply set temporary_state = null
  214. where id = #{id}
  215. </update>
  216. <select id="getApplyDate" resultType="String">
  217. select create_time from z_approval
  218. where APPLY_ID = #{id} and TYPE = "存量用地" order by create_time limit 0,1
  219. </select>
  220. <!-- 审核通过的列表 -->
  221. <select id="findApprovePassPage" resultType="platform.modules.company.entity.StockLand">
  222. SELECT DISTINCT
  223. a.id,
  224. a.company_id,
  225. com.company_name company_name,
  226. a.apply_no apply_no,
  227. a.apply_type apply_type ,
  228. a.apply_status apply_status,
  229. a.approve_status approve_status,
  230. a.process_status process_status,
  231. a.create_time create_time,
  232. a.temporary_state temporary_state,
  233. a.create_by create_by,
  234. item.NAME AS apply_type_name,
  235. item2.NAME AS approve_status_name
  236. FROM
  237. c_stock_land_apply a
  238. LEFT JOIN z_approval approval on approval.apply_id = a.id
  239. LEFT JOIN y_company com ON com.id = a.company_id
  240. LEFT JOIN dictionary_item item ON a.apply_type = item.`value`
  241. LEFT JOIN dictionary_item item2 ON a.approve_status = item2.`value`
  242. LEFT JOIN dictionary_type type ON type.id = item.tid
  243. LEFT JOIN dictionary_type type2 ON type2.id = item2.tid
  244. LEFT JOIN z_user zUser on zUser.id = a.create_by
  245. WHERE
  246. a.del_flag = '0'
  247. AND
  248. type.id = #{stockLandId} and type2.id=#{approvedId}
  249. AND
  250. a.approve_status in
  251. <foreach collection="statusList" index="index" item="item" open="(" separator="," close=")">
  252. #{item}
  253. </foreach>
  254. AND
  255. a.apply_type = #{itemId}
  256. AND
  257. (a.street_id = #{street_id} or a.building_street_id = #{street_id})
  258. <if test="keyword != null and keyword != ''">
  259. AND
  260. a.apply_no LIKE CONCAT(CONCAT('%',#{keyword}),'%')
  261. </if>
  262. <if test="company_name != null and company_name != ''">
  263. AND
  264. com.company_name LIKE CONCAT(CONCAT('%',#{company_name}),'%')
  265. </if>
  266. <if test="apply_type != null and apply_type != ''">
  267. AND
  268. a.apply_type = #{apply_type}
  269. </if>
  270. <if test="applyUserType!=null and applyUserType!=''">
  271. and zUser.user_type = #{applyUserType}
  272. </if>
  273. and (
  274. approval.create_time in
  275. (
  276. select temp.maxTime from (select APPLY_ID,max(CREATE_TIME) maxTime
  277. from z_approval
  278. GROUP BY APPLY_ID
  279. ) temp )
  280. )
  281. order by a.create_time desc
  282. </select>
  283. <!-- 查询所有审核状态下的列表 -->
  284. <select id="findSelectPage" resultType="platform.modules.company.entity.StockLand">
  285. SELECT DISTINCT
  286. a.id,
  287. a.company_id,
  288. com.company_name company_name,
  289. a.apply_no apply_no,
  290. a.apply_type apply_type ,
  291. a.apply_status apply_status,
  292. a.approve_status approve_status,
  293. a.process_status process_status,
  294. a.create_time create_time,
  295. a.temporary_state temporary_state,
  296. a.create_by create_by,
  297. (SELECT `name` FROM dictionary_item WHERE tid = 1 AND `value` = a.apply_type) AS apply_type_name,
  298. (SELECT `name` FROM dictionary_item WHERE tid = 2 AND `value` = a.approve_status) AS approve_status_name
  299. FROM
  300. c_stock_land_apply a
  301. LEFT JOIN y_company com ON com.id = a.company_id
  302. LEFT JOIN z_user zUser on zUser.id = a.create_by
  303. WHERE
  304. a.del_flag = FALSE
  305. AND
  306. a.apply_type = #{itemId}
  307. AND
  308. a.street_id = #{street_id}
  309. <if test="keyword != null and keyword != ''">
  310. AND
  311. a.apply_no LIKE CONCAT(CONCAT('%',#{keyword}),'%')
  312. </if>
  313. <if test="company_name != null and company_name != ''">
  314. AND
  315. com.company_name LIKE CONCAT(CONCAT('%',#{company_name}),'%')
  316. </if>
  317. <if test="approve_status != null and approve_status != ''">
  318. AND
  319. a.approve_status = #{approve_status}
  320. </if>
  321. <if test="userData.street_id != null and userData.street_id != ''">
  322. AND
  323. a.street_id = #{userData.street_id}
  324. </if>
  325. <if test="applyUserType!=null and applyUserType!=''">
  326. and zUser.user_type = #{applyUserType}
  327. </if>
  328. order by a.create_time desc
  329. </select>
  330. <select id="getApplyResult" resultType="platform.modules.government.dto.GovStatisticsDto">
  331. SELECT
  332. SUM( IF(apply_status=1 OR apply_status=2, 1, 0)) AS underReview,
  333. SUM( IF(apply_status=4, 1, 0)) AS fail,
  334. SUM( IF(apply_status=3 OR apply_status=5 OR apply_status=6, 1, 0)) AS pass
  335. FROM
  336. c_stock_land_apply
  337. WHERE
  338. 1=1
  339. <if test="condition.begin_date != null and condition.begin_date !='' ">
  340. <![CDATA[ and DATE_FORMAT(create_time, '%Y-%m-%d')>= DATE_FORMAT(#{condition.begin_date}, '%Y-%m-%d') ]]>
  341. </if>
  342. <if test="condition.end_date != null and condition.end_date !='' ">
  343. <![CDATA[ and DATE_FORMAT(create_time, '%Y-%m-%d')<= DATE_FORMAT(#{condition.end_date}, '%Y-%m-%d') ]]>
  344. </if>
  345. <if test="condition.stocklandType != null and condition.stocklandType !='' ">
  346. AND apply_type = #{condition.stocklandType}
  347. </if>
  348. </select>
  349. <select id="getApplyRate" resultType="platform.modules.government.dto.GovStatisticsDto">
  350. SELECT
  351. di.`name` AS `type`,
  352. COUNT( slp.apply_type ) AS overallNum
  353. FROM
  354. c_stock_land_apply slp
  355. LEFT JOIN dictionary_item di ON di.`value` = slp.apply_type
  356. LEFT JOIN dictionary_type dt ON dt.id = di.tid
  357. WHERE
  358. slp.apply_status <![CDATA[ <> ]]> 0
  359. AND dt.`name` = '存量用地'
  360. <if test="condition.begin_date != null and condition.begin_date !='' ">
  361. <![CDATA[ and DATE_FORMAT(slp.create_time, '%Y-%m-%d')>= DATE_FORMAT(#{condition.begin_date}, '%Y-%m-%d') ]]>
  362. </if>
  363. <if test="condition.end_date != null and condition.end_date !='' ">
  364. <![CDATA[ and DATE_FORMAT(slp.create_time, '%Y-%m-%d')<= DATE_FORMAT(#{condition.end_date}, '%Y-%m-%d') ]]>
  365. </if>
  366. GROUP BY
  367. di.`name`
  368. </select>
  369. <select id="getStreetHandleCompare" resultType="platform.modules.government.dto.GovStatisticsDto">
  370. SELECT
  371. s.`name` AS streetName,
  372. SUM( IF(sla.apply_type=1, 1, 0)) AS equity,
  373. SUM( IF(sla.apply_type=2, 1, 0)) AS property,
  374. SUM( IF(sla.apply_type=3, 1, 0)) AS `use`,
  375. SUM( IF(sla.apply_type=4, 1, 0)) AS rent
  376. FROM
  377. c_stock_land_apply sla
  378. LEFT JOIN s_street s ON s.id = sla.street_id
  379. WHERE
  380. 1=1
  381. <if test="condition.begin_date != null and condition.begin_date !='' ">
  382. <![CDATA[ and DATE_FORMAT(sla.create_time, '%Y-%m-%d')>= DATE_FORMAT(#{condition.begin_date}, '%Y-%m-%d') ]]>
  383. </if>
  384. <if test="condition.end_date != null and condition.end_date !='' ">
  385. <![CDATA[ and DATE_FORMAT(sla.create_time, '%Y-%m-%d')<= DATE_FORMAT(#{condition.end_date}, '%Y-%m-%d') ]]>
  386. </if>
  387. GROUP BY s.`name`
  388. </select>
  389. <select id="findListByCondition" resultType="platform.modules.company.entity.StockLand">
  390. SELECT
  391. sla.*
  392. FROM
  393. c_stock_land_apply sla
  394. WHERE
  395. sla.apply_status <![CDATA[ <> ]]> 0
  396. <if test="condition.begin_date != null and condition.begin_date !='' ">
  397. <![CDATA[ and DATE_FORMAT(sla.create_time, '%Y-%m-%d')>= DATE_FORMAT(#{condition.begin_date}, '%Y-%m-%d') ]]>
  398. </if>
  399. <if test="condition.end_date != null and condition.end_date !='' ">
  400. <![CDATA[ and DATE_FORMAT(sla.create_time, '%Y-%m-%d')<= DATE_FORMAT(#{condition.end_date}, '%Y-%m-%d') ]]>
  401. </if>
  402. </select>
  403. <!-- 所有存量用地数据 -->
  404. <select id="findListByStreetId" resultType="platform.modules.company.dto.StockLandStatistic">
  405. SELECT
  406. stockland.id,
  407. stockland.street_id,
  408. stockland.apply_type,
  409. stockland.apply_status,
  410. stockland.approve_status,
  411. stockland.process_status,
  412. zuser.user_type AS apply_user_type,
  413. t.approval_round
  414. FROM
  415. c_stock_land_apply stockland
  416. LEFT JOIN z_user zuser ON zuser.id = stockland.create_by
  417. LEFT JOIN (
  418. SELECT
  419. APPLY_ID,
  420. max( APPROVAL_ROUND ) APPROVAL_ROUND,
  421. max( id ) AS id
  422. FROM
  423. z_approval
  424. WHERE
  425. type = "存量用地"
  426. AND del_flag = 0
  427. AND is_withdraw IS NULL
  428. GROUP BY
  429. APPLY_ID
  430. ) t ON t.APPLY_ID = stockland.id
  431. WHERE
  432. stockland.del_flag = '0'
  433. <if test="street_id != null and street_id != ''">
  434. AND stockland.street_id = #{street_id}
  435. </if>
  436. <if test="apply_user_type!=null and apply_user_type!=''">
  437. AND zuser.user_type = #{apply_user_type}
  438. </if>
  439. </select>
  440. <!-- 获取除待提交外的申请 -->
  441. <select id="findListByStreetIdAndTime" resultType="platform.modules.company.dto.StockLandStatistic">
  442. SELECT
  443. stockland.id,
  444. stockland.street_id,
  445. stockland.apply_type,
  446. stockland.apply_status,
  447. stockland.approve_status,
  448. stockland.process_status,
  449. stockland.summary_procedure,
  450. stockland.create_time
  451. FROM
  452. c_stock_land_apply stockland
  453. WHERE
  454. stockland.del_flag = '0'
  455. AND stockland.apply_status != 0
  456. <if test="street_id != null and street_id != ''">
  457. AND stockland.street_id = #{street_id}
  458. </if>
  459. <if test="start_time != null and start_time != ''">
  460. AND stockland.create_time <![CDATA[>=]]> #{start_time}
  461. </if>
  462. <if test="end_time != null and end_time != ''">
  463. AND stockland.create_time <![CDATA[<=]]> #{end_time}
  464. </if>
  465. </select>
  466. <update id="updateEasyProcessData" >
  467. UPDATE c_stock_land_apply
  468. SET approve_status = "80",
  469. apply_status = 3,
  470. update_by = 0,
  471. update_name = "sql",
  472. update_time = CONCAT_WS( " ", CURRENT_DATE, CURRENT_TIME )
  473. WHERE
  474. apply_no in
  475. <foreach collection="applyNoList" index="index" item="item" open="(" separator="," close=")">
  476. #{item}
  477. </foreach>
  478. </update>
  479. <insert id="insertAutoEasyProcessDataToStockLand" >
  480. INSERT INTO `z_approval`
  481. (`APPLY_ID`, `TYPE`, `DEPARTMENT`, `BEFORE_APPROVALSTATUS`, `AFTER_APPROVALSTATUS`, `CHECKER`, `NEXTCHECKER`, `APPROVAL_COMMENT`, `APPROVAL_ROUND`, `CREATE_TIME`, `CREATE_BY`, `UPDATE_TIME`, `UPDATE_BY`, `DEAL_TIME`, `STATUS`, `DEL_FLAG`, `ACTION_FLAG`, `TRANS_FLAG`, `REMARK`, `OPER_TYPE`, `PRO_INSTANCE_ID`, `CREATE_NAME`, `UPDATE_NAME`, `IS_WITHDRAW`, `CAN_WITHDRAW`)
  482. VALUES (#{applyid}, '存量用地', '企业服务处', '2', '14', 140, '', '做简易流程处理', 1, CONCAT_WS( " ", CURRENT_DATE, CURRENT_TIME ), 140, CONCAT_WS( " ", CURRENT_DATE, CURRENT_TIME ), NULL, NULL, 0, 0, NULL, NULL, '通过', '通过', null, '张磊', "sql", null, NULL)
  483. ,(#{applyid}, '存量用地', '企业服务处', '14', '80', 140, '', '审核通过', 1, CONCAT_WS( " ", CURRENT_DATE, CURRENT_TIME ), '140', CONCAT_WS( " ", CURRENT_DATE, CURRENT_TIME ), NULL, NULL, 0, 0, NULL, NULL, NULL, '通过', null, '张磊', "sql", NULL, NULL)
  484. </insert>
  485. </mapper>