| | |
| | | //任务 |
| | | if (params.getMsgType().equals("task_complete")) { |
| | | //称重 |
| | | if ((mast.getIoType()==1||mast.getIoType()==10)&&mast.getWrkSts() == 2 && Cools.isEmpty(mast.getStaNo())) { |
| | | if ((mast.getIoType()==1||mast.getIoType()==10) && mast.getWrkSts() == 2 && Cools.isEmpty(mast.getStaNo())) { |
| | | Double weight = 0.0; |
| | | if (!Cools.isEmpty(params.getData())){ |
| | | JSONObject jsonObject = JSONObject.parseObject(params.getData()); |
| | |
| | | if (!wrkDetlService.update(detl, new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo).eq("matnr", detl.getMatnr()).eq("barcode", detl.getBarcode()))) { |
| | | throw new CoolException("原任务档明细修改失败!!"); |
| | | } |
| | | } else { |
| | | throw new CoolException("任务号截取失败,请检查主任务档任档wrkCode字段"); |
| | | } else if(!Cools.isEmpty(mast.getPacked())){ |
| | | String wrkNo = mast.getPacked(); |
| | | WrkMast orgWrk = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkNo)); |
| | | if (Objects.isNull(orgWrk)) { |
| | | throw new CoolException("数据错误,回库主任务档不存在或已删除!!"); |
| | | } |
| | | orgWrk.setOveMk("Y"); |
| | | log.info("回库主任务更新: wrkNo={}, setOveMk=Y", wrkNo); |
| | | if (!wrkMastService.updateById(orgWrk)) { |
| | | throw new CoolException("任务档修改失败!!"); |
| | | } |
| | | WrkDetl detl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); |
| | | if (Objects.isNull(detl)) { |
| | | throw new CoolException("主任务档明细不存在!!"); |
| | | } |
| | | //库存减去称重长度 |
| | | Double v = Math.round((wrkDetl.getStockQty() - realQty) * 10000) / 10000.0; |
| | | log.info("回库主任务明细回写计算: mainWrkNo={}, v=(stockQty-realQty)={}, stockQty={}, realQty={}", |
| | | wrkNo, v, wrkDetl.getStockQty(), realQty); |
| | | //原出为数量与真实数量互换,保持一致性 |
| | | if(v<= 0){ |
| | | detl.setAnfme(matnr.getSafeQty());//设定为默认值 |
| | | log.info("回库主任务明细回写修正: mainWrkNo={}, v<=0, setAnfme(safeQty)={}", wrkNo, detl.getAnfme()); |
| | | }else{ |
| | | detl.setAnfme(v); |
| | | log.info("回库主任务明细回写修正: mainWrkNo={}, v>0, setAnfme={}", wrkNo, detl.getAnfme()); |
| | | |
| | | } |
| | | detl.setWeight(weight); |
| | | if (!wrkDetlService.update(detl, new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo).eq("matnr", detl.getMatnr()).eq("barcode", detl.getBarcode()))) { |
| | | throw new CoolException("原任务档明细修改失败!!"); |
| | | } |
| | | }else{ |
| | | throw new CoolException("任务号截取失败,请检查主任务档任档wrkCode字段"); |
| | | } |
| | | } |
| | | } |
| | |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); |
| | | wrkMast.setIoType(101); |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setCrnNo(sourceLoc.getCrnNo()); |
| | | wrkMast.setSourceLocNo(sourceLoc.getLocNo()); |
| | | wrkMast.setLocNo(targetLoc.getLocNo()); |
| | |
| | | if (wrkMast.getIoType() == 1) { |
| | | // 入库通知单 |
| | | if (!Cools.isEmpty(wrkMast.getBarcode())) { |
| | | String request = "{\"barcode\":\"" + wrkMast.getBarcode() + "\"}"; |
| | | log.info("ERP入库上报请求: workNo={}, request={}", wrkMast.getWrkNo(), request); |
| | | JSONObject res = erpTokenService.stockIn(wrkMast.getBarcode()); |
| | | log.info("ERP入库上报响应: workNo={}, response={}", wrkMast.getWrkNo(), res == null ? null : res.toJSONString()); |
| | | apiLogService.save("erp.stockIn", "erpTokenService.stockIn", null, null, request, |
| | | res == null ? null : res.toJSONString(), |
| | | res != null && Boolean.TRUE.equals(res.getBoolean("success"))); |
| | | if (res != null && Boolean.TRUE.equals(res.getBoolean("success"))) { |
| | | JSONObject data = res.getJSONObject("data"); |
| | | String tlocation = data == null ? null : data.getString("tlocation"); |
| | | if (!Cools.isEmpty(tlocation) && !Cools.isEmpty(wrkMast.getLocNo())) { |
| | | List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", wrkMast.getLocNo())); |
| | | if (!Cools.isEmpty(detls)) { |
| | | for (LocDetl detl : detls) { |
| | | detl.setStandby1(tlocation); |
| | | locDetlService.updateById(detl); |
| | | if(wrkMast.getSourceStaNo().equals("1015")){ |
| | | String request = "{\"barcode\":\"" + wrkMast.getBarcode() + "\"}"; |
| | | log.info("ERP入库上报请求: workNo={}, request={}", wrkMast.getWrkNo(), request); |
| | | JSONObject res = erpTokenService.stockIn(wrkMast.getBarcode()); |
| | | log.info("ERP入库上报响应: workNo={}, response={}", wrkMast.getWrkNo(), res == null ? null : res.toJSONString()); |
| | | apiLogService.save("erp.stockIn", "erpTokenService.stockIn", null, null, request, |
| | | res == null ? null : res.toJSONString(), |
| | | res != null && Boolean.TRUE.equals(res.getBoolean("success"))); |
| | | if (res != null && Boolean.TRUE.equals(res.getBoolean("success"))) { |
| | | JSONObject data = res.getJSONObject("data"); |
| | | String tlocation = data == null ? null : data.getString("tlocation"); |
| | | if (!Cools.isEmpty(tlocation) && !Cools.isEmpty(wrkMast.getLocNo())) { |
| | | List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", wrkMast.getLocNo())); |
| | | if (!Cools.isEmpty(detls)) { |
| | | for (LocDetl detl : detls) { |
| | | detl.setStandby1(tlocation); |
| | | locDetlService.updateById(detl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | sourceCrnNo = sourceLoc.getCrnNo(); |
| | | } |
| | | } |
| | | int[] candidates = sourceCrnNo != null && sourceCrnNo < 3 ? new int[]{1, 2} : new int[]{1, 2, 3, 4}; |
| | | int[] candidates = sourceCrnNo != null && sourceCrnNo < 5 ? new int[]{1, 2} : new int[]{1, 2, 3, 4}; |
| | | Integer chosenCrnNo = null; |
| | | Integer chosenCount = null; |
| | | for (int candidate : candidates) { |