From d0226747665355acecd5b4f2b5c0beb020586729 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期五, 17 一月 2025 15:37:32 +0800
Subject: [PATCH] # 23. PDA拣货单据,勾选或点击确认按钮后,完成当前单据 (已完成) 24. PDA出库成功后,界面数据重置,避免重复操作  (已修复) 25. PDA接口请求,添加一个Loading遮档  (已修复) 27. 非平库单据,在平库可做入库操作  (已修复) 28. 平库已组拖数据,组拖完成后依然可组拖  (已修复) 29. 平库入库后,订单明细没有添加(已修复) 30. 平库入库后,单据类型没有修改(已修复) 31. 没有绑定播种位,不能进行播种,前后端都需加判定(已修复) 33. 平库入库未修改入库已完成数量(已修复) 34. cacheSite缓存站点逻辑需重新梳理,入库生成波次时(已完成) 35. PDA添加发货确认,默认全选 (已修复) 36. 大屏获取任务时,是由容器到达的拖盘码确认通知 (已修复) 37. 拣货单序号不显示 问题修复 (已修复) 42. pda发货确认,添加不同颜色区分是否全部完成拣货,绿色全部拣货完成,红色完成部分拣货(已修复) 43. CTU入库完成后,订单明细没有删除,执行中数量清空(已修复) 44. 平库入库完成后,历史档明细完成数量没有更新 (已修复) 45. PDA料号不显示  (已修复) 46. 发货完成后,波次管理数据未加入历史档 (已修复)

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java |  602 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 464 insertions(+), 138 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
index 90bbd5a..953f7f6 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
@@ -1,138 +1,464 @@
-package com.zy.asrs.wms.asrs.timer;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
-import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
-import com.zy.asrs.framework.exception.CoolException;
-import com.zy.asrs.wms.asrs.entity.*;
-import com.zy.asrs.wms.asrs.entity.enums.LocStsType;
-import com.zy.asrs.wms.asrs.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
-
-import java.util.Date;
-import java.util.List;
-
-@Component
-public class TaskTimer {
-
-    @Autowired
-    private TaskService taskService;
-    @Autowired
-    private TaskDetlService taskDetlService;
-    @Autowired
-    private TaskDetlFieldService taskDetlFieldService;
-    @Autowired
-    private LocService locService;
-    @Autowired
-    private LocDetlService locDetlService;
-    @Autowired
-    private LocDetlFieldService locDetlFieldService;
-    @Autowired
-    private WaitPakinService waitPakinService;
-
-    @Scheduled(cron = "0/3 * * * * ? ")
-    @Transactional
-    public void inExecute() {
-        InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
-        try {
-            //鑾峰彇鍏ュ簱瀹屾垚浠诲姟
-            List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, 99));
-            if (list.isEmpty()) {
-                return;
-            }
-
-            for (Task task : list) {
-                //鍚屾鏁版嵁
-                Long hostId = task.getHostId();
-                switch (task.getTaskType().intValue()) {
-                    case 1://鍏ュ簱
-                        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
-                        if(loc == null) {
-                            throw new CoolException("搴撲綅涓嶅瓨鍦�");
-                        }
-
-                        if(loc.getLocStsId() != LocStsType.S.val()){
-                            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
-                        }
-
-                        loc.setLocStsId(LocStsType.F.val());
-                        loc.setUpdateTime(new Date());
-                        loc.setBarcode(task.getBarcode());
-                        if (!locService.updateById(loc)) {
-                            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
-                        }
-
-
-                        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
-                        if(taskDetls.isEmpty()) {
-                            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
-                        }
-
-                        //娣诲姞搴撳瓨鏄庣粏
-                        for (TaskDetl taskDetl : taskDetls) {
-                            LocDetl locDetl = new LocDetl();
-                            locDetl.setLocId(loc.getId());
-                            locDetl.setLocNo(loc.getLocNo());
-                            locDetl.setMatId(taskDetl.getMatId());
-                            locDetl.setMatnr(taskDetl.getMat$().getMatnr());
-                            locDetl.setOrderNo(taskDetl.getOrderNo());
-                            locDetl.setBatch(taskDetl.getBatch());
-                            locDetl.setAnfme(taskDetl.getAnfme());
-                            locDetl.setHostId(hostId);
-                            if (!locDetlService.save(locDetl)) {
-                                throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
-                            }
-
-                            //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
-                            List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
-                            for (TaskDetlField detlField : detlFields) {
-                                LocDetlField locDetlField = new LocDetlField();
-                                locDetlField.setDetlId(locDetl.getId());
-                                locDetlField.setFieldId(detlField.getFieldId());
-                                locDetlField.setName(detlField.getName());
-                                locDetlField.setHostId(hostId);
-                                if (!locDetlFieldService.save(locDetlField)) {
-                                    throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
-                                }
-                            }
-                        }
-
-                        //鍒犻櫎缁勬墭閫氱煡妗�
-                        waitPakinService.remove(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
-
-                        break;
-                }
-
-                task.setTaskSts(100L);//100.搴撳瓨鏇存柊瀹屾垚
-                task.setUpdateTime(new Date());
-                if (!taskService.updateById(task)) {
-                    throw new CoolException("搴撳瓨鏇存柊澶辫触");
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        }finally {
-            InterceptorIgnoreHelper.clearIgnoreStrategy();
-        }
-    }
-
-    @Scheduled(cron = "0/3 * * * * ? ")
-    @Transactional
-    public void outExecute() {
-        InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
-        try {
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        }finally {
-            InterceptorIgnoreHelper.clearIgnoreStrategy();
-        }
-    }
-
-}
+package com.zy.asrs.wms.asrs.timer;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
+import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
+import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wms.asrs.entity.*;
+import com.zy.asrs.wms.asrs.entity.enums.LocStsType;
+import com.zy.asrs.wms.asrs.entity.enums.TaskStsType;
+import com.zy.asrs.wms.asrs.service.*;
+import io.jsonwebtoken.lang.Collections;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class TaskTimer {
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private TaskDetlService taskDetlService;
+
+    @Autowired
+    private TaskDetlFieldService taskDetlFieldService;
+
+    @Autowired
+    private LocService locService;
+
+    @Autowired
+    private LocDetlService locDetlService;
+
+    @Autowired
+    private LocDetlFieldService locDetlFieldService;
+
+    @Autowired
+    private WaitPakinService waitPakinService;
+
+    @Autowired
+    private WaitPakinLogService waitPakinLogService;
+
+    @Autowired
+    private TaskDetlLogService taskDetlLogService;
+
+    @Autowired
+    private TaskDetlFieldLogService taskDetlFieldLogService;
+
+    @Autowired
+    private OrderService orderService;
+
+    @Autowired
+    private OrderDetlService orderDetlService;
+
+    @Autowired
+    private CacheSiteService cacheSiteService;
+
+
+    /**
+     * 鍏ュ簱鎵ц浠诲姟
+     */
+    @Scheduled(cron = "0/3 * * * * ? ")
+    @Transactional(rollbackFor = Exception.class)
+    public void inExecute() {
+        InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
+        try {
+            //鑾峰彇鍏ュ簱瀹屾垚浠诲姟
+            List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, TaskStsType.COMPLETE_IN.id));
+            if (list.isEmpty()) {
+                return;
+            }
+
+            for (Task task : list) {
+                //鍚屾鏁版嵁
+                switch (task.getTaskType().intValue()) {
+                    case 1://鍏ュ簱
+                        executeTask1(task);
+                        break;
+                    case 11://搴撲綅绉昏浆
+                        executeTask11(task);
+                        break;
+                    case 53://鎷f枡鍐嶅叆搴�
+                        executeTask53(task);
+                        break;
+                    default:
+                        throw new CoolException("鏈煡浠诲姟绫诲瀷");
+                }
+
+                task.setTaskSts(TaskStsType.UPDATED_IN.id);//100.搴撳瓨鏇存柊瀹屾垚
+                task.setUpdateTime(new Date());
+                if (!taskService.updateById(task)) {
+                    throw new CoolException("搴撳瓨鏇存柊澶辫触");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        } finally {
+            InterceptorIgnoreHelper.clearIgnoreStrategy();
+        }
+    }
+
+
+    /**
+     * 1. 瀹氭椂鎷夊彇闇�瑕佹墽琛屽洖搴撲换鍔″垪琛ㄦ暟鎹紝
+     * 2. 鍒犻櫎鍘熷搴撲綅鏄庣粏锛屽師濮嬪簱浣嶇姸鎬佺疆鎴怬.绌哄簱
+     * 3.
+     */
+    @Scheduled(cron = "0/3 * * * * ? ")
+    @Transactional(rollbackFor = Exception.class)
+    public void rollbackStock() {
+        //鑾峰彇闇�瑕佹墽琛屽洖搴撶殑浠诲姟锛屾洿鏂板簱瀛樹俊鎭�
+        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskType, 53).eq(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START.id));
+        if (tasks.isEmpty()) {
+            return;
+        }
+        tasks.forEach(task -> {
+            //鍒犻櫎鍘熷搴撲綅鏄庣粏锛岀姸鎬佺疆涓篛.绌哄簱
+            executeTask103(task);
+        });
+        //todo 闇�娣诲姞涓�涓换鍔$姸鎬佹垨涓存椂鐘舵�侊紝鍚﹀垯浼氫竴鐩磋疆寰紝绋嬪簭鎶ラ敊锛堝簱浣嶇姸鎬佷笉澶勪簬R.鍑哄簱棰勭害锛�
+    }
+
+
+    @Scheduled(cron = "0/10 * * * * ? ")
+    @Transactional(rollbackFor = Exception.class)
+    public void outExecute() {
+        InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
+        try {
+            //鑾峰彇鍑哄簱瀹屾垚浠诲姟
+            List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id));
+            if (list.isEmpty()) {
+                return;
+            }
+            for (Task task : list) {
+                //鍚屾鏁版嵁
+                switch (task.getTaskType().intValue()) {
+                    case 101://鍑哄簱xx
+                        executeTask101(task);
+                        break;
+                    case 103://鎷f枡
+                        executeTask103(task);
+                        break;
+                    default:
+                        throw new CoolException("鏈煡浠诲姟绫诲瀷");
+                }
+                task.setTaskSts(TaskStsType.UPDATED_OUT.id);//200.搴撳瓨鏇存柊瀹屾垚
+                if (!taskService.updateById(task)) {
+                    throw new CoolException("搴撳瓨鏇存柊澶辫触");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        } finally {
+            InterceptorIgnoreHelper.clearIgnoreStrategy();
+        }
+    }
+
+    //鍏ュ簱
+    private void executeTask1(Task task) {
+        Long hostId = task.getHostId();
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦�");
+        }
+
+        if (loc.getLocStsId() != LocStsType.S.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
+        }
+
+        loc.setLocStsId(LocStsType.F.val());
+        loc.setUpdateTime(new Date());
+        loc.setBarcode(task.getBarcode());
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+
+        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+        if (taskDetls.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        //娣诲姞搴撳瓨鏄庣粏
+        for (TaskDetl taskDetl : taskDetls) {
+            LocDetl locDetl = new LocDetl();
+            locDetl.setLocId(loc.getId());
+            locDetl.setLocNo(loc.getLocNo());
+            locDetl.setMatId(taskDetl.getMatId());
+            locDetl.setMatnr(taskDetl.getMat$().getMatnr());
+            locDetl.setOrderNo(taskDetl.getOrderNo());
+            locDetl.setBatch(taskDetl.getBatch());
+            locDetl.setAnfme(taskDetl.getAnfme());
+            locDetl.setHostId(hostId);
+            if (!locDetlService.save(locDetl)) {
+                throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
+            }
+
+            //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
+            List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
+            for (TaskDetlField detlField : detlFields) {
+                LocDetlField locDetlField = new LocDetlField();
+                locDetlField.setDetlId(locDetl.getId());
+                locDetlField.setFieldId(detlField.getFieldId());
+                locDetlField.setName(detlField.getName());
+                locDetlField.setValue(detlField.getValue());
+                locDetlField.setHostId(hostId);
+                if (!locDetlFieldService.save(locDetlField)) {
+                    throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+                }
+            }
+        }
+        //缁勬墭閫氱煡妗h浆鍘嗗彶妗�
+        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
+        if (waitPakins.isEmpty()) {
+            throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
+        }
+        for (WaitPakin waitPakin : waitPakins) {
+            WaitPakinLog waitPakinLog = new WaitPakinLog();
+            waitPakinLog.sync(waitPakin);
+            waitPakinLog.setId(null);
+            if (!waitPakinLogService.save(waitPakinLog)) {
+                throw new CoolException("缁勬墭閫氱煡妗h浆鍘嗗彶妗eけ璐�");
+            }
+
+            //鍒犻櫎缁勬墭閫氱煡妗�
+            waitPakinService.removeById(waitPakin.getId());
+        }
+    }
+
+    //搴撲綅绉昏浆
+    private void executeTask11(Task task) {
+        Long hostId = task.getHostId();
+
+        Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+        if (originLoc == null) {
+            throw new CoolException("婧愬簱浣嶄笉瀛樺湪");
+        }
+
+        if (originLoc.getLocStsId() != LocStsType.R.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+        }
+
+        Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
+        if (targetLoc == null) {
+            throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�");
+        }
+
+        if (targetLoc.getLocStsId() != LocStsType.S.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
+        }
+
+        originLoc.setLocStsId(LocStsType.O.val());
+        originLoc.setUpdateTime(new Date());
+        originLoc.setBarcode("");
+        if (!locService.updateById(originLoc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+
+        targetLoc.setLocStsId(LocStsType.F.val());
+        targetLoc.setUpdateTime(new Date());
+        targetLoc.setBarcode(task.getBarcode());
+        if (!locService.updateById(targetLoc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+
+        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+        if (taskDetls.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        //娣诲姞搴撳瓨鏄庣粏
+        for (TaskDetl taskDetl : taskDetls) {
+            LocDetl locDetl = new LocDetl();
+            locDetl.setLocId(targetLoc.getId());
+            locDetl.setLocNo(targetLoc.getLocNo());
+            locDetl.setMatId(taskDetl.getMatId());
+            locDetl.setMatnr(taskDetl.getMat$().getMatnr());
+            locDetl.setOrderNo(taskDetl.getOrderNo());
+            locDetl.setBatch(taskDetl.getBatch());
+            locDetl.setAnfme(taskDetl.getAnfme());
+            locDetl.setHostId(hostId);
+            if (!locDetlService.save(locDetl)) {
+                throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
+            }
+
+            //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
+            List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
+            for (TaskDetlField detlField : detlFields) {
+                LocDetlField locDetlField = new LocDetlField();
+                locDetlField.setDetlId(locDetl.getId());
+                locDetlField.setFieldId(detlField.getFieldId());
+                locDetlField.setName(detlField.getName());
+                locDetlField.setValue(detlField.getValue());
+                locDetlField.setHostId(hostId);
+                if (!locDetlFieldService.save(locDetlField)) {
+                    throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+                }
+            }
+        }
+
+        List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, originLoc.getId()));
+        for (LocDetl locDetl : locDetls) {
+            boolean remove = locDetlFieldService.remove(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()));
+            boolean result = locDetlService.removeById(locDetl.getId());
+            if (!result) {
+                throw new CoolException("娓呴櫎鏄庣粏澶辫触");
+            }
+        }
+
+    }
+
+    /**
+     * 鎷f枡鍐嶅叆搴擄紝鏍规嵁浠诲姟鐩爣搴撲綅锛岀敓鎴愭柊搴撳瓨淇℃伅
+     * @param task
+     */
+    //鎷f枡鍐嶅叆搴�
+    private void executeTask53(Task task) {
+        Long hostId = task.getHostId();
+        //fixme 灏嗕换鍔″綋鍓�
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦�");
+        }
+
+        if (loc.getLocStsId() != LocStsType.S.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
+        }
+
+        loc.setLocStsId(LocStsType.F.val());
+        loc.setUpdateTime(new Date());
+        loc.setBarcode(task.getBarcode());
+
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+
+        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+        if (taskDetls.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        //娣诲姞搴撳瓨鏄庣粏
+        for (TaskDetl taskDetl : taskDetls) {
+            double anfme = taskDetl.getStock() - taskDetl.getAnfme();
+            if (anfme <= 0) {
+                continue;
+            }
+
+            LocDetl locDetl = new LocDetl();
+            locDetl.setLocId(loc.getId());
+            locDetl.setLocNo(loc.getLocNo());
+            locDetl.setMatId(taskDetl.getMatId());
+            locDetl.setMatnr(taskDetl.getMat$().getMatnr());
+            locDetl.setOrderNo(taskDetl.getOrderNo());
+            locDetl.setBatch(taskDetl.getBatch());
+            locDetl.setAnfme(anfme);
+            locDetl.setHostId(hostId);
+            if (!locDetlService.save(locDetl)) {
+                throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
+            }
+
+            //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
+            List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
+            for (TaskDetlField detlField : detlFields) {
+                LocDetlField locDetlField = new LocDetlField();
+                locDetlField.setDetlId(locDetl.getId());
+                locDetlField.setFieldId(detlField.getFieldId());
+                locDetlField.setName(detlField.getName());
+                locDetlField.setValue(detlField.getValue());
+                locDetlField.setHostId(hostId);
+                if (!locDetlFieldService.save(locDetlField)) {
+                    throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+                }
+            }
+        }
+    }
+
+    //鍑哄簱
+    private void executeTask101(Task task) {
+        Long hostId = task.getHostId();
+//        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦�");
+        }
+        if (loc.getLocStsId() != LocStsType.R.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+        }
+        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+        if (taskDetls.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        loc.setLocStsId(LocStsType.O.val());
+        loc.setBarcode("");
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+        List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId()).eq(LocDetl::getHostId, hostId));
+        //鍒犻櫎搴撳瓨鏄庣粏
+        for (LocDetl locDetl : detlList) {
+            if (!locDetlService.removeById(locDetl)) {
+                throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
+            }
+            List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
+            for (LocDetlField detlField : detlFields) {
+                if (!locDetlFieldService.removeById(detlField)) {
+                    throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+                }
+            }
+        }
+    }
+
+    //鎷f枡鍑哄簱
+    private void executeTask103(Task task) {
+        Long hostId = task.getHostId();
+        //FIXME 鏆傛椂娉ㄩ噴HOSTID绛涢�夋潯浠�
+//        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦�");
+        }
+        if (loc.getLocStsId() != LocStsType.R.val()) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+        }
+        List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+        if (taskDetls.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        loc.setLocStsId(LocStsType.O.val());
+        loc.setBarcode("");
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+        }
+
+        List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId()).eq(LocDetl::getHostId, hostId));
+        //鍒犻櫎搴撳瓨鏄庣粏
+        for (LocDetl locDetl : detlList) {
+            if (!locDetlService.removeById(locDetl)) {
+                throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
+            }
+            List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
+            for (LocDetlField detlField : detlFields) {
+                if (!locDetlFieldService.removeById(detlField)) {
+                    throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+                }
+            }
+        }
+    }
+
+}

--
Gitblit v1.9.1