WaterPipeInfoMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.zksy.WaterSupply.WaterPipeInfo.mapper.WaterPipeInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.zksy.WaterSupply.WaterPipeInfo.domain.WaterPipeInfo">
  5. <id column="id" property="id"/>
  6. <result column="pipe_code" property="pipeCode"/>
  7. <result column="pipe_name" property="pipeName"/>
  8. <result column="pipe_material" property="pipeMaterial"/>
  9. <result column="pipe_diameter" property="pipeDiameter"/>
  10. <result column="pipe_length" property="pipeLength"/>
  11. <result column="start_point" property="startPoint"/>
  12. <result column="end_point" property="endPoint"/>
  13. <result column="start_longitude" property="startLongitude"/>
  14. <result column="start_latitude" property="startLatitude"/>
  15. <result column="end_longitude" property="endLongitude"/>
  16. <result column="end_latitude" property="endLatitude"/>
  17. <result column="laying_year" property="layingYear"/>
  18. <result column="pressure_rating" property="pressureRating"/>
  19. <result column="status" property="status"/>
  20. <result column="remark" property="remark"/>
  21. <result column="del_flag" property="delFlag"/>
  22. <result column="create_by" property="createBy"/>
  23. <result column="create_time" property="createTime"/>
  24. <result column="update_by" property="updateBy"/>
  25. <result column="update_time" property="updateTime"/>
  26. </resultMap>
  27. <sql id="Base_Column_List">
  28. id, pipe_code, pipe_name, pipe_material, pipe_diameter, pipe_length,
  29. start_point, end_point, start_longitude, start_latitude, end_longitude, end_latitude,
  30. laying_year, pressure_rating, status, remark,
  31. del_flag, create_by, create_time, update_by, update_time
  32. </sql>
  33. <select id="selectPipeList" resultMap="BaseResultMap">
  34. SELECT <include refid="Base_Column_List"/>
  35. FROM app_user.water_pipe_info
  36. WHERE del_flag = '0'
  37. <if test="pipeCode != null and pipeCode != ''">
  38. AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
  39. </if>
  40. <if test="pipeName != null and pipeName != ''">
  41. AND pipe_name LIKE CONCAT('%', #{pipeName}, '%')
  42. </if>
  43. <if test="pipeMaterial != null and pipeMaterial != ''">
  44. AND pipe_material = #{pipeMaterial}
  45. </if>
  46. <if test="status != null and status != ''">
  47. AND status = #{status}
  48. </if>
  49. <if test="startTime != null">
  50. AND create_time &gt;= #{startTime}
  51. </if>
  52. <if test="endTime != null">
  53. AND create_time &lt;= #{endTime}
  54. </if>
  55. ORDER BY create_time DESC
  56. </select>
  57. <select id="statPipeByStatus" resultType="java.util.Map">
  58. SELECT
  59. status,
  60. COUNT(*) AS pipeCount
  61. FROM app_user.water_pipe_info
  62. WHERE del_flag = '0'
  63. GROUP BY status
  64. </select>
  65. <select id="statPipeByMaterial" resultType="java.util.Map">
  66. SELECT
  67. pipe_material AS pipeMaterial,
  68. COUNT(*) AS pipeCount,
  69. SUM(pipe_length) AS totalLength
  70. FROM app_user.water_pipe_info
  71. WHERE del_flag = '0'
  72. GROUP BY pipe_material
  73. </select>
  74. <select id="getLatestPipe" resultMap="BaseResultMap">
  75. SELECT <include refid="Base_Column_List"/>
  76. FROM app_user.water_pipe_info
  77. WHERE del_flag = '0'
  78. ORDER BY create_time DESC
  79. LIMIT 1
  80. </select>
  81. <select id="getPipeOverallStatistics" resultType="java.util.Map">
  82. SELECT
  83. COUNT(*) AS totalPipeCount,
  84. SUM(pipe_length) AS totalLength,
  85. SUM(CASE WHEN status = '0' THEN 1 ELSE 0 END) AS runningCount,
  86. SUM(CASE WHEN status = '1' THEN 1 ELSE 0 END) AS stopCount
  87. FROM app_user.water_pipe_info
  88. WHERE del_flag = '0'
  89. </select>
  90. <select id="selectDeletedList" resultMap="BaseResultMap">
  91. SELECT <include refid="Base_Column_List"/>
  92. FROM app_user.water_pipe_info
  93. WHERE del_flag = '2'
  94. <if test="pipeCode != null and pipeCode != ''">
  95. AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
  96. </if>
  97. <if test="pipeName != null and pipeName != ''">
  98. AND pipe_name LIKE CONCAT('%', #{pipeName}, '%')
  99. </if>
  100. <if test="pipeMaterial != null and pipeMaterial != ''">
  101. AND pipe_material = #{pipeMaterial}
  102. </if>
  103. <if test="startTime != null">
  104. AND update_time &gt;= #{startTime}
  105. </if>
  106. <if test="endTime != null">
  107. AND update_time &lt;= #{endTime}
  108. </if>
  109. ORDER BY update_time DESC
  110. </select>
  111. <delete id="deleteByIdsPhysically">
  112. DELETE FROM app_user.water_pipe_info WHERE id IN
  113. <foreach collection="ids" item="id" open="(" separator="," close=")">
  114. #{id}
  115. </foreach>
  116. </delete>
  117. <update id="restoreByIds">
  118. UPDATE app_user.water_pipe_info
  119. SET del_flag = '0',
  120. update_by = #{updateBy},
  121. update_time = CURRENT_TIMESTAMP
  122. WHERE id IN
  123. <foreach collection="ids" item="id" open="(" separator="," close=")">
  124. #{id}
  125. </foreach>
  126. </update>
  127. </mapper>