From af979cc04b9f27b9de3e6e942c5882e1436781f5 Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Fri, 18 Jul 2025 15:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=A9=E5=BA=93=E4=B8=8D?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E4=BE=9B=E5=BA=94=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PurchaseServiceImpl.java | 35 +++++++++++++++---- .../aqgqj/business/utils/SystemUtils.java | 11 ++++-- src/main/resources/application-prod.yml | 1 + .../business/backstage/PurchaseMapper.xml | 1 + 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/bonus/aqgqj/business/backstage/service/PurchaseServiceImpl.java b/src/main/java/com/bonus/aqgqj/business/backstage/service/PurchaseServiceImpl.java index 609f2b0..0b80bf6 100644 --- a/src/main/java/com/bonus/aqgqj/business/backstage/service/PurchaseServiceImpl.java +++ b/src/main/java/com/bonus/aqgqj/business/backstage/service/PurchaseServiceImpl.java @@ -32,10 +32,7 @@ import javax.servlet.http.HttpServletRequest; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -241,6 +238,9 @@ public class PurchaseServiceImpl implements PurchaseService { if (StringUtils.isEmpty(detailsList)) { return ServerResponse.createErroe("发货明细不能为空"); } + // 把利库和采购都为0的都删掉 + detailsList.removeIf(Objects::isNull); + int allCkNum = 0; int allLkNum = 0; SupplierVo supp = new SupplierVo(); @@ -249,6 +249,10 @@ public class PurchaseServiceImpl implements PurchaseService { if (StringUtils.isEmpty(detailsList)) { return ServerResponse.createErroe("厂商数据不能为空"); } + // 采购和利库都是0的数量就不处理 + if (supInfoList.get(0).getCgNum() == 0 && supInfoList.get(0).getLkNum() == 0) { + continue; + } boolean hasDuplicates = supInfoList.stream() .collect(Collectors.groupingBy(OutPlanVoSupInfo::getSupId)) @@ -280,7 +284,8 @@ public class PurchaseServiceImpl implements PurchaseService { supp.setSupId(supInfo.getSupId()); //验证数据 int num = supplierMapper.supCheck(supp); - if (num < 1) { + // 只有采购才需要选择供应商 + if (num < 1 && supInfo.getCgNum() > 0) { return ServerResponse.createErroe(supInfo.getSupName() + "-厂家合同内无此-" + details.getModel() + "-型号设备"); } } @@ -319,6 +324,14 @@ public class PurchaseServiceImpl implements PurchaseService { return ServerResponse.createErroe("新增失败数据异常,请稍后重试"); } List supInfoList = details.getSupList(); + // 没有采购的模拟一条假数据 + for (OutPlanVoSupInfo info : supInfoList) { + if (info.getCgNum() <= 0) { + info.setContractId("10086"); + info.setSupId("10086"); + info.setSupName("库存发出"); + } + } int succ = mapper.insertPurchaseDetailsSupData(details, supInfoList); if (succ != supInfoList.size()) { return ServerResponse.createErroe("新增失败数据异常,请稍后重试"); @@ -437,7 +450,7 @@ public class PurchaseServiceImpl implements PurchaseService { supp.setSupId(supInfo.getSupId()); //验证数据 int num = supplierMapper.supCheck(supp); - if (num < 1) { + if (num < 1 && supInfo.getCgNum() > 0) { return ServerResponse.createErroe(supInfo.getSupName() + "-厂家合同内无此-" + details.getModel() + "-型号设备"); } } @@ -477,6 +490,14 @@ public class PurchaseServiceImpl implements PurchaseService { return ServerResponse.createErroe("新增失败数据异常,请稍后重试"); } List supInfoList = details.getSupList(); + // 没有采购的模拟一条假数据 + for (OutPlanVoSupInfo info : supInfoList) { + if (info.getCgNum() <= 0) { + info.setContractId("10086"); + info.setSupId("10086"); + info.setSupName("库存发出"); + } + } int succ = mapper.insertPurchaseDetailsSupData(details, supInfoList); if (succ != supInfoList.size()) { return ServerResponse.createErroe("新增失败数据异常,请稍后重试"); @@ -604,7 +625,7 @@ public class PurchaseServiceImpl implements PurchaseService { supp.setSupId(supInfo.getSupId()); //验证数据 int num = supplierMapper.supCheck(supp); - if (num < 1) { + if (num < 1 && supInfo.getCgNum() > 0) { return ServerResponse.createErroe(supInfo.getSupName() + "-厂家合同内无此-" + details.getModel() + "-型号设备"); } } diff --git a/src/main/java/com/bonus/aqgqj/business/utils/SystemUtils.java b/src/main/java/com/bonus/aqgqj/business/utils/SystemUtils.java index 8e96465..a2e867a 100644 --- a/src/main/java/com/bonus/aqgqj/business/utils/SystemUtils.java +++ b/src/main/java/com/bonus/aqgqj/business/utils/SystemUtils.java @@ -12,9 +12,10 @@ public class SystemUtils { public static String windowsPath; - public static String linuxPath; + public static String otherPath; + /** * 自动注入 * @@ -35,6 +36,12 @@ public class SystemUtils { SystemUtils.linuxPath = linuxPath; } + @Value("${file.upload_path.other}") + public void setOtherPath(String otherPath) { + SystemUtils.otherPath = otherPath; + } + + /** * 返回系统 * @@ -65,7 +72,7 @@ public class SystemUtils { } else if ("linux".equals(os)) { return linuxPath; } else { - return windowsPath; + return otherPath; } } diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 4fda925..b41f485 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -45,6 +45,7 @@ file: upload_path: windows: D://files/zg_gqj linux: /home/zg_gqj/files + other: /Users/syruan/files diff --git a/src/main/resources/mappers/business/backstage/PurchaseMapper.xml b/src/main/resources/mappers/business/backstage/PurchaseMapper.xml index e3227d6..4c58eb3 100644 --- a/src/main/resources/mappers/business/backstage/PurchaseMapper.xml +++ b/src/main/resources/mappers/business/backstage/PurchaseMapper.xml @@ -54,6 +54,7 @@ #{item.modelId},#{item.cgNum},#{item.lkNum},#{item.supName},#{item.ccDay},#{item.jyDay},#{item.remark}) + update st_plan_out_sup set contract_id=#{contractId},sup_id=#{supId}, cg_num=#{cgNum},lk_num=#{lkNum},sup_name=#{supName},cc_day=#{ccDay},jy_day=#{jyDay},