zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
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
package com.zy.acs.manager.core.domain;
 
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.manager.entity.Code;
import com.zy.acs.manager.manager.entity.Task;
import lombok.Data;
 
import java.util.*;
 
/**
 * Created by vincent on 2023/6/19
 */
@Data
public class TaskPosDto {
 
    public static final Integer INF = 999999999;
 
    private Long taskId;
 
    private Long codeId;
 
    private Double[] xy = new Double[2];
 
    private PosType posType;
 
    public TaskPosDto(Long taskId, Double[] xy, PosType posType) {
        this.taskId = taskId;
        this.xy = xy;
        this.posType = posType;
    }
 
    public enum PosType {
        MOVE(0, "MOVE"),
        ORI_LOC(0, "ORIGIN"),
        ORI_STA(0, "ORIGIN"),
        DEST_LOC(INF, "DESTINATION"),
        DEST_STA(INF, "DESTINATION"),
        TO_CHARGE(INF * 10, "TO_CHARGE"),
        TO_STANDBY(INF * 10, "TO_STANDBY"),
        ;
 
        public int compOffset;
        public String brief;
 
        PosType(int compOffset, String brief) {
            this.compOffset = compOffset;
            this.brief = brief;
        }
 
    }
 
    public static void packagePosGroup(Map<String, List<TaskPosDto>> groups, Task task, Code code, PosType posType, String sameGroupXy) {
        String key = ("Y".equals(sameGroupXy) ? code.getY() : code.getX()) + posType.brief;
        Long taskId = task == null ? 0L : task.getId();
        TaskPosDto taskPosDto = new TaskPosDto(taskId, new Double[]{code.getX(), code.getY()}, posType);
        taskPosDto.setCodeId(code.getId());
        if (groups.containsKey(key)) {
            groups.get(key).add(taskPosDto);
        } else {
            List<TaskPosDto> list = new ArrayList<>();
            list.add(taskPosDto);
            groups.put(key, list);
        }
    }
 
    public Double getFirstWeight(String sameGroupXy) {
        return ("Y".equals(sameGroupXy) ? this.getXy()[1] : this.getXy()[0]);
    }
 
    public Double getSecondWeight(String sameGroupXy) {
        return ("Y".equals(sameGroupXy) ? this.getXy()[0] : this.getXy()[1]);
    }
 
    public static PosType queryPosType(String el) {
        if (Cools.isEmpty(el)) {
            return null;
        }
        for (PosType posType : PosType.values()) {
            if (posType.toString().equals(el)) {
                return posType;
            }
        }
        return null;
    }
 
}