| | |
| | | |
| | | @Override |
| | | public void saveCampaignTimeParameters(DaParamCollection daParamCollection) { |
| | | // List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
| | | // .eq(BsFormulaChildInfo::getProcessesCode, daParamCollection.getLocationCode()) |
| | | // .eq(BsFormulaChildInfo::getSpareField4, "1") |
| | | // ); |
| | | |
| | | BsFormulaChildInfo childInfo = daParamCollection.getFormulaChildEntity(); |
| | | if(StringUtils.isNotBlank(childInfo.getResults())){ |
| | | if(!childInfo.getResults().equals("OK")){ |
| | | try { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | } |
| | | }else { |
| | | try { |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return; |
| | | } |
| | | // BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo(); |
| | | // bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode()); |
| | | // bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode()); |
| | | // bsFormulaChildInfo.setSpareField4("1"); |
| | | // List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
| | | |
| | | String result = childInfo.getResults(); |
| | | if(result != null && !result.isEmpty()){ |
| | | try { |
| | | // //更新参数采集配置表 |
| | | // DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
| | | // daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
| | | // daCollectionParamConf.setCollectParameterId("OUTT"); |
| | | // List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
| | | // DaParamCollection saveData = new DaParamCollection(); |
| | | // saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
| | | // saveData.setProductCode(daParamCollection.getProductCode()); |
| | | // saveData.setLocationCode(daParamCollection.getLocationCode()); |
| | | // saveData.setSfcCode(daParamCollection.getProductBarcode()); |
| | | // saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
| | | // saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
| | | // saveData.setCollectionTime(new Date()); |
| | | // saveData.setParamValue(DateUtil.formatDateTime(new Date())); |
| | | // daParamCollectionMapper.insertDaParamCollection(saveData); |
| | | |
| | | //增加过站记录 |
| | | DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
| | |
| | | boolean save = daPassingStationCollectionService.save(daPassingStationCollection); |
| | | |
| | | //添加基础参数 |
| | | this.manualWorkstationsAddBasicParameters(daParamCollection); |
| | | // this.manualWorkstationsAddBasicParameters(daParamCollection); |
| | | |
| | | // //更新过站记录表出站时间 |
| | | // DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
| | | // daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
| | | // daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); |
| | | // List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
| | | // daPassingStationCollections.get(0).setOutboundTime(new Date()); |
| | | // int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
| | | |
| | | // OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
| | | //半自动工位,先将自动数据保存到数据库 |
| | | this.saveParameters(daParamCollection); |
| | | |
| | | //给opc发21 |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
| | | if(daParamCollection.getLocationCode().equals("OP240")){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
| | | if(daParamCollection.getLocationCode().equals("M1OP100-1") || daParamCollection.getLocationCode().equals("M1OP100-2") ){ |
| | | try{ |
| | | CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | logger.info("OP230报工开始-工厂MES异步方法"); |
| | | String reportResult = RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(), "OP230", format.format(new Date())); |
| | | logger.info("OP100报工开始-工厂MES异步方法"); |
| | | String stationCode = "M1OP100"; |
| | | String reportResult = RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(), stationCode, format.format(new Date())); |
| | | JSONObject jsonObject = new JSONObject(reportResult); |
| | | String code = jsonObject.getStr("code"); |
| | | if("success".equals(code)){ |
| | | //如果成功,执行报工成功方法,修改是否报工为1,添加报工时间 |
| | | omProductionOrdeInfoService.updateOrderByProductNum("1",daParamCollection.getProductBarcode(),"OP230"); |
| | | omProductionOrdeInfoService.updateOrderByProductNum("1",daParamCollection.getProductBarcode(),daParamCollection.getLocationCode()); |
| | | }else{ |
| | | //解析工厂mes返回结果,如果失败,执行报工失败方法,修改是否报工为2,添加报工时间 |
| | | omProductionOrdeInfoService.updateOrderByProductNum("2",daParamCollection.getProductBarcode(),"OP230"); |
| | | omProductionOrdeInfoService.updateOrderByProductNum("2",daParamCollection.getProductBarcode(),daParamCollection.getLocationCode()); |
| | | } |
| | | logger.info("OP230报工结束-工厂MES异步方法{}"+reportResult); |
| | | logger.info("OP100报工结束-工厂MES异步方法{}"+reportResult); |
| | | }); |
| | | }catch (Exception e){ |
| | | System.out.println(e.getMessage()); |
| | | } |
| | | // RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(),"OP230",format.format(new Date())); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //半自动工位,先将自动数据保存到数据库 |
| | | public void saveParameters(DaParamCollection daParamCollection) { |
| | | //添加自动工位参数数据 |
| | | //查询参数配置表 |
| | | List<DaCollectionParamConf> list = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
| | | .eq(DaCollectionParamConf::getProcessesCode, daParamCollection.getLocationCode())//工位 |
| | | .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集 |
| | | );//类型 |
| | | |
| | | List<String> collectAddressList = list.stream() |
| | | .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
| | | List<ReadWriteEntity> paramCollectionList = null;//模组 参数值 |
| | | try { |
| | | paramCollectionList = miloService.readFromOpcUa(collectAddressList); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(paramCollectionList)) { |
| | | List<DaParamCollection> saveParamList = new ArrayList<>();//封装参数采集list |
| | | List<DaParamCollectionTemp> saveParamListTemp = new ArrayList<>();//封装参数采集list |
| | | for (int i = 0; i < paramCollectionList.size(); i++) { |
| | | DaParamCollection collection = new DaParamCollection(); |
| | | collection.setSfcCode(daParamCollection.getProductBarcode());//模组码 |
| | | collection.setParamCode(list.get(i).getCollectParameterId());//参数编码 |
| | | collection.setParamName(list.get(i).getCollectParameterName());//参数名称 |
| | | String paramValue = ""; |
| | | if (ObjectUtil.isNotNull(paramCollectionList.get(i).getValue())) { |
| | | paramValue = paramCollectionList.get(i).getValue().toString();//参数值 |
| | | } |
| | | collection.setParamValue(paramValue);//参数值 |
| | | collection.setLocationCode(daParamCollection.getLocationCode());//工位 |
| | | collection.setCollectionTime(new Date());//采集时间 |
| | | saveParamList.add(collection);//封装参数采集list |
| | | |
| | | DaParamCollectionTemp collectionTemp = new DaParamCollectionTemp(); |
| | | collectionTemp.setSfcCode(daParamCollection.getProductBarcode());//模组码 |
| | | collectionTemp.setParamCode(list.get(i).getCollectParameterId());//参数编码 |
| | | collectionTemp.setParamName(list.get(i).getCollectParameterName());//参数名称 |
| | | |
| | | if (ObjectUtil.isNotNull(paramCollectionList.get(i).getValue())) { |
| | | paramValue = paramCollectionList.get(i).getValue().toString();//参数值 |
| | | } |
| | | collectionTemp.setParamValue(paramValue);//参数值 |
| | | collectionTemp.setLocationCode(daParamCollection.getLocationCode());//工位 |
| | | collectionTemp.setCollectionTime(new Date());//采集时间 |
| | | saveParamListTemp.add(collectionTemp);//封装参数采集list |
| | | |
| | | } |
| | | //插入参数采集表 |
| | | daParamCollectionService.insertBatch(saveParamList); |
| | | //插入参数采集表 |
| | | daParamCollectionTempService.insertBatch(saveParamListTemp); |
| | | } |
| | | } |
| | | @Override |
| | | public void insertBatch(List<DaParamCollection> confList){ |
| | | try{ |
| | |
| | | daPassingStationCollections.get(0).setOutboundTime(new Date()); |
| | | int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
| | | |
| | | // OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
| | | |
| | | //给opc发21 |
| | | try { |
| | | // miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
| | | String strA = daParamCollection.getLocationCode(); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strA+".RecordDataDone").value(21).build()); |
| | | } catch (Exception e) { |
| | |
| | | public void pushGeelycvMesFeedback(String packID, String stationCode) { |
| | | logger.info("进入人工工位推送工厂MES数据方法-pushGeelycvMesFeedback-工位{}-pack码{}",stationCode,packID); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
| | | // String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
| | | String totalResult = "0"; |
| | | List<DaParamCollectionTemp> paramList = daParamCollectionTempService.list(new LambdaQueryWrapper<DaParamCollectionTemp>().eq(DaParamCollectionTemp::getSfcCode, packID).eq(DaParamCollectionTemp::getLocationCode, stationCode)); |
| | | if(paramList.size() > 0){ |
| | |
| | | try{ |
| | | CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | logger.info("开始执行异步方法"); |
| | | HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | logger.info("异步方法执行结束"); |
| | | logger.info("手动工位传工厂MES异步方法{}"+execute.body()); |
| | | |
| | |
| | | public void automaticWorkstationPushGeelycvMesFeedback(String packID, String stationCode,List<DaParamCollection> paramList) { |
| | | logger.info("进入工位{}-工厂MES推送数据方法automaticWorkstationPushGeelycvMesFeedback",stationCode); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
| | | String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
| | | String totalResult = "0"; |
| | | if(paramList.size() > 0){ |
| | | logger.info("进入工位{}-拼数据",stationCode); |
| | |
| | | try{ |
| | | CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | logger.info("开始执行异步方法"); |
| | | HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | System.out.println(execute.body()); |
| | | logger.info("异步方法执行结束"); |
| | | logger.info("自动工位传工厂MES异步方法{}"+execute.body()); |