Jelajahi Sumber

Merge remote-tracking branch 'origin/test' into test

wks 1 tahun lalu
induk
melakukan
71ab28e36f

+ 25 - 0
src/main/java/com/ydtech/modules/admin/controller/taskStatistics/TaskStatisticsController.java

@@ -59,6 +59,31 @@ public class TaskStatisticsController {
         }
     }
 
+    /**
+     * @description:   电销任务统计查询
+     * @author: whp
+     * @date: 2024/10/11
+     **/
+    @PostMapping("queryPageElectric")
+    @ApiOperation(value = "控制台-电销任务统计查询")
+    public HttpResult<IPage<TaskStatisticsDto>> queryPageElectric(@RequestBody TaskStatisticsVo taskStatisticsVo, HttpServletRequest httpServerRequest) {
+        try{
+            KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+            KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+            if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+                if("1".equals(kztGetDeptUtilsDto.getType())){
+                    taskStatisticsVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+                } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                    taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
+                }
+            }
+            IPage<TaskStatisticsDto> result = taskStatisticsService.queryPageElectric(taskStatisticsVo);
+            return HttpResult.ok("查询数据成功", result);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
+
     /**
      * @description:   保险公司统计查询
      * @author: whp

+ 6 - 0
src/main/java/com/ydtech/modules/admin/service/TaskStatisticsService.java

@@ -123,5 +123,11 @@ public interface TaskStatisticsService {
      * @date: 2024/9/9
      **/
     HttpResult costCenterDetailsExcel(TaskStatisticsVo taskStatisticsVo);
+    /**
+     * @description:   电销任务统计查询
+     * @author: whp
+     * @date: 2024/10/11
+     **/
+    IPage<TaskStatisticsDto> queryPageElectric(TaskStatisticsVo taskStatisticsVo);
 
 }

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

@@ -315,6 +315,49 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         String fileName = EasyExcelUtils.downExcel(uploadPath, "费用校验审核人导出", TaskStatisticsDtoExcel.class, list);
         return HttpResult.ok("", uploadUrl + "excel/" + fileName);
     }
+    /**
+     * @description:   电销任务统计查询
+     * @author: whp
+     * @date: 2024/10/11
+     **/
+    @Override
+    public IPage<TaskStatisticsDto> queryPageElectric(TaskStatisticsVo taskStatisticsVo) {
+        PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
+        Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
+        page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+        pageVo.setPageNum(taskStatisticsVo.getPageNum());
+        pageVo.setPageSize(taskStatisticsVo.getPageSize());
+        IPage<TaskStatisticsDto> list = this.insAreaCompanyMapper.queryPageElectric(page,taskStatisticsVo);
+        if (list != null && !list.getRecords().isEmpty()) {
+            List<TaskStatisticsDto> records = list.getRecords();
+            for (TaskStatisticsDto record : records) {
+                String deptId = record.getDeptId();
+                if (StringUtils.isNotEmpty(deptId)) {
+                    int length = deptId.length();
+                    if (length > 0) {
+                        if (length > 0) {
+                            if (length > 10) {
+                                String substring = deptId.substring(0, 6);
+                                String substring1 = deptId.substring(0, 8);
+                                String province = deptId.substring(0, 4);
+                                SysDept cityName = sysDeptService.getById(substring);
+                                SysDept districtName = sysDeptService.getById(substring1);
+                                SysDept provinceName = sysDeptService.getById(province);
+                                SysDept storeDeptName = sysDeptService.getById(deptId);
+                                record.setCityName(cityName.getName());
+                                record.setDistrictName(districtName.getName());
+                                record.setProvinceName(provinceName.getName());
+                                record.setStoreDeptName(storeDeptName.getName());
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        Long  total  = this.insAreaCompanyMapper.queryPageElectricTotal(taskStatisticsVo);
+        list.setTotal(total);
+        return list;
+    }
 
     /**
      * @description:   财务中心-费用校验-明细-查看

+ 28 - 19
src/main/java/com/ydtech/modules/admin/service/impl/UserReportServiceImpl.java

@@ -223,6 +223,8 @@ public class UserReportServiceImpl implements UserReportService {
                 this.channelPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
             } else if (qxFrontlineAgentVo.getManagementSource().equals("2")) {// 代理人
                 this.agentPerson(getQxFrontlineAgentList, qxFrontlineAgentVo);
+            } else if (qxFrontlineAgentVo.getManagementSource().equals("3")) { //电销
+                this.electricPerson(getQxFrontlineAgentList,qxFrontlineAgentVo);
             }
 
             if (StringUtils.isNotEmpty(qxFrontlineAgentVo.getOutThere())) {
@@ -391,25 +393,6 @@ public class UserReportServiceImpl implements UserReportService {
             userItem.setTotalPremium(orderManpower.getTotalPremium());
             //单均保费
             userItem.setAveragePremium(orderManpower.getAveragePremium());
-//            String deptId = userItem.getDeptId();
-//            if(StringUtils.isNotEmpty(deptId)){
-//                int length = deptId.length();
-//                if (length > 0) {
-//                    if (length > 10) {
-//                        String substring = deptId.substring(0, 6);
-//                        String substring1 = deptId.substring(0, 8);
-//                        String province = deptId.substring(0, 4);
-//                        String storeDept = deptId.substring(0, 11);
-//                        SysDept cityName = sysDeptService.getById(substring);
-//                        SysDept districtName = sysDeptService.getById(substring1);
-//                        SysDept provinceName = sysDeptService.getById(province);
-//                        SysDept storeDeptEntity = sysDeptService.getById(storeDept);
-//                        String deptName = userItem.getDeptName();
-//                        String a = provinceName.getName()+"-"+cityName.getName()+"-"+districtName.getName()+"-"+storeDeptEntity.getName()+"-"+deptName;
-//                        userItem.setDeptName(a);
-//                    }
-//                }
-//            }
         }
     }
 
@@ -445,6 +428,32 @@ public class UserReportServiceImpl implements UserReportService {
             }
         }
     }
+    /**
+     *   电销统计
+     * @param sysUserList  渠道userIds
+     */
+    private void electricPerson(List<QxFrontlineAgentDto> getQxFrontlineAgentList, QxFrontlineAgentVo qxFrontlineAgentVo) {
+        for (QxFrontlineAgentDto  item  : getQxFrontlineAgentList){
+//            是否是团队长
+            String userId = item.getUserId();
+                QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
+                wrapper.eq("operatorCode", userId);
+                wrapper.eq("status", "1");
+                List<SysUser> sysUsers = sysUserMapper.selectList(wrapper);
+                List<String> collect =new ArrayList<>();
+                if(sysUsers!=null && sysUsers.size()>0){
+                    collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+                }
+                QxFrontlineAgentDto qxFrontlineAgentDto = new QxFrontlineAgentDto();
+                collect.add(userId);
+                qxFrontlineAgentDto.setCreatetimeEnd(qxFrontlineAgentVo.getCreatetimeEnd());
+                qxFrontlineAgentDto.setCreatetimeStart(qxFrontlineAgentVo.getCreatetimeStart());
+                qxFrontlineAgentDto.setIds(collect);
+                QxFrontlineAgentDto taskStatisticsDto = insAreaCompanyMapper.getOrderManpowerNew(qxFrontlineAgentDto);
+                item.setAveragePremium(taskStatisticsDto.getAveragePremium());
+                item.setTotalPremium(taskStatisticsDto.getTotalPremium());
+        }
+    }
 
     /**
      *  @version

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

@@ -361,6 +361,20 @@ public interface InsAreaCompanyMapper extends BaseMapper<InsAreaCompany> {
     TaskStatisticsDtoNew costCenterSecond(@Param("taskStatisticsVo")TaskStatisticsVo taskStatisticsVo);
 
     List<TaskStatisticsDtoExcel> costCenterDetailsExcel(@Param("taskStatisticsVo") TaskStatisticsVo taskStatisticsVo);
+    /**
+     * @description:   电销任务统计查询
+     * @author: whp
+     * @date: 2024/10/11
+     **/
+    IPage<TaskStatisticsDto> queryPageElectric( @Param("page") Page page, @Param("taskStatisticsVo")  TaskStatisticsVo taskStatisticsVo);
+
+    /**
+     *
+     * @param taskStatisticsVo
+     * @return 电销合计
+     */
+    Long queryPageElectricTotal(@Param("taskStatisticsVo") TaskStatisticsVo taskStatisticsVo);
+
 }
 
 

+ 2 - 1
src/main/java/com/ydtech/modules/protocol/controller/PtlInsAttributionTemplateController.java

@@ -4,6 +4,7 @@ package com.ydtech.modules.protocol.controller;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.protocol.entity.dto.PtlInsAttributionTemplateQueryDto;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.entity.po.PtlInsAttributionTemplate;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateQueryVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateSaveVo;
@@ -27,7 +28,7 @@ public class PtlInsAttributionTemplateController {
 
     @PostMapping("/getPtlInsAttributionTemplate")
     @ApiOperation("通过保险公司id和api类型查询请求模板")
-    public HttpResult<PtlInsAttributionTemplate> getPtlInsAttributionTemplate(@RequestBody PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo) {
+    public HttpResult<PtlAgreementAttribution> getPtlInsAttributionTemplate(@RequestBody PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo) {
         return ptlInsAttributionTemplateService.getPtlInsAttributionTemplate(ptlInsAttributionTemplateVo);
     }
 

+ 3 - 0
src/main/java/com/ydtech/modules/protocol/entity/vo/PtlInsAttributionTemplateVo.java

@@ -19,4 +19,7 @@ public class PtlInsAttributionTemplateVo implements Serializable {
     @ApiModelProperty("保险公司ID")
     private String insCompanyId;
 
+    @ApiModelProperty("协议id")
+    private String agreementId;
+
 }

+ 2 - 1
src/main/java/com/ydtech/modules/protocol/service/PtlInsAttributionTemplateService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.protocol.entity.dto.PtlInsAttributionTemplateQueryDto;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.entity.po.PtlInsAttributionTemplate;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateQueryVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateSaveVo;
@@ -70,6 +71,6 @@ public interface PtlInsAttributionTemplateService extends IService<PtlInsAttribu
      * @param ptlInsAttributionTemplateVo 保险公司id和api类型
      * @return PtlInsAttributionTemplate
      */
-    HttpResult<PtlInsAttributionTemplate> getPtlInsAttributionTemplate(PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo);
+    HttpResult<PtlAgreementAttribution> getPtlInsAttributionTemplate(PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo);
 
 }

+ 19 - 7
src/main/java/com/ydtech/modules/protocol/service/impl/PtlInsAttributionTemplateServiceImpl.java

@@ -11,12 +11,14 @@ import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.protocol.dao.PtlInsAttributionTemplateMapper;
 import com.ydtech.modules.protocol.entity.constants.PtlApiType;
 import com.ydtech.modules.protocol.entity.dto.PtlInsAttributionTemplateQueryDto;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.entity.po.PtlCrawlerApi;
 import com.ydtech.modules.protocol.entity.po.PtlInsAttributionTemplate;
 import com.ydtech.modules.protocol.entity.vo.PtlCrawlerApiSaveVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateQueryVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateSaveVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateVo;
+import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
 import com.ydtech.modules.protocol.service.PtlCrawlerApiService;
 import com.ydtech.modules.protocol.service.PtlInsAttributionTemplateService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
@@ -46,11 +48,14 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
 
     private final PtlInsAttributionTemplateService proxyService;
 
+    private final PtlAgreementAttributionService ptlAgreementAttributionService;
+
     public PtlInsAttributionTemplateServiceImpl(EsmInsCompanyService esmInsCompanyService, PtlCrawlerApiService ptlCrawlerApiService,
-                                                @Lazy PtlInsAttributionTemplateService proxyService) {
+                                                @Lazy PtlInsAttributionTemplateService proxyService,PtlAgreementAttributionService ptlAgreementAttributionService) {
         this.esmInsCompanyService = esmInsCompanyService;
         this.ptlCrawlerApiService = ptlCrawlerApiService;
         this.proxyService = proxyService;
+        this.ptlAgreementAttributionService = ptlAgreementAttributionService;
     }
 
 
@@ -152,15 +157,14 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
     }
 
     @Override
-    public HttpResult<PtlInsAttributionTemplate> getPtlInsAttributionTemplate(PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo) {
+    public HttpResult<PtlAgreementAttribution> getPtlInsAttributionTemplate(PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo) {
         String code = "000000";
         String substring = ptlInsAttributionTemplateVo.getInsCompanyId().substring(0, 5);
         String companyId = substring + code;
-
-        LambdaQueryWrapper<PtlInsAttributionTemplate> wrapper = byInsCompanyIdAndApiType(companyId, ptlInsAttributionTemplateVo.getApiType());
-        PtlInsAttributionTemplate ptlInsAttributionTemplate = getOne(wrapper);
-        AssertionUtils.isEmpty(ptlInsAttributionTemplate, "保险公司归属信息模板查询失败");
-        return HttpResult.ok(ptlInsAttributionTemplate);
+        LambdaQueryWrapper<PtlAgreementAttribution> wrapper = byInsCompanyIdAndApiTypeAndAgreementId(ptlInsAttributionTemplateVo.getAgreementId(),companyId, ptlInsAttributionTemplateVo.getApiType());
+        PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getOne(wrapper);
+        AssertionUtils.isEmpty(ptlAgreementAttribution, "保险公司归属信息模板查询失败");
+        return HttpResult.ok(ptlAgreementAttribution);
     }
 
     private LambdaQueryWrapper<PtlInsAttributionTemplate> byInsCompanyIdAndApiType(String insCompanyId, Integer apiType) {
@@ -170,6 +174,14 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
         return wrapper;
     }
 
+    private LambdaQueryWrapper<PtlAgreementAttribution> byInsCompanyIdAndApiTypeAndAgreementId(String agreementId, String insCompanyId, Integer apiType) {
+        LambdaQueryWrapper<PtlAgreementAttribution> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PtlAgreementAttribution::getId, agreementId)
+                .eq(PtlAgreementAttribution::getInsCompanyId, insCompanyId)
+                .eq(PtlAgreementAttribution::getApiType, apiType);
+        return wrapper;
+    }
+
 }
 
 

+ 178 - 0
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -1149,8 +1149,186 @@
                 and su.id =#{taskStatisticsVo.userId}
             </if>
         </where>
+    </select>
+
+    <select id="queryPageElectric"  resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
+        select a.*, su.name  as "userName",
+        inf.url  as "logo",
+        sui.sex as "sex",
+        su.leader_name as "leaderName",
+        su2.mobile  as "leaderMobile"
+        from (
+        SELECT
+        sd.NAME AS "deptName",
+        io.userid AS "userId",
+        sd.parent_id as "deptId",
+        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"
+        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 = '3'
+            <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.userId != null and taskStatisticsVo.userId != ''">
+                and io.userid =#{taskStatisticsVo.userId}
+            </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.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 !='' ">
+                and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
+            </if>
+
+            <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
+                AND sd.id  in
+                <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
+                AND io.userid  in
+                <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </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,
+        sd.NAME,
+        sd.id
+        ) a
+        left  join  sys_user su  on su.id =a.userId
+        LEFT JOIN  ins_upload_files   inf on  su.head_sculpture  =inf.id
+        LEFT JOIN sys_user_info  sui  on  sui .id =su.id
+        LEFT JOIN  sys_user  su2  on su2.id =su.leader_id
+        <where>
+            <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
+                and su.name like concat('%',#{taskStatisticsVo.userName},'%')
+            </if>
+            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
+                and su.leader_id  =#{taskStatisticsVo.leaderId}
+            </if>
+             <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
+                and su.id =#{taskStatisticsVo.userId}
+            </if>
+        </where>
+    </select>
+
+    <select id="queryPageElectricTotal"  resultType="java.lang.Long">
+        select count(0) from (
+        SELECT
+        io.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 = '3'
+            <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.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 !='' ">
+                and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
+            </if>
+
+            <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
+                and io.userid =#{taskStatisticsVo.userId}
+            </if>
+
+            <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
+                AND sd.id  in
+                <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
+                AND io.userid  in
+                <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </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="queryPageTaskStatisticsTotal"  resultType="java.lang.Long">
         select count(0) from (
         SELECT