From d8c9b9afb41c368a08d7e05d0f624c98bf72042a Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期五, 06 六月 2025 11:18:56 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/model/TaskDto.java |  121 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/common/model/TaskDto.java b/src/main/java/com/zy/common/model/TaskDto.java
index 02f1d74..2da937d 100644
--- a/src/main/java/com/zy/common/model/TaskDto.java
+++ b/src/main/java/com/zy/common/model/TaskDto.java
@@ -1,10 +1,14 @@
 package com.zy.common.model;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
+import com.core.common.SpringUtils;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.LocDetl;
+import com.zy.asrs.service.LocDetlService;
 import lombok.Data;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 /**
  * Created by vincent on 2022/3/28
@@ -15,6 +19,7 @@
     private String locNo;
 
     private Integer staNo;
+    private List<LocDetlDto> locDetlDtos = new ArrayList<>();
 
     private List<LocDto> locDtos;
 
@@ -25,6 +30,12 @@
     public TaskDto(String locNo, Integer staNo) {
         this.locNo = locNo;
         this.staNo = staNo;
+    }
+
+    public TaskDto(String locNo, Integer staNo, LocDto locDto) {
+        this.locNo = locNo;
+        this.staNo = staNo;
+        this.locDtos.add(locDto);
     }
 
     public TaskDto(String locNo, Integer staNo, List<LocDto> locDtos) {
@@ -57,4 +68,110 @@
         return null;
     }
 
+//    public boolean isAll(){
+//        // 姹囨�讳笉鑰冭檻搴忓垪鐮�
+//        List<DetlDto> detlDtos = new ArrayList<>();
+//        for (LocDto locDto : this.getLocDtos()) {
+//            DetlDto dto = new DetlDto(locDto);
+//            if (DetlDto.has(detlDtos, dto)) {
+//                DetlDto detlDto = DetlDto.find(detlDtos, locDto);
+//                assert detlDto != null;
+//                detlDto.setAnfme(detlDto.getAnfme() + locDto.getAnfme());
+//            } else {
+//                detlDtos.add(new DetlDto(locDto));
+//            }
+//        }
+//
+//        // 鏌ヨ褰撳墠搴撲綅鍙锋墍鏈夌殑搴撳瓨鏄庣粏
+//        LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class);
+//        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo));
+//        if (locDetls == null || locDetls.isEmpty()){
+//            throw new CoolException("妫�绱㈠簱瀛樻槑缁嗗け璐ワ紝搴撲綅鍙�=" + this.locNo);
+//        }
+//        int sameNumber = 0;
+//        for (LocDetl locDetl : locDetls) {
+//            Iterator<DetlDto> iterator = detlDtos.iterator();
+//            while (iterator.hasNext()) {
+//                DetlDto dto = iterator.next();
+//                if (!dto.getMatnr().equals(locDetl.getMatnr())) {
+//                    continue;
+//                }
+//                if (Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) {
+//                    continue;
+//                }
+//                if (!Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(locDetl.getBatch())) {
+//                    continue;
+//                }
+//                if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) {
+//                    if (!dto.getBatch().equals(locDetl.getBatch())) {
+//                        continue;
+//                    }
+//                }
+//                if (dto.getAnfme() > locDetl.getAnfme()) {
+//                    throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+//                }
+//                if (dto.getAnfme().equals(locDetl.getAnfme())) {
+//                    sameNumber++;
+//                    iterator.remove();
+//                    break;
+//                }
+//            }
+//        }
+//        return sameNumber == locDetls.size();
+//    }
+public boolean isAll() {
+    // 娣辨嫹璐濓紝闃叉鍘熼泦鍚堣淇敼
+    List<LocDetlDto> locDetlDtosCp = new ArrayList<>(this.locDetlDtos);
+
+    // 鏌ヨ褰撳墠搴撲綅鍙锋墍鏈夊簱瀛樻槑缁�
+    LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class);
+    List<LocDetl> locDetls = locDetlService.selectList(
+            new EntityWrapper<LocDetl>().eq("loc_no", this.locNo)
+    );
+
+    if (locDetls == null || locDetls.isEmpty()) {
+        throw new CoolException("妫�绱㈠簱瀛樻槑缁嗗け璐ワ紝搴撲綅鍙�=" + this.locNo);
+    }
+
+    int sameNumber = 0;
+
+    for (LocDetl locDetl : locDetls) {
+        boolean matched = false;
+
+        System.out.println("褰撳墠搴撳瓨鏄庣粏: matnr=" + locDetl.getMatnr() + ", batch=" + locDetl.getBatch() + ", anfme=" + locDetl.getAnfme());
+
+        Iterator<LocDetlDto> iterator = locDetlDtosCp.iterator();
+        while (iterator.hasNext()) {
+            LocDetlDto dto = iterator.next();
+            String dtoMatnr = dto.getLocDetl().getMatnr();
+            String dtoBatch = dto.getLocDetl().getBatch();
+            Double dtoCount = dto.getCount();
+
+            System.out.println("姣旇緝瀵硅薄: matnr=" + dtoMatnr + ", batch=" + dtoBatch + ", count=" + dtoCount);
+
+            if (!dtoMatnr.equals(locDetl.getMatnr())) continue;
+            if (!Cools.eq(dtoBatch, locDetl.getBatch())) continue;
+
+            if (dtoCount > locDetl.getAnfme()) {
+                throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝鏁伴噺澶т簬搴撳瓨");
+            }
+
+            if (dtoCount.equals(locDetl.getAnfme())) {
+                sameNumber++;
+                matched = true;
+                iterator.remove();
+                System.out.println("鍖归厤鎴愬姛骞剁Щ闄よ椤癸紝褰撳墠 sameNumber = " + sameNumber + "锛屽墿浣欏尮閰嶆暟: " + locDetlDtosCp.size());
+                break;
+            }
+        }
+
+        if (!matched) {
+            System.out.println("鏈尮閰嶆垚鍔�: matnr=" + locDetl.getMatnr() + ", batch=" + locDetl.getBatch());
+        }
+    }
+
+    return sameNumber == locDetls.size();
+}
+
+
 }

--
Gitblit v1.9.1