|
@@ -1,13 +1,18 @@
|
|
|
package com.benyun.core.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.benyun.core.dao.AddrCategoryDao;
|
|
|
+import com.benyun.core.dao.CategoryMapper;
|
|
|
import com.benyun.core.dao.TypeByDao;
|
|
|
import com.benyun.core.dao.WdInfoMapper;
|
|
|
+import com.benyun.core.entity.AddrCategory;
|
|
|
+import com.benyun.core.entity.Category;
|
|
|
import com.benyun.core.entity.TypeBy;
|
|
|
import com.benyun.core.entity.WdInfo;
|
|
|
import com.benyun.core.entity.bo.WdAddrTypeDistribution;
|
|
|
import com.benyun.core.entity.vo.TypeByBody;
|
|
|
import com.benyun.core.entity.vo.WdInfoVo;
|
|
|
+import com.benyun.core.service.CategoryService;
|
|
|
import com.benyun.core.service.WdInfoService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -16,35 +21,158 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class WdInfoServiceImpl implements WdInfoService {
|
|
|
+ public Map<String,String> typeMap;
|
|
|
+ public Map<String,String> addrMap;
|
|
|
+ public Map<String,String> wdTypeMap;
|
|
|
@Autowired
|
|
|
WdInfoMapper wdInfoMapper;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
TypeByDao byDao;
|
|
|
+ @Autowired
|
|
|
+ AddrCategoryDao addrCategoryDao;
|
|
|
|
|
|
+ public void setTypeMap(){
|
|
|
+ if (typeMap == null){
|
|
|
+ typeMap = new HashMap<>();
|
|
|
+ QueryWrapper<TypeBy> queryWrapper = new QueryWrapper<>();
|
|
|
+ List<TypeBy> typeByList = byDao.selectList(queryWrapper);
|
|
|
+ for (TypeBy by : typeByList){
|
|
|
+ if (!by.getSubCategory().equals(""))
|
|
|
+ typeMap.put(by.getTypeCodeBy(),by.getSubCategory());
|
|
|
+ else if (!by.getMidCategory().equals(""))
|
|
|
+ typeMap.put(by.getTypeCodeBy(),by.getMidCategory());
|
|
|
+ else
|
|
|
+ typeMap.put(by.getTypeCodeBy(),by.getBigCategory());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void setAddrMap(){
|
|
|
+ if (addrMap == null){
|
|
|
+ addrMap = new HashMap<>();
|
|
|
+ QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
+ List<AddrCategory> addrCategories = addrCategoryDao.selectList(queryWrapper);
|
|
|
+ for (AddrCategory addr : addrCategories){
|
|
|
+ if (!addr.getDistrict().equals(""))
|
|
|
+ addrMap.put(addr.getAddrCode(),addr.getDistrict());
|
|
|
+ else if (!addr.getCity().equals(""))
|
|
|
+ addrMap.put(addr.getAddrCode(),addr.getCity());
|
|
|
+ else
|
|
|
+ addrMap.put(addr.getAddrCode(),addr.getProvince());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void setWdTypeMap(){
|
|
|
+ if (wdTypeMap == null){
|
|
|
+ wdTypeMap = new HashMap<>();
|
|
|
+ wdTypeMap.put("0","基础设施网点");
|
|
|
+ wdTypeMap.put("1","门店网点");
|
|
|
+ wdTypeMap.put("2","小区网点");
|
|
|
+ wdTypeMap.put("3","楼宇网点");
|
|
|
+ wdTypeMap.put("4","交通设施网点");
|
|
|
+ wdTypeMap.put("5","公司网点");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<String> getAllOtherAddrCode(String addrCode){
|
|
|
+ List<String> addrCodes = new ArrayList<>();
|
|
|
+ byte[] bytes = addrCode.getBytes(StandardCharsets.UTF_8);
|
|
|
+ String big = String.valueOf(bytes[0]) + String.valueOf(bytes[1]);
|
|
|
+ String mid = String.valueOf(bytes[2]) + String.valueOf(bytes[3]);
|
|
|
+ String sub = String.valueOf(bytes[4]) + String.valueOf(bytes[5]);
|
|
|
+ if (sub.equals("00")){
|
|
|
+ QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (mid.equals("00")){
|
|
|
+ queryWrapper.likeRight("addr_code",big).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("city","");
|
|
|
+ }).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("district","");
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ queryWrapper.likeRight("addr_code",big+mid).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("city","");
|
|
|
+ }).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("district","");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ List<AddrCategory> provinces = addrCategoryDao.selectList(queryWrapper);
|
|
|
+ addrCodes.add(provinces.listIterator().next().getAddrCode());
|
|
|
+ }else
|
|
|
+ addrCodes.add(addrCode);
|
|
|
+ return addrCodes;
|
|
|
+ }
|
|
|
+ private List<String> getAllOtherTypeBy(String typeCode){
|
|
|
+ List<String> types = new ArrayList<>();
|
|
|
+ byte[] bytes = typeCode.getBytes(StandardCharsets.UTF_8);
|
|
|
+ String big = String.valueOf(bytes[0]) + String.valueOf(bytes[1]);
|
|
|
+ String mid = String.valueOf(bytes[2]) + String.valueOf(bytes[3]);
|
|
|
+ String sub = String.valueOf(bytes[4]) + String.valueOf(bytes[5]);
|
|
|
+ if (sub.equals("00")){
|
|
|
+ QueryWrapper<TypeBy> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (mid.equals("00")){
|
|
|
+ queryWrapper.likeRight("type_code_by",big).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("mid_category","");
|
|
|
+ }).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("sub_category","");
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ queryWrapper.likeRight("addr_code",big+mid).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("mid_category","");
|
|
|
+ }).and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("sub_category","");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ List<TypeBy> typeByList = byDao.selectList(queryWrapper);
|
|
|
+ types.add(typeByList.listIterator().next().getTypeCodeBy());
|
|
|
+ }else
|
|
|
+ types.add(typeCode);
|
|
|
+ return types;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
|
|
|
- return wdInfoMapper.searchAddrDisByMulti(addrCodes, typeCodes);
|
|
|
+ List<String> acodes = new ArrayList<>();
|
|
|
+ for (String s : addrCodes){
|
|
|
+ List<String> allOtherAddrCode = getAllOtherAddrCode(s);
|
|
|
+ acodes.addAll(allOtherAddrCode);
|
|
|
+ }
|
|
|
+ List<WdAddrTypeDistribution> list = wdInfoMapper.searchAddrDisByMulti(acodes, typeCodes);
|
|
|
+ setTypeMap();
|
|
|
+ setAddrMap();
|
|
|
+ for (WdAddrTypeDistribution wd : list){
|
|
|
+ wd.setTypeName(typeMap.get(wd.getTypeCode()));
|
|
|
+ wd.setAddrName(addrMap.get(wd.getAddrCode()));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<WdAddrTypeDistribution> searchWdTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
|
|
|
- return wdInfoMapper.searchWdTypeDisByMulti(addrCodes,typeCodes);
|
|
|
+ List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTypeDisByMulti(addrCodes, typeCodes);
|
|
|
+ setAddrMap();
|
|
|
+ setWdTypeMap();
|
|
|
+ for (WdAddrTypeDistribution wd : list){
|
|
|
+ wd.setAddrName(addrMap.get(wd.getAddrCode()));
|
|
|
+ wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<WdAddrTypeDistribution> searchWdTotal() {
|
|
|
- return wdInfoMapper.searchWdTotal();
|
|
|
+ List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTotal();
|
|
|
+ setWdTypeMap();
|
|
|
+ for (WdAddrTypeDistribution wd : list){
|
|
|
+ wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
}
|