TBCarScheduleTaskArrangeMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.daju.mix.dao.mapper.TBCarScheduleTaskArrangeMapper">
  4. <!-- 根据作业类型、车辆类型、查询今日作业人数-->
  5. <select id="selectTodayWorkersCountByScheduleTypeAndCarType" resultType="String">
  6. SELECT
  7. csta.user_id as userCount
  8. FROM
  9. t_b_car_schedule_task_detail AS csta
  10. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  11. where
  12. TO_DAYS(NOW()) = TO_DAYS(CONCAT(csta.yearmonth,'-',csta.code_day))
  13. <if test="scheduleType != null and scheduleType != '' ">
  14. AND cst.assignment_style = #{scheduleType}
  15. </if>
  16. <if test="elementType != null and elementType != '' ">
  17. AND csta.carid in (select id from t_b_car where type = #{elementType} )
  18. </if>
  19. GROUP BY
  20. csta.user_id
  21. </select>
  22. <!-- add-刘梦祥-2022年7月18日17:41:58(根据作业类型、场所类型、查询今日作业人数)-->
  23. <select id="selectTodayWorkersCountByScheduleTypeAndElementType" resultType="String">
  24. SELECT
  25. user_id as userId
  26. FROM
  27. t_b_car_schedule_task_detail
  28. WHERE
  29. concat(yearmonth, "-", code_day) = CURDATE()
  30. AND pid IN (
  31. SELECT
  32. id
  33. FROM
  34. T_b_car_schedule_task
  35. WHERE
  36. <if test="scheduleType != null and scheduleType != '' ">
  37. assignment_style = #{scheduleType}
  38. </if>
  39. <if test="elementType != null and elementType != '' ">
  40. AND work_route IN (
  41. SELECT
  42. route_id
  43. FROM
  44. t_b_work_route_list
  45. WHERE
  46. place_code IN (
  47. SELECT
  48. `code`
  49. FROM
  50. t_b_archives_area
  51. where area_type = #{elementType}
  52. )
  53. GROUP BY route_id
  54. )
  55. </if>
  56. )
  57. and user_id is not NULL;
  58. </select>
  59. <!-- 根据作业类型、元素类型、查询今日作业车辆数update:刘梦祥-2022年7月14日15:04:04(优化查询逻辑,并解决查询数据异常的问题)-->
  60. <select id="selectTodayVehiclesCountByScheduleTypeAndElementType" resultType="int">
  61. SELECT
  62. count(DISTINCT tbcstd.carid)
  63. FROM
  64. t_b_car_schedule_task_detail tbcstd
  65. RIGHT JOIN t_b_car_schedule_task tbcst ON tbcstd.pid = tbcst.id
  66. RIGHT JOIN t_b_car tbc ON tbcstd.carid = tbc.id
  67. WHERE
  68. CONCAT(tbcstd.code_year,"-",tbcstd.code_month,"-",tbcstd.code_day) = CURDATE()
  69. <if test="scheduleType != null and scheduleType != '' ">
  70. AND tbcst.assignment_style = #{scheduleType}
  71. </if>
  72. <if test="carType != null and carType != '' ">
  73. AND tbc.type = #{carType}
  74. </if>
  75. <if test="elementType != null and elementType != '' ">
  76. AND tbcstd.pid IN (
  77. SELECT
  78. id
  79. FROM
  80. T_b_car_schedule_task
  81. WHERE
  82. <if test="scheduleType != null and scheduleType != '' ">
  83. assignment_style = #{scheduleType}
  84. </if>
  85. AND work_route IN (
  86. SELECT
  87. route_id
  88. FROM
  89. t_b_work_route_list
  90. WHERE
  91. place_code IN (
  92. SELECT
  93. `code`
  94. FROM
  95. t_b_archives_place
  96. where type = #{elementType}
  97. )
  98. GROUP BY route_id
  99. )
  100. )
  101. </if>
  102. and tbcstd.carid is not NULL;
  103. </select>
  104. <!-- 查询今日区域作业人数-->
  105. <select id="selectTodayWorkersCountByRegionType" resultType="java.util.Map">
  106. SELECT
  107. tbwr.area_region areaRegion,
  108. count(DISTINCT tbcstd.user_id) userCount
  109. FROM
  110. t_b_car_schedule_task_detail tbcstd
  111. LEFT JOIN t_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
  112. LEFT JOIN t_b_work_route tbwr ON tbwr.id = tbcst.work_route
  113. WHERE
  114. CONCAT(
  115. tbcstd.yearmonth,
  116. '-',
  117. tbcstd.code_day
  118. ) = CURRENT_DATE ()
  119. <if test="regionType != null and regionType != '' ">
  120. AND tbwr.area_region = #{regionType}
  121. </if>
  122. GROUP BY
  123. tbwr.area_region;
  124. </select>
  125. <!-- 进博 查询今日区域实际作业人数-->
  126. <select id="selectTodayWorkersCountByRegionTypeJinBo" resultType="java.util.Map">
  127. SELECT
  128. userCount.area_region AS areaRegion,
  129. count(*) AS userCount
  130. FROM
  131. (
  132. SELECT
  133. tu.area_region,
  134. tu.id
  135. FROM
  136. t_s_user AS tu
  137. where
  138. tu.device_id is not null
  139. and tu.area_region is not null
  140. AND tu.area_region = '3'
  141. GROUP BY
  142. tu.area_region,
  143. tu.id
  144. ) AS userCount
  145. GROUP BY
  146. userCount.area_region
  147. </select>
  148. <!-- 查询今日区域作业车辆数-->
  149. <select id="selectTodayVehiclesCountByRegionType" resultType="java.util.Map">
  150. SELECT
  151. areaCar.areaRegion areaRegion,
  152. COUNT(areaCar.carCount) carCount
  153. FROM
  154. (
  155. SELECT
  156. GROUP_CONCAT(DISTINCT tbwr.area_region) areaRegion,
  157. COUNT(tbcstd.carid) carCount
  158. FROM
  159. t_b_car_schedule_task_detail tbcstd
  160. LEFT JOIN t_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
  161. LEFT JOIN t_b_work_route tbwr ON tbwr.id = tbcst.work_route
  162. WHERE
  163. CONCAT(
  164. tbcstd.yearmonth,
  165. '-',
  166. tbcstd.code_day
  167. ) = CURRENT_DATE ()
  168. GROUP BY
  169. tbcstd.carid
  170. ) AS areaCar
  171. <if test="regionType != null and regionType != '' ">
  172. where LEFT(areaCar.areaRegion,1) = #{regionType}
  173. </if>
  174. GROUP BY
  175. LEFT(areaCar.areaRegion,1);
  176. </select>
  177. <!-- 进博 查询今日区域实际作业车辆数-->
  178. <select id="selectTodayVehiclesCountByRegionTypeJinBo" resultType="java.util.Map">
  179. SELECT
  180. carcount.area_region AS areaRegion,
  181. count(*) AS carCount
  182. FROM
  183. (
  184. SELECT
  185. tc.area_region,
  186. tc.id
  187. FROM
  188. t_b_car AS tc
  189. where
  190. tc.area_region is not null
  191. and tc.gpssn is not null
  192. AND tc.area_region = '3'
  193. GROUP BY
  194. tc.area_region,
  195. tc.id
  196. ) AS carcount
  197. GROUP BY
  198. carcount.area_region
  199. </select>
  200. <!-- 根据作业类型、元素类型、车辆id,场所编码查询作业完成率-->
  201. <select id="selectWorkingCountByScheduleTypeAndElementType" resultType="java.util.Map">
  202. SELECT
  203. (
  204. SELECT
  205. SUM(tbcsc.done_count)/100
  206. FROM
  207. t_b_car_schedule_task_detail tbcstd
  208. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  209. WHERE
  210. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  211. CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) BETWEEN #{startDate} AND #{endDate} AND
  212. </if>
  213. tbcstd.pid IN (
  214. SELECT
  215. id
  216. FROM
  217. T_b_car_schedule_task
  218. WHERE
  219. work_route IN (
  220. SELECT
  221. route_id
  222. FROM
  223. t_b_work_route_list
  224. WHERE
  225. place_code IN (
  226. SELECT
  227. `code`
  228. FROM
  229. t_b_archives_area
  230. <where>
  231. <if test="placeType != null and placeType != '' ">
  232. AND area_type = #{placeType}
  233. </if>
  234. <if test="placeCode != null and placeCode != '' ">
  235. AND `code` = #{placeCode}
  236. </if>
  237. </where>
  238. )
  239. )
  240. <if test="scheduleType != null and scheduleType != '' ">
  241. AND assignment_style = #{scheduleType}
  242. </if>
  243. )
  244. <if test="carId != null and carId != '' ">
  245. AND tbcstd.carid = #{carId}
  246. </if>
  247. <if test="elementType != null and elementType != '' ">
  248. AND tbcstd.carid IN (
  249. select id from t_b_car where type = #{elementType}
  250. )
  251. </if>
  252. ) AS completeCount,
  253. (
  254. SELECT
  255. COUNT(DISTINCT CONCAT(yearmonth,code_day,carid))
  256. FROM
  257. t_b_car_schedule_task_detail
  258. WHERE
  259. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  260. CONCAT(yearmonth,"-",code_day) BETWEEN #{startDate} AND #{endDate} and
  261. </if>
  262. pid IN (
  263. SELECT
  264. id
  265. FROM
  266. T_b_car_schedule_task
  267. WHERE
  268. work_route IN (
  269. SELECT
  270. route_id
  271. FROM
  272. t_b_work_route_list
  273. WHERE
  274. place_code IN (
  275. SELECT
  276. `code`
  277. FROM
  278. t_b_archives_area
  279. <where>
  280. <if test="placeType != null and placeType != '' ">
  281. AND area_type = #{placeType}
  282. </if>
  283. <if test="placeCode != null and placeCode != '' ">
  284. AND `code` = #{placeCode}
  285. </if>
  286. </where>
  287. )
  288. )
  289. <if test="scheduleType != null and scheduleType != '' ">
  290. AND assignment_style = #{scheduleType}
  291. </if>
  292. )
  293. <if test="carId != null and carId != '' ">
  294. AND carid = #{carId}
  295. </if>
  296. <if test="elementType != null and elementType != '' ">
  297. AND carid IN (
  298. select id from t_b_car where type = #{elementType}
  299. )
  300. </if>
  301. ) AS totalCount;
  302. </select>
  303. <!-- add-刘梦祥-2022年8月22日13:44:12(添加作业任务查询SQL,根据区域统计) -->
  304. <select id="selectJobsCountByRegionType" resultType="java.util.Map">
  305. SELECT
  306. COUNT(tbcstd.id) todayJobs,
  307. COUNT(
  308. tbcsc.schedule_count
  309. ) jobs
  310. FROM
  311. (
  312. SELECT
  313. *
  314. FROM
  315. t_b_car_schedule_task_detail
  316. WHERE
  317. CONCAT(yearmonth, "-", code_day) = CURRENT_DATE ()
  318. ) tbcstd
  319. LEFT JOIN T_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
  320. LEFT JOIN t_b_car_schedule_count tbcsc ON tbcsc.car_id = tbcstd.carid
  321. AND tbcsc.schedule_date = CONCAT(
  322. tbcstd.yearmonth,
  323. "-",
  324. tbcstd.code_day
  325. )
  326. LEFT JOIN t_b_work_route tbr ON tbr.id = tbcst.work_route
  327. <if test="regionType != null and regionType != '' ">
  328. where tbr.area_region = #{regionType};
  329. </if>
  330. </select>
  331. <!-- 模拟·作业完成率 -->
  332. <select id="getMockRate" resultType="java.util.Map">
  333. select workingType workingTypeName, rateNum totalCount from cursor_working_rate where #{time} <![CDATA[<]]> rateTime group by workingType
  334. </select>
  335. <!-- 查询区域作业完成率-根据作业类型、元素类型、车辆id,场所编码-->
  336. <select id="selectWorkingCountByAreaRegion" resultType="java.util.Map">
  337. SELECT
  338. t1.area_region,completeCount,totalCount
  339. FROM
  340. (
  341. SELECT
  342. route.area_region,
  343. COUNT(tbcsc.id)
  344. FROM
  345. t_b_car_schedule_task_detail tbcstd
  346. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  347. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  348. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  349. <where>
  350. <if test="scheduleType != null and scheduleType != '' ">
  351. AND cst.assignment_style = #{scheduleType}
  352. </if>
  353. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  354. AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) BETWEEN #{startDate} AND #{endDate}
  355. </if>
  356. and tbcsc.done_count = 100
  357. </where>
  358. GROUP BY route.area_region
  359. ) t1
  360. RIGHT JOIN (
  361. SELECT
  362. route.area_region,
  363. COUNT(csta.id) totalCount
  364. FROM
  365. t_b_car_schedule_task_detail AS csta
  366. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  367. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  368. <where>
  369. <if test="scheduleType != null and scheduleType != '' ">
  370. AND cst.assignment_style = #{scheduleType}
  371. </if>
  372. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  373. AND CONCAT(csta.yearmonth,"-",csta.code_day) BETWEEN #{startDate} AND #{endDate}
  374. </if>
  375. </where>
  376. GROUP BY route.area_region
  377. ) t2 ON t1.area_region = t2.area_region
  378. <where>
  379. <if test="areaRegion != null and areaRegion != ''">
  380. AND t1.area_region = #{areaRegion}
  381. </if>
  382. </where>
  383. </select>
  384. <!-- cim首页查询-查询区域作业类型完成情况 -->
  385. <select id="selectWorkingAreaRegionDetailByBusinessType" resultType="com.daju.mix.dto.CimRegionFinishDetailDto">
  386. SELECT
  387. cst.id,
  388. (
  389. SELECT
  390. type.typename
  391. FROM
  392. t_s_typegroup AS typeg
  393. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  394. WHERE
  395. typeg.typegroupcode = 'areaRegion'
  396. AND route.area_region = type.typecode
  397. ) AS regionName,
  398. (
  399. SELECT
  400. type.typename
  401. FROM
  402. t_s_typegroup AS typeg
  403. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  404. WHERE
  405. typeg.typegroupcode = 'assignmentStyle'
  406. AND cst.type = type.typecode
  407. ) AS workingType,
  408. (
  409. SELECT
  410. COUNT(1) completeCount
  411. FROM
  412. t_b_car_schedule_task_arrange AS csta1
  413. LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
  414. LEFT JOIN t_b_work_route AS route1 ON route1.id = cst1.work_route
  415. <where>
  416. cst1. STATUS = '2'
  417. AND route1.area_region = route.area_region
  418. AND cst1.type = cst.type
  419. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  420. AND csta1.date BETWEEN #{startDate} AND #{endDate}
  421. </if>
  422. </where>
  423. ) AS finishCount,
  424. (
  425. SELECT
  426. COUNT(1) totalCount
  427. FROM
  428. t_b_car_schedule_task_arrange AS csta2
  429. LEFT JOIN t_b_car_schedule_task AS cst2 ON cst2.id = csta2.arrange_id
  430. LEFT JOIN t_b_work_route AS route2 ON route2.id = cst2.work_route
  431. <where>
  432. route2.area_region = route.area_region
  433. AND cst2.type = cst.type
  434. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  435. AND csta2.date BETWEEN #{startDate} AND #{endDate}
  436. </if>
  437. </where>
  438. ) AS workingCount
  439. FROM
  440. t_b_car_schedule_task_arrange AS csta
  441. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
  442. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  443. <where>
  444. <if test="scheduleType != null and scheduleType != '' ">
  445. AND cst.assignment_style = #{scheduleType}
  446. </if>
  447. <if test="regionType != null and regionType != '' ">
  448. AND route.area_region = #{regionType}
  449. </if>
  450. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  451. AND csta.date BETWEEN #{startDate} AND #{endDate}
  452. </if>
  453. </where>
  454. GROUP BY
  455. route.area_region,cst.type
  456. </select>
  457. <!-- 根据作业类型、元素类型、查询指定时间段的作业情况 返回作业类型-->
  458. <select id="selectTodayWorkingCountByScheduleTypeAndElementType" resultType="com.daju.mix.dto.todayWorkDto">
  459. SELECT
  460. cst.id,
  461. csta.username AS worker,
  462. (
  463. SELECT
  464. type.typename
  465. FROM
  466. t_s_typegroup AS typeg
  467. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  468. WHERE
  469. typeg.typegroupcode = 'assignmentStyle'
  470. AND cst.type = type.typecode
  471. ) AS type,
  472. GROUP_CONCAT(cst.work_route_name) workRouteName,
  473. IFNULL(tbsfar.num,0) AS completeCount,
  474. IFNULL(tbsfar.area_num,0) AS totalCount
  475. FROM
  476. t_b_car_schedule_task_detail AS csta
  477. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  478. LEFT JOIN t_b_car AS cstype ON cstype.id = csta.carid
  479. LEFT JOIN t_b_car_schedule_finished_area_record tbsfar on tbsfar.schedule_date = CONCAT(csta.yearmonth,'-',csta.code_day) and (tbsfar.car_id = csta.carid or tbsfar.car_id = csta.user_id)
  480. where
  481. TO_DAYS(NOW()) = TO_DAYS(CONCAT(csta.yearmonth,'-',csta.code_day))
  482. <if test="scheduleType != null and scheduleType != '' ">
  483. AND cst.assignment_style = #{scheduleType}
  484. </if>
  485. <if test="elementType != null and elementType != '' ">
  486. AND (cstype.type = #{elementType} OR cst.type = #{elementType})
  487. </if>
  488. <if test="isQueryUnfinished !=null and isQueryUnfinished != ''">
  489. AND csta.`status` != 2
  490. </if>
  491. GROUP BY
  492. csta.user_id
  493. </select>
  494. <!-- home-查询最近5日作业类别、作业数量-->
  495. <select id="selectLast5DayWorkingCount" resultType="java.util.Map">
  496. SELECT
  497. (
  498. SELECT
  499. type.typename
  500. FROM
  501. t_s_typegroup AS typeg
  502. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  503. WHERE
  504. typeg.typegroupcode = 'assignmentStyle'
  505. AND task.type = type.typecode
  506. ) AS workType,
  507. COUNT(1) AS workCount
  508. FROM
  509. t_b_car_schedule_task_arrange AS arr
  510. LEFT JOIN t_b_car_schedule_task AS task ON task.id = arr.arrange_id
  511. <if test="regionType != null and regionType != ''">
  512. RIGHT JOIN t_b_work_route AS route ON route.id = task.work_route
  513. </if>
  514. WHERE
  515. arr.date <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
  516. AND arr.date >= date_format(
  517. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  518. '%Y-%m-%d'
  519. )
  520. <if test="scheduleType != null and scheduleType != ''">
  521. AND task.assignment_style = #{scheduleType}
  522. </if>
  523. <if test="regionType != null and regionType != ''">
  524. AND route.area_region = #{regionType}
  525. </if>
  526. GROUP BY
  527. task.type
  528. </select>
  529. <!-- home-查询今日清运作业完成率排名-->
  530. <select id="getTodayFinishRateRank" resultType="java.util.Map">
  531. SELECT
  532. cst.type,
  533. (
  534. SELECT
  535. type.typename
  536. FROM
  537. t_s_typegroup AS typeg
  538. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  539. WHERE
  540. typeg.typegroupcode = 'assignmentStyle'
  541. AND cst.type = type.typecode
  542. ) AS workingTypeName,
  543. SUM(tbcsc.done_count)/100 completeCount,
  544. COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
  545. FROM
  546. t_b_car_schedule_task_detail AS tbcstd
  547. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  548. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  549. left join t_b_car_schedule_task_arrange as csta on csta.arrange_id = cst.id
  550. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  551. WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
  552. <if test="regionType != null and regionType != ''">
  553. AND route.area_region = #{regionType}
  554. </if>
  555. <!--<if test="regionType != null and regionType != '' ">
  556. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  557. </if>-->
  558. <if test="scheduleType != null and scheduleType != '' ">
  559. AND cst.assignment_style = #{scheduleType}
  560. </if>
  561. GROUP BY
  562. cst.type
  563. </select>
  564. <!-- home-查询今日清运作业完成率排名明细-->
  565. <select id="getTodayFinishRateRankDetail" resultType="com.daju.mix.dto.CimWorkingReteDetailDto">
  566. SELECT
  567. cst.id,
  568. (
  569. SELECT
  570. type.typename
  571. FROM
  572. t_s_typegroup AS typeg
  573. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  574. WHERE
  575. typeg.typegroupcode = 'assignmentStyle'
  576. AND cst.type = type.typecode
  577. ) AS workingType,
  578. cst.work_route_name AS workingLine,
  579. CONCAT(
  580. ROUND(
  581. (
  582. (
  583. SELECT
  584. COUNT(1)
  585. FROM
  586. t_b_car_schedule_task_arrange AS csta1
  587. LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
  588. LEFT JOIN t_b_car_schedule_type AS cstype1 ON cstype1.business_type = cst1.assignment_style
  589. <where>
  590. <if test="scheduleType != null and scheduleType != '' ">
  591. AND cst1.assignment_style = #{scheduleType}
  592. </if>
  593. AND DATEDIFF(NOW(), csta1.date) = 0
  594. AND cst1.type = cst.type
  595. AND cst1. STATUS = '2'
  596. </where>
  597. ) / (
  598. SELECT
  599. COUNT(1)
  600. FROM
  601. t_b_car_schedule_task_arrange AS csta1
  602. LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
  603. LEFT JOIN t_b_car_schedule_type AS cstype1 ON cstype1.business_type = cst1.assignment_style
  604. <where>
  605. <if test="scheduleType != null and scheduleType != '' ">
  606. AND cst1.assignment_style = #{scheduleType}
  607. </if>
  608. AND DATEDIFF(NOW(), csta1.date) = 0
  609. AND cst1.type = cst.type
  610. </where>
  611. )
  612. ) * 100,
  613. 2
  614. ),
  615. '%'
  616. ) AS rate
  617. FROM
  618. t_b_car_schedule_task_arrange AS csta
  619. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
  620. <where>
  621. <if test="scheduleType != null and scheduleType != '' ">
  622. AND cst.assignment_style = #{scheduleType}
  623. </if>
  624. AND DATEDIFF(NOW(), csta.date) = 0
  625. </where>
  626. GROUP BY
  627. cst.type
  628. ORDER BY
  629. rate DESC
  630. </select>
  631. <!-- home-查询作业完成明细-->
  632. <select id="getTodayFinishDetailList" resultType="com.daju.mix.dto.CimWorkingFinishDetailDto">
  633. SELECT
  634. csta.id,
  635. cst.type,
  636. (
  637. SELECT
  638. type.typename
  639. FROM
  640. t_s_typegroup AS typeg
  641. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  642. WHERE
  643. typeg.typegroupcode = 'assignmentStyle'
  644. AND cst.type = type.typecode
  645. ) AS workingType,
  646. csta.user_name AS worker,
  647. CASE csta.archive_type
  648. WHEN '-1' THEN
  649. (
  650. SELECT
  651. r.`name`
  652. FROM
  653. t_b_archives_road_section AS r
  654. WHERE
  655. r.`code` = csta.archive_id
  656. )
  657. ELSE
  658. (
  659. SELECT
  660. p.`name`
  661. FROM
  662. t_b_archives_place AS p
  663. WHERE
  664. p.`code` = csta.archive_id
  665. )
  666. END AS pointName
  667. FROM
  668. t_b_car_schedule_task_arrange AS csta
  669. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
  670. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  671. <where>
  672. <if test="scheduleType != null and scheduleType != '' ">
  673. AND cst.assignment_style = #{scheduleType}
  674. </if>
  675. <if test="regionType != null and regionType != '' ">
  676. AND route.area_region = #{regionType}
  677. </if>
  678. AND DATEDIFF(NOW(), csta.date) = 0
  679. </where>
  680. </select>
  681. <!-- home-查询近5日区域业务类型完成情况-->
  682. <select id="getLast5DayBusinessCountByRegion" resultType="java.util.Map">
  683. SELECT
  684. t2.area_region,
  685. t2.assignment_style,
  686. completeCount,
  687. totalCount
  688. FROM
  689. (
  690. SELECT
  691. cst.assignment_style,
  692. route.area_region,
  693. SUM(tbcsc.done_count)/100 completeCount
  694. FROM t_b_car_schedule_task_detail AS tbcstd
  695. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  696. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  697. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  698. WHERE
  699. CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
  700. AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) >= date_format(
  701. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  702. '%Y-%m-%d'
  703. )
  704. GROUP BY
  705. route.area_region,
  706. cst.assignment_style
  707. ) t1
  708. RIGHT JOIN (
  709. SELECT
  710. cst.assignment_style,
  711. route.area_region,
  712. COUNT(1) totalCount
  713. FROM
  714. t_b_car_schedule_task_detail AS tbcstd
  715. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  716. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  717. WHERE
  718. CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
  719. AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) >= date_format(
  720. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  721. '%Y-%m-%d'
  722. )
  723. GROUP BY
  724. route.area_region,
  725. cst.assignment_style
  726. ) t2 ON t1.area_region = t2.area_region AND t1.assignment_style = t2.assignment_style
  727. <where>
  728. <if test="areaRegion != null and areaRegion != ''">
  729. AND t2.area_region = #{areaRegion}
  730. </if>
  731. </where>
  732. </select>
  733. <select id="getTypeCodeName" resultType="java.util.Map">
  734. select * from t_s_typegroup tg left join t_s_type t on t.typegroupid=tg.ID where tg.typegroupcode=#{typeGroupCode}
  735. </select>
  736. <select id="getGcbSchedule" resultType="com.daju.api.hardware.dto.GcbScheduleDTO">
  737. SELECT
  738. tc.plate plate,
  739. tsp2.typename type,
  740. tsp.typename brand,
  741. tc.framenumber framenumber,
  742. td.description company,
  743. tf.name fleetid,
  744. ta.date date,
  745. tt.work_route_name workRouteName
  746. FROM
  747. t_b_car_schedule_task_arrange ta
  748. LEFT JOIN t_b_car tc ON ta.car_id = tc.id
  749. LEFT JOIN t_b_car_schedule_task tt ON ta.arrange_id = tt.id
  750. LEFT JOIN t_s_depart td ON td.org_code = tc.sys_company_code
  751. LEFT JOIN t_b_car_fleet tf ON tf.id = tc.fleetid
  752. LEFT JOIN (select * from t_s_type where typegroupid = 'ff8080817a8af150017a9f84c7f8003d') tsp ON tsp.typecode = tc.brand
  753. LEFT JOIN (select * from t_s_type where typegroupid = '2c9358a86dbeda88016dbee52d0f0031') tsp2 ON tsp2.typecode = tc.type
  754. ${ew.customSqlSegment}
  755. </select>
  756. </mapper>