自动化立体仓库 - WMS系统
zwl
9 天以前 b187814d7cfa5ace1ed9c203372524c69fe56553
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
package com.zy.asrs.task.handler;
 
import com.zy.asrs.entity.Task;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.entity.rcs.RcsTaskSubmit;
import com.zy.asrs.entity.rcs.RcsTaskTargetRoute;
import com.zy.asrs.service.RcsService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
 
@Slf4j
@Service
@Transactional
public class AGVTaskReportHandler extends AbstractHandler<String> {
 
    @Resource
    private RcsService rcsService;
 
 
    public ReturnT<String> start(Task task) {
        String SourceStaNoType = "SITE";
        String TargetStaNoType = "SITE";
        //给agv下发的任务类型,默认站到站
        //任务类型 4.站到区域
        if(task.getIoType()==4){
            TargetStaNoType = "ZONE";
 
            //任务类型 5.区域到站
        }else if(task.getIoType()==5){
            SourceStaNoType = "ZONE";
        }
        String taskType = "PP";
        Boolean flag1 = false;
        Boolean flag2 = false;
        if(task.getStaNo().equals("401")|| task.getStaNo().equals("402")|| task.getStaNo().equals("307")){
            taskType = "YLIN";
            flag1 = true;
        }
        if (task.getSourceStaNo().equals("401")|| task.getSourceStaNo().equals("402")|| task.getSourceStaNo().equals("307")){
            taskType = "YLOUT";
            flag2 = true;
        }
        if(flag1&&flag2){
            taskType = "YLBOTH";
        }
        //AGV区域中无法用-
        String StaNo = task.getStaNo();
        String SourceStaNo = task.getSourceStaNo();
        if (task.getStaNo().split("-")[0].equals("Q")) {
            String[] split = task.getStaNo().split("-");
            StaNo = split[0]+split[1];
        }
        if (task.getSourceStaNo().split("-")[0].equals("Q")) {
            String[] split = task.getSourceStaNo().split("-");
            SourceStaNo = split[0]+split[1];
        }
 
        // 下发给RCS
        RcsTaskSubmit rcsTaskSubmit = new RcsTaskSubmit();
        rcsTaskSubmit.setTaskType(taskType);
        rcsTaskSubmit.setRobotTaskCode(task.getTaskNo()+"-"+task.getCtnType());
        rcsTaskSubmit.setInitPriority(10);  //默认10
        List<RcsTaskTargetRoute> targetRouteList = new ArrayList<>();
        RcsTaskTargetRoute startRoute = new RcsTaskTargetRoute();
        startRoute.setSeq(0);
        startRoute.setType(SourceStaNoType);
        startRoute.setCode(SourceStaNo);
        startRoute.setOperation("COLLECT");
        targetRouteList.add(startRoute);
        RcsTaskTargetRoute endRoute = new RcsTaskTargetRoute();
        endRoute.setSeq(1);
        endRoute.setType(TargetStaNoType);
        endRoute.setCode(StaNo);
        endRoute.setOperation("DELIVERY");
        targetRouteList.add(endRoute);
        rcsTaskSubmit.setTargetRoute(targetRouteList);
 
        // 转发给海康或华晓RCS
        int success = rcsService.submitTask(rcsTaskSubmit, task.getPltType());
        if (success == 0){
            return FAIL;
        }
        return SUCCESS;
    }
}