admin
2024-06-15 8cfe20288690f2ba46c804f41f39e8aa48c2dea0
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -1,44 +1,59 @@
package com.jcdm.main.plcserver.sub;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.framework.websocket.WebSocketUsers;
import com.jcdm.main.constant.Constants;
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface;
import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
import com.jcdm.main.plcserver.conf.OPCElement;
import com.jcdm.main.plcserver.util.TimeUtil;
import com.jcdm.main.restful.factoryMes.service.RestfulService;
import com.jcdm.main.restful.qingYan.doman.ChildVO;
import com.jcdm.main.restful.qingYan.doman.ParentVO;
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback;
import com.kangaroohy.milo.service.MiloService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.websocket.Session;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component
public class OPCUaSubscription implements SubscriptionCallback {
    private static final Logger logger = LoggerFactory.getLogger("sys-user");
    public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //新自动工站
    public List<String> automaticList = Arrays.asList("OP280", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470");
    public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470");
    //采集模组工位 ModuleCode
    public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330");
    public List<String> moduleCodeList = Arrays.asList("OP300A","OP310A","OP310B","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330");
    //区分模组型号工位
    public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330");
@@ -49,6 +64,9 @@
    //区分pack型号的工位
    public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470");
    //测试设备手动工位
    public List<String> testList = Arrays.asList("OP430-1","OP430-2","OP430-3","OP430-4","OP480-1","OP480-2","OP480-3","OP440");
    //空的
@@ -67,22 +85,28 @@
    public static IOmProductionOrdeInfoService omProductionOrdeInfoService;
    private static IDaTestDeviceInterfaceService daTestDeviceInterfaceService;
    public OPCUaSubscription(MiloService miloService,
                             IDaPassingStationCollectionService daPassingStationCollectionService,
                             IDaCollectionParamConfService collectionParamConfService,
                             IDaParamCollectionService daParamCollectionService,
                             IOmProductionOrdeInfoService omProductionOrdeInfoService) {
                             IOmProductionOrdeInfoService omProductionOrdeInfoService,
                             IDaTestDeviceInterfaceService daTestDeviceInterfaceService) {
        OPCUaSubscription.miloService = miloService;
        this.daPassingStationCollectionService = daPassingStationCollectionService;
        OPCUaSubscription.collectionParamConfService = collectionParamConfService;
        OPCUaSubscription.daParamCollectionService = daParamCollectionService;
        OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService;
        OPCUaSubscription.daTestDeviceInterfaceService = daTestDeviceInterfaceService;
    }
    @Override
    public void onSubscribe(String identifier, Object value) {
        logger.info("地址:"+identifier+"值:"+value);
        try {
            if(null != value && Integer.valueOf(value.toString())!= 0) {
                String[] nodes = identifier.split("[.]");
@@ -91,20 +115,7 @@
                String tab = nodes[2];//标记
                String tabVlaue = value.toString();//地址值
                //请求下发SN号
                if (("RecordSN").equals(tab) && "1".equals(tabVlaue)) {
                    //获取SN号方法
                    String SNCode = getSNCode();
                    //下发SN
                    String SNCodeAddress = thoroughfare + "." + device + ".SNCode";
                    miloService.writeToOpcChar(ReadWriteEntity.builder().identifier(SNCodeAddress).value(SNCode).build());
                    //下发SN完成
                    String recordSNDoneAddress = thoroughfare + "." + device + ".RecordSNDone";
                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(recordSNDoneAddress).value(1).build());
                }
                //请求记录数据
                else if (("RecordData").equals(tab)) {
                if (("RecordData").equals(tab)) {
                    String recordDataDoneValue = "";
                    if("1".equals(tabVlaue)){
@@ -117,52 +128,64 @@
                        //自动工位
                        if(automaticList.stream().anyMatch(s -> s.equals(device))){
                            //plc给我们一个模组码,拿模组码校验出型号
                            if(distinguishingModules.stream().anyMatch(s -> s.equals(device))) {
                            if(moduleCodeList.stream().anyMatch(s -> s.equals(device))) {
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                //读模组码
//                                String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString();
//                                String productTye = thoroughfare + "." + device + ".ProductType";
//                                if (null != moduleCode && moduleCode.length() == 24) {
//                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7, 8))).build());
//                                    //进站保存数据
////                              inSaveDate(thoroughfare,device)
//                                    //记录数据完成
                                    String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
//
                                Object moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue();
                                if(device.equals("OP365")){
                                    Object moduleCodeA = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeA").getValue();
                                    Object moduleCodeB = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeB").getValue();
                                    if(moduleCodeA!=null && moduleCodeB!=null){
                                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
                                    }else {
                                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build());
                                    }
                                    return;
                                }
                                if(moduleCode!=null){
                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
//
//
//                                    //请求工单
//                                } else {
//                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
//                                }
                                }else {
                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build());
                                }
                            }else {
                                if(agvId.stream().anyMatch(s -> s.equals(device))){
                                    String agvId = miloService.readFromOpcUa(thoroughfare + "." + device + ".AGVID").getValue().toString();
                                    String PACKCode = thoroughfare + "." + device + ".MPACKCode";
                                    if (null != agvId) {
                                        OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, agvId));
                                        String packId = one.getProductNum();
                                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(PACKCode).value(packId).build());
                                    } else {
                                    Object agvIdObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".AGVID").getValue();
                                    //agvId 小车码是否为空
                                    if(agvIdObject!=null){
                                        String PACKCode = thoroughfare + "." + device + ".MPACKCode";
                                        OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, agvIdObject.toString()));
                                        //小车码查找工单是否为空
                                        if(one!=null){
                                            String packId = one.getProductNum();
                                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(PACKCode).value(packId).build());
                                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
                                        }else {
                                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
                                        }
                                    }else {
                                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
                                    }
                                }
                                //pack 如果区分型号的话就要处理
                                //记录数据完成
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
                                }else {
                                    String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                    Object packCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".PACKCode").getValue();
                                    if(packCodeObject!=null){
                                        //pack 如果区分型号的话就要处理
                                        //记录数据完成
                                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
                                    }else {
                                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build());
                                    }
                                }
                            }
                        }else {
                            //手动工位处理逻辑
//                            if(automaticList.stream().noneMatch(s -> s.equals(device))){
                                //给前端发工件到位信号
//                            if (map.containsKey(device)){
                                WebSocketUsers.sendMessageToUserByText(map.get(device), "IN");
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
//                            }
                            //校验合格不合格如果合格可以进站
                            String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
                        }
@@ -176,7 +199,34 @@
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build());
                        }else {
                            //手动工位
                            WebSocketUsers.sendMessageToUserByText(map.get(device), "END");
//                            if(device.contains("OP330")){
//                                String str = device.substring(0,5);
//                                WebSocketUsers.sendMessageToUserByText(map.get(str), "END");
//                            }else {
                                WebSocketUsers.sendMessageToUserByText(map.get(device), "END");
//                            }
                            if(testList.stream().anyMatch(s -> s.equals(device))){
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
//                                Object packCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue();
//                                DaTestDeviceInterface deviceInterfaceOne = null;
//
//                                if (ObjectUtil.isNotNull(packCodeObject)) {
//                                    String modelCode = packCodeObject.toString();
//                                    deviceInterfaceOne = daTestDeviceInterfaceService.getOne(new LambdaQueryWrapper<DaTestDeviceInterface>()
//                                            .eq(DaTestDeviceInterface::getProductNum, modelCode)
//                                            .eq(DaTestDeviceInterface::getStationCode, device));
//                                }
//
//                                if (deviceInterfaceOne != null && "1".equals(deviceInterfaceOne.getTotalResult())) {
//                                    writeToOpc(RecordDataDoneAddress, (short) 21);
//                                } else {
//                                    writeToOpc(RecordDataDoneAddress, (short) 22);
//                                }
//                                writeToOpc(RecordDataDoneAddress, (short) 21);
                            }
                        }
                    }else {
                        System.out.println("^");
@@ -196,11 +246,15 @@
                        List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList());
                        String joinedString = String.join(",", collect.toString());
                        WebSocketUsers.sendMessageToUserByText(map.get(device), TightenTheConversionOkNg(joinedString));
                        if(device.contains("270") || device.contains("260")){
                            logger.info("读取到工位{}的Scaner数据:{}",device,TightenTheConversionOkNg(joinedString));
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.info("订阅方法报错:{}"+e.getMessage());
            logger.error("订阅方法报错",e);
        }
    }
@@ -226,46 +280,61 @@
            if(nullList.stream().noneMatch(s -> s.equals(device))){
                if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){
                    read = read + "ModuleCode";
                }else {
                    read = read + "PACKCode";
                }
            }
            snCode = miloService.readFromOpcUa(read).getValue().toString();
            if(null == snCode || "".equals(snCode)){
                result = "22";
            }else{
                String workOrderNo = "";
                String productCode = "";
                //2、保存过站采集数据
                Object orderNumberObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue();
                if(orderNumberObject!=null){
                    workOrderNo = orderNumberObject.toString();
            if(device.equals("OP365")){
                try {
                    result = saveStationInfo365(thoroughfare,device);
                    return result;
//                    return saveStationInfo365(thoroughfare,device);
//                    return result;
                }catch (Exception e){
                    e.printStackTrace();
                }
            }else {
                snCode = miloService.readFromOpcUa(read).getValue().toString();
                Object productCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue();
                if(productCodeObject!=null){
                    productCode = productCodeObject.toString();
                if(null == snCode || "".equals(snCode)){
                    result = "22";
                }else{
                    String workOrderNo = "";
                    String productCode = "";
                    //2、保存过站采集数据
                    Object orderNumberObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue();
                    if(orderNumberObject!=null){
                        workOrderNo = orderNumberObject.toString();
                    }
                    Object productCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue();
                    if(productCodeObject!=null){
                        productCode = productCodeObject.toString();
                    }
                    saveStationInfo(snCode,thoroughfare,device,workOrderNo,productCode);
                    //3、保存参数采集数据
                    List<DaParamCollection> daParamCollectionList = SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode);
                    //如果是末尾工站要报工
                    if(device.equals("OP500")){
                        RestfulService.getWorkReportResultFeedback(snCode,device,format.format(new Date()));
                        //1、更新工单信息
                        updateOrderInfo(snCode);
                    }
                    try{
                        daParamCollectionService.automaticWorkstationPushGeelycvMesFeedback(snCode,device,daParamCollectionList);
                    }catch (Exception e){
                    }
                    result = "21";
                }
                saveStationInfo(snCode,thoroughfare,device,workOrderNo,productCode);
                //3、保存参数采集数据
                SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode);
                //如果是末尾工站要报工
                if(device.equals("OP500")){
                    RestfulService.getWorkReportResultFeedback(snCode,device,format.format(new Date()));
                    //1、更新工单信息
                    updateOrderInfo(snCode);
                }
                result = "21";
            }
        }catch (Exception e) {
            System.out.println(e.getMessage());
            logger.error("出站保存数据异常:"+e);
        }
        return result;
    }
@@ -319,17 +388,18 @@
        daPassingStationCollection.setLocationCode(device);
        String strt = TimeUtil.stringProcessing(startTime);
        String end = TimeUtil.stringProcessing(stopTime);
        daPassingStationCollection.setInboundTime(sdf.parse(strt));//入站时间
        daPassingStationCollection.setOutboundTime(sdf.parse(end));//出站时间
        daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间
        daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间
        daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格
        daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection);
    }
    public static void SaveParamData(String packCode,String thoroughfare,String device,String workOrderNo,String productType) throws Exception {
    public static List<DaParamCollection> SaveParamData(String packCode,String thoroughfare,String device,String workOrderNo,String productType) throws Exception {
        List<DaCollectionParamConf> list;
        DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
        daCollectionParamConf.setGatherAddress(thoroughfare+ "." + device);
        list = collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
        List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
        List<String> nodeIdList = list.stream().map(info -> {
            String nodeid = info.getGatherAddress();
@@ -343,20 +413,29 @@
                    readWriteEntityList.get(i).setValue(" ");
                }
            }
            List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
            for(int i=0;i<nodeIdList.size();i++){
                if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
                    String tt = readWriteEntityList.get(i).getValue().toString();
                    DaParamCollection ParamCollection = new DaParamCollection();
                    ChildVO childVO = new ChildVO();
                    ParamCollection.setParamCode(list.get(i).getCollectParameterId());
                    ParamCollection.setLocationCode(device);
                    if(tt.contains("Time")){
                        String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt));
                        ParamCollection.setParamValue(str);
//                        String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt));
//                        ParamCollection.setParamValue(str);
                        ParamCollection.setParamValue(TimeUtil.test(TimeUtil.stringProcessing(tt)));
                    }else {
                        ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
                    }
                    ParamCollection.setSfcCode(packCode);
                    if(device.contains("OP360")){
                        String node = nodeIdList.get(i);
                        Object value = miloService.readFromOpcUa("PACK.OP360.ModuleSNCode"+node.charAt(node.length()-1)).getValue();
                        if(value!=null){
                            ParamCollection.setModuleCode(value.toString());
                        }
                    }
                    ParamCollection.setParamName(list.get(i).getCollectParameterName());
                    ParamCollection.setParamUpper(list.get(i).getParamUpper());
                    ParamCollection.setParamLower(list.get(i).getParamLower());
@@ -371,12 +450,16 @@
                }
            }
            daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
        }
        addBaseData(workOrderNo,productType,device,packCode);
        }
        List<DaParamCollection> baseDataList = addBaseData(workOrderNo,productType,device,packCode);
        for (int i = 0; i < baseDataList.size(); i++){
            daParamCollectionlist.add(baseDataList.get(i));
        }
        return daParamCollectionlist;
    }
    public static void addBaseData(String workOrderNo,String productCode,String locationCode,String packCode){
    public static List<DaParamCollection> addBaseData(String workOrderNo,String productCode,String locationCode,String packCode){
        Map<String, String> map = new HashMap<>();
        map.put("GC", "南浔工厂");
        map.put("CXBH", "Pack线");
@@ -399,6 +482,7 @@
            confList.add(saveData);
        });
        daParamCollectionService.insertBatch(confList);
        return confList;
    }
    public static void getFactoryOrder(String locationCode){
@@ -466,4 +550,73 @@
        return sb.toString();
    }
    /**
     * 校验是否存在NG
     * @param packCode sfcCode
     * @return boolean
     */
    public boolean checkIsNG(String packCode,String modelCode){
        List<DaPassingStationCollection> list = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>()
                .eq(StrUtil.isNotBlank(packCode),DaPassingStationCollection::getSfcCode, packCode)
                .eq(DaPassingStationCollection::getOutRsSign, Constants.UN_PASS));
        return CollUtil.isEmpty(list);
    }
    /**
     * 保存过站采集
     */
    public String saveStationInfo365(String thoroughfare,String device) throws Exception {
        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
        String prefix = thoroughfare+"."+device+".";
        List<DaPassingStationCollection> passingStationCollections = new ArrayList<>();
        String ModuleCodeA = "";
        String ModuleCodeB = "";
        String StationStatusA = "";
        String StationStatusB = "";
        Object objectModuleCodeA = miloService.readFromOpcUa(prefix + "ModuleCodeA").getValue();
        Object objectModuleCodeB = miloService.readFromOpcUa(prefix + "ModuleCodeB").getValue();
        Object objectStationStatusA = miloService.readFromOpcUa(prefix + "StationStatusA").getValue();
        Object objectStationStatusB = miloService.readFromOpcUa(prefix + "StationStatusB").getValue();
        if(ObjectUtil.isNotNull(objectModuleCodeA) && ObjectUtil.isNotNull(objectStationStatusA) && ObjectUtil.isNotNull(objectModuleCodeB) && ObjectUtil.isNotNull(objectStationStatusB)){
            ModuleCodeA = objectModuleCodeA.toString();
            ModuleCodeB = objectModuleCodeB.toString();
            StationStatusA = objectStationStatusA.toString();
            StationStatusB = objectStationStatusB.toString();
            String[] modeles = {ModuleCodeA,ModuleCodeB};
            String[] StationStatus = {StationStatusA,StationStatusB};
            String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString();
            String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString();
            for (int i = 0; i < 2; i++) {
                DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
                String strt = TimeUtil.stringProcessing(startTime);
                String end = TimeUtil.stringProcessing(stopTime);
                daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间
                daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间
                daPassingStationCollection.setSfcCode(modeles[i]);
                daPassingStationCollection.setLocationCode(device);
                daPassingStationCollection.setOutRsSign(StationStatus[i]);//出站是否合格
                passingStationCollections.add(daPassingStationCollection);
            }
            daPassingStationCollectionService.saveBeachDaPassingStationCollection(passingStationCollections);
//            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
            return "21";
        }else {
//            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(22).build());
            return "22";
        }
    }
    private static void writeToOpc(String identifier, short value) {
        try {
            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(identifier).value(value).build());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}