@ -220,7 +220,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
salesOrderChildByMaterialNo . put ( salesOrderMaterialNo , salesOrderChild ) ;
}
Long purchasePlanMaterialSum = 0L ;
double purchasePlanMaterialSum = 0L ;
// 第三步:计算purchasePlanNum
for ( SysMakeorderBom filterSysMakeorderBom : filterSysMakeorderBoms ) {
String salesOrderMaterialNo = filterSysMakeorderBom . getSalesOrderMaterialNo ( ) ;
@ -229,10 +229,10 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
//物料数量
long materialNum = sysSalesOrderChild . getMaterialNum ( ) ;
//用量
long useNum = filterSysMakeorderBom . getUseNum ( ) ;
Double useNum = filterSysMakeorderBom . getUseNum ( ) ;
//采购计划数
long purchasePlanNum = materialNum * useNum ;
double purchasePlanNum = materialNum * useNum ;
// 立即创建PurchasePlanChild对象
PurchasePlanChild purchasePlanChild = new PurchasePlanChild ( ) ;
@ -243,7 +243,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
if ( tempPurchasePlanChild ! = null ) {
purchasePlanChild . setPurchasePlanChildId ( tempPurchasePlanChild . getPurchasePlanChildId ( ) ) ;
long addMaterialNum = tempPurchasePlanChild . getMaterialNum ( ) + purchasePlanNum ;
double addMaterialNum = tempPurchasePlanChild . getMaterialNum ( ) + purchasePlanNum ;
//设置计划采购数
purchasePlanChild . setMaterialNum ( addMaterialNum ) ;
purchasePlanChildMapper . updatePurchasePlanChild ( purchasePlanChild ) ;
@ -324,7 +324,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
. collect ( Collectors . toList ( ) ) ;
for ( ErpBom subBom : filterSubBomList ) {
PurchasePlanChild purchasePlanChild = createPurchasePlanChild ( purchasePlanCode , subBom , loginName ) ;
purchasePlanChild . setMaterialNum ( ( long ) ( erpDevelopModifyorderDetail . getMaterialNum ( ) * subBom . getUseNum ( ) ) ) ;
purchasePlanChild . setMaterialNum ( ( double ) ( erpDevelopModifyorderDetail . getMaterialNum ( ) * subBom . getUseNum ( ) ) ) ;
purchasePlanChildList . add ( purchasePlanChild ) ;
}
}
@ -338,10 +338,13 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
purchasePlan . setMaterialAmount ( Long . valueOf ( filterMergedPurchasePlanChildList . size ( ) ) ) ;
// 计算所有 PurchasePlanChild 的 materialNum 总和
Long totalMaterialNum = filterMergedPurchasePlanChildList . stream ( )
. mapToLong ( PurchasePlanChild : : getMaterialNum )
. sum ( ) ;
purchasePlan . setMaterialSum ( totalMaterialNum ) ;
// Long totalMaterialNum = filterMergedPurchasePlanChildList.stream()
// .mapToLong(PurchasePlanChild::getMaterialNum)
// .sum();
double totalMaterialNum = filterMergedPurchasePlanChildList . stream ( ) . mapToDouble ( purchasePlanChild - > purchasePlanChild . getMaterialNum ( ) ) . sum ( ) ;
purchasePlan . setMaterialSum ( ( long ) totalMaterialNum ) ;
// 批量新增采购计划子表
// purchasePlanChildMapper.batchInsertPurchasePlanChild(filterMergedPurchasePlanChildList);
@ -365,7 +368,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
purchasePlanChild . setBrand ( detail . getMaterialBrand ( ) ) ;
purchasePlanChild . setUnit ( detail . getMaterialUnit ( ) ) ;
purchasePlanChild . setDescribe ( detail . getMaterialDescribe ( ) ) ;
purchasePlanChild . setMaterialNum ( Long . valueOf ( detail . getMaterialNum ( ) ) ) ;
purchasePlanChild . setMaterialNum ( Double . valueOf ( detail . getMaterialNum ( ) ) ) ;
purchasePlanChild . setWarehouseDept ( detail . getWarehouseDept ( ) ) ;
return purchasePlanChild ;
}
@ -409,7 +412,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
return redisCache . generateBillNo ( "CGJH" ) ;
}
private PurchasePlan buildPurchasePlan ( SysMakeOrder sysMakeOrder , String purchasePlanCode , Integer materialAmount , Long purchasePlanMaterialSum ) {
private PurchasePlan buildPurchasePlan ( SysMakeOrder sysMakeOrder , String purchasePlanCode , Integer materialAmount , double purchasePlanMaterialSum ) {
PurchasePlan purchasePlan = new PurchasePlan ( ) ;
purchasePlan . setCorrelationCode ( sysMakeOrder . getMakeNo ( ) ) ;
purchasePlan . setPurchasePlanCode ( purchasePlanCode ) ;
@ -418,7 +421,7 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
purchasePlan . setMaterialAmount ( ( long ) materialAmount ) ;
//添加数量合计
purchasePlan . setMaterialSum ( purchasePlanMaterialSum ) ;
purchasePlan . setMaterialSum ( ( long ) purchasePlanMaterialSum ) ;
purchasePlan . setNoRmbSum ( sysMakeOrder . getNoRate ( ) ) ;
purchasePlan . setRmbSum ( sysMakeOrder . getRate ( ) ) ;
purchasePlan . setApplyUser ( sysMakeOrder . getSalesman ( ) ) ;