cl
2024-02-23 73bc0656dc15cd9cc95c6f4f51949ef0437088ce
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/COP010Callback.java
@@ -49,7 +49,7 @@
import java.util.*;
@Component
public class COP010Callback implements SubscriptionCallback {
public class COP010Callback  {
    public MiloService miloService;
@@ -132,50 +132,6 @@
        this.productionOrderRecordsService = productionOrderRecordsService;
        this.productionOrderBatchInfoService = productionOrderBatchInfoService;
    }
    @Override
    public void onSubscribe(String identifier, Object value) {
        String ecpStr = "";//异常记录标记
        try {
            //心跳
            if(null != value && identifier.equals(OPCElement.COP010_F_HEART_BEAT)){
                if( "false".equals(value.toString()))
                {
                    ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_F_HEART_BEAT,true);
                    miloService.writeToOpcUa(entity);
                }
            }
            //PLC进站
            else if(null != value && identifier.equals(OPCElement.COP010_J_PLC_START)){
                if("true".equals(value.toString())){
                    String isRepair = miloService.
                            readFromOpcUa(OPCElement.COP010_P_REPAIR)
                            .getValue().toString();//是否返修
                    if(isRepair.equals("true")){
                        handleRepair();
                    }else{
                        handleOrder();
                    }
                }
            }
            //PLC出站
            else if(null != value && identifier.equals(OPCElement.COP010_J_PLC_FINISH)){
                if("true".equals(value.toString())){
                    handleFinsh();
                    handleInfo();
                    handleMaterial();
                }
            }else{
                System.out.println("COP010值没有变");
            }
        } catch (Exception e) {
            ecpStr ="出现异常:" + logUtil.getTrace(e);
        }finally {
            if(!"".equals(ecpStr)){
                logger.info(ecpStr+"\r\n");
            }
            System.out.println("finally" +ecpStr);
        }
    }
    public void handleOrder() throws Exception{
@@ -215,7 +171,8 @@
        String S_PRODUCT_STATE_CODE = miloService.
                readFromOpcUa(OPCElement.COP010_S_PRODUCT_STATE_CODE)
                .getValue().toString();
        ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_J_PC_FINISH,true);
        miloService.writeToOpcUa(entity);//写PC完成
        //处理过站信息
        PassingStationCollectionParam param = new PassingStationCollectionParam();
        param.setWorkOrderNo(S_ORDER_CODE);
@@ -228,8 +185,7 @@
        param.setOutRsSign(S_PRODUCT_STATE_CODE);//出站是否合格
        passingStationCollectionService.add(param);
        ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_J_PC_FINISH,true);
        miloService.writeToOpcUa(entity);//写PC完成
        logger.info("handleFinsh PC处理完成!");
    }