@ -189,30 +189,41 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
//加载 品类
Map < String , GoodsCategory > categoryMap = loadGoodsCategoryMap ( param ) ;
//有错误信息退出
if ( param . isErrorFlag ( ) ) {
return null ;
}
this . save ( budgetBatch ) ;
//保存后赋值
Long batchId = budgetBatch . getId ( ) ;
//修改的生成为更变记录
List < TbsBudgetBatchBo . BudgetMain > updBudgetList = paramBudgetList . stream ( )
. filter ( a - > StringUtils . hasText ( a . getBudgetNumber ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TbsBudget > budgetList = new ArrayList < > ( ) ;
if ( updBudgetList . size ( ) > 0 ) {
List < String > budgetNumbers = updBudgetList . stream ( )
. map ( TbsBudgetBatchBo . BudgetMain : : getBudgetNumber ) . collect ( Collectors . toList ( ) ) ;
List < TbsBudget > budgetList = tbsBudgetService . list (
budgetList = tbsBudgetService . list (
new LambdaQueryWrapper < TbsBudget > ( ) . in (
TbsBudget : : getBudgetNumber , budgetNumbers
)
)
) ;
for ( TbsBudget budget : budgetList ) {
if ( budget . getBudgetCheckState ( ) = = TbsBudgetCheckState . State_1_apply ) {
Assert . throwEx ( "预算[" + budget . getBudgetCode ( ) + "]审批中,无法导入修改" ) ;
for ( TbsBudgetBatchBo . BudgetMain budgetMain : updBudgetList ) {
if ( budgetMain . getBudgetNumber ( ) . equals ( budget . getBudgetNumber ( ) ) ) {
budgetMain . getErrorInfos ( ) . add ( "预算[" + budget . getBudgetCode ( ) + "]审批中,无法导入修改" ) ;
param . setErrorFlag ( true ) ;
}
}
}
}
}
//有错误信息退出
if ( param . isErrorFlag ( ) ) {
return null ;
}
this . save ( budgetBatch ) ;
//保存后赋值
Long batchId = budgetBatch . getId ( ) ;
if ( updBudgetList . size ( ) > 0 ) {
for ( TbsBudget budget : budgetList ) {
TbsBudgetBatchBo . BudgetMain paramItem = null ;
for ( TbsBudgetBatchBo . BudgetMain budgetMain : updBudgetList ) {
@ -303,7 +314,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
}
private void toUpdateBudgetInfo ( Long batchId , SysUser sysUser , Map < String , TbsSchedule > scheduleMap , Map < String , BmsSubject > subjectMap , Map < String , TbsCenterDto > centerDtoMap , Map < String , GoodsCategory > categoryMap , TbsBudgetBatchBo . BudgetMain paramItem , Long budgetId ) {
tbsBudgetService . removeById ( budgetId ) ;
//tbsBudgetService.removeById(budgetId);
tbsBudgetConditionService . remove (
new LambdaQueryWrapper < TbsBudgetCondition > ( )
. eq ( TbsBudgetCondition : : getBudgetId , budgetId )
@ -427,7 +438,37 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
GoodsCategory category = categoryMap . get ( value ) ;
TbsBudgetCondition budgetCondition = new TbsBudgetCondition ( ) ;
budgetCondition . setBudgetId ( budgetId ) ;
budgetCondition . setTargetType ( GoodsType . Brand . name ( ) ) ;
budgetCondition . setTargetType ( TbsGoodsType . brand . name ( ) ) ;
budgetCondition . setTargetId ( category . getId ( ) ) ;
budgetCondition . setTargetCode ( category . getCode ( ) ) ;
budgetCondition . setTargetName ( category . getName ( ) ) ;
budgetCondition . setTargetLevelPathIds ( category . getLevelPath ( ) ) ;
budgetCondition . setTargetLevelPathNames ( category . getLevelPathNames ( ) ) ;
conditionList . add ( budgetCondition ) ;
}
}
if ( StringUtils . hasText ( paramItem . getCategoryNames ( ) ) ) {
String [ ] values = paramItem . getCategoryNames ( ) . split ( "," ) ;
for ( String value : values ) {
GoodsCategory category = categoryMap . get ( value ) ;
TbsBudgetCondition budgetCondition = new TbsBudgetCondition ( ) ;
budgetCondition . setBudgetId ( budgetId ) ;
budgetCondition . setTargetType ( TbsGoodsType . category . name ( ) ) ;
budgetCondition . setTargetId ( category . getId ( ) ) ;
budgetCondition . setTargetCode ( category . getCode ( ) ) ;
budgetCondition . setTargetName ( category . getName ( ) ) ;
budgetCondition . setTargetLevelPathIds ( category . getLevelPath ( ) ) ;
budgetCondition . setTargetLevelPathNames ( category . getLevelPathNames ( ) ) ;
conditionList . add ( budgetCondition ) ;
}
}
if ( StringUtils . hasText ( paramItem . getSeriesNames ( ) ) ) {
String [ ] values = paramItem . getSeriesNames ( ) . split ( "," ) ;
for ( String value : values ) {
GoodsCategory category = categoryMap . get ( value ) ;
TbsBudgetCondition budgetCondition = new TbsBudgetCondition ( ) ;
budgetCondition . setBudgetId ( budgetId ) ;
budgetCondition . setTargetType ( TbsGoodsType . series . name ( ) ) ;
budgetCondition . setTargetId ( category . getId ( ) ) ;
budgetCondition . setTargetCode ( category . getCode ( ) ) ;
budgetCondition . setTargetName ( category . getName ( ) ) ;
@ -525,18 +566,78 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
) ;
if ( goodsCategories . size ( ) ! = goodsCategoryNames . size ( ) ) {
for ( String categoryName : goodsCategoryNames ) {
boolean exist = goodsCategories . stream ( ) . anyMatch ( a - > a . getName ( ) . equals ( categoryName ) ) ;
if ( ! exist ) {
//Assert.throwEx("无效的品类:"+categoryName);
List < GoodsCategory > tempList = goodsCategories . stream ( )
. filter ( a - > a . getName ( ) . equals ( categoryName ) ) . collect ( Collectors . toList ( ) ) ;
if ( tempList . size ( ) < 1 ) {
for ( TbsBudgetBatchBo . BudgetMain budgetMain : paramBudgetList ) {
boolean bandNamesFlag = budgetMain . getBrandNames ( ) ! = null & & budgetMain . getBrandNames ( ) . contains ( categoryName ) ;
boolean categoryNamesFlag = budgetMain . getCategoryNames ( ) ! = null & & budgetMain . getCategoryNames ( ) . contains ( categoryName ) ;
boolean seriesNamesFlag = budgetMain . getSeriesNames ( ) ! = null & & budgetMain . getSeriesNames ( ) . contains ( categoryName ) ;
if ( bandNamesFlag | | categoryNamesFlag | | seriesNamesFlag ) {
if ( bandNamesFlag ) {
budgetMain . getErrorInfos ( ) . add ( "无效的品牌:" + categoryName ) ;
param . setErrorFlag ( true ) ;
break ;
}
if ( categoryNamesFlag ) {
budgetMain . getErrorInfos ( ) . add ( "无效的品类:" + categoryName ) ;
param . setErrorFlag ( true ) ;
break ;
}
if ( seriesNamesFlag ) {
budgetMain . getErrorInfos ( ) . add ( "无效的系列:" + categoryName ) ;
param . setErrorFlag ( true ) ;
break ;
}
}
}
}
} else {
for ( String categoryName : goodsCategoryNames ) {
List < GoodsCategory > tempList = goodsCategories . stream ( )
. filter ( a - > a . getName ( ) . equals ( categoryName ) ) . collect ( Collectors . toList ( ) ) ;
for ( TbsBudgetBatchBo . BudgetMain budgetMain : paramBudgetList ) {
boolean bandNamesFlag = budgetMain . getBrandNames ( ) ! = null & & budgetMain . getBrandNames ( ) . contains ( categoryName ) ;
boolean categoryNamesFlag = budgetMain . getCategoryNames ( ) ! = null & & budgetMain . getCategoryNames ( ) . contains ( categoryName ) ;
boolean seriesNamesFlag = budgetMain . getSeriesNames ( ) ! = null & & budgetMain . getSeriesNames ( ) . contains ( categoryName ) ;
if ( bandNamesFlag ) {
boolean isTrue = false ;
for ( GoodsCategory category : tempList ) {
if ( category . getLevel ( ) . equals ( 1 ) ) {
isTrue = true ;
break ;
}
}
if ( ! isTrue ) {
budgetMain . getErrorInfos ( ) . add ( "无效的品牌:" + categoryName ) ;
param . setErrorFlag ( true ) ;
}
}
if ( categoryNamesFlag ) {
boolean isTrue = false ;
for ( GoodsCategory category : tempList ) {
if ( category . getLevel ( ) . equals ( 2 ) ) {
isTrue = true ;
break ;
}
}
if ( ! isTrue ) {
budgetMain . getErrorInfos ( ) . add ( "无效的品类:" + categoryName ) ;
param . setErrorFlag ( true ) ;
}
}
if ( seriesNamesFlag ) {
boolean isTrue = false ;
for ( GoodsCategory category : tempList ) {
if ( category . getLevel ( ) . equals ( 3 ) ) {
isTrue = true ;
break ;
}
}
if ( ! isTrue ) {
budgetMain . getErrorInfos ( ) . add ( "无效的系列:" + categoryName ) ;
param . setErrorFlag ( true ) ;
}
}
}
}
}