| | |
| | | if (Constants.RECORD_DATA.equals(tab)) { //出入站 |
| | | if (Constants.ONE.equals(valueString)) {//入站 |
| | | if(Constants.OP040_OP160.contains(device)){ |
| | | Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".snCode").getValue(); |
| | | Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); |
| | | if (ObjectUtil.isNull(snCodeObjcet)){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
| | | }else{ |
| | |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(recordDataDone).build()); |
| | | } |
| | | } else if(Constants.TWO.equals(valueString)){//出站 |
| | | Integer result = 21; |
| | | //先判断是否有产品SN |
| | | Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); |
| | | Object orderObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); |
| | | if (ObjectUtil.isNull(snCodeObjcet)){ |
| | | result = 25;//未获取要生产的工单,请联系管理员 |
| | | }else{ |
| | | String snCode = snCodeObjcet.toString();//产品SN |
| | | String orderNumber = orderObjcet.toString();//工单号 |
| | | Object stationStatusObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus").getValue();//站状态地址 |
| | | if (ObjectUtil.isNotNull(stationStatusObjcet)){ |
| | | String stationStatus = stationStatusObjcet.toString(); |
| | | if(Constants.OP010.equals(device)) { |
| | | updateOrderStatus(snCode, "3");//OP010工位更新工单状态为执行中 |
| | | reportFactoryMes(snCode, device, format.format(new Date()));//工厂MES报工 |
| | | if(Constants.OP040_OP160.contains(device)){//人工工位 |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
| | | }else{//自动工位 |
| | | //先判断是否有产品SN |
| | | Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); |
| | | Object orderObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); |
| | | if (ObjectUtil.isNull(snCodeObjcet)){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(25).build()); |
| | | }else { |
| | | Integer result = 21; |
| | | String snCode = snCodeObjcet.toString();//产品SN |
| | | String orderNumber = orderObjcet.toString();//工单号 |
| | | Object stationStatusObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus").getValue();//站状态地址 |
| | | if (ObjectUtil.isNotNull(stationStatusObjcet)) { |
| | | String stationStatus = stationStatusObjcet.toString(); |
| | | if (Constants.OP010.equals(device)) { |
| | | updateOrderStatus(snCode, "3");//OP010工位更新工单状态为执行中 |
| | | reportFactoryMes(snCode, device, format.format(new Date()));//工厂MES报工 |
| | | } |
| | | result = savePassingStation(thoroughfare, device, snCode, orderNumber, stationStatus);//保存过站 |
| | | if (result == 21) { |
| | | result = saveParamCollection(device, snCode, orderNumber, stationStatus);//保存参数,发送工厂MES |
| | | } |
| | | } else { |
| | | result = 23; |
| | | log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}", device, "IS NULL!", result); |
| | | } |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
| | | } |
| | | result = savePassingStation(thoroughfare, device,snCode,orderNumber,stationStatus);//保存过站 |
| | | if(result == 21) { |
| | | result = saveParamCollection(device,snCode,orderNumber,stationStatus);//保存参数,发送工厂MES |
| | | } |
| | | }else{ |
| | | result = 23; |
| | | log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
| | | } |
| | | } |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
| | | } |
| | | }else if (Constants.RECORD_SN.equals(tab)){//请求产品序列号 |
| | | if (Constants.ONE.equals(valueString)){ |
| | |
| | | } |
| | | //下发产品SN和工单号 |
| | | if(!productNum.isEmpty() && !orderNum.isEmpty()){ |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SNCode").value(productNum).build()); |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(orderNum).build()); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(11).build()); |
| | | } |