From 7488018d52edaafcd4e541c5fdeada8dd2e47b11 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期一, 22 十二月 2025 16:49:18 +0800
Subject: [PATCH] Merge branch 'jtwy' of http://114.132.189.42:9002/r/product-inventory-management-after into jtwy

---
 src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java
index d1aaae9..2135a8b 100644
--- a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java
@@ -22,12 +22,16 @@
 import com.ruoyi.production.service.SalesLedgerWorkService;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.sales.mapper.LossMapper;
+import com.ruoyi.sales.pojo.Loss;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -47,12 +51,43 @@
 
     private final SysUserMapper sysUserMapper;
 
+    private final LossMapper lossMapper;
+
     private final SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
 
     @Override
     public IPage<SalesLedgerWorkDto> listPage(Page page, SalesLedgerWorkDto salesLedgerWorkDto) {
         IPage<SalesLedgerWorkDto> iPage = salesLedgerWorkMapper.listPage(page, salesLedgerWorkDto);
+        List<Loss> losses = lossMapper.selectList(null);
+        if(!CollectionUtils.isEmpty(losses)){
+            iPage.getRecords().forEach(item -> {
+                String[] split = item.getSpecificationModel().split("\\*");
+                if(split.length == 2 && isNumeric(split[1]) && isNumeric(split[0])){
+                    // 璁$畻鎹熻�楋紙100000浠h〃 鎹熻�楃殑 100 鍜� 鍗曚綅杞崲鐨�1000锛�
+                    BigDecimal divide = new BigDecimal(split[0])
+                            .multiply(new BigDecimal(split[1]))
+                            .multiply(item.getFinishedNum())
+                            .multiply(losses.get(0).getRate())
+                            .divide(new BigDecimal(100000), 2, RoundingMode.HALF_UP);
+                    item.setLoss(divide.toString());
+                }
+
+            });
+        }
         return iPage;
+    }
+
+    public static boolean isNumeric(String str) {
+        if (str == null || str.isEmpty()) {
+            return false;
+        }
+        // 閬嶅巻瀛楃涓茬殑姣忎釜瀛楃锛屾鏌ユ槸鍚︿负鏁板瓧
+        for (int i = 0; i < str.length(); i++) {
+            if (!Character.isDigit(str.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
     }
 
     private final ProcurementRecordServiceImpl procurementRecordService;
@@ -94,6 +129,8 @@
         Details details1 = new Details();
         details1.setInboundQuantity(productionReportDto.getFinishedNum());
         details1.setId(Integer.parseInt(salesLedgerWork.getSalesLedgerProductId().toString()));
+        details1.setUnitPrice(productionReportDto.getUnitPrice());
+        details1.setTotalPrice(productionReportDto.getTotalPrice());
         details.add(details1);
         procurementRecordOutAdd.setDetails(details);
         procurementRecordService.add(procurementRecordOutAdd);

--
Gitblit v1.9.3