huang
2025-11-20 366ba040d2447bacd3455299425e3166f1f992bb
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
package com.mes.device.entity.request;
 
import cn.hutool.core.collection.CollectionUtil;
import com.github.xingshuangs.iot.common.enums.EDataType;
import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable;
import com.mes.vertical.history.VerticalSheetCageHistoryTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @Author : zhoush
 * @Date: 2025/6/15 15:15
 * @Description:
 */
@ApiModel(description = ":")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class VerticalCarData {
 
    @ApiModelProperty(value = "联机状态", position = 1)
    @S7Variable(address = "verticalCar.onlineState", type = EDataType.BOOL)
    private Boolean onlineState;
 
    @ApiModelProperty(value = "请求字", position = 2)
    @S7Variable(address = "verticalCar.plcRequest", type = EDataType.UINT16)
    private Integer plcRequest;
 
    @ApiModelProperty(value = "汇报字", position = 3)
    @S7Variable(address = "verticalCar.reportWord", type = EDataType.UINT16)
    private Integer reportWord;
 
    @ApiModelProperty(value = "1状态", position = 4)
    @S7Variable(address = "verticalCar.state1", type = EDataType.UINT16)
    private Integer state1;
 
    @ApiModelProperty(value = "2状态", position = 5)
    @S7Variable(address = "verticalCar.state2", type = EDataType.UINT16)
    private Integer state2;
 
    @ApiModelProperty(value = "3状态", position = 6)
    @S7Variable(address = "verticalCar.state3", type = EDataType.UINT16)
    private Integer state3;
 
    @ApiModelProperty(value = "4状态", position = 7)
    @S7Variable(address = "verticalCar.state4", type = EDataType.UINT16)
    private Integer state4;
 
    @ApiModelProperty(value = "5状态", position = 8)
    @S7Variable(address = "verticalCar.state5", type = EDataType.UINT16)
    private Integer state5;
 
    @ApiModelProperty(value = "6状态", position = 9)
    @S7Variable(address = "verticalCar.state6", type = EDataType.UINT16)
    private Integer state6;
 
    @ApiModelProperty(value = "发送字", position = 10)
    @S7Variable(address = "verticalCar.mesSend", type = EDataType.UINT16)
    private Integer mesSend;
 
    @ApiModelProperty(value = "确认字", position = 11)
    @S7Variable(address = "verticalCar.confirmWord", type = EDataType.UINT16)
    private Integer confirmWord;
 
    @ApiModelProperty(value = "车次信息", position = 12)
    @S7Variable(address = "verticalCar.trainInfo", type = EDataType.STRING, count = 20)
    private String trainInfo;
 
    @ApiModelProperty(value = "玻璃id1", position = 13)
    @S7Variable(address = "verticalCar.mesGlassId1", type = EDataType.STRING, count = 20)
    private String mesGlassId1;
 
    @ApiModelProperty(value = "玻璃id2", position = 14)
    @S7Variable(address = "verticalCar.mesGlassId2", type = EDataType.STRING, count = 20)
    private String mesGlassId2;
 
    @ApiModelProperty(value = "玻璃id3", position = 15)
    @S7Variable(address = "verticalCar.mesGlassId3", type = EDataType.STRING, count = 20)
    private String mesGlassId3;
 
    @ApiModelProperty(value = "玻璃id4", position = 16)
    @S7Variable(address = "verticalCar.mesGlassId4", type = EDataType.STRING, count = 20)
    private String mesGlassId4;
 
    @ApiModelProperty(value = "玻璃id5", position = 17)
    @S7Variable(address = "verticalCar.mesGlassId5", type = EDataType.STRING, count = 20)
    private String mesGlassId5;
 
    @ApiModelProperty(value = "玻璃id6", position = 18)
    @S7Variable(address = "verticalCar.mesGlassId6", type = EDataType.STRING, count = 20)
    private String mesGlassId6;
 
    @ApiModelProperty(value = "起始格子1", position = 19)
    @S7Variable(address = "verticalCar.start1", type = EDataType.UINT16)
    private Integer start1;
 
    @ApiModelProperty(value = "起始格子2", position = 20)
    @S7Variable(address = "verticalCar.start2", type = EDataType.UINT16)
    private Integer start2;
 
    @ApiModelProperty(value = "起始格子3", position = 21)
    @S7Variable(address = "verticalCar.start3", type = EDataType.UINT16)
    private Integer start3;
 
    @ApiModelProperty(value = "起始格子4", position = 22)
    @S7Variable(address = "verticalCar.start4", type = EDataType.UINT16)
    private Integer start4;
 
    @ApiModelProperty(value = "起始格子5", position = 23)
    @S7Variable(address = "verticalCar.start5", type = EDataType.UINT16)
    private Integer start5;
 
    @ApiModelProperty(value = "起始格子6", position = 24)
    @S7Variable(address = "verticalCar.start6", type = EDataType.UINT16)
    private Integer start6;
 
    @ApiModelProperty(value = "目标格子1", position = 25)
    @S7Variable(address = "verticalCar.target1", type = EDataType.UINT16)
    private Integer target1;
 
    @ApiModelProperty(value = "目标格子2", position = 26)
    @S7Variable(address = "verticalCar.target2", type = EDataType.UINT16)
    private Integer target2;
 
    @ApiModelProperty(value = "目标格子3", position = 27)
    @S7Variable(address = "verticalCar.target3", type = EDataType.UINT16)
    private Integer target3;
 
    @ApiModelProperty(value = "目标格子4", position = 28)
    @S7Variable(address = "verticalCar.target4", type = EDataType.UINT16)
    private Integer target4;
 
    @ApiModelProperty(value = "目标格子5", position = 29)
    @S7Variable(address = "verticalCar.target5", type = EDataType.UINT16)
    private Integer target5;
 
    @ApiModelProperty(value = "目标格子6", position = 30)
    @S7Variable(address = "verticalCar.target6", type = EDataType.UINT16)
    private Integer target6;
 
    @ApiModelProperty(value = "长边1", position = 31)
    @S7Variable(address = "verticalCar.width1", type = EDataType.UINT16)
    private Integer width1;
 
    @ApiModelProperty(value = "长边2", position = 32)
    @S7Variable(address = "verticalCar.width2", type = EDataType.UINT16)
    private Integer width2;
 
    @ApiModelProperty(value = "长边3", position = 33)
    @S7Variable(address = "verticalCar.width3", type = EDataType.UINT16)
    private Integer width3;
 
    @ApiModelProperty(value = "长边4", position = 34)
    @S7Variable(address = "verticalCar.width4", type = EDataType.UINT16)
    private Integer width4;
 
    @ApiModelProperty(value = "长边5", position = 35)
    @S7Variable(address = "verticalCar.width5", type = EDataType.UINT16)
    private Integer width5;
 
    @ApiModelProperty(value = "长边6", position = 36)
    @S7Variable(address = "verticalCar.width6", type = EDataType.UINT16)
    private Integer width6;
 
    @ApiModelProperty(value = "短边1", position = 37)
    @S7Variable(address = "verticalCar.height1", type = EDataType.UINT16)
    private Integer height1;
 
    @ApiModelProperty(value = "短边2", position = 38)
    @S7Variable(address = "verticalCar.height2", type = EDataType.UINT16)
    private Integer height2;
 
    @ApiModelProperty(value = "短边3", position = 39)
    @S7Variable(address = "verticalCar.height3", type = EDataType.UINT16)
    private Integer height3;
 
    @ApiModelProperty(value = "短边4", position = 40)
    @S7Variable(address = "verticalCar.height4", type = EDataType.UINT16)
    private Integer height4;
 
    @ApiModelProperty(value = "短边5", position = 41)
    @S7Variable(address = "verticalCar.height5", type = EDataType.UINT16)
    private Integer height5;
 
    @ApiModelProperty(value = "短边6", position = 42)
    @S7Variable(address = "verticalCar.height6", type = EDataType.UINT16)
    private Integer height6;
 
    @ApiModelProperty(value = "厚1", position = 43)
    @S7Variable(address = "verticalCar.thickness1", type = EDataType.UINT16)
    private Integer thickness1;
 
    @ApiModelProperty(value = "厚2", position = 44)
    @S7Variable(address = "verticalCar.thickness2", type = EDataType.UINT16)
    private Integer thickness2;
 
    @ApiModelProperty(value = "厚3", position = 45)
    @S7Variable(address = "verticalCar.thickness3", type = EDataType.UINT16)
    private Integer thickness3;
 
    @ApiModelProperty(value = "厚4", position = 46)
    @S7Variable(address = "verticalCar.thickness4", type = EDataType.UINT16)
    private Integer thickness4;
 
    @ApiModelProperty(value = "厚5", position = 47)
    @S7Variable(address = "verticalCar.thickness5", type = EDataType.UINT16)
    private Integer thickness5;
 
    @ApiModelProperty(value = "厚6", position = 48)
    @S7Variable(address = "verticalCar.thickness6", type = EDataType.UINT16)
    private Integer thickness6;
 
    @ApiModelProperty(value = "靠边距1", position = 49)
    @S7Variable(address = "verticalCar.edgeDistance1", type = EDataType.UINT16)
    private Integer edgeDistance1;
 
    @ApiModelProperty(value = "靠边距2", position = 50)
    @S7Variable(address = "verticalCar.edgeDistance2", type = EDataType.UINT16)
    private Integer edgeDistance2;
 
    @ApiModelProperty(value = "靠边距3", position = 51)
    @S7Variable(address = "verticalCar.edgeDistance3", type = EDataType.UINT16)
    private Integer edgeDistance3;
 
    @ApiModelProperty(value = "靠边距4", position = 52)
    @S7Variable(address = "verticalCar.edgeDistance4", type = EDataType.UINT16)
    private Integer edgeDistance4;
 
    @ApiModelProperty(value = "靠边距5", position = 53)
    @S7Variable(address = "verticalCar.edgeDistance5", type = EDataType.UINT16)
    private Integer edgeDistance5;
 
    @ApiModelProperty(value = "靠边距6", position = 54)
    @S7Variable(address = "verticalCar.edgeDistance6", type = EDataType.UINT16)
    private Integer edgeDistance6;
 
    @ApiModelProperty(value = "目标靠边距1", position = 55)
    @S7Variable(address = "verticalCar.targetEdgeDistance1", type = EDataType.UINT16)
    private Integer targetEdgeDistance1;
 
    @ApiModelProperty(value = "目标靠边距2", position = 56)
    @S7Variable(address = "verticalCar.targetEdgeDistance2", type = EDataType.UINT16)
    private Integer targetEdgeDistance2;
 
    @ApiModelProperty(value = "目标靠边距3", position = 57)
    @S7Variable(address = "verticalCar.targetEdgeDistance3", type = EDataType.UINT16)
    private Integer targetEdgeDistance3;
 
    @ApiModelProperty(value = "目标靠边距4", position = 58)
    @S7Variable(address = "verticalCar.targetEdgeDistance4", type = EDataType.UINT16)
    private Integer targetEdgeDistance4;
 
    @ApiModelProperty(value = "目标靠边距5", position = 59)
    @S7Variable(address = "verticalCar.targetEdgeDistance5", type = EDataType.UINT16)
    private Integer targetEdgeDistance5;
 
    @ApiModelProperty(value = "目标靠边距6", position = 60)
    @S7Variable(address = "verticalCar.targetEdgeDistance6", type = EDataType.UINT16)
    private Integer targetEdgeDistance6;
 
    @ApiModelProperty(value = "报警信号", position = 61)
    @S7Variable(address = "verticalCar.alarmSignal", type = EDataType.UINT16)
    private Integer alarmSignal;
 
    public List<Integer> getStartSlots() {
        return Arrays.asList(start1, start2, start3, start4, start5, start6);
    }
 
    public List<Integer> getTargetSlots() {
        return Arrays.asList(target1, target2, target3, target4, target5, target6);
    }
 
    public List<Integer> getStates() {
        return Arrays.asList(state1, state2, state3, state4, state5, state6);
    }
 
    public List<String> getGlassIds() {
        return Arrays.asList(mesGlassId1, mesGlassId2, mesGlassId3, mesGlassId4, mesGlassId5, mesGlassId6)
                .stream()
                .filter(glassId -> glassId != null && !glassId.trim().isEmpty())
                .collect(Collectors.toList());
    }
 
    public List<VerticalSheetCageHistoryTask> getTaskList() {
        List<VerticalSheetCageHistoryTask> inTaskList = new ArrayList();
        List<String> glassIdList = this.getGlassIds();
        if (CollectionUtil.isEmpty(glassIdList)) {
            return inTaskList;
        }
        List<Integer> targetList = this.getTargetSlots();
        List<Integer> stateList = this.getStates();
        List<Integer> startList = this.getStartSlots();
        for (int i = 0; i < glassIdList.size(); i++) {
            VerticalSheetCageHistoryTask task = new VerticalSheetCageHistoryTask();
            task.setGlassId(glassIdList.get(i));
            task.setTargetSlot(targetList.get(i));
            task.setTaskState(stateList.get(i));
            task.setStartSlot(startList.get(i));
            inTaskList.add(task);
        }
        return inTaskList;
    }
 
    public VerticalCarData setGlassIdsAndPosition(List<String> glassIds, Integer inPosition) {
        VerticalCarData verticalCarData = new VerticalCarData();
        verticalCarData.setTrainInfo(inPosition.toString());
        int i = 1;
        for (String glassId : glassIds
        ) {
            switch (i) {
                case 1:
                    verticalCarData.setMesGlassId1(glassId);
                    verticalCarData.setStart1(inPosition);
                    break;
                case 2:
                    verticalCarData.setMesGlassId2(glassId);
                    verticalCarData.setStart2(inPosition);
                    break;
                case 3:
                    verticalCarData.setMesGlassId3(glassId);
                    verticalCarData.setStart3(inPosition);
                    break;
                case 4:
                    verticalCarData.setMesGlassId4(glassId);
                    verticalCarData.setStart4(inPosition);
                    break;
                case 5:
                    verticalCarData.setMesGlassId5(glassId);
                    verticalCarData.setStart5(inPosition);
                    break;
                case 6:
                    verticalCarData.setMesGlassId6(glassId);
                    verticalCarData.setStart6(inPosition);
                    break;
                default:
                    break;
            }
            i++;
        }
        return verticalCarData;
    }
 
    public VerticalCarData setMesGlassInfo(VerticalCarData verticalCarData, List<VerticalSheetCageHistoryTask> verticalSheetCageHistoryTasks) {
        int i = 1;
        for (VerticalSheetCageHistoryTask verticalSheetCageHistoryTask : verticalSheetCageHistoryTasks
        ) {
            switch (i) {
                case 1:
                    verticalCarData.setMesGlassId1(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart1(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget1(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth1(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight1(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness1((int) verticalSheetCageHistoryTask.getThickness().doubleValue());
                    verticalCarData.setEdgeDistance1(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance1(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                case 2:
                    verticalCarData.setMesGlassId2(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart2(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget2(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth2(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight2(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness2((int) verticalSheetCageHistoryTask.getThickness().doubleValue());
                    verticalCarData.setEdgeDistance2(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance2(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                case 3:
                    // 第三组玻璃数据赋值
                    verticalCarData.setMesGlassId3(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart3(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget3(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth3(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight3(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness3(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setEdgeDistance3(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance3(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                case 4:
                    verticalCarData.setMesGlassId4(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart4(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget4(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth4(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight4(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness4((int) verticalSheetCageHistoryTask.getThickness().doubleValue());
                    verticalCarData.setEdgeDistance4(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance4(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                case 5:
                    verticalCarData.setMesGlassId5(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart5(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget5(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth5(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight5(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness5((int) verticalSheetCageHistoryTask.getThickness().doubleValue());
                    verticalCarData.setEdgeDistance5(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance5(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                case 6:
                    verticalCarData.setMesGlassId6(verticalSheetCageHistoryTask.getGlassId());
                    verticalCarData.setStart6(verticalSheetCageHistoryTask.getStartSlot());
                    verticalCarData.setTarget6(verticalSheetCageHistoryTask.getTargetSlot());
                    verticalCarData.setWidth6(Math.max((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setHeight6(Math.min((int) verticalSheetCageHistoryTask.getWidth().doubleValue(), (int) verticalSheetCageHistoryTask.getHeight().doubleValue()));
                    verticalCarData.setThickness6((int) verticalSheetCageHistoryTask.getThickness().doubleValue());
                    verticalCarData.setEdgeDistance6(verticalSheetCageHistoryTask.getEdgeDistance());
                    verticalCarData.setTargetEdgeDistance6(verticalSheetCageHistoryTask.getTargetEdgeDistance());
                    break;
                default:
                    break;
            }
            i++;
        }
        return verticalCarData;
    }
}