BlockedDashboardMapper.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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.blocked.mapper.BlockedDashboardMapper">
  6. <resultMap type="java.lang.Integer" id="BlockedCountResult">
  7. <result property="count" column="total_count"/>
  8. </resultMap>
  9. <!-- 查询查堵总数-->
  10. <select id="selectTotalBlockedCountWithoutBrigade" resultType="java.lang.Integer">
  11. SELECT COALESCE(SUM(total_blocked_count), 0) as total_count
  12. FROM blocked_luggage_statistics_daily
  13. WHERE del_flag = '0'
  14. <if test="startTime != null and endTime != null">
  15. AND stat_date &gt;= #{startTime}
  16. AND stat_date &lt;= #{endTime}
  17. </if>
  18. </select>
  19. <!-- 查询查堵总数-->
  20. <select id="selectTotalBlockedCountWithBrigade" resultType="java.lang.Integer">
  21. SELECT COUNT(1) as total_count
  22. FROM blocked_miss_check_statistics
  23. WHERE del_flag = '0'
  24. AND brigade_id = #{brigadeId}
  25. <if test="startTime != null and endTime != null">
  26. AND review_date &gt;= #{startTime}
  27. AND review_date &lt;= #{endTime}
  28. </if>
  29. <if test="terminalId != null">
  30. AND terminal_id = #{terminalId}
  31. </if>
  32. <if test="supervisorId != null">
  33. AND supervisor_id = #{supervisorId}
  34. </if>
  35. <if test="teamLeaderId != null">
  36. AND team_leader_id = #{teamLeaderId}
  37. </if>
  38. <if test="missCheckItem != null and missCheckItem != ''">
  39. AND miss_check_item = #{missCheckItem}
  40. </if>
  41. </select>
  42. <!-- 查询各大队查堵总数(用于柱状图) -->
  43. <select id="selectBlockedCountByBrigade" resultType="com.sundot.airport.blocked.dto.BlockedBrigadeStatsDTO">
  44. SELECT
  45. brigade_id as brigadeId,
  46. brigade_name as brigadeName,
  47. COALESCE(SUM(total_blocked_count), 0) as totalBlockedCount
  48. FROM blocked_luggage_statistics_daily
  49. WHERE del_flag = '0'
  50. <if test="startTime != null and endTime != null">
  51. AND stat_date &gt;= #{startTime}
  52. AND stat_date &lt;= #{endTime}
  53. </if>
  54. GROUP BY brigade_id, brigade_name
  55. ORDER BY totalBlockedCount DESC
  56. </select>
  57. <!-- 查询总查堵万分率(所有大队平均值) -->
  58. <select id="selectTotalBlockedRate" resultType="java.math.BigDecimal">
  59. SELECT COALESCE(AVG(daily_block_rate), 0) as totalBlockedRate
  60. FROM blocked_luggage_statistics_daily
  61. WHERE del_flag = '0'
  62. <if test="startTime != null and endTime != null">
  63. AND stat_date &gt;= #{startTime}
  64. AND stat_date &lt;= #{endTime}
  65. </if>
  66. </select>
  67. <!-- 查询各大队平均查堵万分率(用于条形图) -->
  68. <select id="selectBlockedRateByBrigade" resultType="com.sundot.airport.blocked.dto.BlockedBrigadeRateStatsDTO">
  69. SELECT
  70. brigade_id as brigadeId,
  71. brigade_name as brigadeName,
  72. COALESCE(AVG(daily_block_rate), 0) as avgBlockedRate
  73. FROM blocked_luggage_statistics_daily
  74. WHERE del_flag = '0'
  75. <if test="startTime != null and endTime != null">
  76. AND stat_date &gt;= #{startTime}
  77. AND stat_date &lt;= #{endTime}
  78. </if>
  79. GROUP BY brigade_id, brigade_name
  80. ORDER BY avgBlockedRate DESC
  81. </select>
  82. <!-- 查询每日查堵合计件数(用于趋势图) -->
  83. <select id="selectBlockedCountByDate" resultType="com.sundot.airport.blocked.dto.BlockedDailyStatsDTO">
  84. SELECT
  85. stat_date as statDate,
  86. COALESCE(SUM(total_blocked_count), 0) as totalBlockedCount
  87. FROM blocked_luggage_statistics_daily
  88. WHERE del_flag = '0'
  89. <if test="startTime != null and endTime != null">
  90. AND stat_date &gt;= #{startTime}
  91. AND stat_date &lt;= #{endTime}
  92. </if>
  93. GROUP BY stat_date
  94. ORDER BY stat_date ASC
  95. </select>
  96. <!-- 查询每日各大队查堵合计件数(用于大队对比表) -->
  97. <select id="selectBlockedCountByDateAndBrigade" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeStatsDTO">
  98. SELECT
  99. stat_date as statDate,
  100. brigade_id as brigadeId,
  101. brigade_name as brigadeName,
  102. COALESCE(SUM(total_blocked_count), 0) as totalBlockedCount
  103. FROM blocked_luggage_statistics_daily
  104. WHERE del_flag = '0'
  105. <if test="startTime != null and endTime != null">
  106. AND stat_date &gt;= #{startTime}
  107. AND stat_date &lt;= #{endTime}
  108. </if>
  109. GROUP BY stat_date, brigade_id, brigade_name
  110. ORDER BY stat_date ASC, brigade_id ASC
  111. </select>
  112. <!-- 查询每日平均查堵万分率(用于趋势图) -->
  113. <select id="selectBlockedRateByDate" resultType="com.sundot.airport.blocked.dto.BlockedDailyRateStatsDTO">
  114. SELECT
  115. stat_date as statDate,
  116. COALESCE(AVG(daily_block_rate), 0) as avgBlockedRate
  117. FROM blocked_luggage_statistics_daily
  118. WHERE del_flag = '0'
  119. <if test="startTime != null and endTime != null">
  120. AND stat_date &gt;= #{startTime}
  121. AND stat_date &lt;= #{endTime}
  122. </if>
  123. GROUP BY stat_date
  124. ORDER BY stat_date ASC
  125. </select>
  126. <!-- 查询每日各大队平均查堵万分率(用于大队对比表) -->
  127. <select id="selectBlockedRateByDateAndBrigade" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeRateStatsDTO">
  128. SELECT
  129. stat_date as statDate,
  130. brigade_id as brigadeId,
  131. brigade_name as brigadeName,
  132. COALESCE(AVG(daily_block_rate), 0) as avgBlockedRate
  133. FROM blocked_luggage_statistics_daily
  134. WHERE del_flag = '0'
  135. <if test="startTime != null and endTime != null">
  136. AND stat_date &gt;= #{startTime}
  137. AND stat_date &lt;= #{endTime}
  138. </if>
  139. GROUP BY stat_date, brigade_id, brigade_name
  140. ORDER BY stat_date ASC, brigade_id ASC
  141. </select>
  142. <!-- 查询每日过检行李合计(用于趋势图) -->
  143. <select id="selectTotalLuggageCountByDate" resultType="com.sundot.airport.blocked.dto.BlockedDailyLuggageStatsDTO">
  144. SELECT
  145. stat_date as statDate,
  146. COALESCE(SUM(total_luggage_count), 0) as totalLuggageCount
  147. FROM blocked_luggage_statistics_daily
  148. WHERE del_flag = '0'
  149. <if test="startTime != null and endTime != null">
  150. AND stat_date &gt;= #{startTime}
  151. AND stat_date &lt;= #{endTime}
  152. </if>
  153. GROUP BY stat_date
  154. ORDER BY stat_date ASC
  155. </select>
  156. <!-- 查询每日各大队过检行李合计(用于大队对比表) -->
  157. <select id="selectTotalLuggageCountByDateAndBrigade" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeLuggageStatsDTO">
  158. SELECT
  159. stat_date as statDate,
  160. brigade_id as brigadeId,
  161. brigade_name as brigadeName,
  162. COALESCE(SUM(total_luggage_count), 0) as totalLuggageCount
  163. FROM blocked_luggage_statistics_daily
  164. WHERE del_flag = '0'
  165. <if test="startTime != null and endTime != null">
  166. AND stat_date &gt;= #{startTime}
  167. AND stat_date &lt;= #{endTime}
  168. </if>
  169. GROUP BY stat_date, brigade_id, brigade_name
  170. ORDER BY stat_date ASC, brigade_id ASC
  171. </select>
  172. <!-- 查询查堵物品分布(用于扇形图) -->
  173. <select id="selectItemDistribution" resultType="com.sundot.airport.blocked.dto.BlockedItemDistributionDTO">
  174. SELECT
  175. miss_check_item as missCheckItem,
  176. COUNT(1) as count
  177. FROM blocked_miss_check_statistics
  178. WHERE del_flag = '0'
  179. AND miss_check_item IS NOT NULL
  180. AND miss_check_item != ''
  181. <if test="startTime != null and endTime != null">
  182. AND review_date &gt;= #{startTime}
  183. AND review_date &lt;= #{endTime}
  184. </if>
  185. <if test="brigadeId != null">
  186. AND brigade_id = #{brigadeId}
  187. </if>
  188. <if test="terminalId != null">
  189. AND terminal_id = #{terminalId}
  190. </if>
  191. <if test="supervisorId != null">
  192. AND supervisor_id = #{supervisorId}
  193. </if>
  194. <if test="teamLeaderId != null">
  195. AND team_leader_id = #{teamLeaderId}
  196. </if>
  197. <if test="missCheckItem != null and missCheckItem != ''">
  198. AND miss_check_item = #{missCheckItem}
  199. </if>
  200. GROUP BY miss_check_item
  201. ORDER BY count DESC
  202. </select>
  203. <!-- 查询区域查堵数据分布-过检行李数(柱状图) -->
  204. <select id="selectAreaLuggageDistribution" resultType="com.sundot.airport.blocked.dto.BlockedAreaLuggageDTO">
  205. SELECT
  206. brigade_name as brigadeName,
  207. COALESCE(SUM(t1_travel_luggage_count), 0) as t1PassengerLuggageCount,
  208. COALESCE(SUM(t2_travel_luggage_count), 0) as t2PassengerLuggageCount,
  209. COALESCE(SUM(t1_walk_luggage_count), 0) as t1CargoLuggageCount,
  210. COALESCE(SUM(t2_walk_luggage_count), 0) as t2CargoLuggageCount
  211. FROM blocked_luggage_statistics_daily
  212. WHERE del_flag = '0'
  213. AND brigade_id IS NOT NULL
  214. <if test="startTime != null and endTime != null">
  215. AND stat_date &gt;= #{startTime}
  216. AND stat_date &lt;= #{endTime}
  217. </if>
  218. <if test="brigadeId != null">
  219. AND brigade_id = #{brigadeId}
  220. </if>
  221. GROUP BY brigade_id, brigade_name
  222. ORDER BY brigade_id
  223. </select>
  224. <!-- 查询区域查堵数据分布-查堵件数(折线图) -->
  225. <select id="selectAreaBlockedDistribution" resultType="com.sundot.airport.blocked.dto.BlockedAreaBlockedDTO">
  226. SELECT
  227. brigade_name as brigadeName,
  228. COALESCE(SUM(t1_travel_blocked_count), 0) as t1PassengerBlockedCount,
  229. COALESCE(SUM(t2_travel_blocked_count), 0) as t2PassengerBlockedCount,
  230. COALESCE(SUM(t1_walk_blocked_count), 0) as t1CargoBlockedCount,
  231. COALESCE(SUM(t2_walk_blocked_count), 0) as t2CargoBlockedCount
  232. FROM blocked_luggage_statistics_daily
  233. WHERE del_flag = '0'
  234. AND brigade_id IS NOT NULL
  235. <if test="startTime != null and endTime != null">
  236. AND stat_date &gt;= #{startTime}
  237. AND stat_date &lt;= #{endTime}
  238. </if>
  239. <if test="brigadeId != null">
  240. AND brigade_id = #{brigadeId}
  241. </if>
  242. GROUP BY brigade_id, brigade_name
  243. ORDER BY brigade_id
  244. </select>
  245. <!-- 查询查堵类型分布(用于分组柱状图) -->
  246. <select id="selectDiscriminationDistribution" resultType="com.sundot.airport.blocked.dto.BlockedDiscriminationDistributionDTO">
  247. SELECT
  248. miss_check_item as missCheckItem,
  249. discrimination_type as discriminationType,
  250. COUNT(1) as count
  251. FROM blocked_miss_check_statistics
  252. WHERE del_flag = '0'
  253. AND miss_check_item IS NOT NULL
  254. AND miss_check_item != ''
  255. AND discrimination_type IS NOT NULL
  256. AND discrimination_type != ''
  257. <if test="startTime != null and endTime != null">
  258. AND review_date &gt;= #{startTime}
  259. AND review_date &lt;= #{endTime}
  260. </if>
  261. <if test="brigadeId != null">
  262. AND brigade_id = #{brigadeId}
  263. </if>
  264. <if test="terminalId != null">
  265. AND terminal_id = #{terminalId}
  266. </if>
  267. <if test="supervisorId != null">
  268. AND supervisor_id = #{supervisorId}
  269. </if>
  270. <if test="teamLeaderId != null">
  271. AND team_leader_id = #{teamLeaderId}
  272. </if>
  273. <if test="missCheckItem != null and missCheckItem != ''">
  274. AND miss_check_item = #{missCheckItem}
  275. </if>
  276. GROUP BY miss_check_item, discrimination_type
  277. ORDER BY miss_check_item, count DESC
  278. </select>
  279. <!-- 查询查堵时间段过检行李数及万分率(用于双轴图表) -->
  280. <select id="selectTimePeriodStats" resultType="com.sundot.airport.blocked.dto.BlockedTimePeriodStatsDTO">
  281. SELECT
  282. time_period as timePeriod,
  283. COALESCE(SUM(total_luggage_count), 0) as totalLuggageCount,
  284. COALESCE(SUM(total_blocked_count), 0) as totalBlockedCount,
  285. COALESCE(AVG(blocked_rate), 0) as blockRate
  286. FROM blocked_luggage_piece_daily
  287. WHERE del_flag = '0'
  288. AND time_period IS NOT NULL
  289. AND time_period != ''
  290. <if test="startTime != null and endTime != null">
  291. AND stat_date &gt;= #{startTime}
  292. AND stat_date &lt;= #{endTime}
  293. </if>
  294. <if test="brigadeId != null">
  295. AND brigade_id = #{brigadeId}
  296. </if>
  297. GROUP BY time_period
  298. ORDER BY MIN(time_period)
  299. </select>
  300. <!-- 查询每日过检行李数及万分率(用于双轴图表) -->
  301. <select id="selectDailyLuggageAndRate" resultType="com.sundot.airport.blocked.dto.BlockedTimePeriodStatsDTO">
  302. SELECT
  303. DATE_FORMAT(stat_date, '%Y-%m-%d') as timePeriod,
  304. COALESCE(SUM(total_luggage_count), 0) as totalLuggageCount,
  305. COALESCE(SUM(total_blocked_count), 0) as totalBlockedCount,
  306. COALESCE(AVG(daily_block_rate), 0) as blockRate
  307. FROM blocked_luggage_statistics_daily
  308. WHERE del_flag = '0'
  309. <if test="startTime != null and endTime != null">
  310. AND stat_date &gt;= #{startTime}
  311. AND stat_date &lt;= #{endTime}
  312. </if>
  313. <if test="brigadeId != null">
  314. AND brigade_id = #{brigadeId}
  315. </if>
  316. GROUP BY stat_date
  317. ORDER BY stat_date ASC
  318. </select>
  319. <!-- 查询查堵-AI复查图像总数(用于双系列图表) -->
  320. <select id="selectAiImageStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyStatsDTO">
  321. SELECT
  322. DATE_FORMAT(stat_date, '%Y-%m-%d') as statDate,
  323. COALESCE(SUM(ai_review_image_total), 0) as totalBlockedCount,
  324. COALESCE(SUM(ai_mark_total), 0) as dailyBlockedCount
  325. FROM blocked_luggage_statistics_daily
  326. WHERE del_flag = '0'
  327. <if test="startTime != null and endTime != null">
  328. AND stat_date &gt;= #{startTime}
  329. AND stat_date &lt;= #{endTime}
  330. </if>
  331. <if test="brigadeId != null">
  332. AND brigade_id = #{brigadeId}
  333. </if>
  334. GROUP BY stat_date
  335. ORDER BY stat_date ASC
  336. </select>
  337. <!-- 查询查堵-AI漏判图像总数(用于单系列图表) -->
  338. <select id="selectAiMissImageStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyStatsDTO">
  339. SELECT
  340. DATE_FORMAT(stat_date, '%Y-%m-%d') as statDate,
  341. COALESCE(SUM(ai_miss_image_total), 0) as totalBlockedCount,
  342. 0 as dailyBlockedCount
  343. FROM blocked_luggage_statistics_daily
  344. WHERE del_flag = '0'
  345. <if test="startTime != null and endTime != null">
  346. AND stat_date &gt;= #{startTime}
  347. AND stat_date &lt;= #{endTime}
  348. </if>
  349. <if test="brigadeId != null">
  350. AND brigade_id = #{brigadeId}
  351. </if>
  352. GROUP BY stat_date
  353. ORDER BY stat_date ASC
  354. </select>
  355. <!-- 查询查堵-AI误判图像总数(用于单系列图表) -->
  356. <select id="selectAiErrorImageStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyStatsDTO">
  357. SELECT
  358. DATE_FORMAT(stat_date, '%Y-%m-%d') as statDate,
  359. COALESCE(SUM(ai_error_image_total), 0) as totalBlockedCount,
  360. 0 as dailyBlockedCount
  361. FROM blocked_luggage_statistics_daily
  362. WHERE del_flag = '0'
  363. <if test="startTime != null and endTime != null">
  364. AND stat_date &gt;= #{startTime}
  365. AND stat_date &lt;= #{endTime}
  366. </if>
  367. <if test="brigadeId != null">
  368. AND brigade_id = #{brigadeId}
  369. </if>
  370. GROUP BY stat_date
  371. ORDER BY stat_date ASC
  372. </select>
  373. <!-- 查询查堵-主管排行榜 -->
  374. <select id="selectSupervisorRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  375. SELECT
  376. supervisor_name as name,
  377. supervisor_id as id,
  378. COUNT(1) as totalCount
  379. FROM blocked_miss_check_statistics
  380. WHERE del_flag = '0'
  381. AND supervisor_name IS NOT NULL
  382. AND supervisor_name != ''
  383. <if test="startTime != null and endTime != null">
  384. AND review_date &gt;= #{startTime}
  385. AND review_date &lt;= #{endTime}
  386. </if>
  387. <if test="brigadeId != null">
  388. AND brigade_id = #{brigadeId}
  389. </if>
  390. <if test="terminalId != null">
  391. AND terminal_id = #{terminalId}
  392. </if>
  393. <if test="supervisorId != null">
  394. AND supervisor_id = #{supervisorId}
  395. </if>
  396. <if test="teamLeaderId != null">
  397. AND team_leader_id = #{teamLeaderId}
  398. </if>
  399. <if test="missCheckItem != null and missCheckItem != ''">
  400. AND miss_check_item = #{missCheckItem}
  401. </if>
  402. GROUP BY supervisor_id, supervisor_name
  403. ORDER BY totalCount DESC
  404. LIMIT 30
  405. </select>
  406. <!-- 查询查堵-班组排行榜 -->
  407. <select id="selectTeamLeaderRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  408. SELECT
  409. team_leader_name as name,
  410. team_leader_id as id,
  411. COUNT(1) as totalCount
  412. FROM blocked_miss_check_statistics
  413. WHERE del_flag = '0'
  414. AND team_leader_name IS NOT NULL
  415. AND team_leader_name != ''
  416. <if test="startTime != null and endTime != null">
  417. AND review_date &gt;= #{startTime}
  418. AND review_date &lt;= #{endTime}
  419. </if>
  420. <if test="brigadeId != null">
  421. AND brigade_id = #{brigadeId}
  422. </if>
  423. <if test="terminalId != null">
  424. AND terminal_id = #{terminalId}
  425. </if>
  426. <if test="teamLeaderId != null">
  427. AND team_leader_id = #{teamLeaderId}
  428. </if>
  429. <if test="supervisorId != null">
  430. AND supervisor_id = #{supervisorId}
  431. </if>
  432. <if test="missCheckItem != null and missCheckItem != ''">
  433. AND miss_check_item = #{missCheckItem}
  434. </if>
  435. GROUP BY team_leader_id, team_leader_name
  436. ORDER BY totalCount DESC
  437. LIMIT 30
  438. </select>
  439. <!-- 查询查堵-人员排行榜 -->
  440. <select id="selectReviewedUserRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  441. SELECT
  442. reviewed_user_name as name,
  443. reviewed_user_id as id,
  444. COUNT(1) as totalCount
  445. FROM blocked_miss_check_statistics
  446. WHERE del_flag = '0'
  447. AND reviewed_user_name IS NOT NULL
  448. AND reviewed_user_name != ''
  449. <if test="startTime != null and endTime != null">
  450. AND review_date &gt;= #{startTime}
  451. AND review_date &lt;= #{endTime}
  452. </if>
  453. <if test="brigadeId != null">
  454. AND brigade_id = #{brigadeId}
  455. </if>
  456. <if test="terminalId != null">
  457. AND terminal_id = #{terminalId}
  458. </if>
  459. <if test="reviewedUserId != null">
  460. AND reviewed_user_id = #{reviewedUserId}
  461. </if>
  462. <if test="supervisorId != null">
  463. AND supervisor_id = #{supervisorId}
  464. </if>
  465. <if test="teamLeaderId != null">
  466. AND team_leader_id = #{teamLeaderId}
  467. </if>
  468. <if test="missCheckItem != null and missCheckItem != ''">
  469. AND miss_check_item = #{missCheckItem}
  470. </if>
  471. GROUP BY reviewed_user_id, reviewed_user_name
  472. ORDER BY totalCount DESC
  473. LIMIT 30
  474. </select>
  475. <!-- 查询查堵-物品位置分布(用于扇形图) -->
  476. <select id="selectItemLocationDistribution" resultType="com.sundot.airport.blocked.dto.BlockedItemLocationDistributionDTO">
  477. SELECT
  478. item_location as itemLocation,
  479. COUNT(1) as count
  480. FROM blocked_miss_check_statistics
  481. WHERE del_flag = '0'
  482. AND item_location IS NOT NULL
  483. AND item_location != ''
  484. <if test="startTime != null and endTime != null">
  485. AND review_date &gt;= #{startTime}
  486. AND review_date &lt;= #{endTime}
  487. </if>
  488. <if test="brigadeId != null">
  489. AND brigade_id = #{brigadeId}
  490. </if>
  491. <if test="terminalId != null">
  492. AND terminal_id = #{terminalId}
  493. </if>
  494. <if test="itemLocation != null and itemLocation != ''">
  495. AND item_location = #{itemLocation}
  496. </if>
  497. <if test="supervisorId != null">
  498. AND supervisor_id = #{supervisorId}
  499. </if>
  500. <if test="teamLeaderId != null">
  501. AND team_leader_id = #{teamLeaderId}
  502. </if>
  503. <if test="missCheckItem != null and missCheckItem != ''">
  504. AND miss_check_item = #{missCheckItem}
  505. </if>
  506. GROUP BY item_location
  507. ORDER BY count DESC
  508. </select>
  509. <!-- 查询查堵-原因分类分布(用于扇形图) -->
  510. <select id="selectMissCheckReasonDistribution" resultType="com.sundot.airport.blocked.dto.BlockedMissCheckReasonDistributionDTO">
  511. SELECT
  512. miss_check_reason_category as missCheckReasonCategory,
  513. COUNT(1) as count
  514. FROM blocked_miss_check_statistics
  515. WHERE del_flag = '0'
  516. AND area_id IS NOT NULL
  517. AND miss_check_reason_category IS NOT NULL
  518. AND miss_check_reason_category != ''
  519. <if test="startTime != null and endTime != null">
  520. AND review_date &gt;= #{startTime}
  521. AND review_date &lt;= #{endTime}
  522. </if>
  523. <if test="brigadeId != null">
  524. AND brigade_id = #{brigadeId}
  525. </if>
  526. <if test="terminalId != null">
  527. AND terminal_id = #{terminalId}
  528. </if>
  529. <if test="supervisorId != null">
  530. AND supervisor_id = #{supervisorId}
  531. </if>
  532. <if test="teamLeaderId != null">
  533. AND team_leader_id = #{teamLeaderId}
  534. </if>
  535. <if test="missCheckItem != null and missCheckItem != ''">
  536. AND miss_check_item = #{missCheckItem}
  537. </if>
  538. GROUP BY miss_check_reason_category
  539. ORDER BY count DESC
  540. </select>
  541. <!-- 查询查堵-图像难易程度分布(用于扇形图) -->
  542. <select id="selectDifficultyDistribution" resultType="com.sundot.airport.blocked.dto.BlockedDifficultyDistributionDTO">
  543. SELECT
  544. difficulty_level as difficultyLevel,
  545. COUNT(1) as count
  546. FROM blocked_miss_check_statistics
  547. WHERE del_flag = '0'
  548. AND difficulty_level IS NOT NULL
  549. AND difficulty_level != ''
  550. <if test="startTime != null and endTime != null">
  551. AND review_date &gt;= #{startTime}
  552. AND review_date &lt;= #{endTime}
  553. </if>
  554. <if test="brigadeId != null">
  555. AND brigade_id = #{brigadeId}
  556. </if>
  557. <if test="terminalId != null">
  558. AND terminal_id = #{terminalId}
  559. </if>
  560. <if test="supervisorId != null">
  561. AND supervisor_id = #{supervisorId}
  562. </if>
  563. <if test="teamLeaderId != null">
  564. AND team_leader_id = #{teamLeaderId}
  565. </if>
  566. <if test="missCheckItem != null and missCheckItem != ''">
  567. AND miss_check_item = #{missCheckItem}
  568. </if>
  569. GROUP BY difficulty_level
  570. ORDER BY count DESC
  571. </select>
  572. <!-- 查询查堵-开机人员持证比例(用于扇形图) -->
  573. <select id="selectCertificateDistribution" resultType="com.sundot.airport.blocked.dto.BlockedCertificateDistributionDTO">
  574. SELECT
  575. u.qualification_level as certificateLevel,
  576. COUNT(DISTINCT bms.reviewed_user_id) as count
  577. FROM blocked_miss_check_statistics bms
  578. INNER JOIN sys_user u ON bms.reviewed_user_id = u.user_id
  579. WHERE bms.del_flag = '0'
  580. AND u.del_flag = '0'
  581. AND u.status = '0'
  582. AND u.qualification_level IS NOT NULL
  583. AND u.qualification_level != ''
  584. <if test="startTime != null and endTime != null">
  585. AND bms.review_date &gt;= #{startTime}
  586. AND bms.review_date &lt;= #{endTime}
  587. </if>
  588. <if test="brigadeId != null">
  589. AND bms.brigade_id = #{brigadeId}
  590. </if>
  591. <if test="terminalId != null">
  592. AND bms.terminal_id = #{terminalId}
  593. </if>
  594. <if test="supervisorId != null">
  595. AND bms.supervisor_id = #{supervisorId}
  596. </if>
  597. <if test="teamLeaderId != null">
  598. AND bms.team_leader_id = #{teamLeaderId}
  599. </if>
  600. <if test="missCheckItem != null and missCheckItem != ''">
  601. AND bms.miss_check_item = #{missCheckItem}
  602. </if>
  603. GROUP BY u.qualification_level
  604. ORDER BY count DESC
  605. </select>
  606. <!-- 查询大队开机人员证书分布(用于柱状图) -->
  607. <select id="selectBrigadeCertificateDistribution" resultType="com.sundot.airport.blocked.dto.BlockedCertificateLevelDTO">
  608. SELECT
  609. d.dept_name as brigadeName,
  610. d.dept_id as brigadeId,
  611. COUNT(DISTINCT CASE WHEN u.qualification_level IN ('LEVEL_ONE', 'LEVEL_TWO', 'LEVEL_THREE') THEN u.user_id END) as seniorCount,
  612. COUNT(DISTINCT CASE WHEN u.qualification_level = 'LEVEL_FOUR' THEN u.user_id END) as middleCount,
  613. COUNT(DISTINCT CASE WHEN u.qualification_level = 'LEVEL_FIVE' THEN u.user_id END) as juniorCount,
  614. COUNT(DISTINCT u.user_id) as totalCount
  615. FROM sys_user u
  616. INNER JOIN sys_dept d ON u.dept_id = d.dept_id
  617. WHERE u.del_flag = '0'
  618. AND u.status = '0'
  619. AND u.qualification_level IS NOT NULL
  620. AND u.qualification_level != ''
  621. AND d.dept_type = 'BRIGADE'
  622. <if test="terminalId != null">
  623. AND d.terminal_id = #{terminalId}
  624. </if>
  625. GROUP BY d.dept_id, d.dept_name
  626. ORDER BY totalCount DESC
  627. </select>
  628. <!-- 查询两楼每日查堵走势(按大队) -->
  629. <select id="selectDailyBrigadeTerminalStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeTerminalStatsDTO">
  630. SELECT
  631. stat_date as statDate,
  632. COALESCE(SUM(t1_travel_blocked_count), 0) as t1TravelBlockedCount,
  633. COALESCE(SUM(t2_travel_blocked_count), 0) as t2TravelBlockedCount,
  634. COALESCE(SUM(t1_walk_blocked_count), 0) as t1WalkBlockedCount,
  635. COALESCE(SUM(t2_walk_blocked_count), 0) as t2WalkBlockedCount
  636. FROM blocked_luggage_statistics_daily
  637. WHERE del_flag = '0'
  638. <if test="brigadeId != null">
  639. AND brigade_id = #{brigadeId}
  640. </if>
  641. <if test="startTime != null and endTime != null">
  642. AND stat_date &gt;= #{startTime}
  643. AND stat_date &lt;= #{endTime}
  644. </if>
  645. GROUP BY stat_date
  646. ORDER BY stat_date ASC
  647. </select>
  648. <!-- 查询两楼每日过检图像数(按大队) -->
  649. <select id="selectDailyBrigadeTerminalLuggageStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeTerminalLuggageStatsDTO">
  650. SELECT
  651. stat_date as statDate,
  652. COALESCE(SUM(t1_travel_luggage_count), 0) as t1TravelBagCount,
  653. COALESCE(SUM(t2_travel_luggage_count), 0) as t2TravelBagCount,
  654. COALESCE(SUM(t1_walk_luggage_count), 0) as t1WalkBagCount,
  655. COALESCE(SUM(t2_walk_luggage_count), 0) as t2WalkBagCount
  656. FROM blocked_luggage_statistics_daily
  657. WHERE del_flag = '0'
  658. <if test="brigadeId != null">
  659. AND brigade_id = #{brigadeId}
  660. </if>
  661. <if test="startTime != null and endTime != null">
  662. AND stat_date &gt;= #{startTime}
  663. AND stat_date &lt;= #{endTime}
  664. </if>
  665. GROUP BY stat_date
  666. ORDER BY stat_date ASC
  667. </select>
  668. <!-- 查询两楼查堵数(包含行检,按大队) -->
  669. <select id="selectTerminalBlockedStats" resultType="com.sundot.airport.blocked.dto.BlockedTerminalStatsDTO">
  670. SELECT
  671. COUNT(1) as totalBlockedCount,
  672. COALESCE(SUM(CASE WHEN terminal_id = 1 THEN 1 ELSE 0 END), 0) as t1BlockedCount,
  673. COALESCE(SUM(CASE WHEN terminal_id = 2 THEN 1 ELSE 0 END), 0) as t2BlockedCount
  674. FROM blocked_miss_check_statistics
  675. WHERE del_flag = '0'
  676. <if test="brigadeId != null">
  677. AND brigade_id = #{brigadeId}
  678. </if>
  679. <if test="terminalId != null">
  680. AND terminal_id = #{terminalId}
  681. </if>
  682. <if test="startTime != null and endTime != null">
  683. AND review_date &gt;= #{startTime}
  684. AND review_date &lt;= #{endTime}
  685. </if>
  686. <if test="supervisorId != null">
  687. AND supervisor_id = #{supervisorId}
  688. </if>
  689. <if test="teamLeaderId != null">
  690. AND team_leader_id = #{teamLeaderId}
  691. </if>
  692. <if test="missCheckItem != null and missCheckItem != ''">
  693. AND miss_check_item = #{missCheckItem}
  694. </if>
  695. </select>
  696. <!-- 查询查堵时间段过检行李数(按大队) -->
  697. <select id="selectTimePeriodLuggageStats" resultType="com.sundot.airport.blocked.dto.BlockedTimePeriodLuggageStatsDTO">
  698. SELECT
  699. time_period as timePeriod,
  700. ROUND(AVG(total_luggage_count), 2) as avgLuggageCount,
  701. ROUND(AVG(total_blocked_count), 2) as avgBlockedCount
  702. FROM blocked_luggage_piece_daily
  703. WHERE del_flag = '0'
  704. <if test="brigadeId != null">
  705. AND brigade_id = #{brigadeId}
  706. </if>
  707. <if test="startTime != null and endTime != null">
  708. AND stat_date &gt;= #{startTime}
  709. AND stat_date &lt;= #{endTime}
  710. </if>
  711. GROUP BY time_period
  712. ORDER BY time_period ASC
  713. </select>
  714. <!-- 查询两楼每日查堵万分率(按大队) -->
  715. <select id="selectDailyBrigadeTerminalRateStats" resultType="com.sundot.airport.blocked.dto.BlockedDailyBrigadeTerminalRateStatsDTO">
  716. SELECT
  717. stat_date as statDate,
  718. COALESCE(AVG(t1_travel_block_rate), 0) as t1TravelBlockRate,
  719. COALESCE(AVG(t2_travel_block_rate), 0) as t2TravelBlockRate,
  720. COALESCE(AVG(t1_walk_block_rate), 0) as t1WalkBlockRate,
  721. COALESCE(AVG(t2_walk_block_rate), 0) as t2WalkBlockRate
  722. FROM blocked_luggage_statistics_daily
  723. WHERE del_flag = '0'
  724. <if test="brigadeId != null">
  725. AND brigade_id = #{brigadeId}
  726. </if>
  727. <if test="startTime != null and endTime != null">
  728. AND stat_date &gt;= #{startTime}
  729. AND stat_date &lt;= #{endTime}
  730. </if>
  731. GROUP BY stat_date
  732. ORDER BY stat_date ASC
  733. </select>
  734. <!-- 查询查堵-主管排行榜(大队维度,前10名) -->
  735. <select id="selectBrigadeSupervisorRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  736. SELECT
  737. supervisor_name as name,
  738. supervisor_id as id,
  739. COUNT(1) as totalCount
  740. FROM blocked_miss_check_statistics
  741. WHERE del_flag = '0'
  742. AND supervisor_name IS NOT NULL
  743. AND supervisor_name != ''
  744. <if test="brigadeId != null">
  745. AND brigade_id = #{brigadeId}
  746. </if>
  747. <if test="terminalId != null">
  748. AND terminal_id = #{terminalId}
  749. </if>
  750. <if test="startTime != null and endTime != null">
  751. AND review_date &gt;= #{startTime}
  752. AND review_date &lt;= #{endTime}
  753. </if>
  754. <if test="supervisorId != null">
  755. AND supervisor_id = #{supervisorId}
  756. </if>
  757. <if test="teamLeaderId != null">
  758. AND team_leader_id = #{teamLeaderId}
  759. </if>
  760. <if test="missCheckItem != null and missCheckItem != ''">
  761. AND miss_check_item = #{missCheckItem}
  762. </if>
  763. GROUP BY supervisor_id, supervisor_name
  764. ORDER BY totalCount DESC
  765. LIMIT 10
  766. </select>
  767. <!-- 查询查堵-班组排行榜(大队维度,前10名) -->
  768. <select id="selectBrigadeTeamLeaderRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  769. SELECT
  770. team_leader_name as name,
  771. team_leader_id as id,
  772. COUNT(1) as totalCount
  773. FROM blocked_miss_check_statistics
  774. WHERE del_flag = '0'
  775. AND team_leader_name IS NOT NULL
  776. AND team_leader_name != ''
  777. <if test="brigadeId != null">
  778. AND brigade_id = #{brigadeId}
  779. </if>
  780. <if test="terminalId != null">
  781. AND terminal_id = #{terminalId}
  782. </if>
  783. <if test="startTime != null and endTime != null">
  784. AND review_date &gt;= #{startTime}
  785. AND review_date &lt;= #{endTime}
  786. </if>
  787. <if test="supervisorId != null">
  788. AND supervisor_id = #{supervisorId}
  789. </if>
  790. <if test="teamLeaderId != null">
  791. AND team_leader_id = #{teamLeaderId}
  792. </if>
  793. <if test="missCheckItem != null and missCheckItem != ''">
  794. AND miss_check_item = #{missCheckItem}
  795. </if>
  796. GROUP BY team_leader_id, team_leader_name
  797. ORDER BY totalCount DESC
  798. LIMIT 10
  799. </select>
  800. <!-- 查询查堵-人员排行榜(大队维度,前10名) -->
  801. <select id="selectBrigadeReviewedUserRanking" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  802. SELECT
  803. reviewed_user_name as name,
  804. reviewed_user_id as id,
  805. COUNT(1) as totalCount
  806. FROM blocked_miss_check_statistics
  807. WHERE del_flag = '0'
  808. AND reviewed_user_name IS NOT NULL
  809. AND reviewed_user_name != ''
  810. <if test="brigadeId != null">
  811. AND brigade_id = #{brigadeId}
  812. </if>
  813. <if test="terminalId != null">
  814. AND terminal_id = #{terminalId}
  815. </if>
  816. <if test="startTime != null and endTime != null">
  817. AND review_date &gt;= #{startTime}
  818. AND review_date &lt;= #{endTime}
  819. </if>
  820. <if test="supervisorId != null">
  821. AND supervisor_id = #{supervisorId}
  822. </if>
  823. <if test="teamLeaderId != null">
  824. AND team_leader_id = #{teamLeaderId}
  825. </if>
  826. <if test="missCheckItem != null and missCheckItem != ''">
  827. AND miss_check_item = #{missCheckItem}
  828. </if>
  829. GROUP BY reviewed_user_id, reviewed_user_name
  830. ORDER BY totalCount DESC
  831. LIMIT 10
  832. </select>
  833. <!-- 查询查堵男女比例(按大队) -->
  834. <select id="selectGenderDistribution" resultType="com.sundot.airport.blocked.dto.BlockedGenderDistributionDTO">
  835. SELECT
  836. gender as gender,
  837. COUNT(1) as count
  838. FROM blocked_miss_check_statistics
  839. WHERE del_flag = '0'
  840. AND gender IS NOT NULL
  841. AND gender != ''
  842. <if test="brigadeId != null">
  843. AND brigade_id = #{brigadeId}
  844. </if>
  845. <if test="terminalId != null">
  846. AND terminal_id = #{terminalId}
  847. </if>
  848. <if test="startTime != null and endTime != null">
  849. AND review_date &gt;= #{startTime}
  850. AND review_date &lt;= #{endTime}
  851. </if>
  852. <if test="supervisorId != null">
  853. AND supervisor_id = #{supervisorId}
  854. </if>
  855. <if test="teamLeaderId != null">
  856. AND team_leader_id = #{teamLeaderId}
  857. </if>
  858. <if test="missCheckItem != null and missCheckItem != ''">
  859. AND miss_check_item = #{missCheckItem}
  860. </if>
  861. GROUP BY gender
  862. ORDER BY count DESC
  863. </select>
  864. <!-- 查询查堵人员证书级别分布(按大队) -->
  865. <select id="selectCertificateLevelDistribution" resultType="com.sundot.airport.blocked.dto.BlockedCertificateLevelDistributionDTO">
  866. SELECT
  867. certificate_level as certificateLevel,
  868. COUNT(1) as count
  869. FROM blocked_miss_check_statistics
  870. WHERE del_flag = '0'
  871. AND certificate_level IS NOT NULL
  872. AND certificate_level != ''
  873. <if test="brigadeId != null">
  874. AND brigade_id = #{brigadeId}
  875. </if>
  876. <if test="terminalId != null">
  877. AND terminal_id = #{terminalId}
  878. </if>
  879. <if test="startTime != null and endTime != null">
  880. AND review_date &gt;= #{startTime}
  881. AND review_date &lt;= #{endTime}
  882. </if>
  883. <if test="supervisorId != null">
  884. AND supervisor_id = #{supervisorId}
  885. </if>
  886. <if test="teamLeaderId != null">
  887. AND team_leader_id = #{teamLeaderId}
  888. </if>
  889. <if test="missCheckItem != null and missCheckItem != ''">
  890. AND miss_check_item = #{missCheckItem}
  891. </if>
  892. GROUP BY certificate_level
  893. ORDER BY count DESC
  894. </select>
  895. <!-- 查询证书级别人员基数(分大队统计) -->
  896. <select id="selectBrigadePersonnelCertificateBase" resultType="com.sundot.airport.blocked.dto.BlockedCertificateLevelDistributionDTO">
  897. SELECT
  898. u.qualification_level as certificateLevel,
  899. COUNT(DISTINCT u.user_id) as count
  900. FROM sys_user u
  901. INNER JOIN sys_dept d ON u.dept_id = d.dept_id
  902. WHERE u.del_flag = '0'
  903. AND u.status = '0'
  904. AND u.qualification_level IS NOT NULL
  905. AND u.qualification_level != ''
  906. AND d.dept_type = 'BRIGADE'
  907. <if test="brigadeId != null">
  908. AND d.dept_id = #{brigadeId}
  909. </if>
  910. GROUP BY u.qualification_level
  911. ORDER BY count DESC
  912. </select>
  913. <!-- 查询查堵-主管分管次数分布(用于饼图) -->
  914. <select id="selectSupervisorDistribution" resultType="com.sundot.airport.blocked.dto.BlockedRankingDTO">
  915. SELECT
  916. supervisor_name as name,
  917. supervisor_id as id,
  918. COUNT(1) as totalCount
  919. FROM blocked_miss_check_statistics
  920. WHERE del_flag = '0'
  921. AND supervisor_name IS NOT NULL
  922. AND supervisor_name != ''
  923. <if test="brigadeId != null">
  924. AND brigade_id = #{brigadeId}
  925. </if>
  926. <if test="terminalId != null">
  927. AND terminal_id = #{terminalId}
  928. </if>
  929. <if test="startTime != null and endTime != null">
  930. AND review_date &gt;= #{startTime}
  931. AND review_date &lt;= #{endTime}
  932. </if>
  933. <if test="supervisorId != null">
  934. AND supervisor_id = #{supervisorId}
  935. </if>
  936. <if test="teamLeaderId != null">
  937. AND team_leader_id = #{teamLeaderId}
  938. </if>
  939. <if test="missCheckItem != null and missCheckItem != ''">
  940. AND miss_check_item = #{missCheckItem}
  941. </if>
  942. GROUP BY supervisor_id, supervisor_name
  943. ORDER BY totalCount DESC
  944. </select>
  945. <!-- 查询查堵人员开机年限分布(用于饼图) -->
  946. <select id="selectOperatingYearsDistribution" resultType="com.sundot.airport.blocked.dto.BlockedOperatingYearsDistributionDTO">
  947. SELECT
  948. machine_operating_years as operatingYears,
  949. COUNT(1) as count
  950. FROM blocked_miss_check_statistics
  951. WHERE del_flag = '0'
  952. AND machine_operating_years IS NOT NULL
  953. AND machine_operating_years != ''
  954. <if test="brigadeId != null">
  955. AND brigade_id = #{brigadeId}
  956. </if>
  957. <if test="terminalId != null">
  958. AND terminal_id = #{terminalId}
  959. </if>
  960. <if test="startTime != null and endTime != null">
  961. AND review_date &gt;= #{startTime}
  962. AND review_date &lt;= #{endTime}
  963. </if>
  964. <if test="supervisorId != null">
  965. AND supervisor_id = #{supervisorId}
  966. </if>
  967. <if test="teamLeaderId != null">
  968. AND team_leader_id = #{teamLeaderId}
  969. </if>
  970. <if test="missCheckItem != null and missCheckItem != ''">
  971. AND miss_check_item = #{missCheckItem}
  972. </if>
  973. GROUP BY machine_operating_years
  974. ORDER BY count DESC
  975. </select>
  976. </mapper>