| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zksy.WaterSupply.WaterPipeInfo.mapper.WaterPipeInfoMapper">
- <resultMap id="BaseResultMap" type="com.zksy.WaterSupply.WaterPipeInfo.domain.WaterPipeInfo">
- <id column="id" property="id"/>
- <result column="pipe_code" property="pipeCode"/>
- <result column="pipe_name" property="pipeName"/>
- <result column="pipe_material" property="pipeMaterial"/>
- <result column="pipe_diameter" property="pipeDiameter"/>
- <result column="pipe_length" property="pipeLength"/>
- <result column="start_point" property="startPoint"/>
- <result column="end_point" property="endPoint"/>
- <result column="start_longitude" property="startLongitude"/>
- <result column="start_latitude" property="startLatitude"/>
- <result column="end_longitude" property="endLongitude"/>
- <result column="end_latitude" property="endLatitude"/>
- <result column="laying_year" property="layingYear"/>
- <result column="pressure_rating" property="pressureRating"/>
- <result column="status" property="status"/>
- <result column="remark" property="remark"/>
- <result column="del_flag" property="delFlag"/>
- <result column="create_by" property="createBy"/>
- <result column="create_time" property="createTime"/>
- <result column="update_by" property="updateBy"/>
- <result column="update_time" property="updateTime"/>
- </resultMap>
- <sql id="Base_Column_List">
- id, pipe_code, pipe_name, pipe_material, pipe_diameter, pipe_length,
- start_point, end_point, start_longitude, start_latitude, end_longitude, end_latitude,
- laying_year, pressure_rating, status, remark,
- del_flag, create_by, create_time, update_by, update_time
- </sql>
- <select id="selectPipeList" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM app_user.water_pipe_info
- WHERE del_flag = '0'
- <if test="pipeCode != null and pipeCode != ''">
- AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
- </if>
- <if test="pipeName != null and pipeName != ''">
- AND pipe_name LIKE CONCAT('%', #{pipeName}, '%')
- </if>
- <if test="pipeMaterial != null and pipeMaterial != ''">
- AND pipe_material = #{pipeMaterial}
- </if>
- <if test="status != null and status != ''">
- AND status = #{status}
- </if>
- <if test="startTime != null">
- AND create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND create_time <= #{endTime}
- </if>
- ORDER BY create_time DESC
- </select>
- <select id="statPipeByStatus" resultType="java.util.Map">
- SELECT
- status,
- COUNT(*) AS pipeCount
- FROM app_user.water_pipe_info
- WHERE del_flag = '0'
- GROUP BY status
- </select>
- <select id="statPipeByMaterial" resultType="java.util.Map">
- SELECT
- pipe_material AS pipeMaterial,
- COUNT(*) AS pipeCount,
- SUM(pipe_length) AS totalLength
- FROM app_user.water_pipe_info
- WHERE del_flag = '0'
- GROUP BY pipe_material
- </select>
- <select id="getLatestPipe" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM app_user.water_pipe_info
- WHERE del_flag = '0'
- ORDER BY create_time DESC
- LIMIT 1
- </select>
- <select id="getPipeOverallStatistics" resultType="java.util.Map">
- SELECT
- COUNT(*) AS totalPipeCount,
- SUM(pipe_length) AS totalLength,
- SUM(CASE WHEN status = '0' THEN 1 ELSE 0 END) AS runningCount,
- SUM(CASE WHEN status = '1' THEN 1 ELSE 0 END) AS stopCount
- FROM app_user.water_pipe_info
- WHERE del_flag = '0'
- </select>
- <select id="selectDeletedList" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM app_user.water_pipe_info
- WHERE del_flag = '2'
- <if test="pipeCode != null and pipeCode != ''">
- AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
- </if>
- <if test="pipeName != null and pipeName != ''">
- AND pipe_name LIKE CONCAT('%', #{pipeName}, '%')
- </if>
- <if test="pipeMaterial != null and pipeMaterial != ''">
- AND pipe_material = #{pipeMaterial}
- </if>
- <if test="startTime != null">
- AND update_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND update_time <= #{endTime}
- </if>
- ORDER BY update_time DESC
- </select>
- <delete id="deleteByIdsPhysically">
- DELETE FROM app_user.water_pipe_info WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <update id="restoreByIds">
- UPDATE app_user.water_pipe_info
- SET del_flag = '0',
- update_by = #{updateBy},
- update_time = CURRENT_TIMESTAMP
- WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- </mapper>
|