From fd7446cbdb4f852cd0d9098aa3f103fd15edbfbe Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期日, 04 一月 2026 14:28:52 +0800
Subject: [PATCH] 财务管理的存货核算获取数据接口,统计数据类
---
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java | 65 ++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 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 7b7f623..6e103b4 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -103,6 +103,7 @@
public int updatePro(ProcurementUpdateDto procurementDto) {
ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
procurementRecordStorageById.setInboundNum(procurementDto.getQuantityStock());
+ procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
procurementRecordStorageById.setUpdateTime(LocalDateTime.now());
return procurementRecordMapper.updateById(procurementRecordStorageById);
@@ -335,6 +336,69 @@
}
@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 int add(ProcurementAddDto procurementDto) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 鎵归噺鏂板
@@ -348,6 +412,7 @@
.salesLedgerProductId(detail.getId())
.inboundBatches(aLong.equals(0L) ? "绗�1鎵规" : "绗�"+ (aLong + 1) + "鎵规")
.inboundNum(detail.getInboundQuantity())
+ .warnNum(detail.getWarnNum())
.createTime(LocalDateTime.now())
.createUser(loginUser.getUserId())
.updateTime(LocalDateTime.now())
--
Gitblit v1.9.3