| | |
| | | package com.jcdm.main.plcserver.sub; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.jcdm.common.utils.StringUtils; |
| | | import com.jcdm.framework.websocket.WebSocketUsers; |
| | | import com.jcdm.main.constant.Constants; |
| | | import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
| | | import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
| | | import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
| | | import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
| | | import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
| | | import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
| | | import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface; |
| | | import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService; |
| | | import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
| | | import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
| | | import com.jcdm.main.plcserver.conf.OPCElement; |
| | |
| | | public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); |
| | | |
| | | //采集模组工位 ModuleCode |
| | | public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330"); |
| | | public List<String> moduleCodeList = Arrays.asList("OP300A","OP310A","OP310B","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330"); |
| | | |
| | | //区分模组型号工位 |
| | | public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); |
| | |
| | | |
| | | public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
| | | |
| | | private static IDaTestDeviceInterfaceService daTestDeviceInterfaceService; |
| | | |
| | | |
| | | public OPCUaSubscription(MiloService miloService, |
| | | IDaPassingStationCollectionService daPassingStationCollectionService, |
| | | IDaCollectionParamConfService collectionParamConfService, |
| | | IDaParamCollectionService daParamCollectionService, |
| | | IOmProductionOrdeInfoService omProductionOrdeInfoService) { |
| | | IOmProductionOrdeInfoService omProductionOrdeInfoService, |
| | | IDaTestDeviceInterfaceService daTestDeviceInterfaceService) { |
| | | OPCUaSubscription.miloService = miloService; |
| | | this.daPassingStationCollectionService = daPassingStationCollectionService; |
| | | OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
| | | OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
| | | OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
| | | OPCUaSubscription.daTestDeviceInterfaceService = daTestDeviceInterfaceService; |
| | | } |
| | | |
| | | |
| | |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | //读模组码 |
| | | Object moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
| | | if(device.equals("OP365")){ |
| | | Object moduleCodeA = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeA").getValue(); |
| | | Object moduleCodeB = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeB").getValue(); |
| | | if(moduleCodeA!=null && moduleCodeB!=null){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | | }else { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if(moduleCode!=null){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | |
| | | }else { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }else { |
| | | //手动工位处理逻辑 |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "IN"); |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | | // if (map.containsKey(device)){ |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "IN"); |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build()); |
| | | }else { |
| | | //手动工位 |
| | | if(device.contains("OP330")){ |
| | | String str = device.substring(0,5); |
| | | WebSocketUsers.sendMessageToUserByText(map.get(str), "END"); |
| | | }else { |
| | | // if(device.contains("OP330")){ |
| | | // String str = device.substring(0,5); |
| | | // WebSocketUsers.sendMessageToUserByText(map.get(str), "END"); |
| | | // }else { |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
| | | } |
| | | // } |
| | | if(testList.stream().anyMatch(s -> s.equals(device))){ |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | // Object packCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
| | | // DaTestDeviceInterface deviceInterfaceOne = null; |
| | | // |
| | | // if (ObjectUtil.isNotNull(packCodeObject)) { |
| | | // String modelCode = packCodeObject.toString(); |
| | | // deviceInterfaceOne = daTestDeviceInterfaceService.getOne(new LambdaQueryWrapper<DaTestDeviceInterface>() |
| | | // .eq(DaTestDeviceInterface::getProductNum, modelCode) |
| | | // .eq(DaTestDeviceInterface::getStationCode, device)); |
| | | // } |
| | | // |
| | | // if (deviceInterfaceOne != null && "1".equals(deviceInterfaceOne.getTotalResult())) { |
| | | // writeToOpc(RecordDataDoneAddress, (short) 21); |
| | | // } else { |
| | | // writeToOpc(RecordDataDoneAddress, (short) 22); |
| | | // } |
| | | // writeToOpc(RecordDataDoneAddress, (short) 21); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build()); |
| | | } |
| | | |
| | | |
| | | } |
| | | }else { |
| | | System.out.println("^"); |
| | |
| | | if(nullList.stream().noneMatch(s -> s.equals(device))){ |
| | | if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ |
| | | read = read + "ModuleCode"; |
| | | if(device.equals("OP365")){ |
| | | try { |
| | | saveStationInfo365(thoroughfare,device); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else { |
| | | read = read + "PACKCode"; |
| | | } |
| | |
| | | //1、更新工单信息 |
| | | updateOrderInfo(snCode); |
| | | } |
| | | |
| | | try{ |
| | | daParamCollectionService.pushGeelycvMesFeedback(snCode,device); |
| | | }catch (Exception e){ |
| | | } |
| | | result = "21"; |
| | | |
| | | } |
| | |
| | | daPassingStationCollection.setLocationCode(device); |
| | | String strt = TimeUtil.stringProcessing(startTime); |
| | | String end = TimeUtil.stringProcessing(stopTime); |
| | | daPassingStationCollection.setInboundTime(sdf.parse(strt));//入站时间 |
| | | daPassingStationCollection.setOutboundTime(sdf.parse(end));//出站时间 |
| | | daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间 |
| | | daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间 |
| | | daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格 |
| | | daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection); |
| | | } |
| | |
| | | if(tt.contains("Time")){ |
| | | // String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt)); |
| | | // ParamCollection.setParamValue(str); |
| | | ParamCollection.setParamValue(TimeUtil.getYyyyDdMm(TimeUtil.stringProcessing(tt))); |
| | | ParamCollection.setParamValue(TimeUtil.test(TimeUtil.stringProcessing(tt))); |
| | | }else { |
| | | ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); |
| | | } |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验是否存在NG |
| | | * @param packCode sfcCode |
| | | * @return boolean |
| | | */ |
| | | public boolean checkIsNG(String packCode,String modelCode){ |
| | | List<DaPassingStationCollection> list = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>() |
| | | .eq(StrUtil.isNotBlank(packCode),DaPassingStationCollection::getSfcCode, packCode) |
| | | .eq(DaPassingStationCollection::getOutRsSign, Constants.UN_PASS)); |
| | | return CollUtil.isEmpty(list); |
| | | } |
| | | |
| | | /** |
| | | * 保存过站采集 |
| | | */ |
| | | public void saveStationInfo365(String thoroughfare,String device) throws Exception { |
| | | String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
| | | String prefix = thoroughfare+"."+device+"."; |
| | | List<DaPassingStationCollection> passingStationCollections = new ArrayList<>(); |
| | | String ModuleCodeA = ""; |
| | | String ModuleCodeB = ""; |
| | | String StationStatusA = ""; |
| | | String StationStatusB = ""; |
| | | |
| | | Object objectModuleCodeA = miloService.readFromOpcUa(prefix + "ModuleCodeA").getValue(); |
| | | Object objectModuleCodeB = miloService.readFromOpcUa(prefix + "ModuleCodeB").getValue(); |
| | | Object objectStationStatusA = miloService.readFromOpcUa(prefix + "StationStatusA").getValue(); |
| | | Object objectStationStatusB = miloService.readFromOpcUa(prefix + "StationStatusB").getValue(); |
| | | |
| | | if(ObjectUtil.isNotNull(objectModuleCodeA) && ObjectUtil.isNotNull(objectStationStatusA) && ObjectUtil.isNotNull(objectModuleCodeB) && ObjectUtil.isNotNull(objectStationStatusB)){ |
| | | ModuleCodeA = objectModuleCodeA.toString(); |
| | | ModuleCodeB = objectModuleCodeB.toString(); |
| | | StationStatusA = objectStationStatusA.toString(); |
| | | StationStatusB = objectStationStatusB.toString(); |
| | | |
| | | String[] modeles = {ModuleCodeA,ModuleCodeB}; |
| | | String[] StationStatus = {StationStatusA,StationStatusB}; |
| | | |
| | | String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString(); |
| | | String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString(); |
| | | for (int i = 0; i < 2; i++) { |
| | | DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
| | | String strt = TimeUtil.stringProcessing(startTime); |
| | | String end = TimeUtil.stringProcessing(stopTime); |
| | | daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间 |
| | | daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间 |
| | | daPassingStationCollection.setSfcCode(modeles[i]); |
| | | daPassingStationCollection.setLocationCode(device); |
| | | daPassingStationCollection.setOutRsSign(StationStatus[i]);//出站是否合格 |
| | | passingStationCollections.add(daPassingStationCollection); |
| | | } |
| | | daPassingStationCollectionService.saveBeachDaPassingStationCollection(passingStationCollections); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build()); |
| | | return; |
| | | }else { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(22).build()); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | private static void writeToOpc(String identifier, short value) { |
| | | try { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(identifier).value(value).build()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | } |