| | |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP050Callback implements SubscriptionCallback { |
| | | public class OP050Callback{ |
| | | |
| | | public MiloService miloService; |
| | | |
| | |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//异常记录标记 |
| | | try { |
| | | //心跳 |
| | | if(null != value && identifier.equals(OPCElement.OP050_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLC进站 |
| | | else if(null != value && identifier.equals(OPCElement.OP050_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLC出站 |
| | | else if(null != value && identifier.equals(OPCElement.OP050_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 { |
| | |
| | | |
| | | logger.info("handleFinsh PC处理开始!"); |
| | | |
| | | |
| | | Object copSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP) |
| | | .getValue(); |
| | | Object bopSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP) |
| | | .getValue(); |
| | | |
| | | |
| | | Object object = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_PRODUCT_STATE_CODE) |
| | | .getValue(); |
| | |
| | | if(null != object){ |
| | | S_PRODUCT_STATE_CODE = object.toString(); |
| | | } |
| | | |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//写PC完成 |
| | | |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | |
| | | passingStationCollectionService.add(param); |
| | | |
| | | |
| | | Object copSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP) |
| | | .getValue(); |
| | | Object bopSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP) |
| | | .getValue(); |
| | | |
| | | |
| | | if(null != copSfcCode && null != bopSfcCode){ |
| | | //根据分总成编码,将EOP物料数据绑定关系修改为总成编码 |
| | |
| | | logger.info("bopSfcCode:"+bopSfcCode); |
| | | |
| | | //查询COP和BOP是否合格 |
| | | PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); |
| | | /* PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); |
| | | passingStationCollectionParam.setSfcCode(S_SFC_CODE); |
| | | List<PassingStationCollectionResult> passingStationCollectionResultList = |
| | | passingStationCollectionService.findListBySpec(passingStationCollectionParam); |
| | |
| | | productionOrderRecordsParam.setWhetherPass("2"); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//写PC完成 |
| | | |
| | | logger.info("handleFinsh PC处理完成!"); |
| | | } |
| | | public void handleMaterial() { |