| | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.jcdm.framework.websocket.WebSocketUsers; |
| | | import com.jcdm.main.constant.Constants; |
| | | import com.jcdm.main.da.cellData.service.IDaCellDataService; |
| | |
| | | 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 |
| | |
| | | mesList.add(childVO); |
| | | } |
| | | |
| | | /* CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | /*CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | //插入参数采集表 |
| | | daParamCollectionService.insertBatch(collectionList); |
| | | //生产报工(首工位和末工位) |
| | | if(Constants.OP010.equals(device)) { |
| | | reportFactoryMes(snCode, device, format.format(new Date())); |
| | | } |
| | | //上传到工厂mes |
| | | ParentVO parentVO = new ParentVO(); |
| | | parentVO.setStationCode(device);//工位 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更新工单 |
| | | * @param snCode 产品sn |
| | | * @param orderStatus 工单状态 |
| | | * @throws Exception e |
| | | */ |
| | | private static void updateOrderStatus(String snCode,String orderStatus){ |
| | | try { |
| | | //更新工单状态为已执行 |
| | | LambdaUpdateWrapper<OmProductionOrdeInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(OmProductionOrdeInfo::getOrderStatus,orderStatus); |
| | | updateWrapper.eq(OmProductionOrdeInfo::getProductNum,snCode); |
| | | omProductionOrdeInfoService.update(new OmProductionOrdeInfo(),updateWrapper); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 工厂MES报工 |
| | | * @param productNum 通道 |
| | | * @param stationCode 工位 |
| | |
| | | //{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"报工成功"},"message":"API调用成功"} |
| | | public static void reportFactoryMes(String productNum, String stationCode, String confirmTime) |
| | | { |
| | | String result = ""; |
| | | try { |
| | | String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; |
| | | HttpResponse response = HttpRequest.get(url).execute(); |
| | | /*HttpRequest httpRequest = HttpRequest.get(url);*/ |
| | | result = response.body(); |
| | | CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | log.info("请求工厂MES报工:入参device{},productNum:{}", stationCode, productNum); |
| | | String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; |
| | | HttpResponse response = HttpRequest.get(url).execute(); |
| | | /*HttpRequest httpRequest = HttpRequest.get(url);*/ |
| | | String result = response.body(); |
| | | log.info("请求工厂MES报工:出参:{}", result); |
| | | }); |
| | | |
| | | }catch (Exception e){ |
| | | throw new RuntimeException(e); |
| | | } |