Browse Source

行政地区编码查询接口修改,返回parentCode

master
yinzuomei 5 years ago
parent
commit
88e4b34298
  1. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

@ -21,11 +21,11 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.constant.AreaCodeConstant;
import com.epmet.dao.AreaCodeChildDao;
import com.epmet.dao.AreaCodeDao;
@ -43,7 +43,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
@ -342,7 +341,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(three.getCountyCode());
dto.setName(three.getCountyName());
dto.setParentCode(c);
//区县的上一级取city_code
dto.setParentCode(three.getCityCode());
threeResult.add(dto);
});
List<AreaCodeDictResultDTO> threeSort = threeResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
@ -361,6 +361,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
});
List<AreaCodeDictResultDTO> citySort = cityOnceResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
dto.setChildren(citySort);
//一级行政地区parent_code设置为0
dto.setParentCode("0");
result.add(dto);
});
List<AreaCodeDictResultDTO> collect = result.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
@ -379,8 +381,10 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
List<AreaCodeDictResultDTO> fourResult = new ArrayList<>();
// 街道-社区
Map<Integer, List<AreaCodeChildDTO>> groupByLevel = areaCodeChildDTOS.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getLevel));
//社区
List<AreaCodeChildDTO> levelFive = groupByLevel.get(NumConstant.FIVE);
Map<String, List<AreaCodeChildDTO>> groupByPCode = levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
//街道
List<AreaCodeChildDTO> levelFour = groupByLevel.get(NumConstant.FOUR);
levelFour.forEach(four -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();

Loading…
Cancel
Save