فهرست منبع

1.控制台借口优化

wuhp 2 سال پیش
والد
کامیت
a5cd1cd3ec

+ 4 - 0
src/main/java/com/ydtech/modules/admin/service/impl/CompanyDataReportServiceImpl.java

@@ -58,7 +58,11 @@ public class CompanyDataReportServiceImpl implements CompanyDataReportService {
         HashMap<String, String> dateMapByType = getDateMapByType(companyQutationCountDataQueryDto.getDateType(), companyQutationCountDataQueryDto.getBeginDate(), companyQutationCountDataQueryDto.getEndDate());
         companyQutationCountDataQueryDto.setBeginDate(dateMapByType.get("startDate"));
         companyQutationCountDataQueryDto.setEndDate(dateMapByType.get("endDate"));
+        page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+
         Page<CompanyQutationCountDataDto> resultSubOrder = insAreaCompanyMapper.queryCompanyQutationCountDataPage(companyQutationCountDataQueryDto, page);
+        Long total = this.insAreaCompanyMapper.queryCompanyQutationCountDataPageTotal(companyQutationCountDataQueryDto);
+        resultSubOrder.setTotal(total);
         return new BasePageResult<>(companyQutationCountDataQueryDto.getPageNum(), page.getSize(), resultSubOrder.getTotal(), page.getPages(),
                 resultSubOrder.getRecords());
     }

+ 4 - 0
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java

@@ -86,7 +86,11 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
         pageVo.setPageNum(taskStatisticsVo.getPageNum());
         pageVo.setPageSize(taskStatisticsVo.getPageSize());
+        page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+
         IPage<TaskStatisticsDto> list = this.insAreaCompanyMapper.agentStatisticsQueryPage(page,taskStatisticsVo);
+        Long total = this.insAreaCompanyMapper.agentStatisticsQueryPageTotal(taskStatisticsVo);
+        list.setTotal(total);
         return list;
     }
     /**

+ 11 - 0
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java

@@ -270,6 +270,17 @@ public interface InsAreaCompanyMapper extends BaseMapper<InsAreaCompany> {
     TaskStatisticsDto numberQuotationsByUserIds(@Param("ids") List<String>  ids,@Param("month") String month);
 
     OrdersDataDto querResultOrderNumber(@Param("vo") OrdersDataVo ordersDataVo);
+
+    /**
+     *   代理人统计查询
+     * @param taskStatisticsVo
+     * @return
+     */
+    Long agentStatisticsQueryPageTotal(@Param("taskStatisticsVo") TaskStatisticsVo taskStatisticsVo);
+
+    Long queryCompanyQutationCountDataPageTotal(@Param("vo") CompanyQutationCountDataQueryDto companyQutationCountDataQueryDto);
+
+
 }
 
 

+ 124 - 34
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -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)