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 lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -9,6 +11,7 @@ import java.math.BigDecimal;
|
|||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PlanSearchItemVO {
|
||||
|
||||
private Long id;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public class PlanController extends ControllerBase {
|
|||
boolean multiRegionQuotations = isMultiRegionQuotationsUser();
|
||||
List<Long> categoryIds = new ArrayList<>();
|
||||
if (multiRegionQuotations) {
|
||||
categoryIds = dictionaryItemService.getListByDictionaryCode("MultiRegionQuotationsSupplier")
|
||||
categoryIds = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory")
|
||||
.stream()
|
||||
.map(DictionaryItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -146,6 +146,7 @@ public class PlanController extends ControllerBase {
|
|||
}
|
||||
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
||||
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()) {
|
||||
if (index >= startIndex && index < endIndex) {
|
||||
categoryIds.forEach(categoryId -> {
|
||||
|
|
@ -156,14 +157,30 @@ public class PlanController extends ControllerBase {
|
|||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(vos)) {
|
||||
entry.getValue().forEach(item -> {
|
||||
item.setStandardPrice(salePrice);
|
||||
item.setAreaId(categoryId);
|
||||
datas.add(item);
|
||||
datas.add(new PlanSearchItemVO()
|
||||
.setPlanId(item.getPlanId())
|
||||
.setIsDefault(item.getIsDefault())
|
||||
.setModelId(item.getModelId())
|
||||
.setModelNo(item.getModelNo())
|
||||
.setName(item.getName())
|
||||
.setRatio(item.getRatio())
|
||||
.setAreaId(categoryId)
|
||||
.setStandardPrice(salePrice)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
vos.forEach(item -> {
|
||||
item.setStandardPrice(salePrice);
|
||||
datas.add(item);
|
||||
datas.add(new PlanSearchItemVO()
|
||||
.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