|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SiteController siteController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${wms.code}") | 
|---|
|  |  |  | private String code; | 
|---|
|  |  |  | @Value("${wms.successCode}") | 
|---|
|  |  |  | private String successCode; | 
|---|
|  |  |  | @Value("${wms.msg}") | 
|---|
|  |  |  | private String msg; | 
|---|
|  |  |  | @Value("${wms.data}") | 
|---|
|  |  |  | private String data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void generateStoreWrkFile1() throws IOException, InterruptedException { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | // 遍历入库口 | 
|---|
|  |  |  | for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|---|
|  |  |  | StorageEscalationParam storageEscalationParam = new StorageEscalationParam(); | 
|---|
|  |  |  | storageEscalationParam.setStationCode(inSta.getStaNo()); | 
|---|
|  |  |  | // 获取入库站信息 | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Short workNo = staProtocol.getWorkNo(); | 
|---|
|  |  |  | Short stano = staProtocol.getStaNo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 尺寸检测异常 | 
|---|
|  |  |  | boolean back = false; | 
|---|
|  |  |  | String errMsg = ""; | 
|---|
|  |  |  | 
|---|
|  |  |  | storageEscalationParam.setWCSErrorMessage(storageEscalationParam.getWCSErrorMessage() + errMsg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("组托入库={}", storageEscalationParam); | 
|---|
|  |  |  | storageEscalationParam.setBoxNo(BoxNo); | 
|---|
|  |  |  | storageEscalationParam.setBarcode(BoxNo); | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | Boolean success = false; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (!Cools.isEmpty(response) && !Cools.isEmpty(jsonObject.get("ReturnStatus")) && jsonObject.get("ReturnStatus").equals(0) && !Cools.isEmpty(jsonObject.get("Result").toString())) { | 
|---|
|  |  |  | Result result = JSON.parseObject(jsonObject.get("Result").toString(), Result.class); | 
|---|
|  |  |  | if (!Cools.isEmpty(response) && !Cools.isEmpty(jsonObject.get(code)) && jsonObject.get(code).equals(successCode)) { | 
|---|
|  |  |  | Result result = JSON.parseObject(jsonObject.get(data).toString(), Result.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp)) { | 
|---|
|  |  |  | log.error("站点号异常1" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常1,未查询到站点信息" + inSta.getStaNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer staNoCrnNo = Utils.StaNoCrnNo(inSta.getStaNo()); | 
|---|
|  |  |  | if (staNoCrnNo == 0) { | 
|---|
|  |  |  | basDevp.setStaErr(1); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | log.error("站点号异常2" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常2,站点号不存在" + inSta.getStaNo()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", staNoCrnNo.longValue()) | 
|---|
|  |  |  | .eq("loc_no", result.getLocNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | basDevp.setStaErr(1); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | log.error("站点号异常3" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常3:此巷道不存在目标库位" + inSta.getStaNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | //                                    log.error("扫码检测程序异常"+inSta.getStaNo()+"异常信息"+e); | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | log.error("扫码检测程序异常" + inSta.getStaNo() + errMsg); | 
|---|
|  |  |  | log.error("扫码检测程序异常,异常信息" + e); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo((short) 9999); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                                    TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | //                                    if (taskWrk != null) { | 
|---|
|  |  |  | //                                        taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 | 
|---|
|  |  |  | //                                        taskWrkMapper.updateById(taskWrk); | 
|---|
|  |  |  | //                                    } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查看该库位是否为空库位 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("loc_no", result.getLocNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | HashMap<String, Object> headParam1 = new HashMap<>(); | 
|---|
|  |  |  | headParam1.put("taskNo", result.getTaskNo()); | 
|---|
|  |  |  | headParam1.put("status", 6); | 
|---|
|  |  |  | headParam1.put("ioType", 1); | 
|---|
|  |  |  | headParam1.put("barcode", BoxNo); | 
|---|
|  |  |  | String response2; | 
|---|
|  |  |  | response2 = new HttpHandler.Builder() | 
|---|
|  |  |  | // .setHeaders(headParam) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath(taskStatusFeedbackPath) | 
|---|
|  |  |  | .setJson(JSON.toJSONString(headParam1)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject1 = JSON.parseObject(response2); | 
|---|
|  |  |  | apiLogService.save("wcs派发库位==》不为空《==上报wms" | 
|---|
|  |  |  | , wmsUrl + taskStatusFeedbackPath | 
|---|
|  |  |  | , null | 
|---|
|  |  |  | , "127.0.0.1" | 
|---|
|  |  |  | , JSON.toJSONString(headParam1) | 
|---|
|  |  |  | , response | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("wcs派发库位==》不为空《==上报wms", result.getTaskNo()); | 
|---|
|  |  |  | throw new CoolException("wcs派发入库任务上报wms失败,派发库位==》不为空《==,异常信息:" + e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 创新一个入库工作档 | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(result.getTaskNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(taskWrk)) { | 
|---|
|  |  |  | taskWrk = createTask1(result, BoxNo); | 
|---|
|  |  |  | taskWrk = createInTask(result, BoxNo, inSta.getStaNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(taskWrk)) { | 
|---|
|  |  |  | log.error("库位异常,库位号:={}", taskWrk.getOriginTargetPoint()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 
|---|
|  |  |  | log.info("入库请求参数=" + JSON.toJSONString(BoxNo)); | 
|---|
|  |  |  | log.info("入库请求返回参数=" + JSON.toJSONString(response)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("generateStoreWrkFile e", e); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void generateStoreWrkFile() throws IOException, InterruptedException { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 根据输送线plc遍历 | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | // 遍历入库口 | 
|---|
|  |  |  | for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|---|
|  |  |  | // 获取入库站信息 | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|---|
|  |  |  | if (staProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Short workNo = staProtocol.getWorkNo(); | 
|---|
|  |  |  | Short stano = staProtocol.getStaNo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 尺寸检测异常 | 
|---|
|  |  |  | 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.isWeightErr()) { | 
|---|
|  |  |  | errMsg = "超重"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!back && staProtocol.isBarcodeErr()) { | 
|---|
|  |  |  | errMsg = "扫码失败"; | 
|---|
|  |  |  | back = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | if (back) { | 
|---|
|  |  |  | if (stano == inSta.getBackSta().shortValue()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (workNo == 0 && stano == 0) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isPakMk()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|---|
|  |  |  | staProtocol.setWorkNo(workNo); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 | 
|---|
|  |  |  | taskWrkMapper.updateById(taskWrk); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断是否满足入库条件 | 
|---|
|  |  |  | if (staProtocol.isAutoing() && staProtocol.isLoading() | 
|---|
|  |  |  | && staProtocol.isInEnable() | 
|---|
|  |  |  | && !staProtocol.isEmptyMk() && (workNo >= 9899) | 
|---|
|  |  |  | && staProtocol.isPakMk()) { | 
|---|
|  |  |  | // 获取条码扫描仪信息 | 
|---|
|  |  |  | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
|---|
|  |  |  | if (barcodeThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String barcode = barcodeThread.getBarcode(); | 
|---|
|  |  |  | if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) { | 
|---|
|  |  |  | // 请求wms接口,获取工作号和目标库位 | 
|---|
|  |  |  | ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), staProtocol.isHigh() ? 2 : 1); | 
|---|
|  |  |  | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); | 
|---|
|  |  |  | if (!Cools.isEmpty(taskWrk1)) { | 
|---|
|  |  |  | log.info("托盘码:" + barcode + "任务档存在"); | 
|---|
|  |  |  | if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("crn_no", taskWrk1.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | log.info("托盘码:" + barcode + "任务档存在"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staProtocol.setWorkNo(taskWrk1.getWrkNo().shortValue()); | 
|---|
|  |  |  | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HashMap<String, Object> headParam = new HashMap<>(); | 
|---|
|  |  |  | headParam.put("Content-Type", "application/json"); | 
|---|
|  |  |  | System.out.println(JSON.toJSONString(toWmsDTO)); | 
|---|
|  |  |  | String response; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | // .setHeaders(headParam) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath(inboundTaskApplyPath) | 
|---|
|  |  |  | .setJson(JSON.toJSONString(toWmsDTO)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("请求入库调用接口失败"); | 
|---|
|  |  |  | log.error("异常信息打印:" + e); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp)) { | 
|---|
|  |  |  | log.error("站点号异常" + inSta.getStaNo()); | 
|---|
|  |  |  | } else if (basDevp.getStaErr() != 0) { | 
|---|
|  |  |  | basDevp.setStaErr(2); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e1) { | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | log.error("扫码检测程序异常" + inSta.getStaNo() + "异常信息" + e1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | staProtocol.setWorkNo((short) 9999); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                                    TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | //                                    if (taskWrk != null) { | 
|---|
|  |  |  | //                                        taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 | 
|---|
|  |  |  | //                                        taskWrkMapper.updateById(taskWrk); | 
|---|
|  |  |  | //                                    } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | log.info("入库请求参数{}" + JSON.toJSONString(toWmsDTO)); | 
|---|
|  |  |  | log.info("入库请求返回参数{}" + JSON.toJSONString(response)); | 
|---|
|  |  |  | if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) { | 
|---|
|  |  |  | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp)) { | 
|---|
|  |  |  | log.error("站点号异常1" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常1,未查询到站点信息" + inSta.getStaNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer staNoCrnNo = Utils.StaNoCrnNo(inSta.getStaNo()); | 
|---|
|  |  |  | if (staNoCrnNo == 0) { | 
|---|
|  |  |  | basDevp.setStaErr(1); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | log.error("站点号异常2" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常2,站点号不存在" + inSta.getStaNo()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", staNoCrnNo.longValue()) | 
|---|
|  |  |  | .eq("loc_no", getWmsDto.getLocNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | basDevp.setStaErr(1); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | log.error("站点号异常3" + inSta.getStaNo()); | 
|---|
|  |  |  | throw new CoolException("站点号异常3:此巷道不存在目标库位" + inSta.getStaNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | //                                    log.error("扫码检测程序异常"+inSta.getStaNo()+"异常信息"+e); | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | log.error("扫码检测程序异常" + inSta.getStaNo() + errMsg); | 
|---|
|  |  |  | log.error("扫码检测程序异常,异常信息" + e); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo((short) 9999); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | //                                    TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | //                                    if (taskWrk != null) { | 
|---|
|  |  |  | //                                        taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 | 
|---|
|  |  |  | //                                        taskWrkMapper.updateById(taskWrk); | 
|---|
|  |  |  | //                                    } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查看该库位是否为空库位 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("loc_no", getWmsDto.getLocNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | HashMap<String, Object> headParam1 = new HashMap<>(); | 
|---|
|  |  |  | headParam1.put("taskNo", getWmsDto.getTaskNo()); | 
|---|
|  |  |  | headParam1.put("status", 6); | 
|---|
|  |  |  | headParam1.put("ioType", 1); | 
|---|
|  |  |  | headParam1.put("barcode", barcode); | 
|---|
|  |  |  | String response2; | 
|---|
|  |  |  | response2 = new HttpHandler.Builder() | 
|---|
|  |  |  | // .setHeaders(headParam) | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath(taskStatusFeedbackPath) | 
|---|
|  |  |  | .setJson(JSON.toJSONString(headParam1)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject1 = JSON.parseObject(response2); | 
|---|
|  |  |  | apiLogService.save("wcs派发库位==》不为空《==上报wms" | 
|---|
|  |  |  | , wmsUrl + taskStatusFeedbackPath | 
|---|
|  |  |  | , null | 
|---|
|  |  |  | , "127.0.0.1" | 
|---|
|  |  |  | , JSON.toJSONString(headParam1) | 
|---|
|  |  |  | , response | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("wcs派发库位==》不为空《==上报wms", getWmsDto.getWrkNo()); | 
|---|
|  |  |  | throw new CoolException("wcs派发入库任务上报wms失败,派发库位==》不为空《==,异常信息:" + e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 创新一个入库工作档 | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getWrkNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(taskWrk)) { | 
|---|
|  |  |  | taskWrk = createTask(getWmsDto, barcode); | 
|---|
|  |  |  | if (Cools.isEmpty(taskWrk)) { | 
|---|
|  |  |  | log.error("库位异常,库位号:{}", getWmsDto.getTargetLocationCode()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | taskWrkService.insert(taskWrk); | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); | 
|---|
|  |  |  | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); | 
|---|
|  |  |  | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | apiLogService.save("wms请求入库货位接口" | 
|---|
|  |  |  | , wmsUrl + inboundTaskApplyPath | 
|---|
|  |  |  | , null | 
|---|
|  |  |  | , "127.0.0.1" | 
|---|
|  |  |  | , JSON.toJSONString(toWmsDTO) | 
|---|
|  |  |  | , response | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 退回 | 
|---|
|  |  |  | log.error("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo((short) 9999); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 | 
|---|
|  |  |  | taskWrkMapper.updateById(taskWrk); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return response; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private TaskWrk createTask1(Result result, String barcode) { | 
|---|
|  |  |  | String locNo = Utils.Fusion(result.getRow(), result.getFloor(), result.getColumn()); | 
|---|
|  |  |  | private TaskWrk createInTask(Result result, String barcode, Integer startPoint) { | 
|---|
|  |  |  | //String locNo = Utils.Fusion(result.getRow(), result.getFloor(), result.getColumn()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String locNo = result.getLocNo(); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | TaskWrk taskWrk = new TaskWrk(); | 
|---|
|  |  |  | int workNo1 = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectByLocNo(locNo); | 
|---|
|  |  |  | taskWrk.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | taskWrk.setTargetPoint(locNo); | 
|---|
|  |  |  | taskWrk.setStartPoint("116"); | 
|---|
|  |  |  | if (result.getAlley().equals("1")) { | 
|---|
|  |  |  | taskWrk.setCrnNo(1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | taskWrk.setCrnNo(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | taskWrk.setStartPoint(startPoint + ""); | 
|---|
|  |  |  | taskWrk.setCrnNo(result.getCrnNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (taskWrk.getIoType() == 1) { | 
|---|
|  |  |  | taskWrk.setWrkSts(2); | 
|---|
|  |  |  | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return taskWrk; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private TaskWrk createTask(GetWmsDto dto, String barcode) { | 
|---|
|  |  |  | String wcsLocNo = dto.getLocNo(); | 
|---|
|  |  |  | if (Cools.isEmpty(wcsLocNo)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | TaskWrk taskWrk = new TaskWrk(); | 
|---|
|  |  |  | int workNo1 = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号 | 
|---|
|  |  |  | taskWrk.setTaskNo(dto.getWrkNo());//任务号 | 
|---|
|  |  |  | taskWrk.setWrkNo(workNo1); | 
|---|
|  |  |  | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//任务状态:接收 | 
|---|
|  |  |  | taskWrk.setCreateTime(now); | 
|---|
|  |  |  | taskWrk.setIoType(1);//任务类型 | 
|---|
|  |  |  | taskWrk.setIoPri(Cools.isEmpty(dto.getTaskPriority()) ? 300 : Integer.parseInt(dto.getTaskPriority()));//优先级 | 
|---|
|  |  |  | taskWrk.setBarcode(barcode);//条码 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectByLocNo(wcsLocNo); | 
|---|
|  |  |  | taskWrk.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | taskWrk.setTargetPoint(wcsLocNo); | 
|---|
|  |  |  | taskWrk.setStartPoint(dto.getStaNo().toString()); | 
|---|
|  |  |  | if (taskWrk.getIoType() == 1) { | 
|---|
|  |  |  | taskWrk.setWrkSts(2); | 
|---|
|  |  |  | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { | 
|---|
|  |  |  | taskWrk.setOriginTargetPoint(taskWrk.getTargetPoint()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        } else if (param.getIoType() == 2) { | 
|---|
|  |  |  | //            taskWrk.setWrkSts(11); | 
|---|
|  |  |  | //            if (!Cools.isEmpty(param.getStartPoint())) { | 
|---|
|  |  |  | //                taskWrk.setStartPoint(Utils.getWcsLocNo(param.getStartPoint()));//起点 | 
|---|
|  |  |  | //                taskWrk.setOriginStartPoint(param.getStartPoint()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            taskWrk.setTargetPoint(param.getTargetPoint()); | 
|---|
|  |  |  | //        }else if (param.getIoType() == 3){ | 
|---|
|  |  |  | //            taskWrk.setWrkSts(11); | 
|---|
|  |  |  | //            if (!Cools.isEmpty(param.getStartPoint())) { | 
|---|
|  |  |  | //                taskWrk.setStartPoint(param.getStartPoint());//起点 | 
|---|
|  |  |  | //                taskWrk.setOriginStartPoint(param.getStartPoint()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return taskWrk; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 入出库模式切换函数 | 
|---|
|  |  |  | 
|---|
|  |  |  | // 根据输送线plc遍历 | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  | for (DevpSlave.Sta outSta : devp.getOutSta()) { | 
|---|
|  |  |  | WrkMast pakout = wrkMastMapper.selectWorkingPakout(outSta.getStaNo()); | 
|---|
|  |  |  | switch (outSta.getStaNo()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|---|
|  |  |  | if (inSta.getStaNo() == 2) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); | 
|---|
|  |  |  | switch (inSta.getStaNo()) { | 
|---|
|  |  |  | case 203://1F | 
|---|
|  |  |  | case 203: | 
|---|
|  |  |  | if (pakout != null) { | 
|---|
|  |  |  | if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { | 
|---|
|  |  |  | if (devpThread.ioModeOf1F1 != IoModeType.PAKOUT_MODE) { | 
|---|
|  |  |  | // 出库切换中 | 
|---|
|  |  |  | devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING; | 
|---|
|  |  |  | devpThread.ioModeOf1F1 = IoModeType.PAKOUT_BOOTING; | 
|---|
|  |  |  | WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); | 
|---|
|  |  |  | if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() | 
|---|
|  |  |  | && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() | 
|---|
|  |  |  | 
|---|
|  |  |  | devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 401://1F | 
|---|
|  |  |  | case 401: | 
|---|
|  |  |  | if (pakout != null) { | 
|---|
|  |  |  | if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) { | 
|---|
|  |  |  | // 出库切换中 | 
|---|