refactor(quotation): 优化PlanSearchItemVO对象构造及查询逻辑
- 替换多区域字典代码为DirectSalesCategory以准确获取分类ID - 在分页数据中设置总数以支持分页展示 - 修改循环中对象处理,避免直接修改原有对象,改为构建新的PlanSearchItemVO对象 - 新建PlanSearchItemVO实例时链式调用设置属性,保证数据完整性和代码简洁 - 在PlanSearchItemVO类上添加@Accessors(chain = true)注解支持链式调用
This commit is contained in:
parent
5eb48c2c09
commit
9e90022fed
|
|
@ -2,6 +2,8 @@ package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
import com.nflg.mobilebroken.common.util.NumberUtil;
|
import com.nflg.mobilebroken.common.util.NumberUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.data.annotation.AccessType;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
@ -9,6 +11,7 @@ import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class PlanSearchItemVO {
|
public class PlanSearchItemVO {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ public class PlanController extends ControllerBase {
|
||||||
boolean multiRegionQuotations = isMultiRegionQuotationsUser();
|
boolean multiRegionQuotations = isMultiRegionQuotationsUser();
|
||||||
List<Long> categoryIds = new ArrayList<>();
|
List<Long> categoryIds = new ArrayList<>();
|
||||||
if (multiRegionQuotations) {
|
if (multiRegionQuotations) {
|
||||||
categoryIds = dictionaryItemService.getListByDictionaryCode("MultiRegionQuotationsSupplier")
|
categoryIds = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory")
|
||||||
.stream()
|
.stream()
|
||||||
.map(DictionaryItem::getId)
|
.map(DictionaryItem::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
@ -146,6 +146,7 @@ public class PlanController extends ControllerBase {
|
||||||
}
|
}
|
||||||
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
||||||
Map<Long, List<PlanSearchItemVO>> fgroup = items.stream().collect(Collectors.groupingBy(PlanSearchItemVO::getModelId));
|
Map<Long, List<PlanSearchItemVO>> fgroup = items.stream().collect(Collectors.groupingBy(PlanSearchItemVO::getModelId));
|
||||||
|
pageData.setTotal(fgroup.size());
|
||||||
for (Map.Entry<Long, List<PlanSearchItemVO>> entry : fgroup.entrySet()) {
|
for (Map.Entry<Long, List<PlanSearchItemVO>> entry : fgroup.entrySet()) {
|
||||||
if (index >= startIndex && index < endIndex) {
|
if (index >= startIndex && index < endIndex) {
|
||||||
categoryIds.forEach(categoryId -> {
|
categoryIds.forEach(categoryId -> {
|
||||||
|
|
@ -156,14 +157,30 @@ public class PlanController extends ControllerBase {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollectionUtil.isEmpty(vos)) {
|
if (CollectionUtil.isEmpty(vos)) {
|
||||||
entry.getValue().forEach(item -> {
|
entry.getValue().forEach(item -> {
|
||||||
item.setStandardPrice(salePrice);
|
datas.add(new PlanSearchItemVO()
|
||||||
item.setAreaId(categoryId);
|
.setPlanId(item.getPlanId())
|
||||||
datas.add(item);
|
.setIsDefault(item.getIsDefault())
|
||||||
|
.setModelId(item.getModelId())
|
||||||
|
.setModelNo(item.getModelNo())
|
||||||
|
.setName(item.getName())
|
||||||
|
.setRatio(item.getRatio())
|
||||||
|
.setAreaId(categoryId)
|
||||||
|
.setStandardPrice(salePrice)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vos.forEach(item -> {
|
vos.forEach(item -> {
|
||||||
item.setStandardPrice(salePrice);
|
datas.add(new PlanSearchItemVO()
|
||||||
datas.add(item);
|
.setId(item.getId())
|
||||||
|
.setPlanId(item.getPlanId())
|
||||||
|
.setIsDefault(item.getIsDefault())
|
||||||
|
.setModelId(item.getModelId())
|
||||||
|
.setModelNo(item.getModelNo())
|
||||||
|
.setName(item.getName())
|
||||||
|
.setRatio(item.getRatio())
|
||||||
|
.setAreaId(categoryId)
|
||||||
|
.setStandardPrice(salePrice)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue