CimHomeMapper.xml 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041
  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.CimHomeMapper">
  4. <!--通过区域获取近30日内投诉和问题情况-->
  5. <select id="selectComplaintsInfoByRegion" resultType="java.util.Map">
  6. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  7. (
  8. SELECT COUNT(1)
  9. FROM t_b_complaint AS plain
  10. WHERE DATEDIFF(
  11. last30Day.tempDay,
  12. plain.complaint_date
  13. ) = 0
  14. <if test="areaRegion != null and areaRegion != ''">
  15. AND plain.area = ${areaRegion}
  16. </if>
  17. AND plain.`status` = 4
  18. ) AS finishCount,
  19. (
  20. SELECT COUNT(1)
  21. FROM t_b_complaint AS plain
  22. WHERE DATEDIFF(
  23. last30Day.tempDay,
  24. plain.complaint_date
  25. ) = 0
  26. <if test="areaRegion != null and areaRegion != ''">
  27. AND plain.area = #{areaRegion}
  28. </if>
  29. ) AS totalCount
  30. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  31. FROM (
  32. SELECT @xi := @xi + 1 as i
  33. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  34. (SELECT 1
  35. UNION
  36. SELECT 2
  37. UNION
  38. SELECT 3
  39. UNION
  40. SELECT 4
  41. UNION
  42. SELECT 5
  43. UNION
  44. SELECT 6) xc2,
  45. (SELECT @xi := -1) xc0
  46. ) xc
  47. ORDER BY tempDay DESC LIMIT 5) last30Day
  48. ORDER BY last30Day.tempDay ASC LIMIT 5
  49. </select>
  50. <select id="selectComplaintsInfoByRegion1" resultType="java.util.Map">
  51. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  52. (
  53. SELECT COUNT(1)
  54. FROM t_b_complaint AS plain
  55. WHERE DATEDIFF(
  56. last30Day.tempDay,
  57. plain.complaint_date
  58. ) = 0
  59. <if test="areaRegion != null and areaRegion != ''">
  60. AND plain.area = ${areaRegion}
  61. </if>
  62. AND plain.`status` = 4
  63. ) AS finishCount,
  64. (
  65. SELECT COUNT(1)
  66. FROM t_b_complaint AS plain
  67. WHERE DATEDIFF(
  68. last30Day.tempDay,
  69. plain.complaint_date
  70. ) = 0
  71. <if test="areaRegion != null and areaRegion != ''">
  72. AND plain.area = #{areaRegion}
  73. </if>
  74. ) AS totalCount
  75. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  76. FROM (
  77. SELECT @xi := @xi + 1 as i
  78. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  79. (SELECT 1
  80. UNION
  81. SELECT 2
  82. UNION
  83. SELECT 3
  84. UNION
  85. SELECT 4
  86. UNION
  87. SELECT 5
  88. UNION
  89. SELECT 6) xc2,
  90. (SELECT @xi := -1) xc0
  91. ) xc
  92. ORDER BY tempDay DESC LIMIT 1) last30Day
  93. ORDER BY last30Day.tempDay ASC LIMIT 1
  94. </select>
  95. <select id="selectInspectorLastFive" resultType="java.util.Map">
  96. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  97. (
  98. SELECT COUNT(1)
  99. FROM t_b_schedule_superivse AS super
  100. WHERE DATEDIFF(
  101. last30Day.tempDay,
  102. super.supervise_date
  103. ) = 0
  104. <if test="areaRegion != null and areaRegion != ''">
  105. AND plain.area in ${areaRegion}
  106. </if>
  107. AND super.`status` = 3
  108. ) AS finishCount,
  109. (
  110. SELECT COUNT(1)
  111. FROM t_b_schedule_superivse AS super
  112. WHERE DATEDIFF(
  113. last30Day.tempDay,
  114. super.supervise_date
  115. ) = 0
  116. <if test="areaRegion != null and areaRegion != ''">
  117. AND super.area in ${areaRegion}
  118. </if>
  119. ) AS totalCount
  120. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  121. FROM (
  122. SELECT @xi := @xi + 1 as i
  123. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  124. (SELECT 1
  125. UNION
  126. SELECT 2
  127. UNION
  128. SELECT 3
  129. UNION
  130. SELECT 4
  131. UNION
  132. SELECT 5
  133. UNION
  134. SELECT 6) xc2,
  135. (SELECT @xi := -1) xc0
  136. ) xc
  137. ORDER BY tempDay DESC LIMIT 5) last30Day
  138. ORDER BY last30Day.tempDay ASC LIMIT 5
  139. </select>
  140. <select id="selectInspectorLastOne" resultType="java.util.Map">
  141. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  142. (
  143. SELECT COUNT(1)
  144. FROM t_b_schedule_superivse AS super
  145. WHERE DATEDIFF(
  146. last30Day.tempDay,
  147. super.supervise_date
  148. ) = 0
  149. <if test="areaRegion != null and areaRegion != ''">
  150. AND super.area in ${areaRegion}
  151. </if>
  152. AND super.`status` = 3
  153. ) AS finishCount,
  154. (
  155. SELECT COUNT(1)
  156. FROM t_b_schedule_superivse AS super
  157. WHERE DATEDIFF(
  158. last30Day.tempDay,
  159. super.supervise_date
  160. ) = 0
  161. <if test="areaRegion != null and areaRegion != ''">
  162. AND super.area in ${areaRegion}
  163. </if>
  164. ) AS totalCount
  165. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  166. FROM (
  167. SELECT @xi := @xi + 1 as i
  168. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  169. (SELECT 1
  170. UNION
  171. SELECT 2
  172. UNION
  173. SELECT 3
  174. UNION
  175. SELECT 4
  176. UNION
  177. SELECT 5
  178. UNION
  179. SELECT 6) xc2,
  180. (SELECT @xi := -1) xc0
  181. ) xc
  182. ORDER BY tempDay DESC LIMIT 1) last30Day
  183. ORDER BY last30Day.tempDay ASC LIMIT 1
  184. </select>
  185. <!--通过区域获取近30日内垃圾排放量变化趋势-->
  186. <select id="selectRubbishesInfoByRegion" resultType="java.util.Map">
  187. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  188. (
  189. SELECT IFNULL(SUM(gw.amount_weight), 0)
  190. FROM t_b_garbage_weight AS gw
  191. WHERE DATEDIFF(
  192. last30Day.tempDay,
  193. gw.weigh_time
  194. ) = 0
  195. AND gw.garbage_type = 2
  196. <if test="areaRegion != null and areaRegion != ''">
  197. AND gw.area_region = #{areaRegion}
  198. </if>
  199. ) AS wetWaste,
  200. (
  201. SELECT IFNULL(SUM(gw.amount_weight), 0)
  202. FROM t_b_garbage_weight AS gw
  203. WHERE DATEDIFF(
  204. last30Day.tempDay,
  205. gw.weigh_time
  206. ) = 0
  207. AND gw.garbage_type = 1
  208. <if test="areaRegion != null and areaRegion != ''">
  209. AND gw.area_region = #{areaRegion}
  210. </if>
  211. ) AS dryGarbage
  212. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  213. FROM (
  214. SELECT @xi := @xi + 1 as i
  215. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  216. (SELECT 1
  217. UNION
  218. SELECT 2
  219. UNION
  220. SELECT 3
  221. UNION
  222. SELECT 4
  223. UNION
  224. SELECT 5
  225. UNION
  226. SELECT 6) xc2,
  227. (SELECT @xi := -1) xc0
  228. ) xc
  229. ORDER BY tempDay) last30Day
  230. ORDER BY last30Day.tempDay
  231. </select>
  232. <!--通过区域获取近30日内清洁指数变化趋势,0914 改 5日内-->
  233. <select id="selectClearingIndexByRegion" resultType="java.util.Map">
  234. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  235. (
  236. SELECT SUM(tbcsc.done_count)/100
  237. FROM t_b_car_schedule_task_detail AS tbcstd
  238. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  239. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  240. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  241. WHERE DATEDIFF(
  242. last30Day.tempDay,
  243. CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day)
  244. ) = 0
  245. <if test="businessType != null and businessType != ''">
  246. AND cst.assignment_style = #{businessType}
  247. </if>
  248. <if test="areaRegionOld != null and areaRegionOld != ''">
  249. AND route.area_region = #{areaRegionOld}
  250. </if>
  251. ) AS completeCount,
  252. (
  253. SELECT COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
  254. FROM t_b_car_schedule_task_detail AS tbcstd
  255. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  256. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  257. WHERE DATEDIFF(last30Day.tempDay, CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day)) = 0
  258. <if test="businessType != null and businessType != ''">
  259. AND cst.assignment_style = #{businessType}
  260. </if>
  261. <if test="areaRegionOld != null and areaRegionOld != ''">
  262. AND route.area_region = #{areaRegionOld}
  263. </if>
  264. ) AS totalCount,
  265. (
  266. SELECT COUNT(1)
  267. FROM t_b_schedule_superivse AS super
  268. WHERE DATEDIFF(last30Day.tempDay, super.confirm_date) = 0 and super.status = '1'
  269. <if test="businessType != null and businessType != ''">
  270. AND super.type = #{businessType}
  271. </if>
  272. <if test="areaRegion != null and areaRegion != ''">
  273. AND super.area in ${areaRegion}
  274. </if>
  275. ) AS inspectCount,
  276. (
  277. SELECT COUNT(1)
  278. FROM t_b_complaint AS cpt
  279. WHERE DATEDIFF(last30Day.tempDay, cpt.complaint_date) = 0 and cpt.status = '1'
  280. <if test="businessType != null and businessType != ''">
  281. AND cpt.business_type = #{businessType}
  282. </if>
  283. <if test="areaRegionOld != null and areaRegionOld != ''">
  284. AND cpt.area = #{areaRegionOld}
  285. </if>
  286. ) AS complaintCount
  287. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  288. FROM (
  289. SELECT @xi := @xi + 1 AS i
  290. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  291. (SELECT 1
  292. UNION
  293. SELECT 2
  294. UNION
  295. SELECT 3
  296. UNION
  297. SELECT 4
  298. UNION
  299. SELECT 5
  300. UNION
  301. SELECT 6) xc2,
  302. (SELECT 1
  303. UNION
  304. SELECT 2
  305. UNION
  306. SELECT 3
  307. UNION
  308. SELECT 4
  309. UNION
  310. SELECT 5
  311. UNION
  312. SELECT 6) xc3,
  313. (SELECT @xi := -1) xc0
  314. ) xc
  315. ORDER BY tempDay DESC
  316. LIMIT 5
  317. ) last30Day
  318. ORDER BY last30Day.tempDay ASC LIMIT 5
  319. </select>
  320. <!--进博 通过区域获取近30日内清洁指数变化趋势 -->
  321. <select id="selectClearingIndexByRegionJinBo" resultType="java.util.Map">
  322. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS xDay,
  323. (
  324. SELECT COUNT(1)
  325. FROM t_b_car_schedule_task_arrange AS csta
  326. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
  327. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  328. WHERE DATEDIFF(
  329. last30Day.tempDay,
  330. csta.date
  331. ) = 0
  332. <if test="businessType != null and businessType != ''">
  333. AND cst.assignment_style = #{businessType}
  334. </if>
  335. <if test="areaRegion != null and areaRegion != ''">
  336. AND route.area_region = #{areaRegion}
  337. </if>
  338. AND cst.STATUS = '2'
  339. ) AS completeCount,
  340. (
  341. SELECT COUNT(1)
  342. FROM t_b_car_schedule_task_arrange AS csta
  343. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
  344. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  345. WHERE DATEDIFF(last30Day.tempDay, csta.date) = 0
  346. <if test="businessType != null and businessType != ''">
  347. AND cst.assignment_style = #{businessType}
  348. </if>
  349. <if test="areaRegion != null and areaRegion != ''">
  350. AND route.area_region = #{areaRegion}
  351. </if>
  352. ) AS totalCount,
  353. (
  354. SELECT COUNT(1)
  355. FROM t_b_schedule_superivse AS super
  356. WHERE DATEDIFF(last30Day.tempDay, super.confirm_date) = 0 and super.status = '3'
  357. <if test="businessType != null and businessType != ''">
  358. AND super.type = #{businessType}
  359. </if>
  360. <if test="areaRegion != null and areaRegion != ''">
  361. AND super.area = #{areaRegion}
  362. </if>
  363. ) AS inspectCount,
  364. (
  365. SELECT COUNT(1)
  366. FROM t_b_complaint AS cpt
  367. WHERE DATEDIFF(last30Day.tempDay, cpt.complaint_date) = 0 and cpt.status = '3'
  368. <if test="businessType != null and businessType != ''">
  369. AND cpt.business_type = #{businessType}
  370. </if>
  371. <if test="areaRegion != null and areaRegion != ''">
  372. AND cpt.area = #{areaRegion}
  373. </if>
  374. ) AS complaintCount
  375. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  376. FROM (
  377. SELECT @xi := @xi + 1 AS i
  378. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  379. (SELECT 1
  380. UNION
  381. SELECT 2
  382. UNION
  383. SELECT 3
  384. UNION
  385. SELECT 4
  386. UNION
  387. SELECT 5
  388. UNION
  389. SELECT 6) xc2,
  390. (SELECT 1
  391. UNION
  392. SELECT 2
  393. UNION
  394. SELECT 3
  395. UNION
  396. SELECT 4
  397. UNION
  398. SELECT 5
  399. UNION
  400. SELECT 6) xc3,
  401. (SELECT @xi := -1) xc0
  402. ) xc
  403. ORDER BY tempDay DESC
  404. LIMIT 30
  405. ) last30Day
  406. ORDER BY last30Day.tempDay ASC LIMIT 30
  407. </select>
  408. <!--通过区域获取近5日内清洁指数-->
  409. <select id="selectLast5DayClearingIndexByRegion" resultType="java.util.Map">
  410. SELECT SUM(completeCount) AS completeCount,
  411. SUM(totalCount) AS totalCount,
  412. SUM(inspectCount) AS inspectCount,
  413. SUM(complaintCount) AS complaintCount
  414. FROM (
  415. SELECT DATE_FORMAT(last5Day.tempDay, '%c.%e') AS xDay,
  416. (
  417. SELECT
  418. SELECT SUM(tbcsc.done_count)/100 completeCount
  419. FROM t_b_car_schedule_task_detail AS tbcstd
  420. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  421. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  422. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  423. WHERE DATEDIFF(
  424. last5Day.tempDay,
  425. CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day)
  426. ) = 0
  427. <if test="businessType != null and businessType != ''">
  428. AND cst.assignment_style = #{businessType}
  429. </if>
  430. <if test="areaRegion != null and areaRegion != ''">
  431. AND route.area_region = #{areaRegion}
  432. </if>
  433. AND cst.STATUS = '2'
  434. ) AS completeCount,
  435. (
  436. SELECT COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
  437. FROM t_b_car_schedule_task_detail AS tbcstd
  438. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  439. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  440. WHERE DATEDIFF(last5Day.tempDay, CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day)) = 0
  441. <if test="businessType != null and businessType != ''">
  442. AND cst.assignment_style = #{businessType}
  443. </if>
  444. <if test="areaRegion != null and areaRegion != ''">
  445. AND route.area_region = #{areaRegion}
  446. </if>
  447. ) AS totalCount,
  448. (
  449. SELECT COUNT(1)
  450. FROM t_b_schedule_superivse AS super
  451. WHERE DATEDIFF(last5Day.tempDay, super.confirm_date) = 0
  452. <if test="businessType != null and businessType != ''">
  453. AND super.type = #{businessType}
  454. </if>
  455. <if test="areaRegion != null and areaRegion != ''">
  456. AND super.area in ${areaRegion}
  457. </if>
  458. ) AS inspectCount,
  459. (
  460. SELECT COUNT(1)
  461. FROM t_b_complaint AS cpt
  462. WHERE DATEDIFF(last5Day.tempDay, cpt.complaint_date) = 0
  463. <if test="businessType != null and businessType != ''">
  464. AND cpt.business_type = #{businessType}
  465. </if>
  466. <if test="areaRegion != null and areaRegion != ''">
  467. AND cpt.area = #{areaRegion}
  468. </if>
  469. ) AS complaintCount
  470. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  471. FROM (
  472. SELECT @xi := @xi + 1 AS i
  473. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  474. (SELECT @xi := -1) xc0
  475. ) xc
  476. ORDER BY tempDay DESC
  477. ) last5Day
  478. ORDER BY last5Day.tempDay DESC
  479. ) as a
  480. </select>
  481. <!--1920通过区域获取近1日内清洁指数-->
  482. <select id="selectOneDayClearingIndexByRegion1920" resultType="java.util.Map">
  483. select * from (
  484. SELECT SUM(tbcsc.done_count)/100 completeCount
  485. FROM t_b_car_schedule_task_detail AS tbcstd
  486. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  487. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  488. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  489. WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
  490. <if test="regionCode != null and regionCode != ''">
  491. AND route.area_region = #{regionCode}
  492. </if>
  493. ) AS a,
  494. (
  495. SELECT COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
  496. FROM t_b_car_schedule_task_detail AS tbcstd
  497. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  498. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  499. WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
  500. <if test="regionCode != null and regionCode != ''">
  501. AND route.area_region = #{regionCode}
  502. </if>
  503. ) AS b,
  504. (
  505. SELECT COUNT(1) inspectCount
  506. FROM t_b_schedule_superivse AS super
  507. WHERE super.supervise_date = CURRENT_DATE()
  508. <if test="r1 != null and r1 != ''">
  509. AND super.area = #{r1}
  510. </if>
  511. <if test="r2 != null and r2 != ''">
  512. or super.area = #{r2}
  513. </if>
  514. <if test="r3 != null and r3 != ''">
  515. or super.area = #{r3}
  516. </if>
  517. ) AS c,
  518. (
  519. SELECT COUNT(1) completeInspectCount
  520. FROM t_b_schedule_superivse AS super
  521. WHERE super.supervise_date = CURRENT_DATE()
  522. <if test="r1 != null and r1 != ''">
  523. AND super.area = #{r1}
  524. </if>
  525. <if test="r2 != null and r2 != ''">
  526. or super.area = #{r2}
  527. </if>
  528. <if test="r3 != null and r3 != ''">
  529. or super.area = #{r3}
  530. </if>
  531. AND super.status = '1'
  532. ) AS d,
  533. (
  534. SELECT COUNT(1) complaintCount
  535. FROM t_b_complaint AS cpt
  536. WHERE DATEDIFF(CURDATE(), cpt.complaint_date) = 0
  537. <if test="regionCode != null and regionCode != ''">
  538. AND cpt.area = #{regionCode}
  539. </if>
  540. ) AS e,
  541. (
  542. SELECT COUNT(1) completeComplaintCount
  543. FROM t_b_complaint AS cpt
  544. WHERE DATEDIFF(CURDATE(), cpt.complaint_date) = 0
  545. <if test="regionCode != null and regionCode != ''">
  546. AND cpt.area = #{regionCode}
  547. </if>
  548. AND cpt.status = '1'
  549. ) AS f
  550. </select>
  551. <!--3840通过区域获取近1日内清洁指数-->
  552. <select id="selectOneDayClearingIndexByRegion" resultType="java.util.Map">
  553. select *
  554. from (
  555. SELECT SUM(tbcsc.done_count)/100 completeCount
  556. FROM t_b_car_schedule_task_detail AS tbcstd
  557. left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
  558. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  559. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  560. WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
  561. AND route.area_region = 1
  562. ) AS a,
  563. (
  564. SELECT COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
  565. FROM t_b_car_schedule_task_detail AS tbcstd
  566. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
  567. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  568. WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
  569. AND route.area_region = 1
  570. ) AS b,
  571. (
  572. SELECT COUNT(1) inspectCount
  573. FROM t_b_schedule_superivse AS super
  574. WHERE TO_DAYS(super.supervise_date) = TO_DAYS(NOW())
  575. AND super.area in (5,6,7)
  576. ) AS c,
  577. (
  578. SELECT COUNT(1) completeInspectCount
  579. FROM t_b_schedule_superivse AS super
  580. WHERE DATEDIFF(CURDATE(), super.supervise_date) = 0
  581. AND super.area in (5,6,7)
  582. AND super.status = 1
  583. ) AS d,
  584. (
  585. SELECT COUNT(1) complaintCount
  586. FROM t_b_complaint AS cpt
  587. WHERE DATEDIFF(CURDATE(), cpt.complaint_date) = 0
  588. AND cpt.area = 1
  589. ) AS e,
  590. (
  591. SELECT COUNT(1) completeComplaintCount
  592. FROM t_b_complaint AS cpt
  593. WHERE DATEDIFF(CURDATE(), cpt.complaint_date) = 0
  594. AND cpt.area = 1
  595. AND cpt.status = 3
  596. ) AS f
  597. </select>
  598. <!-- 3840 当日督查问题 -->
  599. <select id="todayInspectInfo" resultType="com.daju.mix.dto.TodayProblemSummaryDto">
  600. SELECT create_date time, context info, status state
  601. FROM t_b_schedule_superivse
  602. WHERE TO_DAYS(supervise_date) = TO_DAYS(NOW())
  603. </select>
  604. <select id="inspectInfoKy" resultType="com.daju.mix.dto.ProblemKy">
  605. SELECT code code, context content, status status
  606. FROM t_b_schedule_superivse
  607. WHERE TO_DAYS(supervise_date) = TO_DAYS(NOW())
  608. </select>
  609. <!-- 3840 当日投诉问题 -->
  610. <select id="todayComplainInfo" resultType="com.daju.mix.dto.TodayProblemSummaryDto">
  611. SELECT complaint_date time, complaint_context info, status status
  612. FROM t_b_complaint
  613. WHERE TO_DAYS(complaint_date) = TO_DAYS(NOW())
  614. AND status = 3
  615. </select>
  616. <select id="complainInfoKy" resultType="com.daju.mix.dto.ProblemKy">
  617. SELECT code code, complaint_context content, status state
  618. FROM t_b_complaint
  619. WHERE TO_DAYS(complaint_date) = TO_DAYS(NOW())
  620. AND status = 3
  621. </select>
  622. <!-- 3840 当日警报问题 -->
  623. <select id="todayWorkingAlertInfo" resultType="com.daju.mix.dto.AlarmDto">
  624. SELECT tba.alarm_time time, tba.context info
  625. FROM t_b_car_schedule_task_arrange AS csta
  626. LEFT JOIN t_b_car_schedule_task AS cst
  627. ON cst.id = csta.arrange_id
  628. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  629. LEFT JOIN t_b_alarm AS tba ON csta.user_id = tba.alarm_user
  630. WHERE csta.create_date = TO_DAYS(CURDATE())
  631. AND tba.alarm_time = TO_DAYS(CURDATE())
  632. AND route.area_region = 3
  633. </select>
  634. <!-- to ky 当日人员/车辆排班 -->
  635. <select id="todayPersonScheduler" resultType="com.daju.mix.dto.TodaySchedulerDto">
  636. select td.username name, ts.type jobTask, ts.work_time time
  637. from t_b_car_schedule_task_detail td
  638. left join t_b_car_schedule_task ts
  639. on td.pid = ts.id
  640. left join t_personnel_real_position trp on td.user_id = trp.person_id
  641. where TO_DAYS(CONCAT(td.yearmonth
  642. , '-'
  643. , td.code_day)) = TO_DAYS(NOW())
  644. and td.username != ''
  645. and TO_DAYS(trp.gps_time) = TO_DAYS(NOW())
  646. </select>
  647. <select id="todayCarScheduler" resultType="com.daju.mix.dto.TodaySchedulerDto">
  648. select tc.plate name, ts.type jobTask, ts.work_time time
  649. from t_b_car_schedule_task_detail td
  650. left join t_b_car_schedule_task ts
  651. on td.pid = ts.id
  652. left join t_b_car tc on tc.id = td.carid
  653. left join t_b_car_now tn on tn.carid = td.carid
  654. where TO_DAYS(CONCAT(td.yearmonth
  655. , '-'
  656. , td.code_day)) = TO_DAYS(NOW())
  657. and tc.plate != ''
  658. and TO_DAYS(tn.gps_time) = TO_DAYS(NOW())
  659. </select>
  660. <!-- 1920 近六个月碳排放量变化趋势 -->
  661. <select id="getOilSix" resultType="com.daju.mix.dto.OilSixDTO">
  662. SELECT DATE_FORMAT(
  663. last6Month.tempMonth,
  664. '%c月'
  665. ) AS xLabels,
  666. IFNULL(
  667. (
  668. SELECT SUM(gas.quantity)
  669. FROM
  670. t_b_car_gas_refuel AS gas
  671. RIGHT JOIN (
  672. SELECT route.area_region,
  673. csta.carid carid,
  674. CONCAT(csta.yearmonth,'-',csta.code_day) date
  675. FROM t_b_car_schedule_task_detail AS csta
  676. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  677. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  678. WHERE csta.carid IS NOT NULL
  679. <if test="areaRegion != null and areaRegion != ''">
  680. AND route.area_region = #{areaRegion}
  681. </if>
  682. GROUP BY csta.carid,
  683. CONCAT(csta.yearmonth,'-',csta.code_day)
  684. ) AS areaCar
  685. ON (
  686. areaCar.carid = gas.car_id
  687. AND DATEDIFF(areaCar.date, gas.refuel_date) = 0
  688. )
  689. WHERE DATE_FORMAT(
  690. last6Month.tempMonth, '%Y.%m') = DATE_FORMAT(gas.refuel_date, '%Y.%m')),0
  691. ) AS chartValues
  692. FROM (
  693. SELECT ADDDATE(NOW(), INTERVAL - i MONTH) AS tempMonth
  694. FROM (
  695. SELECT 0 as i
  696. UNION
  697. SELECT 1
  698. UNION
  699. SELECT 2
  700. UNION
  701. SELECT 3
  702. UNION
  703. SELECT 4
  704. UNION
  705. SELECT 5
  706. UNION
  707. SELECT 6) xc
  708. ORDER BY tempMonth DESC
  709. ) last6Month
  710. ORDER BY last6Month.tempMonth asc LIMIT 6
  711. </select>
  712. <!-- 获取近6月环卫车辆排放变化趋势信息-->
  713. <select id="selectCarCEmissionByRegion" resultType="java.util.Map">
  714. SELECT DATE_FORMAT(
  715. last6Month.tempMonth,
  716. '%c月'
  717. ) AS xMonth,
  718. IFNULL(
  719. (
  720. SELECT SUM(gas.total_oil)
  721. FROM
  722. t_b_car_gas_statistics AS gas
  723. RIGHT JOIN (
  724. SELECT route.area_region,
  725. csta.carid,
  726. CONCAT(csta.yearmonth,'-',csta.code_day) date
  727. FROM t_b_car_schedule_task_detail AS csta
  728. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  729. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  730. WHERE csta.carid IS NOT NULL
  731. <if test="areaRegion != null and areaRegion != ''">
  732. AND route.area_region = #{areaRegion}
  733. </if>
  734. GROUP BY csta.carid,
  735. CONCAT(csta.yearmonth,'-',csta.code_day)
  736. ) AS areaCar ON (
  737. areaCar.carid = gas.car_id
  738. AND DATEDIFF(areaCar.date, gas.end_date) = 0
  739. )
  740. WHERE DATE_FORMAT(
  741. last6Month.tempMonth,
  742. '%Y.%m'
  743. ) = DATE_FORMAT(gas.end_date, '%Y.%m')
  744. ),
  745. 0
  746. ) AS thisYearTotalOil,
  747. IFNULL(
  748. (
  749. SELECT SUM(m.mileage)
  750. FROM
  751. t_b_car_mileage_day AS m
  752. RIGHT JOIN (
  753. SELECT route.area_region,
  754. csta.carid,
  755. CONCAT(csta.yearmonth,'-',csta.code_day) date
  756. FROM t_b_car_schedule_task_detail AS csta
  757. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  758. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  759. WHERE csta.carid IS NOT NULL
  760. <if test="areaRegion != null and areaRegion != ''">
  761. AND route.area_region = #{areaRegion}
  762. </if>
  763. GROUP BY csta.carid,
  764. CONCAT(csta.yearmonth,'-',csta.code_day)
  765. ) AS areaCar ON (
  766. areaCar.carid = m.car_id
  767. AND DATEDIFF(areaCar.date, m.date) = 0
  768. )
  769. WHERE DATE_FORMAT(
  770. last6Month.tempMonth,
  771. '%Y.%m'
  772. ) = DATE_FORMAT(m.date, '%Y.%m')
  773. ),
  774. 0
  775. ) AS thisYearMileage,
  776. IFNULL(
  777. (
  778. SELECT SUM(gas.total_oil)
  779. FROM
  780. t_b_car_gas_statistics AS gas
  781. RIGHT JOIN (
  782. SELECT route.area_region,
  783. csta.carid,
  784. CONCAT(csta.yearmonth,'-',csta.code_day) date
  785. FROM t_b_car_schedule_task_detail AS csta
  786. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  787. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  788. WHERE csta.carid IS NOT NULL
  789. <if test="areaRegion != null and areaRegion != ''">
  790. AND route.area_region = #{areaRegion}
  791. </if>
  792. GROUP BY csta.carid,
  793. CONCAT(csta.yearmonth,'-',csta.code_day)
  794. ) AS areaCar ON (
  795. areaCar.carid = gas.car_id
  796. AND DATEDIFF(areaCar.date, gas.end_date) = 0
  797. )
  798. WHERE DATE_FORMAT(
  799. ADDDATE(
  800. last6Month.tempMonth,
  801. INTERVAL - 1 YEAR
  802. ),
  803. '%Y.%m'
  804. ) = DATE_FORMAT(gas.start_date, '%Y.%m')
  805. ),
  806. 0
  807. ) AS lastYearTotalOil,
  808. IFNULL(
  809. (
  810. SELECT SUM(m.mileage)
  811. FROM
  812. t_b_car_mileage_day AS m
  813. RIGHT JOIN (
  814. SELECT route.area_region,
  815. csta.carid,
  816. CONCAT(csta.yearmonth,'-',csta.code_day) date
  817. FROM t_b_car_schedule_task_detail AS csta
  818. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  819. LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
  820. WHERE csta.carid IS NOT NULL
  821. <if test="areaRegion != null and areaRegion != ''">
  822. AND route.area_region = #{areaRegion}
  823. </if>
  824. GROUP BY csta.carid,
  825. CONCAT(csta.yearmonth,'-',csta.code_day)
  826. ) AS areaCar ON (
  827. areaCar.carid = m.car_id
  828. AND DATEDIFF(areaCar.date, m.date) = 0
  829. )
  830. WHERE DATE_FORMAT(
  831. ADDDATE(
  832. last6Month.tempMonth,
  833. INTERVAL - 1 YEAR
  834. ),
  835. '%Y.%m'
  836. ) = DATE_FORMAT(m.date, '%Y.%m')
  837. ),
  838. 0
  839. ) AS lastYearMileage
  840. FROM (
  841. SELECT ADDDATE(NOW(), INTERVAL - i MONTH) AS tempMonth
  842. FROM (
  843. SELECT 0 as i
  844. UNION
  845. SELECT 1
  846. UNION
  847. SELECT 2
  848. UNION
  849. SELECT 3
  850. UNION
  851. SELECT 4
  852. UNION
  853. SELECT 5
  854. UNION
  855. SELECT 6) xc
  856. ORDER BY tempMonth DESC
  857. ) last6Month
  858. ORDER BY last6Month.tempMonth asc LIMIT 6
  859. </select>
  860. <!--通过区域获取近5日内投诉和问题总数-->
  861. <select id="selectLast5DayComplainCount" resultType="java.util.Map">
  862. SELECT * FROM
  863. (
  864. SELECT COUNT(1) AS totalCount
  865. FROM t_b_complaint AS a
  866. WHERE a.complaint_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  867. <if test="areaRegion != null and areaRegion != ''">
  868. AND a.area = #{areaRegion}
  869. </if>
  870. ) a
  871. ,
  872. (
  873. SELECT COUNT(1) AS solveCount
  874. FROM t_b_complaint AS a
  875. WHERE a.complaint_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  876. AND a.`status` = 4
  877. <if test="areaRegion != null and areaRegion != ''">
  878. AND a.area = #{areaRegion}
  879. </if>
  880. ) b
  881. </select>
  882. <!--根据id获取投诉详情-->
  883. <select id="selectComplainById" resultType="java.util.Map">
  884. SELECT
  885. complaint_date complaintDate,
  886. complaint_context complaintContext,
  887. complaint_location complaintLocation,
  888. depart_id departName,
  889. IFNULL(img_url,photos) imgUrl,
  890. videos videoUrlList,
  891. (
  892. SELECT
  893. typename
  894. FROM
  895. t_s_type
  896. WHERE
  897. typegroupid IN (
  898. SELECT
  899. id
  900. FROM
  901. t_s_typegroup
  902. WHERE
  903. typegroupcode = "complaintFrom"
  904. )
  905. AND typecode = tbc.complaint_from
  906. ) complaintFromName,
  907. (
  908. SELECT
  909. typename
  910. FROM
  911. t_s_type
  912. WHERE
  913. typegroupid IN (
  914. SELECT
  915. id
  916. FROM
  917. t_s_typegroup
  918. WHERE
  919. typegroupcode = "complainType"
  920. )
  921. AND typecode = tbc.type
  922. ) complaintType,
  923. (
  924. SELECT
  925. typename
  926. FROM
  927. t_s_type
  928. WHERE
  929. typegroupid IN (
  930. SELECT
  931. id
  932. FROM
  933. t_s_typegroup
  934. WHERE
  935. typegroupcode = "complaintCorrectionState"
  936. )
  937. AND typecode = tbc.`status`
  938. ) complaintStatus
  939. FROM
  940. t_b_complaint tbc
  941. WHERE
  942. tbc.id = #{id}
  943. </select>
  944. <!--根据id获取投诉整改详情-->
  945. <select id="selectComplainRecordById" resultType="java.util.Map">
  946. SELECT img_url imgUrl,complaint_date complaintDate,remark
  947. FROM t_b_complaint_record
  948. WHERE complaint_id = #{id}
  949. </select>
  950. <!--根据id获取督查详情-->
  951. <select id="selectInspectorById" resultType="java.util.Map">
  952. SELECT
  953. supervise_date superviseDate,
  954. img_url imgUrl,
  955. videos videoUrlList,
  956. result_url resultUrl,
  957. (select realname from t_s_base_user where id = user_id LIMIT 1) superviseUserName,
  958. (select typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = "complaintFrom") and typecode = type) type,
  959. (select typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = "complainType") and typecode = source) source,
  960. (select typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = "superivseArea") and typecode = area) area,
  961. location,
  962. context,
  963. (select realname from t_s_base_user where id = responsible_user_id LIMIT 1) responsibleUserName,
  964. (select realname from t_s_base_user where id = leader_user_id LIMIT 1) leaderUserName,
  965. (select typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = "superivseStatus") and typecode = `status`) superviseStatus
  966. FROM
  967. t_b_schedule_superivse
  968. WHERE id = #{id}
  969. </select>
  970. <!--根据id获取督查整改详情-->
  971. <select id="selectInspectorRecordById" resultType="java.util.Map">
  972. SELECT
  973. deal_date dealDate,
  974. img_url imgUrl
  975. FROM
  976. t_b_schedule_superivse_record
  977. WHERE supervise_id = #{id}
  978. </select>
  979. <!--通过区域获取近5日内督查问题总数-->
  980. <select id="selectLast5DayInspectorCount" resultType="java.util.Map">
  981. SELECT * FROM
  982. (
  983. SELECT COUNT(1) AS totalCount
  984. FROM t_b_schedule_superivse AS s
  985. WHERE s.supervise_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  986. <if test="areaRegion != null and areaRegion != ''">
  987. AND s.area in ${areaRegion}
  988. </if>
  989. ) a
  990. ,
  991. (
  992. SELECT COUNT(1) AS finishCount
  993. FROM t_b_schedule_superivse AS s
  994. WHERE s.supervise_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  995. AND s.status = 5
  996. <if test="areaRegion != null and areaRegion != ''">
  997. AND s.area in ${areaRegion}
  998. </if>
  999. ) b
  1000. </select>
  1001. <!--通过作业类型获取近5日内投诉和问题总数-->
  1002. <select id="selectLast5DayComplainCountByBusinessType" resultType="java.util.Map">
  1003. SELECT (
  1004. SELECT type.typename
  1005. FROM t_s_typegroup AS typeg
  1006. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1007. WHERE typeg.typegroupcode = 'complainType'
  1008. AND c.type = type.typecode
  1009. ) AS complainType,
  1010. COUNT(1) AS indexData,
  1011. (
  1012. SELECT COUNT(1)
  1013. FROM t_b_complaint AS a
  1014. WHERE a.complaint_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  1015. AND a.`status` = 4
  1016. <if test="businessType != null and businessType != ''">
  1017. AND a.type = #{businessType}
  1018. </if>
  1019. <if test="regionType != null and regionType != ''">
  1020. AND a.area = #{regionType}
  1021. </if>
  1022. AND a.type = c.type
  1023. ) AS solveCount
  1024. FROM t_b_complaint AS c
  1025. WHERE c.complaint_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  1026. <if test="businessType != null and businessType != ''">
  1027. AND c.type = #{businessType}
  1028. </if>
  1029. <if test="regionType != null and regionType != ''">
  1030. AND c.area = #{regionType}
  1031. </if>
  1032. GROUP BY c.type
  1033. </select>
  1034. <!--3840通过作业类型获取近5日内投诉和问题总数-->
  1035. <select id="selectLast5DayComplainCountByBusinessType3840" resultType="java.util.Map">
  1036. select tst.typename complainType, ifnull(sas.indexData, 0) indexData, ifnull(sas.solveCount, 0) solveCount
  1037. from (SELECT (
  1038. SELECT type.typename
  1039. FROM t_s_typegroup AS typeg
  1040. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1041. WHERE typeg.typegroupcode = 'complainType'
  1042. AND c.type = type.typecode
  1043. ) AS complainType,
  1044. COUNT(1) AS indexData,
  1045. (
  1046. SELECT COUNT(1)
  1047. FROM t_b_complaint AS a
  1048. WHERE a.complaint_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1049. AND a.status = 4
  1050. AND a.area = 3
  1051. AND a.type = c.type
  1052. ) AS solveCount
  1053. FROM t_b_complaint AS c
  1054. WHERE c.complaint_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1055. AND c.area = 3
  1056. GROUP BY c.type) sas
  1057. right join (select typename from t_s_type where typegroupid = 'ff8080817b3a196e017b428f6c130016') tst
  1058. on tst.typename = sas.complainType
  1059. </select>
  1060. <!-- 获取近 5 日督查问题类型统计信息 -->
  1061. <select id="selectLast5DayInspectorTypeCount" resultType="java.util.Map">
  1062. SELECT (
  1063. SELECT type.typename
  1064. FROM t_s_typegroup AS typeg
  1065. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1066. WHERE typeg.typegroupcode = 'complainType'
  1067. AND superivse.source = type.typecode
  1068. ) AS superivseType,
  1069. COUNT(1) AS totalCount,
  1070. (
  1071. SELECT COUNT(1)
  1072. FROM t_b_schedule_superivse AS ss
  1073. WHERE ss.supervise_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1074. AND ss.`status` = 3
  1075. AND ss.source = superivse.source
  1076. ) AS solveCount
  1077. FROM t_b_schedule_superivse AS superivse
  1078. WHERE superivse.supervise_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1079. GROUP BY superivse.type
  1080. </select>
  1081. <!-- 3840获取近 5 日督查问题类型统计信息 -->
  1082. <select id="selectLast5DayInspectorTypeCount3840" resultType="java.util.Map">
  1083. select tst.typename superivseType, ifnull(sas.totalCount, 0) totalCount, ifnull(sas.solveCount, 0) solveCount
  1084. from (SELECT (
  1085. SELECT type.typename
  1086. FROM t_s_typegroup AS typeg
  1087. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1088. WHERE typeg.typegroupcode = 'complainType'
  1089. AND superivse.source = type.typecode
  1090. ) AS superivseType,
  1091. COUNT(1) AS totalCount,
  1092. (
  1093. SELECT COUNT(1)
  1094. FROM t_b_schedule_superivse AS ss
  1095. WHERE ss.supervise_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1096. AND ss.`status` = 3
  1097. AND ss.source = superivse.source
  1098. ) AS solveCount
  1099. FROM t_b_schedule_superivse AS superivse
  1100. WHERE superivse.supervise_date &gt;= DATE_ADD(NOW(), INTERVAL - #{num} DAY)
  1101. GROUP BY superivse.source) sas
  1102. right join (select typename from t_s_type where typegroupid = 'ff8080817b3a196e017b428f6c130016') tst
  1103. on tst.typename = sas.superivseType
  1104. </select>
  1105. <!--通过作业区域获取近5日内督查问题总数-->
  1106. <select id="selectSuperivseCountLast5Day" resultType="java.util.Map">
  1107. SELECT (
  1108. SELECT type.typename
  1109. FROM t_s_typegroup AS typeg
  1110. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1111. WHERE typeg.typegroupcode = 'superivseArea'
  1112. AND superivse.area = type.typecode
  1113. ) AS superivseArea,
  1114. COUNT(1) AS totalCount,
  1115. (
  1116. SELECT COUNT(1)
  1117. FROM t_b_schedule_superivse AS ss
  1118. WHERE DATEDIFF(ss.supervise_date, NOW()) <![CDATA[<]]> 5
  1119. AND ss.`status` = 2
  1120. <if test="businessType != null and businessType != ''">
  1121. AND ss.type = #{businessType}
  1122. </if>
  1123. AND ss.area = superivse.area
  1124. ) AS solveCount
  1125. FROM t_b_schedule_superivse AS superivse
  1126. WHERE DATEDIFF(superivse.supervise_date, NOW()) <![CDATA[<]]> 5
  1127. <if test="businessType != null and businessType != ''">
  1128. AND superivse.type = #{businessType}
  1129. </if>
  1130. <if test="regionType != null and regionType != ''">
  1131. AND superivse.area in ${regionType}
  1132. </if>
  1133. GROUP BY ceil((superivse.area - 1) / 3)
  1134. </select>
  1135. <!--通过区域获取近5日内投诉和问题明细-->
  1136. <select id="selectLast5DayComplainList" resultType="com.daju.mix.dto.CimLast5ComplainDto">
  1137. SELECT p.id,
  1138. p.complaint_context AS complainContent,
  1139. (
  1140. SELECT type.typename
  1141. FROM t_s_typegroup AS typeg
  1142. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1143. WHERE typeg.typegroupcode = 'complaintFrom'
  1144. AND p.complaint_from = type.typecode
  1145. ) AS complainSource,
  1146. IFNULL(
  1147. DATE_FORMAT(p.deal_date, '%Y.%m.%d'),
  1148. '未解决'
  1149. ) AS solveTime
  1150. FROM t_b_complaint AS p
  1151. WHERE p.complaint_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  1152. <if test="areaRegion != null and areaRegion != ''">
  1153. AND p.area = #{areaRegion}
  1154. </if>
  1155. </select>
  1156. <!--通过区域获取近5日内督查问题明细-->
  1157. <select id="selectLast5DayInspectorList" resultType="com.daju.mix.dto.CimLast5InspectorDto">
  1158. SELECT superivse.id,
  1159. superivse.location AS problemLocation,
  1160. DATE_FORMAT(superivse.supervise_date, '%Y.%m.%d') AS reportTime,
  1161. IFNULL(
  1162. DATE_FORMAT(superivse.deal_date, '%Y.%m.%d'),
  1163. '未解决'
  1164. ) AS solveTime
  1165. FROM t_b_schedule_superivse AS superivse
  1166. WHERE superivse.supervise_date &gt;= DATE_ADD(NOW(),INTERVAL -5 DAY)
  1167. <if test="areaRegion != null and areaRegion != ''">
  1168. AND superivse.area in ${areaRegion}
  1169. </if>
  1170. </select>
  1171. <!--通过类型获取近5日内投诉和问题明细-->
  1172. <select id="selectLast5DayComplainListByBusinessType" resultType="com.daju.mix.dto.CimLast5ComplainTypeDto">
  1173. SELECT p.id,
  1174. p.`code` AS complaintCode,
  1175. (
  1176. SELECT type.typename
  1177. FROM t_s_typegroup AS typeg
  1178. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1179. WHERE typeg.typegroupcode = 'complainType'
  1180. AND p.type = type.typecode
  1181. ) AS complaintType,
  1182. p.complaint_context AS complainContent,
  1183. DATE_FORMAT(
  1184. p.complaint_date,
  1185. '%Y.%m.%d'
  1186. ) AS complaintTime,
  1187. IFNULL(
  1188. DATE_FORMAT(p.deal_date, '%Y.%m.%d'),
  1189. ''
  1190. ) AS dealDate,
  1191. IFNULL(
  1192. DATE_FORMAT(p.confirm_date, '%Y.%m.%d'),
  1193. ''
  1194. ) AS confirmDate,
  1195. CASE p.`status`
  1196. WHEN '1' THEN
  1197. '整改中'
  1198. WHEN '2' THEN
  1199. '待确认'
  1200. WHEN '3' THEN
  1201. '已整改'
  1202. ELSE
  1203. '整改中'
  1204. END AS solveState
  1205. FROM t_b_complaint AS p
  1206. WHERE DATEDIFF(p.complaint_date, NOW()) <![CDATA[<]]> 5
  1207. <if test="businessType != null and businessType != ''">
  1208. AND p.type = #{businessType}
  1209. </if>
  1210. <if test="regionType != null and regionType != ''">
  1211. AND p.area = #{regionType}
  1212. </if>
  1213. </select>
  1214. <!--通过类型作业区域分组获取近5日内督查问题明细-->
  1215. <select id="selectSuperviseLast5DayList" resultType="com.daju.mix.dto.CimLast5SuperivseTypeDto">
  1216. SELECT ss.id,
  1217. ss.`code` AS inspectorCode,
  1218. ss.location AS regionName,
  1219. (
  1220. SELECT type.typename
  1221. FROM t_s_typegroup AS typeg
  1222. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1223. WHERE typeg.typegroupcode = 'superivseType'
  1224. AND ss.type = type.typecode
  1225. ) AS problemType,
  1226. CASE ss.`status`
  1227. WHEN '1' THEN
  1228. '整改中'
  1229. WHEN '2' THEN
  1230. '待确认'
  1231. WHEN '3' THEN
  1232. '已整改'
  1233. ELSE
  1234. '整改中'
  1235. END AS solveState
  1236. FROM t_b_schedule_superivse AS ss
  1237. WHERE DATEDIFF(ss.supervise_date, NOW()) <![CDATA[<]]> 5
  1238. <if test="businessType != null and businessType != ''">
  1239. AND ss.type = #{businessType}
  1240. </if>
  1241. <if test="regionType != null and regionType != ''">
  1242. AND ss.area in ${regionType}
  1243. </if>
  1244. </select>
  1245. <!--获取今日作业车辆行驶距离-->
  1246. <select id="getTodayDrivingDistance" resultType="double">
  1247. SELECT IFNULL(SUM(m.mileage), 0) AS todayDrivingDistance
  1248. FROM
  1249. t_b_car_mileage_day AS m
  1250. <if test="areaRegion != null and areaRegion != ''">
  1251. RIGHT JOIN (
  1252. SELECT csta.carid
  1253. FROM t_b_car_schedule_task_detail AS csta
  1254. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
  1255. RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
  1256. WHERE CONCAT(csta.yearmonth,'-',csta.code_day) = CURRENT_DATE()
  1257. AND route.area_region = #{areaRegion}
  1258. GROUP BY csta.carid
  1259. ) AS car ON m.car_id = car.carid
  1260. </if>
  1261. WHERE DATEDIFF(m.date, NOW()) = 0
  1262. </select>
  1263. <!--1920获取今日作业指定车辆信息-->
  1264. <select id="getVehiclesInfoByCarid1920" resultType="java.util.Map">
  1265. SELECT car.id id,
  1266. IF(car.image IS NULL OR car.image = "","",CONCAT('http://47.100.210.233/',car.image)) photo,
  1267. car.plate plateNum,
  1268. (
  1269. SELECT type.typename
  1270. FROM t_s_typegroup AS typeg
  1271. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1272. WHERE typeg.typegroupcode = 'cartype'
  1273. AND car.type = type.typecode
  1274. ) AS vehicleType,
  1275. (
  1276. select count(1) from t_b_alarm where alarm_car = #{userId} and TO_DAYS(NOW()) = TO_DAYS(alarm_time)
  1277. ) AS alertCount,
  1278. gas.hundred_km_oil AS oilConsumption,
  1279. tc.work_route AS workingLine,
  1280. ifnull(car.video_provider, "未录入") AS videoProvider
  1281. FROM t_b_car AS car
  1282. LEFT JOIN t_b_car_gas_statistics AS gas ON gas.car_id = car.id
  1283. LEFT JOIN t_b_car_schedule AS tc ON tc.carid = car.id
  1284. WHERE car.id = #{userId} limit 1
  1285. </select>
  1286. <!--1920获取今日作业指定车辆信息-->
  1287. <!--<select id="getVehiclesInfoByCarid1920" resultType="java.util.Map">
  1288. SELECT car.id id, car.plate plateNum,
  1289. (
  1290. SELECT type.typename
  1291. FROM t_s_typegroup AS typeg
  1292. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1293. WHERE typeg.typegroupcode = 'cartype'
  1294. AND car.type = type.typecode
  1295. ) AS vehicleType,
  1296. (
  1297. SELECT COUNT(1)
  1298. FROM t_b_alarm AS a
  1299. WHERE DATEDIFF(now(), a.alarm_time) = 0
  1300. ) AS alertCount,
  1301. gas.hundred_km_oil AS oilConsumption,
  1302. ts.work_route AS workingLine
  1303. FROM t_b_car AS car
  1304. LEFT JOIN t_b_car_gas_statistics AS gas ON gas.car_id = car.id
  1305. LEFT JOIN t_b_car_schedule AS ts ON ts.carid = car.id
  1306. WHERE car.id = #{userId}
  1307. </select>-->
  1308. <!--获取今日作业指定车辆信息-->
  1309. <select id="getVehiclesInfoByCarid" resultType="java.util.Map">
  1310. SELECT car.id id,
  1311. ifnull(CONCAT('http://47.100.210.233/', car.image), "") photo,
  1312. car.plate plateNum,
  1313. (
  1314. SELECT type.typename
  1315. FROM t_s_typegroup AS typeg
  1316. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1317. WHERE typeg.typegroupcode = 'cartype'
  1318. AND car.type = type.typecode
  1319. ) AS vehicleType,
  1320. (
  1321. SELECT COUNT(1)
  1322. FROM t_b_alarm AS a
  1323. WHERE DATEDIFF(now(), a.alarm_time) = 0
  1324. ) AS alertCount,
  1325. gas.hundred_km_oil AS oilConsumption,
  1326. ts.work_route AS workingLine,
  1327. ifnull(car.video_provider, "未录入") AS videoProvider
  1328. FROM t_b_car AS car
  1329. LEFT JOIN t_b_car_gas_statistics AS gas ON gas.car_id = car.id
  1330. LEFT JOIN t_b_car_schedule AS ts ON ts.carid = car.id
  1331. WHERE car.id = #{userId}
  1332. </select>
  1333. <select id="getElementGpsInCarData" resultType="java.util.Map">
  1334. SELECT
  1335. tbc.id id,
  1336. tbc.plate `name`,
  1337. '2' elementType,
  1338. tbc.area_region regionCode,
  1339. tbcn.lng longitude,
  1340. tbcn.lat latitude,
  1341. tbcn.gps_time gpsTime
  1342. FROM
  1343. t_b_car_now tbcn
  1344. LEFT JOIN t_b_car tbc ON tbc.id = tbcn.carid
  1345. WHERE
  1346. tbc.id IS NOT NULL
  1347. <if test="areaRegion != null and areaRegion != ''">
  1348. AND tbc.area_region = #{areaRegion}
  1349. </if>
  1350. ORDER BY
  1351. tbc.area_region,
  1352. tbcn.gps_time DESC;
  1353. </select>
  1354. <select id="getElementGpsInUserData" resultType="java.util.Map">
  1355. SELECT
  1356. tsbu.id id,
  1357. tsbu.realname `name`,
  1358. '1' elementType,
  1359. tsu.area_region regionCode,
  1360. tprp.longitude_wgs84 longitude,
  1361. tprp.latitude_wgs84 latitude,
  1362. tprp.gps_time gpsTime
  1363. FROM
  1364. t_personnel_real_position tprp
  1365. LEFT JOIN t_s_base_user tsbu ON tsbu.id = tprp.person_id
  1366. LEFT JOIN t_s_user tsu ON tsu.id = tsbu.id
  1367. WHERE
  1368. tsbu.id IS NOT NULL
  1369. <if test="areaRegion != null and areaRegion != ''">
  1370. AND tsu.area_region = #{areaRegion}
  1371. </if>
  1372. ORDER BY
  1373. tsu.area_region,
  1374. tprp.gps_time DESC;
  1375. </select>
  1376. <!--获取今日作业指定人员信息-->
  1377. <select id="getWorkersInfoByUserid" resultType="com.daju.mix.dto.CimWorkersInfoDto">
  1378. SELECT up.userid AS id,
  1379. ur.realname AS `name`,
  1380. ifnull(CONCAT('http://47.100.210.233/', tu.image), "") AS photo,
  1381. ur.username AS telPhone,
  1382. d.duties_name AS jobTitle,
  1383. (
  1384. SELECT COUNT(1)
  1385. FROM t_b_alarm AS alm
  1386. WHERE DATEDIFF(NOW(), alm.alarm_time) = 0
  1387. AND alm.alarm_user = up.userid
  1388. ) AS todayAlertCount,
  1389. ta.work_route_name AS todayWorkingLine,
  1390. concat(
  1391. DATE_FORMAT(NOW(), '%Y-%m-%d '),
  1392. ta.`start`,
  1393. ':00'
  1394. ) AS workingStartTime,
  1395. concat(
  1396. DATE_FORMAT(NOW(), '%Y-%m-%d '),
  1397. ta.`end`,
  1398. ':00'
  1399. ) AS workingEndTime,
  1400. ts.work_route AS workingRegion
  1401. FROM t_bus_user_personnel AS up
  1402. LEFT JOIN t_bus_duties AS d ON up.belong_dutiesid = d.id
  1403. LEFT JOIN t_s_base_user AS ur ON ur.id = up.userid
  1404. LEFT JOIN t_b_car_schedule_task_detail AS de ON de.username = ur.realname
  1405. LEFT JOIN t_b_car_schedule_task AS ta ON ta.id = de.pid
  1406. LEFT JOIN t_b_car_schedule AS ts ON ts.id = ta.schedule_id
  1407. LEFT JOIN t_b_archives_area AS ba ON ba.manage_man = ur.realname
  1408. LEFT JOIN t_s_user AS tu ON tu.mobilePhone = ur.username
  1409. WHERE up.userid = #{userId} LIMIT 1
  1410. </select>
  1411. <!--1920获取今日作业指定人员信息-->
  1412. <select id="getWorkersInfoByUserid2" resultType="com.daju.mix.dto.CimWorkersInfoDto2">
  1413. SELECT up.userid AS id,
  1414. ur.realname AS `name`,
  1415. ifnull(CONCAT('http://47.100.210.233/', tu.image), "") AS photo,
  1416. ur.username AS telPhone,
  1417. d.duties_name AS jobTitle,
  1418. (
  1419. SELECT COUNT(1)
  1420. FROM t_b_alarm AS alm
  1421. WHERE DATEDIFF(NOW(), alm.alarm_time) = 0
  1422. AND alm.alarm_user = #{userId}
  1423. ) AS todayAlertCount,
  1424. ta.work_route_name AS todayWorkingLine,
  1425. concat(
  1426. DATE_FORMAT(NOW(), '%Y-%m-%d '),
  1427. ta.`start`,
  1428. ':00'
  1429. ) AS workingStartTime,
  1430. concat(
  1431. DATE_FORMAT(NOW(), '%Y-%m-%d '),
  1432. ta.`end`,
  1433. ':00'
  1434. ) AS workingEndTime,
  1435. ts.work_route AS workingRegion
  1436. FROM t_bus_user_personnel AS up
  1437. LEFT JOIN t_bus_duties AS d ON up.belong_dutiesid = d.id
  1438. LEFT JOIN t_s_base_user AS ur ON ur.id = up.userid
  1439. LEFT JOIN t_b_car_schedule_task_detail AS de ON de.user_id = ur.id
  1440. LEFT JOIN t_b_car_schedule_task AS ta ON ta.id = de.pid
  1441. LEFT JOIN t_b_car_schedule AS ts ON ts.id = ta.schedule_id
  1442. LEFT JOIN t_b_archives_area AS ba ON ba.manage_man = ur.realname
  1443. LEFT JOIN t_s_user AS tu ON tu.mobilePhone = ur.username
  1444. WHERE up.userid = #{userId} LIMIT 1
  1445. </select>
  1446. <!--cim home 近5日报警情况-->
  1447. <select id="getLast5AlarmDataList" resultType="com.daju.mix.dto.CimLast5AlarmDataDto">
  1448. SELECT a.id,
  1449. (
  1450. SELECT type.typename
  1451. FROM t_s_typegroup AS typeg
  1452. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1453. WHERE typeg.typegroupcode = 'alarmType'
  1454. AND a.alarm_type = type.typecode
  1455. ) AS alertType,
  1456. a.context AS alertContent,
  1457. (
  1458. SELECT u.realname
  1459. FROM t_s_base_user AS u
  1460. WHERE u.id = a.alarm_recevier
  1461. ) AS leader,
  1462. a.alarm_time AS alertTime
  1463. FROM
  1464. t_b_alarm AS a
  1465. <if test="regionType != null and regionType != ''">
  1466. RIGHT JOIN t_b_archives_place AS place on a.archives_code = place.`code`
  1467. </if>
  1468. WHERE a.alarm_time <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
  1469. <if test="scheduleType != null and scheduleType != ''">
  1470. AND a.schedule_assignment_style = #{scheduleType}
  1471. </if>
  1472. <if test="regionType != null and regionType != ''">
  1473. AND place.area_region = #{regionType}
  1474. </if>
  1475. AND a.alarm_time >= date_format(
  1476. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  1477. '%Y-%m-%d'
  1478. )
  1479. </select>
  1480. <!--3840近5日报警情况-->
  1481. <select id="getLast5AlarmDataList3840" resultType="java.util.Map">
  1482. select tst.typename alertType, ifnull(count(c.alertType), 0) num
  1483. from (SELECT a.id,
  1484. (
  1485. SELECT type.typename
  1486. FROM t_s_typegroup AS typeg
  1487. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1488. WHERE typeg.typegroupcode = 'alarmFrom'
  1489. AND a.alarm_from = type.typecode
  1490. ) AS alertType,
  1491. a.context AS alertContent,
  1492. (
  1493. SELECT u.realname
  1494. FROM t_s_base_user AS u
  1495. WHERE u.id = a.alarm_recevier
  1496. ) AS leader,
  1497. a.alarm_time AS alertTime
  1498. FROM t_b_alarm AS a
  1499. WHERE a.alarm_time &lt;= date_format(NOW(), '%Y-%m-%d')
  1500. AND a.alarm_time &gt;= date_format(
  1501. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  1502. '%Y-%m-%d'
  1503. )) c
  1504. RIGHT JOIN (select typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b62e8670023') tst
  1505. ON tst.typename = c.alertType
  1506. where tst.typename = '洒水作业'
  1507. or tst.typename = '洗扫作业'
  1508. or tst.typename = '路面养护作业'
  1509. or tst.typename = '巡回保洁作业'
  1510. or tst.typename = '机扫作业'
  1511. group by tst.typename
  1512. </select>
  1513. <!--3840近5日报警情况-->
  1514. <select id="getLast5AlarmDataList3840JinBo" resultType="java.util.Map">
  1515. select tst.typename alertType, ifnull(count(c.alertType), 0) num
  1516. from (SELECT a.id,
  1517. (
  1518. SELECT type.typename
  1519. FROM t_s_typegroup AS typeg
  1520. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  1521. WHERE typeg.typegroupcode = 'alarmType'
  1522. AND a.alarm_type = type.typecode
  1523. ) AS alertType,
  1524. a.context AS alertContent,
  1525. (
  1526. SELECT u.realname
  1527. FROM t_s_base_user AS u
  1528. WHERE u.id = a.alarm_recevier
  1529. ) AS leader,
  1530. a.alarm_time AS alertTime
  1531. FROM t_b_alarm AS a
  1532. WHERE a.alarm_time &lt;= date_format(NOW(), '%Y-%m-%d')
  1533. AND a.alarm_time &gt;= date_format(
  1534. DATE_ADD(NOW(), INTERVAL - 1 DAY),
  1535. '%Y-%m-%d'
  1536. )) c
  1537. RIGHT JOIN (select typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b64ead0002b') tst
  1538. ON tst.typename = c.alertType
  1539. where tst.typename = '车辆超速'
  1540. or tst.typename = '视频存储空间不足'
  1541. or tst.typename = '停驻超时'
  1542. or tst.typename = '迟到'
  1543. or tst.typename = '作业未按时完成'
  1544. group by tst.typename
  1545. </select>
  1546. <!--今日作业区域人的位置以及职位-->
  1547. <select id="selectHumRegionAndDuties" resultType="com.daju.mix.dto.AllElementDto">
  1548. SELECT DISTINCT tu.id as id,
  1549. '1' as elementType,
  1550. tu.gender as elementProperty,
  1551. tu.area_region as regionCode,
  1552. prp.longitude_wgs84 as longitude,
  1553. prp.latitude_wgs84 as latitude,
  1554. prp.gps_time as gpsTime
  1555. FROM t_s_user as tu
  1556. LEFT JOIN t_personnel_real_position as prp on prp.person_id = tu.id
  1557. where
  1558. tu.area_region is not null
  1559. <if test="regionType != null and regionType != ''">
  1560. AND tu.area_region = #{regionType}
  1561. </if>
  1562. group by tu.id
  1563. </select>
  1564. <!--3840今日作业区域人的位置以及职位-->
  1565. <select id="selectHumRegionAndDuties3840" resultType="com.daju.mix.dto.AllElement3840Dto">
  1566. SELECT DISTINCT tu.id as id,
  1567. '1' as elementType,
  1568. tu.gender as elementProperty,
  1569. tu.area_region as regionCode,
  1570. prp.longitude_wgs84 as longitude,
  1571. prp.latitude_wgs84 as latitude,
  1572. prp.gps_time as gpsTime
  1573. FROM t_s_user as tu
  1574. LEFT JOIN t_personnel_real_position as prp on prp.person_id = tu.id
  1575. where
  1576. tu.area_region = 3
  1577. group by tu.id
  1578. </select>
  1579. <!-- 巡回保洁车作业区域车的位置 -->
  1580. <select id="selectCarRegionAndDutiesItinerant" resultType="com.daju.mix.dto.AllElementDto">
  1581. SELECT DISTINCT bc.id AS id,
  1582. ifnull(bc.type,0) AS elementType,
  1583. ifnull(bc.energy_type,0) AS elementProperty,
  1584. ifnull(bc.area_region,1) AS regionCode,
  1585. bcn.longitude_wgs84 AS longitude,
  1586. bcn.latitude_wgs84 AS latitude,
  1587. bcn.gps_time AS gpsTime,
  1588. bcn.velocity AS velocity
  1589. FROM t_car_itinerant_clean_real_pos AS bcn
  1590. LEFT JOIN t_b_car AS bc ON bc.id = bcn.card_id
  1591. WHERE
  1592. TO_DAYS(NOW()) = TO_DAYS(bcn.gps_time)
  1593. AND bc.id is NOT NULL
  1594. AND bc.id != ''
  1595. AND bc.type = 'cleancyclic'
  1596. <if test="regionType != null and regionType != ''">
  1597. AND bc.area_region = #{regionType}
  1598. </if>
  1599. group by bc.id
  1600. </select>
  1601. <!--1920今日作业区域车的位置-->
  1602. <select id="selectCarRegionAndDuties" resultType="com.daju.mix.dto.AllElementDto">
  1603. SELECT DISTINCT bc.id AS id,
  1604. ifnull(bc.type, 0) AS elementType,
  1605. ifnull(bc.energy_type, 0) AS elementProperty,
  1606. bc.area_region AS regionCode,
  1607. bcn.lng AS longitude,
  1608. bcn.lat AS latitude,
  1609. bcn.gps_time AS gpsTime,
  1610. bcn.speed AS velocity
  1611. FROM t_b_car bc
  1612. LEFT JOIN t_b_car_now AS bcn ON bcn.carid = bc.id
  1613. WHERE
  1614. bc.id is NOT NULL
  1615. AND bc.id != ''
  1616. AND bc.area_region is not null
  1617. AND bc.type != 'cleancyclic'
  1618. <if test="regionType != null and regionType != ''">
  1619. AND bc.area_region = #{regionType}
  1620. </if>
  1621. group by bc.id
  1622. </select>
  1623. <!--3840今日作业区域车的位置-->
  1624. <select id="selectCarRegionAndDuties3840" resultType="com.daju.mix.dto.AllElement3840Dto">
  1625. SELECT DISTINCT bc.id AS id,
  1626. ifnull(bc.type, 0) AS elementType,
  1627. ifnull(bc.energy_type, 0) AS elementProperty,
  1628. bc.area_region AS regionCode,
  1629. bcn.lng AS longitude,
  1630. bcn.lat AS latitude,
  1631. bcn.gps_time AS gpsTime,
  1632. bcn.speed AS velocity
  1633. FROM t_b_car bc
  1634. LEFT JOIN t_b_car_now AS bcn ON bcn.carid = bc.id
  1635. WHERE
  1636. bc.id is NOT NULL
  1637. AND bc.id != ''
  1638. AND bc.area_region = 3
  1639. group by bc.id
  1640. </select>
  1641. <!--今日作业区域清运点-->
  1642. <select id="selectCleanRegionAndDuties" resultType="com.daju.mix.dto.AllElementDto">
  1643. SELECT DISTINCT
  1644. bap.id AS id,
  1645. ifnull(bap.type,0) AS elementType,
  1646. ifnull(bap.area_region,1) AS regionCode,
  1647. bap.longitude AS longitude,
  1648. bap.latitude AS latitude
  1649. FROM
  1650. t_b_archives_place AS bap
  1651. WHERE
  1652. bap.id != ''
  1653. <if test="regionType != null and regionType != ''">
  1654. AND bap.area_region = #{regionType}
  1655. </if>
  1656. </select>
  1657. <!--3840今日作业区域清运点-->
  1658. <select id="selectCleanRegionAndDuties3840" resultType="com.daju.mix.dto.AllElement3840Dto">
  1659. SELECT DISTINCT bap.id AS id,
  1660. ifnull(bap.type, 0) AS elementType,
  1661. '作业地点' AS elementProperty,
  1662. bap.longitude AS longitude,
  1663. bap.latitude AS latitude
  1664. FROM t_b_archives_place AS bap
  1665. WHERE bap.area_region = 3
  1666. </select>
  1667. <select id="selectItCarRegionAndDuties" resultType="com.daju.mix.dto.AllElementDto">
  1668. SELECT sta.car_id AS id,
  1669. '21' AS elementType,
  1670. '1' AS regionCode,
  1671. '' AS type,
  1672. crp.longitude_wgs84 AS longitude,
  1673. crp.latitude_wgs84 AS latitude
  1674. FROM t_b_car AS sta
  1675. LEFT JOIN t_car_Itinerant_clean_real_pos AS crp ON sta.id = crp.card_id
  1676. WHERE sta.date = DATE_FORMAT(NOW(), '%Y-%m-%d')
  1677. AND sta.id IS not NULL
  1678. AND sta.id != ''
  1679. AND crp.longitude_wgs84 IS not NULL
  1680. AND crp.latitude_wgs84 IS not NULL
  1681. </select>
  1682. <select id="selectItCarRegionAndDuties3840" resultType="com.daju.mix.dto.AllElement3840Dto">
  1683. SELECT sta.car_id AS id,
  1684. '21' AS elementType,
  1685. '' AS type,
  1686. crp.longitude_wgs84 AS longitude,
  1687. crp.latitude_wgs84 AS latitude
  1688. FROM t_b_car_schedule_task_arrange AS sta
  1689. LEFT JOIN t_b_car_schedule_task AS st ON sta.arrange_id = st.id
  1690. LEFT JOIN t_car_Itinerant_clean_real_pos AS crp ON sta.car_id = crp.card_id
  1691. WHERE sta.date = DATE_FORMAT(NOW(), '%Y-%m-%d')
  1692. AND sta.car_id IS not NULL
  1693. AND sta.car_id != ''
  1694. AND crp.longitude_wgs84 IS not NULL
  1695. AND crp.latitude_wgs84 IS not NULL
  1696. </select>
  1697. <select id="getCompletionRate" resultType="com.daju.mix.dto.CompletionRateDto">
  1698. SELECT DISTINCT
  1699. sta.carid AS id,
  1700. tbcru.user_id as infoUserId,
  1701. sta.user_id as userId,
  1702. bc.plate AS plate,
  1703. bc.type AS carType,
  1704. tsbu.realname AS userName,
  1705. st.work_route AS routeId,
  1706. st.type AS workType,
  1707. IF(st.type not in ("16","23","24","25"),bcn.lng,IF(st.type in ("16","23","25"),tprp.longitude_wgs84,tcicr.longitude_wgs84)) AS longitude,
  1708. IF(st.type not in ("16","23","24","25"),bcn.lat,IF(st.type in ("16","23","25"),tprp.latitude_wgs84,tcicr.latitude_wgs84)) AS latitude,
  1709. IF(st.type not in ("16","23","24","25"),bcn.gps_time,IF(st.type in ("16","23","25"),tprp.gps_time,tcicr.gps_time)) AS gpsTime,
  1710. IFNULL(bcn.mileage,0) AS mileage,
  1711. CONCAT(sta.yearmonth, '-', sta.code_day) AS date,
  1712. CONCAT(sta.yearmonth,'-',sta.code_day,' ',st.`start`,':00') AS startTime,
  1713. CONCAT(sta.yearmonth,'-',sta.code_day,' ', st.end, ':00') AS endTime
  1714. FROM t_b_car_schedule_task_detail AS sta
  1715. LEFT JOIN t_b_car_schedule_task AS st ON sta.pid = st.id
  1716. LEFT JOIN t_bus_user_personnel tbup on tbup.userid = SUBSTRING_INDEX(sta.user_id,',',1)
  1717. LEFT JOIN t_b_work_route AS wr ON st.work_route = wr.id
  1718. LEFT JOIN t_b_car AS bc ON sta.carid = bc.id
  1719. LEFT JOIN t_b_car_now AS bcn ON sta.carid = bcn.carid
  1720. LEFT JOIN t_b_car_schedule tbcs on tbcs.id = st.schedule_id
  1721. LEFT JOIN t_bus_post tbp on tbp.id = tbup.in_postid
  1722. LEFT JOIN t_b_car_schedule_type tbcst on tbcst.business_type = tbcs.assignment_style and tbcst.car_type = bc.type and tbcst.user_type = tbp.id
  1723. LEFT JOIN t_b_car_receiver_user tbcru on tbcru.business_type = tbcs.assignment_style and tbcru.area_region = wr.area_region and tbcru.msg_type = '5' and tbcru.schedule_type_id = tbcst.id
  1724. LEFT JOIN t_personnel_real_position tprp on tprp.person_id = sta.user_id
  1725. LEFT JOIN t_s_base_user tsbu on tsbu.id = sta.user_id
  1726. LEFT JOIN t_car_Itinerant_clean_real_pos tcicr on tcicr.card_id = sta.carid
  1727. WHERE CONCAT(sta.yearmonth
  1728. , '-'
  1729. , sta.code_day) = CURDATE() GROUP BY CONCAT(sta.carid,tbcst.business_type,tbcst.car_type,sta.id);
  1730. </select>
  1731. <select id="getCompletionRateRouteListByCarId" resultType="int">
  1732. SELECT
  1733. COUNT(id)
  1734. FROM
  1735. t_b_work_route_list
  1736. WHERE
  1737. route_id IN (
  1738. SELECT
  1739. st.work_route
  1740. FROM
  1741. t_b_car_schedule_task_detail AS sta
  1742. LEFT JOIN t_b_car_schedule_task AS st ON sta.pid = st.id
  1743. LEFT JOIN t_bus_user_personnel tbup ON tbup.userid = SUBSTRING_INDEX(sta.user_id, ',', 1)
  1744. LEFT JOIN t_b_work_route AS wr ON st.work_route = wr.id
  1745. LEFT JOIN t_b_car AS bc ON sta.carid = bc.id
  1746. LEFT JOIN t_b_car_now AS bcn ON sta.carid = bcn.carid
  1747. LEFT JOIN t_b_car_schedule tbcs ON tbcs.id = st.schedule_id
  1748. LEFT JOIN t_bus_post tbp ON tbp.id = tbup.in_postid
  1749. LEFT JOIN t_b_car_schedule_type tbcst ON tbcst.business_type = tbcs.assignment_style
  1750. AND tbcst.car_type = bc.type
  1751. AND tbcst.user_type = tbp.id
  1752. LEFT JOIN t_b_car_receiver_user tbcru ON tbcru.business_type = tbcs.assignment_style
  1753. AND tbcru.area_region = wr.area_region
  1754. AND tbcru.msg_type = '5'
  1755. AND tbcru.schedule_type_id = tbcst.id
  1756. WHERE
  1757. CONCAT(
  1758. sta.yearmonth,
  1759. '-',
  1760. sta.code_day
  1761. ) = CURDATE()
  1762. <if test="carId != null and carId != ''">
  1763. AND sta.carid = #{carId}
  1764. </if>
  1765. <if test="userId != null and userId != ''">
  1766. AND sta.user_id = #{userId}
  1767. </if>
  1768. GROUP BY st.work_route
  1769. );
  1770. </select>
  1771. <select id="getTypeByReglas" resultType="com.daju.api.hardware.dao.entity.TBCarShootReglas">
  1772. select *
  1773. from t_b_car_shoot_reglas
  1774. where
  1775. 1 = 1
  1776. <if test="time != null and time != ''">
  1777. and by_time = 1
  1778. </if>
  1779. <if test="area != null and area != ''">
  1780. and by_area = 1
  1781. </if>
  1782. <if test="status != null and status != ''">
  1783. and by_state = 1
  1784. </if>
  1785. </select>
  1786. <select id="getReglasCarId" resultType="com.daju.api.hardware.dto.ReglasCarIdDto">
  1787. SELECT DISTINCT sta.carid AS id,
  1788. bcn.plate AS plate,
  1789. st.work_route AS routeId,
  1790. bcn.lng AS longitude,
  1791. bcn.lat AS latitude,
  1792. CONCAT(sta.yearmonth, '-', sta.code_day) AS date,
  1793. bc.video_provider AS videoProvider
  1794. FROM t_b_car_schedule_task_detail AS sta
  1795. LEFT JOIN t_b_car_schedule_task AS st
  1796. ON sta.pid = st.id
  1797. LEFT JOIN t_b_work_route AS wr ON st.work_route = wr.id
  1798. LEFT JOIN t_b_car AS bc ON sta.carid = bc.id
  1799. LEFT JOIN t_b_car_now AS bcn ON sta.carid = bcn.carid
  1800. WHERE TO_DAYS(CONCAT(sta.yearmonth
  1801. , '-'
  1802. , sta.code_day)) = TO_DAYS(NOW())
  1803. AND TO_DAYS(NOW()) = TO_DAYS(bcn.gps_time)
  1804. AND sta.carid is NOT NULL
  1805. AND sta.carid != ''
  1806. <if test="type != null and type != ''">
  1807. AND bc.type = #{type}
  1808. </if>
  1809. group by sta.carid
  1810. </select>
  1811. <select id="getCarIdAndPlate" resultType="java.util.Map">
  1812. SELECT
  1813. tbc.id,
  1814. tbc.plate AS NAME,
  1815. tbc.`type` AS carType,
  1816. tst.typename as carTypeName
  1817. FROM
  1818. t_b_car tbc
  1819. LEFT JOIN (
  1820. SELECT
  1821. *
  1822. FROM
  1823. t_s_type
  1824. WHERE
  1825. typegroupid = (
  1826. SELECT
  1827. ID
  1828. FROM
  1829. t_s_typegroup
  1830. WHERE
  1831. typegroupcode = 'cartype'
  1832. )
  1833. ) tst on tst.typecode = tbc.type
  1834. WHERE
  1835. tbc.type not in ('other','pickup','forklift','administration','wash','cleancyclic')
  1836. </select>
  1837. <select id="getAllPeoples" resultType="com.daju.api.hardware.dto.GcbPeoplesDTO">
  1838. SELECT
  1839. ts.id id,
  1840. ts.userNum userNum,
  1841. tb.realname name,
  1842. ts.mobilePhone mobilePhone,
  1843. ts.gender gender,
  1844. ts.nation nation,
  1845. ts.idcard idcard,
  1846. ts.birthday birthday,
  1847. ts.hkaddress hkadress,
  1848. ts.address address,
  1849. td2.departname company,
  1850. td.departname depart,
  1851. tbd.duties_name duties,
  1852. tp.post_name post,
  1853. ts.email email,
  1854. ts.employment_date employmentDate
  1855. FROM
  1856. t_s_user ts
  1857. LEFT JOIN t_s_base_user tb ON tb.id = ts.id
  1858. LEFT JOIN t_s_depart td ON td.id = tb.departid
  1859. LEFT JOIN t_s_depart td2 on td2.id = td.parentdepartid
  1860. LEFT JOIN t_bus_user_personnel tbu ON tbu.userid = ts.id
  1861. LEFT JOIN t_bus_post tp ON tp.id = tbu.in_postid
  1862. LEFT JOIN t_bus_duties tbd ON tbd.id = tbu.belong_dutiesid
  1863. ${ew.customSqlSegment}
  1864. </select>
  1865. <select id="getPeopleSchedule" resultType="com.daju.api.hardware.dto.GcbPeoScheduleDTO">
  1866. SELECT
  1867. ts.userNum userNum,
  1868. ta.username name,
  1869. ts.mobilePhone mobilePhone,
  1870. td2.departname company,
  1871. td.departname depart,
  1872. tbd.duties_name duties,
  1873. tp.post_name post,
  1874. CONCAT(ta.yearmonth,'-',ta.code_day) date,
  1875. tt.work_route_name workRouteName
  1876. FROM
  1877. t_b_car_schedule_task_detail ta
  1878. left join t_s_user ts on ts.id = ta.user_id
  1879. LEFT JOIN t_s_base_user tb ON tb.id = ts.id
  1880. LEFT JOIN t_s_depart td ON td.id = tb.departid
  1881. LEFT JOIN t_s_depart td2 on td2.id = td.parentdepartid
  1882. LEFT JOIN t_bus_user_personnel tbu ON tbu.userid = ts.id
  1883. LEFT JOIN t_bus_post tp ON tp.id = tbu.in_postid
  1884. LEFT JOIN t_bus_duties tbd ON tbd.id = tbu.belong_dutiesid
  1885. LEFT JOIN t_b_car_schedule_task tt ON ta.pid = tt.id
  1886. ${ew.customSqlSegment}
  1887. </select>
  1888. <select id="getToilets" resultType="com.daju.api.hardware.dto.GcbToiletsDTO">
  1889. SELECT
  1890. tp.id id,
  1891. tp.code code,
  1892. tp.name name,
  1893. tu.realname manager,
  1894. tp.mobile_phone mobilePhone,
  1895. tp.position position,
  1896. tp.longitude longitude,
  1897. tp.latitude latitude,
  1898. tp.height height,
  1899. tp.manage_content manageContent,
  1900. tp.vehicle_no01 vehicleNo01,
  1901. tp.vehicle_no02 vehicleNo02,
  1902. tp.vehicle_no03 vehicleNo03,
  1903. tp.channel_no channelNo,
  1904. tp.signing_time signingTime,
  1905. tt.typename areaRegion
  1906. FROM
  1907. t_b_archives_place tp
  1908. LEFT JOIN t_s_base_user tu ON tu.id = tp.manager_id
  1909. LEFT JOIN (select * from t_s_type where typegroupid = 'ff8080817a842ec0017a84a6154f000c') tt ON tt.typecode = tp.area_region
  1910. ${ew.customSqlSegment}
  1911. </select>
  1912. <select id="getBRoom" resultType="com.daju.api.hardware.dto.GcbBRoomDTO">
  1913. SELECT
  1914. tp.id id,
  1915. tp.code code,
  1916. tp.name name,
  1917. tu.realname manager,
  1918. tp.mobile_phone mobilePhone,
  1919. tp.position position,
  1920. tp.longitude longitude,
  1921. tp.latitude latitude,
  1922. tp.height height,
  1923. tp.manage_content manageContent,
  1924. tp.vehicle_no01 vehicleNo01,
  1925. tp.vehicle_no02 vehicleNo02,
  1926. tp.vehicle_no03 vehicleNo03,
  1927. tp.channel_no channelNo,
  1928. tp.signing_time signingTime,
  1929. tt.typename areaRegion
  1930. FROM
  1931. t_b_archives_place tp
  1932. LEFT JOIN t_s_base_user tu ON tu.id = tp.manager_id
  1933. LEFT JOIN (select * from t_s_type where typegroupid = 'ff8080817a842ec0017a84a6154f000c') tt ON tt.typecode = tp.area_region
  1934. ${ew.customSqlSegment}
  1935. </select>
  1936. <select id="getGcbTCo" resultType="com.daju.api.hardware.dto.GcbTCoDTO">
  1937. SELECT
  1938. tbth.toilet_id toiletId,
  1939. tba.name toiletName,
  1940. tba.area_location toiletLocation,
  1941. tt.typename toiletRegion,
  1942. MIN( tbth.time ) minTime,
  1943. MAX( tbth.time ) maxTime,
  1944. SUM( tbth.water_consumption ) waterConsumption,
  1945. SUM( tbth.electricity_consumption ) electricityConsumption,
  1946. SUM( tbth.liquid_soap ) liquidSoap,
  1947. SUM( tbth.disinfectant ) disinfectant,
  1948. SUM( tbth.tissue ) tissue,
  1949. SUM( tbth.cleaning ) cleaning
  1950. FROM
  1951. t_b_toilet_history tbth
  1952. LEFT JOIN t_b_archives_area tba ON tba.id = tbth.toilet_id
  1953. LEFT JOIN (select * from t_s_type where typegroupid = 'ff8080817a842ec0017a84a6154f000c') tt ON tt.typecode = tba.area_region
  1954. ${ew.customSqlSegment}
  1955. </select>
  1956. </mapper>