Commit 6cc0b7df authored by zhangfeng's avatar zhangfeng

获得目的仓树形列表返回优化

parent 930bb1a7
package cn.iocoder.yudao.module.member.service.scoreRule; package cn.iocoder.yudao.module.member.service.scoreRule;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.depository.service.warehouse.WarehouseService; import cn.iocoder.yudao.module.depository.service.warehouse.WarehouseService;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseTreeRegionVO; import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseTreeRegionVO;
import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert; import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert;
...@@ -31,11 +27,13 @@ import org.jetbrains.annotations.NotNull; ...@@ -31,11 +27,13 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import javax.annotation.Resource;
import java.time.Instant;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
import static java.util.Arrays.stream;
/** /**
* 积分规则 Service 实现类 * 积分规则 Service 实现类
...@@ -458,18 +456,18 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -458,18 +456,18 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
ArrayList<WarehouseTreeRegionSimpleVO> warehouseTreeRegionSimpleVOS = new ArrayList<>(); ArrayList<WarehouseTreeRegionSimpleVO> warehouseTreeRegionSimpleVOS = new ArrayList<>();
for (WarehouseTreeRegionVO warehouseTreeRegionVO : list) { for (WarehouseTreeRegionVO warehouseTreeRegionVO : list) {
WarehouseTreeRegionSimpleVO warehouseTreeRegionSimpleVO = new WarehouseTreeRegionSimpleVO(); WarehouseTreeRegionSimpleVO warehouseTreeRegionSimpleVO = new WarehouseTreeRegionSimpleVO();
warehouseTreeRegionSimpleVO.setCountryId(warehouseTreeRegionVO.getGuojia()); warehouseTreeRegionSimpleVO.setId(warehouseTreeRegionVO.getGuojia());
warehouseTreeRegionSimpleVO.setLabelZh(warehouseTreeRegionVO.getGuojiaName().replaceAll("\t", "")); warehouseTreeRegionSimpleVO.setLabelZh(warehouseTreeRegionVO.getGuojiaName().replaceAll("\t", ""));
warehouseTreeRegionSimpleVO.setLabelEn(warehouseTreeRegionVO.getChildren().get(0).getGuojiaNameEn()); warehouseTreeRegionSimpleVO.setLabelEn(warehouseTreeRegionVO.getChildren().get(0).getGuojiaNameEn());
ArrayList<WarehouseTreeRegionSimpleVO.WarehouseCity> warehouseCitiesSimple = new ArrayList<>(); ArrayList<WarehouseTreeRegionSimpleVO.WarehouseCity> warehouseCitiesSimple = new ArrayList<>();
for (WarehouseTreeRegionVO warehouseTreeRegionVOChild : warehouseTreeRegionVO.getChildren()) { for (WarehouseTreeRegionVO warehouseTreeRegionVOChild : warehouseTreeRegionVO.getChildren()) {
WarehouseTreeRegionSimpleVO.WarehouseCity warehouseCity = new WarehouseTreeRegionSimpleVO.WarehouseCity(); WarehouseTreeRegionSimpleVO.WarehouseCity warehouseCity = new WarehouseTreeRegionSimpleVO.WarehouseCity();
warehouseCity.setCityId(warehouseTreeRegionVOChild.getShi()); warehouseCity.setId(warehouseTreeRegionVOChild.getShi());
warehouseCity.setLabelZh(warehouseTreeRegionVOChild.getShiName().replaceAll("\t", "")); warehouseCity.setLabelZh(warehouseTreeRegionVOChild.getShiName().replaceAll("\t", ""));
warehouseCity.setLabelEn(warehouseTreeRegionVOChild.getShiNameEn()); warehouseCity.setLabelEn(warehouseTreeRegionVOChild.getShiNameEn());
if (warehouseCitiesSimple.contains(warehouseCity)) { if (warehouseCitiesSimple.contains(warehouseCity)) {
WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse(); WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse();
warehouse.setWarehouseId(warehouseTreeRegionVOChild.getId()); warehouse.setId(warehouseTreeRegionVOChild.getId());
warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh()); warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh());
warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn()); warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn());
warehouseCitiesSimple.get(warehouseCitiesSimple.indexOf(warehouseCity)).getChildren().add(warehouse); warehouseCitiesSimple.get(warehouseCitiesSimple.indexOf(warehouseCity)).getChildren().add(warehouse);
...@@ -477,7 +475,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -477,7 +475,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
} }
ArrayList<WarehouseTreeRegionSimpleVO.Warehouse> warehouseSimples = new ArrayList<>(); ArrayList<WarehouseTreeRegionSimpleVO.Warehouse> warehouseSimples = new ArrayList<>();
WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse(); WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse();
warehouse.setWarehouseId(warehouseTreeRegionVOChild.getId()); warehouse.setId(warehouseTreeRegionVOChild.getId());
warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh().replaceAll("\t", "")); warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh().replaceAll("\t", ""));
warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn()); warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn());
warehouseSimples.add(warehouse); warehouseSimples.add(warehouse);
......
package cn.iocoder.yudao.module.member.vo.scoreRule; package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseRespVO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -10,7 +9,7 @@ import java.util.Objects; ...@@ -10,7 +9,7 @@ import java.util.Objects;
@Data @Data
public class WarehouseTreeRegionSimpleVO { public class WarehouseTreeRegionSimpleVO {
@ApiModelProperty("国家id") @ApiModelProperty("国家id")
private Long countryId; private Long id;
@ApiModelProperty("国家中文名") @ApiModelProperty("国家中文名")
private String labelZh; private String labelZh;
@ApiModelProperty("国家英文名") @ApiModelProperty("国家英文名")
...@@ -22,7 +21,7 @@ public class WarehouseTreeRegionSimpleVO { ...@@ -22,7 +21,7 @@ public class WarehouseTreeRegionSimpleVO {
@Data @Data
public static class WarehouseCity { public static class WarehouseCity {
@ApiModelProperty("城市id") @ApiModelProperty("城市id")
private Long cityId; private Long id;
@ApiModelProperty("城市中文名") @ApiModelProperty("城市中文名")
private String labelZh; private String labelZh;
@ApiModelProperty("城市英文名") @ApiModelProperty("城市英文名")
...@@ -35,18 +34,18 @@ public class WarehouseTreeRegionSimpleVO { ...@@ -35,18 +34,18 @@ public class WarehouseTreeRegionSimpleVO {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
WarehouseCity that = (WarehouseCity) o; WarehouseCity that = (WarehouseCity) o;
return Objects.equals(cityId, that.cityId); return Objects.equals(id, that.id);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(cityId); return Objects.hashCode(id);
} }
} }
@Data @Data
public static class Warehouse { public static class Warehouse {
@ApiModelProperty("仓库id") @ApiModelProperty("仓库id")
private Long warehouseId; private Long id;
@ApiModelProperty("仓库中文名") @ApiModelProperty("仓库中文名")
private String labelZh; private String labelZh;
@ApiModelProperty("仓库英文名") @ApiModelProperty("仓库英文名")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment