自动化立体仓库 - WCS系统
Junjie
2023-08-11 5ede6d1ba71a47fa33034d6e815681f218d61ff9
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.zy.asrs.service.impl;
 
import com.core.exception.CoolException;
import com.zy.asrs.domain.enums.TaskStatusType;
import com.zy.asrs.domain.enums.WorkNoType;
import com.zy.asrs.mapper.TaskWrkMapper;
import com.zy.asrs.entity.TaskWrk;
import com.zy.asrs.service.TaskWrkService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.common.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
 
@Service("taskWrkService")
public class TaskWrkServiceImpl extends ServiceImpl<TaskWrkMapper, TaskWrk> implements TaskWrkService {
 
    @Autowired
    private CommonService commonService;
 
    @Override
    public TaskWrk selectByTaskNo(String taskNo) {
        return this.baseMapper.selectByTaskNo(taskNo);
    }
 
    @Override
    public TaskWrk selectByWrkNo(Integer wrkNo) {
        return this.baseMapper.selectByWrkNo(wrkNo);
    }
 
    @Override
    @Transactional
    public void distribute(String taskNo, Long userId) {
        TaskWrk taskWrk = this.selectByTaskNo(taskNo);
        if (taskWrk == null) {
            throw new CoolException("WMS任务不存在");
        }
 
        if (taskWrk.getStatus() != 1) {
            throw new CoolException("任务已派发");
        }
 
        //创建任务
        if (taskWrk.getIoType() == 1) {
            //1.入库
            startup(taskWrk, userId);
        }else if(taskWrk.getIoType() == 2){
            //2.出库
            stockOut(taskWrk, userId);
        } else if (taskWrk.getIoType() == 3) {
            //3.库格移载
            locMove(taskWrk, userId);
        }
    }
 
    @Override
    public void startup(TaskWrk taskWrk, Long userId) {
        //入库任务派发
        int workNo = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号
        taskWrk.setWrkNo(workNo);//工作号
        taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态
        taskWrk.setAssignTime(new Date());//派发时间
        taskWrk.setWrkSts(2);//工作状态 2.设备上走
        taskWrk.setModiTime(new Date());
        taskWrk.setModiUser(userId);
        updateById(taskWrk);
    }
 
    @Override
    public void stockOut(TaskWrk taskWrk, Long userId) {
        //出库任务派发
        int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type);//获取出库工作号
        taskWrk.setWrkNo(workNo);//工作号
        taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态
        taskWrk.setAssignTime(new Date());//派发时间
        taskWrk.setWrkSts(11);//工作状态 11.生成出库ID
        taskWrk.setModiTime(new Date());
        taskWrk.setModiUser(userId);
        updateById(taskWrk);
    }
 
    @Override
    public void locMove(TaskWrk taskWrk, Long userId) {
        //库格移载任务派发
        int workNo = commonService.getWorkNo(WorkNoType.OTHER.type);//获取工作号
        taskWrk.setWrkNo(workNo);//工作号
        taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态
        taskWrk.setAssignTime(new Date());//派发时间
        taskWrk.setWrkSts(11);//工作状态 11.生成出库ID
        taskWrk.setModiTime(new Date());
        taskWrk.setModiUser(userId);
        updateById(taskWrk);
    }
 
    @Override
    public List<TaskWrk> selectToBeHistoryData() {
        return this.baseMapper.selectToBeHistoryData();
    }
 
    @Override
    public int saveToHistory(String taskNo) {
        return this.baseMapper.saveToHistory(taskNo);
    }
}