自动化立体仓库 - WMS系统
#
Administrator
2 天以前 e955eb6077fc28f0ad379af45c5adec1962eeff6
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
package com.zy.asrs.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.AutoEmptyOutHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
@Slf4j
@Component
public class AutoEmptyOutScheduler {
 
 
    @Autowired
    private ConfigService configService;
    @Autowired
    private AutoEmptyOutHandler autoEmptyOutHandler;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private LocMastService locMastService;
    //定时空库位预留,空轴出库
    @Scheduled(cron = "0/3 * * * * ? ")
    public void autoEmptyOut() {
 
        Config config = configService.selectConfigByCode("AutoEmptyOut");
        if (Cools.isEmpty(config) || config.getValue().equals("false")) {
            return;
        }
        ReturnT<String> result = autoEmptyOutHandler.start();
        if (!result.isSuccess()) {
            log.error("自动出空轴失败{}", result.getMsg());
        }
    }
 
    @Scheduled(cron = "0/30 * * * * ? ")
    public void autoLocMove() {
        Config config = configService.selectConfigByCode("AutoLocMoveToOther");
        if (Cools.isEmpty(config) || config.getValue().equals("false")) {
            return;
        }
        Config configMax = configService.selectConfigByCode("moveMax");
        Integer max;
        if (Cools.isEmpty(configMax)) {
            max = 4;
        }else{
            max = Integer.valueOf(config.getValue());
        }
        try {
            Integer existCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>()
                    .eq("io_type", 101)
                    .eq("log_mk", "Y")
                    .eq("ove_mk", "N"));
            int allow = max - (existCount == null ? 0 : existCount);
            if (allow <= 0) {
                return;
            }
            int created = 0;
            for (int crnNo = 1; crnNo < 5 && created < allow; crnNo++) {
                Integer emptyLocCount = locMastService.selectCount(new EntityWrapper<LocMast>()
                        .eq("crn_no", crnNo)
                        .eq("loc_sts", "O")
                        .eq("frozen", 0)
                        .eq("deleted", 0)
                        .eq("whs_type", 1));
                if (emptyLocCount == null || emptyLocCount >= 50) {
                    continue;
                }
                String result = autoEmptyOutHandler.moveMostMatnrInventoryInner(crnNo, 1L);
                if (!Cools.isEmpty(result)) {
                    created++;
                    log.info("自动移库生成任务: {}", result);
                }
            }
        } catch (Exception e) {
            log.error("自动移库失败", e);
        }
    }
 
}