Commit 60a64ac9 by zhouhaibao

[+]品牌处理

1 parent 078275dc
...@@ -38,6 +38,7 @@ import com.rop.annotation.ServiceMethod; ...@@ -38,6 +38,7 @@ import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean; import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -216,8 +217,16 @@ public class MerchantAnalysisController { ...@@ -216,8 +217,16 @@ public class MerchantAnalysisController {
for (StoreItemResponse itemResponse : result) { for (StoreItemResponse itemResponse : result) {
MerchantDetailResponse merchantDetailResponse = responses.stream().filter(detailResponse -> (detailResponse.getMerchantNo()+"").equals(itemResponse.getMerchantNo())).findFirst().orElse(null); MerchantDetailResponse merchantDetailResponse = responses.stream().filter(detailResponse -> (detailResponse.getMerchantNo()+"").equals(itemResponse.getMerchantNo())).findFirst().orElse(null);
if (merchantDetailResponse != null) { if (merchantDetailResponse != null) {
itemResponse.setMainBrands(merchantDetailResponse.getCarBrandResponses().stream().map(CarBrandDTO::getLabel).collect( itemResponse.setMainBrands(
Collectors.joining("/"))); merchantDetailResponse.getCarBrandResponses().stream()
.flatMap(parent ->
(parent.getChildren() != null && !parent.getChildren().isEmpty())
? parent.getChildren().stream()
.map(child -> parent.getLabel() + "-" + child.getLabel())
: Stream.of(parent.getLabel()) // 若无子品牌,保留主品牌自身
)
.collect(Collectors.joining("/"))
);
itemResponse.setOnlineOperators(merchantDetailResponse.getOnlineOperator().stream().map( itemResponse.setOnlineOperators(merchantDetailResponse.getOnlineOperator().stream().map(
OperatorResponse::getUsername).collect( OperatorResponse::getUsername).collect(
Collectors.joining("/"))); Collectors.joining("/")));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!