1
zhang
2025-04-30 f837a9d55af6eedbf684c470de9a7bb926ba0633
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package com.zy.asrs.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.devops.DevopsMessage;
import com.zy.asrs.domain.devops.ErrorType;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.WrkMastService;
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.CrnForkPosType;
import com.zy.core.enums.CrnModeType;
import com.zy.core.enums.CrnStatusType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.CrnSlave;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("/devops")
public class DevopsController {
 
    @Autowired
    private WrkMastService wrkMastService;
 
    @Autowired
    private SlaveProperties slaveProperties;
 
    @Autowired
    private WrkMastMapper wrkMastMapper;
 
    @RequestMapping("/wrkMast/list")
    public R list() {
        List<DevopsMessage> devopsMessages = new ArrayList<>();
        DevopsMessage devopsMessage;
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnSlave.getId()).in("io_type", 101, 103, 107).orderBy("wrk_sts", false));
            WrkMast working = wrkMastMapper.selectWorking(crnSlave.getId());
            for (WrkMast wrkMast : wrkMasts) {
                devopsMessage = new DevopsMessage();
                devopsMessage.setWrkNo(wrkMast.getWrkNo());
                if (working != null) {
                    if (working.getWrkNo().equals(wrkMast.getWrkNo())) {
                        devopsMessage.setError("该工作档正在出库,请稍后");
                    } else {
                        devopsMessage.setError(working.getWrkNo() + "号工作档正在出库");
                    }
                    continue;
                }
                List<ErrorType> staError = isStaError(wrkMast);
                for (ErrorType type : staError) {
                    if (!Cools.isEmpty(devopsMessage.getError())) {
                        devopsMessage.setError(devopsMessage.getError() + ";" + type.getDesc());
                        devopsMessage.setMethod(devopsMessage.getMethod() + ";" + type.getMethod());
                    } else {
                        devopsMessage.setError(type.getDesc());
                        devopsMessage.setMethod(type.getMethod());
                    }
                }
                List<ErrorType> crnError = isCrnError(wrkMast);
                for (ErrorType type : crnError) {
                    if (!Cools.isEmpty(devopsMessage.getError())) {
                        devopsMessage.setError(devopsMessage.getError() + ";" + type.getDesc());
                        devopsMessage.setMethod(devopsMessage.getMethod() + ";" + type.getMethod());
                    } else {
                        devopsMessage.setError(type.getDesc());
                        devopsMessage
                                .setMethod(type.getMethod());
                    }
                }
                devopsMessages.add(devopsMessage);
            }
        }
        return R.ok(devopsMessages);
    }
 
    private List<ErrorType> isStaError(WrkMast staNo) {
        List<ErrorType> types = new ArrayList<>();
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        StaProtocol staProtocol = devpThread.getStation().get(staNo);
        if (staProtocol == null) {
            types.add(ErrorType.ERROR);
            return types;
        } else {
            staProtocol = staProtocol.clone();
        }
        if (staProtocol.isAutoing()) {
            types.add(ErrorType.FEIZIDONG);
        }
        if (staProtocol.isLoading()) {
            types.add(ErrorType.YOUWU);
        }
        if (staProtocol.getWorkNo() == 0) {
            types.add(ErrorType.GONGZUOHAO);
        }
        if (staProtocol.getStaNo() == null) {
            types.add(ErrorType.STANO);
        }
        return types;
    }
 
 
    private List<ErrorType> isCrnError(WrkMast wrkMast) {
        List<ErrorType> types = new ArrayList<>();
        CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
        CrnProtocol crnProtocol = crnThread.getCrnProtocol();
 
        if (crnProtocol.getStatusType() == CrnStatusType.IDLE) {
 
        }
        if (crnProtocol.getTaskNo() == 0) {
 
        }
        if (crnProtocol.getModeType() == CrnModeType.AUTO) {
 
        }
        if (crnProtocol.getLoaded() == 0) {
 
        }
        if (crnProtocol.statusType == CrnStatusType.FETCHING) {
            types.add(ErrorType.WORKING);
        }
        if (crnProtocol.statusType == CrnStatusType.PUTTING) {
            types.add(ErrorType.WORKING);
        }
        if (crnProtocol.statusType == CrnStatusType.WAITING) {
            types.add(ErrorType.WORKING);
        }
        if (crnProtocol.forkPosType == CrnForkPosType.HOME) {
            types.add(ErrorType.HOME);
        }
        if (crnProtocol.modeType == CrnModeType.AUTO) {
            types.add(ErrorType.FEIZIDONG);
        }
//        if (crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())) {
//            types.add(ErrorType.CRNGONGZUOHAO);
//        }
        return types;
    }
 
 
}