|  |  |  | 
|---|
|  |  |  | public Integer wrkNo = 10000; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ConfigMapper configMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 组托 | 
|---|
|  |  |  | * 入库站,根据条码扫描生成入库工作档,工作状态 2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public synchronized void generateStoreWrkFile(Integer mark) { | 
|---|
|  |  |  | public synchronized void generateStoreWrkFile3(Integer mark) { | 
|---|
|  |  |  | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); | 
|---|
|  |  |  | // 根据输送线plc遍历 | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String barcode = barcodeThread.getBarcode(); | 
|---|
|  |  |  | if(staProtocolIn.getStamp() == 1) { | 
|---|
|  |  |  | log.error("生成任务中"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|---|
|  |  |  | if (staProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | locTypeDto.setLocType1((short) 1); | 
|---|
|  |  |  | param.setBarcode(barcode); | 
|---|
|  |  |  | param.setIoType(1); | 
|---|
|  |  |  | param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | param.setLocType1(locTypeDto.getLocType1()); | 
|---|
|  |  |  | param.setWeight(staProtocol.getWeight()); | 
|---|
|  |  |  | String response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setTimeout(30, TimeUnit.SECONDS) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|---|
|  |  |  | barcodeThread.setBarcode(""); | 
|---|
|  |  |  | staProtocolIn.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | //                            //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo())); | 
|---|
|  |  |  | //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn)); | 
|---|
|  |  |  | log.error("输送线下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  | ledThread.errorReset(); | 
|---|
|  |  |  | log.error("组托请求后LED错误清除"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //                        else { | 
|---|
|  |  |  | //                            if (jsonObject.getString("msg").equals("工作档已存在")) { | 
|---|
|  |  |  | //                                continue; | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                            staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                            wrkNo++; | 
|---|
|  |  |  | //                            staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                            log.error("输送线下发2:" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                            if (ledThread != null) { | 
|---|
|  |  |  | //                            String errorMsg = jsonObject.getString("msg"); | 
|---|
|  |  |  | //                            if (!Cools.isEmpty(errorMsg)) { | 
|---|
|  |  |  | //                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | ////                            } | 
|---|
|  |  |  | ////                            News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if (staProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 尺寸检测异常 | 
|---|
|  |  |  | boolean back = false; | 
|---|
|  |  |  | String errMsg = ""; | 
|---|
|  |  |  | if (staProtocol.isFrontErr()) { | 
|---|
|  |  |  | errMsg = "前超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isBackErr()) { | 
|---|
|  |  |  | errMsg = "后超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isHighErr()) { | 
|---|
|  |  |  | errMsg = "高超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isLeftErr()) { | 
|---|
|  |  |  | errMsg = "左超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isRightErr()) { | 
|---|
|  |  |  | errMsg = "右超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.getWeight() > 1000) { | 
|---|
|  |  |  | errMsg = "超重或未读取"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isBarcodeErr()) { | 
|---|
|  |  |  | errMsg = "扫码失败"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 尺寸检测异常 | 
|---|
|  |  |  | boolean back = false; | 
|---|
|  |  |  | String errMsg = ""; | 
|---|
|  |  |  | if (staProtocol.isFrontErr()) { | 
|---|
|  |  |  | errMsg = "前超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isBackErr()) { | 
|---|
|  |  |  | errMsg = "后超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isHighErr()) { | 
|---|
|  |  |  | errMsg = "高超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isLeftErr()) { | 
|---|
|  |  |  | errMsg = "左超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isRightErr()) { | 
|---|
|  |  |  | errMsg = "右超限"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.getWeight() > 1000) { | 
|---|
|  |  |  | errMsg = "超重或未读取"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isBarcodeErr()) { | 
|---|
|  |  |  | errMsg = "扫码失败"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //                if(staProtocol.getWeight() <= 0 ){ | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                News.info("{}重量", staProtocol.getWeight()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | if (back) { | 
|---|
|  |  |  | log.info("errmsg: " + errMsg); | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | if (back) { | 
|---|
|  |  |  | log.info("errmsg: " + errMsg); | 
|---|
|  |  |  | //                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!staProtocol.isLoading()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isPakMk()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isLoading()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isPakMk()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | News.info("{}PLC入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | wrkNo++; | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否满足入库条件 | 
|---|
|  |  |  | if (staProtocol.isAutoing() | 
|---|
|  |  |  | && staProtocol.isLoading() | 
|---|
|  |  |  | && staProtocol.isInEnable() | 
|---|
|  |  |  | && !staProtocol.isEmptyMk() | 
|---|
|  |  |  | && staProtocol.isPakMk()) { | 
|---|
|  |  |  | if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) { | 
|---|
|  |  |  | News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | News.info("{}PLC入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | News.info("{}barcode入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | wrkNo++; | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否满足入库条件 | 
|---|
|  |  |  | if (staProtocol.isAutoing() | 
|---|
|  |  |  | && staProtocol.isLoading() | 
|---|
|  |  |  | && staProtocol.isInEnable() | 
|---|
|  |  |  | && !staProtocol.isEmptyMk() | 
|---|
|  |  |  | && staProtocol.isPakMk()) { | 
|---|
|  |  |  | if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) { | 
|---|
|  |  |  | News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | News.info("{}barcode入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | wrkNo++; | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断重复工作档 | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | // 判断重复工作档 | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | //                        int wrkNo1 = basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())); | 
|---|
|  |  |  | //                        if (wrkNo1 != 0){ | 
|---|
|  |  |  | //                            if (ledThread != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | News.error(barcode + "条码已存在状态为( 2.设备上走 )的数据,请查看WCS输送线界面,工作号={}", wrkMast.getWrkNo()); | 
|---|
|  |  |  | News.error(barcode + "条码已存在状态为( 2.设备上走 )的数据,请查看WCS输送线界面,工作号={}", wrkMast.getWrkNo()); | 
|---|
|  |  |  | //                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, barcode + "条码已存在状态为( 2.设备上走 )的任务,工作号=" + wrkMast.getWrkNo())); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | //                        barcodeThread.setBarcode(""); | 
|---|
|  |  |  | //                        staProtocol.setWorkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | //                        staProtocol.setStaNo(RouteUtils.SouStaEnd(null,wrkMast.getSourceStaNo())); | 
|---|
|  |  |  | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | locTypeDto.setLocType1((short) 1); | 
|---|
|  |  |  | param.setBarcode(barcode); | 
|---|
|  |  |  | param.setIoType(1); | 
|---|
|  |  |  | param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | param.setLocType1(locTypeDto.getLocType1()); | 
|---|
|  |  |  | param.setWeight(staProtocol.getWeight()); | 
|---|
|  |  |  | String response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setTimeout(30,TimeUnit.SECONDS) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|---|
|  |  |  | barcodeThread.setBarcode(""); | 
|---|
|  |  |  | staProtocol.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo())); | 
|---|
|  |  |  | staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ledThread.errorReset(); | 
|---|
|  |  |  | log.error("组托请求后LED错误清除"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (jsonObject.getString("msg").equals("工作档已存在")) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | wrkNo++; | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发2:" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                            if (ledThread != null) { | 
|---|
|  |  |  | String errorMsg = jsonObject.getString("msg"); | 
|---|
|  |  |  | if (!Cools.isEmpty(errorMsg)) { | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                            News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        News.infoNoLog(""+mark+" - 0"+" - 组托  ===》执行完成"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 组托 | 
|---|
|  |  |  | * 入库站,根据条码扫描生成入库工作档,工作状态 2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | //    public synchronized void generateStoreWrkFile(Integer mark) { | 
|---|
|  |  |  | //        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); | 
|---|
|  |  |  | //        // 根据输送线plc遍历 | 
|---|
|  |  |  | //        for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | //            // 遍历入库口 | 
|---|
|  |  |  | //            for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|---|
|  |  |  | //                // 获取条码扫描仪信息 | 
|---|
|  |  |  | //                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
|---|
|  |  |  | //                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|---|
|  |  |  | //                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  | //                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|---|
|  |  |  | //                StaProtocol staProtocolIn = devpThread.getStation().get(inSta.getStaNo() -1); | 
|---|
|  |  |  | //                if (staProtocolIn == null) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    staProtocolIn = staProtocolIn.clone(); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (barcodeThread == null) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                String barcode = barcodeThread.getBarcode(); | 
|---|
|  |  |  | //                if(staProtocolIn.getStamp() == 1 && barcode!=null && !barcode.isEmpty()) { | 
|---|
|  |  |  | //                    log.error("生成任务中"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | //                            .eq("barcode", barcode) | 
|---|
|  |  |  | //                            .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | //                    if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    try { | 
|---|
|  |  |  | //                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | //                        locTypeDto.setLocType1((short) 1); | 
|---|
|  |  |  | //                        param.setBarcode(barcode); | 
|---|
|  |  |  | //                        param.setIoType(1); | 
|---|
|  |  |  | //                        param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | //                        param.setLocType1(locTypeDto.getLocType1()); | 
|---|
|  |  |  | //                        param.setWeight(staProtocol.getWeight()); | 
|---|
|  |  |  | //                        String response = new HttpHandler.Builder() | 
|---|
|  |  |  | //                                .setTimeout(30, TimeUnit.SECONDS) | 
|---|
|  |  |  | //                                .setUri(wmsUrl) | 
|---|
|  |  |  | //                                .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | //                                .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | //                                .build() | 
|---|
|  |  |  | //                                .doPost(); | 
|---|
|  |  |  | //                        JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | //                        if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | //                            StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|---|
|  |  |  | //                            barcodeThread.setBarcode(""); | 
|---|
|  |  |  | //                            staProtocolIn.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | ////                            //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo())); | 
|---|
|  |  |  | ////                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocolIn.getSiteId(), false); | 
|---|
|  |  |  | //                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn)); | 
|---|
|  |  |  | //                            log.error("工作号下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  | //                            ledThread.errorReset(); | 
|---|
|  |  |  | //                            log.error("组托请求后LED错误清除"); | 
|---|
|  |  |  | //                            if (!result) { | 
|---|
|  |  |  | //                                News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                                throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                    } catch (Exception e) { | 
|---|
|  |  |  | //                        e.printStackTrace(); | 
|---|
|  |  |  | //                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                }else{ | 
|---|
|  |  |  | //                    if (staProtocol == null) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } else { | 
|---|
|  |  |  | //                        staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    // 尺寸检测异常 | 
|---|
|  |  |  | //                    boolean back = false; | 
|---|
|  |  |  | //                    String errMsg = ""; | 
|---|
|  |  |  | //                    if (staProtocol.isFrontErr()) { | 
|---|
|  |  |  | //                        errMsg = "前超限"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.isBackErr()) { | 
|---|
|  |  |  | //                        errMsg = "后超限"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.isHighErr()) { | 
|---|
|  |  |  | //                        errMsg = "高超限"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.isLeftErr()) { | 
|---|
|  |  |  | //                        errMsg = "左超限"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.isRightErr()) { | 
|---|
|  |  |  | //                        errMsg = "右超限"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.getWeight() > 1000) { | 
|---|
|  |  |  | //                        errMsg = "超重或未读取"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!back && staProtocol.isBarcodeErr()) { | 
|---|
|  |  |  | //                        errMsg = "扫码失败"; | 
|---|
|  |  |  | //                        back = true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    // 退回 | 
|---|
|  |  |  | //                    if (back) { | 
|---|
|  |  |  | //                        log.info("errmsg: " + errMsg); | 
|---|
|  |  |  | ////                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|---|
|  |  |  | //                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        if (!staProtocol.isLoading()) { | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        if (!staProtocol.isPakMk()) { | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                        News.info("{}PLC入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | //                        wrkNo++; | 
|---|
|  |  |  | //                        staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                        devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                        log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    // 判断是否满足入库条件 | 
|---|
|  |  |  | //                    if (staProtocol.isAutoing() | 
|---|
|  |  |  | //                            && staProtocol.isLoading() | 
|---|
|  |  |  | //                            && staProtocol.isInEnable() | 
|---|
|  |  |  | //                            && !staProtocol.isEmptyMk() | 
|---|
|  |  |  | //                            && staProtocol.isPakMk()) { | 
|---|
|  |  |  | //                        if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) { | 
|---|
|  |  |  | //                            News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                            staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                            News.info("{}barcode入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | //                            wrkNo++; | 
|---|
|  |  |  | //                            staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                            log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        // 判断重复工作档 | 
|---|
|  |  |  | //                        WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
|---|
|  |  |  | //                        if (wrkMast != null) { | 
|---|
|  |  |  | //                            News.error(barcode + "条码已存在状态为( 2.设备上走 )的数据,请查看WCS输送线界面,工作号={}", wrkMast.getWrkNo()); | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | //                                .eq("barcode", barcode) | 
|---|
|  |  |  | //                                .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | //                        if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        try { | 
|---|
|  |  |  | //                            LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | 
|---|
|  |  |  | //                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                                log.error("输送线下发2:" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                            if (ledThread != null) { | 
|---|
|  |  |  | //                                String errorMsg = jsonObject.getString("msg"); | 
|---|
|  |  |  | //                                if (!Cools.isEmpty(errorMsg)) { | 
|---|
|  |  |  | //                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|---|
|  |  |  | //                                } | 
|---|
|  |  |  | ////                            } | 
|---|
|  |  |  | ////                            News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        } catch (Exception e) { | 
|---|
|  |  |  | //                            e.printStackTrace(); | 
|---|
|  |  |  | //                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public synchronized void generateStoreWrkFile(Integer mark) { | 
|---|
|  |  |  | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); | 
|---|
|  |  |  | final Set<String> INVALID_BARCODES = new HashSet<>(Arrays.asList("NG", "NoRead", "00000000")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|---|
|  |  |  | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
|---|
|  |  |  | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|---|
|  |  |  | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|---|
|  |  |  | StaProtocol staProtocolIn = devpThread.getStation().get(inSta.getStaNo() - 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (staProtocolIn == null || barcodeThread == null) continue; | 
|---|
|  |  |  | staProtocolIn = staProtocolIn.clone(); | 
|---|
|  |  |  | String barcode = barcodeThread.getBarcode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果前工位有货 + 扫码器有条码 | 
|---|
|  |  |  | if (staProtocolIn.getStamp() == 1 && barcode != null && !barcode.isEmpty()) { | 
|---|
|  |  |  | if (wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 107, 103, 57)) != null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | param.setBarcode(barcode); | 
|---|
|  |  |  | param.setIoType(1); | 
|---|
|  |  |  | param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | param.setLocType1((short) 1); | 
|---|
|  |  |  | param.setWeight(staProtocolIn.getWeight()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setTimeout(30, TimeUnit.SECONDS) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject json = JSON.parseObject(response); | 
|---|
|  |  |  | if (json.getInteger("code").equals(200)) { | 
|---|
|  |  |  | StartupDto dto = json.getObject("data", StartupDto.class); | 
|---|
|  |  |  | barcodeThread.setBarcode(""); | 
|---|
|  |  |  | staProtocolIn.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocolIn.getSiteId(), false); | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn)); | 
|---|
|  |  |  | ledThread.errorReset(); | 
|---|
|  |  |  | log.error("工作号下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  | throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("组托任务异常:", e); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                if (staProtocol == null) { | 
|---|
|  |  |  | //                    continue; | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                // 尺寸检测异常 | 
|---|
|  |  |  | //                boolean back = false; | 
|---|
|  |  |  | //                String errMsg = ""; | 
|---|
|  |  |  | //                if (staProtocol.isFrontErr()) { | 
|---|
|  |  |  | //                    errMsg = "前超限"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.isBackErr()) { | 
|---|
|  |  |  | //                    errMsg = "后超限"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.isHighErr()) { | 
|---|
|  |  |  | //                    errMsg = "高超限"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.isLeftErr()) { | 
|---|
|  |  |  | //                    errMsg = "左超限"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.isRightErr()) { | 
|---|
|  |  |  | //                    errMsg = "右超限"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.getWeight() > 1000) { | 
|---|
|  |  |  | //                    errMsg = "超重或未读取"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!back && staProtocol.isBarcodeErr()) { | 
|---|
|  |  |  | //                    errMsg = "扫码失败"; | 
|---|
|  |  |  | //                    back = true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | ////                if(staProtocol.getWeight() <= 0 ){ | 
|---|
|  |  |  | ////                    continue; | 
|---|
|  |  |  | ////                } | 
|---|
|  |  |  | ////                if (!back && staProtocol.getWeight() == 0.0) { | 
|---|
|  |  |  | ////                    errMsg = "重量获取失败"; | 
|---|
|  |  |  | ////                    back = true; | 
|---|
|  |  |  | ////                } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                News.info("{}重量", staProtocol.getWeight()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                // 退回 | 
|---|
|  |  |  | //                if (back) { | 
|---|
|  |  |  | //                    log.info("errmsg: " + errMsg); | 
|---|
|  |  |  | ////                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|---|
|  |  |  | //                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    if (!staProtocol.isLoading()) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    if (!staProtocol.isPakMk()) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                    News.info("{}PLC入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | //                    wrkNo++; | 
|---|
|  |  |  | //                    staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                    devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                    log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                // 判断是否满足入库条件 | 
|---|
|  |  |  | //                if (staProtocol.isAutoing() | 
|---|
|  |  |  | //                        && staProtocol.isLoading() | 
|---|
|  |  |  | //                        && staProtocol.isInEnable() | 
|---|
|  |  |  | //                        && !staProtocol.isEmptyMk() | 
|---|
|  |  |  | //                        && staProtocol.isPakMk()) { | 
|---|
|  |  |  | //                    if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) { | 
|---|
|  |  |  | //                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                        News.info("{}barcode入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); | 
|---|
|  |  |  | //                        wrkNo++; | 
|---|
|  |  |  | //                        staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                        devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                        log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    // 判断重复工作档 | 
|---|
|  |  |  | //                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
|---|
|  |  |  | //                    if (wrkMast != null) { | 
|---|
|  |  |  | ////                        int wrkNo1 = basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())); | 
|---|
|  |  |  | ////                        if (wrkNo1 != 0){ | 
|---|
|  |  |  | ////                            if (ledThread != null) { | 
|---|
|  |  |  | ////                                News.error(methodName + ":扫码失败,请重试"); | 
|---|
|  |  |  | ////                            } | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////                        } | 
|---|
|  |  |  | //                        News.error(barcode + "条码已存在状态为( 2.设备上走 )的数据,请查看WCS输送线界面,工作号={}", wrkMast.getWrkNo()); | 
|---|
|  |  |  | ////                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, barcode + "条码已存在状态为( 2.设备上走 )的任务,工作号=" + wrkMast.getWrkNo())); | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | ////                        barcodeThread.setBarcode(""); | 
|---|
|  |  |  | ////                        staProtocol.setWorkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | ////                        staProtocol.setStaNo(RouteUtils.SouStaEnd(null,wrkMast.getSourceStaNo())); | 
|---|
|  |  |  | ////                        devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | ////                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | ////                        log.info("输送线下发(存在设备上走的工作档,直接下发!)):"+wrkMast.getWrkNo()+","+wrkMast.getStaNo()); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////                        ledThread.errorReset(); | 
|---|
|  |  |  | ////                        log.info("组托请求后LED错误清除"); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////                        if (!result) { | 
|---|
|  |  |  | ////                            News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  | ////                            log.error("输送线下发(存在设备上走的工作档,直接下发!)==>更新plc站点信息失败"); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | //////                            throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | ////                            continue; | 
|---|
|  |  |  | ////                        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | //                            .eq("barcode", barcode) | 
|---|
|  |  |  | //                            .in("io_type", 107, 103, 57)); | 
|---|
|  |  |  | //                    if (!Cools.isEmpty(checkPick)) { | 
|---|
|  |  |  | //                        continue; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    try { | 
|---|
|  |  |  | //                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | //                        locTypeDto.setLocType1((short) 1); | 
|---|
|  |  |  | //                        param.setBarcode(barcode); | 
|---|
|  |  |  | //                        param.setIoType(1); | 
|---|
|  |  |  | //                        param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | //                        param.setLocType1(locTypeDto.getLocType1()); | 
|---|
|  |  |  | //                        param.setWeight(staProtocol.getWeight()); | 
|---|
|  |  |  | //                        String response = new HttpHandler.Builder() | 
|---|
|  |  |  | //                                .setTimeout(30,TimeUnit.SECONDS) | 
|---|
|  |  |  | //                                .setUri(wmsUrl) | 
|---|
|  |  |  | //                                .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | //                                .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | //                                .build() | 
|---|
|  |  |  | //                                .doPost(); | 
|---|
|  |  |  | //                        JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | //                        if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | //                            StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|---|
|  |  |  | //                            barcodeThread.setBarcode(""); | 
|---|
|  |  |  | //                            staProtocol.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | //                            //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo())); | 
|---|
|  |  |  | //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                            log.error("输送线下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                            ledThread.errorReset(); | 
|---|
|  |  |  | //                            log.error("组托请求后LED错误清除"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                            if (!result) { | 
|---|
|  |  |  | //                                News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                                throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                        } else { | 
|---|
|  |  |  | //                            if (jsonObject.getString("msg").equals("工作档已存在")) { | 
|---|
|  |  |  | //                                continue; | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                            staProtocol.setWorkNo(wrkNo); | 
|---|
|  |  |  | //                            wrkNo++; | 
|---|
|  |  |  | //                            staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                            log.error("输送线下发2:" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                            if (ledThread != null) { | 
|---|
|  |  |  | //                            String errorMsg = jsonObject.getString("msg"); | 
|---|
|  |  |  | //                            if (!Cools.isEmpty(errorMsg)) { | 
|---|
|  |  |  | //                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | ////                            } | 
|---|
|  |  |  | ////                            News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    } catch (Exception e) { | 
|---|
|  |  |  | //                        e.printStackTrace(); | 
|---|
|  |  |  | //                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | // 尺寸/重量/扫码异常检测 | 
|---|
|  |  |  | if (staProtocol == null) continue; | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | boolean back = false; | 
|---|
|  |  |  | String errMsg = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (staProtocol.isFrontErr()) { errMsg = "前超限"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.isBackErr()) { errMsg = "后超限"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.isHighErr()) { errMsg = "高超限"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.isLeftErr()) { errMsg = "左超限"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.isRightErr()) { errMsg = "右超限"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.getWeight() > 1000) { errMsg = "超重或未读取"; back = true; } | 
|---|
|  |  |  | else if (staProtocol.isBarcodeErr()) { errMsg = "扫码失败"; back = true; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 尺寸异常回退 | 
|---|
|  |  |  | if (back) { | 
|---|
|  |  |  | log.info("errmsg: " + errMsg); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!staProtocol.isLoading() || !staProtocol.isPakMk()) continue; | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo++); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 入库条件满足,开始请求入库地址 | 
|---|
|  |  |  | if (staProtocol.isAutoing() && staProtocol.isLoading() | 
|---|
|  |  |  | && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && staProtocol.isPakMk()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(barcode) || INVALID_BARCODES.contains(barcode)) { | 
|---|
|  |  |  | News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo++); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发1:{} , {}", wrkNo, inSta.getBackSta()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode) != null || | 
|---|
|  |  |  | wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 107, 103, 57)) != null) { | 
|---|
|  |  |  | News.error(barcode + "条码已存在状态为(2.设备上走)的数据,请查看WCS输送线界面"); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | SearchLocParam param = new SearchLocParam(); | 
|---|
|  |  |  | param.setBarcode(barcode); | 
|---|
|  |  |  | param.setIoType(1); | 
|---|
|  |  |  | param.setSourceStaNo(inSta.getStaNo()); | 
|---|
|  |  |  | param.setLocType1((short) 1); | 
|---|
|  |  |  | param.setWeight(staProtocol.getWeight()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setTimeout(30, TimeUnit.SECONDS) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath("/rpc/pakin/loc/v1") | 
|---|
|  |  |  | .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject json = JSON.parseObject(response); | 
|---|
|  |  |  | if (json.getInteger("code").equals(200)) { | 
|---|
|  |  |  | StartupDto dto = json.getObject("data", StartupDto.class); | 
|---|
|  |  |  | barcodeThread.setBarcode(""); | 
|---|
|  |  |  | staProtocol.setWorkNo(dto.getWorkNo()); | 
|---|
|  |  |  | staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | ledThread.errorReset(); | 
|---|
|  |  |  | log.error("输送线下发2:" + dto.getWorkNo() + "," + dto.getStaNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!result) { | 
|---|
|  |  |  | News.error(methodName + ":更新plc站点信息失败"); | 
|---|
|  |  |  | throw new CoolException("更新plc站点信息失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | String msg = json.getString("msg"); | 
|---|
|  |  |  | if (!"工作档已存在".equals(msg)) { | 
|---|
|  |  |  | staProtocol.setWorkNo(wrkNo++); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | log.error("输送线下发2:" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo()); | 
|---|
|  |  |  | if (!Cools.isEmpty(msg)) { | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, msg)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("组托任务异常:", e); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        News.infoNoLog(""+mark+" - 0"+" - 组托  ===》执行完成"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * wms入库 | 
|---|
|  |  |  | * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2 | 
|---|