|
|
@@ -860,6 +860,8 @@
|
|
|
ins_area_company iac
|
|
|
LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
|
|
|
LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
|
|
|
+ LEFT JOIN ins_orders io on iac.orderno = io.orderno
|
|
|
+ LEFT JOIN sys_dept sd on sd.id = io.deptid
|
|
|
WHERE
|
|
|
agree.id IS NOT NULL
|
|
|
<if test="vo.companyId != null and vo.companyId!='' ">
|
|
|
@@ -871,6 +873,9 @@
|
|
|
<if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
|
|
|
AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
|
|
|
</if>
|
|
|
+ <if test="vo.managementSource != null and vo.managementSource!=''">
|
|
|
+ AND sd.management_source =#{vo.managementSource}
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
agree.insurance_company_id,
|
|
|
agree.insurance_company,
|
|
|
@@ -1186,7 +1191,7 @@
|
|
|
agree.insurance_company_id AS companyId,
|
|
|
agree.insurance_company AS companyName,
|
|
|
agree.partner_companies_id AS parterCompanyId,
|
|
|
- ins.NAME AS parterCompanyName,
|
|
|
+ ins.namesimple AS parterCompanyName,
|
|
|
count(iac.orderstatus) AS orderNumber,
|
|
|
'-' as bigQutationCount,
|
|
|
'-' as bigUnderwritingCount,
|
|
|
@@ -1233,4 +1238,129 @@
|
|
|
ins.NAME
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
|
|
|
+
|
|
|
+ select
|
|
|
+ a.companyId as "companyId",
|
|
|
+ a.insuranceCompanyName as "insuranceCompanyName",
|
|
|
+ a.parterCompanyId as "parterCompanyId",
|
|
|
+ a.partnerCompaniesName as "partnerCompaniesName",
|
|
|
+ a.totalPremium as "totalPremium",
|
|
|
+ a.qutationInsureCount as "qutationInsureCount",
|
|
|
+ a.averagePremium as "averagePremium",
|
|
|
+ a.userNumber as "userNumber",
|
|
|
+ a.perCapitaAmount as "perCapitaAmount",
|
|
|
+ b.logo as "logo"
|
|
|
+ from (
|
|
|
+ SELECT
|
|
|
+ agree.insurance_company_id AS "companyId",
|
|
|
+ agree.insurance_company AS "insuranceCompanyName",
|
|
|
+ agree.partner_companies_id AS "parterCompanyId",
|
|
|
+ ins.namesimple AS "partnerCompaniesName",
|
|
|
+ sum(iac.sumpremium) as "totalPremium",
|
|
|
+ COUNT(0 ) AS "qutationInsureCount",
|
|
|
+ sum(iac.sumpremium) / COUNT(0 ) AS "averagePremium",
|
|
|
+ COUNT(DISTINCT io.userId) AS "userNumber",
|
|
|
+ sum(iac.sumpremium) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
|
|
|
+ LEFT JOIN ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
|
|
|
+ WHERE
|
|
|
+ agree.id IS NOT NULL
|
|
|
+ and iac.orderstatus = '3'
|
|
|
+ <if test="vo.companyId != null and vo.companyId!='' ">
|
|
|
+ and agree.insurance_company_id = #{vo.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
|
|
|
+ and agree.partner_companies_id = #{vo.parterCompanyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
|
|
|
+ AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.provinceId != null and vo.provinceId != ''">
|
|
|
+ and io.deptid like "${vo.provinceId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.cityId != null and vo.cityId != ''">
|
|
|
+ and io.deptid like "${vo.cityId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.countyId != null and vo.countyId != ''">
|
|
|
+ and io.deptid like "${vo.countyId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.houseId != null and vo.houseId != ''">
|
|
|
+ and io.deptid like "${vo.houseId}%"
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ agree.insurance_company_id,
|
|
|
+ agree.insurance_company,
|
|
|
+ agree.partner_companies_id
|
|
|
+ <choose>
|
|
|
+ <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
|
|
|
+ order by
|
|
|
+ sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
|
|
|
+ </when>
|
|
|
+ <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
|
|
|
+ order by
|
|
|
+ COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
|
|
|
+ </when>
|
|
|
+ <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
|
|
|
+ order by
|
|
|
+ COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ ) a
|
|
|
+ left join esm_ins_company b on b.id =a.companyId
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
|
|
|
+ SELECT
|
|
|
+ agree.insurance_company_id AS "companyId",
|
|
|
+ agree.insurance_company AS "insuranceCompanyName",
|
|
|
+ agree.partner_companies_id AS "parterCompanyId",
|
|
|
+ ins.namesimple AS "partnerCompaniesName",
|
|
|
+ sum(sumpremium) as "totalPremium",
|
|
|
+ COUNT(0) AS "qutationInsureCount",
|
|
|
+ sum(sumpremium) / COUNT(0) AS "averagePremium",
|
|
|
+ COUNT(DISTINCT io.userId) AS "userNumber",
|
|
|
+ sum(sumpremium) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
|
|
|
+ LEFT JOIN ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
|
|
|
+ WHERE
|
|
|
+ agree.id IS NOT NULL
|
|
|
+ <if test="vo.companyId != null and vo.companyId!='' ">
|
|
|
+ and agree.insurance_company_id = #{vo.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
|
|
|
+ and agree.partner_companies_id = #{vo.parterCompanyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
|
|
|
+ AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.provinceId != null and vo.provinceId != ''">
|
|
|
+ and io.deptid like "${vo.provinceId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.cityId != null and vo.cityId != ''">
|
|
|
+ and io.deptid like "${vo.cityId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.countyId != null and vo.countyId != ''">
|
|
|
+ and io.deptid like "${vo.countyId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.houseId != null and vo.houseId != ''">
|
|
|
+ and io.deptid like "${vo.houseId}%"
|
|
|
+ </if>
|
|
|
+ <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
|
|
|
+ and iac.orderstatus =#{vo.quotationStatus}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ agree.insurance_company_id,
|
|
|
+ agree.insurance_company,
|
|
|
+ agree.partner_companies_id,
|
|
|
+ ins.namesimple
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|