RepairProjectMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.RepairProjectDao">
  4. <insert id="addRepairProjectData" parameterType="RepairProjectDTO" useGeneratedKeys="true" keyProperty="id">
  5. insert into repair_project(sectionId,work_id,com_time,type,`desc`,user_id,create_time)
  6. values (#{sectionId},#{workId},#{comTime},#{type},#{desc},#{userid},#{createTime})
  7. </insert>
  8. <update id="updateRepairProjectData" parameterType="RepairProjectDTO">
  9. update repair_project r
  10. set
  11. r.sectionId = #{sectionId},
  12. r.work_id = #{workId},
  13. r.com_time = #{comTime},
  14. r.type = #{type},
  15. r.`desc` = #{desc}
  16. where r.id = #{id}
  17. </update>
  18. <select id="getRepairProjectList" resultType="RepairProjectDTO">
  19. select r.id,r.number,r.type,r.com_time comTime,r.work_name workName,r.`desc`,r.status
  20. from repair_project r
  21. left join section s on r.sectionId = s.id
  22. left join global_location gl on s.pid = gl.id
  23. left join global_location gl1 on gl.pid = gl1.id
  24. left join global_location gl2 on gl1.pid = gl2.id
  25. where 1=1
  26. <if test="sectionList != null and !sectionList.isEmpty()">
  27. and r.sectionId in
  28. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  29. #{item}
  30. </foreach>
  31. </if>
  32. <choose>
  33. <when test="type == 0">
  34. and r.type = 0
  35. </when>
  36. <when test="type == 1">
  37. and r.type = 1
  38. </when>
  39. <when test="type == 2">
  40. and r.type = 2
  41. </when>
  42. </choose>
  43. <if test="keyword != null and keyword != ''">
  44. and r.number like '%${keyword}%'
  45. </if>
  46. <if test="areaId != null and areaId != 0">
  47. and gl.id = #{areaId}
  48. </if>
  49. <if test="sectionId != null and sectionId != 0">
  50. and r.sectionId = #{sectionId}
  51. </if>
  52. <if test="cityId != null and cityId != 0">
  53. and gl1.id = #{cityId}
  54. </if>
  55. <if test="provinceId != null and provinceId != 0">
  56. and gl2.id = #{provinceId}
  57. </if>
  58. <if test="page >= 0 and count > 0">
  59. limit #{page},#{count}
  60. </if>
  61. </select>
  62. <select id="getRepairProjectTotal" resultType="Integer">
  63. select count(r.id)
  64. from repair_project r
  65. <if test="sectionList != null and !sectionList.isEmpty()">
  66. where r.sectionId in
  67. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  68. #{item}
  69. </foreach>
  70. </if>
  71. </select>
  72. <select id="getRepairProjectTotal2" resultType="Integer">
  73. select count(r.id)
  74. from repair_project r
  75. where r.type = 0
  76. <if test="sectionList != null and !sectionList.isEmpty()">
  77. and r.sectionId in
  78. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  79. #{item}
  80. </foreach>
  81. </if>
  82. </select>
  83. <select id="getRepairProjectTotal3" resultType="Integer">
  84. select count(r.id)
  85. from repair_project r
  86. where r.type = 1
  87. <if test="sectionList != null and !sectionList.isEmpty()">
  88. and r.sectionId in
  89. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  90. #{item}
  91. </foreach>
  92. </if>
  93. </select>
  94. <select id="getRepairProjectTotal4" resultType="Integer">
  95. select count(r.id)
  96. from repair_project r
  97. where r.type = 2
  98. <if test="sectionList != null and !sectionList.isEmpty()">
  99. and r.sectionId in
  100. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  101. #{item}
  102. </foreach>
  103. </if>
  104. </select>
  105. <update id="updateRepairProjectStatus" parameterType="RepairProjectDTO">
  106. update repair_project r
  107. set
  108. r.status = #{status}
  109. where r.id = #{id}
  110. </update>
  111. <!-- 运维概览项目维修数 -->
  112. <select id="getRepairProjectCount" resultType="Integer">
  113. select count(r.id)
  114. from repair_project r
  115. where date(r.create_time) <![CDATA[ <= ]]> #{endDate}
  116. <if test="startDate != null and startDate != ''">
  117. and date(r.create_time) <![CDATA[ >= ]]> #{startDate}
  118. </if>
  119. <if test="sectionList != null and !sectionList.isEmpty()">
  120. and r.sectionId in
  121. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  122. #{item}
  123. </foreach>
  124. </if>
  125. </select>
  126. <!-- 运维概览维修项目数,前30天内的数据数量 -->
  127. <select id="getRepairProjectCountOnMonth" resultType="RepairProjectDTO">
  128. select count(*) as dayCount,date(r.create_time) as createTime
  129. from repair_project r
  130. where r.create_time <![CDATA[ >= ]]> curdate() - interval 30 day
  131. and r.create_time <![CDATA[ <= ]]> now()
  132. <if test="sectionList != null and !sectionList.isEmpty()">
  133. and r.sectionId in
  134. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  135. #{item}
  136. </foreach>
  137. </if>
  138. group by date(r.create_time)
  139. order by date(r.create_time) desc
  140. </select>
  141. </mapper>