From 25f17b8d7560108974af84929df1e841ad1cf13e Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Mon, 16 Mar 2026 12:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=B3=E8=AF=B7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=9D=90=E6=96=99=E4=B8=AD=E6=B7=BB=E5=8A=A0BOM?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B0=86=E6=96=99?= =?UTF-8?q?=E5=8F=B7=E5=AF=B9=E5=BA=94=E7=9A=84BOM=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=BD=93=E5=89=8D=E6=B5=8B=E8=AF=95=E5=8D=95?= =?UTF-8?q?=20=20=20=20=20=20=201=E3=80=81bom=E5=AF=BC=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=80=89=E6=8B=A9=E5=AF=B9=E5=BA=94=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E8=BF=9B=E8=A1=8C=E5=AF=BC=E5=85=A5=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=201.1=20=20=E5=A6=82=E6=9E=9C=E6=98=AF?= =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E6=96=99=E5=8F=B7=EF=BC=8C=E9=82=A3=E4=B9=88?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=88=90=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/controller/TestSoBomController.java | 11 ++++++ .../test/service/TestSoBomService.java | 1 + .../service/impl/TestSoBomServiceImpl.java | 39 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/main/java/com/spring/modules/test/controller/TestSoBomController.java b/src/main/java/com/spring/modules/test/controller/TestSoBomController.java index 4febf8fc..5dc54ad9 100644 --- a/src/main/java/com/spring/modules/test/controller/TestSoBomController.java +++ b/src/main/java/com/spring/modules/test/controller/TestSoBomController.java @@ -70,4 +70,15 @@ public class TestSoBomController { testSoBomService.removeBatchTestSoBom(testSoBomList); return R.ok("操作成功"); } + + /** + * BOM导入 - 批量新增测试产品结构 + * @param testSoBomList 从BOM导入的物料列表 + * @return + */ + @PostMapping("/saveBatch") + public R saveBatchTestSoBom(@RequestBody List testSoBomList){ + testSoBomService.saveBatchTestSoBom(testSoBomList); + return R.ok("导入成功"); + } } diff --git a/src/main/java/com/spring/modules/test/service/TestSoBomService.java b/src/main/java/com/spring/modules/test/service/TestSoBomService.java index 119527f7..dbf79639 100644 --- a/src/main/java/com/spring/modules/test/service/TestSoBomService.java +++ b/src/main/java/com/spring/modules/test/service/TestSoBomService.java @@ -16,5 +16,6 @@ public interface TestSoBomService extends IService { void removeBatchTestSoBom(List testSoBomList); void saveTestSoBom(TestSoBom testSoBom); void updateTestSoBom(TestSoBom testSoBom); + void saveBatchTestSoBom(List testSoBomList); } diff --git a/src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java b/src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java index e8f129aa..1443e93d 100644 --- a/src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java +++ b/src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java @@ -146,6 +146,45 @@ public class TestSoBomServiceImpl extends ServiceImpl testSoBomList) { + if (testSoBomList == null || testSoBomList.isEmpty()) { + return; + } + String site = testSoBomList.get(0).getSite(); + String testNo = testSoBomList.get(0).getTestNo(); + checkoutTestSoBomKey(testSoBomList.get(0)); + + TestInformationEntity testInfo = testInformationService.lambdaQuery() + .eq(TestInformationEntity::getTestNo, testNo) + .eq(TestInformationEntity::getSite, site) + .one(); + if (Objects.isNull(testInfo)) { + throw new RuntimeException("测试单号" + testNo + "不存在"); + } + + BigDecimal nextItemNo = baseMapper.selectTestSoBomItemNo(site, testNo); + if (nextItemNo == null) { + nextItemNo = BigDecimal.ONE; + } + + for (TestSoBom testSoBom : testSoBomList) { + if (testInfo.getTestPartNo().equals(testSoBom.getComponentPartNo())) { + throw new RuntimeException("不可将自身物料[" + testSoBom.getComponentPartNo() + "]作为产品结构"); + } + testSoBom.setSite(site); + testSoBom.setTestNo(testNo); + testSoBom.setItemNo(nextItemNo); + nextItemNo = nextItemNo.add(BigDecimal.ONE); + baseMapper.insert(testSoBom); + } + } + /** * 检查测试产品结构Key * @param testSoBom