cl
2024-02-23 73bc0656dc15cd9cc95c6f4f51949ef0437088ce
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java
@@ -43,7 +43,7 @@
import java.util.List;
@Component
public class OP090Callback implements SubscriptionCallback {
public class OP090Callback{
    public MiloService miloService;
@@ -127,43 +127,6 @@
        this.productionOrderBatchInfoService = productionOrderBatchInfoService;
    }
    @Override
    public void onSubscribe(String identifier, Object value) {
        String ecpStr = "";//异常记录标记
        try {
            //心跳
            if(null != value && identifier.equals(OPCElement.OP090_F_HEART_BEAT)){
                if( "false".equals(value.toString()))
                {
                    ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_F_HEART_BEAT,true);
                    miloService.writeToOpcUa(entity);
                }
            }
            //PLC进站
            else if(null != value && identifier.equals(OPCElement.OP090_J_PLC_START)){
                if("true".equals(value.toString())){
                    handleOrder();
                }
            }
            //PLC出站
            else if(null != value && identifier.equals(OPCElement.OP090_J_PLC_FINISH)){
                if("true".equals(value.toString())){
                    handleMaterial();
                    handleFinsh();
                    handleInfo();
                }
            }else{
                System.out.println("值没有变");
            }
        } catch (Exception e) {
            ecpStr ="出现异常:" + logUtil.getTrace(e);
        }finally {
            if(!"".equals(ecpStr)){
                logger.info(ecpStr+"\r\n");
            }
        }
    }
    //PC读工单
    public void handleOrder() throws Exception {
@@ -207,6 +170,14 @@
            S_PRODUCT_STATE_CODE = object.toString();
        }
        Object eopSfcCode = miloService.
                readFromOpcUa(OPCElement.OP090_S_SFC_CODE_EOP)
                .getValue();
        ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_J_PC_FINISH,true);
        miloService.writeToOpcUa(entity);//写PC完成
        PassingStationCollectionParam param = new PassingStationCollectionParam();
        param.setWorkOrderNo(S_ORDER_CODE);
        param.setProductCode(S_PRODUCT_CODE);
@@ -218,9 +189,7 @@
        param.setOutRsSign(S_PRODUCT_STATE_CODE);//出站是否合格
        passingStationCollectionService.add(param);
        Object eopSfcCode = miloService.
                readFromOpcUa(OPCElement.OP090_S_SFC_CODE_EOP)
                .getValue();
        if(null != eopSfcCode) {
            //根据分总成编码,将EOP物料数据绑定关系修改为总成编码
@@ -235,7 +204,7 @@
            logger.info("S_SFC_CODE:" + S_SFC_CODE);
            logger.info("eopSfcCode:" + eopSfcCode);
        }
        //查询COP和BOP是否合格
       /* //查询COP和BOP是否合格
        PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam();
        passingStationCollectionParam.setSfcCode(S_SFC_CODE);
        List<PassingStationCollectionResult> passingStationCollectionResultList =
@@ -262,10 +231,9 @@
                productionOrderRecordsParam.setWhetherPass("2");
                productionOrderRecordsService.update(productionOrderRecordsParam);
            }
        }
        }*/
        ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_J_PC_FINISH,true);
        miloService.writeToOpcUa(entity);//写PC完成
        logger.info("handleFinsh PC处理完成!");
    }
    public void handleMaterial() {