#
vincentlu
2025-12-18 ff176992e79222234735220fea9e767e4942d25d
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
package com.zy.acs.manager.core.service;
 
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.manager.entity.Loc;
import com.zy.acs.manager.manager.entity.Sta;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.service.AreaAgvService;
import com.zy.acs.manager.manager.service.LocService;
import com.zy.acs.manager.manager.service.StaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
@Slf4j
@Service
public class AgvAreaDispatcher {
 
    @Autowired
    private LocService locService;
    @Autowired
    private StaService staService;
    @Autowired
    private AreaGovernService areaGovernService;
    @Autowired
    private AreaAgvService areaAgvService;
 
    @PostConstruct
    public void init() {
    }
 
    public List<Long> getAgvNosByTask(Task task) {
        if (null == task) {
            return null;
        }
        Loc oriLoc = null;
        Sta oriSta = null;
        Loc destLoc = null;
        Sta destSta = null;
        if (null != task.getOriLoc()) {
            oriLoc = locService.getById(task.getOriLoc());
            return this.getAgvIdsByCode(oriLoc.getCode$());
        }
        if (null != task.getOriSta()) {
            oriSta = staService.getById(task.getOriSta());
            return this.getAgvIdsByCode(oriSta.getCode$());
        }
        if (null != task.getDestLoc()) {
            destLoc = locService.getById(task.getDestLoc());
            return this.getAgvIdsByCode(destLoc.getCode$());
        }
        if (null != task.getDestSta()) {
            destSta = staService.getById(task.getDestSta());
            return this.getAgvIdsByCode(destSta.getCode$());
        }
        return null;
    }
 
    public List<Long> getAgvIdsByCode(String code) {
        if (Cools.isEmpty(code)) {
            return Collections.emptyList();
        }
        List<Long> areaIds = areaGovernService.queryAreas(code);
        return areaAgvService.queryAgvIdsByAreaIds(areaIds);
    }
 
    public List<String> getAgvNosByStaNo(String staNo) {
        return null;
    }
 
    public List<String> getAreaCodeListByAgvNo(String agvNo) {
        List<String> areaCodeList = new ArrayList<>();
        return areaCodeList;
    }
 
}