ApprovalDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="platform.modules.sys.dao.ApprovalDao">
  6. <!-- 查找最近一条审核记录(含撤回的) -->
  7. <select id="getLatestApprovalAll" resultType="platform.modules.sys.entity.Approval">
  8. select *
  9. from z_approval
  10. where apply_id = #{apply_id}
  11. and type = #{type}
  12. <!-- and del_flag = 0 -->
  13. order by create_time desc
  14. limit 0,1
  15. </select>
  16. <!-- 查找最近一条审核记录 -->
  17. <select id="getLatestApproval" resultType="platform.modules.sys.entity.Approval">
  18. select *
  19. from z_approval
  20. where apply_id = #{apply_id}
  21. and type = #{type}
  22. and del_flag = 0 and is_withdraw is null
  23. order by id desc
  24. limit 0,1
  25. </select>
  26. <!-- 查找当前用户最近一条待审核记录 -->
  27. <select id="getLatestApprovalByUser" resultType="platform.modules.sys.entity.Approval">
  28. select *
  29. from z_approval
  30. where
  31. apply_id = #{apply_id}
  32. and type = #{type}
  33. and (
  34. NEXTCHECKER = #{user_id}
  35. or NEXTCHECKER LIKE CONCAT(CONCAT('%',#{user_id}), ',%')
  36. or NEXTCHECKER LIKE CONCAT(CONCAT('%,',#{user_id}), '%')
  37. )
  38. order by create_time desc
  39. limit 0,1
  40. </select>
  41. <!-- 查找当前用户最近一条审核的记录 含撤回的记录-->
  42. <select id="getLatestApprovalAllByUser" resultType="platform.modules.sys.entity.Approval">
  43. select *
  44. from z_approval
  45. where
  46. apply_id = #{apply_id}
  47. and type = #{type}
  48. and CHECKER = #{user_id}
  49. order by create_time desc
  50. limit 0,1
  51. </select>
  52. <select id="findLastByCheckerAndBeforeStatu" resultType="platform.modules.sys.entity.Approval">
  53. SELECT * FROM z_approval where
  54. apply_id=#{id}
  55. and type = #{type}
  56. <if test="userId != null and userId != ''">
  57. and checker=#{userId}
  58. </if>
  59. <if test="complianceAudit != null and complianceAudit != ''">
  60. and BEFORE_APPROVALSTATUS=#{complianceAudit}
  61. </if>
  62. and del_flag = 0
  63. order by create_time desc limit 1
  64. </select>
  65. <select id="findDepartmentNameByApplyId" resultType="String">
  66. SELECT DISTINCT DEPARTMENT from z_approval where APPLY_ID=#{id} AND <![CDATA[ BEFORE_APPROVALSTATUS <> 1
  67. ]]> and del_flag = 0
  68. </select>
  69. <select id="findProcessNodes" resultType="platform.common.base.model.DictionaryItem">
  70. select
  71. item.name,
  72. item.value,
  73. item.sort,
  74. app.create_time
  75. from dictionary_item item
  76. LEFT JOIN dictionary_type t on t.id = item.tid
  77. LEFT JOIN z_approval app on app.BEFORE_APPROVALSTATUS = item.value
  78. where t.`name` = #{statusType}
  79. and app.apply_id = #{apply_id}
  80. and app.approval_round = (select max(approval_round) from z_approval where apply_id = #{apply_id})
  81. order by app.create_time
  82. </select>
  83. <select id="selectAllApprovalDistinct" resultType="platform.modules.sys.entity.Approval">
  84. SELECT
  85. *
  86. FROM
  87. z_approval t
  88. WHERE
  89. id = (
  90. SELECT
  91. max(id)
  92. FROM
  93. z_approval b
  94. WHERE
  95. b.apply_id = t.apply_id
  96. )
  97. <if test="type != null and type != ''">
  98. and t.type=#{type}
  99. </if>
  100. </select>
  101. <select id="selectAllApproval" resultType="platform.modules.sys.entity.Approval">
  102. SELECT
  103. *
  104. FROM
  105. z_approval t
  106. where 1=1
  107. AND del_flag = 0
  108. <if test="type != null and type != ''">
  109. and t.type=#{type}
  110. </if>
  111. </select>
  112. <select id="getCenterBusiness" resultType="platform.modules.government.dto.CenterBusiness">
  113. SELECT
  114. type,
  115. COUNT( DISTINCT apply_id) AS businessNum
  116. FROM
  117. z_approval
  118. WHERE
  119. department = #{businessSearchDto.department}
  120. AND del_flag = 0
  121. AND `type` <![CDATA[ <> ]]> '存量用地'
  122. AND `type` <![CDATA[ <> ]]> '企业注册'
  123. <if test="businessSearchDto.status != null and businessSearchDto.status != ''">
  124. AND AFTER_APPROVALSTATUS = null
  125. </if>
  126. GROUP BY type
  127. </select>
  128. <select id="getBusinessVolume" resultType="java.lang.Integer">
  129. SELECT
  130. COUNT(DISTINCT APPLY_ID )
  131. FROM
  132. z_approval
  133. WHERE
  134. `type` <![CDATA[ <> ]]> '存量用地'
  135. AND `type` <![CDATA[ <> ]]> '企业注册'
  136. AND del_flag = 0
  137. <if test="businessSearchDto.department != null and businessSearchDto.department != ''">
  138. AND DEPARTMENT = #{businessSearchDto.department}
  139. </if>
  140. <if test="businessSearchDto.status != null and businessSearchDto.status != ''">
  141. AND AFTER_APPROVALSTATUS = null
  142. </if>
  143. <if test="businessSearchDto.week">
  144. AND YEARWEEK( date_format( create_time, '%Y-%m-%d' ) ) = YEARWEEK( now( ) )
  145. </if>
  146. <if test="businessSearchDto.month">
  147. AND DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
  148. </if>
  149. </select>
  150. <select id="getBusinessAcceptNum" resultType="java.lang.Integer">
  151. SELECT
  152. count(*)
  153. FROM
  154. (
  155. SELECT
  156. id,
  157. create_time
  158. FROM
  159. project_application
  160. WHERE
  161. del_flag = 0
  162. AND apply_status != 0 UNION
  163. SELECT
  164. id,
  165. create_time
  166. FROM
  167. project_filling
  168. WHERE
  169. del_flag = 0
  170. AND apply_status != 0 UNION
  171. SELECT
  172. id,
  173. create_time
  174. FROM
  175. project_intelligent
  176. WHERE
  177. del_flag = 0
  178. AND apply_status != 0 UNION
  179. SELECT
  180. id,
  181. create_time
  182. FROM
  183. project_provinces
  184. WHERE
  185. del_flag = 0
  186. AND apply_status != 0 UNION
  187. SELECT
  188. id,
  189. create_time
  190. FROM
  191. project_filling
  192. WHERE
  193. del_flag = 0
  194. AND apply_status != 0 UNION
  195. SELECT
  196. id,
  197. create_time
  198. FROM
  199. project_matters
  200. WHERE
  201. del_flag = 0
  202. AND apply_status != 0
  203. ) a
  204. WHERE 1=1
  205. <if test="businessSearchDto.week">
  206. AND YEARWEEK( date_format( create_time, '%Y-%m-%d' ) ) = YEARWEEK( now( ) )
  207. </if>
  208. <if test="businessSearchDto.month">
  209. AND DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
  210. </if>
  211. </select>
  212. <select id="getWindowBusiness" resultType="platform.modules.government.dto.CenterWindow">
  213. SELECT
  214. COUNT( type = '省市申报' OR NULL ) AS provincesNum,
  215. COUNT( type = '区级智能制造' OR NULL ) AS inteligentNum,
  216. COUNT( type = '服务事项' OR NULL ) AS mattersNum,
  217. COUNT( type = '项目填报' OR NULL ) AS fillingNum,
  218. COUNT( type = '项目申报' OR NULL ) AS projectNum
  219. FROM
  220. z_approval
  221. WHERE
  222. del_flag = 0
  223. AND `type` <![CDATA[ <> ]]>'存量用地'
  224. AND `type` <![CDATA[ <> ]]> '企业注册'
  225. AND CHECKER = #{businessSearchDto.userId}
  226. <if test="businessSearchDto.week">
  227. AND YEARWEEK( date_format( create_time, '%Y-%m-%d' ) ) = YEARWEEK( now( ) )
  228. </if>
  229. <if test="businessSearchDto.month">
  230. AND DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
  231. </if>
  232. </select>
  233. <select id="getMonthStatistical" resultType="platform.modules.government.dto.CenterWindow">
  234. SELECT
  235. COUNT( type = '省市申报' OR NULL ) AS provincesNum,
  236. COUNT( type = '区级智能制造' OR NULL ) AS inteligentNum,
  237. COUNT( type = '服务事项' OR NULL ) AS mattersNum,
  238. COUNT( type = '项目填报' OR NULL ) AS fillingNum,
  239. COUNT( type = '项目申报' OR NULL ) AS projectNum
  240. FROM
  241. z_approval
  242. WHERE
  243. department = '中心窗口'
  244. AND del_flag = 0
  245. AND `type` <![CDATA[ <> ]]>'存量用地'
  246. AND `type` <![CDATA[ <> ]]> '企业注册'
  247. <if test="businessSearchDto.month">
  248. AND YEARWEEK(date_format(create_time,'%Y-%m-%d')) = YEARWEEK(now()) - #{businessSearchDto.xnum}
  249. </if>
  250. <if test="businessSearchDto.year">
  251. AND quarter( create_time ) = quarter(DATE_SUB(now(),interval #{businessSearchDto.xnum} QUARTER))
  252. </if>
  253. </select>
  254. <select id="getOverallAnalysis" resultType="platform.modules.government.dto.GovStatisticsDto">
  255. SELECT
  256. `type`,
  257. COUNT( DISTINCT APPLY_ID ) AS overallNum
  258. FROM
  259. z_approval
  260. WHERE
  261. del_flag = 0
  262. AND `type` <![CDATA[ <> ]]> '企业注册'
  263. <if test="searchCondition.begin_date != null and searchCondition.begin_date !='' ">
  264. <![CDATA[ and DATE_FORMAT(create_time, '%Y-%m-%d')>= DATE_FORMAT(#{searchCondition.begin_date}, '%Y-%m-%d') ]]>
  265. </if>
  266. <if test="searchCondition.end_date != null and searchCondition.end_date !='' ">
  267. <![CDATA[ and DATE_FORMAT(create_time, '%Y-%m-%d')<= DATE_FORMAT(#{searchCondition.end_date}, '%Y-%m-%d') ]]>
  268. </if>
  269. GROUP BY
  270. `type`
  271. </select>
  272. <select id="getDepartmentTrack" resultType="platform.modules.government.dto.AffairsTrackingDto">
  273. SELECT
  274. (
  275. COUNT( type = '省市申报' OR NULL ) +
  276. COUNT( type = '存量用地' OR NULL ) +
  277. COUNT( type = '服务事项' OR NULL ) +
  278. COUNT( type = '项目填报' OR NULL ) +
  279. COUNT( type = '项目申报' OR NULL )
  280. )AS totalHandelNum,
  281. COUNT( type = '省市申报' OR NULL ) AS provincesHandleNum,
  282. COUNT( type = '存量用地' OR NULL ) AS stocklandHandleNum,
  283. COUNT( type = '服务事项' OR NULL ) AS mattersHandleNum,
  284. COUNT( type = '项目填报' OR NULL ) AS fillingHandleNum,
  285. COUNT( type = '项目申报' OR NULL ) AS projectHandleNum
  286. FROM
  287. z_approval
  288. WHERE
  289. `type` <![CDATA[ <> ]]> '企业注册'
  290. AND DEL_FLAG = 0
  291. AND CHECKER IN
  292. <foreach collection="userList" index="index" item="item" open="(" separator="," close=")">
  293. #{item.id}
  294. </foreach>
  295. </select>
  296. <select id="getTrackByUser" resultType="platform.modules.government.dto.CheckTrackingNum">
  297. SELECT
  298. COUNT( * ) AS handleNum
  299. FROM
  300. z_approval
  301. WHERE
  302. DEL_FLAG = 0
  303. AND CHECKER = #{userId}
  304. </select>
  305. <select id="getDocumentByUser" resultType="platform.modules.sys.entity.Approval">
  306. SELECT
  307. *
  308. FROM
  309. z_approval a
  310. WHERE
  311. a.CHECKER = #{searchCondition.userId}
  312. AND del_flag = 0
  313. </select>
  314. <select id="getSearchDocumentByUser" resultType="platform.modules.government.dto.CheckTrackingNum">
  315. SELECT
  316. #{searchCondition.checkName} AS checkName,
  317. businessType,
  318. applyId,
  319. affairsType,
  320. approveTime,
  321. applyNo,
  322. company,
  323. approvalStatus,
  324. applyStatus
  325. FROM
  326. (
  327. SELECT
  328. 1 AS businessType,
  329. a.apply_id AS applyId,
  330. a.type AS affairsType,
  331. a.deal_time AS approveTime,
  332. pa.apply_no AS applyNo,
  333. c.company_name AS company,
  334. i.`value` AS approvalStatus,
  335. i.`name` AS applyStatus
  336. FROM
  337. z_approval a
  338. LEFT JOIN project_application pa ON pa.id = a.APPLY_ID
  339. LEFT JOIN y_company c ON c.id = pa.company_id
  340. LEFT JOIN dictionary_item i ON pa.approve_status = i.`value`
  341. LEFT JOIN dictionary_type t ON t.id = i.tid
  342. WHERE
  343. a.del_flag = 0
  344. AND CHECKER = #{searchCondition.userId}
  345. AND a.type = '项目申报'
  346. AND t.`name` = '项目申报审核状态'
  347. UNION
  348. SELECT
  349. 3 AS businessType,
  350. a.apply_id AS applyId,
  351. a.type AS affairsType,
  352. a.deal_time AS approveTime,
  353. pa.apply_no AS applyNo,
  354. c.company_name AS company,
  355. i.`value` AS approvalStatus,
  356. i.`name` AS applyStatus
  357. FROM
  358. z_approval a
  359. LEFT JOIN project_filling pa ON pa.id = a.APPLY_ID
  360. LEFT JOIN y_company c ON c.id = pa.company_id
  361. LEFT JOIN dictionary_item i ON pa.approve_status = i.`value`
  362. LEFT JOIN dictionary_type t ON t.id = i.tid
  363. WHERE
  364. a.del_flag = 0
  365. AND CHECKER = #{searchCondition.userId}
  366. AND a.type = '项目填报'
  367. AND t.`name` = '项目填报审核状态'
  368. UNION
  369. SELECT
  370. 4 AS businessType,
  371. a.apply_id AS applyId,
  372. a.type AS affairsType,
  373. a.deal_time AS approveTime,
  374. pa.apply_no AS applyNo,
  375. c.company_name AS company,
  376. i.`value` AS approvalStatus,
  377. i.`name` AS applyStatus
  378. FROM
  379. z_approval a
  380. LEFT JOIN project_matters pa ON pa.id = a.APPLY_ID
  381. LEFT JOIN y_company c ON c.id = pa.company_id
  382. LEFT JOIN dictionary_item i ON pa.approve_status = i.`value`
  383. LEFT JOIN dictionary_type t ON t.id = i.tid
  384. WHERE
  385. a.del_flag = 0
  386. AND CHECKER = #{searchCondition.userId}
  387. AND a.type = '服务事项'
  388. AND t.`name` = '服务事项审核状态'
  389. UNION
  390. SELECT
  391. 2 AS businessType,
  392. a.apply_id AS applyId,
  393. a.type AS affairsType,
  394. a.deal_time AS approveTime,
  395. pa.apply_no AS applyNo,
  396. c.company_name AS company,
  397. i.`value` AS approvalStatus,
  398. i.`name` AS applyStatus
  399. FROM
  400. z_approval a
  401. LEFT JOIN project_provinces pa ON pa.id = a.APPLY_ID
  402. LEFT JOIN y_company c ON c.id = pa.company_id
  403. LEFT JOIN dictionary_item i ON pa.approve_status = i.`value`
  404. LEFT JOIN dictionary_type t ON t.id = i.tid
  405. WHERE
  406. a.del_flag = 0
  407. AND CHECKER = #{searchCondition.userId}
  408. AND a.type = '省市申报'
  409. AND t.`name` = '省市申报审核状态'
  410. UNION
  411. SELECT
  412. 5 AS businessType,
  413. a.apply_id AS applyId,
  414. a.type AS affairsType,
  415. a.deal_time AS approveTime,
  416. pa.apply_no AS applyNo,
  417. c.company_name AS company,
  418. i.`value` AS approvalStatus,
  419. i.`name` AS applyStatus
  420. FROM
  421. z_approval a
  422. LEFT JOIN c_stock_land_apply pa ON pa.id = a.APPLY_ID
  423. LEFT JOIN y_company c ON c.id = pa.company_id
  424. LEFT JOIN dictionary_item i ON pa.approve_status = i.`value`
  425. LEFT JOIN dictionary_type t ON t.id = i.tid
  426. WHERE
  427. a.del_flag = 0
  428. AND CHECKER = #{searchCondition.userId}
  429. AND a.type = '存量用地'
  430. AND t.`name` = '存量用地审核状态'
  431. ) t
  432. WHERE 1=1
  433. <if test="searchCondition.businessName != null and searchCondition.businessName !='' ">
  434. AND affairsType = #{searchCondition.businessName}
  435. </if>
  436. <if test="searchCondition.approvalStatus != null and searchCondition.approvalStatus !='' ">
  437. AND approvalStatus = #{searchCondition.approvalStatus}
  438. </if>
  439. <if test="searchCondition.applyNo != null and searchCondition.applyNo !='' ">
  440. AND applyNo LIKE CONCAT('%',#{searchCondition.applyNo},'%')
  441. </if>
  442. <if test="searchCondition.company != null and searchCondition.company !='' ">
  443. AND company LIKE CONCAT('%',#{searchCondition.company},'%')
  444. </if>
  445. <if test="searchCondition.begin_date != null and searchCondition.begin_date !='' ">
  446. AND approveTime <![CDATA[ >= ]]> #{searchCondition.begin_date}
  447. </if>
  448. <if test="searchCondition.end_date != null and searchCondition.end_date !='' ">
  449. AND approveTime <![CDATA[ <= ]]> #{searchCondition.end_date}
  450. </if>
  451. ORDER BY
  452. approveTime DESC
  453. </select>
  454. <select id="getNear3MonthStatistical" resultType="platform.modules.sys.entity.Approval">
  455. SELECT
  456. id,
  457. create_time
  458. FROM
  459. (
  460. SELECT
  461. id,
  462. create_time
  463. FROM
  464. project_application UNION
  465. SELECT
  466. id,
  467. create_time
  468. FROM
  469. project_filling UNION
  470. SELECT
  471. id,
  472. create_time
  473. FROM
  474. project_matters UNION
  475. SELECT
  476. id,
  477. create_time
  478. FROM
  479. project_intelligent UNION
  480. SELECT
  481. id,
  482. create_time
  483. FROM
  484. project_provinces
  485. ) t
  486. WHERE
  487. 1=1
  488. <if test="month == 0">
  489. AND DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
  490. </if>
  491. <if test="month == 1">
  492. AND date_format(create_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL #{month} MONTH),'%Y %m')
  493. </if>
  494. <if test="month == 2">
  495. AND date_format(create_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL #{month} MONTH),'%Y %m')
  496. </if>
  497. </select>
  498. </mapper>