PatrolManageMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.PatrolManageDao">
  4. <select id="getPatrolManageList" resultType="PatrolManageDTO">
  5. select p.number,p.count,p.id
  6. from patrol_manage p
  7. left join section s on p.sectionId = s.id
  8. left join global_location gl on s.pid = gl.id
  9. left join global_location gl1 on gl.pid = gl1.id
  10. left join global_location gl2 on gl1.pid = gl2.id
  11. where 1=1
  12. <if test="sectionList != null and !sectionList.isEmpty()">
  13. and p.sectionId in
  14. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  15. #{item}
  16. </foreach>
  17. </if>
  18. <if test="sectionId != null and sectionId != 0">
  19. and p.id = #{sectionId}
  20. </if>
  21. <if test="areaId != null and areaId != 0">
  22. and gl.id = #{areaId}
  23. </if>
  24. <if test="cityId != null and cityId != 0">
  25. and gl1.id = #{cityId}
  26. </if>
  27. <if test="provinceId != null and provinceId != 0">
  28. and gl2.id = #{provinceId}
  29. </if>
  30. <if test="keyword != null and keyword != ''">
  31. and p.number like '%${keyword}%'
  32. </if>
  33. <if test="page >= 0 and count > 0">
  34. limit #{page},#{count}
  35. </if>
  36. </select>
  37. <select id="getPatrolManageCount" resultType="Integer">
  38. select count(p.id) as total
  39. from patrol_manage p
  40. <if test="sectionList != null and !sectionList.isEmpty()">
  41. where p.sectionId in
  42. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  43. #{item}
  44. </foreach>
  45. </if>
  46. </select>
  47. <select id="getPatrolDownList" resultType="PatrolManageDTO">
  48. select p.id,p.number
  49. from patrol_manage p
  50. where p.user_id = #{userid}
  51. </select>
  52. <insert id="addPatrolManageData" parameterType="PatrolManageDTO" useGeneratedKeys="true" keyProperty="id">
  53. insert into patrol_manage(sectionId,`count`,plan_start_time,plan_end_time,user_id,create_time)
  54. values (#{sectionId},#{count},#{planStartTime},#{planEndTime},#{userid},#{createTime})
  55. </insert>
  56. <update id="updatePatrolManageData" parameterType="PatrolManageDTO">
  57. update patrol_manage p
  58. set p.sectionId = #{sectionId},
  59. p.`count` = #{count},
  60. p.plan_start_time = #{planStartTime},
  61. p.plan_end_time = #{planEndTime}
  62. where p.id = #{id}
  63. </update>
  64. <!-- 运维概览巡视数 -->
  65. <select id="getPatrolManageCount1" resultType="Integer">
  66. select count(p.id)
  67. from patrol_manage p
  68. where date(p.create_time) <![CDATA[ <= ]]> #{endDate}
  69. <if test="startDate != null and startDate != ''">
  70. and date(p.create_time) <![CDATA[ >= ]]> #{startDate}
  71. </if>
  72. <if test="sectionList != null and !sectionList.isEmpty()">
  73. and p.sectionId in
  74. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  75. #{item}
  76. </foreach>
  77. </if>
  78. </select>
  79. <!-- 运维概览巡视数,前30天内的数据数量 -->
  80. <select id="getPatrolManageCountOnMonth" resultType="PatrolManageDTO">
  81. select count(*) as dayCount,date(p.create_time) as createTime
  82. from patrol_manage p
  83. where p.create_time <![CDATA[ >= ]]> curdate() - interval 30 day
  84. and p.create_time <![CDATA[ <= ]]> now()
  85. <if test="sectionList != null and !sectionList.isEmpty()">
  86. and p.sectionId in
  87. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  88. #{item}
  89. </foreach>
  90. </if>
  91. group by date(p.create_time)
  92. order by date(p.create_time) desc
  93. </select>
  94. </mapper>