| | |
| | | import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
| | | import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
| | | import com.jcdm.main.plcserver.conf.OPCElement; |
| | | import com.jcdm.main.plcserver.util.TimeUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.websocket.Session; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | //自动工位 |
| | | public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); |
| | | |
| | | public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP33"); |
| | | //采集模组工位 |
| | | public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP330"); |
| | | |
| | | //空的 |
| | | public List<String> nullList = Arrays.asList("OP250","OP260"); |
| | | |
| | | |
| | |
| | | recordDataDoneValue = "11"; |
| | | //校验入站是否可以工作 |
| | | |
| | | //plc给我们一个pack码,拿pack码校验出型号 |
| | | if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ |
| | | //读模组码 |
| | | String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); |
| | | String productTye = thoroughfare + "." + device + ".ProductType"; |
| | | 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()); |
| | | |
| | | if(automaticList.stream().noneMatch(s -> s.equals(device))){ |
| | |
| | | } |
| | | //保存拧紧数据 |
| | | else if (("AngleResult").equals(tab)) { |
| | | if("OK".equals(tabVlaue)||"NG".equals(tabVlaue)){ |
| | | if("1".equals(tabVlaue)||"2".equals(tabVlaue)){ |
| | | List<String> list = new ArrayList<>(); |
| | | String[] suffixes = {"Torque", "Angle", "TorqueResult", "AngleResult"}; |
| | | |
| | |
| | | String workOrderNo = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue().toString(); |
| | | String productCode = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue().toString(); |
| | | |
| | | |
| | | saveStationInfo(snCode,thoroughfare,device,workOrderNo,productCode); |
| | | //3、保存参数采集数据 |
| | | SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode); |
| | |
| | | * 保存过站采集 |
| | | */ |
| | | public void saveStationInfo(String packCode,String thoroughfare,String device,String workOrderNo,String productCode) throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); |
| | | sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); // CST通常表示中国标准时间,即东八区 |
| | | String prefix = thoroughfare+"."+device+"."; |
| | | String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString(); |
| | | String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString(); |
| | |
| | | daPassingStationCollection.setWorkOrderNo(workOrderNo); |
| | | daPassingStationCollection.setProductCode(productCode); |
| | | daPassingStationCollection.setLocationCode(device); |
| | | // daPassingStationCollection.setInboundTime(startTime);//入站时间 |
| | | // daPassingStationCollection.setOutboundTime(stopTime);//出站时间 |
| | | String strt = TimeUtil.stringProcessing(startTime); |
| | | String end = TimeUtil.stringProcessing(stopTime); |
| | | daPassingStationCollection.setInboundTime(sdf.parse(strt));//入站时间 |
| | | daPassingStationCollection.setOutboundTime(sdf.parse(end));//出站时间 |
| | | daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格 |
| | | daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection); |
| | | } |
| | |
| | | List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); |
| | | for(int i=0;i<nodeIdList.size();i++){ |
| | | if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ |
| | | String tt = readWriteEntityList.get(i).getValue().toString(); |
| | | DaParamCollection ParamCollection = new DaParamCollection(); |
| | | ParamCollection.setParamCode(list.get(i).getCollectParameterId()); |
| | | ParamCollection.setLocationCode(device); |
| | | ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); |
| | | if(tt.contains("Time")){ |
| | | String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt)); |
| | | ParamCollection.setParamValue(str); |
| | | }else { |
| | | ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); |
| | | } |
| | | ParamCollection.setSfcCode(packCode); |
| | | ParamCollection.setParamName(list.get(i).getCollectParameterName()); |
| | | ParamCollection.setParamUpper(list.get(i).getParamUpper()); |