You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
331 lines
13 KiB
331 lines
13 KiB
<?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.ccic.safeliab.dao.ServiceStatMapper"> |
|
|
|
<!-- 通用查询映射结果 --> |
|
<resultMap id="customerMap" type="com.ccic.safeliab.entity.Customer"> |
|
<id column="customer_id" property="customerId"/> |
|
<result column="customer_no" property="customerNo"/> |
|
<result column="customer_name" property="customerName"/> |
|
<result column="type_pname" property="typePname"/> |
|
<result column="contacts" property="contacts"/> |
|
<result column="contacts_phone" property="contactsPhone"/> |
|
</resultMap> |
|
<resultMap id="statResultMap" type="com.ccic.safeliab.vo.ServiceStatVO"> |
|
<id column="policy_id" property="policyId"/> |
|
<result column="policy_number" property="policyNumber"/> |
|
<result column="insurance_name" property="insuranceName"/> |
|
<result column="other_information" property="remarks"/> |
|
<result column="service_status_name" property="serviceStatusName"/> |
|
</resultMap> |
|
|
|
<resultMap id="exportResultMap" type="com.ccic.safeliab.excel.ServiceStatExcel"> |
|
<result column="policy_number" property="policyNumber"/> |
|
<result column="insurance_name" property="insuranceName"/> |
|
<result column="other_information" property="remarks"/> |
|
<result column="service_status_name" property="serviceStatusName"/> |
|
</resultMap> |
|
|
|
<resultMap id="PolicyServiceResultMap" type="com.ccic.safeliab.vo.ServiceStatisticsVO"> |
|
<result property="policy_number" column="policyNumber"/> |
|
</resultMap> |
|
|
|
<sql id="selectPageColumn"> |
|
SELECT |
|
p.policy_id, |
|
p.policy_number, |
|
p.insurance_name, |
|
p.other_information, |
|
CASE |
|
WHEN p.policy_id IS NOT NULL AND t.service_id IS NULL AND s.service_apply_id IS NULL THEN '保单未分配(在中支节点)' |
|
WHEN t.dispatch_status = 2 THEN '已推送服务机构(待服务机构领取任务)' |
|
WHEN t.status = 1 THEN '任务已分配至XX服务专家(待开展)' |
|
WHEN t.status = 2 THEN '服务专家已签到(事故预防服务中)' |
|
WHEN t.status = 10 THEN '服务报告已上传' |
|
ELSE '-1' |
|
END AS service_status_name |
|
</sql> |
|
|
|
<sql id="selectExportColumn"> |
|
SELECT |
|
p.policy_number, |
|
p.insurance_name, |
|
p.other_information, |
|
CASE |
|
WHEN p.policy_id IS NOT NULL AND t.service_id IS NULL AND s.service_apply_id IS NULL THEN '保单未分配(在中支节点)' |
|
WHEN t.dispatch_status = 2 THEN '已推送服务机构(待服务机构领取任务)' |
|
WHEN t.status = 1 THEN '任务已分配至XX服务专家(待开展)' |
|
WHEN t.status = 2 THEN '服务专家已签到(事故预防服务中)' |
|
WHEN t.status = 10 THEN '服务报告已上传' |
|
ELSE '-1' |
|
END AS service_status_name |
|
</sql> |
|
|
|
<sql id="baseQuery"> |
|
FROM |
|
tbl_policy p |
|
LEFT JOIN tbl_service_apply s ON p.policy_id = s.policy_id |
|
LEFT JOIN tbl_service t ON s.service_apply_id = t.service_apply_id |
|
<where> |
|
((p.policy_id IS NOT NULL |
|
AND t.service_id IS NULL |
|
AND s.service_apply_id IS NULL) |
|
OR t.dispatch_status = 2 |
|
OR t.status IN (1, 2, 10)) |
|
<if test="policy.serviceStatus != null and policy.serviceStatus != ''"> |
|
<if test="policy.serviceStatus == 1"> |
|
AND (p.policy_id IS NOT NULL |
|
AND t.service_id IS NULL |
|
AND s.service_apply_id IS NULL) |
|
</if> |
|
<if test="policy.serviceStatus == 2"> |
|
AND t.dispatch_status = 2 |
|
</if> |
|
<if test="policy.serviceStatus == 3"> |
|
AND t.status = 1 |
|
</if> |
|
<if test="policy.serviceStatus == 4"> |
|
AND t.status = 2 |
|
</if> |
|
<if test="policy.serviceStatus == 5"> |
|
AND t.status = 10 |
|
</if> |
|
</if> |
|
<if test="policy.dateFilter != null and policy.dateFilter != ''"> |
|
<if test="policy.dateFilter == 'lastWeek'"> |
|
AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '7 days' AND p.done_date <= CURRENT_TIMESTAMP |
|
</if> |
|
<if test="policy.dateFilter == 'lastMonth'"> |
|
AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '1 month' AND p.done_date <= CURRENT_TIMESTAMP |
|
</if> |
|
<if test="policy.dateFilter == 'last3Months'"> |
|
AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '3 months' AND p.done_date <= CURRENT_TIMESTAMP |
|
</if> |
|
</if> |
|
<if test="policy.startDate != null and policy.startDate != ''"> |
|
AND p.start_date >= #{policy.startDate} || ' 00:00:00' |
|
</if> |
|
<if test="policy.doneDate != null and policy.doneDate != ''"> |
|
AND p.done_date <= #{policy.doneDate} || ' 23:59:59' |
|
</if> |
|
</where> |
|
</sql> |
|
|
|
<select id="selectServiceCustomerPage" resultMap="customerMap"> |
|
SELECT DISTINCT |
|
a.customer_id, |
|
a.customer_no, |
|
a.customer_name, |
|
a.type_pname, |
|
a.contacts, |
|
a.contacts_phone, |
|
a.changed_at |
|
FROM |
|
tbl_customer a |
|
LEFT JOIN tbl_service b ON b.customer_id = a.customer_id |
|
WHERE |
|
1 = 1 |
|
<if test="customer.typePid != null and customer.typePid != ''"> |
|
AND a.type_pid = #{customer.typePid} |
|
</if> |
|
<if test="customer.keyword != null and customer.keyword != ''"> |
|
AND (a.customer_name LIKE '%'||#{customer.keyword}||'%' OR a.customer_no LIKE '%'||#{customer.keyword}||'%') |
|
</if> |
|
<if test="customer.insuranceId != null and customer.insuranceId != ''"> |
|
AND b.insurance_id = #{customer.insuranceId} |
|
</if> |
|
AND A.customer_no is not null |
|
order by a.changed_at desc, a.customer_id desc |
|
</select> |
|
|
|
<select id="selectPage" resultMap="statResultMap"> |
|
<include refid="selectPageColumn" /> |
|
<include refid="baseQuery" /> |
|
</select> |
|
|
|
<select id="selectExport" resultMap="exportResultMap"> |
|
<include refid="selectExportColumn" /> |
|
<include refid="baseQuery" /> |
|
</select> |
|
|
|
<select id="getOrganByParam" resultType="com.ccic.safeliab.entity.Organ"> |
|
select organ_id,organ_name,parent_id,feature,is_sup from tbl_organ |
|
where status=1 and organ_type=3 |
|
<if test="map.organId!=null and map.organId!=''"> |
|
and parent_id = #{map.organId} |
|
</if> |
|
<if test="map.organName!=null and map.organName!=''"> |
|
and organ_name like concat('%',#{map.organName},'%') |
|
</if> |
|
<if test="map.oneOrganId!=null and map.oneOrganId!=''"> |
|
and organ_id = #{map.oneOrganId} |
|
</if> |
|
order by changed_at desc limit 20 |
|
</select> |
|
|
|
<select id="getCustomerStatistics" resultType="com.ccic.safeliab.vo.EnterpriseArchivesVO"> |
|
SELECT |
|
a.customer_no customerNo, |
|
a.type_name typeName, |
|
b.social_credit_code socialCreditCode, |
|
b.legal_person legalPerson, |
|
a.contacts contacts, |
|
a.email, |
|
a.contacts_phone contactsPhone, |
|
a.type_pname typePname, |
|
a.business_scope businessScope, |
|
a.org_registration_address orgRegistrationAddress |
|
FROM |
|
tbl_customer a |
|
LEFT JOIN tbl_customer_addon b on a.customer_id = b.customer_id |
|
where a.customer_id = #{customerId} |
|
</select> |
|
|
|
<select id="getPolicyStatistics" resultType="com.ccic.safeliab.vo.PolicyStatisticsVO"> |
|
SELECT |
|
policy_number policyNumber, |
|
insur_customer_name insurCustomerName, |
|
customer_name customerName, |
|
due_premium duePremium, |
|
start_date startDate, |
|
done_date doneDate, |
|
policy_status_name policyStatusName, |
|
premium_rate premiumRate, |
|
sum_insured sumInsured |
|
from tbl_policy |
|
where customer_id = #{customerId} |
|
</select> |
|
|
|
<select id="getHivePolicyCoverageStatistics" resultType="com.ccic.safeliab.entity.HivePolicyCoverage"> |
|
SELECT |
|
clausecode, |
|
coverage_type coverageType, |
|
product_element_name productElementName, |
|
sum_insured sumInsured |
|
FROM |
|
hive_policy_coverage |
|
where policy_no = #{policyNumber} |
|
</select> |
|
|
|
<select id="getHivePolicyInnerCoInsurerStatistics" resultType="com.ccic.safeliab.entity.HivePolicyInnerCoInsurer"> |
|
SELECT |
|
inner_co_org_code innerCoOrgCode, |
|
share_rate shareRate |
|
FROM |
|
hive_policy_inner_co_insurer |
|
where policy_no = #{policyNumber} |
|
</select> |
|
|
|
<select id="getHiveClaimStatistics" resultType="com.ccic.safeliab.vo.HiveClaimStatisticsVO"> |
|
SELECT |
|
PolicyNo policyno, |
|
REPORTTIME reporttime, |
|
CLAIMTIME claimtime, |
|
TASKTYPE tasktype, |
|
CLAIMLOSS claimloss, |
|
|
|
sumLossApproval sumlossapproval, |
|
peopleLossApproval peoplelossapproval, |
|
medicSumApprv medicsumapprv, |
|
OSSAPPROVAL ossapproval, |
|
accidentSumAPRV accidentsumaprv, |
|
LOSSAPPROVAL lossapproval, |
|
lawSumApprv lawsumapprv, |
|
accidentRSSumApprv accidentrssumapprv, |
|
otherSumApprv othersumapprv, |
|
|
|
TotalAmtCharg totalamtcharg, |
|
bankPayTime bankpaytime, |
|
ENDCASEDATE endcasedate, |
|
peopleMdieSumCharg peoplemdiesumcharg, |
|
medicSumCharg medicsumcharg, |
|
'' lossinjurycharg, |
|
accidentRSSumCharg accidentrssumcharg, |
|
LOSSCharg losscharg, |
|
lawSumCharg lawsumcharg, |
|
hive_claim hiveClaim, |
|
otherSumCharg othersumcharg |
|
FROM |
|
hive_claim |
|
where customer_id = #{customerId} |
|
order by PolicyNo asc |
|
</select> |
|
|
|
<select id="selectPolicyByService" resultMap="PolicyServiceResultMap"> |
|
SELECT |
|
policy_number |
|
FROM |
|
tbl_service |
|
WHERE |
|
customer_id = #{customerId} |
|
GROUP BY |
|
policy_number |
|
</select> |
|
|
|
|
|
<select id="getAccidentPreventionStatistics" resultType="com.ccic.safeliab.vo.AccidentPreventionVO"> |
|
SELECT |
|
a.completed_at completedAt, |
|
a.service_name serviceName, |
|
b.service_object_name serviceObjectName, |
|
a.service_range serviceRange, |
|
a.executed_organ_name executedOrganName, |
|
CASE |
|
WHEN a.service_report_url IS NOT NULL THEN '已上传' |
|
ELSE '未上传' |
|
END AS uploadStatus |
|
FROM |
|
tbl_service a |
|
LEFT JOIN tbl_service_relation b on b.service_id = a.service_id |
|
where a.customer_id = #{customerId} |
|
and a.policy_number = #{policyNumber} |
|
</select> |
|
|
|
<select id="getRiskStatistics" resultType="com.ccic.safeliab.entity.Risk"> |
|
SELECT |
|
risk_number riskNumber, |
|
risk_name riskName, |
|
risk_content riskontent, |
|
discovered_address discoveredAddress, |
|
risk_grade riskGrade, |
|
status, |
|
discovered_at discoveredAt |
|
FROM |
|
tbl_risk a |
|
where a.service_id in (SELECT service_id |
|
FROM |
|
tbl_service |
|
WHERE |
|
customer_id = #{customerId} and policy_number = #{policyNumber}) |
|
and a.policy_number = #{policyNumber} |
|
</select> |
|
|
|
<select id="getHazardInvestigationStatistics" resultType="com.ccic.safeliab.vo.HazardInvestigationVO"> |
|
SELECT |
|
a.hidden_number hiddenNumber, |
|
d.description, |
|
a.classify_name hiddenDangerType, |
|
c.danger_type_name dangerTypeName, |
|
d.risk_grade riskGrade, |
|
a.discovered_at discoveredAt, |
|
CASE |
|
WHEN a.examine_status = 1 THEN '待审核' |
|
WHEN a.examine_status = 2 THEN '审核中(上级审核)' |
|
WHEN a.examine_status = 3 THEN '审核成功' |
|
WHEN a.examine_status = 4 THEN '审核失败' |
|
END AS correctionStatus |
|
FROM |
|
tbl_hidden_danger a |
|
LEFT JOIN tbl_service b on b.service_id = a.service_id |
|
LEFT JOIN tbl_service_item c on c.service_id = a.service_id |
|
LEFT JOIN tbl_danger_check_record d on d.service_item_id = c.service_item_id |
|
WHERE |
|
a.service_id in (SELECT service_id |
|
FROM |
|
tbl_service |
|
WHERE |
|
customer_id = #{customerId} and policy_number = #{policyNumber}) |
|
and a.policy_number = #{policyNumber} |
|
</select> |
|
|
|
</mapper>
|
|
|