WorkManageMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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.welampiot.dao.WorkManageDao">
  4. <select id="getWorkManageListByVO" resultType="WorkManageDTO" parameterType="WorkManageVO">
  5. select w.id,w.number,w.open_time openTime,w.script,w.location,w.status,
  6. w.level,w.work_name as workName
  7. from work_manage w
  8. left join work_manage_file wmf on w.id = wmf.work_manage_id
  9. left join section s on w.sectionId = s.id
  10. left join global_location gl on s.pid = gl.id
  11. left join global_location gl1 on gl.pid = gl1.id
  12. left join global_location gl2 on gl1.pid = gl2.id
  13. where 1=1
  14. <if test="sectionList != null and !sectionList.isEmpty()">
  15. and w.sectionId in
  16. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  17. #{item}
  18. </foreach>
  19. </if>
  20. <if test="sectionId != null and sectionId != 0">
  21. and s.id = #{sectionId}
  22. </if>
  23. <if test="areaId != null and areaId != 0">
  24. and gl.id = #{areaId}
  25. </if>
  26. <if test="cityId != null and cityId != 0">
  27. and gl1.id = #{cityId}
  28. </if>
  29. <if test="provinceId != null and provinceId != 0">
  30. and gl2.id = #{provinceId}
  31. </if>
  32. <if test="keyword != null and keyword != ''">
  33. and w.number like '%${keyword}%'
  34. </if>
  35. <choose>
  36. <when test="status == 4">
  37. and w.status = 4
  38. </when>
  39. <when test="status == 3">
  40. and w.status = 3
  41. </when>
  42. <when test="status == 2">
  43. and w.status = 2
  44. </when>
  45. <when test="status == 1">
  46. and w.status = 1
  47. </when>
  48. <otherwise>
  49. and w.status = 0
  50. </otherwise>
  51. </choose>
  52. <if test="page >= 0 and count > 0">
  53. limit #{page},#{count}
  54. </if>
  55. </select>
  56. <!-- 总数 -->
  57. <select id="getWorkManageTotal" resultType="Integer" parameterType="WorkManageVO">
  58. select count(w.id) as total
  59. from work_manage w
  60. left join section s on w.sectionId = s.id
  61. left join global_location gl on s.pid = gl.id
  62. left join global_location gl1 on gl.pid = gl1.id
  63. left join global_location gl2 on gl1.pid = gl2.id
  64. <if test="sectionList != null and !sectionList.isEmpty()">
  65. where w.sectionId in
  66. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  67. #{item}
  68. </foreach>
  69. </if>
  70. </select>
  71. <!-- 未派发数 -->
  72. <select id="getWorkManageTotal2" resultType="Integer" parameterType="WorkManageVO">
  73. select count(w.id) as total
  74. from work_manage w
  75. left join section s on w.sectionId = s.id
  76. left join global_location gl on s.pid = gl.id
  77. left join global_location gl1 on gl.pid = gl1.id
  78. left join global_location gl2 on gl1.pid = gl2.id
  79. where w.status = 0
  80. <if test="sectionList != null and !sectionList.isEmpty()">
  81. and w.sectionId in
  82. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  83. #{item}
  84. </foreach>
  85. </if>
  86. </select>
  87. <!-- 处理中数 -->
  88. <select id="getWorkManageTotal3" resultType="Integer" parameterType="WorkManageVO">
  89. select count(w.id) as total
  90. from work_manage w
  91. left join section s on w.sectionId = s.id
  92. left join global_location gl on s.pid = gl.id
  93. left join global_location gl1 on gl.pid = gl1.id
  94. left join global_location gl2 on gl1.pid = gl2.id
  95. where w.status = 1
  96. <if test="sectionList != null and !sectionList.isEmpty()">
  97. and w.sectionId in
  98. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  99. #{item}
  100. </foreach>
  101. </if>
  102. </select>
  103. <!-- 复核数 -->
  104. <select id="getWorkManageTotal4" resultType="Integer" parameterType="WorkManageVO">
  105. select count(w.id) as total
  106. from work_manage w
  107. left join section s on w.sectionId = s.id
  108. left join global_location gl on s.pid = gl.id
  109. left join global_location gl1 on gl.pid = gl1.id
  110. left join global_location gl2 on gl1.pid = gl2.id
  111. where w.status = 2
  112. <if test="sectionList != null and !sectionList.isEmpty()">
  113. and w.sectionId in
  114. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  115. #{item}
  116. </foreach>
  117. </if>
  118. </select>
  119. <!-- 结案数 -->
  120. <select id="getWorkManageTotal5" resultType="Integer" parameterType="WorkManageVO">
  121. select count(w.id) as total
  122. from work_manage w
  123. left join section s on w.sectionId = s.id
  124. left join global_location gl on s.pid = gl.id
  125. left join global_location gl1 on gl.pid = gl1.id
  126. left join global_location gl2 on gl1.pid = gl2.id
  127. where w.status = 3
  128. <if test="sectionList != null and !sectionList.isEmpty()">
  129. and w.sectionId in
  130. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  131. #{item}
  132. </foreach>
  133. </if>
  134. </select>
  135. <!-- 归档数 -->
  136. <select id="getWorkManageTotal6" resultType="Integer" parameterType="WorkManageVO">
  137. select count(w.id) as total
  138. from work_manage w
  139. left join section s on w.sectionId = s.id
  140. left join global_location gl on s.pid = gl.id
  141. left join global_location gl1 on gl.pid = gl1.id
  142. left join global_location gl2 on gl1.pid = gl2.id
  143. where w.status = 4
  144. <if test="sectionList != null and !sectionList.isEmpty()">
  145. and w.sectionId in
  146. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  147. #{item}
  148. </foreach>
  149. </if>
  150. </select>
  151. <!-- 工单详情 -->
  152. <select id="getWorkManageInfoById" resultType="WorkManageDTO">
  153. select w.id,w.number,w.open_time openTime,w.script,
  154. w.level,w.location,w.longitude,w.latitude
  155. from work_manage w
  156. where w.id = #{id}
  157. </select>
  158. <insert id="addWorkManageData" parameterType="WorkManageDTO" keyProperty="id" useGeneratedKeys="true">
  159. insert into work_manage(sectionId,open_time,location,dev_type,`level`,
  160. dev_name,script,longitude,latitude,alarm_id,
  161. create_time,user_id)
  162. values
  163. (#{sectionId},#{openTime},#{location},#{devType},#{level},
  164. #{devName},#{script},#{longitude},#{latitude},#{alarmId},
  165. #{createTime},#{userid})
  166. </insert>
  167. <update id="updateWorkManageData" parameterType="WorkManageDTO">
  168. update work_manage w
  169. set
  170. w.sectionId = #{sectionId},
  171. w.open_time = #{openTime},
  172. w.location = #{location},
  173. w.dev_type = #{devType},
  174. w.dev_name = #{devName},
  175. w.script = #{script},
  176. w.longitude = #{longitude},
  177. w.latitude = #{latitude},
  178. w.alarm_id = #{alarmId}
  179. where w.id = #{id}
  180. </update>
  181. <!-- 更新工单状态 -->
  182. <update id="updateWorkStatus" parameterType="WorkManageDTO">
  183. update work_manage w
  184. set
  185. w.status = #{status}
  186. where w.id = #{id}
  187. </update>
  188. <select id="getAlarmIdAndUseridById" resultType="WorkManageDTO">
  189. select w.alarm_id as alarmId,w.user_id as userid
  190. from work_manage w
  191. where w.id = #{id}
  192. </select>
  193. <!-- 运维概览工单数 -->
  194. <select id="getWorkManageCount" resultType="Integer">
  195. select count(w.id)
  196. from work_manage w
  197. where date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  198. <if test="startDate != null and startDate != ''">
  199. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  200. </if>
  201. <if test="sectionList != null and !sectionList.isEmpty()">
  202. and w.sectionId in
  203. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  204. #{item}
  205. </foreach>
  206. </if>
  207. </select>
  208. <!-- 运维概览工单数,前30天内的数据数量 -->
  209. <select id="getWorkManageCountOnMonth" resultType="WorkManageDTO">
  210. select count(*) as dayCount,date(w.create_time) as createTime
  211. from work_manage w
  212. where w.create_time <![CDATA[ >= ]]> curdate() - interval 30 day
  213. and w.create_time <![CDATA[ <= ]]> now()
  214. <if test="sectionList != null and !sectionList.isEmpty()">
  215. and w.sectionId in
  216. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  217. #{item}
  218. </foreach>
  219. </if>
  220. group by date(w.create_time)
  221. order by date(w.create_time) desc
  222. </select>
  223. <!-- 运维概览工单未派发数,当月当年全部具体月份的数据数量 -->
  224. <select id="getWorkManageUndistributedCount" resultType="Integer">
  225. select count(*) as dayCount
  226. from work_manage w
  227. where w.status = 0
  228. and date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  229. <if test="startDate != null and startDate != ''">
  230. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  231. </if>
  232. <if test="sectionList != null and !sectionList.isEmpty()">
  233. and w.sectionId in
  234. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  235. #{item}
  236. </foreach>
  237. </if>
  238. </select>
  239. <!-- 运维概览工单处理中数,当月当年全部具体月份的数据数量 -->
  240. <select id="getWorkManageHandlingCount" resultType="Integer">
  241. select count(*) as dayCount
  242. from work_manage w
  243. where w.status = 1
  244. and date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  245. <if test="startDate != null and startDate != ''">
  246. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  247. </if>
  248. <if test="sectionList != null and !sectionList.isEmpty()">
  249. and w.sectionId in
  250. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  251. #{item}
  252. </foreach>
  253. </if>
  254. </select>
  255. <!-- 运维概览工单复核数,当月当年全部具体月份的数据数量 -->
  256. <select id="getWorkManageRecheckCount" resultType="Integer">
  257. select count(*) as dayCount
  258. from work_manage w
  259. where w.status = 2
  260. and date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  261. <if test="startDate != null and startDate != ''">
  262. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  263. </if>
  264. <if test="sectionList != null and !sectionList.isEmpty()">
  265. and w.sectionId in
  266. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  267. #{item}
  268. </foreach>
  269. </if>
  270. </select>
  271. <!-- 运维概览工单结案数,当月当年全部具体月份的数据数量 -->
  272. <select id="getWorkManageCloseCaseCount" resultType="Integer">
  273. select count(*) as dayCount
  274. from work_manage w
  275. where w.status = 3
  276. and date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  277. <if test="startDate != null and startDate != ''">
  278. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  279. </if>
  280. <if test="sectionList != null and !sectionList.isEmpty()">
  281. and w.sectionId in
  282. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  283. #{item}
  284. </foreach>
  285. </if>
  286. </select>
  287. <!-- 运维概览工单归档数,当月当年全部具体月份的数据数量 -->
  288. <select id="getWorkManageArchiveCount" resultType="Integer">
  289. select count(*) as dayCount
  290. from work_manage w
  291. where w.status = 4
  292. and date(w.create_time) <![CDATA[ <= ]]> #{endDate}
  293. <if test="startDate != null and startDate != ''">
  294. and date(w.create_time) <![CDATA[ >= ]]> #{startDate}
  295. </if>
  296. <if test="sectionList != null and !sectionList.isEmpty()">
  297. and w.sectionId in
  298. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  299. #{item}
  300. </foreach>
  301. </if>
  302. </select>
  303. </mapper>