From ab7b52a8884bb033e187331a437f3c9e31585a04 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 03 十二月 2024 14:19:55 +0800
Subject: [PATCH] #

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
index cdbe93b..c259f0a 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
@@ -1,5 +1,6 @@
 package com.zy.asrs.wms.asrs.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.framework.common.R;
@@ -8,6 +9,7 @@
 import com.zy.asrs.wms.asrs.entity.enums.*;
 import com.zy.asrs.wms.asrs.entity.param.FieldParam;
 import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
+import com.zy.asrs.wms.asrs.entity.param.LocAdjustParam;
 import com.zy.asrs.wms.asrs.entity.param.LocTransferParam;
 import com.zy.asrs.wms.asrs.service.*;
 import com.zy.asrs.wms.utils.LocUtils;
@@ -70,6 +72,8 @@
     private OrderUtils orderUtils;
     @Autowired
     private WaveDetlService waveDetlService;
+    @Autowired
+    private MatFieldService matFieldService;
 
     @Override
     public String generateTaskNo(Long taskType) {
@@ -686,6 +690,71 @@
     }
 
     @Override
+    @Transactional
+    public boolean locAdjust(LocAdjustParam param) {
+        if (param == null) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
+        }
+
+        if (Cools.isEmpty(param.getLocNo())) {
+            throw new CoolException("搴撲綅鍙蜂笉鑳戒负绌�");
+        }
+
+        if (param.getDetls() == null) {
+            throw new CoolException("搴撳瓨鏄庣粏涓嶈兘涓虹┖");
+        }
+
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getLocNo()));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦�");
+        }
+
+        //鍒犻櫎婧愬簱瀛�
+        locDetlService.removeLocDetl(loc.getId());
+
+        List<MatField> matFields = matFieldService.list(new LambdaQueryWrapper<MatField>().eq(MatField::getUnique, 1));
+        for (Map<String, Object> map : param.getDetls()) {
+            LocDetl locDetl = JSON.parseObject(JSON.toJSONString(map), LocDetl.class);
+            HashMap<String, Object> uniqueFields = new HashMap<>();
+            for (Map.Entry<String, Object> entry : map.entrySet()) {
+                for (MatField field : matFields) {
+                    if (entry.getKey().equals(field.getName())) {
+                        uniqueFields.put(entry.getKey(), entry.getValue());
+                    }
+                }
+            }
+            locDetl.setAnfme(Double.parseDouble(map.get("qty").toString()));
+            locDetl.syncFieldMap(uniqueFields);
+
+            if (locDetl.getAnfme() <= 0D) {
+                throw new CoolException("鏁伴噺涓嶈兘灏忎簬0");
+            }
+
+            locDetl.setId(null);
+            locDetl.setLocId(loc.getId());
+            locDetl.setLocNo(loc.getLocNo());
+            boolean save = locDetlService.save(locDetl);
+            if (!save) {
+                throw new CoolException("搴撳瓨璋冩暣澶辫触");
+            }
+
+            //鎻掑叆搴撳瓨鏄庣粏瀛楁
+            for (MatField matField : matFields) {
+                LocDetlField locDetlField = new LocDetlField();
+                locDetlField.setDetlId(locDetl.getId());
+                locDetlField.setFieldId(matField.getId());
+                locDetlField.setName(matField.getName());
+                locDetlField.setValue(Optional.ofNullable(uniqueFields.get(matField.getName()).toString()).orElse(""));
+                locDetlFieldService.save(locDetlField);
+            }
+
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional
     public boolean locTransfer(LocTransferParam param) {
         if (param == null) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖");

--
Gitblit v1.9.1