923 lines
42 KiB
XML
923 lines
42 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.ruoyi.ccdi.project.mapper.CcdiProjectSpecialCheckMapper">
|
|
|
|
<resultMap id="FamilyAssetLiabilityListItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetLiabilityListItemVO">
|
|
<id property="staffIdCard" column="staff_id_card"/>
|
|
<result property="staffCode" column="staff_code"/>
|
|
<result property="staffName" column="staff_name"/>
|
|
<result property="deptName" column="dept_name"/>
|
|
<result property="totalIncome" column="total_income"/>
|
|
<result property="totalAsset" column="total_asset"/>
|
|
<result property="totalDebt" column="total_debt"/>
|
|
<result property="comparisonAmount" column="comparison_amount"/>
|
|
<result property="riskLevelCode" column="risk_level_code"/>
|
|
<result property="riskLevelName" column="risk_level_name"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="FamilyAssetItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetItemVO">
|
|
<result property="assetName" column="asset_name"/>
|
|
<result property="assetMainType" column="asset_main_type"/>
|
|
<result property="assetSubType" column="asset_sub_type"/>
|
|
<result property="holderName" column="holder_name"/>
|
|
<result property="holderIdCard" column="holder_id_card"/>
|
|
<result property="currentValue" column="current_value"/>
|
|
<result property="valuationDate" column="valuation_date"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="FamilyDebtItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyDebtItemVO">
|
|
<result property="debtName" column="debt_name"/>
|
|
<result property="debtMainType" column="debt_main_type"/>
|
|
<result property="debtSubType" column="debt_sub_type"/>
|
|
<result property="creditorType" column="creditor_type"/>
|
|
<result property="ownerName" column="owner_name"/>
|
|
<result property="ownerIdCard" column="owner_id_card"/>
|
|
<result property="principalBalance" column="principal_balance"/>
|
|
<result property="queryDate" column="query_date"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="ExtendedPurchaseListItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedPurchaseListItemVO">
|
|
<id property="purchaseId" column="purchase_id"/>
|
|
<result property="projectName" column="project_name"/>
|
|
<result property="subjectName" column="subject_name"/>
|
|
<result property="applicantName" column="applicant_name"/>
|
|
<result property="applyDate" column="apply_date"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="ExtendedRecruitmentListItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedRecruitmentListItemVO">
|
|
<id property="recruitId" column="recruit_id"/>
|
|
<result property="recruitName" column="recruit_name"/>
|
|
<result property="posName" column="pos_name"/>
|
|
<result property="interviewerNameSummary" column="interviewer_name_summary"/>
|
|
<result property="admitStatus" column="admit_status"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="ExtendedTransferListItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedTransferListItemVO">
|
|
<id property="id" column="id"/>
|
|
<result property="staffName" column="staff_name"/>
|
|
<result property="transferType" column="transfer_type"/>
|
|
<result property="deptNameBefore" column="dept_name_before"/>
|
|
<result property="deptNameAfter" column="dept_name_after"/>
|
|
<result property="transferDate" column="transfer_date"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="IncreaseLendingListItemResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectIncreaseLendingListItemVO">
|
|
<result property="staffId" column="staff_id"/>
|
|
<result property="staffName" column="staff_name"/>
|
|
<result property="staffIdCard" column="staff_id_card"/>
|
|
<result property="deptName" column="dept_name"/>
|
|
<result property="contractNo" column="contract_no"/>
|
|
<result property="lendingOrgNo" column="lending_org_no"/>
|
|
<result property="borrowerName" column="borrower_name"/>
|
|
<result property="borrowerCertNo" column="borrower_cert_no"/>
|
|
<result property="loanProduct" column="loan_product"/>
|
|
<result property="contractAmount" column="contract_amount"/>
|
|
<result property="loanBalance" column="loan_balance"/>
|
|
<result property="loanStartDate" column="loan_start_date"/>
|
|
<result property="loanEndDate" column="loan_end_date"/>
|
|
<result property="status" column="status"/>
|
|
<result property="fiveClassification" column="five_classification"/>
|
|
<result property="customerManagerId" column="customer_manager_id"/>
|
|
<result property="customerManagerName" column="customer_manager_name"/>
|
|
<result property="approver" column="approver"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="FamilyAssetLiabilityDetailResultMap"
|
|
type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetLiabilityDetailVO">
|
|
<association property="incomeDetail"
|
|
javaType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyIncomeDetailVO">
|
|
<result property="selfIncome" column="income_self_income"/>
|
|
<result property="spouseIncome" column="income_spouse_income"/>
|
|
<result property="totalIncome" column="income_total_income"/>
|
|
</association>
|
|
<association property="assetDetail"
|
|
javaType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetDetailVO">
|
|
<result property="missingSelfAssetInfo" column="asset_missing_self_asset_info"/>
|
|
<result property="selfTotalAsset" column="asset_self_total_asset"/>
|
|
<result property="spouseTotalAsset" column="asset_spouse_total_asset"/>
|
|
<result property="totalAsset" column="asset_total_asset"/>
|
|
<collection property="items"
|
|
column="{projectId=project_id,staffIdCard=staff_id_card,spouseIdCard=spouse_id_card,spouseIsStaff=spouse_is_staff}"
|
|
ofType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetItemVO"
|
|
select="selectFamilyAssetItemsByScope"/>
|
|
</association>
|
|
<association property="debtDetail"
|
|
javaType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyDebtDetailVO">
|
|
<result property="missingSelfDebtInfo" column="debt_missing_self_debt_info"/>
|
|
<result property="selfTotalDebt" column="debt_self_total_debt"/>
|
|
<result property="spouseTotalDebt" column="debt_spouse_total_debt"/>
|
|
<result property="totalDebt" column="debt_total_debt"/>
|
|
<collection property="items"
|
|
column="{projectId=project_id,staffIdCard=staff_id_card,spouseIdCard=spouse_id_card,spouseIsStaff=spouse_is_staff}"
|
|
ofType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyDebtItemVO"
|
|
select="selectFamilyDebtItemsByScope"/>
|
|
</association>
|
|
<association property="summary"
|
|
javaType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetLiabilityListItemVO">
|
|
<id property="staffIdCard" column="summary_staff_id_card"/>
|
|
<result property="staffCode" column="summary_staff_code"/>
|
|
<result property="staffName" column="summary_staff_name"/>
|
|
<result property="deptName" column="summary_dept_name"/>
|
|
<result property="totalIncome" column="summary_total_income"/>
|
|
<result property="totalAsset" column="summary_total_asset"/>
|
|
<result property="totalDebt" column="summary_total_debt"/>
|
|
<result property="comparisonAmount" column="summary_comparison_amount"/>
|
|
<result property="riskLevelCode" column="summary_risk_level_code"/>
|
|
<result property="riskLevelName" column="summary_risk_level_name"/>
|
|
</association>
|
|
</resultMap>
|
|
|
|
<sql id="projectEmployeeScopeSql">
|
|
select distinct
|
|
statement_staff.id_card as staff_id_card,
|
|
cast(statement_staff.staff_id as char) as staff_code,
|
|
statement_staff.name as staff_name,
|
|
dept.dept_name
|
|
from ccdi_bank_statement bs
|
|
inner join ccdi_base_staff statement_staff
|
|
on statement_staff.id_card = trim(bs.cret_no)
|
|
left join sys_dept dept
|
|
on dept.dept_id = statement_staff.dept_id
|
|
where bs.project_id = #{projectId}
|
|
and bs.cret_no is not null
|
|
and trim(bs.cret_no) != ''
|
|
</sql>
|
|
|
|
<sql id="spouseRelationSql">
|
|
select
|
|
relation_pair.person_id,
|
|
max(relation_pair.spouse_name) as spouse_name,
|
|
min(relation_pair.spouse_id_card) as spouse_id_card,
|
|
max(coalesce(spouse_staff.annual_income, relation_pair.spouse_relation_income, 0)) as spouse_income,
|
|
max(case when spouse_staff.id_card is not null then 1 else 0 end) as spouse_is_staff
|
|
from (
|
|
select
|
|
relation.person_id,
|
|
relation.relation_name as spouse_name,
|
|
relation.relation_cert_no as spouse_id_card,
|
|
relation.annual_income as spouse_relation_income
|
|
from ccdi_staff_fmy_relation relation
|
|
where relation.status = 1
|
|
and relation.is_emp_family = 1
|
|
and relation.relation_type = '配偶'
|
|
union all
|
|
select
|
|
relation.relation_cert_no as person_id,
|
|
base_staff.name as spouse_name,
|
|
relation.person_id as spouse_id_card,
|
|
null as spouse_relation_income
|
|
from ccdi_staff_fmy_relation relation
|
|
inner join ccdi_base_staff current_staff
|
|
on current_staff.id_card = relation.relation_cert_no
|
|
left join ccdi_base_staff base_staff
|
|
on base_staff.id_card = relation.person_id
|
|
where relation.status = 1
|
|
and relation.is_emp_family = 1
|
|
and relation.relation_type = '配偶'
|
|
) relation_pair
|
|
left join ccdi_base_staff spouse_staff
|
|
on spouse_staff.id_card = relation_pair.spouse_id_card
|
|
group by relation_pair.person_id
|
|
</sql>
|
|
|
|
<select id="selectFamilyAssetLiabilityList" resultMap="FamilyAssetLiabilityListItemResultMap">
|
|
select
|
|
aggregated.staff_id_card,
|
|
aggregated.staff_code,
|
|
aggregated.staff_name,
|
|
aggregated.dept_name,
|
|
aggregated.total_income,
|
|
aggregated.total_asset,
|
|
aggregated.total_debt,
|
|
aggregated.comparison_amount,
|
|
case
|
|
when aggregated.missing_asset_info = 1 or aggregated.missing_debt_info = 1 then 'MISSING_INFO'
|
|
when comparison_amount <= total_asset * 1.5 then 'NORMAL'
|
|
when comparison_amount > total_asset * 1.5 and comparison_amount <= total_asset * 3 then 'RISK'
|
|
when comparison_amount > total_asset * 3 then 'HIGH'
|
|
else 'HIGH'
|
|
end as risk_level_code,
|
|
case
|
|
when aggregated.missing_asset_info = 1 or aggregated.missing_debt_info = 1 then '缺少信息'
|
|
when comparison_amount <= total_asset * 1.5 then '正常'
|
|
when comparison_amount > total_asset * 1.5 and comparison_amount <= total_asset * 3 then '存在风险'
|
|
when comparison_amount > total_asset * 3 then '高风险'
|
|
else '高风险'
|
|
end as risk_level_name
|
|
from (
|
|
select
|
|
source.*,
|
|
case
|
|
when source.self_asset_record_count = 0
|
|
or source.spouse_staff_asset_record_count = 0 then 1
|
|
else 0
|
|
end as missing_asset_info,
|
|
case
|
|
when source.self_debt_record_count = 0
|
|
or source.spouse_staff_debt_record_count = 0 then 1
|
|
else 0
|
|
end as missing_debt_info,
|
|
case
|
|
when source.self_asset_record_count = 0
|
|
or source.spouse_staff_asset_record_count = 0
|
|
or source.self_debt_record_count = 0
|
|
or source.spouse_staff_debt_record_count = 0 then 4
|
|
when source.comparison_amount <= source.total_asset * 1.5 then 1
|
|
when source.comparison_amount <= source.total_asset * 3 then 2
|
|
when source.comparison_amount > source.total_asset * 3 then 3
|
|
else 3
|
|
end as risk_level_sort
|
|
from (
|
|
select
|
|
scope.staff_id_card,
|
|
scope.staff_code,
|
|
scope.staff_name,
|
|
scope.dept_name,
|
|
coalesce(base_staff.annual_income, 0) + coalesce(spouse.spouse_income, 0) as total_income,
|
|
coalesce((
|
|
select count(1)
|
|
from ccdi_asset_info asset
|
|
where asset.family_id = scope.staff_id_card
|
|
and asset.person_id = scope.staff_id_card
|
|
), 0) as self_asset_record_count,
|
|
case
|
|
when spouse.spouse_is_staff = 1 then coalesce((
|
|
select count(1)
|
|
from ccdi_asset_info asset
|
|
where asset.family_id = spouse.spouse_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
), 0)
|
|
else 1
|
|
end as spouse_staff_asset_record_count,
|
|
coalesce((
|
|
select count(1)
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
), 0) as self_debt_record_count,
|
|
case
|
|
when spouse.spouse_is_staff = 1 then coalesce((
|
|
select count(1)
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = spouse.spouse_id_card
|
|
), 0)
|
|
else 1
|
|
end as spouse_staff_debt_record_count,
|
|
coalesce((
|
|
select sum(coalesce(asset.current_value, 0))
|
|
from ccdi_asset_info asset
|
|
where (asset.family_id = scope.staff_id_card and asset.person_id = scope.staff_id_card)
|
|
or (
|
|
spouse.spouse_id_card is not null
|
|
and (
|
|
(
|
|
spouse.spouse_is_staff = 1
|
|
and asset.family_id = spouse.spouse_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
or (
|
|
(spouse.spouse_is_staff is null or spouse.spouse_is_staff != 1)
|
|
and asset.family_id = scope.staff_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
)
|
|
)
|
|
), 0) as total_asset,
|
|
coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
or (spouse.spouse_id_card is not null and debt.person_id = spouse.spouse_id_card)
|
|
), 0) as total_debt,
|
|
coalesce(base_staff.annual_income, 0)
|
|
+ coalesce(spouse.spouse_income, 0)
|
|
+ coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
or (spouse.spouse_id_card is not null and debt.person_id = spouse.spouse_id_card)
|
|
), 0) as comparison_amount
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
left join ccdi_base_staff base_staff
|
|
on base_staff.id_card = scope.staff_id_card
|
|
left join (
|
|
<include refid="spouseRelationSql"/>
|
|
) spouse
|
|
on spouse.person_id = scope.staff_id_card
|
|
) source
|
|
) aggregated
|
|
order by risk_level_sort desc, comparison_amount desc, staff_name asc
|
|
</select>
|
|
|
|
<select id="selectFamilyAssetLiabilityDetail" resultMap="FamilyAssetLiabilityDetailResultMap">
|
|
select
|
|
aggregated.project_id,
|
|
aggregated.staff_id_card,
|
|
aggregated.spouse_id_card,
|
|
aggregated.spouse_is_staff,
|
|
aggregated.staff_code,
|
|
aggregated.staff_name,
|
|
aggregated.dept_name,
|
|
aggregated.self_income as income_self_income,
|
|
aggregated.spouse_income as income_spouse_income,
|
|
aggregated.total_income as income_total_income,
|
|
aggregated.missing_self_asset_info as asset_missing_self_asset_info,
|
|
aggregated.self_total_asset as asset_self_total_asset,
|
|
aggregated.spouse_total_asset as asset_spouse_total_asset,
|
|
aggregated.total_asset as asset_total_asset,
|
|
aggregated.missing_self_debt_info as debt_missing_self_debt_info,
|
|
aggregated.self_total_debt as debt_self_total_debt,
|
|
aggregated.spouse_total_debt as debt_spouse_total_debt,
|
|
aggregated.total_debt as debt_total_debt,
|
|
aggregated.staff_id_card as summary_staff_id_card,
|
|
aggregated.staff_code as summary_staff_code,
|
|
aggregated.staff_name as summary_staff_name,
|
|
aggregated.dept_name as summary_dept_name,
|
|
aggregated.total_income as summary_total_income,
|
|
aggregated.total_asset as summary_total_asset,
|
|
aggregated.total_debt as summary_total_debt,
|
|
aggregated.comparison_amount as summary_comparison_amount,
|
|
case
|
|
when aggregated.missing_self_asset_info = 1 or aggregated.missing_self_debt_info = 1 then 'MISSING_INFO'
|
|
when comparison_amount <= total_asset * 1.5 then 'NORMAL'
|
|
when comparison_amount > total_asset * 1.5 and comparison_amount <= total_asset * 3 then 'RISK'
|
|
when comparison_amount > total_asset * 3 then 'HIGH'
|
|
else 'HIGH'
|
|
end as summary_risk_level_code,
|
|
case
|
|
when aggregated.missing_self_asset_info = 1 or aggregated.missing_self_debt_info = 1 then '缺少信息'
|
|
when comparison_amount <= total_asset * 1.5 then '正常'
|
|
when comparison_amount > total_asset * 1.5 and comparison_amount <= total_asset * 3 then '存在风险'
|
|
when comparison_amount > total_asset * 3 then '高风险'
|
|
else '高风险'
|
|
end as summary_risk_level_name
|
|
from (
|
|
select
|
|
source.*,
|
|
case
|
|
when source.self_asset_record_count = 0
|
|
or source.spouse_staff_asset_record_count = 0 then 1
|
|
else 0
|
|
end as missing_self_asset_info,
|
|
case
|
|
when source.self_debt_record_count = 0
|
|
or source.spouse_staff_debt_record_count = 0 then 1
|
|
else 0
|
|
end as missing_self_debt_info
|
|
from (
|
|
select
|
|
#{projectId} as project_id,
|
|
scope.staff_id_card,
|
|
scope.staff_code,
|
|
scope.staff_name,
|
|
scope.dept_name,
|
|
spouse.spouse_id_card,
|
|
spouse.spouse_is_staff,
|
|
coalesce(base_staff.annual_income, 0) as self_income,
|
|
coalesce(spouse.spouse_income, 0) as spouse_income,
|
|
coalesce(base_staff.annual_income, 0) + coalesce(spouse.spouse_income, 0) as total_income,
|
|
coalesce((
|
|
select count(1)
|
|
from ccdi_asset_info asset
|
|
where asset.family_id = scope.staff_id_card
|
|
and asset.person_id = scope.staff_id_card
|
|
), 0) as self_asset_record_count,
|
|
case
|
|
when spouse.spouse_is_staff = 1 then coalesce((
|
|
select count(1)
|
|
from ccdi_asset_info asset
|
|
where asset.family_id = spouse.spouse_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
), 0)
|
|
else 1
|
|
end as spouse_staff_asset_record_count,
|
|
coalesce((
|
|
select sum(coalesce(asset.current_value, 0))
|
|
from ccdi_asset_info asset
|
|
where asset.family_id = scope.staff_id_card
|
|
and asset.person_id = scope.staff_id_card
|
|
), 0) as self_total_asset,
|
|
coalesce((
|
|
select sum(coalesce(asset.current_value, 0))
|
|
from ccdi_asset_info asset
|
|
where spouse.spouse_id_card is not null
|
|
and (
|
|
(
|
|
spouse.spouse_is_staff = 1
|
|
and asset.family_id = spouse.spouse_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
or (
|
|
(spouse.spouse_is_staff is null or spouse.spouse_is_staff != 1)
|
|
and asset.family_id = scope.staff_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
)
|
|
), 0) as spouse_total_asset,
|
|
coalesce((
|
|
select sum(coalesce(asset.current_value, 0))
|
|
from ccdi_asset_info asset
|
|
where (asset.family_id = scope.staff_id_card and asset.person_id = scope.staff_id_card)
|
|
or (
|
|
spouse.spouse_id_card is not null
|
|
and (
|
|
(
|
|
spouse.spouse_is_staff = 1
|
|
and asset.family_id = spouse.spouse_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
or (
|
|
(spouse.spouse_is_staff is null or spouse.spouse_is_staff != 1)
|
|
and asset.family_id = scope.staff_id_card
|
|
and asset.person_id = spouse.spouse_id_card
|
|
)
|
|
)
|
|
)
|
|
), 0) as total_asset,
|
|
coalesce((
|
|
select count(1)
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
), 0) as self_debt_record_count,
|
|
case
|
|
when spouse.spouse_is_staff = 1 then coalesce((
|
|
select count(1)
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = spouse.spouse_id_card
|
|
), 0)
|
|
else 1
|
|
end as spouse_staff_debt_record_count,
|
|
coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
), 0) as self_total_debt,
|
|
coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where spouse.spouse_id_card is not null
|
|
and debt.person_id = spouse.spouse_id_card
|
|
), 0) as spouse_total_debt,
|
|
coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
or (spouse.spouse_id_card is not null and debt.person_id = spouse.spouse_id_card)
|
|
), 0) as total_debt,
|
|
coalesce(base_staff.annual_income, 0)
|
|
+ coalesce(spouse.spouse_income, 0)
|
|
+ coalesce((
|
|
select sum(coalesce(debt.principal_balance, 0))
|
|
from ccdi_debts_info debt
|
|
where debt.person_id = scope.staff_id_card
|
|
or (spouse.spouse_id_card is not null and debt.person_id = spouse.spouse_id_card)
|
|
), 0) as comparison_amount
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
left join ccdi_base_staff base_staff
|
|
on base_staff.id_card = scope.staff_id_card
|
|
left join (
|
|
<include refid="spouseRelationSql"/>
|
|
) spouse
|
|
on spouse.person_id = scope.staff_id_card
|
|
where scope.staff_id_card = #{staffIdCard}
|
|
) source
|
|
) aggregated
|
|
</select>
|
|
|
|
<select id="selectFamilyAssetItemsByScope" resultMap="FamilyAssetItemResultMap">
|
|
select
|
|
asset.asset_name,
|
|
asset.asset_main_type,
|
|
asset.asset_sub_type,
|
|
case
|
|
when asset.person_id = #{staffIdCard} then base_staff.name
|
|
else coalesce(holder_staff.name, (
|
|
select max(relation.relation_name)
|
|
from ccdi_staff_fmy_relation relation
|
|
where relation.person_id = #{staffIdCard}
|
|
and relation.relation_cert_no = asset.person_id
|
|
and relation.status = 1
|
|
and relation.is_emp_family = 1
|
|
and relation.relation_type = '配偶'
|
|
))
|
|
end as holder_name,
|
|
asset.person_id as holder_id_card,
|
|
asset.current_value,
|
|
asset.valuation_date
|
|
from ccdi_asset_info asset
|
|
left join ccdi_base_staff base_staff
|
|
on base_staff.id_card = #{staffIdCard}
|
|
left join ccdi_base_staff holder_staff
|
|
on holder_staff.id_card = asset.person_id
|
|
where (asset.family_id = #{staffIdCard} and asset.person_id = #{staffIdCard})
|
|
or (
|
|
#{spouseIdCard} is not null
|
|
and (
|
|
(
|
|
#{spouseIsStaff} = 1
|
|
and asset.family_id = #{spouseIdCard}
|
|
and asset.person_id = #{spouseIdCard}
|
|
)
|
|
or (
|
|
(#{spouseIsStaff} is null or #{spouseIsStaff} != 1)
|
|
and asset.family_id = #{staffIdCard}
|
|
and asset.person_id = #{spouseIdCard}
|
|
)
|
|
)
|
|
)
|
|
order by
|
|
case when asset.person_id = #{staffIdCard} then 1 else 2 end,
|
|
asset.valuation_date desc,
|
|
asset.asset_name asc
|
|
</select>
|
|
|
|
<select id="selectFamilyDebtItemsByScope" resultMap="FamilyDebtItemResultMap">
|
|
select
|
|
debt.debt_name,
|
|
debt.debt_main_type,
|
|
debt.debt_sub_type,
|
|
debt.creditor_type,
|
|
case
|
|
when debt.person_id = #{staffIdCard} then base_staff.name
|
|
else coalesce(owner_staff.name, (
|
|
select max(relation.relation_name)
|
|
from ccdi_staff_fmy_relation relation
|
|
where relation.person_id = #{staffIdCard}
|
|
and relation.relation_cert_no = debt.person_id
|
|
and relation.status = 1
|
|
and relation.is_emp_family = 1
|
|
and relation.relation_type = '配偶'
|
|
))
|
|
end as owner_name,
|
|
debt.person_id as owner_id_card,
|
|
debt.principal_balance,
|
|
debt.query_date
|
|
from ccdi_debts_info debt
|
|
left join ccdi_base_staff base_staff
|
|
on base_staff.id_card = #{staffIdCard}
|
|
left join ccdi_base_staff owner_staff
|
|
on owner_staff.id_card = debt.person_id
|
|
where debt.person_id = #{staffIdCard}
|
|
or (#{spouseIdCard} is not null and debt.person_id = #{spouseIdCard})
|
|
order by
|
|
case when debt.person_id = #{staffIdCard} then 1 else 2 end,
|
|
debt.query_date desc,
|
|
debt.debt_name asc
|
|
</select>
|
|
|
|
<select id="selectExtendedPurchasePage" resultMap="ExtendedPurchaseListItemResultMap">
|
|
<bind name="projectId" value="query.projectId"/>
|
|
select
|
|
p.purchase_id,
|
|
p.project_name,
|
|
p.subject_name,
|
|
p.applicant_name,
|
|
p.apply_date
|
|
from ccdi_purchase_transaction p
|
|
inner join (
|
|
select distinct scope.staff_name
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
) scoped_staff
|
|
on scoped_staff.staff_name = p.applicant_name
|
|
<where>
|
|
<if test="query.applicantName != null and query.applicantName != ''">
|
|
and p.applicant_name like concat('%', #{query.applicantName}, '%')
|
|
</if>
|
|
<if test="query.applyDateStart != null and query.applyDateStart != ''">
|
|
and p.apply_date >= #{query.applyDateStart}
|
|
</if>
|
|
<if test="query.applyDateEnd != null and query.applyDateEnd != ''">
|
|
and p.apply_date <= #{query.applyDateEnd}
|
|
</if>
|
|
</where>
|
|
order by p.apply_date desc, p.create_time desc, p.purchase_id desc
|
|
</select>
|
|
|
|
<select id="selectExtendedPurchaseDetail"
|
|
resultType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedPurchaseDetailVO">
|
|
select
|
|
p.purchase_id,
|
|
p.purchase_category,
|
|
p.project_name,
|
|
p.subject_name,
|
|
p.subject_desc,
|
|
p.purchase_qty,
|
|
p.budget_amount,
|
|
p.bid_amount,
|
|
p.actual_amount,
|
|
p.contract_amount,
|
|
p.settlement_amount,
|
|
p.purchase_method,
|
|
p.supplier_name,
|
|
p.contact_person,
|
|
p.contact_phone,
|
|
p.supplier_uscc,
|
|
p.supplier_bank_account,
|
|
p.apply_date,
|
|
p.plan_approve_date,
|
|
p.announce_date,
|
|
p.bid_open_date,
|
|
p.contract_sign_date,
|
|
p.expected_delivery_date,
|
|
p.actual_delivery_date,
|
|
p.acceptance_date,
|
|
p.settlement_date,
|
|
p.applicant_id,
|
|
p.applicant_name,
|
|
p.apply_department,
|
|
p.purchase_leader_id,
|
|
p.purchase_leader_name,
|
|
p.purchase_department,
|
|
p.created_by,
|
|
p.create_time,
|
|
p.updated_by,
|
|
p.update_time
|
|
from ccdi_purchase_transaction p
|
|
inner join (
|
|
select distinct scope.staff_name
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
) scoped_staff
|
|
on scoped_staff.staff_name = p.applicant_name
|
|
where p.purchase_id = #{purchaseId}
|
|
</select>
|
|
|
|
<select id="selectExtendedPurchaseSuppliers"
|
|
resultType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedPurchaseSupplierVO">
|
|
select
|
|
s.id,
|
|
s.purchase_id,
|
|
s.supplier_name,
|
|
s.supplier_uscc,
|
|
s.contact_person,
|
|
s.contact_phone,
|
|
s.supplier_bank_account,
|
|
s.is_bid_winner,
|
|
s.sort_order
|
|
from ccdi_purchase_transaction_supplier s
|
|
inner join ccdi_purchase_transaction p on p.purchase_id = s.purchase_id
|
|
inner join (
|
|
select distinct scope.staff_name
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
) scoped_staff
|
|
on scoped_staff.staff_name = p.applicant_name
|
|
where s.purchase_id = #{purchaseId}
|
|
order by s.sort_order asc, s.id asc
|
|
</select>
|
|
|
|
<select id="selectExtendedRecruitmentPage" resultMap="ExtendedRecruitmentListItemResultMap">
|
|
<bind name="projectId" value="query.projectId"/>
|
|
select distinct r.recruit_id,
|
|
r.recruit_name,
|
|
r.pos_name,
|
|
concat_ws(' / ',
|
|
nullif(trim(r.interviewer_name1), ''),
|
|
nullif(trim(r.interviewer_name2), '')
|
|
) as interviewer_name_summary,
|
|
r.admit_status
|
|
from ccdi_staff_recruitment r
|
|
where exists (
|
|
select 1
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
and (
|
|
scope.staff_name = r.interviewer_name1
|
|
or scope.staff_name = r.interviewer_name2
|
|
)
|
|
)
|
|
<if test="query.interviewerName != null and query.interviewerName != ''">
|
|
and (
|
|
r.interviewer_name1 like concat('%', #{query.interviewerName}, '%')
|
|
or r.interviewer_name2 like concat('%', #{query.interviewerName}, '%')
|
|
)
|
|
</if>
|
|
order by r.create_time desc, r.recruit_id desc
|
|
</select>
|
|
|
|
<select id="selectExtendedRecruitmentDetail"
|
|
resultType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedRecruitmentDetailVO">
|
|
select
|
|
r.recruit_id,
|
|
r.recruit_name,
|
|
r.pos_name,
|
|
r.pos_category,
|
|
r.pos_desc,
|
|
r.cand_name,
|
|
r.cand_edu,
|
|
r.cand_id,
|
|
r.cand_school,
|
|
r.cand_major,
|
|
r.cand_grad,
|
|
r.admit_status,
|
|
r.interviewer_name1,
|
|
r.interviewer_id1,
|
|
r.interviewer_name2,
|
|
r.interviewer_id2,
|
|
r.created_by,
|
|
r.create_time,
|
|
r.updated_by,
|
|
r.update_time
|
|
from ccdi_staff_recruitment r
|
|
where r.recruit_id = #{recruitId}
|
|
and exists (
|
|
select 1
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
and (
|
|
scope.staff_name = r.interviewer_name1
|
|
or scope.staff_name = r.interviewer_name2
|
|
)
|
|
)
|
|
</select>
|
|
|
|
<select id="selectExtendedTransferPage" resultMap="ExtendedTransferListItemResultMap">
|
|
<bind name="projectId" value="query.projectId"/>
|
|
select
|
|
t.id,
|
|
s.name as staff_name,
|
|
t.transfer_type,
|
|
t.dept_name_before,
|
|
t.dept_name_after,
|
|
t.transfer_date
|
|
from ccdi_staff_transfer t
|
|
inner join ccdi_base_staff s
|
|
on t.staff_id = s.staff_id
|
|
inner join (
|
|
select distinct scope.staff_name
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name is not null
|
|
and scope.staff_name != ''
|
|
) scope
|
|
on scope.staff_name = s.name
|
|
<where>
|
|
<if test="query.staffName != null and query.staffName != ''">
|
|
and s.name like concat('%', #{query.staffName}, '%')
|
|
</if>
|
|
<if test="query.transferDateStart != null and query.transferDateStart != ''">
|
|
and t.transfer_date >= #{query.transferDateStart}
|
|
</if>
|
|
<if test="query.transferDateEnd != null and query.transferDateEnd != ''">
|
|
and t.transfer_date <= #{query.transferDateEnd}
|
|
</if>
|
|
</where>
|
|
order by t.transfer_date desc, t.create_time desc, t.id desc
|
|
</select>
|
|
|
|
<select id="selectExtendedTransferDetail"
|
|
resultType="com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedTransferDetailVO">
|
|
select
|
|
t.id,
|
|
t.staff_id,
|
|
s.name as staff_name,
|
|
t.transfer_type,
|
|
t.transfer_sub_type,
|
|
t.dept_id_before,
|
|
t.dept_name_before,
|
|
t.grade_before,
|
|
t.position_before,
|
|
t.salary_level_before,
|
|
t.dept_id_after,
|
|
t.dept_name_after,
|
|
t.grade_after,
|
|
t.position_after,
|
|
t.salary_level_after,
|
|
t.transfer_date,
|
|
t.created_by,
|
|
t.create_time,
|
|
t.updated_by,
|
|
t.update_time
|
|
from ccdi_staff_transfer t
|
|
inner join ccdi_base_staff s
|
|
on t.staff_id = s.staff_id
|
|
where t.id = #{id}
|
|
and exists (
|
|
select 1
|
|
from (
|
|
<include refid="projectEmployeeScopeSql"/>
|
|
) scope
|
|
where scope.staff_name = s.name
|
|
)
|
|
</select>
|
|
|
|
<select id="selectIncreaseLendingPage" resultMap="IncreaseLendingListItemResultMap">
|
|
select
|
|
trim(loan.customer_manager_id) as staff_id,
|
|
coalesce(staff.name, loan.customer_manager_name) as staff_name,
|
|
staff.id_card as staff_id_card,
|
|
dept.dept_name,
|
|
loan.nfaacono as contract_no,
|
|
loan.nfaabrno as lending_org_no,
|
|
loan.borrower_name,
|
|
loan.borrower_cert_no,
|
|
loan.loan_product,
|
|
loan.contract_amount,
|
|
loan.loan_balance,
|
|
date_format(loan.loan_start_date, '%Y-%m-%d') as loan_start_date,
|
|
date_format(loan.loan_end_date, '%Y-%m-%d') as loan_end_date,
|
|
loan.status,
|
|
loan.five_classification,
|
|
loan.customer_manager_id,
|
|
loan.customer_manager_name,
|
|
loan.approver
|
|
from ccdi_increase_lending loan
|
|
left join ccdi_base_staff staff
|
|
on trim(loan.customer_manager_id) = cast(staff.staff_id as char)
|
|
left join sys_dept dept
|
|
on dept.dept_id = staff.dept_id
|
|
<where>
|
|
<if test="query.staffId != null and query.staffId != ''">
|
|
and trim(loan.customer_manager_id) = #{query.staffId}
|
|
</if>
|
|
<if test="query.staffIdCard != null and query.staffIdCard != ''">
|
|
and staff.id_card = #{query.staffIdCard}
|
|
</if>
|
|
<if test="query.approver != null and query.approver != ''">
|
|
and trim(loan.approver) = #{query.approver}
|
|
</if>
|
|
<if test="query.loanStartDate != null and query.loanStartDate != ''">
|
|
and loan.loan_start_date >= #{query.loanStartDate}
|
|
</if>
|
|
<if test="query.loanEndDate != null and query.loanEndDate != ''">
|
|
and loan.loan_start_date <= #{query.loanEndDate}
|
|
</if>
|
|
</where>
|
|
order by loan.loan_start_date desc, loan.nfaacono desc
|
|
</select>
|
|
|
|
<select id="selectIncreaseLendingExportList"
|
|
resultType="com.ruoyi.ccdi.project.domain.excel.CcdiProjectIncreaseLendingExcel">
|
|
select
|
|
trim(loan.customer_manager_id) as staff_id,
|
|
coalesce(staff.name, loan.customer_manager_name) as staff_name,
|
|
staff.id_card as staff_id_card,
|
|
dept.dept_name,
|
|
loan.nfaacono as contract_no,
|
|
loan.nfaabrno as lending_org_no,
|
|
loan.borrower_name,
|
|
loan.borrower_cert_no,
|
|
loan.loan_product,
|
|
loan.contract_amount,
|
|
loan.loan_balance,
|
|
date_format(loan.loan_start_date, '%Y-%m-%d') as loan_start_date,
|
|
date_format(loan.loan_end_date, '%Y-%m-%d') as loan_end_date,
|
|
loan.status,
|
|
loan.five_classification,
|
|
loan.customer_manager_id,
|
|
loan.customer_manager_name,
|
|
loan.approver
|
|
from ccdi_increase_lending loan
|
|
left join ccdi_base_staff staff
|
|
on trim(loan.customer_manager_id) = cast(staff.staff_id as char)
|
|
left join sys_dept dept
|
|
on dept.dept_id = staff.dept_id
|
|
<where>
|
|
<if test="query.staffId != null and query.staffId != ''">
|
|
and trim(loan.customer_manager_id) = #{query.staffId}
|
|
</if>
|
|
<if test="query.staffIdCard != null and query.staffIdCard != ''">
|
|
and staff.id_card = #{query.staffIdCard}
|
|
</if>
|
|
<if test="query.approver != null and query.approver != ''">
|
|
and trim(loan.approver) = #{query.approver}
|
|
</if>
|
|
<if test="query.loanStartDate != null and query.loanStartDate != ''">
|
|
and loan.loan_start_date >= #{query.loanStartDate}
|
|
</if>
|
|
<if test="query.loanEndDate != null and query.loanEndDate != ''">
|
|
and loan.loan_start_date <= #{query.loanEndDate}
|
|
</if>
|
|
</where>
|
|
order by loan.loan_start_date desc, loan.nfaacono desc
|
|
</select>
|
|
|
|
</mapper>
|