| | |
| | | public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | //新自动工站 |
| | | public List<String> automaticList = Arrays.asList("OP280", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); |
| | | public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); |
| | | |
| | | //自动工位 |
| | | // public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320A","OP320B", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); |
| | | //采集模组工位 ModuleCode |
| | | public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330"); |
| | | |
| | | //采集模组工位 |
| | | public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); |
| | | //区分模组型号工位 |
| | | public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); |
| | | |
| | | //区分小车码 |
| | | public List<String> agvId = Arrays.asList("OP360", "OP390", "OP470","OP280"); |
| | | |
| | | |
| | | //区分pack型号的工位 |
| | | public List<String> packIdList = Arrays.asList("OP280"); |
| | | public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470"); |
| | | |
| | | |
| | | //空的 |
| | | public List<String> nullList = Arrays.asList("OP250","OP260"); |
| | |
| | | //自动工位 |
| | | if(automaticList.stream().anyMatch(s -> s.equals(device))){ |
| | | //plc给我们一个模组码,拿模组码校验出型号 |
| | | if(moduleCodeList.stream().anyMatch(s -> s.equals(device))) { |
| | | if(distinguishingModules.stream().anyMatch(s -> s.equals(device))) { |
| | | //读模组码 |
| | | String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); |
| | | String productTye = thoroughfare + "." + device + ".ProductType"; |
| | | if (null != moduleCode && moduleCode.length() == 24) { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7, 8))).build()); |
| | | //进站保存数据 |
| | | // inSaveDate(thoroughfare,device) |
| | | //记录数据完成 |
| | | // String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); |
| | | // String productTye = thoroughfare + "." + device + ".ProductType"; |
| | | // if (null != moduleCode && moduleCode.length() == 24) { |
| | | // miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7, 8))).build()); |
| | | // //进站保存数据 |
| | | //// inSaveDate(thoroughfare,device) |
| | | // //记录数据完成 |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | |
| | | // |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | | |
| | | |
| | | //请求工单 |
| | | } else { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
| | | // |
| | | // |
| | | // //请求工单 |
| | | // } else { |
| | | // miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
| | | // } |
| | | }else { |
| | | if(agvId.stream().anyMatch(s -> s.equals(device))){ |
| | | String agvId = miloService.readFromOpcUa(thoroughfare + "." + device + ".AGVID").getValue().toString(); |
| | | String PACKCode = thoroughfare + "." + device + ".MPACKCode"; |
| | | if (null != agvId) { |
| | | OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, agvId)); |
| | | String packId = one.getProductNum(); |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(PACKCode).value(packId).build()); |
| | | } else { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
| | | } |
| | | } |
| | | //pack 如果区分型号的话就要处理 |
| | | //记录数据完成 |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | | } |
| | | }else { |
| | | //手动工位处理逻辑 |
| | |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build()); |
| | | }else { |
| | | //手动工位 |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
| | | if(device.contains("OP330")){ |
| | | String str = device.substring(0,5); |
| | | WebSocketUsers.sendMessageToUserByText(map.get(str), "END"); |
| | | }else { |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
| | | } |
| | | } |
| | | }else { |
| | | System.out.println("^"); |
| | |
| | | List<ReadWriteEntity> list1 = miloService.readFromOpcUa(list); |
| | | List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList()); |
| | | String joinedString = String.join(",", collect.toString()); |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), joinedString); |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), TightenTheConversionOkNg(joinedString)); |
| | | } |
| | | } |
| | | } |
| | |
| | | String workOrderNo = ""; |
| | | String productCode = ""; |
| | | //2、保存过站采集数据 |
| | | // String workOrderNo = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue().toString(); |
| | | // String productCode = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue().toString(); |
| | | Object orderNumberObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue(); |
| | | if(orderNumberObject!=null){ |
| | | workOrderNo = orderNumberObject.toString(); |
| | |
| | | omProductionOrdeInfoService.saveOrUpdate(one); |
| | | } |
| | | |
| | | public static void avgFunction(){ |
| | | |
| | | } |
| | | |
| | | public static String TightenTheConversionOkNg(String param){ |
| | | // 去除首尾的方括号,然后按照逗号分割字符串 |
| | | String[] parts = param.substring(1, param.length() - 1).split(","); |
| | | |
| | | // 创建一个新的StringBuilder来构建替换后的字符串 |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append('['); // 添加左方括号 |
| | | |
| | | for (int i = 0; i < parts.length; i++) { |
| | | String part = parts[i].trim(); // 去除可能的空格 |
| | | float value; |
| | | try { |
| | | value = Float.parseFloat(part); // 尝试将字符串转换为浮点数 |
| | | String replacement; |
| | | if (value == 1f) { |
| | | replacement = "OK"; |
| | | } else if (value == 2f) { |
| | | replacement = "NG"; |
| | | } else { |
| | | replacement = part; // 如果不是1或2,则保持不变 |
| | | } |
| | | sb.append(replacement); |
| | | if (i < parts.length - 1) { |
| | | sb.append(','); // 添加逗号(除了最后一个元素) |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // 如果转换失败,则保持原样(或进行其他错误处理) |
| | | sb.append(part); |
| | | if (i < parts.length - 1) { |
| | | sb.append(','); |
| | | } |
| | | } |
| | | } |
| | | sb.append(']'); // 添加右方括号 |
| | | return sb.toString(); |
| | | } |
| | | |
| | | } |