| | |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP030Callback implements SubscriptionCallback { |
| | | public class OP030Callback{ |
| | | |
| | | 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.OP030_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLC进站 |
| | | else if(null != value && identifier.equals(OPCElement.OP030_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLC出站 |
| | | else if(null != value && identifier.equals(OPCElement.OP030_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }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 { |
| | |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP030_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//写PC完成 |
| | | /* if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | }*/ |
| | | //处理过站信息 |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//出站是否合格 |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//写PC完成 |
| | | |
| | | logger.info("handleFinsh PC处理完成!"); |
| | | } |
| | | |