自动化立体仓库 - WMS系统
zhou zhou
2025-12-30 0eab67f624c2b3349002860b408942265a076b9e
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
package com.zy.asrs.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.entity.Task;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.TaskService;
import com.zy.asrs.task.handler.AgvHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
/**
 * @author pang.jiabao
 * @description AGV交互相关定时任务
 * @createDate 2025/11/18 14:18
 */
@Component
public class AgvScheduler {
 
    @Resource
    private ConfigService configService;
 
    @Resource
    private AgvHandler agvHandler;
 
    @Resource
    private TaskService taskService;
 
    @Resource
    private WrkMastMapper wrkMastMapper;
 
    /**
     * 呼叫agv搬运
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    private void callAgv() {
        // 查询待呼叫agv任务
        List<Task> taskList = taskService.selectList(new EntityWrapper<Task>().eq("wrk_sts", 7));
        if(taskList.isEmpty()) {
            return;
        }
        agvHandler.callAgv(taskList);
    }
 
    /**
     * 货物到达出库口,生成agv任务
     */
    @Scheduled(cron = "0/3 * * * * ? ")
    private void createAgvOutTasks() {
 
        // 获取呼叫agv配置
        List<Config> configs = configService.selectList(new EntityWrapper<Config>().in("code", "eastCallAgvControl", "westCallAgvControl").eq("status", 1));
        if(configs.isEmpty()) {
            return;
        }
 
        // 获取agv出库可用站点
        List<String> sites = new ArrayList<>();
        for(Config config: configs) {
            String value = config.getValue();
            if(Cools.isEmpty(value)) {
                continue;
            }
            String[] split = value.split(";");
            sites.addAll(Arrays.asList(split));
        }
 
        if(sites.isEmpty()) {
            return;
        }
 
        agvHandler.createAgvOutTasks(sites);
    }
 
    /**
     * 任务完成转历史
     */
    @Scheduled(cron = "0/10 * * * * ? ")
    private void moveTaskToHistory() {
        List<Task> taskList = taskService.selectList(new EntityWrapper<Task>().eq("wrk_sts", 9));
        if(taskList.isEmpty()) {
            return;
        }
        agvHandler.moveTaskToHistory(taskList);
    }
 
}