xuhy
2026-01-12 d05de30119a88b98eecf682f96b2988d080b808e
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
@@ -99,6 +99,11 @@
        TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
        Map<String, Object> map = new HashMap<>();
@@ -141,16 +146,21 @@
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, userId)
                    .last("LIMIT 1"));
            // ***
            if (Objects.isNull(crmSupplier)) {
                SysUser sysUser = sysUserService.selectUserById(userId);
                crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
            }
            supplierAndClinicId = crmSupplier.getId();
        } else {
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, userId)
                    .last("LIMIT 1"));
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                SysUser sysUser = sysUserService.selectUserById(userId);
                crmClinic = crmClinicService.getById(sysUser.getObjectId());
            }
            if(Objects.isNull(crmClinic)){
            if (Objects.isNull(crmClinic)) {
                return R.fail("未找到该账号诊所信息");
            }
            supplierAndClinicId = crmClinic.getId();
@@ -204,11 +214,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
@@ -232,11 +242,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        List<TCrmClinicPoints> crmClinicPoints = crmClinicPointsService.clinicPointsStatistics(crmClinic.getId(), LocalDate.now() + " 23:59:59");
@@ -264,6 +274,11 @@
        TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
        // 查询药品总类和总数
        Integer typeTotalCount = erpProcurementService.supplierSalesStatisticsTypeCount(crmSupplier.getId());
        Integer totalCount = erpProcurementService.supplierSalesStatisticsCount(crmSupplier.getId());
@@ -309,6 +324,11 @@
        TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                .eq(TCrmSupplier::getUserId, userId)
                .last("LIMIT 1"));
        // ***
        if (Objects.isNull(crmSupplier)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
        }
        SupplierSalesStatisticsVO supplierSalesStatisticsVO = new SupplierSalesStatisticsVO();
        // 销售金额
        BigDecimal totalMoney = erpProcurementService.supplierSalesStatisticsMoney(crmSupplier.getId(), startTime, endTime);
@@ -419,11 +439,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        // 查询药品总类和总数
@@ -471,11 +491,11 @@
        TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                .eq(TCrmClinic::getUserId, userId)
                .last("LIMIT 1"));
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            SysUser sysUser = sysUserService.selectUserById(userId);
            crmClinic = crmClinicService.getById(sysUser.getObjectId());
        }
        if(Objects.isNull(crmClinic)){
        if (Objects.isNull(crmClinic)) {
            return R.fail("未找到该账号诊所信息");
        }
        ClinicSalesStatisticsVO clinicSalesStatisticsVO = new ClinicSalesStatisticsVO();
@@ -587,6 +607,140 @@
    }
    @ApiOperation(value = "分公司管理员-首页统计(获取所有分公司信息)")
    @GetMapping(value = "/branchAdminList")
    public R<List<BranchAdminListVO>> branchAdminList() {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        ArrayList<BranchAdminListVO> branchAdminListVOs = new ArrayList<>();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId()).eq(TCrmBranch::getAuditStatus,2)
                    .last("LIMIT 1"));
            if (branch != null) {
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                    }
                }
                // 省
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    // 所有的区 公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                        if (!crmBranchesThree.isEmpty()) {
                            for (TCrmBranch crmBranch : crmBranchesThree) {
                                BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                                branchAdminListVO.setId(crmBranch.getId());
                                branchAdminListVO.setName(crmBranch.getBranchName());
                                branchAdminListVOs.add(branchAdminListVO);
                            }
                        }
                    }
                }
            }
        }
        return R.ok(branchAdminListVOs);
    }
    @ApiOperation(value = "分公司管理员-首页统计(获取所有业务员信息)")
    @GetMapping(value = "/branchAdminSaleList")
    public R<List<BranchAdminListVO>> branchAdminSaleList(String branchId) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        ArrayList<BranchAdminListVO> branchAdminListVOs = new ArrayList<>();
        if (roleType == 2) {
            TCrmBranch branch =null;
            if(branchId==null || branchId.isEmpty()){
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getUserId, user.getUserId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }else {
                branch = crmBranchService.getById(branchId);
            }
            if (branch != null) {
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                    }
                }
                // 省
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    // 所有的区 公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        for (TCrmBranch crmBranch : crmBranches) {
                            BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                            branchAdminListVO.setId(crmBranch.getId());
                            branchAdminListVO.setName(crmBranch.getBranchName());
                            branchAdminListVOs.add(branchAdminListVO);
                        }
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                        if (!crmBranchesThree.isEmpty()) {
                            for (TCrmBranch crmBranch : crmBranchesThree) {
                                BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                                branchAdminListVO.setId(crmBranch.getId());
                                branchAdminListVO.setName(crmBranch.getBranchName());
                                branchAdminListVOs.add(branchAdminListVO);
                            }
                        }
                    }
                }
            }
        }
        ArrayList<BranchAdminListVO> list = new ArrayList<>();
        if(!branchAdminListVOs.isEmpty()){
            Set<String> branchIds = branchAdminListVOs.stream().map(BranchAdminListVO::getId).collect(Collectors.toSet());
            List<TCrmSalesperson> tCrmSalespersonList = crmSalespersonService.list(new LambdaQueryWrapper<TCrmSalesperson>().in(TCrmSalesperson::getBranchId, branchIds));
            if(!tCrmSalespersonList.isEmpty()){
                for (TCrmSalesperson tCrmSalesperson : tCrmSalespersonList) {
                    BranchAdminListVO branchAdminListVO = new BranchAdminListVO();
                    branchAdminListVO.setId(tCrmSalesperson.getId());
                    branchAdminListVO.setName(tCrmSalesperson.getSalespersonName());
                    list.add(branchAdminListVO);
                }
            }
        }
        return R.ok(list);
    }
    /**
     * 分公司管理员-首页统计(第一部分)
     */
@@ -596,21 +750,83 @@
        BranchAdminStatisticsOneVo branchAdminStatisticsOneVo = new BranchAdminStatisticsOneVo();
        // 找出分公司下的所有员工 -》 所有诊所-》订单(状态 3=待发货 4=已发货 5=已入库)
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        Set<String> branchIdsAll = new HashSet<>();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            TCrmBranch branch =null;
            if(query.getBranchId()==null || query.getBranchId().isEmpty()){
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getUserId, user.getUserId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }else {
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getId, query.getBranchId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }
            if (branch != null) {
                branchIdsAll.add(branch.getId());
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus, 2));
                    List<String> branchIdsThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                    if(!crmBranches.isEmpty()){
                        branchIdsAll.addAll(crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()));
                        List<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toList());
                        List<String> branchIdsFour = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        if(!branchIdsFour.isEmpty()){
                            branchIdsAll.addAll(branchIdsFour);
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsFour).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                    if(!branchIdsThree.isEmpty()){
                        branchIdsAll.addAll(branchIdsThree);
                    }
                }
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        branchIdsAll.addAll(branchIds);
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        branchIdsAll.addAll(branchIds);
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            branchIdsAll.addAll(branchIdsThree);
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                if (!list.isEmpty()) {
                    List<String> crmClinicIds = list.stream().map(TCrmClinic::getId).collect(Collectors.toList());
                    // 获取最近一年的时间
                    LocalDateTime time = LocalDateTime.now().minusYears(1);
                    List<TErpProcurement> procurementList = erpProcurementService.list(new LambdaQueryWrapper<TErpProcurement>().between(TErpProcurement::getCreateTime, DateUtils.localDateTimeToDate(time), DateUtils.localDateTimeToDate(LocalDateTime.now())).ne(TErpProcurement::getStatus, 6).isNotNull(TErpProcurement::getPayTime).in(TErpProcurement::getClinicId, crmClinicIds));
                    List<TErpProcurementCommission> list1 = erpProcurementCommissionService.list(new LambdaQueryWrapper<TErpProcurementCommission>().eq(TErpProcurementCommission::getBranchSalespersonId, branch.getId()).eq(TErpProcurementCommission::getCommissionType, 1).between(TErpProcurementCommission::getCreateTime, DateUtils.localDateTimeToDate(time), DateUtils.localDateTimeToDate(LocalDateTime.now())));
                    List<TErpProcurementCommission> list1 = erpProcurementCommissionService.list(new LambdaQueryWrapper<TErpProcurementCommission>().in(TErpProcurementCommission::getBranchSalespersonId,branchIdsAll).eq(TErpProcurementCommission::getCommissionType, 1).between(TErpProcurementCommission::getCreateTime, DateUtils.localDateTimeToDate(time), DateUtils.localDateTimeToDate(LocalDateTime.now())));
                    // list1 获取本月的
                    List<TErpProcurementCommission> list2 = list1.stream().filter(commission -> commission.getCreateTime().toLocalDate().isAfter(time.toLocalDate())).collect(Collectors.toList());
@@ -654,7 +870,7 @@
                        // 获取公司业务员
                        List<String> salesIds = crmSalespersonService.list(new LambdaQueryWrapper<TCrmSalesperson>().eq(TCrmSalesperson::getBranchId, branch.getId())).stream().map(TCrmSalesperson::getId).collect(Collectors.toList());
                        List<String> salesIds = crmSalespersonService.list(new LambdaQueryWrapper<TCrmSalesperson>().in(TCrmSalesperson::getBranchId,branchIdsAll)).stream().map(TCrmSalesperson::getId).collect(Collectors.toList());
                        if (salesIds.isEmpty()) {
                            salesIds.add("0");
                        }
@@ -694,14 +910,18 @@
                        branchAdminStatisticsOneVo.setStaffMoneyProcurement(collect1.stream().map(TErpProcurement::getPayMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
                        branchAdminStatisticsOneVo.setStaffMoney(collect3.stream().map(TErpProcurementCommission::getMoney).filter(Objects::nonNull).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
                        long count = crmSalespersonService.count(new LambdaQueryWrapper<TCrmSalesperson>().eq(TCrmSalesperson::getBranchId, branch.getId()));
                        branchAdminStatisticsOneVo.setStaffCount((int) count);
                    }
                }
            }
            if(CollectionUtils.isEmpty(branchIdsAll)){
                branchAdminStatisticsOneVo.setStaffCount(0);
            }else{
                long count = crmSalespersonService.count(new LambdaQueryWrapper<TCrmSalesperson>().in(TCrmSalesperson::getBranchId, branchIdsAll));
                branchAdminStatisticsOneVo.setStaffCount((int) count);
            }
        }
        return R.ok(branchAdminStatisticsOneVo);
@@ -717,20 +937,72 @@
        BranchAdminStatisticsTwoVo branchAdminStatisticsTwoVo = new BranchAdminStatisticsTwoVo();
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        Set<String> branchIdsAll = new HashSet<>();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            TCrmBranch branch =null;
            if(query.getBranchId()==null || query.getBranchId().isEmpty()){
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getUserId, user.getUserId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }else {
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getId, query.getBranchId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }
            if (branch != null) {
                LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
                if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                    eq.eq(TCrmClinic::getSalespersonId, query.getSalespersonId());
                } else {
                    eq.eq(TCrmClinic::getBranchId, branch.getId());
                }
                eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                List<TCrmClinic> list = crmClinicService.list(eq);
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus, 2));
                    List<String> branchIdsThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                    if(!crmBranches.isEmpty()){
                        branchIdsAll.addAll(crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()));
                        List<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toList());
                        List<String> branchIdsFour = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        if(!branchIdsFour.isEmpty()){
                            branchIdsAll.addAll(branchIdsFour);
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsFour).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                    if(!branchIdsThree.isEmpty()){
                        branchIdsAll.addAll(branchIdsThree);
                    }
                }
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                    list = list.stream().filter(e -> e.getSalespersonId().equals(query.getSalespersonId())).collect(Collectors.toList());
                }
                branchAdminStatisticsTwoVo.setClinicNum(list.size());
                // 金额
@@ -808,15 +1080,67 @@
        SysUser user = tokenService.getLoginUser().getUser();
        SimpleDateFormat formatMonth = new SimpleDateFormat("yyyy-MM");
        Integer roleType = user.getRoleType();
        Set<String> branchIdsAll = new HashSet<>();
        if (roleType == 2) {
            TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                    .eq(TCrmBranch::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            TCrmBranch branch =null;
            if(query.getBranchId()==null || query.getBranchId().isEmpty()){
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getUserId, user.getUserId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }else {
                branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getId, query.getBranchId()).eq(TCrmBranch::getAuditStatus,2)
                        .last("LIMIT 1"));
            }
            if (branch != null) {
                LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
                eq.eq(TCrmClinic::getBranchId, branch.getId());
                eq.eq(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                List<TCrmClinic> list = crmClinicService.list(eq);
                // 先查自己本身的
                List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                if (branch.getPersonType() != null && branch.getPersonType() == 1) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus, 2));
                    List<String> branchIdsThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                    if(!crmBranches.isEmpty()){
                        branchIdsAll.addAll(crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()));
                        List<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toList());
                        List<String> branchIdsFour = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2)).stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        if(!branchIdsFour.isEmpty()){
                            branchIdsAll.addAll(branchIdsFour);
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsFour).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                    if(!branchIdsThree.isEmpty()){
                        branchIdsAll.addAll(branchIdsThree);
                    }
                }
                // 如果是区
                if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                    // 区查下面所有城市的公司
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                    }
                }
                if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                    List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus,2));
                    if (!crmBranches.isEmpty()) {
                        // 区公司
                        List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                        list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                        // 城市公司
                        List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus,2));
                        if (!crmBranchesThree.isEmpty()) {
                            List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                }
                List<String> clinicIds = list.stream().map(TCrmClinic::getId).collect(Collectors.toList());
                if (clinicIds.isEmpty()) {
@@ -860,7 +1184,7 @@
                List<ClinicSalesStatisticsGoodsTypeVO> thirtyMoneyProcurementStatisticsVOS = collect2.entrySet().stream().map(entry -> {
                    ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                    clinicSalesStatisticsGoodsTypeVO.setGoodsCount(entry.getValue().stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
                    clinicSalesStatisticsGoodsTypeVO.setTypeName(entry.getValue().get(0).getGoodsName());
                    clinicSalesStatisticsGoodsTypeVO.setGoodsName(entry.getValue().get(0).getGoodsName());
                    return clinicSalesStatisticsGoodsTypeVO;
                }).sorted(Comparator.comparing(ClinicSalesStatisticsGoodsTypeVO::getGoodsCount).reversed()).limit(9).collect(Collectors.toList());
                // 总数
@@ -869,7 +1193,7 @@
                if (sum - sum1 > 0) {
                    ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                    clinicSalesStatisticsGoodsTypeVO.setGoodsCount(sum - sum1);
                    clinicSalesStatisticsGoodsTypeVO.setTypeName("其他");
                    clinicSalesStatisticsGoodsTypeVO.setGoodsName("其他");
                    thirtyMoneyProcurementStatisticsVOS.add(clinicSalesStatisticsGoodsTypeVO);
                }
                vo.setThirtyMoneyProcurementStatisticsVOS(thirtyMoneyProcurementStatisticsVOS);
@@ -1047,16 +1371,65 @@
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        List<TCrmClinic> list =new ArrayList<>();
        if (roleType == 1) {
            LambdaQueryWrapper<TCrmClinic> w = new LambdaQueryWrapper<>();
            if (query.getBranchId() != null && !query.getBranchId().isEmpty()) {
                w.eq(TCrmClinic::getBranchId, query.getBranchId());
            if(   ((query.getBranchId()==null || query.getBranchId().isEmpty()) && ( query.getSalespersonId()==null || query.getSalespersonId().isEmpty())) || ((query.getBranchId()!=null || !query.getBranchId().isEmpty()) && (query.getSalespersonId()==null || !query.getSalespersonId().isEmpty()))){
                LambdaQueryWrapper<TCrmClinic> w = new LambdaQueryWrapper<>();
                if (query.getBranchId() != null && !query.getBranchId().isEmpty()) {
                    w.eq(TCrmClinic::getBranchId, query.getBranchId());
                }
                if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                    w.eq(TCrmClinic::getSalespersonId, query.getSalespersonId());
                }
                w.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                list = crmClinicService.list(w);
            }else {
                TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getId, query.getBranchId()).eq(TCrmBranch::getAuditStatus, 2)
                        .last("LIMIT 1"));
                if (branch != null) {
                    // 先查自己本身的
                    list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                    // 如果是区
                    if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                        // 区查下面所有城市的公司
                        List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus, 2));
                        if (!crmBranches.isEmpty()) {
                            List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                    if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                        List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus, 2));
                        if (!crmBranches.isEmpty()) {
                            // 区公司
                            List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                            Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                            // 城市公司
                            List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus, 2));
                            if (!crmBranchesThree.isEmpty()) {
                                List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                                list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                            }
                        }
                    }
                    if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                        list = list.stream().filter(e -> e.getSalespersonId().equals(query.getSalespersonId())).collect(Collectors.toList());
                    }
                }
            }
            if (query.getSalespersonId() != null && !query.getSalespersonId().isEmpty()) {
                w.eq(TCrmClinic::getSalespersonId, query.getSalespersonId());
            }
            w.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
            List<TCrmClinic> list = crmClinicService.list(w);
            branchAdminStatisticsOneVo.setClinicNum(list.size());
            if (!list.isEmpty()) {
@@ -1164,13 +1537,53 @@
        SysUser user = tokenService.getLoginUser().getUser();
        SimpleDateFormat formatMonth = new SimpleDateFormat("yyyy-MM");
        Integer roleType = user.getRoleType();
        List<TCrmClinic> list =new ArrayList<>();
        if (roleType == 1) {
            LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
            if (query.getBranchId() != null && !query.getBranchId().isEmpty()) {
                eq.eq(TCrmClinic::getBranchId, query.getBranchId());
            if(query.getBranchId()==null || query.getBranchId().isEmpty() ){
                LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
                if (query.getBranchId() != null && !query.getBranchId().isEmpty()) {
                    eq.eq(TCrmClinic::getBranchId, query.getBranchId());
                }
                eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
                list = crmClinicService.list(eq);
            }else {
                TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
                        .eq(TCrmBranch::getId, query.getBranchId()).eq(TCrmBranch::getAuditStatus, 2)
                        .last("LIMIT 1"));
                if (branch != null) {
                    // 先查自己本身的
                    list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
                    // 如果是区
                    if (branch.getPersonType() != null && branch.getPersonType() == 2) {
                        // 区查下面所有城市的公司
                        List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus, 2));
                        if (!crmBranches.isEmpty()) {
                            List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                        }
                    }
                    if (branch.getPersonType() != null && branch.getPersonType() == 3) {
                        List<TCrmBranch> crmBranches = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().eq(TCrmBranch::getCorrelationPersonId, branch.getUserId()).eq(TCrmBranch::getPersonType, 2).eq(TCrmBranch::getAuditStatus, 2));
                        if (!crmBranches.isEmpty()) {
                            // 区公司
                            List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                            list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIds).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                            Set<Long> userIds = crmBranches.stream().map(TCrmBranch::getUserId).collect(Collectors.toSet());
                            // 城市公司
                            List<TCrmBranch> crmBranchesThree = crmBranchService.list(new LambdaQueryWrapper<TCrmBranch>().in(TCrmBranch::getCorrelationPersonId, userIds).eq(TCrmBranch::getPersonType, 3).eq(TCrmBranch::getAuditStatus, 2));
                            if (!crmBranchesThree.isEmpty()) {
                                List<String> branchIdsThree = crmBranchesThree.stream().map(TCrmBranch::getId).collect(Collectors.toList());
                                list.addAll(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getBranchId, branchIdsThree).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5))));
                            }
                        }
                    }
                }
            }
            eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
            List<TCrmClinic> list = crmClinicService.list(eq);
            List<String> clinicIds = list.stream().map(TCrmClinic::getId).collect(Collectors.toList());
            if (clinicIds.isEmpty()) {
@@ -1214,7 +1627,7 @@
            List<ClinicSalesStatisticsGoodsTypeVO> thirtyMoneyProcurementStatisticsVOS = collect2.entrySet().stream().map(entry -> {
                ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                clinicSalesStatisticsGoodsTypeVO.setGoodsCount(entry.getValue().stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
                clinicSalesStatisticsGoodsTypeVO.setTypeName(entry.getValue().get(0).getGoodsName());
                clinicSalesStatisticsGoodsTypeVO.setGoodsName(entry.getValue().get(0).getGoodsName());
                return clinicSalesStatisticsGoodsTypeVO;
            }).sorted(Comparator.comparing(ClinicSalesStatisticsGoodsTypeVO::getGoodsCount).reversed()).limit(9).collect(Collectors.toList());
            // 总数
@@ -1223,7 +1636,7 @@
            if (sum - sum1 > 0) {
                ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                clinicSalesStatisticsGoodsTypeVO.setGoodsCount(sum - sum1);
                clinicSalesStatisticsGoodsTypeVO.setTypeName("其他");
                clinicSalesStatisticsGoodsTypeVO.setGoodsName("其他");
                thirtyMoneyProcurementStatisticsVOS.add(clinicSalesStatisticsGoodsTypeVO);
            }
            vo.setThirtyMoneyProcurementStatisticsVOS(thirtyMoneyProcurementStatisticsVOS);
@@ -1303,8 +1716,9 @@
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if (roleType == 3) {
            TCrmSalesperson one = crmSalespersonService.getOne(new LambdaQueryWrapper<TCrmSalesperson>().eq(TCrmSalesperson::getUserId, user.getUserId()));
            LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
            eq.eq(TCrmClinic::getSalespersonId, user.getUserId());
            eq.eq(TCrmClinic::getSalespersonId, one.getId());
            eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
            List<TCrmClinic> list = crmClinicService.list(eq);
@@ -1384,8 +1798,9 @@
        SimpleDateFormat formatMonth = new SimpleDateFormat("yyyy-MM");
        Integer roleType = user.getRoleType();
        if (roleType == 3) {
            TCrmSalesperson one = crmSalespersonService.getOne(new LambdaQueryWrapper<TCrmSalesperson>().eq(TCrmSalesperson::getUserId, user.getUserId()));
            LambdaQueryWrapper<TCrmClinic> eq = Wrappers.lambdaQuery(TCrmClinic.class);
            eq.eq(TCrmClinic::getSalespersonId, user.getUserId());
            eq.eq(TCrmClinic::getSalespersonId, one.getId());
            eq.in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5));
            List<TCrmClinic> list = crmClinicService.list(eq);
@@ -1431,7 +1846,7 @@
            List<ClinicSalesStatisticsGoodsTypeVO> thirtyMoneyProcurementStatisticsVOS = collect2.entrySet().stream().map(entry -> {
                ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                clinicSalesStatisticsGoodsTypeVO.setGoodsCount(entry.getValue().stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
                clinicSalesStatisticsGoodsTypeVO.setTypeName(entry.getValue().get(0).getGoodsName());
                clinicSalesStatisticsGoodsTypeVO.setGoodsName(entry.getValue().get(0).getGoodsName());
                return clinicSalesStatisticsGoodsTypeVO;
            }).sorted(Comparator.comparing(ClinicSalesStatisticsGoodsTypeVO::getGoodsCount).reversed()).limit(9).collect(Collectors.toList());
            // 总数
@@ -1440,7 +1855,7 @@
            if (sum - sum1 > 0) {
                ClinicSalesStatisticsGoodsTypeVO clinicSalesStatisticsGoodsTypeVO = new ClinicSalesStatisticsGoodsTypeVO();
                clinicSalesStatisticsGoodsTypeVO.setGoodsCount(sum - sum1);
                clinicSalesStatisticsGoodsTypeVO.setTypeName("其他");
                clinicSalesStatisticsGoodsTypeVO.setGoodsName("其他");
                thirtyMoneyProcurementStatisticsVOS.add(clinicSalesStatisticsGoodsTypeVO);
            }
            vo.setThirtyMoneyProcurementStatisticsVOS(thirtyMoneyProcurementStatisticsVOS);