<?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.zzg.system.mapper.state.StateApplyRecordMapper">
|
<select id="selectProjectWithApplyRecord" parameterType="com.zzg.system.domain.bo.StateApplyRecordPageBO"
|
resultType="com.zzg.system.domain.vo.StateApplyRecordVO">
|
SELECT A.project_name,
|
A.id as projectId,
|
b.*
|
FROM state_project A
|
LEFT JOIN state_apply_record b ON A.id = b.project_id
|
WHERE 1 = 1
|
and b.id is not null
|
<if test="stateApplyRecordPageBO.projectId != null">
|
AND A.id = #{stateApplyRecordPageBO.projectId}
|
</if>
|
<if test="stateApplyRecordPageBO.applyStartTime != null
|
and stateApplyRecordPageBO.applyEndTime != null">
|
AND b.create_time BETWEEN #{stateApplyRecordPageBO.applyStartTime,jdbcType=DATE} AND
|
#{stateApplyRecordPageBO.applyEndTime,jdbcType=DATE}
|
</if>
|
<if test="stateApplyRecordPageBO.applyStatus != null and stateApplyRecordPageBO.applyStatus != '' != null">
|
AND b.apply_status = #{stateApplyRecordPageBO.applyStatus}
|
</if>
|
<if test="stateApplyRecordPageBO.applyUser != null and stateApplyRecordPageBO.applyUser != '' != null">
|
AND b.apply_user LIKE CONCAT('%', #{stateApplyRecordPageBO.applyUser}, '%')
|
</if>
|
<if test="stateApplyRecordPageBO.applyDepartment != null and stateApplyRecordPageBO.applyDepartment != ''">
|
AND b.apply_department LIKE CONCAT('%', #{stateApplyRecordPageBO.applyDepartment}, '%')
|
</if>
|
<if test="stateApplyRecordPageBO.projectName != null and stateApplyRecordPageBO.projectName != ''">
|
AND a.project_name LIKE CONCAT('%', #{stateApplyRecordPageBO.projectName}, '%')
|
</if>
|
<if test="stateApplyRecordPageBO.applyType != null and stateApplyRecordPageBO.applyType != ''">
|
AND b.apply_type = #{stateApplyRecordPageBO.applyType}
|
</if>
|
order by b.create_time desc
|
</select>
|
|
<select id="selectProjectAndHousehold"
|
resultType="com.zzg.system.domain.vo.ApplyHouseholdOwnerVO">
|
SELECT A.project_name,
|
A.start_time,
|
c.*
|
FROM state_project A
|
LEFT JOIN state_household c ON A.ID = c.state_project_id
|
LEFT JOIN state_household_owner d ON c.ID = d.state_household_id
|
WHERE 1 = 1
|
<if test="projectId != null and projectId != ''">
|
AND A.ID = #{projectId}
|
</if>
|
<if test="ownerType != null">
|
AND c.owner_type = #{ownerType}
|
</if>
|
AND c.ID IS NOT NULL
|
</select>
|
|
<select id="selectApplyRecordWithOwnerDistinctPage"
|
parameterType="com.zzg.system.domain.bo.GetApplyHouseholdOwnerBO"
|
resultType="com.zzg.system.domain.bo.ApplyOwnerBO">
|
SELECT DISTINCT on (t3.ID) t1.*,
|
t2.person_id_card,
|
t2.company_social_code,
|
t2.company_agent,
|
t2.owner_name,
|
t2.owner_type,
|
t2.id as stateHouseholdOwnerId,
|
t4.record_no,
|
t4.project_id,
|
t5.start_time,
|
t3.belonging_street_town as street,
|
t3.id as stateHouseholdId
|
FROM state_apply_record_item t1
|
LEFT JOIN state_household_owner t2 ON t1.state_household_owner = t2.id
|
LEFT JOIN state_household t3 ON t2.state_household_id = t3.id
|
LEFT JOIN state_apply_record t4 ON t1.apply_id = t4.id
|
LEFT JOIN state_project t5 ON t4.project_id = t5.id
|
WHERE 1 = 1
|
<!-- <if test="getApplyHouseholdOwnerBO.ownerType != null">-->
|
<!-- AND t2.owner_type = #{getApplyHouseholdOwnerBO.ownerType}-->
|
<!-- </if>-->
|
<if test="getApplyHouseholdOwnerBO.applyType != null">
|
AND t4.apply_type = #{getApplyHouseholdOwnerBO.applyType}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.projectId != null and getApplyHouseholdOwnerBO.projectId != ''">
|
AND t4.project_id = #{getApplyHouseholdOwnerBO.projectId}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.applyId != null and getApplyHouseholdOwnerBO.applyId != ''">
|
AND t4.id = #{getApplyHouseholdOwnerBO.applyId}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.street != null and getApplyHouseholdOwnerBO.street != ''">
|
AND t3.belonging_street_town LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.street}, '%')
|
</if>
|
<!-- 使用 choose 来根据条件切换模糊查询的字段 -->
|
<choose>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 1">
|
<if test="getApplyHouseholdOwnerBO.ownerName != null and getApplyHouseholdOwnerBO.ownerName != ''">
|
AND t2.owner_name LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.ownerName}, '%')
|
</if>
|
</when>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 2">
|
<if test="getApplyHouseholdOwnerBO.ownerName != null and getApplyHouseholdOwnerBO.ownerName != ''">
|
AND t2.owner_name LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.ownerName}, '%')
|
</if>
|
</when>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 0">
|
</when>
|
<otherwise>
|
-- 默认情况不执行任何操作,防止空选择引起的语法错误
|
</otherwise>
|
</choose>
|
</select>
|
<select id="selectApplyRecordWithProject" parameterType="com.zzg.system.domain.bo.StateApplyRecordPageBO"
|
resultType="com.zzg.system.domain.vo.StateApplyRecordVO">
|
SELECT t1.*,
|
t2.project_no,
|
t2.project_name,
|
t2.start_time,
|
t2.street
|
FROM state_apply_record t1
|
LEFT JOIN
|
state_project t2 ON t1.project_id = t2.id
|
WHERE 1 = 1
|
AND t1.apply_status = 3
|
<if test="stateApplyRecordPageInfoLevelBO.applyType != null">
|
AND t1.apply_type = #{stateApplyRecordPageInfoLevelBO.applyType}
|
</if>
|
<!-- 动态判断 project_no -->
|
<if test="stateApplyRecordPageInfoLevelBO.projectNo != null and stateApplyRecordPageInfoLevelBO.projectNo != ''">
|
AND t2.project_no LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.projectNo}, '%')
|
</if>
|
<!-- 动态判断 project_name -->
|
<if test="stateApplyRecordPageInfoLevelBO.projectName != null and stateApplyRecordPageInfoLevelBO.projectName != ''">
|
AND t2.project_name LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.projectName}, '%')
|
</if>
|
<!-- 动态判断 street -->
|
<if test="stateApplyRecordPageInfoLevelBO.street != null and stateApplyRecordPageInfoLevelBO.street != ''">
|
AND t2.street LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.street}, '%')
|
</if>
|
<if test="stateApplyRecordPageInfoLevelBO.projectId != null and stateApplyRecordPageInfoLevelBO.projectId != ''">
|
and t2.id = #{stateApplyRecordPageInfoLevelBO.projectId}
|
</if>
|
</select>
|
|
<select id="countApplyRecordWithOwnerPage" parameterType="com.zzg.system.domain.bo.StateApplyRecordPageBO"
|
resultType="java.lang.String">
|
SELECT stateHouseholdId
|
FROM (
|
SELECT t1.*,
|
t2.project_no,
|
t2.project_name,
|
t2.start_time,
|
t2.street
|
FROM state_apply_record t1
|
LEFT JOIN
|
state_project t2 ON t1.project_id = t2.id
|
WHERE 1 = 1
|
AND t1.apply_status = 3
|
<if test="stateApplyRecordPageInfoLevelBO.applyType != null">
|
AND t1.apply_type = #{stateApplyRecordPageInfoLevelBO.applyType}
|
</if>
|
<!-- 动态判断 project_no -->
|
<if test="stateApplyRecordPageInfoLevelBO.projectNo != null and stateApplyRecordPageInfoLevelBO.projectNo != ''">
|
AND t2.project_no LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.projectNo}, '%')
|
</if>
|
<!-- 动态判断 project_name -->
|
<if test="stateApplyRecordPageInfoLevelBO.projectName != null and stateApplyRecordPageInfoLevelBO.projectName != ''">
|
AND t2.project_name LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.projectName}, '%')
|
</if>
|
<!-- 动态判断 street -->
|
<if test="stateApplyRecordPageInfoLevelBO.street != null and stateApplyRecordPageInfoLevelBO.street != ''">
|
AND t2.street LIKE CONCAT('%', #{stateApplyRecordPageInfoLevelBO.street}, '%')
|
</if>
|
<if test="stateApplyRecordPageInfoLevelBO.projectId != null and stateApplyRecordPageInfoLevelBO.projectId != ''">
|
and t2.id = #{stateApplyRecordPageInfoLevelBO.projectId}
|
</if>
|
) tmp_count
|
GROUP BY stateHouseholdId
|
</select>
|
|
<select id="selectApplyRecordWithOwnerPage" resultType="com.zzg.system.domain.bo.ApplyOwnerBO">
|
SELECT t1.*,
|
t2.person_id_card,
|
t2.company_social_code,
|
t2.company_agent,
|
t2.owner_name,
|
t2.owner_type,
|
t2.id as stateHouseholdOwnerId,
|
t4.record_no,
|
t4.project_id,
|
t5.start_time,
|
t3.belonging_street_town as street,
|
t3.id as stateHouseholdId
|
FROM state_apply_record_item t1
|
LEFT JOIN state_household_owner t2 ON t1.state_household_owner = t2.id
|
LEFT JOIN state_household t3 ON t2.state_household_id = t3.id
|
LEFT JOIN state_apply_record t4 ON t1.apply_id = t4.id
|
LEFT JOIN state_project t5 ON t4.project_id = t5.id
|
WHERE 1 = 1
|
<!-- <if test="getApplyHouseholdOwnerBO.ownerType != null">-->
|
<!-- AND t2.owner_type = #{getApplyHouseholdOwnerBO.ownerType}-->
|
<!-- </if>-->
|
<if test="getApplyHouseholdOwnerBO.applyType != null">
|
AND t4.apply_type = #{getApplyHouseholdOwnerBO.applyType}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.projectId != null and getApplyHouseholdOwnerBO.projectId != ''">
|
AND t4.project_id = #{getApplyHouseholdOwnerBO.projectId}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.applyId != null and getApplyHouseholdOwnerBO.applyId != ''">
|
AND t4.id = #{getApplyHouseholdOwnerBO.applyId}
|
</if>
|
<if test="getApplyHouseholdOwnerBO.street != null and getApplyHouseholdOwnerBO.street != ''">
|
AND t3.belonging_street_town LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.street}, '%')
|
</if>
|
<!-- 使用 choose 来根据条件切换模糊查询的字段 -->
|
<choose>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 1">
|
<if test="getApplyHouseholdOwnerBO.ownerName != null and getApplyHouseholdOwnerBO.ownerName != ''">
|
AND t2.owner_name LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.ownerName}, '%')
|
</if>
|
</when>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 2">
|
<if test="getApplyHouseholdOwnerBO.ownerName != null and getApplyHouseholdOwnerBO.ownerName != ''">
|
AND t2.owner_name LIKE CONCAT('%', #{getApplyHouseholdOwnerBO.ownerName}, '%')
|
</if>
|
</when>
|
<when test="getApplyHouseholdOwnerBO.ownerType == 0">
|
</when>
|
<otherwise>
|
-- 默认情况不执行任何操作,防止空选择引起的语法错误
|
</otherwise>
|
</choose>
|
|
<if test="getApplyHouseholdOwnerBO.stateHouseIdList != null">
|
AND t1.state_household_id in
|
<foreach item="stateHouseId" collection="getApplyHouseholdOwnerBO.stateHouseIdList" open="(" separator=","
|
close=")">
|
#{stateHouseId}
|
</foreach>
|
</if>
|
</select>
|
</mapper>
|