@ -236,6 +236,17 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre
component . setCreateDate ( detail . getCreateDate ( ) ) ;
component . setCreateDate ( detail . getCreateDate ( ) ) ;
QuoteDetail childDetail = createQuoteDetail ( detail , component ) ;
QuoteDetail childDetail = createQuoteDetail ( detail , component ) ;
String childPartType = baseMapper . queryPartType ( childDetail . getSite ( ) , childDetail . getPartNo ( ) ) ;
boolean treatAsPurchasedLeaf = "Purchased" . equals ( childPartType ) | | "Purchased (raw)" . equals ( childPartType ) ;
if ( treatAsPurchasedLeaf ) {
/ / 按业务新口径 : Purchased 与 Purchased ( raw ) 一样按叶子处理 , 不再递归展开下级BOM
component . setBomFlag ( "N" ) ;
log . info ( "[BOM_PROCESS] 子物料 {} (partType={}) 按叶子处理,跳过递归建树" ,
component . getComponentPart ( ) , childPartType ) ;
nodeData . components . add ( component ) ;
continue ;
}
QuoteDetailBomTree childBomCheck = isComponentBom ( childDetail ) ;
QuoteDetailBomTree childBomCheck = isComponentBom ( childDetail ) ;
if ( Objects . nonNull ( childBomCheck ) & & "Y" . equals ( component . getBomFlag ( ) ) ) {
if ( Objects . nonNull ( childBomCheck ) & & "Y" . equals ( component . getBomFlag ( ) ) ) {
@ -720,6 +731,60 @@ public class QuoteDetailBomTreeServiceImpl extends ServiceImpl<QuoteDetailBomTre
}
}
}
}
@Override
public BigDecimal queryInventoryValue ( String site , String partNo ) {
log . info ( "queryInventoryValue - Request params: site={}, partNo={}" , site , partNo ) ;
String status = baseMapper . queryPartStatus ( site , partNo ) ;
log . info ( "queryInventoryValue - Query part status from database: status={}" , status ) ;
/ / 非正式料按现有口径回退数据库函数 , 避免 IFS 无数据导致整单成本归零
if ( ! "Y" . equals ( status ) ) {
BigDecimal cost = baseMapper . getPartCost ( site , partNo ) ;
BigDecimal result = cost ! = null ? cost : BigDecimal . ZERO ;
log . info ( "queryInventoryValue - Unofficial part (status={}), fallback to DB unit cost: {}" , status , result ) ;
return result ;
}
try {
String username = ( ( SysUserEntity ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ) . getUsername ( ) ;
SysUserEntity ifsUser = sysUserDao . selectOne ( new QueryWrapper < SysUserEntity > ( ) . eq ( "username" , username ) ) ;
if ( ifsUser = = null | | ! org . apache . commons . lang3 . StringUtils . isNotBlank ( ifsUser . getIfsUsername ( ) )
| | ! org . apache . commons . lang3 . StringUtils . isNotBlank ( ifsUser . getIfsPassword ( ) ) ) {
log . warn ( "queryInventoryValue - User {} has no IFS account configured, fallback to DB unit cost" , username ) ;
BigDecimal cost = baseMapper . getPartCost ( site , partNo ) ;
BigDecimal result = cost ! = null ? cost : BigDecimal . ZERO ;
log . info ( "queryInventoryValue - Fallback result from DB unit cost: {}" , result ) ;
return result ;
}
Server ifsCon = ifsServer . getIfsServer ( ifsUser . getIfsUsername ( ) , ifsUser . getIfsPassword ( ) ) ;
PartInformationEntity part = new PartInformationEntity ( ) ;
part . setSite ( site ) ;
part . setPartNo ( partNo ) ;
log . info ( "queryInventoryValue - Calling IFS getInventoryValueByPartNo with params: site={}, partNo={}" , site , partNo ) ;
Map < String , String > map = baseSearchBean . getInventoryValueByPartNo ( ifsCon , part ) ;
log . info ( "queryInventoryValue - IFS API response: {}" , map ) ;
if ( Objects . equals ( map . get ( "resultCode" ) , "200" ) ) {
InventoryPartUnitCostSumVo unitCostSumVo = JSONObject . parseObject ( map . get ( "obj" ) , InventoryPartUnitCostSumVo . class ) ;
String inventoryValueStr = unitCostSumVo . getInventoryValue ( ) ;
BigDecimal inventoryValue = org . apache . commons . lang3 . StringUtils . isNotBlank ( inventoryValueStr )
? new BigDecimal ( inventoryValueStr ) : BigDecimal . ZERO ;
log . info ( "queryInventoryValue - Successfully retrieved InventoryValue from IFS: {}" , inventoryValue ) ;
return inventoryValue ;
} else {
log . warn ( "queryInventoryValue - Failed to retrieve from IFS, resultCode={}, resultMsg={}" ,
map . get ( "resultCode" ) , map . get ( "resultMsg" ) ) ;
return BigDecimal . ZERO ;
}
} catch ( Exception e ) {
log . error ( "queryInventoryValue - Exception occurred for partNo={}: {}" , partNo , e . getMessage ( ) , e ) ;
return BigDecimal . ZERO ;
}
}
@Override
@Override
public String queryPartType ( String site , String partNo ) {
public String queryPartType ( String site , String partNo ) {
return baseMapper . queryPartType ( site , partNo ) ;
return baseMapper . queryPartType ( site , partNo ) ;