From e61046030a9b6967fcf9968c328ba140438f2df7 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 27 十月 2025 15:44:47 +0800
Subject: [PATCH] bug修改
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java | 70 ++++++++++++++++++++++++++++------
1 files changed, 57 insertions(+), 13 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 f481688..12e7c8e 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
@@ -97,7 +97,8 @@
}
TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
- .eq(TCrmSupplier::getUserId, userId));
+ .eq(TCrmSupplier::getUserId, userId)
+ .last("LIMIT 1"));
Map<String, Object> map = new HashMap<>();
@@ -138,11 +139,20 @@
String supplierAndClinicId = null;
if (roleType == 4) {
TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
- .eq(TCrmSupplier::getUserId, userId));
+ .eq(TCrmSupplier::getUserId, userId)
+ .last("LIMIT 1"));
supplierAndClinicId = crmSupplier.getId();
} else {
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
- .eq(TCrmClinic::getUserId, userId));
+ .eq(TCrmClinic::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(crmClinic)){
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ crmClinic = crmClinicService.getById(sysUser.getObjectId());
+ }
+ if(Objects.isNull(crmClinic)){
+ return R.fail("未找到该账号诊所信息");
+ }
supplierAndClinicId = crmClinic.getId();
}
@@ -192,7 +202,15 @@
Long userId = tokenService.getLoginUser().getUserId();
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
- .eq(TCrmClinic::getUserId, userId));
+ .eq(TCrmClinic::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(crmClinic)){
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ crmClinic = crmClinicService.getById(sysUser.getObjectId());
+ }
+ if(Objects.isNull(crmClinic)){
+ return R.fail("未找到该账号诊所信息");
+ }
List<TSysAppUser> sysAppUsers = sysAppUserService.list(Wrappers.lambdaQuery(TSysAppUser.class)
.eq(TSysAppUser::getClinicId, crmClinic.getId()));
@@ -212,8 +230,15 @@
Long userId = tokenService.getLoginUser().getUserId();
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
- .eq(TCrmClinic::getUserId, userId));
-
+ .eq(TCrmClinic::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(crmClinic)){
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ crmClinic = crmClinicService.getById(sysUser.getObjectId());
+ }
+ if(Objects.isNull(crmClinic)){
+ return R.fail("未找到该账号诊所信息");
+ }
List<TCrmClinicPoints> crmClinicPoints = crmClinicPointsService.clinicPointsStatistics(crmClinic.getId(), LocalDate.now() + " 23:59:59");
Map<String, Integer> map = new HashMap<>();
if (CollectionUtils.isEmpty(crmClinicPoints)) {
@@ -237,7 +262,8 @@
Long userId = tokenService.getLoginUser().getUserId();
TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
- .eq(TCrmSupplier::getUserId, userId));
+ .eq(TCrmSupplier::getUserId, userId)
+ .last("LIMIT 1"));
// 查询药品总类和总数
Integer typeTotalCount = erpProcurementService.supplierSalesStatisticsTypeCount(crmSupplier.getId());
Integer totalCount = erpProcurementService.supplierSalesStatisticsCount(crmSupplier.getId());
@@ -281,7 +307,8 @@
break;
}
TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
- .eq(TCrmSupplier::getUserId, userId));
+ .eq(TCrmSupplier::getUserId, userId)
+ .last("LIMIT 1"));
SupplierSalesStatisticsVO supplierSalesStatisticsVO = new SupplierSalesStatisticsVO();
// 销售金额
BigDecimal totalMoney = erpProcurementService.supplierSalesStatisticsMoney(crmSupplier.getId(), startTime, endTime);
@@ -390,10 +417,18 @@
Long userId = tokenService.getLoginUser().getUserId();
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
- .eq(TCrmClinic::getUserId, userId));
+ .eq(TCrmClinic::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(crmClinic)){
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ crmClinic = crmClinicService.getById(sysUser.getObjectId());
+ }
+ if(Objects.isNull(crmClinic)){
+ return R.fail("未找到该账号诊所信息");
+ }
// 查询药品总类和总数
- Integer typeTotalCount = sysOrderService.clinicSalesStatisticsTypeCount(Arrays.asList(crmClinic.getId()));
- Integer totalCount = sysOrderService.clinicSalesStatisticsCount(Arrays.asList(crmClinic.getId()));
+ Integer typeTotalCount = sysOrderService.clinicSalesStatisticsTypeCount(Collections.singletonList(crmClinic.getId()));
+ Integer totalCount = sysOrderService.clinicSalesStatisticsCount(Collections.singletonList(crmClinic.getId()));
Map<String, Integer> map = new HashMap<>();
map.put("typeTotalCount", typeTotalCount);
map.put("totalCount", totalCount);
@@ -434,7 +469,15 @@
break;
}
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
- .eq(TCrmClinic::getUserId, userId));
+ .eq(TCrmClinic::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(crmClinic)){
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ crmClinic = crmClinicService.getById(sysUser.getObjectId());
+ }
+ if(Objects.isNull(crmClinic)){
+ return R.fail("未找到该账号诊所信息");
+ }
ClinicSalesStatisticsVO clinicSalesStatisticsVO = new ClinicSalesStatisticsVO();
// 销售金额
BigDecimal totalMoney = sysOrderService.clinicSalesStatisticsMoney(crmClinic.getId(), startTime, endTime);
@@ -557,7 +600,8 @@
Integer roleType = user.getRoleType();
if (roleType == 2) {
TCrmBranch branch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
- .eq(TCrmBranch::getUserId, user.getUserId()));
+ .eq(TCrmBranch::getUserId, user.getUserId())
+ .last("LIMIT 1"));
if (branch != null) {
List<TCrmClinic> list = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).eq(TCrmClinic::getBranchId, branch.getId()).in(TCrmClinic::getStatus, Arrays.asList(3, 4, 5)));
if (!list.isEmpty()) {
--
Gitblit v1.7.1