Junjie
23 小时以前 1a3f0ed6b7f6d4112069a3c8679e7192365d5eef
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
package com.zy.core.utils;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.WrkMastService;
import com.zy.core.enums.WrkIoType;
import com.zy.core.enums.WrkStsType;
import com.zy.core.utils.station.StationDispatchLoadSupport;
import com.zy.core.utils.station.StationOutboundDispatchProcessor;
import com.zy.core.utils.station.StationRegularDispatchProcessor;
import com.zy.core.utils.station.StationRerouteProcessor;
import com.zy.core.utils.station.model.RerouteCommandPlan;
import com.zy.core.utils.station.model.RerouteContext;
import com.zy.core.utils.station.model.RerouteDecision;
import com.zy.core.utils.station.model.RerouteExecutionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
@Component
public class StationOperateProcessUtils {
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private StationRegularDispatchProcessor stationRegularDispatchProcessor;
    @Autowired
    private StationDispatchLoadSupport stationDispatchLoadSupport;
    @Autowired
    private StationOutboundDispatchProcessor stationOutboundDispatchProcessor;
    @Autowired
    private StationRerouteProcessor stationRerouteProcessor;
 
    //执行输送站点入库任务
    public synchronized void stationInExecute() {
        stationRegularDispatchProcessor.stationInExecute();
    }
 
    //执行堆垛机输送站点出库任务
    public synchronized void crnStationOutExecute() {
        stationOutboundDispatchProcessor.crnStationOutExecute();
    }
 
    //执行双工位堆垛机输送站点出库任务
    public synchronized void dualCrnStationOutExecute() {
        stationOutboundDispatchProcessor.dualCrnStationOutExecute();
    }
 
    //检测输送站点出库任务执行完成
    public synchronized void stationOutExecuteFinish() {
        stationRegularDispatchProcessor.stationOutExecuteFinish();
    }
 
    // 检测任务转完成
    public synchronized void checkTaskToComplete() {
        stationRegularDispatchProcessor.checkTaskToComplete();
    }
 
    //检测输送站点是否运行堵塞
    public synchronized void checkStationRunBlock() {
        stationRerouteProcessor.checkStationRunBlock();
    }
 
    //检测输送站点任务停留超时后重新计算路径
    public synchronized void checkStationIdleRecover() {
        stationRerouteProcessor.checkStationIdleRecover();
    }
 
    //获取输送线任务数量
    public synchronized int getCurrentStationTaskCount() {
        return stationDispatchLoadSupport.countCurrentStationTask();
    }
 
    public synchronized int getCurrentOutboundTaskCountByTargetStation(Integer stationId) {
        if (stationId == null) {
            return 0;
        }
        return (int) wrkMastService.count(new QueryWrapper<WrkMast>()
                .eq("io_type", WrkIoType.OUT.id)
                .eq("sta_no", stationId)
                .in("wrk_sts",
                        WrkStsType.OUTBOUND_RUN.sts,
                        WrkStsType.OUTBOUND_RUN_COMPLETE.sts,
                        WrkStsType.STATION_RUN.sts));
    }
 
    // 检测出库排序
    public synchronized void checkStationOutOrder() {
        stationRerouteProcessor.checkStationOutOrder();
    }
 
    // 监控绕圈站点
    public synchronized void watchCircleStation() {
        stationRerouteProcessor.watchCircleStation();
    }
 
    RerouteCommandPlan buildRerouteCommandPlan(RerouteContext context,
                                               RerouteDecision decision) {
        return stationRerouteProcessor.buildRerouteCommandPlan(context, decision);
    }
 
    RerouteExecutionResult executeReroutePlan(RerouteContext context,
                                              RerouteCommandPlan plan) {
        return stationRerouteProcessor.executeReroutePlan(context, plan);
    }
 
    RerouteDecision resolveSharedRerouteDecision(RerouteContext context) {
        return stationRerouteProcessor.resolveSharedRerouteDecision(context);
    }
 
    boolean shouldUseRunBlockDirectReassign(WrkMast wrkMast,
                                            Integer stationId,
                                            List<Integer> runBlockReassignLocStationList) {
        return stationRerouteProcessor.shouldUseRunBlockDirectReassign(wrkMast, stationId, runBlockReassignLocStationList);
    }
 
    private boolean shouldSkipIdleRecoverForRecentDispatch(Integer taskNo, Integer stationId) {
        return stationRerouteProcessor.shouldSkipIdleRecoverForRecentDispatch(taskNo, stationId);
    }
}