From d930329846969fa9e32be34230ad3f0c06dcde68 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Fri, 19 Dec 2025 16:40:29 +0800 Subject: [PATCH] =?UTF-8?q?2025-12-19=20=E6=8A=A5=E4=BB=B7=E6=97=B6?= =?UTF-8?q?=E7=9A=84estimatedMaterialCost=E4=BB=8E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/QuoteDetailBomTreeServiceImpl.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/spring/modules/quote/service/impl/QuoteDetailBomTreeServiceImpl.java b/src/main/java/com/spring/modules/quote/service/impl/QuoteDetailBomTreeServiceImpl.java index bced5862..5cd48a64 100644 --- a/src/main/java/com/spring/modules/quote/service/impl/QuoteDetailBomTreeServiceImpl.java +++ b/src/main/java/com/spring/modules/quote/service/impl/QuoteDetailBomTreeServiceImpl.java @@ -498,7 +498,36 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl().eq("username", username)); + if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) + || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { + log.warn("用户 {} 未维护IFS账号,使用数据库查询estimatedMaterialCost", username); + BigDecimal cost = baseMapper.queryEstimatedMaterialCost(site, partNo); + return cost != null ? cost : BigDecimal.ZERO; + } + Server ifsCon = ifsServer.getIfsServer(ifsUser.getIfsUsername(), ifsUser.getIfsPassword()); + + // 调用IFS接口获取预估材料成本 + PartInformationEntity part = new PartInformationEntity(); + part.setSite(site); + part.setPartNo(partNo); + Map map = baseSearchBean.getInventoryEstimatedMaterialCostByPartNo(ifsCon, part); + + if (Objects.equals(map.get("resultCode"), "200")) { + InventoryPartUnitCostSumVo unitCostSumVo = JSONObject.parseObject(map.get("obj"), InventoryPartUnitCostSumVo.class); + BigDecimal estimatedCost = new BigDecimal(unitCostSumVo.getInventoryValue()); + log.info("物料 {} 从IFS获取预估材料成本: {}", partNo, estimatedCost); + return estimatedCost; + } else { + log.warn("物料 {} 从IFS获取预估材料成本失败: {}", partNo, map.get("resultMsg")); + return BigDecimal.ZERO; + } + } catch (Exception e) { + log.error("物料 {} 获取预估材料成本异常: {}", partNo, e.getMessage()); + return BigDecimal.ZERO; + } } }