From 9aba17fd13bcd4a0a293d906f619b6948fac8e11 Mon Sep 17 00:00:00 2001 From: liuxy Date: Thu, 6 Jun 2024 09:35:53 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E6=88=90=E5=93=81=E6=8A=A5?= =?UTF-8?q?=E5=BA=9F=E5=AE=A1=E6=A0=B8=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProductScrapServiceImpl.java | 137 +++++++++--------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java index 3d19d9243..bcbe88320 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java @@ -212,82 +212,81 @@ public class ProductScrapServiceImpl implements ProductScrapService { WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); WQLObject dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); WQLObject ivt = WQLObject.getWQLObject("st_ivt_structivt"); + + try { + // 查询所有明细 + JSONArray dtlArr = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0); - // 查询所有明细 - JSONArray dtlArr = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0); + // 查询库存中这些子卷是否存在 + String pcsnJoining = dtlArr.stream() + .map(row -> JSON.parseObject(row.toString())) + .map(row -> row.getString("pcsn")) + .collect(Collectors.joining("','")); - // 查询库存中这些子卷是否存在 - String pcsnJoining = dtlArr.stream() - .map(row -> JSON.parseObject(row.toString())) - .map(row -> row.getString("pcsn")) - .collect(Collectors.joining("','")); + List ivtList = ivt.query("pcsn in ('" + pcsnJoining + "') and canuse_qty > 0") + .getResultJSONArray(0).toJavaList(JSONObject.class); - List ivtList = ivt.query("pcsn in ('" + pcsnJoining + "') and canuse_qty > 0") - .getResultJSONArray(0).toJavaList(JSONObject.class); + if (dtlArr.size() != ivtList.size()) { + throw new BadRequestException("库存异常请检查!"); + } - if (dtlArr.size() != ivtList.size()) { - throw new BadRequestException("库存异常请检查!"); + // 校验库存 + boolean is_pass = ivtList.stream() + .allMatch(row -> pcsnJoining.contains(row.getString("pcsn"))); + + if (!is_pass) { + throw new BadRequestException("库存异常请检查!"); + } + + // 生成出库单 + JSONObject jsonOutMst = new JSONObject(); + jsonOutMst.put("stor_id", whereJson.getString("stor_id")); + jsonOutMst.put("stor_code", whereJson.getString("stor_code")); + jsonOutMst.put("stor_name", whereJson.getString("stor_name")); + jsonOutMst.put("detail_count", ivtList.size()); + jsonOutMst.put("bill_status", "10"); + jsonOutMst.put("create_mode", "03"); + jsonOutMst.put("biz_date", DateUtil.now()); + jsonOutMst.put("io_type", "1"); + jsonOutMst.put("buss_type", "1002"); + jsonOutMst.put("bill_type", "1002"); + jsonOutMst.put("source_name", "成品报废审核单"); + + JSONArray tableData = new JSONArray(); + for (int i = 0; i < dtlArr.size(); i++) { + JSONObject json = dtlArr.getJSONObject(i); + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("pcsn", json.getString("pcsn")); + jsonDtl.put("box_no", json.getString("package_box_sn")); + jsonDtl.put("material_id", json.getString("material_id")); + jsonDtl.put("qty_unit_id", json.getLongValue("qty_unit_id")); + jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); + jsonDtl.put("plan_qty", json.getDoubleValue("qty")); + tableData.add(jsonDtl); + } + + // 调用出库新增并分配 + jsonOutMst.put("tableData", tableData); + String iostorinv_id = checkOutBillService.insertDtl(jsonOutMst); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("iostorinv_id", iostorinv_id); + checkOutBillService.allDiv(jsonObject); + + // 更新主表为完成 + JSONObject param = new JSONObject(); + param.put("bill_status", "99"); + param.put("confirm_optid", SecurityUtils.getCurrentUserId()); + param.put("confirm_optname", SecurityUtils.getCurrentNickName()); + param.put("confirm_time", DateUtil.now()); + mst.update(param, "scrap_id = '" + whereJson.getString("scrap_id") + "'"); + } catch (Exception e) { + JSONObject msg = new JSONObject(); + msg.put("remark", "单据异常:"+e.getMessage()); + mst.update(msg,"scrap_id = '" + whereJson.getString("scrap_id") + "'"); } - // 校验库存 - boolean is_pass = ivtList.stream() - .allMatch(row -> pcsnJoining.contains(row.getString("pcsn"))); - if (!is_pass) { - throw new BadRequestException("库存异常请检查!"); - } - - /* List collect = ivtList.stream() - .filter(row -> !pcsnJoining.contains(row.getString("pcsn"))) - .map(row -> row.getString("pcsn")) - .collect(Collectors.toList()); - - if (ObjectUtil.isNotEmpty(collect)) { - throw new BadRequestException("子卷:"+collect.toString()+"异常请检查!"); - }*/ - - // 生成出库单 - JSONObject jsonOutMst = new JSONObject(); - jsonOutMst.put("stor_id", whereJson.getString("stor_id")); - jsonOutMst.put("stor_code", whereJson.getString("stor_code")); - jsonOutMst.put("stor_name", whereJson.getString("stor_name")); - jsonOutMst.put("detail_count", ivtList.size()); - jsonOutMst.put("bill_status", "10"); - jsonOutMst.put("create_mode", "03"); - jsonOutMst.put("biz_date", DateUtil.now()); - jsonOutMst.put("io_type", "1"); - jsonOutMst.put("buss_type", "1002"); - jsonOutMst.put("bill_type", "1002"); - jsonOutMst.put("source_name", "成品报废审核单"); - - JSONArray tableData = new JSONArray(); - for (int i = 0; i < dtlArr.size(); i++) { - JSONObject json = dtlArr.getJSONObject(i); - - JSONObject jsonDtl = new JSONObject(); - jsonDtl.put("pcsn", json.getString("pcsn")); - jsonDtl.put("box_no", json.getString("package_box_sn")); - jsonDtl.put("material_id", json.getString("material_id")); - jsonDtl.put("qty_unit_id", json.getLongValue("qty_unit_id")); - jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); - jsonDtl.put("plan_qty", json.getDoubleValue("qty")); - tableData.add(jsonDtl); - } - - // 调用出库新增并分配 - jsonOutMst.put("tableData", tableData); - String iostorinv_id = checkOutBillService.insertDtl(jsonOutMst); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("iostorinv_id", iostorinv_id); - checkOutBillService.allDiv(jsonObject); - - // 更新主表为完成 - JSONObject param = new JSONObject(); - param.put("bill_status", "99"); - param.put("confirm_optid", SecurityUtils.getCurrentUserId()); - param.put("confirm_optname", SecurityUtils.getCurrentNickName()); - param.put("confirm_time", DateUtil.now()); - mst.update(param, "scrap_id = '" + whereJson.getString("scrap_id") + "'"); } @Override