From c26270ef459e2ccf15bb019a05ac6d3934e2ad57 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期二, 16 一月 2024 12:35:55 +0800
Subject: [PATCH] # 拣货单删除功能

---
 src/main/java/com/zy/asrs/service/impl/PlaServiceImpl.java |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/PlaServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/PlaServiceImpl.java
index 81a1491..c95796c 100644
--- a/src/main/java/com/zy/asrs/service/impl/PlaServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/PlaServiceImpl.java
@@ -4,12 +4,17 @@
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.core.common.Cools;
+import com.core.exception.CoolException;
 import com.zy.asrs.entity.OrderDetl;
 import com.zy.asrs.entity.Pla;
 import com.zy.asrs.entity.PlaQty;
+import com.zy.asrs.entity.param.GlobleParameter;
 import com.zy.asrs.mapper.PlaMapper;
 import com.zy.asrs.service.PlaQtyService;
 import com.zy.asrs.service.PlaService;
+import com.zy.asrs.utils.SaasUtils;
+import com.zy.asrs.utils.Utils;
+import com.zy.system.entity.User;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -38,7 +43,7 @@
         if(!Cools.isEmpty(orderDetl.getBrand())){
             wrapper.eq("package_no",orderDetl.getBrand());
         }
-        wrapper.eq("status","宸插叆搴�");
+        wrapper.eq("status", GlobleParameter.PLA_STATUS_1);
         wrapper.ge("finger_melting", orderDetl.getFingerMeltingMin()).le("finger_melting", orderDetl.getFingerMeltingMax());
         wrapper.ge("fusing_point", orderDetl.getFusingPointMin()).le("fusing_point", orderDetl.getFusingPointMax());
         wrapper.ge("yellowness", orderDetl.getYellownessMin()).le("yellowness", orderDetl.getYellownessMax());
@@ -84,4 +89,57 @@
         }
 
     }
+
+    //閫�鍥�
+    public void returned(List<PlaQty> plaQties, User user) {
+        plaQties.forEach(plaQty -> {
+            PlaQty plaQtyOut = plaQtyService.selectById(plaQty.getId());
+            if(Cools.isEmpty(plaQtyOut.getReturned())){
+                plaQtyOut.setReturned(plaQty.getOrderWeight());
+            }else {
+                plaQtyOut.setReturned(plaQty.getOrderWeight()+plaQtyOut.getReturned());
+            }
+            plaQtyService.updateById(plaQtyOut);
+
+            PlaQty plaQtyReturned = new PlaQty();
+            plaQtyReturned.setBatch(plaQtyOut.getBatch());
+            plaQtyReturned.setPackageNo(plaQtyOut.getPackageNo());
+            plaQtyReturned.setCreateTime(new Date());
+            plaQtyReturned.setLocNo(plaQtyOut.getLocNo());
+            plaQtyReturned.setOrderNo(plaQtyOut.getOrderNo());
+            plaQtyReturned.setPakoutTime(Utils.getDateStr(new Date()));
+            plaQtyReturned.setOrderWeight(plaQty.getOrderWeight());
+            plaQtyReturned.setTransfer("閫�鍥炲叆搴�");
+            plaQtyReturned.setHandlerBy(user.getUsername());
+            plaQtyReturned.setCustomer(plaQtyOut.getCustomer());
+            plaQtyReturned.setMemo(plaQty.getMemo());
+            plaQtyService.insert(plaQtyReturned);
+
+            //鐩存帴鏇存柊pla鐨勫簱瀛�
+            Pla pla = this.selectByBatchAndPackageNo(plaQty.getBatch(), plaQty.getPackageNo());
+            //pla.setStatus(GlobleParameter.PLA_STATUS_0);
+            pla.setModifyTime(new Date());
+
+            pla.setWeightAnfme(pla.getWeightAnfme() + plaQty.getOrderWeight());
+            pla.setStatus(GlobleParameter.PLA_STATUS_1);
+            this.updateById(pla);
+
+            SaasUtils.insertLog(0,pla.getLocNo(),pla.getBatch()+","+pla.getPackageNo(),plaQty.getOrderWeight(),user.getUsername());
+
+        });
+    }
+
+    @Override
+    @Transactional
+    public void viladate(List<Pla> plas, User user) {
+        plas.forEach(pla -> {
+            if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00)){
+               throw new CoolException("閫変腑鐨勬暟鎹笉鏄殏鍏ュ簱鐘舵�侊紝璇锋牳瀵圭姸鎬�");
+            }
+            pla = this.selectById(pla.getId());
+            pla.setModifyTime(new Date());
+            pla.setStatus(GlobleParameter.PLA_STATUS_0);
+            this.updateById(pla);
+        });
+    }
 }

--
Gitblit v1.9.1