TBCarAlarmMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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.TBCarAlarmMapper">
  4. <resultMap id="AlarmCountDtoMap" type="com.daju.mix.dto.AlarmCountDto"/>
  5. <resultMap id="IndexWarningsDtoMap" type="com.daju.mix.dto.IndexWarningsDto"/>
  6. <resultMap id="DaysCountDtoMap" type="com.daju.mix.dto.DaysCountDto"/>
  7. <!-- 查询所有预警及 预警是否处理-->
  8. <select id="selectAll" resultMap="IndexWarningsDtoMap">
  9. select id, description content, create_date time, status, create_date
  10. from t_b_car_alarm a
  11. </select>
  12. <select id="selectAlarmByCarId" resultMap="IndexWarningsDtoMap">
  13. select id, create_date time, description content, status state
  14. from t_b_car_alarm
  15. where carid = #{carId};
  16. </select>
  17. <!-- 车辆总预警次数 及 当日预警次数-->
  18. <select id="selectAlarmCountByCarId" resultMap="AlarmCountDtoMap">
  19. select count(id) totalViolationCount,
  20. (select count(id)
  21. from t_b_car_alarm
  22. where date_format(create_date, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
  23. and carid = #{carId}) violationCount
  24. from t_b_car_alarm
  25. where carid = #{carid};
  26. </select>
  27. <!-- 车辆总预警次数 及 当日预警次数-->
  28. <select id="selectAlarmCountByArchiveType" resultMap="AlarmCountDtoMap">
  29. select count(id) totalViolationCount,
  30. (select count(id)
  31. from t_b_car_alarm
  32. where date_format(create_date, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
  33. and archive_type = #{type}) violationCount
  34. from t_b_car_alarm
  35. where archive_type = #{type};
  36. </select>
  37. <!-- 1道班房,2垃圾清运点,3垃圾箱,4清扫点,5干垃圾清运车,6湿垃圾清运车,7洒水车,8道路,9公厕,10治安巡逻车,11保安,12保安打卡点-->
  38. <!-- 秩序维护(已派)工单数量-->
  39. <select id="securityWorkOrderCount" resultType="int">
  40. select count(p.id)
  41. from p_projecttask p
  42. left join t_b_car_alarm t on p.sourceid = t.id
  43. where executer is not null
  44. and archive_type = 10
  45. or archive_type = 11
  46. or archive_type = 12
  47. </select>
  48. <!-- 秩序维护(逾期)工单数量-->
  49. <select id="securityWorkOrderCountOverdue" resultType="int">
  50. select count(p.id)
  51. from p_projecttask p
  52. left join t_b_car_alarm t on p.sourceid = t.id
  53. where executer is not null
  54. and planendtime <![CDATA[ < ]]> now()
  55. and archive_type = 10
  56. or archive_type = 11
  57. or archive_type = 12
  58. </select>
  59. <!-- 秩序维护近七日(已派/ 逾期 / 催办)工单数量列表-->
  60. <!-- status 1:已派 2:逾期 3:催办 -->
  61. <select id="securityWorkOrderSevenCount" resultMap="DaysCountDtoMap">
  62. select DATE_FORMAT(a.timeDay, '%Y-%m-%d') as days, ifnull(b.count, 0) as count
  63. from (
  64. SELECT curdate() as timeDay
  65. union all
  66. SELECT date_sub(curdate(), interval 1 day) as timeDay
  67. union all
  68. SELECT date_sub(curdate(), interval 2 day) as timeDay
  69. union all
  70. SELECT date_sub(curdate(), interval 3 day) as timeDay
  71. union all
  72. SELECT date_sub(curdate(), interval 4 day) as timeDay
  73. union all
  74. SELECT date_sub(curdate(), interval 5 day) as timeDay
  75. union all
  76. SELECT date_sub(curdate(), interval 6 day) as timeDayA
  77. ) a
  78. left join (
  79. select date(planendtime) as time, count(*) count
  80. from p_projecttask p
  81. left join t_b_car_alarm t on p.sourceid = t.id
  82. <where>
  83. <if test="status == 1">
  84. executer is not null
  85. and archive_type = 10
  86. or archive_type = 11
  87. or archive_type = 12
  88. </if>
  89. <if test="status == 2">
  90. executer is not null
  91. and planendtime <![CDATA[ < ]]> now()
  92. and archive_type = 10
  93. or archive_type = 11
  94. or archive_type = 12
  95. </if>
  96. </where>
  97. group by date(p.planendtime)
  98. ) b on a.timeDay = b.time
  99. order by days;
  100. </select>
  101. <!-- 1道班房,2垃圾清运点,3垃圾箱,4清扫点,5干垃圾清运车,6湿垃圾清运车,7洒水车,8道路,9公厕,10治安巡逻车,11保安,12保安打卡点-->
  102. <!-- 环境保洁(已派)工单数量-->
  103. <select id="environmentWorkOrderCount" resultType="int">
  104. select count(p.id)
  105. from p_projecttask p
  106. left join t_b_car_alarm t on p.sourceid = t.id
  107. where executer is not null
  108. and archive_type = 1
  109. or archive_type = 2
  110. or archive_type = 3
  111. or archive_type = 4
  112. or archive_type = 5
  113. or archive_type = 6
  114. or archive_type = 7
  115. or archive_type = 8
  116. or archive_type = 9
  117. </select>
  118. <!-- 环境保洁(逾期)工单数量-->
  119. <select id="environmentWorkOrderCountOverdue" resultType="int">
  120. select count(p.id)
  121. from p_projecttask p
  122. left join t_b_car_alarm t on p.sourceid = t.id
  123. where executer is not null
  124. and planendtime <![CDATA[ < ]]> now()
  125. and archive_type = 1
  126. or archive_type = 2
  127. or archive_type = 3
  128. or archive_type = 4
  129. or archive_type = 5
  130. or archive_type = 6
  131. or archive_type = 7
  132. or archive_type = 8
  133. or archive_type = 9
  134. </select>
  135. <!-- 秩序维护近七日(已派/ 逾期 / 催办)工单数量列表-->
  136. <!-- status 1:已派 2:逾期 3:催办 -->
  137. <select id="environmentWorkOrderSevenCount" resultMap="DaysCountDtoMap">
  138. select DATE_FORMAT(a.timeDay, '%Y-%m-%d') as days, ifnull(b.count, 0) as count
  139. from (
  140. SELECT curdate() as timeDay
  141. union all
  142. SELECT date_sub(curdate(), interval 1 day) as timeDay
  143. union all
  144. SELECT date_sub(curdate(), interval 2 day) as timeDay
  145. union all
  146. SELECT date_sub(curdate(), interval 3 day) as timeDay
  147. union all
  148. SELECT date_sub(curdate(), interval 4 day) as timeDay
  149. union all
  150. SELECT date_sub(curdate(), interval 5 day) as timeDay
  151. union all
  152. SELECT date_sub(curdate(), interval 6 day) as timeDayA
  153. ) a
  154. left join (
  155. select date(planendtime) as time, count(*) count
  156. from p_projecttask p
  157. left join t_b_car_alarm t on p.sourceid = t.id
  158. <where>
  159. <if test="status == 1">
  160. executer is not null
  161. and archive_type = 1
  162. or archive_type = 2
  163. or archive_type = 3
  164. or archive_type = 4
  165. or archive_type = 5
  166. or archive_type = 6
  167. or archive_type = 7
  168. or archive_type = 8
  169. or archive_type = 9
  170. </if>
  171. <if test="status == 2">
  172. executer is not null
  173. and planendtime <![CDATA[ < ]]> now()
  174. and archive_type = 1
  175. or archive_type = 2
  176. or archive_type = 3
  177. or archive_type = 4
  178. or archive_type = 5
  179. or archive_type = 6
  180. or archive_type = 7
  181. or archive_type = 8
  182. or archive_type = 9
  183. </if>
  184. </where>
  185. group by date(p.planendtime)
  186. ) b on a.timeDay = b.time
  187. order by days;
  188. </select>
  189. <!-- 1道班房,2垃圾清运点,3垃圾箱,4清扫点,5干垃圾清运车,6湿垃圾清运车,7洒水车,8道路,9公厕,10治安巡逻车,11保安,12保安打卡点-->
  190. <!-- 清扫点(已派)工单数量-->
  191. <select id="sweepPointWorkOrderCount" resultType="int">
  192. select count(p.id)
  193. from p_projecttask p
  194. left join t_b_car_alarm t on p.sourceid = t.id
  195. where executer is not null
  196. and archive_id = #{id}
  197. and archive_type = 4
  198. </select>
  199. <!-- 清扫点(逾期)工单数量-->
  200. <select id="sweepPointWorkOrderCountOverdue" resultType="int">
  201. select count(p.id)
  202. from p_projecttask p
  203. left join t_b_car_alarm t on p.sourceid = t.id
  204. where executer is not null
  205. and archive_id = #{id}
  206. and planendtime <![CDATA[ < ]]> now()
  207. and archive_type = 4
  208. </select>
  209. <!-- 清扫点近七日(已派)工单数量列表-->
  210. <select id="sweepPointWorkOrderSevenCount" resultMap="DaysCountDtoMap">
  211. select DATE_FORMAT(a.timeDay, '%Y-%m-%d') as days, ifnull(b.count, 0) as count
  212. from (
  213. SELECT curdate() as timeDay
  214. union all
  215. SELECT date_sub(curdate(), interval 1 day) as timeDay
  216. union all
  217. SELECT date_sub(curdate(), interval 2 day) as timeDay
  218. union all
  219. SELECT date_sub(curdate(), interval 3 day) as timeDay
  220. union all
  221. SELECT date_sub(curdate(), interval 4 day) as timeDay
  222. union all
  223. SELECT date_sub(curdate(), interval 5 day) as timeDay
  224. union all
  225. SELECT date_sub(curdate(), interval 6 day) as timeDayA
  226. ) a
  227. left join (
  228. select date(planendtime) as time, count(*) count
  229. from p_projecttask p
  230. left join t_b_car_alarm t on p.sourceid = t.id
  231. where archive_id = #{archiveId}
  232. and executer is not null
  233. and archive_type = 4
  234. group by date(p.planendtime)
  235. ) b on a.timeDay = b.time
  236. order by days;
  237. </select>
  238. <!-- 清扫点近七日(逾期)工单数量列表-->
  239. <select id="sweepPointWorkOrderSevenCount1" resultMap="DaysCountDtoMap">
  240. select DATE_FORMAT(a.timeDay, '%Y-%m-%d') as days, ifnull(b.count, 0) as count
  241. from (
  242. SELECT curdate() as timeDay
  243. union all
  244. SELECT date_sub(curdate(), interval 1 day) as timeDay
  245. union all
  246. SELECT date_sub(curdate(), interval 2 day) as timeDay
  247. union all
  248. SELECT date_sub(curdate(), interval 3 day) as timeDay
  249. union all
  250. SELECT date_sub(curdate(), interval 4 day) as timeDay
  251. union all
  252. SELECT date_sub(curdate(), interval 5 day) as timeDay
  253. union all
  254. SELECT date_sub(curdate(), interval 6 day) as timeDayA
  255. ) a
  256. left join (
  257. select date(planendtime) as time, count(*) count
  258. from p_projecttask p
  259. left join t_b_car_alarm t on p.sourceid = t.id
  260. where archive_id = #{archiveId}
  261. and executer is not null
  262. and planendtime <![CDATA[ < ]]> now()
  263. and archive_type = 4
  264. group by date(p.planendtime)
  265. ) b on a.timeDay = b.time
  266. order by days;
  267. </select>
  268. <!--指定清扫点当日预警信息-->
  269. <select id="sweepPointWarningsDays" resultMap="IndexWarningsDtoMap">
  270. select archive_id id, create_date time, content, a.status state
  271. from t_b_car_alarm a
  272. left join t_b_archives_sweep_point b on a.archive_id = b.id
  273. where TO_DAYS(a.alarm_date) = TO_DAYS(NOW())
  274. and archive_id = #{archivesId};
  275. </select>
  276. <!-- 指定公厕预警信息-->
  277. <select id="toiletsWarningsById" resultMap="IndexWarningsDtoMap">
  278. select a.id, a.create_date time, a.content, a.status state
  279. from t_b_car_alarm a
  280. left join t_b_archives_toilets b on archive_id = b.id
  281. where b.id = #{toiletsId}
  282. </select>
  283. <!-- 指定道班房预警信息-->
  284. <select id="DBFWarningsById" resultMap="IndexWarningsDtoMap">
  285. select id, create_date time, content, status
  286. from t_b_car_alarm
  287. where archive_type = 1
  288. and archive_id = #{id}
  289. </select>
  290. </mapper>