|
@@ -10,6 +10,7 @@ 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.AddStatusVo;
|
|
|
import com.benyun.core.entity.vo.TypeByBody;
|
|
|
import com.benyun.core.entity.vo.WdInfoVo;
|
|
|
import com.benyun.core.service.CategoryService;
|
|
@@ -22,6 +23,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -31,7 +34,11 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class WdInfoServiceImpl implements WdInfoService {
|
|
|
public Map<String,String> typeMap;
|
|
|
+ public Map<String,List<String>> typeChildren = new HashMap<>();
|
|
|
+
|
|
|
public Map<String,String> addrMap;
|
|
|
+ public Map<String,List<String>> addrChildren = new HashMap<>();
|
|
|
+
|
|
|
public Map<String,String> wdTypeMap;
|
|
|
@Autowired
|
|
|
WdInfoMapper wdInfoMapper;
|
|
@@ -81,12 +88,15 @@ public class WdInfoServiceImpl implements WdInfoService {
|
|
|
wdTypeMap.put("5","公司网点");
|
|
|
}
|
|
|
}
|
|
|
- private List<String> getAllOtherAddrCode(String addrCode){
|
|
|
+ public List<String> getAllOtherAddrCode(String addrCode){
|
|
|
+ if (addrChildren.get(addrCode) != null){
|
|
|
+// System.out.println("quickly");
|
|
|
+ return addrChildren.get(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]);
|
|
|
+ String big = String.valueOf(addrCode.charAt(0))+String.valueOf(addrCode.charAt(1));
|
|
|
+ String mid = String.valueOf(addrCode.charAt(2))+String.valueOf(addrCode.charAt(3));
|
|
|
+ String sub = String.valueOf(addrCode.charAt(4))+String.valueOf(addrCode.charAt(5));
|
|
|
if (sub.equals("00")){
|
|
|
QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
if (mid.equals("00")){
|
|
@@ -102,18 +112,24 @@ public class WdInfoServiceImpl implements WdInfoService {
|
|
|
addrCategoryQueryWrapper.ne("district","");
|
|
|
});
|
|
|
}
|
|
|
- List<AddrCategory> provinces = addrCategoryDao.selectList(queryWrapper);
|
|
|
- addrCodes.add(provinces.listIterator().next().getAddrCode());
|
|
|
+ List<AddrCategory> zones = addrCategoryDao.selectList(queryWrapper);
|
|
|
+ for (AddrCategory zone : zones){
|
|
|
+ addrCodes.add(zone.getAddrCode());
|
|
|
+ }
|
|
|
+ addrChildren.put(addrCode,addrCodes);
|
|
|
}else
|
|
|
addrCodes.add(addrCode);
|
|
|
return addrCodes;
|
|
|
}
|
|
|
- private List<String> getAllOtherTypeBy(String typeCode){
|
|
|
+ public List<String> getAllOtherTypeBy(String typeCode){
|
|
|
+ if (typeChildren.get(typeCode) != null){
|
|
|
+// System.out.println("quickly");
|
|
|
+ return typeChildren.get(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]);
|
|
|
+ String big = String.valueOf(typeCode.charAt(0)) + String.valueOf(typeCode.charAt(1));
|
|
|
+ String mid = String.valueOf(typeCode.charAt(2)) + String.valueOf(typeCode.charAt(3));
|
|
|
+ String sub = String.valueOf(typeCode.charAt(4)) + String.valueOf(typeCode.charAt(5));
|
|
|
if (sub.equals("00")){
|
|
|
QueryWrapper<TypeBy> queryWrapper = new QueryWrapper<>();
|
|
|
if (mid.equals("00")){
|
|
@@ -123,56 +139,82 @@ public class WdInfoServiceImpl implements WdInfoService {
|
|
|
addrCategoryQueryWrapper.ne("sub_category","");
|
|
|
});
|
|
|
}else{
|
|
|
- queryWrapper.likeRight("addr_code",big+mid).and(addrCategoryQueryWrapper -> {
|
|
|
+ queryWrapper.likeRight("type_code_by",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());
|
|
|
+ for (TypeBy typeBy : typeByList){
|
|
|
+ types.add(typeBy.getTypeCodeBy());
|
|
|
+ }
|
|
|
+ typeChildren.put(typeCode,types);
|
|
|
}else
|
|
|
types.add(typeCode);
|
|
|
return types;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
|
|
|
- List<String> acodes = new ArrayList<>();
|
|
|
- for (String s : addrCodes){
|
|
|
- List<String> allOtherAddrCode = getAllOtherAddrCode(s);
|
|
|
- acodes.addAll(allOtherAddrCode);
|
|
|
+ public List<AddStatusVo> searchAddStatus(List<String> addrCodes, List<String> typeCodes) {
|
|
|
+ setWdTypeMap();
|
|
|
+ List<String> addrs = new ArrayList<>();
|
|
|
+ List<String> times = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 12; i++){
|
|
|
+ times.add(LocalDateTime.now().plusMonths(-i).format(DateTimeFormatter.ofPattern("yyyy-MM")));
|
|
|
}
|
|
|
- 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()));
|
|
|
+ if (addrCodes != null){
|
|
|
+ for (String s : addrCodes){
|
|
|
+ List<String> allOtherAddrCode = getAllOtherAddrCode(s);
|
|
|
+ addrs.addAll(allOtherAddrCode);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ addrs = null;
|
|
|
}
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<WdAddrTypeDistribution> searchWdTypeDistribution(List<String> addrCodes, List<String> 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()));
|
|
|
+ List<AddStatusVo> addStatusVos = wdInfoMapper.searchAddStatusByMulti(times, addrs, typeCodes);
|
|
|
+ for (AddStatusVo vo : addStatusVos){
|
|
|
+ vo.setTypeName(wdTypeMap.get(vo.getTypeCode()));
|
|
|
}
|
|
|
- return list;
|
|
|
+ return addStatusVos;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<WdAddrTypeDistribution> searchWdTotal() {
|
|
|
- List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTotal();
|
|
|
- setWdTypeMap();
|
|
|
- for (WdAddrTypeDistribution wd : list){
|
|
|
- wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> 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) {
|
|
|
+// 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() {
|
|
|
+// List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTotal();
|
|
|
+// setWdTypeMap();
|
|
|
+// for (WdAddrTypeDistribution wd : list){
|
|
|
+// wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
|
|
|
+// }
|
|
|
+// return list;
|
|
|
+// }
|
|
|
|
|
|
}
|