|
|
@@ -846,41 +846,74 @@
|
|
|
<select id="queryCompanyQutationCountDataPage"
|
|
|
resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
|
|
|
SELECT
|
|
|
- agree.insurance_company_id AS companyId,
|
|
|
- agree.insurance_company AS companyName,
|
|
|
- agree.partner_companies_id AS parterCompanyId,
|
|
|
- ins.NAME AS parterCompanyName,
|
|
|
- count(iac.orderstatus) 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 = 2 THEN 1 END )/ count(iac.orderstatus) AS passRate,
|
|
|
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
|
|
|
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS contributionRate
|
|
|
+ a.* , (select ins.namesimple from esm_ins_company ins where a.parterCompanyId = ins.id) as "parterCompanyName"
|
|
|
FROM
|
|
|
- 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
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ agree.insurance_company AS companyName,
|
|
|
+ agree.partner_companies_id AS parterCompanyId,
|
|
|
+ count( iac.orderstatus ) 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 = 2 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.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!='' ">
|
|
|
- agree.insurance_company_id = #{vo.companyId}
|
|
|
- </if>
|
|
|
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
|
|
|
- agree.partner_companies_id = #{vo.parterCompanyId}
|
|
|
- </if>
|
|
|
- <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>
|
|
|
+ agree.id IS NOT NULL
|
|
|
+ <if test="vo.companyId != null and vo.companyId!='' ">
|
|
|
+ agree.insurance_company_id = #{vo.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
|
|
|
+ agree.partner_companies_id = #{vo.parterCompanyId}
|
|
|
+ </if>
|
|
|
+ <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,
|
|
|
- agree.partner_companies_id,
|
|
|
- ins.NAME
|
|
|
+ agree.insurance_company,
|
|
|
+ agree.partner_companies_id
|
|
|
+ ) a
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryCompanyQutationCountDataPageTotal"
|
|
|
+ resultType="java.lang.Long">
|
|
|
+ SELECT
|
|
|
+ count(0)
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ agree.partner_companies_id
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.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!='' ">
|
|
|
+ agree.insurance_company_id = #{vo.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
|
|
|
+ agree.partner_companies_id = #{vo.parterCompanyId}
|
|
|
+ </if>
|
|
|
+ <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.partner_companies_id
|
|
|
+ ) a
|
|
|
</select>
|
|
|
|
|
|
<select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
|
|
|
@@ -1199,6 +1232,63 @@
|
|
|
GROUP BY io.userid , su.name, sd.id , sd.name
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+ <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
|
|
|
+ select count(0) from (
|
|
|
+ SELECT
|
|
|
+ io.userid as "userId"
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
+ left join sys_dept sd on sd.id=io.deptid
|
|
|
+ <where>
|
|
|
+ sd.management_source = '2'
|
|
|
+ <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.provinceId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.cityId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.countyId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.houseId}%"
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
|
+ AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
|
+ AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test="taskStatisticsVo.days =='1'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='7'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='30'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY io.userid
|
|
|
+ ) a
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
<select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
|
|
|
SELECT
|
|
|
iac.company_id,
|
|
|
@@ -1219,7 +1309,7 @@
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
|
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
|
|
|
+ AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
@@ -1461,7 +1551,7 @@
|
|
|
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.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeStart}
|
|
|
+ AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
|
|
|
</if>
|
|
|
<if test="vo.days !=null and vo.days !='' ">
|
|
|
and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
|