自动化立体仓库 - WMS系统
zhou zhou
2025-12-25 418a73bcee019e078307a1c2c255235de33d20ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.zy.asrs.service.impl;
 
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));
        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));
        if (Objects.isNull(detls) || detls.isEmpty()) {
            throw new CoolException("数据错误:任务不存在!!");
        }
        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("工作档明细历史保存失败!!");
            }
        });
 
        return true;
    }
}