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;
|
}
|
}
|