Explorar o código

1.报价统计逻辑修改

wuhp hai 1 ano
pai
achega
56388e485d

+ 18 - 13
src/main/resources/mapper/modules/admin/TaskStatisticsMapper.xml

@@ -334,20 +334,25 @@
     <select id="channelAgentDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
         SELECT
         iac.inscompany,
-        COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
-        COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
-        (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT(
-        iac.orderstatus ) AS "contributionRate",
-        COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
-        COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
-        COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
-        COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
+
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
+        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
+        COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
+        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
+        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN  iot.order_status = '2'  THEN 1 END ))/ COUNT(
+        CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "contributionRate",
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
+        COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
+        COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
+        COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
         FROM
-        ins_area_company iac
+        (
+        select iot.suborder,iot.order_status from `ins_orders_track` iot
+        GROUP BY iot.suborder ,iot.order_status
+        ) iot
+        left join ins_area_company  iac ON iac.id = iot.suborder
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
         LEFT JOIN sys_dept sd ON sd.id = io.deptid
         <where>

+ 62 - 46
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -1066,19 +1066,23 @@
         io.userid AS "userId",
         sd.parent_id as "deptId",
         sd.management_source as "managementSource",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS "passingRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) /  COUNT( iac.orderstatus ) AS "closeRate",
-        (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )  +  COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
-        COUNT(CASE WHEN io.order_source = 0  and iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END) as "pcOrderSource",
-        COUNT(CASE WHEN io.order_source = 1  and iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END) as "appOrderSource",
-        COUNT( CASE WHEN iac.orderstatus in( 1 , 2 , 3 ,4) THEN 1 END ) AS "auditOrder"
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
+        COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
+        COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
+        COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) /  COUNT(  CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
+        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END )  +  COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/ COUNT(CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
+        COUNT( CASE WHEN iot.order_status  = '0' THEN 1 END ) / COUNT(CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END  ) AS "quotationRate",
+        COUNT(CASE WHEN io.order_source = 0  and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
+        COUNT(CASE WHEN io.order_source = 1  and iot.order_status ='0' THEN 1 END) as "appOrderSource",
+        COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
         FROM
-        ins_area_company iac
+        (
+        select iot.suborder,iot.order_status from `ins_orders_track` iot
+        GROUP BY iot.suborder ,iot.order_status
+        ) iot
+        left join ins_area_company  iac ON iac.id = iot.suborder
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
         LEFT JOIN sys_dept sd ON sd.id = io.deptid
         <where>
@@ -1172,19 +1176,24 @@
         io.userid AS "userId",
         sd.parent_id as "deptId",
         sd.management_source as "managementSource",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS "passingRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) /  COUNT( iac.orderstatus ) AS "closeRate",
-        (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )  +  COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
-        COUNT(CASE WHEN io.order_source = 0  and iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END) as "pcOrderSource",
-        COUNT(CASE WHEN io.order_source = 1  and iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END) as "appOrderSource",
-        COUNT( CASE WHEN iac.orderstatus in( 1 , 2 , 3 ,4) THEN 1 END ) AS "auditOrder"
+
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
+        COUNT( CASE WHEN iot.order_status  ='2' THEN 1 END ) AS underwritingCount,
+        COUNT( CASE WHEN iot.order_status  = '3' THEN 1 END ) AS qutationInsureCount,
+        COUNT( CASE WHEN iot.order_status =  '4' THEN 1 END ) AS underwritingReturn,
+        COUNT( CASE WHEN iot.order_status  = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "closeRate",
+        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END )  +  COUNT( CASE WHEN iot.order_status =  '2' THEN 1 END ))/ COUNT(CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
+        COUNT( CASE WHEN iot.order_status  ='0' THEN 1 END ) / COUNT(CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
+        COUNT(CASE WHEN io.order_source = 0  and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
+        COUNT(CASE WHEN io.order_source = 1  and iot.order_status = '0' THEN 1 END) as "appOrderSource",
+        COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
         FROM
-        ins_area_company iac
+        (
+        select iot.suborder,iot.order_status from `ins_orders_track` iot
+        GROUP BY iot.suborder ,iot.order_status
+        ) iot
+        left join ins_area_company  iac ON iac.id = iot.suborder
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
         LEFT JOIN sys_dept sd ON sd.id = io.deptid
         <where>
@@ -1414,7 +1423,7 @@
 
 
     <select id="insuranceCompanyQueryPage"  resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
-        SELECT
+        select
         a.*,
         ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
         FROM
@@ -1423,18 +1432,21 @@
         pa.insurance_company_id,
         pa.partner_companies_id,
         pa.insurance_company AS "insuranceCompanyName",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iac.orderstatus in( 1 , 2 , 3 ,4) THEN 1 END ) AS "auditOrder",
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
-
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS "passingRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS "closeRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
-        COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate"
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
+        COUNT( CASE WHEN iot.order_status  = '1' THEN 1 END ) AS "auditOrder",
+        COUNT( CASE WHEN iot.order_status  = '2' THEN 1 END ) AS underwritingCount,
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
+        COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
+        COUNT( CASE WHEN iot.order_status  ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
+        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) / COUNT( iot.order_status ) AS "contributionRate",
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
         FROM
-        ins_area_company iac
+        (
+        select iot.suborder,iot.order_status from `ins_orders_track` iot
+        GROUP BY iot.suborder ,iot.order_status
+        ) iot
+        LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
         LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
         LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
@@ -1552,17 +1564,21 @@
         suLeader.name as "leaderName",
         suLeader.mobile as "leaderMobile",
         sd.management_source as "managementSource",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
-        (COUNT( CASE WHEN iac.orderstatus in (2,3) THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ))  /  COUNT(iac.orderstatus)  as "passingRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )  /  COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END )  as "closeRate",
-        COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )  /  COUNT(iac.orderstatus)  as  "contributionRate",
-        COUNT( CASE WHEN iac.orderstatus in ( 0 ,1 , 2 , 3 ,4) THEN 1 END )  /  COUNT(iac.orderstatus)  as "quotationRate",
-        COUNT( CASE WHEN iac.orderstatus in( 1 , 2 , 3 ,4) THEN 1 END  )   as  "auditOrder"
+        COUNT( CASE WHEN iot.order_status  = '0' THEN 1 END ) AS qutationCount,
+        COUNT( CASE WHEN iot.order_status  = '2' THEN 1 END ) AS underwritingCount,
+        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END ) AS qutationInsureCount,
+        COUNT( CASE WHEN iot.order_status =  '4' THEN 1 END ) AS underwritingReturn,
+        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as "passingRate",
+        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END )  /  COUNT( CASE WHEN iot.order_status ='0' THEN 1 END )  as "closeRate",
+        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as  "contributionRate",
+        COUNT( CASE WHEN iot.order_status =  '0' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as "quotationRate",
+        COUNT( CASE WHEN iot.order_status =  '1' THEN 1 END  )   as  "auditOrder"
         FROM
-        ins_area_company iac
+        (
+        select iot.suborder,iot.order_status from `ins_orders_track` iot
+        GROUP BY iot.suborder ,iot.order_status
+        ) iot
+        LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
         left join ins_orders io on io.orderno = iac.orderno
         left join sys_dept sd on sd.id=io.deptid
         left join sys_user su on su.id=io.userid