123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?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.slibra.business.mapper.TCutOffWaterMapper">
-
- <resultMap type="TCutOffWater" id="TCutOffWaterResult">
- <result property="id" column="id" />
- <result property="timeBegin" column="time_begin" />
- <result property="timeEnd" column="time_end" />
- <result property="reason" column="reason" />
- <result property="pumpingStationNeighborhoodBuildingId" column="pumping_station_neighborhood_building_id" />
- <result property="delFlag" column="del_flag" />
- <result property="revision" column="revision" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- </resultMap>
- <sql id="selectTCutOffWaterVo">
- select id, time_begin, time_end, reason, pumping_station_neighborhood_building_id, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_cut_off_water
- </sql>
- <select id="selectTCutOffWaterList" parameterType="TCutOffWater" resultMap="TCutOffWaterResult">
- <include refid="selectTCutOffWaterVo"/>
- <where>
- 1 = 1
- <if test="timeBegin != null "> and time_begin = #{timeBegin}</if>
- <if test="timeEnd != null "> and time_end = #{timeEnd}</if>
- <if test="reason != null and reason != ''"> and reason = #{reason}</if>
- <if test="pumpingStationNeighborhoodBuildingId != null and pumpingStationNeighborhoodBuildingId != ''"> and pumping_station_neighborhood_building_id = #{pumpingStationNeighborhoodBuildingId}</if>
- <if test="revision != null "> and revision = #{revision}</if>
- </where>
- and del_flag = 0 order by id desc
- </select>
-
- <select id="selectTCutOffWaterById" parameterType="Long" resultMap="TCutOffWaterResult">
- <include refid="selectTCutOffWaterVo"/>
- where id = #{id} and del_flag = 0
- </select>
-
- <insert id="insertTCutOffWater" parameterType="TCutOffWater" useGeneratedKeys="true" keyProperty="id">
- insert into t_cut_off_water
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="timeBegin != null">time_begin,</if>
- <if test="timeEnd != null">time_end,</if>
- <if test="reason != null">reason,</if>
- <if test="pumpingStationNeighborhoodBuildingId != null and pumpingStationNeighborhoodBuildingId != ''">pumping_station_neighborhood_building_id,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="revision != null">revision,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="timeBegin != null">#{timeBegin},</if>
- <if test="timeEnd != null">#{timeEnd},</if>
- <if test="reason != null">#{reason},</if>
- <if test="pumpingStationNeighborhoodBuildingId != null and pumpingStationNeighborhoodBuildingId != ''">#{pumpingStationNeighborhoodBuildingId},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="revision != null">#{revision},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- </trim>
- </insert>
- <update id="updateTCutOffWater" parameterType="TCutOffWater">
- update t_cut_off_water
- <trim prefix="SET" suffixOverrides=",">
- <if test="timeBegin != null">time_begin = #{timeBegin},</if>
- <if test="timeEnd != null">time_end = #{timeEnd},</if>
- <if test="reason != null">reason = #{reason},</if>
- <if test="pumpingStationNeighborhoodBuildingId != null and pumpingStationNeighborhoodBuildingId != ''">pumping_station_neighborhood_building_id = #{pumpingStationNeighborhoodBuildingId},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="revision != null">revision = #{revision},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- </trim>
- ,revision = revision + 1
- where id = #{id}
- </update>
-
- <delete id="deleteTCutOffWaterById" parameterType="Long">
- update t_cut_off_water set del_flag = 2,revision = revision + 1 where del_flag = 0 and id = #{id}
- </delete>
- <delete id="deleteTCutOffWaterByIds" parameterType="String">
- update t_cut_off_water set del_flag = 2,revision = revision + 1 where del_flag = 0 and id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!-- 2024年11月06日10:18:29 下面是新增的,不允许覆盖 -->
- <!-- <select id="getCutOffWaterByUserPhone" resultMap="TCutOffWaterResult">-->
- <!-- </select>-->
- <select id="getCutOffWaterByNeighbourhoodName" resultMap="TCutOffWaterResult">
- <!-- SELECT
- *,#{asrText} neighbourhoodName
- FROM
- t_cut_off_water
- WHERE
- pumping_station_neighborhood_building_id IN (
- SELECT
- psnn.id
- FROM
- t_pumping_station_neighbourhood_number psnn
- INNER JOIN t_neighborhood n ON psnn.neighborhood_id = n.id
- AND n.`name` LIKE concat('%', #{asrText}, '%')
- AND psnn.del_flag = 0
- AND n.del_flag = 0
- )
- AND NOW() BETWEEN time_begin
- AND time_end -->
- <!-- 2024年11月15日15:15:56,逻辑调整,查询改成下面 -->
- SELECT DISTINCT
- a.*,
- c.`name` neighbourhoodName
- FROM
- t_cut_off_water a
- INNER JOIN t_cut_off_water_extra b ON a.id = b.cut_off_water_id
- AND a.del_flag = 0
- AND b.del_flag = 0
- INNER JOIN t_neighborhood c ON c.id = b.neighborhood_id
- AND c.del_flag = 0
- WHERE c.`name` LIKE concat('%', #{asrText}, '%')
- AND NOW() >= time_begin AND (time_end is NULL or NOW() < time_end)
- </select>
-
- <select id="selectgetExtraListByPumpingStationId" resultType="com.slibra.business.res.CutOffExtraRes">
- SELECT
- b.id pumpingStationId,
- b.`name` pumpingStationName,
- b.address pumpingStationAddress,
- c.id neighbourhoodId,
- c.`name` neighbourhoodName,
- c.address neighbourhoodAddress,
- d.`name` neighbourhoodNumberNames
- FROM
- ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE pumping_station_id = #{id} AND del_flag = 0 ) a
- INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
- INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
- INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
- </select>
- <select id="selectgetExtraListByNeighbourhoodId" resultType="com.slibra.business.res.CutOffExtraRes">
- SELECT
- b.id pumpingStationId,
- b.`name` pumpingStationName,
- b.address pumpingStationAddress,
- c.id neighbourhoodId,
- c.`name` neighbourhoodName,
- c.address neighbourhoodAddress,
- d.`name` neighbourhoodNumberNames
- FROM
- ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE neighborhood_id = #{id} AND del_flag = 0 ) a
- INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
- INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
- INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
- </select>
- <select id="selectgetExtraListByPumpingStationIdAndNeighbourhoodId" resultType="com.slibra.business.res.CutOffExtraRes">
- SELECT
- b.id pumpingStationId,
- b.`name` pumpingStationName,
- b.address pumpingStationAddress,
- c.id neighbourhoodId,
- c.`name` neighbourhoodName,
- c.address neighbourhoodAddress,
- d.`name` neighbourhoodNumberNames
- FROM
- ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE pumping_station_id = #{pumpingStationId} AND neighborhood_id = #{neighborhoodId} AND del_flag = 0 ) a
- INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
- INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
- INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
- </select>
- <select id="getDistinctNamesUnionById" resultType="string">
- SELECT GROUP_CONCAT(DISTINCT b.`name` SEPARATOR ', ')
- FROM
- t_cut_off_water_extra a
- INNER JOIN t_neighborhood b ON a.neighborhood_id = b.id
- AND a.del_flag = 0
- AND b.del_flag = 0
- WHERE a.cut_off_water_id = #{id}
- </select>
- </mapper>
|