|
|
@ -36,10 +36,7 @@ import com.epmet.dao.AreaCodeChildDao; |
|
|
|
import com.epmet.dao.AreaCodeDao; |
|
|
|
import com.epmet.dto.AreaCodeChildDTO; |
|
|
|
import com.epmet.dto.AreaCodeDTO; |
|
|
|
import com.epmet.dto.form.AddAreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.AddAreaCodeFormDTO; |
|
|
|
import com.epmet.dto.form.AreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.AreaCodeFormDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.AreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.AreaCodeResultDTO; |
|
|
|
import com.epmet.entity.AreaCodeEntity; |
|
|
@ -72,6 +69,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
private AreaCodeChildDao childDao; |
|
|
|
@Autowired |
|
|
|
private AreaCodeChildService areaCodeChildService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<AreaCodeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<AreaCodeEntity> page = baseDao.selectPage( |
|
|
@ -88,8 +86,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
return ConvertUtils.sourceToTarget(entityList, AreaCodeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<AreaCodeEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<AreaCodeEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<AreaCodeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -125,7 +123,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 行政地区编码查询 |
|
|
|
* @Description 行政地区编码查询 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/7 下午1:41 |
|
|
@ -134,14 +132,14 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
public List<AreaCodeDictResultDTO> areaCodeDictTree(AreaCodeDictFormDTO formDTO) { |
|
|
|
List<AreaCodeDictResultDTO> tree = new ArrayList<>(); |
|
|
|
String s = areaCodeRedis.get(AreaCodeConstant.SCREEN_TREE); |
|
|
|
if (StringUtils.isNotBlank(s)){ |
|
|
|
tree = JSON.parseArray(s,AreaCodeDictResultDTO.class); |
|
|
|
}else { |
|
|
|
if (StringUtils.isNotBlank(s)) { |
|
|
|
tree = JSON.parseArray(s, AreaCodeDictResultDTO.class); |
|
|
|
} else { |
|
|
|
List<AreaCodeDictResultDTO> areaCodeDictResultDTOS = disposeTree(formDTO); |
|
|
|
areaCodeRedis.set(AreaCodeConstant.SCREEN_TREE,areaCodeDictResultDTOS); |
|
|
|
areaCodeRedis.set(AreaCodeConstant.SCREEN_TREE, areaCodeDictResultDTOS); |
|
|
|
tree = areaCodeDictResultDTOS; |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaCode())){ |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaCode())) { |
|
|
|
return tree; |
|
|
|
} |
|
|
|
List<AreaCodeDictResultDTO> treeByRootAreaCode = getTreeByRootAreaCode(tree, formDTO.getRootAreaCode()); |
|
|
@ -149,12 +147,12 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 行政区树查询 |
|
|
|
* @Description 行政区树查询 |
|
|
|
* @Param |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/8 上午8:57 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> disposeTree(AreaCodeDictFormDTO formDTO){ |
|
|
|
public List<AreaCodeDictResultDTO> disposeTree(AreaCodeDictFormDTO formDTO) { |
|
|
|
// 查询所有省市区
|
|
|
|
List<AreaCodeDTO> areaCodeDTOS = baseDao.selectAllArea(); |
|
|
|
// 查询所有街道、社区
|
|
|
@ -173,8 +171,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
dto.setCode(four.getCode()); |
|
|
|
dto.setName(four.getName()); |
|
|
|
dto.setParentCode(four.getPCode()); |
|
|
|
groupByPCode.forEach((pCode,v) -> { |
|
|
|
if (dto.getCode().equals(pCode)){ |
|
|
|
groupByPCode.forEach((pCode, v) -> { |
|
|
|
if (dto.getCode().equals(pCode)) { |
|
|
|
List<AreaCodeDictResultDTO> fiveResult = new ArrayList<>(); |
|
|
|
v.forEach(five -> { |
|
|
|
AreaCodeDictResultDTO fiveDto = new AreaCodeDictResultDTO(); |
|
|
@ -189,7 +187,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
fourResult.add(dto); |
|
|
|
}); |
|
|
|
List<AreaCodeDictResultDTO> fourSort = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(fourResult)){ |
|
|
|
if (!CollectionUtils.isEmpty(fourResult)) { |
|
|
|
fourSort = fourResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
@ -209,7 +207,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
dto.setName(three.getCountyName()); |
|
|
|
List<AreaCodeDictResultDTO> fourOnceResult = new ArrayList<>(); |
|
|
|
finalFourSort.forEach(four -> { |
|
|
|
if (dto.getCode().equals(four.getParentCode())){ |
|
|
|
if (dto.getCode().equals(four.getParentCode())) { |
|
|
|
fourOnceResult.add(four); |
|
|
|
} |
|
|
|
}); |
|
|
@ -220,13 +218,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
cityDto.setChildren(threeSort); |
|
|
|
cityResult.add(cityDto); |
|
|
|
}); |
|
|
|
groupByProvince.forEach((p,v) -> { |
|
|
|
groupByProvince.forEach((p, v) -> { |
|
|
|
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO(); |
|
|
|
dto.setCode(p); |
|
|
|
dto.setName(v.get(NumConstant.ZERO).getProvinceName()); |
|
|
|
List<AreaCodeDictResultDTO> cityOnceResult = new ArrayList<>(); |
|
|
|
cityResult.forEach(c -> { |
|
|
|
if (dto.getCode().equals(c.getParentCode())){ |
|
|
|
if (dto.getCode().equals(c.getParentCode())) { |
|
|
|
cityOnceResult.add(c); |
|
|
|
} |
|
|
|
}); |
|
|
@ -239,54 +237,51 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根据节点获取组织区域树【遍历】,传参只能是 省,市,区级别 【暂时这样,循环太多了】 |
|
|
|
* |
|
|
|
* |
|
|
|
* @Description 根据节点获取组织区域树【遍历】,传参只能是 省,市,区级别 【暂时这样,循环太多了】 |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样 |
|
|
|
* ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样== |
|
|
|
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样 |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样== |
|
|
|
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样 |
|
|
|
* @Param tree |
|
|
|
* @Param rootAreaCode |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/8 上午10:02 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> getTreeByRootAreaCode(List<AreaCodeDictResultDTO> tree , String rootAreaCode){ |
|
|
|
public List<AreaCodeDictResultDTO> getTreeByRootAreaCode(List<AreaCodeDictResultDTO> tree, String rootAreaCode) { |
|
|
|
List<AreaCodeDictResultDTO> result = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(tree)){ |
|
|
|
if (!CollectionUtils.isEmpty(tree)) { |
|
|
|
// 省级获取
|
|
|
|
for (AreaCodeDictResultDTO dto : tree) { |
|
|
|
if (rootAreaCode.equals(dto.getCode())){ |
|
|
|
if (rootAreaCode.equals(dto.getCode())) { |
|
|
|
result.add(dto); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// 市级获取
|
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO child : dto.getChildren()) { |
|
|
|
if (rootAreaCode.equals(child.getCode())){ |
|
|
|
if (rootAreaCode.equals(child.getCode())) { |
|
|
|
result.add(child); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// 区级获取
|
|
|
|
if (!CollectionUtils.isEmpty(child.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(child.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO threeChild : child.getChildren()) { |
|
|
|
if (rootAreaCode.equals(threeChild.getCode())){ |
|
|
|
if (rootAreaCode.equals(threeChild.getCode())) { |
|
|
|
result.add(threeChild); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// 街道获取
|
|
|
|
if (!CollectionUtils.isEmpty(threeChild.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(threeChild.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO fourChild : threeChild.getChildren()) { |
|
|
|
if (rootAreaCode.equals(fourChild.getCode())){ |
|
|
|
if (rootAreaCode.equals(fourChild.getCode())) { |
|
|
|
result.add(fourChild); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// 社区获取
|
|
|
|
if (!CollectionUtils.isEmpty(fourChild.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(fourChild.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO fiveChild : fourChild.getChildren()) { |
|
|
|
if (rootAreaCode.equals(fiveChild.getCode())){ |
|
|
|
if (rootAreaCode.equals(fiveChild.getCode())) { |
|
|
|
result.add(fiveChild); |
|
|
|
return result; |
|
|
|
} |
|
|
@ -304,40 +299,40 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<AreaCodeDictResultDTO> areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO){ |
|
|
|
public List<AreaCodeDictResultDTO> areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO) { |
|
|
|
List<AreaCodeDictResultDTO> tree = new ArrayList<>(); |
|
|
|
String s = areaCodeRedis.get(AreaCodeConstant.THREE_SCREEN_TREE); |
|
|
|
if (StringUtils.isNotBlank(s)){ |
|
|
|
tree = JSON.parseArray(s,AreaCodeDictResultDTO.class); |
|
|
|
}else { |
|
|
|
if (StringUtils.isNotBlank(s)) { |
|
|
|
tree = JSON.parseArray(s, AreaCodeDictResultDTO.class); |
|
|
|
} else { |
|
|
|
List<AreaCodeDictResultDTO> threeTree = beforeThreeTree(); |
|
|
|
areaCodeRedis.set(AreaCodeConstant.THREE_SCREEN_TREE,threeTree); |
|
|
|
areaCodeRedis.set(AreaCodeConstant.THREE_SCREEN_TREE, threeTree); |
|
|
|
tree = threeTree; |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaCode())){ |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaCode())) { |
|
|
|
return tree; |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaLevel())){ |
|
|
|
if (StringUtils.isBlank(formDTO.getRootAreaLevel())) { |
|
|
|
throw new RenException(AreaCodeConstant.ROOT_AGENCY_LEVEL_IS_LEVEL); |
|
|
|
} |
|
|
|
// 传参为街道-社区级
|
|
|
|
if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.STREET) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.COMMUNITY)){ |
|
|
|
if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.STREET) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.COMMUNITY)) { |
|
|
|
tree = disposeAfterTwoLevel(formDTO); |
|
|
|
}else if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.CITY) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)){ |
|
|
|
tree = disposeBeforeThreeLevelFinal(formDTO,tree); |
|
|
|
}else { |
|
|
|
throw new RenException(String.format(AreaCodeConstant.LEVEL_ERROR,formDTO.getRootAreaLevel())); |
|
|
|
} else if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.CITY) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)) { |
|
|
|
tree = disposeBeforeThreeLevelFinal(formDTO, tree); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format(AreaCodeConstant.LEVEL_ERROR, formDTO.getRootAreaLevel())); |
|
|
|
} |
|
|
|
return tree; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 省市区三级联动查询 |
|
|
|
* @Description 省市区三级联动查询 |
|
|
|
* @Param |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/11 上午9:35 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> beforeThreeTree(){ |
|
|
|
public List<AreaCodeDictResultDTO> beforeThreeTree() { |
|
|
|
// 查询所有省市区
|
|
|
|
List<AreaCodeDTO> areaCodeDTOS = baseDao.selectAllArea(); |
|
|
|
Map<String, List<AreaCodeDTO>> groupByCity = areaCodeDTOS.stream().collect(Collectors.groupingBy(AreaCodeDTO::getCityCode)); |
|
|
@ -362,13 +357,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
cityDto.setChildren(threeSort); |
|
|
|
cityResult.add(cityDto); |
|
|
|
}); |
|
|
|
groupByProvince.forEach((p,v) -> { |
|
|
|
groupByProvince.forEach((p, v) -> { |
|
|
|
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO(); |
|
|
|
dto.setCode(p); |
|
|
|
dto.setName(v.get(NumConstant.ZERO).getProvinceName()); |
|
|
|
List<AreaCodeDictResultDTO> cityOnceResult = new ArrayList<>(); |
|
|
|
cityResult.forEach(c -> { |
|
|
|
if (dto.getCode().equals(c.getParentCode())){ |
|
|
|
if (dto.getCode().equals(c.getParentCode())) { |
|
|
|
cityOnceResult.add(c); |
|
|
|
} |
|
|
|
}); |
|
|
@ -383,12 +378,12 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 街道-社区组织树查询 |
|
|
|
* @Description 街道-社区组织树查询 |
|
|
|
* @Param |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/11 上午9:48 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> afterTwoTree(AreaCodeDictFormDTO form){ |
|
|
|
public List<AreaCodeDictResultDTO> afterTwoTree(AreaCodeDictFormDTO form) { |
|
|
|
// 查询所有街道、社区
|
|
|
|
List<AreaCodeChildDTO> areaCodeChildDTOS = childDao.selectAllChild(form.getRootAreaCode()); |
|
|
|
List<AreaCodeDictResultDTO> fourResult = new ArrayList<>(); |
|
|
@ -399,7 +394,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
List<AreaCodeChildDTO> levelFive = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FIVE)) ? groupByLevel.get(NumConstant.FIVE) : new ArrayList<>(); |
|
|
|
Map<String, List<AreaCodeChildDTO>> groupByPCode = CollectionUtils.isEmpty(levelFive) ? new HashMap<>() : levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode)); |
|
|
|
//街道
|
|
|
|
List<AreaCodeChildDTO> levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ?groupByLevel.get(NumConstant.FOUR):new ArrayList<>(); |
|
|
|
List<AreaCodeChildDTO> levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ? groupByLevel.get(NumConstant.FOUR) : new ArrayList<>(); |
|
|
|
// 6级
|
|
|
|
List<AreaCodeChildDTO> levelSix = groupByLevel.get(NumConstant.SIX); |
|
|
|
Map<String, List<AreaCodeChildDTO>> groupBySixPCode = CollectionUtils.isEmpty(levelSix) ? new HashMap<>() : levelSix.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode)); |
|
|
@ -409,8 +404,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
dto.setCode(f.getCode()); |
|
|
|
dto.setName(f.getName()); |
|
|
|
dto.setParentCode(f.getPCode()); |
|
|
|
groupBySixPCode.forEach((k,v) -> { |
|
|
|
if (dto.getCode().equals(k)){ |
|
|
|
groupBySixPCode.forEach((k, v) -> { |
|
|
|
if (dto.getCode().equals(k)) { |
|
|
|
List<AreaCodeDictResultDTO> six = new ArrayList<>(); |
|
|
|
v.forEach(s -> { |
|
|
|
AreaCodeDictResultDTO sixDto = new AreaCodeDictResultDTO(); |
|
|
@ -431,8 +426,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
dto.setCode(four.getCode()); |
|
|
|
dto.setName(four.getName()); |
|
|
|
dto.setParentCode(four.getPCode()); |
|
|
|
groupByFivePCode.forEach((pCode,v) -> { |
|
|
|
if (dto.getCode().equals(pCode)){ |
|
|
|
groupByFivePCode.forEach((pCode, v) -> { |
|
|
|
if (dto.getCode().equals(pCode)) { |
|
|
|
dto.setChildren(v); |
|
|
|
} |
|
|
|
}); |
|
|
@ -443,28 +438,28 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 街道-社区组织树处理 |
|
|
|
* @Description 街道-社区组织树处理 |
|
|
|
* @Param form |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/11 上午9:58 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> disposeAfterTwoLevel(AreaCodeDictFormDTO form){ |
|
|
|
public List<AreaCodeDictResultDTO> disposeAfterTwoLevel(AreaCodeDictFormDTO form) { |
|
|
|
List<AreaCodeDictResultDTO> result = new ArrayList<>(); |
|
|
|
List<AreaCodeDictResultDTO> areaCodeDictResultDTOS = afterTwoTree(form); |
|
|
|
if (CollectionUtils.isEmpty(areaCodeDictResultDTOS)){ |
|
|
|
if (CollectionUtils.isEmpty(areaCodeDictResultDTOS)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.STREET)){ |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.STREET)) { |
|
|
|
for (AreaCodeDictResultDTO dto : areaCodeDictResultDTOS) { |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())) { |
|
|
|
result.add(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
for (AreaCodeDictResultDTO dto : areaCodeDictResultDTOS) { |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO child : dto.getChildren()) { |
|
|
|
if (child.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (child.getCode().equals(form.getRootAreaCode())) { |
|
|
|
result.add(child); |
|
|
|
} |
|
|
|
} |
|
|
@ -475,42 +470,42 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 省市区获取 |
|
|
|
* @Description 省市区获取 |
|
|
|
* @Param form |
|
|
|
* @Param tree |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/12 上午9:22 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevel(AreaCodeDictFormDTO form,List<AreaCodeDictResultDTO> tree){ |
|
|
|
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevel(AreaCodeDictFormDTO form, List<AreaCodeDictResultDTO> tree) { |
|
|
|
List<AreaCodeDictResultDTO> result = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isEmpty(tree)){ |
|
|
|
if (CollectionUtils.isEmpty(tree)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)){ |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)) { |
|
|
|
for (AreaCodeDictResultDTO dto : tree) { |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())) { |
|
|
|
result.add(dto); |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)){ |
|
|
|
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)) { |
|
|
|
for (AreaCodeDictResultDTO dto : tree) { |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO city : dto.getChildren()) { |
|
|
|
if (city.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (city.getCode().equals(form.getRootAreaCode())) { |
|
|
|
result.add(city); |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)){ |
|
|
|
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)) { |
|
|
|
for (AreaCodeDictResultDTO dto : tree) { |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO city : dto.getChildren()) { |
|
|
|
if (!CollectionUtils.isEmpty(city.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(city.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO child : city.getChildren()) { |
|
|
|
if (child.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (child.getCode().equals(form.getRootAreaCode())) { |
|
|
|
result.add(child); |
|
|
|
return result; |
|
|
|
} |
|
|
@ -524,29 +519,29 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 拼接 街道-社区 |
|
|
|
* @Description 拼接 街道-社区 |
|
|
|
* @Param form |
|
|
|
* @Param tree |
|
|
|
* @author zxc |
|
|
|
* @date 2021/1/12 上午9:21 |
|
|
|
*/ |
|
|
|
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form,List<AreaCodeDictResultDTO> tree){ |
|
|
|
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form, List<AreaCodeDictResultDTO> tree) { |
|
|
|
List<AreaCodeDictResultDTO> threeDto = disposeBeforeThreeLevel(form, tree); |
|
|
|
List<AreaCodeDictResultDTO> twoDto = afterTwoTree(form); |
|
|
|
if (CollectionUtils.isEmpty(threeDto)){ |
|
|
|
if (CollectionUtils.isEmpty(threeDto)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(twoDto)){ |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)){ |
|
|
|
if (!CollectionUtils.isEmpty(twoDto)) { |
|
|
|
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)) { |
|
|
|
for (AreaCodeDictResultDTO dto : tree) { |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (dto.getCode().equals(form.getRootAreaCode())) { |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO city : dto.getChildren()) { |
|
|
|
if (!CollectionUtils.isEmpty(city.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(city.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO child : city.getChildren()) { |
|
|
|
List<AreaCodeDictResultDTO> areaList = new ArrayList<>(); |
|
|
|
for (AreaCodeDictResultDTO area : twoDto) { |
|
|
|
if (child.getCode().equals(area.getParentCode())){ |
|
|
|
if (child.getCode().equals(area.getParentCode())) { |
|
|
|
areaList.add(area); |
|
|
|
} |
|
|
|
} |
|
|
@ -557,13 +552,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)){ |
|
|
|
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)) { |
|
|
|
for (AreaCodeDictResultDTO dto : threeDto) { |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())){ |
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
for (AreaCodeDictResultDTO child : dto.getChildren()) { |
|
|
|
List<AreaCodeDictResultDTO> areaList = new ArrayList<>(); |
|
|
|
for (AreaCodeDictResultDTO area : twoDto) { |
|
|
|
if (child.getCode().equals(area.getParentCode())){ |
|
|
|
if (child.getCode().equals(area.getParentCode())) { |
|
|
|
areaList.add(area); |
|
|
|
} |
|
|
|
} |
|
|
@ -571,11 +566,11 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
for (AreaCodeDictResultDTO dto : threeDto) { |
|
|
|
List<AreaCodeDictResultDTO> areaList = new ArrayList<>(); |
|
|
|
for (AreaCodeDictResultDTO area : twoDto) { |
|
|
|
if (dto.getCode().equals(area.getParentCode())){ |
|
|
|
if (dto.getCode().equals(area.getParentCode())) { |
|
|
|
areaList.add(area); |
|
|
|
} |
|
|
|
} |
|
|
@ -677,35 +672,35 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
String areaCode = ""; |
|
|
|
switch (formDTO.getCurrentAreaLevel()) { |
|
|
|
case AreaCodeConstant.DISTRICT: |
|
|
|
areaCode = addDistrictAreaCode(formDTO.getParentAreaCode(),formDTO.getName()); |
|
|
|
areaCode = addDistrictAreaCode(formDTO.getParentAreaCode(), formDTO.getName()); |
|
|
|
break; |
|
|
|
case AreaCodeConstant.STREET: |
|
|
|
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class)); |
|
|
|
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO, AddAreaCodeDictFormDTO.class)); |
|
|
|
break; |
|
|
|
case AreaCodeConstant.COMMUNITY: |
|
|
|
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class)); |
|
|
|
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO, AddAreaCodeDictFormDTO.class)); |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.info("currentAreaLevel值为"+formDTO.getCurrentAreaLevel()); |
|
|
|
log.info("currentAreaLevel值为" + formDTO.getCurrentAreaLevel()); |
|
|
|
} |
|
|
|
return areaCode; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<AreaCodeResultDTO> nextArea(AreaCodeFormDTO formDTO) { |
|
|
|
if(StringUtils.isBlank(formDTO.getParentAreaCode())&&StringUtils.isBlank(formDTO.getParentLevel())){ |
|
|
|
String pKey=RedisKeys.getNextAreaCodeKey(NumConstant.ZERO_STR); |
|
|
|
List<AreaCodeResultDTO> list=areaCodeRedis.getNextAreaCodeKey(pKey); |
|
|
|
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){ |
|
|
|
if (StringUtils.isBlank(formDTO.getParentAreaCode()) && StringUtils.isBlank(formDTO.getParentLevel())) { |
|
|
|
String pKey = RedisKeys.getNextAreaCodeKey(NumConstant.ZERO_STR); |
|
|
|
List<AreaCodeResultDTO> list = areaCodeRedis.getNextAreaCodeKey(pKey); |
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) { |
|
|
|
return list; |
|
|
|
} |
|
|
|
List<AreaCodeResultDTO> pList=baseDao.selectProvince(); |
|
|
|
areaCodeRedis.setNextAreaCodeKey(pKey,pList); |
|
|
|
List<AreaCodeResultDTO> pList = baseDao.selectProvince(); |
|
|
|
areaCodeRedis.setNextAreaCodeKey(pKey, pList); |
|
|
|
return pList; |
|
|
|
} |
|
|
|
String key=RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode()); |
|
|
|
List<AreaCodeResultDTO> list=areaCodeRedis.getNextAreaCodeKey(key); |
|
|
|
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){ |
|
|
|
String key = RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode()); |
|
|
|
List<AreaCodeResultDTO> list = areaCodeRedis.getNextAreaCodeKey(key); |
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) { |
|
|
|
return list; |
|
|
|
} |
|
|
|
switch (formDTO.getParentLevel()) { |
|
|
@ -723,17 +718,59 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
break; |
|
|
|
case AreaCodeConstant.COMMUNITY: |
|
|
|
log.info("社区无下级"); |
|
|
|
list=null; |
|
|
|
list = null; |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.warn("parentLevel错误:"+formDTO.getParentLevel()); |
|
|
|
log.warn("parentLevel错误:" + formDTO.getParentLevel()); |
|
|
|
} |
|
|
|
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){ |
|
|
|
areaCodeRedis.setNextAreaCodeKey(key,list); |
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) { |
|
|
|
areaCodeRedis.setNextAreaCodeKey(key, list); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public AreaCodeResultDTO getAreaCodeDetail(AreaCodeDetailFormDTO formDTO) { |
|
|
|
AreaCodeResultDTO result = new AreaCodeResultDTO(); |
|
|
|
switch (formDTO.getLevel()) { |
|
|
|
case AreaCodeConstant.PROVINCE: |
|
|
|
AreaCodeDTO province = baseDao.selectByProvinceCode(formDTO.getAreaCode()); |
|
|
|
if (province != null) { |
|
|
|
result.setAreaName(province.getProvinceName()); |
|
|
|
result.setAreaCode(province.getProvinceCode()); |
|
|
|
result.setParentCode(NumConstant.ZERO_STR); |
|
|
|
result.setLevel(AreaCodeConstant.PROVINCE); |
|
|
|
} |
|
|
|
break; |
|
|
|
case AreaCodeConstant.CITY: |
|
|
|
AreaCodeDTO city = baseDao.selectByCityCode(formDTO.getAreaCode()); |
|
|
|
if (city != null) { |
|
|
|
result.setAreaName(city.getCityName()); |
|
|
|
result.setAreaCode(city.getCityName()); |
|
|
|
result.setParentCode(city.getProvinceCode()); |
|
|
|
result.setLevel(AreaCodeConstant.CITY); |
|
|
|
} |
|
|
|
break; |
|
|
|
case AreaCodeConstant.DISTRICT: |
|
|
|
AreaCodeDTO county = baseDao.selectByCountyCode(formDTO.getAreaCode()); |
|
|
|
if (county != null) { |
|
|
|
result.setAreaName(county.getCountyName()); |
|
|
|
result.setAreaCode(county.getCountyCode()); |
|
|
|
result.setParentCode(county.getCityCode()); |
|
|
|
result.setLevel(AreaCodeConstant.DISTRICT); |
|
|
|
} |
|
|
|
break; |
|
|
|
case AreaCodeConstant.STREET: |
|
|
|
result = baseDao.selectByStreetCode(formDTO.getAreaCode()); |
|
|
|
break; |
|
|
|
case AreaCodeConstant.COMMUNITY: |
|
|
|
result = baseDao.selectByCommunityCode(formDTO.getAreaCode()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.warn("Level错误:" + formDTO.getLevel()); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private String addDistrictAreaCode(String cityCode, String countyName) { |
|
|
|
AreaCodeDTO city = baseDao.selectByCityCode(cityCode); |
|
|
|