Browse Source

fix: 预算核销历史记录;订单查询异常

checkBack
Yen 1 year ago
parent
commit
21ad1f4626
  1. 1
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java
  2. 9
      src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetController.java
  3. 3
      src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetChangeScheduleItem.java
  4. 5
      src/main/java/com/qs/serve/modules/tbs/entity/bo/TbsBudgetAmtBo.java
  5. 196
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetBatchServiceImpl.java
  6. 2
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeOperationServiceImpl.java
  7. 13
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeServiceImpl.java
  8. 8
      src/main/resources/mapper/goods/GoodsSpuMapper.xml

1
src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

@ -553,6 +553,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
order.setBrandRuleName(categoryRule.getLabel()); order.setBrandRuleName(categoryRule.getLabel());
} }
order.setOrderSource(confirmOrder.getOrderSource());
order.setCdOrderRemark(createOrderParam.getCdOrderRemark()); order.setCdOrderRemark(createOrderParam.getCdOrderRemark());
order.setOrderType(confirmOrder.getOrderType()); order.setOrderType(confirmOrder.getOrderType());
order.setSupplierId(Long.parseLong(supplier.getId())); order.setSupplierId(Long.parseLong(supplier.getId()));

9
src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetController.java

@ -436,6 +436,15 @@ public class TbsBudgetController {
if(tbsBudgetCostItemService.count(lqw)>0){ if(tbsBudgetCostItemService.count(lqw)>0){
return R.error("预算已被使用"); return R.error("预算已被使用");
} }
long countUnPub = tbsBudgetService.count(
new LambdaQueryWrapper<TbsBudget>()
.in(TbsBudget::getId,idsLong)
.eq(TbsBudget::getBudgetState,0)
.eq(TbsBudget::getBudgetCheckState,TbsCommonCheckState.State_0_unPublish)
);
if(countUnPub>0){
return R.error("预算状态不支持删除");
}
boolean result = tbsBudgetService.removeByIds(idsLong); boolean result = tbsBudgetService.removeByIds(idsLong);
//移除考核期预算 //移除考核期预算
LambdaQueryWrapper<TbsScheduleItemBudget> rmItemBudget = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TbsScheduleItemBudget> rmItemBudget = new LambdaQueryWrapper<>();

3
src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetChangeScheduleItem.java

@ -34,6 +34,9 @@ public class TbsBudgetChangeScheduleItem implements Serializable {
/** 更变记录id */ /** 更变记录id */
private Long changeId; private Long changeId;
/** 和原来记录做对比,判断是否更变 */
private Integer changeFlag;
/** TbsScheduleItemBudget.id */ /** TbsScheduleItemBudget.id */
private Long sourceId; private Long sourceId;

5
src/main/java/com/qs/serve/modules/tbs/entity/bo/TbsBudgetAmtBo.java

@ -11,7 +11,10 @@ import java.math.BigDecimal;
@Data @Data
public class TbsBudgetAmtBo { public class TbsBudgetAmtBo {
private Long budgetScheduleItemId; /**
* scheduleItemBudgetId
*/
private Long scheduleItemId;
private BigDecimal preDispatchAmount; private BigDecimal preDispatchAmount;

196
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetBatchServiceImpl.java

@ -279,7 +279,6 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
batchItem.setUserName(sysUser.getName()); batchItem.setUserName(sysUser.getName());
batchItem.setRemark(paramItem.getRemark()); batchItem.setRemark(paramItem.getRemark());
batchItems.add(batchItem); batchItems.add(batchItem);
}else { }else {
//修改后为新增类型提交 //修改后为新增类型提交
this.toUpdateBudgetInfo(batchId,sysUser, scheduleMap, subjectMap, centerDtoMap, categoryMap, paramItem, budgetId); this.toUpdateBudgetInfo(batchId,sysUser, scheduleMap, subjectMap, centerDtoMap, categoryMap, paramItem, budgetId);
@ -329,7 +328,9 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
return budgetBatch; return budgetBatch;
} }
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) { 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( tbsBudgetConditionService.remove(
new LambdaQueryWrapper<TbsBudgetCondition>() new LambdaQueryWrapper<TbsBudgetCondition>()
@ -363,19 +364,19 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
private void toSaveChangeCondition(Map<String, GoodsCategory> categoryMap, TbsBudget budget, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId, Long changeId) { private void toSaveChangeCondition(Map<String, GoodsCategory> categoryMap, TbsBudget budget, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId, Long changeId) {
if(budget.getConditionFlag().equals(1)){ if(budget.getConditionFlag().equals(1)){
List<TbsBudgetCondition> existingConditionList = tbsBudgetConditionService // List<TbsBudgetCondition> existingConditionList = tbsBudgetConditionService
.list(new LambdaQueryWrapper<TbsBudgetCondition>() // .list(new LambdaQueryWrapper<TbsBudgetCondition>()
.eq(TbsBudgetCondition::getBudgetId, budgetId)); // .eq(TbsBudgetCondition::getBudgetId, budgetId));
String bandNames = paramItem.getBrandNames(); String bandNames = paramItem.getBrandNames();
String categoryNames = paramItem.getCategoryNames(); String categoryNames = paramItem.getCategoryNames();
String seriesNames = paramItem.getSeriesNames(); String seriesNames = paramItem.getSeriesNames();
//设置changeConditionList参数 //设置changeConditionList参数
List<TbsBudgetChangeCondition> changeConditionList = new ArrayList<>(); List<TbsBudgetChangeCondition> changeConditionList = new ArrayList<>();
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, null,
bandNames, TbsGoodsType.brand.name()); bandNames, TbsGoodsType.brand.name());
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, null,
categoryNames, TbsGoodsType.category.name()); categoryNames, TbsGoodsType.category.name());
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, null,
seriesNames, TbsGoodsType.series.name()); seriesNames, TbsGoodsType.series.name());
if(CollUtil.isNotEmpty(changeConditionList)){ if(CollUtil.isNotEmpty(changeConditionList)){
tbsBudgetChangeConditionService.saveBatch(changeConditionList); tbsBudgetChangeConditionService.saveBatch(changeConditionList);
@ -407,10 +408,10 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
if(budgetAmount.getScheduleItemName().equals(itemBudget.getItemName())){ if(budgetAmount.getScheduleItemName().equals(itemBudget.getItemName())){
boolean ne1 = ! (itemBudget.getPreDispatchAmount().compareTo(budgetAmount.getPreDispatchAmount())==0); boolean ne1 = ! (itemBudget.getPreDispatchAmount().compareTo(budgetAmount.getPreDispatchAmount())==0);
boolean ne2 = ! (realAmt.compareTo(budgetAmount.getBudgetAmount())==0); boolean ne2 = ! (realAmt.compareTo(budgetAmount.getBudgetAmount())==0);
if(ne1 || ne2){
TbsBudgetChangeScheduleItem resultItem = TbsBudgetChangeScheduleItem.toNewObject(itemBudget); TbsBudgetChangeScheduleItem resultItem = TbsBudgetChangeScheduleItem.toNewObject(itemBudget);
resultItem.setChangeId(changeId); resultItem.setChangeId(changeId);
resultItem.setBudgetAmount(realAmt); resultItem.setBudgetAmount(realAmt);
resultItem.setChangeFlag((ne1 || ne2)?1:0);
resultItem.setNewBudgetAmount(budgetAmount.getBudgetAmount()); resultItem.setNewBudgetAmount(budgetAmount.getBudgetAmount());
resultItem.setNewPreDispatchAmount(budgetAmount.getPreDispatchAmount()); resultItem.setNewPreDispatchAmount(budgetAmount.getPreDispatchAmount());
resultItem.setCategoryNames(paramItem.getCategoryNames()); resultItem.setCategoryNames(paramItem.getCategoryNames());
@ -422,17 +423,12 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
} }
} }
} }
}
private void buildChangeConditionList(Map<String, GoodsCategory> categoryMap, Long budgetId, Long changeId, List<TbsBudgetChangeCondition> changeConditionList, List<TbsBudgetCondition> existingConditionList, String values, String targetType) { private void buildChangeConditionList(Map<String, GoodsCategory> categoryMap, Long budgetId, Long changeId, List<TbsBudgetChangeCondition> changeConditionList, List<TbsBudgetCondition> existingConditionList, String values, String targetType) {
if(StringUtils.hasText(values)){ if(StringUtils.hasText(values)){
String[] valueArr = values.replace(",",",").split(","); String[] valueArr = values.replace(",",",").split(",");
for (String val : valueArr) { for (String val : valueArr) {
boolean exist = existingConditionList.stream().anyMatch( GoodsCategory goodsCategory = categoryMap.get(targetType+"_"+val);
a->a.getTargetName().equals(val)||a.getTargetCode().equals(val)
);
if(!exist){
GoodsCategory goodsCategory = categoryMap.get(val);
if(goodsCategory!=null){ if(goodsCategory!=null){
TbsBudgetChangeCondition budgetChangeCondition = new TbsBudgetChangeCondition(); TbsBudgetChangeCondition budgetChangeCondition = new TbsBudgetChangeCondition();
budgetChangeCondition.setChangeId(changeId); budgetChangeCondition.setChangeId(changeId);
@ -448,7 +444,6 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
} }
} }
} }
}
@NotNull @NotNull
private List<TbsBudgetCondition> createTbsBudgetConditions(Map<String, GoodsCategory> categoryMap, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId) { private List<TbsBudgetCondition> createTbsBudgetConditions(Map<String, GoodsCategory> categoryMap, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId) {
@ -456,7 +451,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
if(StringUtils.hasText(paramItem.getBrandNames())){ if(StringUtils.hasText(paramItem.getBrandNames())){
String[] values = paramItem.getBrandNames().split(","); String[] values = paramItem.getBrandNames().split(",");
for (String value : values) { for (String value : values) {
GoodsCategory category = categoryMap.get(value); GoodsCategory category = categoryMap.get(TbsGoodsType.brand.name()+"_"+value);
TbsBudgetCondition budgetCondition = new TbsBudgetCondition(); TbsBudgetCondition budgetCondition = new TbsBudgetCondition();
budgetCondition.setBudgetId(budgetId); budgetCondition.setBudgetId(budgetId);
budgetCondition.setTargetType(TbsGoodsType.brand.name()); budgetCondition.setTargetType(TbsGoodsType.brand.name());
@ -471,7 +466,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
if(StringUtils.hasText(paramItem.getCategoryNames())){ if(StringUtils.hasText(paramItem.getCategoryNames())){
String[] values = paramItem.getCategoryNames().split(","); String[] values = paramItem.getCategoryNames().split(",");
for (String value : values) { for (String value : values) {
GoodsCategory category = categoryMap.get(value); GoodsCategory category = categoryMap.get(TbsGoodsType.category.name()+"_"+value);
TbsBudgetCondition budgetCondition = new TbsBudgetCondition(); TbsBudgetCondition budgetCondition = new TbsBudgetCondition();
budgetCondition.setBudgetId(budgetId); budgetCondition.setBudgetId(budgetId);
budgetCondition.setTargetType(TbsGoodsType.category.name()); budgetCondition.setTargetType(TbsGoodsType.category.name());
@ -486,7 +481,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
if(StringUtils.hasText(paramItem.getSeriesNames())){ if(StringUtils.hasText(paramItem.getSeriesNames())){
String[] values = paramItem.getSeriesNames().split(","); String[] values = paramItem.getSeriesNames().split(",");
for (String value : values) { for (String value : values) {
GoodsCategory category = categoryMap.get(value); GoodsCategory category = categoryMap.get(TbsGoodsType.series.name()+"_"+value);
TbsBudgetCondition budgetCondition = new TbsBudgetCondition(); TbsBudgetCondition budgetCondition = new TbsBudgetCondition();
budgetCondition.setBudgetId(budgetId); budgetCondition.setBudgetId(budgetId);
budgetCondition.setTargetType(TbsGoodsType.series.name()); budgetCondition.setTargetType(TbsGoodsType.series.name());
@ -567,120 +562,121 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
*/ */
private Map<String,GoodsCategory> loadGoodsCategoryMap(TbsBudgetBatchBo param) { private Map<String,GoodsCategory> loadGoodsCategoryMap(TbsBudgetBatchBo param) {
List<TbsBudgetBatchBo.BudgetMain> paramBudgetList = param.getBudgetList(); List<TbsBudgetBatchBo.BudgetMain> paramBudgetList = param.getBudgetList();
Set<String> goodsCategoryNames = new HashSet<>(); //初始化三个维度的品类
List<String> allBandNameList = new ArrayList<>(),
allCategoryNameList = new ArrayList<>(),
allSeriesNameList = new ArrayList<>();
for (TbsBudgetBatchBo.BudgetMain budgetMain : paramBudgetList) { for (TbsBudgetBatchBo.BudgetMain budgetMain : paramBudgetList) {
String bandNames = budgetMain.getBrandNames(); String bandNames = budgetMain.getBrandNames();
String categoryNames = budgetMain.getCategoryNames(); String categoryNames = budgetMain.getCategoryNames();
String seriesNames = budgetMain.getSeriesNames(); String seriesNames = budgetMain.getSeriesNames();
initCategorySet(goodsCategoryNames, bandNames); allBandNameList.addAll(initCategorySet(bandNames));
initCategorySet(goodsCategoryNames, categoryNames); allCategoryNameList.addAll(initCategorySet(categoryNames));
initCategorySet(goodsCategoryNames, seriesNames); allSeriesNameList.addAll(initCategorySet(seriesNames));
} }
if(goodsCategoryNames.size()<1){ if(CollUtil.isEmpty(allBandNameList)
&& CollUtil.isEmpty(allCategoryNameList)
&& CollUtil.isEmpty(allSeriesNameList)){
return new HashMap<>(); return new HashMap<>();
} }
List<GoodsCategory> goodsCategories = goodsCategoryService.list( //查询类目
new LambdaQueryWrapper<GoodsCategory>() List<GoodsCategory> bandList = this.queryCategory(1,allBandNameList);
.in(GoodsCategory::getName,goodsCategoryNames) List<GoodsCategory> categoryList = this.queryCategory(2,allCategoryNameList);
.or() List<GoodsCategory> seriesList = this.queryCategory(3,allSeriesNameList);
.in(GoodsCategory::getCode,goodsCategoryNames)
);
if(goodsCategories.size()!= goodsCategoryNames.size()){
for (String categoryName : goodsCategoryNames) {
List<GoodsCategory> tempList = goodsCategories.stream()
.filter(a->a.getName().equals(categoryName)).collect(Collectors.toList());
if(tempList.size()<1){
for (TbsBudgetBatchBo.BudgetMain budgetMain : paramBudgetList) { for (TbsBudgetBatchBo.BudgetMain budgetMain : paramBudgetList) {
boolean bandNamesFlag = budgetMain.getBrandNames() != null && budgetMain.getBrandNames().contains(categoryName); String bandNames = budgetMain.getBrandNames();
boolean categoryNamesFlag = budgetMain.getCategoryNames() != null && budgetMain.getCategoryNames().contains(categoryName); String categoryNames = budgetMain.getCategoryNames();
boolean seriesNamesFlag = budgetMain.getSeriesNames() != null && budgetMain.getSeriesNames().contains(categoryName); String seriesNames = budgetMain.getSeriesNames();
if(bandNamesFlag){
budgetMain.getErrorInfos().add("无效的品牌:"+categoryName); List<String> bandNameItemList = initCategorySet(bandNames);
param.setErrorFlag(true); List<String> categoryNameItemList = initCategorySet(categoryNames);
break; List<String> seriesNameItemList = initCategorySet(seriesNames);
} checkMchError(1,param, budgetMain,bandList, bandNameItemList);
if(categoryNamesFlag){ checkMchError(2,param, budgetMain,categoryList, categoryNameItemList);
budgetMain.getErrorInfos().add("无效的品类:"+categoryName); checkMchError(3,param, budgetMain,seriesList, seriesNameItemList);
param.setErrorFlag(true);
break;
}
if(seriesNamesFlag){
budgetMain.getErrorInfos().add("无效的系列:"+categoryName);
param.setErrorFlag(true);
break;
}
}
}
} }
}else{
for (String categoryName : goodsCategoryNames) { Map<String,GoodsCategory> categoryMap = new HashMap<>();
List<GoodsCategory> tempList = goodsCategories.stream() for (GoodsCategory category : bandList) {
.filter(a->a.getName().equals(categoryName)).collect(Collectors.toList()); categoryMap.put(TbsGoodsType.brand.name()+"_"+category.getName(),category);
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;
} }
for (GoodsCategory category : categoryList) {
categoryMap.put(TbsGoodsType.category.name()+"_"+category.getName(),category);
} }
if(!isTrue){ for (GoodsCategory category : seriesList) {
budgetMain.getErrorInfos().add("无效的品牌:"+categoryName); categoryMap.put(TbsGoodsType.series.name()+"_"+category.getName(),category);
param.setErrorFlag(true);
} }
return categoryMap;
} }
if(categoryNamesFlag){
boolean isTrue = false; /**
for (GoodsCategory category : tempList) { * 校验查询结果
if(category.getLevel().equals(2)){ * @param level
isTrue = true; * @param param
* @param budgetMain
* @param bandList
* @param cateNames
*/
private void checkMchError(int level,TbsBudgetBatchBo param,
TbsBudgetBatchBo.BudgetMain budgetMain,
List<GoodsCategory> bandList,
List<String> cateNames) {
for (String name : cateNames) {
boolean mch = false;
for (GoodsCategory category : bandList) {
if(name.equals(category.getName())){
mch = true;
break; break;
} }
} }
if(!isTrue){ if(!mch){
budgetMain.getErrorInfos().add("无效的品类:"+categoryName); if(level==1){
param.setErrorFlag(true); budgetMain.getErrorInfos().add("无效的品牌:"+name);
} }else if (level==2){
} budgetMain.getErrorInfos().add("无效的品类:"+name);
if(seriesNamesFlag){ }else {
boolean isTrue = false; budgetMain.getErrorInfos().add("无效的系列:"+name);
for (GoodsCategory category : tempList) {
if(category.getLevel().equals(3)){
isTrue = true;
break;
}
} }
if(!isTrue){
budgetMain.getErrorInfos().add("无效的系列:"+categoryName);
param.setErrorFlag(true); param.setErrorFlag(true);
} }
} }
} }
/**
* 查询品类
* @param level 等级1-品牌 2-类目 3-系列
* @param nameOrCodes
* @return
*/
private List<GoodsCategory> queryCategory(int level,List<String> nameOrCodes) {
if(CollUtil.isEmpty(nameOrCodes)){
return new ArrayList<>();
} }
} List<GoodsCategory> list = goodsCategoryService.list(
Map<String,GoodsCategory> categoryMap = new HashMap<>(goodsCategories.size()); new LambdaQueryWrapper<GoodsCategory>()
for (GoodsCategory category : goodsCategories) { .eq(GoodsCategory::getLevel,level)
categoryMap.put(category.getName(),category); .and(cn->{
} cn.in(GoodsCategory::getName,nameOrCodes)
return categoryMap; .or()
.in(GoodsCategory::getCode,nameOrCodes);
})
);
return list;
} }
/** /**
* 初始化set * 初始化set
* @param goodsCategories
* @param categoryString * @param categoryString
*/ */
private void initCategorySet(Set<String> goodsCategories, String categoryString) { private List<String> initCategorySet(String categoryString) {
if(StringUtils.hasText(categoryString)){ if(StringUtils.hasText(categoryString)){
String[] values = categoryString String[] values = categoryString
.replace(",",",") .replace(",",",")
.split(","); .split(",");
goodsCategories.addAll(Arrays.asList(values)); return Arrays.asList(values);
} }
return new ArrayList<>();
} }
private Map<String,TbsSchedule> loadScheduleMap(List<String> scheduleNames,TbsBudgetBatchBo param) { private Map<String,TbsSchedule> loadScheduleMap(List<String> scheduleNames,TbsBudgetBatchBo param) {

2
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeOperationServiceImpl.java

@ -130,6 +130,8 @@ public class TbsBudgetChangeOperationServiceImpl implements SeeYonOperationServi
} }
//更新金额 //更新金额
List<TbsBudgetChangeScheduleItem> changeScheduleItemList = tbsBudgetChangeScheduleItemService.listByChangeId(budgetChange.getId()); List<TbsBudgetChangeScheduleItem> changeScheduleItemList = tbsBudgetChangeScheduleItemService.listByChangeId(budgetChange.getId());
//过滤更变金额
changeScheduleItemList = changeScheduleItemList.stream().filter(a->a.getChangeFlag().equals(1)).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(changeScheduleItemList)){ if(CollectionUtil.isNotEmpty(changeScheduleItemList)){
List<Long> scheduleItemBudgetIds = changeScheduleItemList.stream().map(TbsBudgetChangeScheduleItem::getSourceId).collect(Collectors.toList()); List<Long> scheduleItemBudgetIds = changeScheduleItemList.stream().map(TbsBudgetChangeScheduleItem::getSourceId).collect(Collectors.toList());
List<TbsScheduleItemBudget> scheduleItemBudgetList = tbsScheduleItemBudgetService.listByIds(scheduleItemBudgetIds); List<TbsScheduleItemBudget> scheduleItemBudgetList = tbsScheduleItemBudgetService.listByIds(scheduleItemBudgetIds);

13
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeServiceImpl.java

@ -270,16 +270,21 @@ public class TbsBudgetChangeServiceImpl extends ServiceImpl<TbsBudgetChangeMappe
//设置金额 //设置金额
List<TbsBudgetAmtBo> budgetAmtUpdateList = param.getBudgetAmtUpdateList(); List<TbsBudgetAmtBo> budgetAmtUpdateList = param.getBudgetAmtUpdateList();
if(CollectionUtil.isNotEmpty(budgetAmtUpdateList)){ if(CollectionUtil.isNotEmpty(budgetAmtUpdateList)){
List<Long> budgetScheduleIds = budgetAmtUpdateList.stream().map(TbsBudgetAmtBo::getBudgetScheduleItemId).collect(Collectors.toList()); //更变的周期项
List<Long> budgetScheduleIds = budgetAmtUpdateList.stream().map(TbsBudgetAmtBo::getScheduleItemId).collect(Collectors.toList());
List<TbsBudgetLogWithAmount> budgetLogWithAmountList = tbsScheduleItemBudgetMapper.getSumAmtInList(budgetScheduleIds,Arrays.asList(0,2,3)); List<TbsBudgetLogWithAmount> budgetLogWithAmountList = tbsScheduleItemBudgetMapper.getSumAmtInList(budgetScheduleIds,Arrays.asList(0,2,3));
List<TbsScheduleItemBudget> scheduleItemBudgetList = tbsScheduleItemBudgetMapper.selectBatchIds(budgetScheduleIds); //所有的周期项
List<TbsScheduleItemBudget> allScheduleItemBudgetList = tbsScheduleItemBudgetMapper
.selectList(new LambdaQueryWrapper<TbsScheduleItemBudget>().eq(TbsScheduleItemBudget::getBudgetId,budget.getId()));
List<TbsBudgetChangeScheduleItem> changeScheduleItemList = new ArrayList<>(); List<TbsBudgetChangeScheduleItem> changeScheduleItemList = new ArrayList<>();
for (TbsScheduleItemBudget scheduleItemBudget : scheduleItemBudgetList) { for (TbsScheduleItemBudget scheduleItemBudget : allScheduleItemBudgetList) {
if(!scheduleItemBudget.getBudgetId().equals(budget.getId())){ if(!scheduleItemBudget.getBudgetId().equals(budget.getId())){
Assert.throwEx("参数异常!!"); Assert.throwEx("参数异常!!");
} }
boolean isChange = budgetScheduleIds.stream().anyMatch(a->a.equals(scheduleItemBudget.getId()));
TbsBudgetChangeScheduleItem resultItem = TbsBudgetChangeScheduleItem.toNewObject(scheduleItemBudget); TbsBudgetChangeScheduleItem resultItem = TbsBudgetChangeScheduleItem.toNewObject(scheduleItemBudget);
resultItem.setChangeId(changeId); resultItem.setChangeId(changeId);
resultItem.setChangeFlag(isChange?1:0);
//设置当前项调整的最终金额 //设置当前项调整的最终金额
for (TbsBudgetLogWithAmount withAmount : budgetLogWithAmountList) { for (TbsBudgetLogWithAmount withAmount : budgetLogWithAmountList) {
if(withAmount.getId().equals(scheduleItemBudget.getId())){ if(withAmount.getId().equals(scheduleItemBudget.getId())){
@ -289,7 +294,7 @@ public class TbsBudgetChangeServiceImpl extends ServiceImpl<TbsBudgetChangeMappe
} }
//设置更新的金额 //设置更新的金额
for (TbsBudgetAmtBo budgetAmtBo : budgetAmtUpdateList) { for (TbsBudgetAmtBo budgetAmtBo : budgetAmtUpdateList) {
if(budgetAmtBo.getBudgetScheduleItemId().equals(scheduleItemBudget.getId())){ if(budgetAmtBo.getScheduleItemId().equals(scheduleItemBudget.getId())){
resultItem.setNewPreDispatchAmount(budgetAmtBo.getPreDispatchAmount()); resultItem.setNewPreDispatchAmount(budgetAmtBo.getPreDispatchAmount());
resultItem.setNewBudgetAmount(budgetAmtBo.getBudgetAmount()); resultItem.setNewBudgetAmount(budgetAmtBo.getBudgetAmount());
break; break;

8
src/main/resources/mapper/goods/GoodsSpuMapper.xml

@ -270,7 +270,7 @@
SELECT sku.*,ROW_NUMBER() OVER(PARTITION BY sku.spu_id ORDER BY sku.belong_sort) AS rn SELECT sku.*,ROW_NUMBER() OVER(PARTITION BY sku.spu_id ORDER BY sku.belong_sort) AS rn
FROM goods_sku sku FROM goods_sku sku
left join goods_spu spu on sku.spu_id = spu.id left join goods_spu spu on sku.spu_id = spu.id
WHERE sku.order_flag = 1 AND sku.special_flag = 0 and sku.del_flag = 0 WHERE sku.order_flag = 1 AND sku.special_flag = 0 and sku.del_flag = 0 and sku.enable = 1
<if test="query.keyword != null and query.keyword != '' "> <if test="query.keyword != null and query.keyword != '' ">
and ( and (
`sku`.`sku_code` like concat('%', #{query.keyword},'%') or `sku`.`sku_code` like concat('%', #{query.keyword},'%') or
@ -295,7 +295,7 @@
UNION ALL UNION ALL
SELECT sku.*,1 as rn FROM goods_sku sku SELECT sku.*,1 as rn FROM goods_sku sku
left join goods_spu spu on sku.spu_id = spu.id left join goods_spu spu on sku.spu_id = spu.id
WHERE sku.special_flag = 1 and sku.del_flag = 0 WHERE sku.special_flag = 1 and sku.del_flag = 0 and sku.enable = 1
<if test="query.keyword != null and query.keyword != '' "> <if test="query.keyword != null and query.keyword != '' ">
and ( and (
`sku`.`sku_code` like concat('%', #{query.keyword},'%') or `sku`.`sku_code` like concat('%', #{query.keyword},'%') or
@ -337,7 +337,7 @@
SELECT sku.*,ROW_NUMBER() OVER(PARTITION BY sku.spu_id ORDER BY sku.belong_sort) AS rn SELECT sku.*,ROW_NUMBER() OVER(PARTITION BY sku.spu_id ORDER BY sku.belong_sort) AS rn
FROM goods_sku sku FROM goods_sku sku
left join goods_spu spu on sku.spu_id = spu.id left join goods_spu spu on sku.spu_id = spu.id
WHERE sku.order_flag = 1 AND sku.special_flag = 0 WHERE sku.order_flag = 1 AND sku.special_flag = 0 and sku.enable = 1
<if test="query.keyword != null and query.keyword != '' "> <if test="query.keyword != null and query.keyword != '' ">
and ( and (
`sku`.`sku_code` like concat('%', #{query.keyword},'%') or `sku`.`sku_code` like concat('%', #{query.keyword},'%') or
@ -365,7 +365,7 @@
UNION ALL UNION ALL
SELECT sku.*,1 as rn FROM goods_sku sku SELECT sku.*,1 as rn FROM goods_sku sku
left join goods_spu spu on sku.spu_id = spu.id left join goods_spu spu on sku.spu_id = spu.id
WHERE sku.special_flag = 1 WHERE sku.special_flag = 1 and sku.enable = 1
<if test="query.keyword != null and query.keyword != '' "> <if test="query.keyword != null and query.keyword != '' ">
and ( and (
`sku`.`sku_code` like concat('%', #{query.keyword},'%') or `sku`.`sku_code` like concat('%', #{query.keyword},'%') or

Loading…
Cancel
Save