From 2a9c3934bb093c978a54a1c3e220e6a120855e77 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 09 一月 2026 15:11:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jtwy' into jtwy
---
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java | 122 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 115 insertions(+), 7 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 ff534de..3820823 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.OrderUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
@@ -110,6 +111,8 @@
procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
procurementRecordStorageById.setUpdateTime(LocalDateTime.now());
+ procurementRecordStorageById.setUnitPrice(procurementDto.getUnitPrice());
+ procurementRecordStorageById.setTotalPrice(procurementDto.getTotalPrice());
return procurementRecordMapper.updateById(procurementRecordStorageById);
}
@@ -193,15 +196,28 @@
if(salesLedgerProduct == null){
throw new RuntimeException("閿�鍞彴璐︿骇鍝佷笉瀛樺湪");
}
+ // 鏍规嵁澶х被锛岃鏍兼煡璇㈡墍鏈変骇鍝乮d
+ LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getProductCategory, salesLedgerProduct.getProductCategory())
+ .eq(SalesLedgerProduct::getSpecificationModel, salesLedgerProduct.getSpecificationModel())
+ .eq(SalesLedgerProduct::getType, 1);
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(salesLedgerProductLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty(salesLedgerProducts)){
+ throw new RuntimeException("娌℃湁鎵惧埌瀵瑰簲鐨勪骇鍝�");
+ }
salesLedgerProduct.setMinStock(procurementDto.getMinStock());
salesLedgerProductMapper.updateById(salesLedgerProduct);
- ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
- procurementRecordStorageById.setCreateBy(sysUser.getNickName());
- procurementRecordStorageById.setCreateUser(sysUser.getUserId());
- procurementRecordStorageById.setUpdateTime(LocalDateTime.parse(entryDateStr,df));
- procurementRecordStorageById.setUpdateUser(loginUser.getUserId());
- procurementRecordStorageById.setCreateTime(LocalDateTime.parse(createTimeStr,df));
- procurementRecordMapper.updateById(procurementRecordStorageById);
+ LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ procurementRecordStorageLambdaQueryWrapper.in(ProcurementRecordStorage::getSalesLedgerProductId, salesLedgerProducts.stream().map(SalesLedgerProduct::getId).collect(Collectors.toList()));
+ ProcurementRecordStorage procurementRecordStorage = ProcurementRecordStorage.builder().build();
+ procurementRecordStorage.setUnitPrice(procurementDto.getUnitPrice());
+ procurementRecordStorage.setTotalPrice(procurementDto.getTotalPrice());
+ procurementRecordStorage.setCreateBy(sysUser.getNickName());
+ procurementRecordStorage.setCreateUser(sysUser.getUserId());
+ procurementRecordStorage.setUpdateTime(LocalDateTime.parse(entryDateStr,df));
+ procurementRecordStorage.setUpdateUser(loginUser.getUserId());
+ procurementRecordStorage.setCreateTime(LocalDateTime.parse(createTimeStr,df));
+ procurementRecordMapper.update(procurementRecordStorage,procurementRecordStorageLambdaQueryWrapper);
return 0;
}
@@ -400,6 +416,68 @@
}
@Override
+ public InventoryInformationDto getReportList() {
+ InventoryInformationDto inventoryInformationDto = new InventoryInformationDto();
+ IPage<ProcurementPageDto> procurementPageDtoIPage = this.listPage(new Page<>(1, -1), new ProcurementPageDto());
+ if(CollectionUtils.isEmpty(procurementPageDtoIPage.getRecords())){
+ return inventoryInformationDto;
+ }
+ // 璁$畻鎬诲簱瀛樻暟閲�
+ inventoryInformationDto.setTotalInventoryCount(procurementPageDtoIPage.getRecords().stream()
+ .map(ProcurementPageDto::getInboundNum0)
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
+ .intValue());
+ // 璁$畻鎬诲簱瀛橀噾棰�-ProcurementPageDto閲屾瘡涓璞$殑inboundNum0鍊煎拰taxInclusiveUnitPrice鐨勪箻绉紝涔嬪悗鐩稿姞寰楀埌鎬诲簱瀛橀噾棰�
+ BigDecimal totalInventoryValue = procurementPageDtoIPage.getRecords().stream()
+ // 杩囨护绌哄璞★紝閬垮厤NPE
+ .filter(Objects::nonNull)
+ // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+ .map(dto -> {
+ // 鍏ュ簱鏁伴噺锛歯ull 鈫� 0
+ BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO);
+ // 鍚◣鍗曚环锛歯ull 鈫� 0
+ BigDecimal taxInclusiveUnitPrice = Optional.ofNullable(dto.getTaxInclusiveUnitPrice()).orElse(BigDecimal.ZERO);
+ // 璁$畻鍗曚釜瀵硅薄鐨勫簱瀛橀噾棰濓細鏁伴噺 脳 鍚◣鍗曚环
+ return inboundNum0.multiply(taxInclusiveUnitPrice);
+ })
+ // 鎵�鏈夊崟涓噾棰濇眰鍜岋紝鍒濆鍊间负0
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ // 璁剧疆鎬诲簱瀛橀噾棰�
+ inventoryInformationDto.setTotalInventoryValue(totalInventoryValue);
+ // 璁$畻搴撳瓨鍙樺姩鏁伴噺-ProcurementPageDto閲屾瘡涓璞$殑inboundNum鍊煎拰inboundNum0鍊肩殑宸�硷紝涔嬪悗鐩稿姞寰楀埌搴撳瓨鍙樺姩鏁伴噺
+ inventoryInformationDto.setInventoryChangeCount(procurementPageDtoIPage.getRecords().stream()
+ // 杩囨护绌哄璞★紝閬垮厤NPE
+ .filter(Objects::nonNull)
+ // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+ .map(dto -> {
+ // 鍏ュ簱鏁伴噺锛歯ull 鈫� 0
+ BigDecimal inboundNum = Optional.ofNullable(dto.getInboundNum()).orElse(BigDecimal.ZERO);
+ // 寰呭嚭搴撴暟閲忥細null 鈫� 0
+ BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO);
+ // 璁$畻鍗曚釜瀵硅薄鐨勫簱瀛樺彉鍔ㄦ暟閲忥細鏁伴噺 - 寰呭嚭搴撴暟閲�
+ return inboundNum.subtract(inboundNum0);
+ })
+ // 鎵�鏈夊崟涓彉鍔ㄦ暟閲忔眰鍜岋紝鍒濆鍊间负0
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
+ .intValue());
+ // 璁$畻搴撳瓨鍙樺姩閲戦ProcurementPageDto閲屾瘡涓璞$殑taxInclusiveTotalPrice鍊肩殑鍜�
+ BigDecimal inventoryChangeValue = procurementPageDtoIPage.getRecords().stream()
+ // 杩囨护绌哄璞★紝閬垮厤NPE
+ .filter(Objects::nonNull)
+ // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+ .map(dto -> {
+ // 鍚◣鎬讳环锛歯ull 鈫� 0
+ BigDecimal taxInclusiveTotalPrice = Optional.ofNullable(dto.getTaxInclusiveTotalPrice()).orElse(BigDecimal.ZERO);
+ // 璁$畻鍗曚釜瀵硅薄鐨勫叆搴撳簱瀛橀噾棰濓細鍚◣鎬讳环
+ return taxInclusiveTotalPrice;
+ })
+ // 鎵�鏈夊崟涓彉鍔ㄩ噾棰濇眰鍜岋紝鍒濆鍊间负0
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ // 璁剧疆搴撳瓨鍙樺姩閲戦
+ inventoryInformationDto.setInventoryChangeValue(inventoryChangeValue.subtract(totalInventoryValue));
+ return inventoryInformationDto;
+ }
+ @Override
public IPage<ProcurementPageDto> listPageByProduction(Page page, ProcurementPageDto procurementDto) {
IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordMapper.listPageByProduction(page, procurementDto);
List<ProcurementPageDto> procurementPageDtos = procurementPageDtoIPage.getRecords();
@@ -452,6 +530,7 @@
Long aLong = customStorageMapper.selectCount(null);
item.setInboundBatches(aLong.equals(0L) ? "绗�1鎵规(鑷畾涔夊叆搴�)" : "绗�"+ (aLong + 1) + "鎵规(鑷畾涔夊叆搴�)" );
item.setCreateBy(loginUser.getNickName());
+ item.setCode(OrderUtils.countTodayByCreateTime(customStorageMapper, ""));
customStorageMapper.insert(item);
});
return AjaxResult.success("鑷畾涔夊叆搴撴垚鍔�");
@@ -632,6 +711,35 @@
}
@Override
+ public int updateManagementByCustom(ProcurementManagementUpdateDto procurementDto) {
+ CustomStorage customStorage = customStorageMapper.selectById(procurementDto.getId());
+ if(customStorage == null){
+ throw new RuntimeException("鏉愭枡搴撳瓨涓嶅瓨鍦�");
+ }
+ LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ customStorageLambdaQueryWrapper.eq(CustomStorage::getProductCategory, customStorage.getProductCategory())
+ .eq(CustomStorage::getSpecificationModel, customStorage.getSpecificationModel());
+ CustomStorage one = new CustomStorage();
+ one.setTaxInclusiveUnitPrice(procurementDto.getTaxInclusiveUnitPrice());
+ one.setTaxInclusiveTotalPrice(procurementDto.getTaxInclusiveTotalPrice());
+ return customStorageMapper.update(one,customStorageLambdaQueryWrapper);
+ }
+
+ @Override
+ public BigDecimal getProcurementAmount(Long salesProductId) {
+ LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ procurementRecordStorageLambdaQueryWrapper.eq(ProcurementRecordStorage::getSalesLedgerProductId, salesProductId)
+ .eq(ProcurementRecordStorage::getType, 2);
+ List<ProcurementRecordStorage> procurementRecordStorages = procurementRecordMapper.selectList(procurementRecordStorageLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty( procurementRecordStorages)){
+ return BigDecimal.ZERO;
+ }
+ return procurementRecordStorages.stream()
+ .map(ProcurementRecordStorage::getInboundNum)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ }
+
+ @Override
public int add(ProcurementAddDto procurementDto) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 鎵归噺鏂板
--
Gitblit v1.9.3