From 0c8a2d35fdf8e402ad34355c545c69a1750d759c Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 09 十二月 2025 17:26:04 +0800
Subject: [PATCH] yys 1.销售台账同步日期 2.销售台账返回车牌号 3.库存管理分组条件修改 4.排产增加产线字段 5.首页增加条幅提醒

---
 src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
index f9d6105..cc6292e 100644
--- a/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -18,16 +18,20 @@
 import com.ruoyi.production.service.SalesLedgerSchedulingService;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.sales.mapper.LossMapper;
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.pojo.Loss;
 import com.ruoyi.sales.pojo.SalesLedgerProduct;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -62,6 +66,7 @@
         salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerProductId, collect)
                 .ne(SalesLedgerWork::getStatus, 1);
         List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper);
+        List<SalesLedgerSchedulingDto> list1 = new ArrayList<>();
         list.getRecords().forEach(i -> {
             // 鑾峰彇瀹屾垚鏁伴噺
             i.setSuccessNum(salesLedgerWorks
@@ -69,16 +74,40 @@
                     .filter(j -> j.getSalesLedgerProductId().equals(i.getSalesLedgerProductId()))
                     .map(SalesLedgerWork::getFinishedNum)
                     .reduce(BigDecimal.ZERO, BigDecimal::add));
+
+            // 璁$畻鐢熶骇鎬婚噺 = 瑙勬牸 * 鏁伴噺 / 1000
+            String[] split = i.getSpecificationModel().split("\\*");
+            if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){
+                BigDecimal multiply = new BigDecimal(split[0])
+                        .multiply(new BigDecimal(split[1])
+                                .multiply(i.getQuantity()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
+                i.setTotalProduction(multiply);
+            }
+
             // 鐘舵�� = 鏁伴噺鍜屽畬宸ユ暟閲忔瘮杈�
             if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){
                 i.setStatus("鏈畬鎴�");
-            } else if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){
+            } else if(i.getQuantity().compareTo(i.getSchedulingNum()) <= 0){
                 i.setStatus("宸插畬鎴�");
             }else{
                 i.setStatus("鐢熶骇涓�");
             }
+
         });
         return list;
+    }
+
+    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;
     }
 
     @Override
@@ -210,8 +239,14 @@
                 totalNum.addAndGet(productionNum.intValue());
             }
         });
-        return new BigDecimal(totalNum.get());
+        // 闇�瑕� / 鎹熻�楃巼
+        Loss loss = lossMapper.selectOne(new LambdaQueryWrapper<Loss>().last("limit 1"));
+        BigDecimal lossNum = loss == null ? new BigDecimal(6) : loss.getRate(); //娌℃湁鎹熻�楃巼鍒欓粯璁や负6
+
+        return new BigDecimal(totalNum.get()).multiply(new BigDecimal(100)).divide(lossNum, 2,RoundingMode.HALF_UP);
     }
+
+    private final LossMapper lossMapper;
 
 
     /**
@@ -256,14 +291,16 @@
 //        salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerSchedulingId, collect)
 //                .ne(SalesLedgerWork::getStatus, 1);
 //        List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper);
-//        list.getRecords().forEach(i -> {
-//            // 鑾峰彇瀹屾垚鏁伴噺
-//            i.setSuccessNum(salesLedgerWorks
-//                    .stream()
-//                    .filter(j -> j.getSalesLedgerSchedulingId().equals(i.getId()))
-//                    .map(SalesLedgerWork::getFinishedNum)
-//                    .reduce(BigDecimal.ZERO, BigDecimal::add));
-//        });
+        list.getRecords().forEach(i -> {
+            // 璁$畻鐢熶骇鎬婚噺 = 瑙勬牸 * 鏁伴噺 / 1000
+            String[] split = i.getSpecificationModel().split("\\*");
+            if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){
+                BigDecimal multiply = new BigDecimal(split[0])
+                        .multiply(new BigDecimal(split[1])
+                                .multiply(i.getSuccessNum()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
+                i.setTotalProduction(multiply);
+            }
+        });
         return list;
     }
 
@@ -305,6 +342,7 @@
                     .salesLedgerSchedulingId(salesLedgerScheduling.getId())
                     .salesLedgerId(salesLedgerScheduling.getSalesLedgerId())
                     .remark(processSchedulingDto.getRemark())
+                    .productionLine(processSchedulingDto.getProductionLine())
                     .type(processSchedulingDto.getType())
                     .loss(processSchedulingDto.getLoss())
                     .receive(processSchedulingDto.getReceive())

--
Gitblit v1.9.3