172 lines
7.7 KiB
XML
172 lines
7.7 KiB
XML
<?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.eden.room.mapper.FloorMapper">
|
|
|
|
<resultMap type="Floor" id="FloorResult">
|
|
<result property="id" column="id"/>
|
|
<result property="tenantId" column="tenant_id"/>
|
|
<result property="buildingId" column="building_id"/>
|
|
<result property="floorNumber" column="floor_number"/>
|
|
<result property="floorName" column="floor_name"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="lastModTime" column="last_mod_time"/>
|
|
<result property="createUserId" column="create_user_id"/>
|
|
<result property="lastModUserId" column="last_mod_user_id"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="reserve1" column="reserve1"/>
|
|
<result property="reserve2" column="reserve2"/>
|
|
<result property="reserve3" column="reserve3"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectFloorVo">
|
|
select id, tenant_id, building_id, floor_number, floor_name,
|
|
create_time, last_mod_time, create_user_id, last_mod_user_id,
|
|
del_flag, remark, reserve1, reserve2, reserve3
|
|
from TB_FLOOR
|
|
</sql>
|
|
|
|
<select id="selectFloorList" parameterType="Floor" resultMap="FloorResult">
|
|
<include refid="selectFloorVo"/>
|
|
<where>
|
|
<if test="buildingId != null and buildingId != ''">
|
|
AND building_id = #{buildingId}
|
|
</if>
|
|
<if test="floorNumber != null">
|
|
AND floor_number = #{floorNumber}
|
|
</if>
|
|
<if test="floorName != null and floorName != ''">
|
|
AND floor_name like concat('%', #{floorName}, '%')
|
|
</if>
|
|
AND del_flag = '0'
|
|
</where>
|
|
order by floor_number asc
|
|
</select>
|
|
|
|
<select id="selectFloorById" parameterType="String" resultMap="FloorResult">
|
|
<include refid="selectFloorVo"/>
|
|
where id = #{id} and del_flag = '0'
|
|
</select>
|
|
|
|
<insert id="insertFloor" parameterType="Floor" useGeneratedKeys="true" keyProperty="id">
|
|
insert into TB_FLOOR
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="tenantId != null">tenant_id,</if>
|
|
<if test="buildingId != null">building_id,</if>
|
|
<if test="floorNumber != null">floor_number,</if>
|
|
<if test="floorName != null">floor_name,</if>
|
|
<if test="createUserId != null">create_user_id,</if>
|
|
<if test="lastModUserId != null">last_mod_user_id,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="reserve1 != null">reserve1,</if>
|
|
<if test="reserve2 != null">reserve2,</if>
|
|
<if test="reserve3 != null">reserve3,</if>
|
|
create_time,
|
|
last_mod_time
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="tenantId != null">#{tenantId},</if>
|
|
<if test="buildingId != null">#{buildingId},</if>
|
|
<if test="floorNumber != null">#{floorNumber},</if>
|
|
<if test="floorName != null">#{floorName},</if>
|
|
<if test="createUserId != null">#{createUserId},</if>
|
|
<if test="lastModUserId != null">#{lastModUserId},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="reserve1 != null">#{reserve1},</if>
|
|
<if test="reserve2 != null">#{reserve2},</if>
|
|
<if test="reserve3 != null">#{reserve3},</if>
|
|
CURRENT_TIMESTAMP,
|
|
CURRENT_TIMESTAMP
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateFloor" parameterType="Floor">
|
|
update TB_FLOOR
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="floorNumber != null">floor_number = #{floorNumber},</if>
|
|
<if test="floorName != null">floor_name = #{floorName},</if>
|
|
<if test="lastModUserId != null">last_mod_user_id = #{lastModUserId},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="reserve1 != null">reserve1 = #{reserve1},</if>
|
|
<if test="reserve2 != null">reserve2 = #{reserve2},</if>
|
|
<if test="reserve3 != null">reserve3 = #{reserve3},</if>
|
|
last_mod_time = CURRENT_TIMESTAMP
|
|
</trim>
|
|
where id = #{id} and del_flag = '0'
|
|
</update>
|
|
|
|
<delete id="deleteFloorById" parameterType="String">
|
|
update TB_FLOOR set del_flag = '1' where id = #{id} and del_flag = '0'
|
|
</delete>
|
|
|
|
<delete id="deleteFloorByIds" parameterType="String">
|
|
update TB_FLOOR set del_flag = '1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="checkFloorNameExists" parameterType="Floor" resultType="Integer">
|
|
select count(*) from TB_FLOOR
|
|
where floor_name = #{floorName}
|
|
and building_id = #{buildingId}
|
|
and tenant_id = #{tenantId}
|
|
and del_flag = '0'
|
|
<if test="id != null and id != ''">
|
|
and id != #{id}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="checkFloorNumberExists" parameterType="Floor" resultType="Integer">
|
|
select count(*) from TB_FLOOR
|
|
where floor_number = #{floorNumber}
|
|
and building_id = #{buildingId}
|
|
and tenant_id = #{tenantId}
|
|
and del_flag = '0'
|
|
<if test="id != null and id != ''">
|
|
and id != #{id}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectFloorStatistics" parameterType="String" resultMap="FloorResult">
|
|
select f.*,
|
|
(select count(*) from TB_ROOM_BASE where floor_id = f.id and del_flag = '0') as total_rooms,
|
|
(select count(*) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_rooms,
|
|
(select count(*) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_rooms,
|
|
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_area,
|
|
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_area,
|
|
(select count(*) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_rooms,
|
|
(select COALESCE(sum(rb.building_area), 0) from TB_ROOM_BASE rb
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where rb.floor_id = f.id and rb.del_flag = '0' and rbs.business_status = '招商') as available_area
|
|
from TB_FLOOR f
|
|
where f.id = #{id} and f.del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectFloorIdByNameAndBuildingId" resultType="String">
|
|
select id from TB_FLOOR
|
|
where floor_name = #{floorName}
|
|
and building_id = #{buildingId}
|
|
and del_flag = '0'
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="checkFloorHasRooms" parameterType="String" resultType="Integer">
|
|
select count(*) from TB_ROOM_BASE
|
|
where floor_id = #{id} and del_flag = '0'
|
|
</select>
|
|
</mapper> |