From 09394848ce262aff81897503d32ec334fd3f2b6f Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 20 一月 2026 15:59:30 +0800
Subject: [PATCH] Merge branch 'dev_tide' into dev_tide_zlglxt_xinlan
---
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java | 167 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 122 insertions(+), 45 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
index fecbc59..d7b178f 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -2,8 +2,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.mapper.ProductModelMapper;
+import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.utils.OrderUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -14,9 +17,10 @@
import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper;
import com.ruoyi.procurementrecord.pojo.CustomStorage;
-import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut;
+import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
import com.ruoyi.procurementrecord.service.ProcurementRecordService;
+import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
@@ -29,10 +33,13 @@
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
-import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -49,6 +56,8 @@
private final ProcurementRecordOutMapper procurementRecordOutMapper;
private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final StockUtils stockUtils;
+ private final ProductModelMapper productModelMapper;
@Override
public List<ProcurementDto> listProcurementBySalesLedgerId(ProcurementDto procurementDto) {
@@ -70,18 +79,18 @@
List<ProcurementRecordStorage> collect1 = procurementRecordStorages.stream()
.filter(procurementRecordStorage -> procurementRecordStorage.getSalesLedgerProductId().equals(dto.getId()))
.collect(Collectors.toList());
-
+
// 濡傛灉娌℃湁鐩稿叧鐨勫叆搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
if(CollectionUtils.isEmpty(collect1)){
dto.setQuantity0(dto.getQuantity());
continue;
}
-
+
// 璁$畻宸插叆搴撴暟閲忔�诲拰锛屽苟璁剧疆寰呭叆搴撴暟閲�
BigDecimal totalInboundNum = collect1.stream()
.map(ProcurementRecordStorage::getInboundNum)
.reduce(BigDecimal.ZERO, BigDecimal::add);
-
+
// 寰呭叆搴撴暟閲� = 鎬绘暟閲� - 宸插叆搴撴暟閲�
dto.setQuantity0(dto.getQuantity().subtract(totalInboundNum));
}
@@ -107,6 +116,7 @@
@Override
public int updatePro(ProcurementUpdateDto procurementDto) {
ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
+ procurementRecordStorageById.setCreateTime(LocalDate.parse(procurementDto.getInboundDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atTime(LocalTime.MIDNIGHT));
procurementRecordStorageById.setInboundNum(procurementDto.getQuantityStock());
procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
@@ -267,6 +277,53 @@
dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
}
ExcelUtil<ProcurementPageDtoCopy> util = new ExcelUtil<ProcurementPageDtoCopy>(ProcurementPageDtoCopy.class);
+ util.exportExcel(response, list, "搴撳瓨绠$悊");
+ }
+
+ @Override
+ public void exportCopyTwo(HttpServletResponse response,Integer type) {
+ LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ customStorageLambdaQueryWrapper.groupBy(CustomStorage::getSupplierName, CustomStorage::getProductCategory, CustomStorage::getSpecificationModel);
+ List<CustomStorage> list = customStorageMapper.selectList(customStorageLambdaQueryWrapper);
+ // 璁$畻寰呭叆搴撴暟閲�
+ // 鏌ヨ閲囪喘璁板綍宸插叆搴撴暟閲�
+ List<Integer> collect = list.stream().map(CustomStorage::getId).collect(Collectors.toList());
+ if(CollectionUtils.isEmpty( collect)){
+ ExcelUtil<CustomStorage> util = new ExcelUtil<CustomStorage>(CustomStorage.class);
+ util.exportExcel(response, list, "搴撳瓨绠$悊");
+ return;
+ }
+ LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect);
+ procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType, type);
+ procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType, type);
+ List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty( procurementRecords)){
+ ExcelUtil<CustomStorage> util = new ExcelUtil<CustomStorage>(CustomStorage.class);
+ util.exportExcel(response, list, "搴撳瓨绠$悊");
+ return;
+ }
+ for (CustomStorage dto : list) {
+ // 鏍规嵁閲囪喘鍙拌处ID绛涢�夊搴旂殑鍑哄簱璁板綍
+ List<ProcurementRecordOut> collect1 = procurementRecords.stream()
+ .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()))
+ .collect(Collectors.toList());
+
+ // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
+ if(CollectionUtils.isEmpty(collect1)){
+ dto.setInboundNum0(dto.getInboundNum());
+ continue;
+ }
+
+ // 璁$畻宸插嚭搴撴暟閲忔�诲拰锛屽苟璁剧疆寰呭嚭搴撴暟閲�
+ BigDecimal totalInboundNum = collect1.stream()
+ .map(ProcurementRecordOut::getInboundNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
+ dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
+ }
+ ExcelUtil<CustomStorage> util = new ExcelUtil<CustomStorage>(CustomStorage.class);
util.exportExcel(response, list, "搴撳瓨绠$悊");
}
@@ -601,46 +658,13 @@
if(CollectionUtils.isEmpty( collect)){
return procurementPageDtoCopyIPage;
}
-// LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
-// procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect);
-// procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType, 2);
-// List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper);
-// if(CollectionUtils.isEmpty(procurementRecords)){
-// return procurementPageDtoCopyIPage;
-// }
-// for (ProcurementPageDtoCopy dto : procurementPageDtoCopyList) {
-// // 鏍规嵁閲囪喘鍙拌处ID绛涢�夊搴旂殑鍑哄簱璁板綍
-// List<ProcurementRecordOut> collect1 = procurementRecords.stream()
-// .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()))
-// .collect(Collectors.toList());
-//
-// // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
-// if(CollectionUtils.isEmpty(collect1)){
-// dto.setInboundNum0(dto.getInboundNum());
-// dto.setTotalInboundNum(BigDecimal.ZERO);
-// continue;
-// }
-//
-// // 璁$畻宸插嚭搴撴暟閲忔�诲拰锛屽苟璁剧疆寰呭嚭搴撴暟閲�
-// BigDecimal totalInboundNum = collect1.stream()
-// .map(ProcurementRecordOut::getInboundNum)
-// .reduce(BigDecimal.ZERO, BigDecimal::add);
-// // 鍑哄簱鏁伴噺 = 鎬绘暟閲� - 寰呭嚭搴撴暟閲�
-// dto.setTotalInboundNum(totalInboundNum);
-// // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
-// dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
-// // 搴撳瓨浠峰��
-// if(dto.getUnitPrice() != null){
-// dto.setTotalPrice(dto.getTotalInboundNum().multiply(dto.getUnitPrice()));
-// }
-// }
// 1. 鏌ヨ閲囪喘璁板綍宸插叆搴撶殑鍑哄簱璁板綍锛堟寜storageId鍒嗙粍锛�
LambdaQueryWrapper<ProcurementRecordOut> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect);
List<ProcurementRecordOut> recordOutList = procurementRecordOutMapper.selectList(queryWrapper);
// 2. 鎸塖alesLedgerProductId鍒嗙粍锛岀粺璁℃瘡涓猧d瀵瑰簲鐨勫凡鍑哄簱鏁伴噺鎬诲拰-宸插嚭搴撴暟閲�
- Map<Integer, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream()
+ Map<Long, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream()
.collect(Collectors.groupingBy(
ProcurementRecordOut::getSalesLedgerProductId,
Collectors.reducing(
@@ -665,13 +689,14 @@
Integer salesLedgerProductId = Integer.valueOf(Math.toIntExact(dto.getSalesLedgerProductId()));
// 鑾峰彇褰撳墠salesLedgerProductId瀵瑰簲鐨勫凡鍑哄簱鎬绘暟锛堥粯璁�0锛�
BigDecimal totalInboundNum = storageIdToTotalOutNumMap.getOrDefault(salesLedgerProductId, BigDecimal.ZERO);
-
+ // 宸插嚭搴撴暟閲�
+ dto.setTotalInboundNum(totalInboundNum);
// 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲忥紙鎬绘暟閲忕┖鍊煎垯榛樿0锛�
// BigDecimal totalNum = dto.getInboundNum() == null ? BigDecimal.ZERO : dto.getInboundNum();
BigDecimal totalNum = storageIdToTotalintNumMap.getOrDefault(salesLedgerProductId, BigDecimal.ZERO);
+ dto.setInboundNum(totalNum);
dto.setInboundNum0(totalNum.subtract(totalInboundNum));
- // 宸插嚭搴撴暟閲�
- dto.setTotalInboundNum(totalInboundNum);
+
// 搴撳瓨浠峰�� = 宸插嚭搴撴暟閲� * 鍗曚环锛堝崟浠风┖鍊煎垯榛樿0锛�
BigDecimal unitPrice = dto.getUnitPrice() == null ? BigDecimal.ZERO : dto.getUnitPrice();
dto.setTotalPrice(totalInboundNum.multiply(unitPrice));
@@ -791,7 +816,10 @@
procurementRecordLambdaQueryWrapper.eq(ProcurementRecordStorage::getSalesLedgerProductId, detail.getId())
.eq(ProcurementRecordStorage::getType, procurementDto.getType());
Long aLong = procurementRecordMapper.selectCount(procurementRecordLambdaQueryWrapper);
-
+ SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(detail.getId());
+ if (ObjectUtils.isNull(detail.getProductModelId())){
+ detail.setProductModelId(salesLedgerProduct.getProductModelId());
+ }
ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder()
.salesLedgerProductId(detail.getId())
.inboundBatches(aLong.equals(0L) ? "绗�1鎵规("+ procurementDto.getTypeName() +")" : "绗�"+ (aLong + 1) + "鎵规(" + procurementDto.getTypeName() + ")" )
@@ -804,7 +832,9 @@
.createUser(loginUser.getUserId())
.updateTime(LocalDateTime.now())
.updateUser(loginUser.getUserId())
- .createBy(procurementDto.getNickName());
+ .createBy(procurementDto.getNickName())
+ .productModelId(detail.getProductModelId())
+ .qualityInspectId(ObjectUtils.isNotNull(procurementDto.getQualityInspectId())?procurementDto.getQualityInspectId():0L);
this.save(procurementRecordBuilder.build());
// 鍏ュ簱鎴愬姛鍑忔帀閲囪喘鏁伴噺
// LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -905,4 +935,51 @@
return procurementPageDtoCopyIPage;
}
+ @Override
+ public IPage<ProductModel> listPageProductionStock(Page page, ProcurementPageDto dto) {
+ return productModelMapper.listPageProductionStock(page, dto);
+ }
+
+ @Override
+ public IPage<ProcurementPageDto> listPageByProductProduction(Page page, ProcurementPageDto procurementDto) {
+ IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordMapper.listPageByProductProduction(page, procurementDto);
+
+
+ List<ProcurementPageDto> procurementPageDtos = procurementPageDtoIPage.getRecords();
+ // 璁$畻寰呭叆搴撴暟閲�
+ // 鏌ヨ閲囪喘璁板綍宸插叆搴撴暟閲�
+ List<Integer> collect = procurementPageDtos.stream().map(ProcurementPageDto::getId).collect(Collectors.toList());
+ if(CollectionUtils.isEmpty( collect)){
+ return procurementPageDtoIPage;
+ }
+ LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect)
+ .eq(ProcurementRecordOut::getType, 4);
+ List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty( procurementRecords)){
+ return procurementPageDtoIPage;
+ }
+ for (ProcurementPageDto dto : procurementPageDtos) {
+ // 鏍规嵁閲囪喘鍙拌处ID绛涢�夊搴旂殑鍑哄簱璁板綍
+ List<ProcurementRecordOut> collect1 = procurementRecords.stream()
+ .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()))
+ .collect(Collectors.toList());
+
+ // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
+ if(CollectionUtils.isEmpty(collect1)){
+ dto.setInboundNum0(dto.getInboundNum());
+ continue;
+ }
+
+ // 璁$畻宸插嚭搴撴暟閲忔�诲拰锛屽苟璁剧疆寰呭嚭搴撴暟閲�
+ BigDecimal totalInboundNum = collect1.stream()
+ .map(ProcurementRecordOut::getInboundNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
+ dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
+ }
+ return procurementPageDtoIPage;
+ }
+
}
--
Gitblit v1.9.3