CimWorkingMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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.CimWorkingMapper">
  4. <resultMap id="BaseResultMap" type="com.daju.mix.dto.InspectorInfosDTO">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="context" jdbcType="VARCHAR" property="inspectContent"/>
  7. <result column="region" jdbcType="VARCHAR" property="inspectRegion"/>
  8. <result column="status" jdbcType="VARCHAR" property="status"/>
  9. </resultMap>
  10. <!-- 获取督查问题统计信息列表 -->
  11. <select id="getInspectorInfos" resultMap="BaseResultMap">
  12. select ci.id,
  13. ci.context,
  14. (
  15. SELECT
  16. type.typename
  17. FROM
  18. t_s_typegroup AS typeg
  19. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  20. WHERE
  21. typeg.typegroupcode = 'superivseArea'
  22. AND ci.area = type.typecode
  23. ) AS region,
  24. (
  25. SELECT
  26. type.typename
  27. FROM
  28. t_s_typegroup AS typeg
  29. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  30. WHERE
  31. typeg.typegroupcode = 'superivseStatus'
  32. AND ci.status = type.typecode
  33. ) AS state from t_b_schedule_superivse ci
  34. where TO_DAYS(ci.create_date) = TO_DAYS(NOW())
  35. <if test="scheduleType != null and scheduleType != '' ">
  36. and ci.type = #{scheduleType}
  37. </if>
  38. </select>
  39. <!-- 督查4.5 -->
  40. <select id="getCleInfos" resultType="com.daju.mix.dto.CleanInsDTO">
  41. select id, code serial, context inspectContent, type category, status state
  42. from t_b_schedule_superivse
  43. where TO_DAYS(create_date) = TO_DAYS(NOW())
  44. and type = '1'
  45. </select>
  46. <!--获取近5日预警统计信息-->
  47. <select id="getLast5daysWarningsOld" resultType="java.util.Map">
  48. SELECT
  49. (
  50. SELECT
  51. type.typename
  52. FROM
  53. t_s_typegroup AS typeg
  54. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  55. WHERE
  56. typeg.typegroupcode = 'assignmentStyle'
  57. AND a.schedule_type = type.typecode
  58. ) AS transportType,
  59. count(1) / (
  60. SELECT
  61. count(1)
  62. FROM
  63. t_b_alarm AS b
  64. <where>
  65. datediff(NOW(), b.alarm_time) <![CDATA[<]]> 5
  66. <if test="scheduleType != null and scheduleType != '' ">
  67. AND b.schedule_assignment_style = #{scheduleType}
  68. </if>
  69. </where>
  70. ) AS warningsRate
  71. FROM
  72. t_b_alarm AS a
  73. <where>
  74. datediff(NOW(), a.alarm_time) <![CDATA[<]]> 5
  75. <if test="scheduleType != null and scheduleType != '' ">
  76. AND a.schedule_assignment_style = #{scheduleType}
  77. </if>
  78. </where>
  79. GROUP BY
  80. a.schedule_type
  81. </select>
  82. <select id="getLast5daysWarnings" resultType="java.util.Map">
  83. select tst.typename alertType, ifnull(count(c.alertType), 0) num from
  84. (SELECT a.id,
  85. (
  86. SELECT type.typename
  87. FROM t_s_typegroup AS typeg
  88. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  89. WHERE typeg.typegroupcode = 'alarmFrom'
  90. AND a.alarm_from = type.typecode
  91. ) AS alertType,
  92. a.context AS alertContent,
  93. (
  94. SELECT u.realname
  95. FROM t_s_base_user AS u
  96. WHERE u.id = a.alarm_recevier
  97. ) AS leader,
  98. a.alarm_time AS alertTime
  99. FROM
  100. t_b_alarm AS a
  101. WHERE a.alarm_time &lt;= date_format(NOW(), '%Y-%m-%d')
  102. AND a.alarm_time &gt;= date_format(
  103. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  104. '%Y-%m-%d'
  105. )) c
  106. RIGHT JOIN (select typecode, typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b62e8670023') tst
  107. ON tst.typename = c.alertType
  108. where
  109. 1 = 1
  110. <if test="id != null and id != ''">
  111. and tst.typecode = #{id}
  112. </if>
  113. group by tst.typename
  114. </select>
  115. <select id="getLast5daysWarningsC" resultType="java.util.Map">
  116. select tst.typename alertType, ifnull(count(c.alertType), 0) num from
  117. (SELECT a.id,
  118. (
  119. SELECT type.typename
  120. FROM t_s_typegroup AS typeg
  121. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  122. WHERE typeg.typegroupcode = 'alarmFrom'
  123. AND a.alarm_from = type.typecode
  124. ) AS alertType,
  125. a.context AS alertContent,
  126. (
  127. SELECT u.realname
  128. FROM t_s_base_user AS u
  129. WHERE u.id = a.alarm_recevier
  130. ) AS leader,
  131. a.alarm_time AS alertTime
  132. FROM
  133. t_b_alarm AS a
  134. WHERE a.alarm_time &lt;= date_format(NOW(), '%Y-%m-%d')
  135. AND a.alarm_time &gt;= date_format(
  136. DATE_ADD(NOW(), INTERVAL - 5 DAY),
  137. '%Y-%m-%d'
  138. )) c
  139. RIGHT JOIN (select typecode, typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b62e8670023') tst
  140. ON tst.typename = c.alertType
  141. where
  142. 1 = 1
  143. <if test="id != null and id != ''">
  144. and tst.typecode = #{id}
  145. </if>
  146. group by tst.typename
  147. </select>
  148. <!--获取近5日预警按元素类型统计信息-->
  149. <select id="getLast5daysWarningsByElementType" resultType="java.util.Map">
  150. SELECT
  151. DATE_FORMAT(
  152. last5Day.alarmDay,
  153. '%c.%e'
  154. ) AS alarmDay,
  155. (
  156. SELECT
  157. count(1)
  158. FROM
  159. t_b_alarm AS alarm
  160. WHERE
  161. EXISTS (
  162. SELECT
  163. csta.id
  164. FROM
  165. t_b_car_schedule_type AS csta
  166. WHERE
  167. alarm.schedule_assignment_style = csta.business_type
  168. <if test="elementType != null and elementType != '' ">
  169. AND csta.car_type = #{elementType}
  170. </if>
  171. )
  172. <if test="scheduleType != null and scheduleType != '' ">
  173. AND alarm.schedule_assignment_style = #{scheduleType}
  174. </if>
  175. AND DATEDIFF(
  176. alarm.alarm_time,
  177. last5Day.alarmDay
  178. ) = 0
  179. ) alarmCount
  180. FROM
  181. (
  182. SELECT
  183. i,
  184. DATE_FORMAT(
  185. ADDDATE(NOW(), INTERVAL - i DAY),
  186. '%Y-%m-%d'
  187. ) AS alarmDay
  188. FROM
  189. (
  190. SELECT
  191. 0 AS i
  192. UNION
  193. SELECT
  194. 1
  195. UNION
  196. SELECT
  197. 2
  198. UNION
  199. SELECT
  200. 3
  201. UNION
  202. SELECT
  203. 4
  204. ) lastDay
  205. ) last5Day
  206. ORDER BY
  207. last5Day.alarmDay DESC
  208. </select>
  209. <!-- 车辆作业获取实时预警信息-近5日-->
  210. <select id="getRealWarningsByElementType" resultType="com.daju.mix.dto.RealWarningDTO">
  211. SELECT
  212. a.id,
  213. (@i :=@i + 1) AS serial,
  214. a.context AS alertContent,
  215. (
  216. SELECT
  217. u.realname
  218. FROM
  219. t_s_base_user AS u
  220. WHERE
  221. u.id = a.alarm_recevier
  222. ) AS receiver
  223. FROM
  224. (SELECT @i := 0) t,
  225. t_b_car AS car
  226. RIGHT JOIN t_b_alarm AS a ON car.id = a.alarm_car
  227. WHERE
  228. DATEDIFF(NOW(), a.alarm_time) <![CDATA[<]]> 5
  229. <if test="scheduleType != null and scheduleType != '' ">
  230. AND a.schedule_assignment_style = #{scheduleType}
  231. </if>
  232. <if test="alarmFrom != null and alarmFrom != '' ">
  233. AND a.alarm_from = #{alarmFrom}
  234. </if>
  235. <if test="alarmType != null and alarmType != '' ">
  236. AND a.alarm_type = #{alarmType}
  237. </if>
  238. <if test="elementType != null and elementType != '' ">
  239. AND a.alarm_car = #{elementType}
  240. </if>
  241. ORDER BY
  242. a.alarm_time DESC
  243. </select>
  244. <select id="getRealWarningsByElementTypeC" resultType="com.daju.mix.dto.RealWarningCDTO">
  245. SELECT
  246. a.id,
  247. (@i :=@i + 1) AS serial,
  248. a.context AS Content,
  249. (
  250. SELECT
  251. u.realname
  252. FROM
  253. t_s_base_user AS u
  254. WHERE
  255. u.id = a.alarm_recevier
  256. ) AS receiver
  257. FROM
  258. (SELECT @i := 0) t,
  259. t_b_car AS car
  260. LEFT JOIN t_b_alarm AS a ON car.id = a.alarm_car
  261. WHERE
  262. datediff(NOW(), a.alarm_time) <![CDATA[<]]> 5
  263. <if test="id != null and id != '' ">
  264. AND a.alarm_user = #{id} OR a.alarm_car = #{id}
  265. </if>
  266. <if test="elementType != null and elementType = ''">
  267. AND a.alarm_from = #{elementType}
  268. </if>
  269. ORDER BY
  270. a.alarm_time DESC
  271. </select>
  272. <select id="getGWarning" resultType="com.daju.mix.dto.GcbWarningDTO">
  273. SELECT
  274. a.id id,
  275. (
  276. SELECT
  277. u.realname
  278. FROM
  279. t_s_base_user AS u
  280. WHERE
  281. u.id = a.alarm_user
  282. ) alarmUser,
  283. a.context AS alertContent,
  284. (
  285. SELECT
  286. u.realname
  287. FROM
  288. t_s_base_user AS u
  289. WHERE
  290. u.id = a.alarm_recevier
  291. ) AS receiver
  292. FROM
  293. t_b_car AS car
  294. LEFT JOIN t_b_alarm AS a ON car.id = a.alarm_car
  295. ${ew.customSqlSegment}
  296. </select>
  297. <select id="warningDetailsByCarId" resultType="java.util.Map">
  298. SELECT
  299. a.id,a.context, (
  300. SELECT
  301. u.realname
  302. FROM
  303. t_s_base_user AS u
  304. WHERE
  305. a.alarm_recevier = u.id
  306. ) AS username
  307. FROM
  308. t_b_alarm AS a
  309. <where>
  310. <if test="scheduleType != null and scheduleType != '' ">
  311. AND a.schedule_assignment_style = #{scheduleType}
  312. </if>
  313. <if test="carId != null and carId != '' ">
  314. AND a.alarm_car = #{carId}
  315. </if>
  316. </where>
  317. </select>
  318. <!-- 根据车辆查询今日预警数-->
  319. <select id="todayWarningCount" resultType="int">
  320. SELECT
  321. count(1)
  322. FROM
  323. t_b_alarm AS a
  324. <where>
  325. <if test="scheduleType != null and scheduleType != '' ">
  326. AND a.schedule_assignment_style = #{scheduleType}
  327. </if>
  328. <if test="carId != null and carId != '' ">
  329. AND a.alarm_car = #{carId}
  330. </if>
  331. <if test="archivesCode != null and archivesCode != '' ">
  332. AND a.archives_code = #{archivesCode}
  333. </if>
  334. <if test="alarmFrom != null and alarmFrom != '' ">
  335. AND a.alarm_from = #{alarmFrom}
  336. </if>
  337. <if test="alarmType != null and alarmType != '' ">
  338. AND a.alarm_type = #{alarmType}
  339. </if>
  340. AND DATEDIFF(now(), a.alarm_time) = 0
  341. </where>
  342. </select>
  343. <!-- 获取指定车辆的作业概况信息-->
  344. <select id="workingProfilesByCarId" resultType="java.util.Map">
  345. SELECT
  346. cst.id,
  347. cstd.username,
  348. cstd.user_id,
  349. cst.work_route_name AS workingLine,
  350. (
  351. SELECT
  352. type.typename
  353. FROM
  354. t_s_typegroup AS typeg
  355. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  356. WHERE
  357. typeg.typegroupcode = 'assignmentStyle'
  358. AND cst.type = type.typecode
  359. ) AS workingContent,
  360. (
  361. SELECT
  362. type.typename
  363. FROM
  364. t_s_typegroup AS typeg
  365. LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
  366. WHERE
  367. typeg.typegroupcode = 'workStatus'
  368. AND cst.`work_status` = type.typecode
  369. ) AS workingState
  370. FROM
  371. t_b_car_schedule_task_detail AS cstd
  372. LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = cstd.pid
  373. <where>
  374. <if test="scheduleType != null and scheduleType != '' ">
  375. AND cst.assignment_style = #{scheduleType}
  376. </if>
  377. <if test="carId != null and carId != '' ">
  378. AND cstd.carid = #{carId}
  379. </if>
  380. AND DATEDIFF(now(), concat(cstd.yearmonth , '-' ,cstd.code_day)) = 0
  381. </where>
  382. </select>
  383. <!-- 根据场所类型-查询场所数量-->
  384. <select id="selectPlaceCountByPlaceType" resultType="int">
  385. SELECT COUNT(1)
  386. FROM t_b_archives_place AS p
  387. WHERE p.type = #{placeType}
  388. </select>
  389. <!-- 根据人员职务类型-查询人员数量-->
  390. <select id="selectUserCountByUserDutiesId" resultType="int">
  391. select
  392. COUNT(id)
  393. from t_s_base_user
  394. where id in
  395. (SELECT
  396. userid
  397. FROM
  398. t_bus_user_personnel
  399. WHERE
  400. belong_dutiesid = #{dutiesid});
  401. </select>
  402. <select id="getUserTrend" resultType="java.lang.Integer">
  403. select ifnull(in_num, 0) num
  404. from t_public_toilet_ridership
  405. where TO_DAYS(NOW()) = TO_DAYS(update_time)
  406. and update_time &lt;= #{date}
  407. and in_num != 0
  408. and code = #{id}
  409. order by
  410. update_time desc limit 1
  411. </select>
  412. <select id="getToiletWE" resultType="com.daju.mix.dto.ToiletWEDTO">
  413. SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS date,
  414. (
  415. select ifnull(sum(water_meter), 0) water from t_public_toilet_energy where DATEDIFF(last30Day.tempDay,
  416. count_date) = 0
  417. <if test="code != null and code != ''">
  418. and code = #{code}
  419. </if>
  420. ) AS water,
  421. (
  422. select ifnull(sum(watt_meter), 0) watt from t_public_toilet_energy where DATEDIFF(last30Day.tempDay, count_date)
  423. = 0
  424. <if test="code != null and code != ''">
  425. and code = #{code}
  426. </if>
  427. ) AS watt
  428. FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
  429. FROM (
  430. SELECT @xi := @xi + 1 AS i
  431. FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
  432. (SELECT 1
  433. UNION
  434. SELECT 2
  435. UNION
  436. SELECT 3
  437. UNION
  438. SELECT 4
  439. UNION
  440. SELECT 5
  441. UNION
  442. SELECT 6) xc2,
  443. (SELECT 1
  444. UNION
  445. SELECT 2
  446. UNION
  447. SELECT 3
  448. UNION
  449. SELECT 4
  450. UNION
  451. SELECT 5
  452. UNION
  453. SELECT 6) xc3,
  454. (SELECT @xi := -1) xc0
  455. ) xc
  456. ORDER BY tempDay DESC
  457. LIMIT 5
  458. ) last30Day
  459. ORDER BY last30Day.tempDay ASC LIMIT 5
  460. </select>
  461. <select id="getTNum" resultType="java.lang.Integer">
  462. select in_num num
  463. from t_public_toilet_ridership
  464. where code = #{id}
  465. and in_num is not null
  466. order by update_time desc limit 1
  467. </select>
  468. <!-- 巡回保洁排班信息-电子围栏报警 -->
  469. <select id="getScheduleGps" resultType="com.daju.mix.dto.ElectronicFenceDto">
  470. select tpr.person_id userId,
  471. tpr.longitude_wgs84 longitude,
  472. tpr.latitude_wgs84 latitude,
  473. CONCAT(tcd.yearmonth, '-', tcd.code_day) date, tbt.`start`, CONCAT(tcd.yearmonth,'-',tcd.code_day,' ', tbt.`start`, ':00') beginTime, CONCAT(tcd.yearmonth,'-',tcd.code_day,' ', tbt.`end`, ':00') endTime
  474. from
  475. t_personnel_real_position tpr
  476. left join
  477. t_b_car_schedule_task_detail tcd on tcd.user_id = tpr.person_id
  478. left join
  479. t_b_car_schedule_task tbt on tbt.id = tcd.pid
  480. where
  481. TO_DAYS(NOW()) = TO_DAYS(tpr.gps_time)
  482. and
  483. TO_DAYS(NOW()) = TO_DAYS(CONCAT(tcd.yearmonth
  484. , '-'
  485. , tcd.code_day))
  486. and
  487. tbt.type = 24
  488. </select>
  489. </mapper>