CheckLargeScreenMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  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="com.sundot.airport.check.mapper.CheckLargeScreenMapper">
  6. <select id="planOverview" resultType="com.sundot.airport.check.domain.CheckLargeScreenPlanOverviewDto">
  7. select date_format(ct.check_start_time, '%Y-%m-%d') date,
  8. ct.check_category type,
  9. ct.check_category_desc typeDesc,
  10. count(ct.id) total
  11. from check_task ct
  12. where 1 = 1
  13. <if test="isSelfCheck != null">
  14. and ct.is_self_check=#{isSelfCheck}
  15. </if>
  16. <if test="createId != null">
  17. and ct.create_id=#{createId}
  18. </if>
  19. <if test="deptId != null">
  20. and ct.self_check_dept_id=#{deptId}
  21. </if>
  22. <if test="startDate != null and endDate != null">
  23. and (ct.check_start_time >= #{startDate}
  24. and ct.check_start_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  25. </if>
  26. group by date_format(ct.check_start_time, '%Y-%m-%d'), ct.check_category, ct.check_category_desc
  27. </select>
  28. <select id="planDistribution" resultType="com.sundot.airport.check.domain.CheckLargeScreenCommonDto">
  29. select cpi.category_code_one code, category_name_one name, count(cpi.id) total
  30. from check_task ct
  31. inner join check_project_item cpi on (cpi.source_id = ct.id and cpi.type = 'CHECK_TASK')
  32. where 1 = 1
  33. <if test="isSelfCheck != null">
  34. and ct.is_self_check=#{isSelfCheck}
  35. </if>
  36. <if test="createId != null">
  37. and ct.create_id=#{createId}
  38. </if>
  39. <if test="deptId != null">
  40. and ct.self_check_dept_id=#{deptId}
  41. </if>
  42. <if test="startDate != null and endDate != null">
  43. and (ct.check_start_time >= #{startDate}
  44. and ct.check_start_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  45. </if>
  46. group by cpi.category_code_one, cpi.category_name_one
  47. order by total desc
  48. </select>
  49. <select id="planStatistics" resultType="com.sundot.airport.check.domain.CheckTask">
  50. select ct.*
  51. from check_task ct
  52. where 1 = 1
  53. <if test="isSelfCheck != null">
  54. and ct.is_self_check=#{isSelfCheck}
  55. </if>
  56. <if test="createId != null">
  57. and ct.create_id=#{createId}
  58. </if>
  59. <if test="deptId != null">
  60. and ct.self_check_dept_id=#{deptId}
  61. </if>
  62. <if test="startDate != null and endDate != null">
  63. and (ct.check_start_time >= #{startDate}
  64. and ct.check_start_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  65. </if>
  66. order by ct.check_start_time desc
  67. </select>
  68. <select id="problemDistribution" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  69. select cpi.category_code_one code, cpi.category_name_one name, count(cpi.id) total
  70. from check_correction cc
  71. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  72. where 1 = 1
  73. <if test="isSelfCheck != null">
  74. and cc.is_self_check=#{isSelfCheck}
  75. </if>
  76. <if test="checkedBrigadeId != null">
  77. and cc.checked_brigade_id=#{checkedBrigadeId}
  78. </if>
  79. <if test="checkedDepartmentId != null">
  80. and cc.checked_department_id=#{checkedDepartmentId}
  81. </if>
  82. <if test="checkedTeamId != null">
  83. and cc.checked_team_id=#{checkedTeamId}
  84. </if>
  85. <if test="startDate != null and endDate != null">
  86. and (cc.check_time >= #{startDate}
  87. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  88. </if>
  89. group by cpi.category_code_one, cpi.category_name_one
  90. order by total desc
  91. </select>
  92. <select id="problemComparisonBrigade" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  93. select cc.checked_brigade_id deptId,
  94. cc.checked_brigade_name deptName,
  95. cpi.category_code_one code,
  96. cpi.category_name_one name,
  97. count(cpi.id) total
  98. from check_correction cc
  99. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  100. where 1 = 1
  101. <if test="isSelfCheck != null">
  102. and cc.is_self_check=#{isSelfCheck}
  103. </if>
  104. <if test="checkedBrigadeId != null">
  105. and cc.checked_brigade_id=#{checkedBrigadeId}
  106. </if>
  107. <if test="checkedDepartmentId != null">
  108. and cc.checked_department_id=#{checkedDepartmentId}
  109. </if>
  110. <if test="checkedTeamId != null">
  111. and cc.checked_team_id=#{checkedTeamId}
  112. </if>
  113. <if test="startDate != null and endDate != null">
  114. and (cc.check_time >= #{startDate}
  115. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  116. </if>
  117. group by cc.checked_brigade_id, cc.checked_brigade_name, cpi.category_code_one, cpi.category_name_one
  118. order by total desc
  119. </select>
  120. <select id="problemComparison" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  121. select cc.checked_department_id deptId,
  122. cc.checked_department_name deptName,
  123. cpi.category_code_one code,
  124. cpi.category_name_one name,
  125. count(cpi.id) total
  126. from check_correction cc
  127. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  128. where 1 = 1
  129. <if test="isSelfCheck != null">
  130. and cc.is_self_check=#{isSelfCheck}
  131. </if>
  132. <if test="checkedBrigadeId != null">
  133. and cc.checked_brigade_id=#{checkedBrigadeId}
  134. </if>
  135. <if test="checkedDepartmentId != null">
  136. and cc.checked_department_id=#{checkedDepartmentId}
  137. </if>
  138. <if test="checkedTeamId != null">
  139. and cc.checked_team_id=#{checkedTeamId}
  140. </if>
  141. <if test="startDate != null and endDate != null">
  142. and (cc.check_time >= #{startDate}
  143. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  144. </if>
  145. group by cc.checked_department_id, cc.checked_department_name, cpi.category_code_one, cpi.category_name_one
  146. order by total desc
  147. </select>
  148. <select id="problemComparisonTwoBrigade" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  149. select cc.checked_brigade_id deptId,
  150. cc.checked_brigade_name deptName,
  151. cpi.category_code_two code,
  152. cpi.category_name_two name,
  153. count(cpi.id) total
  154. from check_correction cc
  155. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  156. where 1 = 1
  157. <if test="isSelfCheck != null">
  158. and cc.is_self_check=#{isSelfCheck}
  159. </if>
  160. <if test="checkedBrigadeId != null">
  161. and cc.checked_brigade_id=#{checkedBrigadeId}
  162. </if>
  163. <if test="checkedDepartmentId != null">
  164. and cc.checked_department_id=#{checkedDepartmentId}
  165. </if>
  166. <if test="checkedTeamId != null">
  167. and cc.checked_team_id=#{checkedTeamId}
  168. </if>
  169. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  170. and cpi.category_code_one=#{categoryCodeOne}
  171. </if>
  172. <if test="startDate != null and endDate != null">
  173. and (cc.check_time >= #{startDate}
  174. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  175. </if>
  176. group by cc.checked_brigade_id, cc.checked_brigade_name, cpi.category_code_two, cpi.category_name_two
  177. order by total desc
  178. </select>
  179. <select id="problemComparisonTwo" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  180. select cc.checked_department_id deptId,
  181. cc.checked_department_name deptName,
  182. cpi.category_code_two code,
  183. cpi.category_name_two name,
  184. count(cpi.id) total
  185. from check_correction cc
  186. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  187. where 1 = 1
  188. <if test="isSelfCheck != null">
  189. and cc.is_self_check=#{isSelfCheck}
  190. </if>
  191. <if test="checkedBrigadeId != null">
  192. and cc.checked_brigade_id=#{checkedBrigadeId}
  193. </if>
  194. <if test="checkedDepartmentId != null">
  195. and cc.checked_department_id=#{checkedDepartmentId}
  196. </if>
  197. <if test="checkedTeamId != null">
  198. and cc.checked_team_id=#{checkedTeamId}
  199. </if>
  200. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  201. and cpi.category_code_one=#{categoryCodeOne}
  202. </if>
  203. <if test="startDate != null and endDate != null">
  204. and (cc.check_time >= #{startDate}
  205. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  206. </if>
  207. group by cc.checked_department_id, cc.checked_department_name, cpi.category_code_two, cpi.category_name_two
  208. order by total desc
  209. </select>
  210. <select id="problemComparisonBanZu" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  211. select cc.checked_team_id deptId,
  212. cc.checked_team_name deptName,
  213. cpi.category_code_one code,
  214. cpi.category_name_one name,
  215. count(cpi.id) total
  216. from check_correction cc
  217. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  218. where 1 = 1
  219. <if test="isSelfCheck != null">
  220. and cc.is_self_check=#{isSelfCheck}
  221. </if>
  222. <if test="checkedBrigadeId != null">
  223. and cc.checked_brigade_id=#{checkedBrigadeId}
  224. </if>
  225. <if test="checkedDepartmentId != null">
  226. and cc.checked_department_id=#{checkedDepartmentId}
  227. </if>
  228. <if test="checkedTeamId != null">
  229. and cc.checked_team_id=#{checkedTeamId}
  230. </if>
  231. <if test="startDate != null and endDate != null">
  232. and (cc.check_time >= #{startDate}
  233. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  234. </if>
  235. group by cc.checked_team_id, cc.checked_team_name, cpi.category_code_one, cpi.category_name_one
  236. order by total desc
  237. </select>
  238. <select id="problemComparisonTwoBanZu" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  239. select cc.checked_team_id deptId,
  240. cc.checked_team_name deptName,
  241. cpi.category_code_two code,
  242. cpi.category_name_two name,
  243. count(cpi.id) total
  244. from check_correction cc
  245. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  246. where 1 = 1
  247. <if test="isSelfCheck != null">
  248. and cc.is_self_check=#{isSelfCheck}
  249. </if>
  250. <if test="checkedBrigadeId != null">
  251. and cc.checked_brigade_id=#{checkedBrigadeId}
  252. </if>
  253. <if test="checkedDepartmentId != null">
  254. and cc.checked_department_id=#{checkedDepartmentId}
  255. </if>
  256. <if test="checkedTeamId != null">
  257. and cc.checked_team_id=#{checkedTeamId}
  258. </if>
  259. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  260. and cpi.category_code_one=#{categoryCodeOne}
  261. </if>
  262. <if test="startDate != null and endDate != null">
  263. and (cc.check_time >= #{startDate}
  264. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  265. </if>
  266. group by cc.checked_team_id, cc.checked_team_name, cpi.category_code_two, cpi.category_name_two
  267. order by total desc
  268. </select>
  269. <select id="problemTrendBrigade" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemTrendDto">
  270. select date_format(cc.check_time, '%Y-%m-%d') date,
  271. cc.checked_brigade_id id,
  272. cc.checked_brigade_name name,
  273. count(cpi.id) total
  274. from check_correction cc
  275. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  276. where 1 = 1
  277. <if test="isSelfCheck != null">
  278. and cc.is_self_check=#{isSelfCheck}
  279. </if>
  280. <if test="checkedBrigadeId != null">
  281. and cc.checked_brigade_id=#{checkedBrigadeId}
  282. </if>
  283. <if test="checkedDepartmentId != null">
  284. and cc.checked_department_id=#{checkedDepartmentId}
  285. </if>
  286. <if test="checkedTeamId != null">
  287. and cc.checked_team_id=#{checkedTeamId}
  288. </if>
  289. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  290. and cpi.category_code_one=#{categoryCodeOne}
  291. </if>
  292. <if test="startDate != null and endDate != null">
  293. and (cc.check_time >= #{startDate}
  294. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  295. </if>
  296. group by date_format(cc.check_time, '%Y-%m-%d'), cc.checked_brigade_id, cc.checked_brigade_name
  297. order by total desc
  298. </select>
  299. <select id="problemTrend" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemTrendDto">
  300. select date_format(cc.check_time, '%Y-%m-%d') date,
  301. cc.checked_department_id id,
  302. cc.checked_department_name name,
  303. count(cpi.id) total
  304. from check_correction cc
  305. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  306. where 1 = 1
  307. <if test="isSelfCheck != null">
  308. and cc.is_self_check=#{isSelfCheck}
  309. </if>
  310. <if test="checkedBrigadeId != null">
  311. and cc.checked_brigade_id=#{checkedBrigadeId}
  312. </if>
  313. <if test="checkedDepartmentId != null">
  314. and cc.checked_department_id=#{checkedDepartmentId}
  315. </if>
  316. <if test="checkedTeamId != null">
  317. and cc.checked_team_id=#{checkedTeamId}
  318. </if>
  319. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  320. and cpi.category_code_one=#{categoryCodeOne}
  321. </if>
  322. <if test="startDate != null and endDate != null">
  323. and (cc.check_time >= #{startDate}
  324. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  325. </if>
  326. group by date_format(cc.check_time, '%Y-%m-%d'), cc.checked_department_id, cc.checked_department_name
  327. order by total desc
  328. </select>
  329. <select id="problemTrendBanZu" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemTrendDto">
  330. select date_format(cc.check_time, '%Y-%m-%d') date,
  331. cc.checked_team_id id,
  332. cc.checked_team_name name,
  333. count(cpi.id) total
  334. from check_correction cc
  335. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  336. where 1 = 1
  337. <if test="isSelfCheck != null">
  338. and cc.is_self_check=#{isSelfCheck}
  339. </if>
  340. <if test="checkedBrigadeId != null">
  341. and cc.checked_brigade_id=#{checkedBrigadeId}
  342. </if>
  343. <if test="checkedDepartmentId != null">
  344. and cc.checked_department_id=#{checkedDepartmentId}
  345. </if>
  346. <if test="checkedTeamId != null">
  347. and cc.checked_team_id=#{checkedTeamId}
  348. </if>
  349. <if test="categoryCodeOne != null and categoryCodeOne != ''">
  350. and cpi.category_code_one=#{categoryCodeOne}
  351. </if>
  352. <if test="startDate != null and endDate != null">
  353. and (cc.check_time >= #{startDate}
  354. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  355. </if>
  356. group by date_format(cc.check_time, '%Y-%m-%d'), cc.checked_team_id, cc.checked_team_name
  357. order by total desc
  358. </select>
  359. <select id="correction" resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionAssistDto">
  360. select cc.checked_brigade_id brigadeId,
  361. cc.checked_brigade_name brigadeName,
  362. cc.checked_department_id departmentId,
  363. cc.checked_department_name departmentName,
  364. cc.checked_team_id teamId,
  365. cc.checked_team_name teamName,
  366. case
  367. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  368. then 'ON_TIME_COMPLETED'
  369. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  370. then 'OVER_TIME_COMPLETED'
  371. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  372. then 'ON_TIME_UNFINISHED'
  373. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  374. then 'OVER_TIME_UNFINISHED'
  375. else 'OTHER' end type
  376. from check_correction cc
  377. where 1 = 1
  378. <if test="isSelfCheck != null">
  379. and cc.is_self_check=#{isSelfCheck}
  380. </if>
  381. <if test="startDate != null and endDate != null">
  382. and (cc.check_time >= #{startDate}
  383. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  384. </if>
  385. <if test="checkedBrigadeId != null">
  386. and cc.checked_brigade_id=#{checkedBrigadeId}
  387. </if>
  388. <if test="checkedDepartmentId != null">
  389. and cc.checked_department_id=#{checkedDepartmentId}
  390. </if>
  391. <if test="checkedTeamId != null">
  392. and cc.checked_team_id=#{checkedTeamId}
  393. </if>
  394. </select>
  395. <select id="correctionDistributionBrigade"
  396. resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionDto">
  397. select temp.deptId deptId,
  398. temp.deptName deptName,
  399. ifnull(sum(case when temp.type = 'ON_TIME_COMPLETED' then 1 else 0 end), 0) onTimeCompletedCount,
  400. ifnull(sum(case when temp.type = 'OVER_TIME_COMPLETED' then 1 else 0 end), 0) overTimeCompletedCount,
  401. ifnull(sum(case when temp.type = 'ON_TIME_UNFINISHED' then 1 else 0 end), 0) onTimeUnfinishedCount,
  402. ifnull(sum(case when temp.type = 'OVER_TIME_UNFINISHED' then 1 else 0 end), 0) overTimeUnfinishedCount,
  403. ifnull(sum(case when temp.type = 'OTHER' then 1 else 0 end), 0) otherCount
  404. from (select cc.checked_brigade_id deptId,
  405. cc.checked_brigade_name deptName,
  406. case
  407. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  408. then 'ON_TIME_COMPLETED'
  409. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  410. then 'OVER_TIME_COMPLETED'
  411. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  412. then 'ON_TIME_UNFINISHED'
  413. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  414. then 'OVER_TIME_UNFINISHED'
  415. else 'OTHER' end type
  416. from check_correction cc
  417. where 1 = 1
  418. <if test="isSelfCheck != null">
  419. and cc.is_self_check=#{isSelfCheck}
  420. </if>
  421. <if test="checkedBrigadeId != null">
  422. and cc.checked_brigade_id=#{checkedBrigadeId}
  423. </if>
  424. <if test="checkedDepartmentId != null">
  425. and cc.checked_department_id=#{checkedDepartmentId}
  426. </if>
  427. <if test="checkedTeamId != null">
  428. and cc.checked_team_id=#{checkedTeamId}
  429. </if>
  430. <if test="startDate != null and endDate != null">
  431. and (cc.check_time >= #{startDate}
  432. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  433. </if>) temp
  434. group by temp.deptId, temp.deptName
  435. </select>
  436. <select id="correctionDistribution" resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionDto">
  437. select temp.deptId deptId,
  438. temp.deptName deptName,
  439. ifnull(sum(case when temp.type = 'ON_TIME_COMPLETED' then 1 else 0 end), 0) onTimeCompletedCount,
  440. ifnull(sum(case when temp.type = 'OVER_TIME_COMPLETED' then 1 else 0 end), 0) overTimeCompletedCount,
  441. ifnull(sum(case when temp.type = 'ON_TIME_UNFINISHED' then 1 else 0 end), 0) onTimeUnfinishedCount,
  442. ifnull(sum(case when temp.type = 'OVER_TIME_UNFINISHED' then 1 else 0 end), 0) overTimeUnfinishedCount,
  443. ifnull(sum(case when temp.type = 'OTHER' then 1 else 0 end), 0) otherCount
  444. from (select cc.checked_department_id deptId,
  445. cc.checked_department_name deptName,
  446. case
  447. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  448. then 'ON_TIME_COMPLETED'
  449. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  450. then 'OVER_TIME_COMPLETED'
  451. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  452. then 'ON_TIME_UNFINISHED'
  453. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  454. then 'OVER_TIME_UNFINISHED'
  455. else 'OTHER' end type
  456. from check_correction cc
  457. where 1 = 1
  458. <if test="isSelfCheck != null">
  459. and cc.is_self_check=#{isSelfCheck}
  460. </if>
  461. <if test="checkedBrigadeId != null">
  462. and cc.checked_brigade_id=#{checkedBrigadeId}
  463. </if>
  464. <if test="checkedDepartmentId != null">
  465. and cc.checked_department_id=#{checkedDepartmentId}
  466. </if>
  467. <if test="checkedTeamId != null">
  468. and cc.checked_team_id=#{checkedTeamId}
  469. </if>
  470. <if test="startDate != null and endDate != null">
  471. and (cc.check_time >= #{startDate}
  472. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  473. </if>) temp
  474. group by temp.deptId, temp.deptName
  475. </select>
  476. <select id="correctionDistributionBanZu" resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionDto">
  477. select temp.deptId deptId,
  478. temp.deptName deptName,
  479. ifnull(sum(case when temp.type = 'ON_TIME_COMPLETED' then 1 else 0 end), 0) onTimeCompletedCount,
  480. ifnull(sum(case when temp.type = 'OVER_TIME_COMPLETED' then 1 else 0 end), 0) overTimeCompletedCount,
  481. ifnull(sum(case when temp.type = 'ON_TIME_UNFINISHED' then 1 else 0 end), 0) onTimeUnfinishedCount,
  482. ifnull(sum(case when temp.type = 'OVER_TIME_UNFINISHED' then 1 else 0 end), 0) overTimeUnfinishedCount,
  483. ifnull(sum(case when temp.type = 'OTHER' then 1 else 0 end), 0) otherCount
  484. from (select cc.checked_team_id deptId,
  485. cc.checked_team_name deptName,
  486. case
  487. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  488. then 'ON_TIME_COMPLETED'
  489. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  490. then 'OVER_TIME_COMPLETED'
  491. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  492. then 'ON_TIME_UNFINISHED'
  493. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  494. then 'OVER_TIME_UNFINISHED'
  495. else 'OTHER' end type
  496. from check_correction cc
  497. where 1 = 1
  498. <if test="isSelfCheck != null">
  499. and cc.is_self_check=#{isSelfCheck}
  500. </if>
  501. <if test="checkedBrigadeId != null">
  502. and cc.checked_brigade_id=#{checkedBrigadeId}
  503. </if>
  504. <if test="checkedDepartmentId != null">
  505. and cc.checked_department_id=#{checkedDepartmentId}
  506. </if>
  507. <if test="checkedTeamId != null">
  508. and cc.checked_team_id=#{checkedTeamId}
  509. </if>
  510. <if test="startDate != null and endDate != null">
  511. and (cc.check_time >= #{startDate}
  512. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  513. </if>) temp
  514. group by temp.deptId, temp.deptName
  515. </select>
  516. <select id="inspectionExecute" resultType="com.sundot.airport.check.domain.CheckLargeScreenInspectionExecuteDto">
  517. select ct.id taskId,
  518. ct.task_code taskCode,
  519. ct.task_name taskName,
  520. ct.check_level checkLevel,
  521. ct.check_level_desc checkLevelDesc,
  522. ct.rule_type_num ruleTypeNum,
  523. ct.check_start_time checkStartTime,
  524. ct.check_end_time checkEndTime
  525. from check_task ct
  526. where 1 = 1
  527. and current_date() between ct.check_start_time and ct.check_end_time
  528. </select>
  529. <select id="inspectionExecuteItem"
  530. resultType="com.sundot.airport.check.domain.CheckLargeScreenInspectionExecuteItemDto">
  531. select cr.task_code taskCode,
  532. cr.checker_id userId,
  533. cr.checker_name userName,
  534. count(distinct cr.id) checkOrderCount,
  535. count(distinct cc.id) rectificationOrderCount,
  536. count(distinct cpi.id) unqualifiedProjectCount
  537. from check_record cr
  538. left join check_correction cc on cc.check_record_id = cr.id
  539. left join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  540. where 1 = 1
  541. and cr.task_code in
  542. <foreach item="item" collection="list" open="(" separator="," close=")">
  543. #{item}
  544. </foreach>
  545. and (cr.check_time
  546. between concat(curdate(), ' 00:00:00') and concat(date_add(curdate(), interval 1 day), ' 00:00:00'))
  547. group by cr.task_code, cr.checker_id, cr.checker_name
  548. </select>
  549. <select id="inspectionExecuteUser"
  550. resultType="com.sundot.airport.check.domain.CheckLargeScreenInspectionExecuteUserDto">
  551. select su.user_id,
  552. su.user_name,
  553. su.nick_name,
  554. su.dept_id,
  555. sr.role_id,
  556. sr.role_name,
  557. sr.role_key
  558. from sys_user su
  559. inner join sys_user_role sur on su.user_id = sur.user_id
  560. inner join sys_role sr on sr.role_id = sur.role_id
  561. where 1 = 1
  562. and su.del_flag = '0'
  563. and sr.del_flag = '0'
  564. and su.user_id in
  565. <foreach item="item" collection="list" open="(" separator="," close=")">
  566. #{item}
  567. </foreach>
  568. </select>
  569. <select id="getProblemBrigade" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  570. select distinct cc.checked_brigade_id deptId,
  571. cc.checked_brigade_name deptName
  572. from check_correction cc
  573. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  574. where 1 = 1
  575. <if test="isSelfCheck != null">
  576. and cc.is_self_check=#{isSelfCheck}
  577. </if>
  578. <if test="checkedBrigadeId != null">
  579. and cc.checked_brigade_id=#{checkedBrigadeId}
  580. </if>
  581. <if test="checkedDepartmentId != null">
  582. and cc.checked_department_id=#{checkedDepartmentId}
  583. </if>
  584. <if test="checkedTeamId != null">
  585. and cc.checked_team_id=#{checkedTeamId}
  586. </if>
  587. <if test="startDate != null and endDate != null">
  588. and (cc.check_time >= #{startDate}
  589. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  590. </if>
  591. </select>
  592. <select id="getProblemDepartment" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  593. select distinct cc.checked_department_id deptId,
  594. cc.checked_department_name deptName
  595. from check_correction cc
  596. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  597. where 1 = 1
  598. <if test="isSelfCheck != null">
  599. and cc.is_self_check=#{isSelfCheck}
  600. </if>
  601. <if test="checkedBrigadeId != null">
  602. and cc.checked_brigade_id=#{checkedBrigadeId}
  603. </if>
  604. <if test="checkedDepartmentId != null">
  605. and cc.checked_department_id=#{checkedDepartmentId}
  606. </if>
  607. <if test="checkedTeamId != null">
  608. and cc.checked_team_id=#{checkedTeamId}
  609. </if>
  610. <if test="startDate != null and endDate != null">
  611. and (cc.check_time >= #{startDate}
  612. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  613. </if>
  614. </select>
  615. <select id="getProblemTeam" resultType="com.sundot.airport.check.domain.CheckLargeScreenProblemDto">
  616. select distinct cc.checked_team_id deptId,
  617. cc.checked_team_name deptName
  618. from check_correction cc
  619. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  620. where 1 = 1
  621. <if test="isSelfCheck != null">
  622. and cc.is_self_check=#{isSelfCheck}
  623. </if>
  624. <if test="checkedBrigadeId != null">
  625. and cc.checked_brigade_id=#{checkedBrigadeId}
  626. </if>
  627. <if test="checkedDepartmentId != null">
  628. and cc.checked_department_id=#{checkedDepartmentId}
  629. </if>
  630. <if test="checkedTeamId != null">
  631. and cc.checked_team_id=#{checkedTeamId}
  632. </if>
  633. <if test="startDate != null and endDate != null">
  634. and (cc.check_time >= #{startDate}
  635. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  636. </if>
  637. </select>
  638. <select id="portrait" resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionPortraitSqlDto">
  639. select cc.id id,
  640. cc.checked_brigade_id checkedBrigadeId,
  641. cc.checked_brigade_name checkedBrigadeName,
  642. cc.checked_department_id checkedDepartmentId,
  643. cc.checked_department_name checkedDepartmentName,
  644. cc.checked_team_id checkedTeamId,
  645. cc.checked_team_name checkedTeamName,
  646. cpi.category_code_one categoryCodeOne,
  647. cpi.category_name_one categoryNameOne,
  648. cpi.category_code_two categoryCodeTwo,
  649. cpi.category_name_two categoryNameTwo,
  650. cu.user_id userId,
  651. cu.user_name userName,
  652. case
  653. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  654. then 'ON_TIME_COMPLETED'
  655. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  656. then 'OVER_TIME_COMPLETED'
  657. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  658. then 'ON_TIME_UNFINISHED'
  659. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  660. then 'OVER_TIME_UNFINISHED'
  661. else 'OTHER' end correctionType
  662. from check_correction cc
  663. inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  664. inner join check_user cu
  665. on (cu.source_id = cpi.id and cu.type = 'PROBLEM_RECTIFICATION_INSPECTION_ITEM_DETAILS')
  666. where 1 = 1
  667. <if test="isSelfCheck != null">
  668. and cc.is_self_check=#{isSelfCheck}
  669. </if>
  670. <if test="processStatus != null">
  671. and cc.process_status=#{processStatus}
  672. </if>
  673. <if test="checkedBrigadeId != null">
  674. and cc.checked_brigade_id=#{checkedBrigadeId}
  675. </if>
  676. <if test="checkedDepartmentId != null">
  677. and cc.checked_department_id=#{checkedDepartmentId}
  678. </if>
  679. <if test="checkedTeamId != null">
  680. and cc.checked_team_id=#{checkedTeamId}
  681. </if>
  682. <if test="checkedUserId != null">
  683. and cu.user_id=#{checkedUserId}
  684. </if>
  685. <if test="specifiedDate != null and specifiedDate != null">
  686. and DATE(cc.check_time) = DATE(#{specifiedDate})
  687. </if>
  688. <if test="startDate != null and endDate != null">
  689. and (cc.check_time >= #{startDate}
  690. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  691. </if>
  692. </select>
  693. <select id="managementPromotionRecord" resultType="com.sundot.airport.check.domain.CheckLargeScreenPlanOverviewDto">
  694. select date_format(cr.check_time, '%Y-%m-%d') date,
  695. ct.check_category type,
  696. ct.check_category_desc typeDesc,
  697. count(cr.id) total
  698. from check_task ct
  699. inner join check_record cr on cr.task_code = ct.task_code
  700. where 1 = 1
  701. <if test="isSelfCheck != null">
  702. and ct.is_self_check=#{isSelfCheck}
  703. </if>
  704. <if test="checkedBrigadeId != null">
  705. and cr.checked_brigade_id=#{checkedBrigadeId}
  706. </if>
  707. <if test="checkedDepartmentId != null">
  708. and cr.checked_department_id=#{checkedDepartmentId}
  709. </if>
  710. <if test="checkedTeamId != null">
  711. and cr.checked_team_id=#{checkedTeamId}
  712. </if>
  713. <if test="startDate != null and endDate != null">
  714. and (cr.check_time >= #{startDate}
  715. and cr.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  716. </if>
  717. group by date_format(cr.check_time, '%Y-%m-%d'), ct.check_category, ct.check_category_desc
  718. order by date desc
  719. </select>
  720. <select id="managementPromotionCorrection"
  721. resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionDto">
  722. select ifnull(sum(case when temp.type = 'ON_TIME_COMPLETED' then 1 else 0 end), 0) onTimeCompletedCount,
  723. ifnull(sum(case when temp.type = 'OVER_TIME_COMPLETED' then 1 else 0 end), 0) overTimeCompletedCount,
  724. ifnull(sum(case when temp.type = 'ON_TIME_UNFINISHED' then 1 else 0 end), 0) onTimeUnfinishedCount,
  725. ifnull(sum(case when temp.type = 'OVER_TIME_UNFINISHED' then 1 else 0 end), 0) overTimeUnfinishedCount,
  726. ifnull(sum(case when temp.type = 'OTHER' then 1 else 0 end), 0) otherCount
  727. from (select
  728. case
  729. when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
  730. then 'ON_TIME_COMPLETED'
  731. when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
  732. then 'OVER_TIME_COMPLETED'
  733. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
  734. then 'ON_TIME_UNFINISHED'
  735. when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
  736. then 'OVER_TIME_UNFINISHED'
  737. else 'OTHER' end type
  738. from check_correction cc
  739. where 1 = 1
  740. <if test="isSelfCheck != null">
  741. and cc.is_self_check=#{isSelfCheck}
  742. </if>
  743. <if test="processStatus != null">
  744. and cc.process_status=#{processStatus}
  745. </if>
  746. <if test="checkedBrigadeId != null">
  747. and cc.checked_brigade_id=#{checkedBrigadeId}
  748. </if>
  749. <if test="checkedDepartmentId != null">
  750. and cc.checked_department_id=#{checkedDepartmentId}
  751. </if>
  752. <if test="checkedTeamId != null">
  753. and cc.checked_team_id=#{checkedTeamId}
  754. </if>
  755. <if test="startDate != null and endDate != null">
  756. and (cc.check_time >= #{startDate}
  757. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  758. </if>) temp
  759. </select>
  760. <select id="homePageCheckRecord"
  761. resultType="com.sundot.airport.check.domain.CheckLargeScreenHomePageCheckRecordSqlDto">
  762. select cr.id id,
  763. cr.document_code documentCode,
  764. cr.document_name documentName,
  765. cr.checker_id checkerId,
  766. cr.checker_name checkerName,
  767. date_format(cr.check_time, '%Y-%m-%d %H:%i:%s') checkTime,
  768. cr.check_level checkLevel,
  769. cr.check_level_desc checkLevelDesc,
  770. cr.checked_level checkedLevel,
  771. cr.checked_level_desc checkedLevelDesc,
  772. cr.checked_brigade_id checkedBrigadeId,
  773. cr.checked_brigade_name checkedBrigadeName,
  774. cr.checked_department_id checkedDepartmentId,
  775. cr.checked_department_name checkedDepartmentName,
  776. cr.checked_team_id checkedTeamId,
  777. cr.checked_team_name checkedTeamName,
  778. cr.checked_personnel_id checkedPersonnelId,
  779. cr.checked_personnel_name checkedPersonnelName,
  780. cr.checked_dept_id checkedDeptId,
  781. cr.checked_dept_name checkedDeptName,
  782. cr.responsible_user_id responsibleUserId,
  783. cr.responsible_user_name responsibleUserName,
  784. cr.check_result checkResult,
  785. cr.check_result_desc checkResultDesc,
  786. cpi.score_level scoreLevel,
  787. cpi.score_level_desc scoreLevelDesc,
  788. cr.check_record_status checkRecordStatus,
  789. cr.check_record_status_desc checkRecordStatusDesc,
  790. cu.user_id userId,
  791. cu.user_name userName
  792. from check_record cr
  793. left join check_project_item cpi on (cpi.source_id = cr.id and cpi.type = 'CHECK_RECORDS')
  794. left join check_user cu on (cu.source_id = cpi.id and cu.type = 'INSPECT_RECORDS_INSPECTION_ITEM_DETAILS')
  795. where 1 = 1
  796. <if test="specifiedDate != null">
  797. and cr.check_time >= #{specifiedDate}
  798. and cr.check_time <![CDATA[ < ]]> DATE_ADD(#{specifiedDate}, INTERVAL 1 DAY)
  799. </if>
  800. <if test="startDate != null and endDate != null">
  801. and (cr.check_time >= #{startDate}
  802. and cr.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  803. </if>
  804. </select>
  805. <select id="homePageCheckCorrection"
  806. resultType="com.sundot.airport.check.domain.CheckLargeScreenHomePageCheckCorrectionSqlDto">
  807. select cc.id id,
  808. cc.document_code documentCode,
  809. cc.document_name documentName,
  810. cc.checker_id checkerId,
  811. cc.checker_name checkerName,
  812. date_format(cc.check_time, '%Y-%m-%d %H:%i:%s') checkTime,
  813. cc.check_level checkLevel,
  814. cc.check_level_desc checkLevelDesc,
  815. cc.checked_level checkedLevel,
  816. cc.checked_level_desc checkedLevelDesc,
  817. cc.checked_brigade_id checkedBrigadeId,
  818. cc.checked_brigade_name checkedBrigadeName,
  819. cc.checked_department_id checkedDepartmentId,
  820. cc.checked_department_name checkedDepartmentName,
  821. cc.checked_team_id checkedTeamId,
  822. cc.checked_team_name checkedTeamName,
  823. cc.checked_personnel_id checkedPersonnelId,
  824. cc.checked_personnel_name checkedPersonnelName,
  825. cc.checked_dept_id checkedDeptId,
  826. cc.checked_dept_name checkedDeptName,
  827. cc.responsible_user_id responsibleUserId,
  828. cc.responsible_user_name responsibleUserName,
  829. cc.process_status processStatus,
  830. cc.process_status_desc processStatusDesc,
  831. cc.instance_id instanceId,
  832. date_format(cc.completion_time, '%Y-%m-%d %H:%i:%s') completionTime,
  833. cu.user_id userId,
  834. cu.user_name userName
  835. from check_correction cc
  836. left join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
  837. left join check_user cu
  838. on (cu.source_id = cpi.id and cu.type = 'PROBLEM_RECTIFICATION_INSPECTION_ITEM_DETAILS')
  839. where 1 = 1
  840. <if test="specifiedDate != null">
  841. and DATE(cc.check_time) = DATE(#{specifiedDate})
  842. </if>
  843. <if test="startDate != null and endDate != null">
  844. and (cc.check_time >= #{startDate}
  845. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  846. </if>
  847. </select>
  848. <select id="checkCorrectionCount"
  849. resultType="java.lang.Integer">
  850. select count(1)
  851. from check_correction cc
  852. where 1 = 1
  853. <if test="userId != null">
  854. and cc.checker_id = #{userId}
  855. </if>
  856. <if test="specifiedDate != null">
  857. and DATE(cc.check_time) = DATE(#{specifiedDate})
  858. </if>
  859. <if test="startDate != null and endDate != null">
  860. and (cc.check_time >= #{startDate}
  861. and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
  862. </if>
  863. </select>
  864. </mapper>