|
|
@ -497,16 +497,29 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public BigDecimal queryEstimatedMaterialCost(String site, String partNo) { |
|
|
|
|
|
|
|
|
public BigDecimal queryEstimatedMaterialCost(String site, String partNo, String status) { |
|
|
|
|
|
log.info("queryEstimatedMaterialCost - Request params: site={}, partNo={}, status={}", site, partNo, status); |
|
|
|
|
|
|
|
|
|
|
|
// 非正式物料(status='N')直接从数据库查询 |
|
|
|
|
|
if (!"Y".equals(status)) { |
|
|
|
|
|
BigDecimal cost = baseMapper.queryEstimatedMaterialCost(site, partNo); |
|
|
|
|
|
BigDecimal result = cost != null ? cost : BigDecimal.ZERO; |
|
|
|
|
|
log.info("queryEstimatedMaterialCost - Unofficial part, query from database. Result: {}", result); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 正式物料(status='Y')调用IFS接口 |
|
|
try { |
|
|
try { |
|
|
// 获取当前用户的IFS连接 |
|
|
// 获取当前用户的IFS连接 |
|
|
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); |
|
|
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); |
|
|
SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper<SysUserEntity>().eq("username", username)); |
|
|
SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper<SysUserEntity>().eq("username", username)); |
|
|
if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) |
|
|
if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) |
|
|
|| !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { |
|
|
|| !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { |
|
|
log.warn("用户 {} 未维护IFS账号,使用数据库查询estimatedMaterialCost", username); |
|
|
|
|
|
|
|
|
log.warn("queryEstimatedMaterialCost - User {} has no IFS account configured, fallback to database query", username); |
|
|
BigDecimal cost = baseMapper.queryEstimatedMaterialCost(site, partNo); |
|
|
BigDecimal cost = baseMapper.queryEstimatedMaterialCost(site, partNo); |
|
|
return cost != null ? cost : BigDecimal.ZERO; |
|
|
|
|
|
|
|
|
BigDecimal result = cost != null ? cost : BigDecimal.ZERO; |
|
|
|
|
|
log.info("queryEstimatedMaterialCost - Fallback result from database: {}", result); |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
Server ifsCon = ifsServer.getIfsServer(ifsUser.getIfsUsername(), ifsUser.getIfsPassword()); |
|
|
Server ifsCon = ifsServer.getIfsServer(ifsUser.getIfsUsername(), ifsUser.getIfsPassword()); |
|
|
|
|
|
|
|
|
@ -514,19 +527,23 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre |
|
|
PartInformationEntity part = new PartInformationEntity(); |
|
|
PartInformationEntity part = new PartInformationEntity(); |
|
|
part.setSite(site); |
|
|
part.setSite(site); |
|
|
part.setPartNo(partNo); |
|
|
part.setPartNo(partNo); |
|
|
|
|
|
log.info("queryEstimatedMaterialCost - Calling IFS API with params: site={}, partNo={}", site, partNo); |
|
|
|
|
|
|
|
|
Map<String, String> map = baseSearchBean.getInventoryEstimatedMaterialCostByPartNo(ifsCon, part); |
|
|
Map<String, String> map = baseSearchBean.getInventoryEstimatedMaterialCostByPartNo(ifsCon, part); |
|
|
|
|
|
log.info("queryEstimatedMaterialCost - IFS API response: {}", map); |
|
|
|
|
|
|
|
|
if (Objects.equals(map.get("resultCode"), "200")) { |
|
|
if (Objects.equals(map.get("resultCode"), "200")) { |
|
|
InventoryPartUnitCostSumVo unitCostSumVo = JSONObject.parseObject(map.get("obj"), InventoryPartUnitCostSumVo.class); |
|
|
InventoryPartUnitCostSumVo unitCostSumVo = JSONObject.parseObject(map.get("obj"), InventoryPartUnitCostSumVo.class); |
|
|
BigDecimal estimatedCost = new BigDecimal(unitCostSumVo.getInventoryValue()); |
|
|
BigDecimal estimatedCost = new BigDecimal(unitCostSumVo.getInventoryValue()); |
|
|
log.info("物料 {} 从IFS获取预估材料成本: {}", partNo, estimatedCost); |
|
|
|
|
|
|
|
|
log.info("queryEstimatedMaterialCost - Successfully retrieved estimated material cost from IFS: {}", estimatedCost); |
|
|
return estimatedCost; |
|
|
return estimatedCost; |
|
|
} else { |
|
|
} else { |
|
|
log.warn("物料 {} 从IFS获取预估材料成本失败: {}", partNo, map.get("resultMsg")); |
|
|
|
|
|
|
|
|
log.warn("queryEstimatedMaterialCost - Failed to retrieve from IFS, resultCode={}, resultMsg={}", |
|
|
|
|
|
map.get("resultCode"), map.get("resultMsg")); |
|
|
return BigDecimal.ZERO; |
|
|
return BigDecimal.ZERO; |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("物料 {} 获取预估材料成本异常: {}", partNo, e.getMessage()); |
|
|
|
|
|
|
|
|
log.error("queryEstimatedMaterialCost - Exception occurred for partNo={}: {}", partNo, e.getMessage(), e); |
|
|
return BigDecimal.ZERO; |
|
|
return BigDecimal.ZERO; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|