Administrator
2 天以前 aa33e56e37cd19b88ae8eea69c5ebc7c6da8b1d2
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -25,11 +25,9 @@
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
 * 输送线线程
@@ -47,6 +45,11 @@
    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
        add(301);add(302);add(303);add(304);add(305);add(306);add(307);add(308);
    }};
    // 正面5个条码扫描站
    public static final ArrayList<Integer> barcodeSite2 = new ArrayList<Integer>() {{
        add(102);add(105);add(108);add(111);add(114);
    }};
    // 侧面三个条码扫描站
@@ -249,37 +252,67 @@
            }
            // 读取正面条码
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.1404", (short) (16 * 8));
            if (result2.IsSuccess) {
                for (int i = 0; i < 16; i++) {
                    int barcodeId = 0;
                    switch (i) {
                        case 1:
                            barcodeId = 1;
                            break;
                        case 4:
                            barcodeId = 2;
                            break;
                        case 7:
                            barcodeId = 3;
                            break;
                        case 10:
                            barcodeId = 4;
                            break;
                        case 13:
                            barcodeId = 5;
                            break;
                        default:
            OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB103.0", (short) (5 * 40));
            if (result3.IsSuccess) {
                for (int i = 0; i < 5; i++) {
                    String barcode = siemensS7Net.getByteTransform().TransString(result3.Content, i * 40, 40, "UTF-8");
                    if(!Cools.isEmpty()){
                        barcode = barcode.trim();
                    }
                    if (barcodeId != 0) {
                        String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 6, "UTF-8");
                        BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId);
                        if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                            barcodeThread.setBarcode(barcode);
                    List<String> barcodeList = Arrays.stream(barcode.split(";")).collect(Collectors.toList());
                    Iterator<String> iterator = barcodeList.iterator();
                    while (iterator.hasNext()){
                        String next = iterator.next();
                        if(next.length() == 6) {
                            barcode = next;
                            iterator.remove();
                            break;
                        }
                    }
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i+1);
                    if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                        barcodeThread.setBarcode(barcode);
                    }
                    StaProtocol staProtocol = station.get(barcodeSite2.get(i));
                    if (staProtocol != null) {
                        staProtocol.setMatIdList(barcodeList);
                    }
                }
            }
            // 读取正面条码
//            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.1404", (short) (16 * 8));
//            if (result2.IsSuccess) {
//                for (int i = 0; i < 16; i++) {
//                    int barcodeId = 0;
//                    switch (i) {
//                        case 1:
//                            barcodeId = 1;
//                            break;
//                        case 4:
//                            barcodeId = 2;
//                            break;
//                        case 7:
//                            barcodeId = 3;
//                            break;
//                        case 10:
//                            barcodeId = 4;
//                            break;
//                        case 13:
//                            barcodeId = 5;
//                            break;
//                        default:
//                    }
//                    if (barcodeId != 0) {
//                        String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 6, "UTF-8");
//                        BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId);
//                        if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
//                            barcodeThread.setBarcode(barcode);
//                        }
//                    }
//                }
//            }
            // 读取侧面条码
            OperateResultExOne<byte[]> resultCM2 = siemensS7Net.Read("DB101.2574", (short) (3 * 4 * 6));
@@ -448,9 +481,12 @@
        String workNoAddress;
        // 目标站地址
        String staNoAddress;
        // 高度类型地址
        String heightAddress;
        if (index < 16) {
            workNoAddress = "DB100." + index * 4;
            staNoAddress = "DB100." + (index * 4 + 2);
            heightAddress = "DB104." + (index * 4 + 2);
        } else {
            workNoAddress = "DB100." + (400 + (index-16) * 4);
            staNoAddress = "DB100." + (400 + (index-16) * 4 + 2);