From 17b7ef820be095bede95df2fe959cae539d90cc3 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 09 十二月 2025 18:35:15 +0800
Subject: [PATCH] 修改bug
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java | 162 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 141 insertions(+), 21 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
index 89a7375..b109079 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
@@ -760,28 +760,57 @@
// 找出分公司下的所有员工 -》 所有诊所-》订单(状态 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()).eq(TCrmBranch::getAuditStatus,2)
- .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);
+ }
+
+ }
+ 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::getPersonType, 2).eq(TCrmBranch::getAuditStatus,2));
+ 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());
@@ -789,6 +818,8 @@
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))));
}
}
@@ -845,7 +876,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");
}
@@ -885,14 +916,14 @@
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);
+
}
}
}
-
+ long count = crmSalespersonService.count(new LambdaQueryWrapper<TCrmSalesperson>().in(TCrmSalesperson::getBranchId, branchIdsAll));
+ branchAdminStatisticsOneVo.setStaffCount((int) count);
}
return R.ok(branchAdminStatisticsOneVo);
@@ -1287,16 +1318,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()) {
@@ -1404,13 +1484,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()) {
--
Gitblit v1.7.1