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; + } } }