From 9611dc686299be640ce5e5f5990c747765161ec7 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期三, 21 一月 2026 10:59:38 +0800
Subject: [PATCH] agv逻辑调整2

---
 src/main/java/com/zy/asrs/service/impl/TaskLogServiceImpl.java |   65 +++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/TaskLogServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/TaskLogServiceImpl.java
index a413b01..0b531e7 100644
--- a/src/main/java/com/zy/asrs/service/impl/TaskLogServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/TaskLogServiceImpl.java
@@ -1,12 +1,71 @@
 package com.zy.asrs.service.impl;
 
-import com.zy.asrs.mapper.TaskLogMapper;
-import com.zy.asrs.entity.TaskLog;
-import com.zy.asrs.service.TaskLogService;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.Task;
+import com.zy.asrs.entity.TaskDetl;
+import com.zy.asrs.entity.TaskDetlLog;
+import com.zy.asrs.entity.TaskLog;
+import com.zy.asrs.mapper.TaskLogMapper;
+import com.zy.asrs.service.TaskDetlLogService;
+import com.zy.asrs.service.TaskDetlService;
+import com.zy.asrs.service.TaskLogService;
+import com.zy.asrs.service.TaskService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Objects;
 
 @Service("taskLogService")
 public class TaskLogServiceImpl extends ServiceImpl<TaskLogMapper, TaskLog> implements TaskLogService {
 
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private TaskDetlService taskDetlService;
+    @Autowired
+    private TaskDetlLogService taskDetlLogService;
+
+    /**
+     * @author Ryan
+     * @date 2025/9/23
+     * @description: 淇濆瓨浠诲姟鏃ュ織
+     * @version 1.0
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean save(Integer wrkNo) {
+        Task task = taskService.selectOne(new EntityWrapper<Task>()
+                .eq("wrk_no", wrkNo)
+                .andNew("(is_deleted = 0)"));
+        if (Objects.isNull(task)) {
+            throw new CoolException("鏁版嵁閿欒锛氫换鍔′笉瀛樺湪锛侊紒");
+        }
+        TaskLog taskLog = new TaskLog();
+        BeanUtils.copyProperties(task, taskLog);
+
+        if (!this.insert(taskLog)) {
+            throw new CoolException("浠诲姟鏃ュ織淇濆瓨澶辫触锛侊紒");
+        }
+
+        List<TaskDetl> detls = taskDetlService.selectList(new EntityWrapper<TaskDetl>().eq("wrk_no", wrkNo));
+        // 绌烘墭鍏ュ簱(io_type=10)鍜岀┖鎵樺嚭搴�(io_type=110)鍙兘娌℃湁鏄庣粏锛屽厑璁镐负绌�
+        if (Objects.nonNull(detls) && !detls.isEmpty()) {
+            detls.forEach(detl -> {
+                TaskDetlLog detlLog = new TaskDetlLog();
+                BeanUtils.copyProperties(detl, detlLog);
+                detlLog.setId(null);
+                detlLog.setTaskID(taskLog.getId());
+                if (!taskDetlLogService.insert(detlLog)) {
+                    throw new CoolException("宸ヤ綔妗f槑缁嗗巻鍙蹭繚瀛樺け璐ワ紒锛�");
+                }
+            });
+        }
+
+        return true;
+    }
 }

--
Gitblit v1.9.1