From bf4f7bae745b8c6e9c468e243961c9edea6dfed4 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 24 四月 2026 09:13:09 +0800
Subject: [PATCH] fix: 进销存数据分析产品数去重
---
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java | 69 ++++------------------------------
1 files changed, 8 insertions(+), 61 deletions(-)
diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index 2d3e608..1e94a30 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -4,15 +4,13 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.account.mapper.AccountExpenseMapper;
import com.ruoyi.account.mapper.AccountIncomeMapper;
import com.ruoyi.account.pojo.AccountExpense;
-import com.ruoyi.home.mapper.HomeMapper;
-import com.ruoyi.account.mapper.AccountExpenseMapper;
import com.ruoyi.approve.mapper.ApproveProcessMapper;
import com.ruoyi.approve.pojo.ApproveProcess;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.mapper.ProductMapper;
-import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.mapper.SupplierManageMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.pojo.Product;
@@ -27,19 +25,11 @@
import com.ruoyi.dto.MapDto;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.home.dto.*;
+import com.ruoyi.home.mapper.HomeMapper;
import com.ruoyi.home.service.HomeService;
-import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
-import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
-import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.dto.ProductOrderDto;
import com.ruoyi.production.dto.ProductWorkOrderDto;
-import com.ruoyi.production.mapper.ProductOrderMapper;
-import com.ruoyi.production.mapper.ProductProcessMapper;
-import com.ruoyi.production.mapper.ProductWorkOrderMapper;
-import com.ruoyi.production.mapper.ProductionProductInputMapper;
-import com.ruoyi.production.mapper.ProductionProductOutputMapper;
-import com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper;
-import com.ruoyi.production.pojo.ProductProcess;
+import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.ProductWorkOrder;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -145,7 +135,7 @@
@Autowired
private ProductProcessMapper productProcessMapper;
-
+
@Autowired
private AccountExpenseMapper accountExpenseMapper;
@@ -676,64 +666,21 @@
@Override
public HomeSummaryDto summaryStatistics() {
HomeSummaryDto dto = new HomeSummaryDto();
- LocalDate now = LocalDate.now();
- YearMonth currentMonth = YearMonth.from(now);
- YearMonth prevMonth = currentMonth.minusMonths(1);
-
- LocalDateTime currentMonthEnd = currentMonth.atEndOfMonth().atTime(23, 59, 59);
- LocalDateTime prevMonthEnd = prevMonth.atEndOfMonth().atTime(23, 59, 59);
-
// 鎬诲伐浣滀汉鍛�
- Long currentStaff = countStaff(currentMonthEnd);
- Long prevStaff = countStaff(prevMonthEnd);
+ Long currentStaff = 0L;
dto.setTotalStaff(currentStaff);
- dto.setStaffGrowthRate(calculateMoM(currentStaff, prevStaff));
// 鎬诲鎴锋暟
- Long currentCustomers = countCustomers(currentMonthEnd);
- Long prevCustomers = countCustomers(prevMonthEnd);
+ Long currentCustomers = customerMapper.selectCount(null);
dto.setTotalCustomer(currentCustomers);
- dto.setCustomerGrowthRate(calculateMoM(currentCustomers, prevCustomers));
// 鎬讳緵搴斿晢鏁�
- Long currentSuppliers = countSuppliers(currentMonthEnd);
- Long prevSuppliers = countSuppliers(prevMonthEnd);
+ Long currentSuppliers = supplierManageMapper.selectCount(null);
dto.setTotalSupplier(currentSuppliers);
- dto.setSupplierGrowthRate(calculateMoM(currentSuppliers, prevSuppliers));
return dto;
}
- private Long countStaff(LocalDateTime dateTime) {
- Long staffCountItem = staffOnJobMapper.selectCount(new LambdaQueryWrapper<StaffOnJob>()
- .isNotNull(StaffOnJob::getStaffState)
- .eq(StaffOnJob::getStaffState, 1)
- .le(StaffOnJob::getCreateTime, dateTime));
- return staffCountItem;
- }
-
- private Long countCustomers(LocalDateTime dateTime) {
- return customerMapper.selectCount(new LambdaQueryWrapper<Customer>()
- .le(Customer::getMaintenanceTime, dateTime.toLocalDate()));
- }
-
- private Long countSuppliers(LocalDateTime dateTime) {
- return supplierManageMapper.selectCount(new LambdaQueryWrapper<SupplierManage>()
- .le(SupplierManage::getCreateTime, dateTime));
- }
-
- private String calculateMoM(Number current, Number prev) {
- BigDecimal curVal = new BigDecimal(current.toString());
- BigDecimal prevVal = new BigDecimal(prev.toString());
- if (prevVal.compareTo(BigDecimal.ZERO) == 0) {
- return curVal.compareTo(BigDecimal.ZERO) > 0 ? "100.00" : "0.00";
- }
- return curVal.subtract(prevVal)
- .divide(prevVal, 4, RoundingMode.HALF_UP)
- .multiply(new BigDecimal("100"))
- .setScale(2, RoundingMode.HALF_UP)
- .toString();
- }
@Override
public List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type) {
@@ -2416,7 +2363,7 @@
.collect(Collectors.groupingBy(QualityInspect::getCheckResult));
List<QualityInspect> qualityInspects = groupedByCheckResult.get("涓嶅悎鏍�");
if (ObjectUtils.isNull(qualityInspects) || qualityInspects.size() == 0) {
- return null;
+ return dto;
}
// 4. 澶勭悊鍥捐〃椤� (Item)
List<QualityStatisticsItem> itemList = new ArrayList<>();
--
Gitblit v1.9.3