自动化立体仓库 - WMS系统
pang.jiabao
2024-10-12 906378a251838ab4d4f3b7f7ecc461764ea7090f
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.zy.asrs.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.OrderDetlMapper;
import com.zy.asrs.mapper.OrderMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.task.handler.GhjtHandler;
import com.zy.system.entity.Config;
import com.zy.system.mapper.ConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @author pang.jiabao
 * @description 冠鸿江铜相关定时任务
 * @createDate 2024/7/3 9:07
 */
@Slf4j
@Component
public class GhjtScheduler {
 
    @Resource
    private GhjtHandler ghjtHandler;
 
    @Resource
    private WrkMastMapper wrkMastMapper;
 
    @Resource
    private OrderMapper orderMapper;
 
    @Resource
    private ConfigMapper configMapper;
 
    @Resource
    private OrderDetlMapper orderDetlMapper;
 
    // 自动备货(根据出库单,把要出的货提前放到靠近出库口位置)
    // 定时任务获取待备货订单明细->获取堆垛机对应的源库位,获取备货区库位->生成移库任务11->
    // 执行移库任务12->入库完成4->更新工作档定时任务中更新订单备货状态和订单明细备货状态5->转储历史
    @Scheduled(cron = "0/10 * * * * ?")
    public void autoStockUp() {
        // 查询自动备货配置
        Config config = configMapper.selectConfigByCode("auto_stock_up");
        if (config == null || config.getStatus() == 0) {
            return;
        }
        // 查询出库申请单中没有备货的订单明细的包装组号
        List<String> list = orderMapper.selectStockUpOrderDetl();
        if (list.isEmpty()) {
            return;
        }
 
        ghjtHandler.autoStockUpHandler(list, Integer.parseInt(config.getValue()));
 
    }
 
    // 下发出库任务给GWCS(从出库码头到出库口)
    @Scheduled(cron = "0/2 * * * * ? ")
    public void ckrwPushGwcs() {
        // 查询状态为13的工作档
        List<WrkMast> wrkMasts = wrkMastMapper.selectList(new EntityWrapper<WrkMast>().in("io_type", 101,103,107,110,3,12,109).eq("wrk_sts", 13));
        for (WrkMast wrkMast : wrkMasts) {
            try {
                ghjtHandler.startCkrwPushGwcs(wrkMast);
            } catch (Exception e) {
                log.error("下发出库任务给GWCS(从出库码头到出库口)失败,异常信息:" + e);
            }
        }
    }
 
    // 自动跨巷道移库
    // 配置开启->获取单据明细->获取源库位目标库位->生成移库任务->取消任务回滚单据->
    // wcs出库到堆垛机出库口->gwms给gwcs推送目标站1->gwcs到达堆垛机入库口请求入库->堆垛机执行入库->入库完成->更新单据状态
    // 11->12->13->1->2->3->4->5
    @Scheduled(cron = "0/10 * * * * ?")
    public void autoMoveLoc() {
        // 查询跨巷道移库配置
        Config config = configMapper.selectConfigByCode("auto_move_loc");
        if (config == null || config.getStatus() == 0) {
            return;
        }
        // 查询待移库的单据明细
        List<OrderDetl> orderDetlList = orderDetlMapper.selectMoveLocDetl();
        if (orderDetlList.isEmpty()) {
            return;
        }
 
        ghjtHandler.autoMoveLoc(orderDetlList);
    }
 
    // 空闲理货
    // 配置开启->查询可用桁架->获取到能理货的两个木箱->生成两个木箱的理货任务和组盘点的入库任务
    // wcs出库到堆垛机出库口->推送给gwms去桁架命令->到达理货桁架请求zms拆垛规则->返回拆垛规则gwcs执行拆垛->拆垛完成请求zwms->返回去叠盘/回库/组盘点入库命令->gwcs到达入库口请求入库->堆垛机执行入库
    // 11->12->13->2->42->52->2->3->4->5 // 回库
    //                  ->15 // 去叠盘
    //                  ->1->2->3->4->5 // 组盘点入库
    @Scheduled(cron = "0/10 * * * * ? ")
    public void autoTallyGoods() {
 
        // 系统配置界面启用
        Config config = configMapper.selectConfigByCode("auto_tally_goods");
        if (config == null || config.getStatus() == 0) {
            return;
        }
 
        // 标记哪一套桁架能用
        int flag = 0;
 
        // 分别查询两套桁架是否存在任务
        Integer count = wrkMastMapper.selectCount(new EntityWrapper<WrkMast>().eq("source_sta_no", 3046).or().in("sta_no", 3045, 3044));
        if (count == 0) {
            flag = 1;
        } else {
            count = wrkMastMapper.selectCount(new EntityWrapper<WrkMast>().in("source_sta_no", 3042).or().in("sta_no", 3041, 3040));
            if (count == 0) {
                flag = 2;
            }
        }
 
        // 没有找到可用桁架,桁架都都存在任务
        if (flag == 0) {
            return;
        }
 
        // 指定桁架生成理货任务
        ghjtHandler.autoTallyGoods(flag);
    }
 
}