<?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="ownerPropertySurveyServiceDaoImpl">
|
|
<!-- 保存业主房屋产调记录信息 -->
|
<insert id="saveOwnerPropertySurveyInfo" parameterType="Map">
|
insert into owner_property_survey(
|
id, owner_id, room_id, survey_warrant_apply_date, property_survey_date,
|
name, extra_date, create_time, update_time
|
) values (
|
#{id}, #{ownerId}, #{roomId},
|
<if test="surveyWarrantApplyDate == null">''</if>
|
<if test="surveyWarrantApplyDate != null">#{surveyWarrantApplyDate}</if>,
|
<if test="propertySurveyDate == null">''</if>
|
<if test="propertySurveyDate != null">#{propertySurveyDate}</if>,
|
<if test="name == null">''</if>
|
<if test="name != null">#{name}</if>,
|
<if test="extraDate == null">''</if>
|
<if test="extraDate != null">#{extraDate}</if>,
|
<if test="createTime == null">CURRENT_TIMESTAMP</if>
|
<if test="createTime != null">#{createTime}</if>,
|
<if test="updateTime == null">CURRENT_TIMESTAMP</if>
|
<if test="updateTime != null">#{updateTime}</if>
|
)
|
</insert>
|
|
<!-- 批量插入业主房屋产调记录 -->
|
<insert id="saveOwnerPropertySurveys" parameterType="Map">
|
insert into owner_property_survey(
|
id, owner_id, room_id, survey_warrant_apply_date, property_survey_date,
|
name, extra_date, create_time, update_time
|
) values
|
<foreach collection="ownerPropertySurveyPos" item="item" separator=",">
|
( #{item.id}, #{item.ownerId}, #{item.roomId},
|
<if test="item.surveyWarrantApplyDate == null">''</if><if test="item.surveyWarrantApplyDate != null">#{item.surveyWarrantApplyDate}</if>,
|
<if test="item.propertySurveyDate == null">''</if><if test="item.propertySurveyDate != null">#{item.propertySurveyDate}</if>,
|
<if test="item.name == null">''</if><if test="item.name != null">#{item.name}</if>,
|
<if test="item.extraDate == null">''</if><if test="item.extraDate != null">#{item.extraDate}</if>,
|
<if test="item.createTime == null">CURRENT_TIMESTAMP</if><if test="item.createTime != null">#{item.createTime}</if>,
|
<if test="item.updateTime == null">CURRENT_TIMESTAMP</if><if test="item.updateTime != null">#{item.updateTime}</if>)
|
</foreach>
|
</insert>
|
|
<!-- 查询业主房屋产调记录信息(单条/多条) -->
|
<select id="getOwnerPropertySurveyInfo" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.owner_id as ownerId,
|
t.room_id as roomId,
|
t.survey_warrant_apply_date as surveyWarrantApplyDate,
|
t.property_survey_date as propertySurveyDate,
|
t.name,
|
t.extra_date as extraDate,
|
t.create_time as createTime,
|
t.update_time as updateTime
|
from owner_property_survey t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="ownerId != null and ownerId != ''">
|
and t.owner_id = #{ownerId}
|
</if>
|
<if test="roomId != null and roomId != ''">
|
and t.room_id = #{roomId}
|
</if>
|
<if test="surveyWarrantApplyDate != null and surveyWarrantApplyDate != ''">
|
and t.survey_warrant_apply_date = #{surveyWarrantApplyDate}
|
</if>
|
<if test="propertySurveyDate != null and propertySurveyDate != ''">
|
and t.property_survey_date = #{propertySurveyDate}
|
</if>
|
<if test="name != null and name != ''">
|
and t.name = #{name}
|
</if>
|
<if test="extraDate != null and extraDate != ''">
|
and t.extra_date = #{extraDate}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date >= #{startSurveyWarrantApplyDate}
|
</if>
|
<if test="endSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date <= #{endSurveyWarrantApplyDate}
|
</if>
|
<if test="startPropertySurveyDate != null">
|
and t.property_survey_date >= #{startPropertySurveyDate}
|
</if>
|
<if test="endPropertySurveyDate != null">
|
and t.property_survey_date <= #{endPropertySurveyDate}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
order by t.id desc
|
<if test="page != -1 and page != null ">
|
limit #{page}, #{row}
|
</if>
|
</select>
|
|
<!-- 查询业主房屋产调记录数量 -->
|
<select id="queryOwnerPropertySurveysCount" parameterType="Map" resultType="Map">
|
select count(1) count
|
from owner_property_survey t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="ownerId != null and ownerId != ''">
|
and t.owner_id = #{ownerId}
|
</if>
|
<if test="roomId != null and roomId != ''">
|
and t.room_id = #{roomId}
|
</if>
|
<if test="surveyWarrantApplyDate != null and surveyWarrantApplyDate != ''">
|
and t.survey_warrant_apply_date = #{surveyWarrantApplyDate}
|
</if>
|
<if test="propertySurveyDate != null and propertySurveyDate != ''">
|
and t.property_survey_date = #{propertySurveyDate}
|
</if>
|
<if test="name != null and name != ''">
|
and t.name = #{name}
|
</if>
|
<if test="extraDate != null and extraDate != ''">
|
and t.extra_date = #{extraDate}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date >= #{startSurveyWarrantApplyDate}
|
</if>
|
<if test="endSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date <= #{endSurveyWarrantApplyDate}
|
</if>
|
<if test="startPropertySurveyDate != null">
|
and t.property_survey_date >= #{startPropertySurveyDate}
|
</if>
|
<if test="endPropertySurveyDate != null">
|
and t.property_survey_date <= #{endPropertySurveyDate}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
</select>
|
|
<!-- 修改业主房屋产调记录信息 -->
|
<update id="updateOwnerPropertySurveyInfo" parameterType="Map">
|
update owner_property_survey t set
|
<if test="ownerId != null and ownerId != ''">
|
t.owner_id = #{ownerId},
|
</if>
|
<if test="roomId != null and roomId != ''">
|
t.room_id = #{roomId},
|
</if>
|
<if test="surveyWarrantApplyDate != null">
|
t.survey_warrant_apply_date = #{surveyWarrantApplyDate},
|
</if>
|
<if test="propertySurveyDate != null">
|
t.property_survey_date = #{propertySurveyDate},
|
</if>
|
<if test="name != null">
|
t.name = #{name},
|
</if>
|
<if test="extraDate != null">
|
t.extra_date = #{extraDate},
|
</if>
|
<if test="updateTime != null">
|
t.update_time = #{updateTime},
|
</if>
|
t.update_time = CURRENT_TIMESTAMP
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="ownerId != null and ownerId != '' and roomId != null and roomId != ''">
|
and t.owner_id = #{ownerId} and t.room_id = #{roomId}
|
</if>
|
</update>
|
|
<!-- 删除业主房屋产调记录信息 -->
|
<delete id="deleteOwnerPropertySurveyInfo" parameterType="Map">
|
delete from owner_property_survey t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="ownerId != null and ownerId != ''">
|
and t.owner_id = #{ownerId}
|
</if>
|
<if test="roomId != null and roomId != ''">
|
and t.room_id = #{roomId}
|
</if>
|
<if test="surveyWarrantApplyDate != null and surveyWarrantApplyDate != ''">
|
and t.survey_warrant_apply_date = #{surveyWarrantApplyDate}
|
</if>
|
<if test="propertySurveyDate != null and propertySurveyDate != ''">
|
and t.property_survey_date = #{propertySurveyDate}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date >= #{startSurveyWarrantApplyDate}
|
</if>
|
<if test="endSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date <= #{endSurveyWarrantApplyDate}
|
</if>
|
</delete>
|
|
<!-- 查询业主房屋产调记录统计信息 -->
|
<select id="queryOwnerPropertySurveyStatistics" parameterType="Map" resultType="Map">
|
select
|
count(1) as total_count,
|
count(distinct t.owner_id) as distinct_owner_count,
|
count(distinct t.room_id) as distinct_room_count,
|
min(t.survey_warrant_apply_date) as earliest_survey_warrant_apply_date,
|
max(t.survey_warrant_apply_date) as latest_survey_warrant_apply_date,
|
min(t.property_survey_date) as earliest_property_survey_date,
|
max(t.property_survey_date) as latest_property_survey_date
|
from owner_property_survey t
|
where 1 = 1
|
<if test="ownerId != null and ownerId != ''">
|
and t.owner_id = #{ownerId}
|
</if>
|
<if test="roomId != null and roomId != ''">
|
and t.room_id = #{roomId}
|
</if>
|
<if test="startSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date >= #{startSurveyWarrantApplyDate}
|
</if>
|
<if test="endSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date <= #{endSurveyWarrantApplyDate}
|
</if>
|
<if test="startPropertySurveyDate != null">
|
and t.property_survey_date >= #{startPropertySurveyDate}
|
</if>
|
<if test="endPropertySurveyDate != null">
|
and t.property_survey_date <= #{endPropertySurveyDate}
|
</if>
|
</select>
|
|
<!-- 按年月维度统计产调记录 -->
|
<select id="queryOwnerPropertySurveyByMonth" parameterType="Map" resultType="Map">
|
select
|
date_format(str_to_date(t.property_survey_date, '%Y-%m-%d'), '%Y-%m') as month,
|
count(1) as total_count,
|
count(distinct t.owner_id) as owner_count,
|
count(distinct t.room_id) as room_count
|
from owner_property_survey t
|
where 1 = 1
|
and t.property_survey_date != ''
|
<if test="startPropertySurveyDate != null">
|
and t.property_survey_date >= #{startPropertySurveyDate}
|
</if>
|
<if test="endPropertySurveyDate != null">
|
and t.property_survey_date <= #{endPropertySurveyDate}
|
</if>
|
group by date_format(str_to_date(t.property_survey_date, '%Y-%m-%d'), '%Y-%m')
|
order by month desc
|
</select>
|
|
<!-- 查询未完成产调的记录(产调日期为空) -->
|
<select id="queryUnfinishedPropertySurveyRecords" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.owner_id as ownerId,
|
t.room_id as roomId,
|
t.survey_warrant_apply_date as surveyWarrantApplyDate,
|
t.property_survey_date as propertySurveyDate,
|
t.name,
|
t.extra_date as extraDate,
|
datediff(curdate(), str_to_date(t.survey_warrant_apply_date, '%Y-%m-%d')) as overdue_days
|
from owner_property_survey t
|
where 1 = 1
|
and (t.property_survey_date = '' or t.property_survey_date is null)
|
<if test="ownerId != null and ownerId != ''">
|
and t.owner_id = #{ownerId}
|
</if>
|
<if test="roomId != null and roomId != ''">
|
and t.room_id = #{roomId}
|
</if>
|
<if test="startSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date >= #{startSurveyWarrantApplyDate}
|
</if>
|
<if test="endSurveyWarrantApplyDate != null">
|
and t.survey_warrant_apply_date <= #{endSurveyWarrantApplyDate}
|
</if>
|
order by overdue_days desc, t.survey_warrant_apply_date asc
|
<if test="page != -1 and page != null ">
|
limit #{page}, #{row}
|
</if>
|
</select>
|
|
</mapper>
|