213 lines
10 KiB
XML
213 lines
10 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.ProjectMapper">
|
|
|
|
<resultMap type="Project" id="ProjectResult">
|
|
<result property="id" column="id"/>
|
|
<result property="tenantId" column="tenant_id"/>
|
|
<result property="projectType" column="project_type"/>
|
|
<result property="projectName" column="project_name"/>
|
|
<result property="projectShortName" column="project_short_name"/>
|
|
<result property="region" column="region"/>
|
|
<result property="address" column="address"/>
|
|
<result property="projectTags" column="project_tags"/>
|
|
<result property="projectDesc" column="project_desc"/>
|
|
<result property="projectImage" column="project_image"/>
|
|
<result property="managerId" column="manager_id"/>
|
|
<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="selectProjectVo">
|
|
select id, tenant_id, project_type, project_name, project_short_name, region,
|
|
address, project_tags, project_desc, project_image, manager_id, create_time,
|
|
last_mod_time, create_user_id, last_mod_user_id, del_flag, remark,
|
|
reserve1, reserve2, reserve3
|
|
from TB_PROJECT
|
|
</sql>
|
|
|
|
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
|
<include refid="selectProjectVo"/>
|
|
<where>
|
|
<if test="projectType != null and projectType != ''">
|
|
AND project_type = #{projectType}
|
|
</if>
|
|
<if test="projectName != null and projectName != ''">
|
|
AND project_name like concat('%', #{projectName}, '%')
|
|
</if>
|
|
<if test="projectShortName != null and projectShortName != ''">
|
|
AND project_short_name like concat('%', #{projectShortName}, '%')
|
|
</if>
|
|
<if test="region != null and region != ''">
|
|
AND region = #{region}
|
|
</if>
|
|
<if test="projectTags != null and projectTags != ''">
|
|
AND project_tags = #{projectTags}
|
|
</if>
|
|
<if test="managerId != null and managerId != ''">
|
|
AND manager_id = #{managerId}
|
|
</if>
|
|
AND del_flag = '0'
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<select id="selectProjectById" parameterType="String" resultMap="ProjectResult">
|
|
<include refid="selectProjectVo"/>
|
|
where id = #{id} and del_flag = '0'
|
|
</select>
|
|
|
|
<insert id="insertProject" parameterType="Project" useGeneratedKeys="true" keyProperty="id">
|
|
insert into TB_PROJECT
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="tenantId != null">tenant_id,</if>
|
|
<if test="projectType != null">project_type,</if>
|
|
<if test="projectName != null">project_name,</if>
|
|
<if test="projectShortName != null">project_short_name,</if>
|
|
<if test="region != null">region,</if>
|
|
<if test="address != null">address,</if>
|
|
<if test="projectTags != null">project_tags,</if>
|
|
<if test="projectDesc != null">project_desc,</if>
|
|
<if test="projectImage != null">project_image,</if>
|
|
<if test="managerId != null">manager_id,</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="projectType != null">#{projectType},</if>
|
|
<if test="projectName != null">#{projectName},</if>
|
|
<if test="projectShortName != null">#{projectShortName},</if>
|
|
<if test="region != null">#{region},</if>
|
|
<if test="address != null">#{address},</if>
|
|
<if test="projectTags != null">#{projectTags},</if>
|
|
<if test="projectDesc != null">#{projectDesc},</if>
|
|
<if test="projectImage != null">#{projectImage},</if>
|
|
<if test="managerId != null">#{managerId},</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="updateProject" parameterType="Project">
|
|
update TB_PROJECT
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="projectType != null">project_type = #{projectType},</if>
|
|
<if test="projectName != null">project_name = #{projectName},</if>
|
|
<if test="projectShortName != null">project_short_name = #{projectShortName},</if>
|
|
<if test="region != null">region = #{region},</if>
|
|
<if test="address != null">address = #{address},</if>
|
|
<if test="projectTags != null">project_tags = #{projectTags},</if>
|
|
<if test="projectDesc != null">project_desc = #{projectDesc},</if>
|
|
<if test="projectImage != null">project_image = #{projectImage},</if>
|
|
<if test="managerId != null">manager_id = #{managerId},</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="deleteProjectById" parameterType="String">
|
|
update TB_PROJECT set del_flag = '1' where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteProjectByIds" parameterType="String">
|
|
update TB_PROJECT set del_flag = '1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectProjectIdByName" parameterType="String" resultType="String">
|
|
select id from TB_PROJECT
|
|
where project_name = #{projectName}
|
|
and del_flag = '0'
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="checkProjectNameExists" parameterType="Project" resultType="Integer">
|
|
select count(*) from TB_PROJECT
|
|
where project_name = #{projectName}
|
|
and tenant_id = #{tenantId}
|
|
and del_flag = '0'
|
|
<if test="id != null and id != ''">
|
|
and id != #{id}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="checkProjectShortNameExists" parameterType="Project" resultType="Integer">
|
|
select count(*) from TB_PROJECT
|
|
where project_short_name = #{projectShortName}
|
|
and tenant_id = #{tenantId}
|
|
and del_flag = '0'
|
|
<if test="id != null and id != ''">
|
|
and id != #{id}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectProjectStatistics" parameterType="String" resultMap="ProjectResult">
|
|
select p.*,
|
|
(select COALESCE(sum(building_area), 0) from TB_BUILDING where project_id = p.id and del_flag = '0') as total_area,
|
|
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.business_status = '招商') as available_area,
|
|
(select count(*) from TB_BUILDING where project_id = p.id and del_flag = '0') as total_buildings,
|
|
(select count(*) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.business_status = '招商') as available_buildings,
|
|
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_area,
|
|
(select count(*) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '已租') as rented_buildings,
|
|
(select COALESCE(sum(building_area), 0) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_area,
|
|
(select count(*) from TB_BUILDING b
|
|
inner join TB_ROOM_BASE rb on b.id = rb.building_id
|
|
inner join TB_ROOM_BUSINESS rbs on rb.id = rbs.room_id
|
|
where b.project_id = p.id and b.del_flag = '0' and rb.del_flag = '0' and rbs.rental_status = '待租') as waiting_buildings
|
|
from TB_PROJECT p
|
|
where p.id = #{id} and p.del_flag = '0'
|
|
</select>
|
|
<select id="selectProjectListByIds" parameterType="java.util.List" resultMap="ProjectResult">
|
|
<include refid="selectProjectVo"/>
|
|
where id IN
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</select>
|
|
</mapper> |