数据处理代码
This commit is contained in:
@@ -44,7 +44,7 @@ public interface RegionService {
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/7/11
|
||||
* @description:获取某区域下的所有子区域
|
||||
* @description:获取管理区域下的所有子区域(门店-大区,加盟分部)
|
||||
*/
|
||||
List<RegionResponse> getSubRegionByParentId(Long regionId);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.*;
|
||||
import com.cool.store.dto.region.BigRegionDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.enums.point.PayBusinessTypeEnum;
|
||||
@@ -15,6 +16,7 @@ import com.cool.store.enums.point.ShopSubStageEnum;
|
||||
import com.cool.store.enums.point.ShopSubStageStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.*;
|
||||
import com.cool.store.request.QueryBigRegionRequest;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.easyExcel.EasyExcelUtil;
|
||||
@@ -47,6 +49,10 @@ import static com.cool.store.utils.poi.DateUtils.YYYY_MM_DD;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DataHandlerServerImpl implements DataHandlerServer {
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
@Resource
|
||||
private RegionDao regionDao;
|
||||
@Resource
|
||||
@@ -1159,46 +1165,52 @@ public class DataHandlerServerImpl implements DataHandlerServer {
|
||||
shopInfoDO.setManagerRegionId(isCreateStoreDTO.getPid());
|
||||
updateList.add(shopInfoDO);
|
||||
}
|
||||
List<BigRegionDTO> bigRegionDTOS = bigRegionDAO.queryBigRegion(new QueryBigRegionRequest());
|
||||
Map<Long, BigRegionDTO> bigRegionDTOMap = bigRegionDTOS.stream().collect(Collectors.toMap(BigRegionDTO::getRegionId, x -> x));
|
||||
//XX大区
|
||||
List<Long> storeManageIds = bigRegionDTOS.stream().filter(x -> x.getStoreManageRegionId() != null).map(BigRegionDTO::getStoreManageRegionId).collect(Collectors.toList());
|
||||
//加盟分部
|
||||
List<Long> branchStoreManageIds = bigRegionDTOS.stream().filter(x -> x.getStoreManageRegionId() == null).map(BigRegionDTO::getRegionId).collect(Collectors.toList());
|
||||
|
||||
//查询门店-XX大区下面的管理督导
|
||||
List<RegionDO> manageRegionList = regionDao.getSubRegionByParentIdsAndRegionType(storeManageIds, "path");
|
||||
Map<String, RegionDO> manageRegionMap = manageRegionList.stream().collect(Collectors.toMap(regionDO -> regionDO.getName(), Function.identity()));
|
||||
//查询加盟分部下的管理督导
|
||||
List<RegionDO> branchStoreManageList = regionDao.getSubRegionByParentIdsAndRegionType(branchStoreManageIds, "path");
|
||||
Map<String, RegionDO> branchStoreManageMap = manageRegionList.stream().collect(Collectors.toMap(regionDO -> regionDO.getName(), Function.identity()));
|
||||
|
||||
List<Long> isShopIds = isCreateStore.stream().map(IsCreateStoreDTO::getShopId).collect(Collectors.toList());
|
||||
//未建店
|
||||
List<ShopInfoDO> shopInfoDOS = shopInfoDAO.selectByNotCreateStore(isShopIds);
|
||||
Set<String> investUserIds = shopInfoDOS.stream().map(ShopInfoDO::getInvestmentManager).collect(Collectors.toSet());
|
||||
Map<String, String> userNameMap = enterpriseUserDAO.getUserNameMap(new ArrayList<>(investUserIds));
|
||||
Set<String> nameSet = userNameMap.keySet();
|
||||
|
||||
List<RegionDO> regionDOList = regionDao.getRegionByNameListAndIsPath(new ArrayList<>(nameSet));
|
||||
Set<Long> parentIdSet = new HashSet<>();
|
||||
regionDOList.forEach(regionDO -> parentIdSet.add(Long.valueOf(regionDO.getParentId())));
|
||||
Map<Long, String> parentRegionNameMap = regionDao.getRegionNameMap(new ArrayList<>(parentIdSet));
|
||||
|
||||
|
||||
Map<Long, String> shopRegionNameMap = regionDao.getRegionNameMap(new ArrayList<>(shopInfoDOS.stream().map(ShopInfoDO::getRegionId).collect(Collectors.toSet())));
|
||||
List<ImportOaOldShopDataErrorDTO> errorList = new ArrayList<>();
|
||||
Map<String, List<RegionDO>> regionName = regionDOList.stream().collect(Collectors.groupingBy(RegionDO::getName));
|
||||
|
||||
for (ShopInfoDO shopInfoDO : shopInfoDOS){
|
||||
String name = userNameMap.getOrDefault(shopInfoDO.getInvestmentManager(),"");
|
||||
if (StringUtils.isBlank(name)){
|
||||
log.info("门店招商经理未找到 shopId:{}",shopInfoDO.getId());
|
||||
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店招商经理未找到");
|
||||
errorList.add(errorDTO);
|
||||
continue;
|
||||
}
|
||||
List<RegionDO> regionList = regionName.getOrDefault(name, new ArrayList<>());
|
||||
if (CollectionUtils.isEmpty(regionList)){
|
||||
BigRegionDTO bigRegionDTO = bigRegionDTOMap.get(shopInfoDO.getId());
|
||||
RegionDO regionDO;
|
||||
if (bigRegionDTO.getStoreManageRegionId()==null){
|
||||
regionDO = manageRegionMap.get(name);
|
||||
}else{
|
||||
regionDO= branchStoreManageMap.get(name);
|
||||
}
|
||||
if (Objects.isNull(regionDO)){
|
||||
log.info("门店所属管理区域未找到 shopId:{}",shopInfoDO.getId());
|
||||
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店所属管理区域未找到");
|
||||
errorList.add(errorDTO);
|
||||
continue;
|
||||
}
|
||||
for (RegionDO regionDO : regionList){
|
||||
String parentRegionNameMapOrDefault = parentRegionNameMap.getOrDefault(Long.valueOf(regionDO.getParentId()), "");
|
||||
String shopRegionName = shopRegionNameMap.getOrDefault(regionDO.getId(), "");
|
||||
if (StringUtils.isNotBlank(parentRegionNameMapOrDefault)&&StringUtils.isNotBlank(shopRegionName)
|
||||
&&(parentRegionNameMapOrDefault.equals("门店"+shopRegionName)||parentRegionNameMapOrDefault.equals(shopRegionName))){
|
||||
shopInfoDO.setManagerRegionId(regionDO.getId());
|
||||
updateList.add(shopInfoDO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
shopInfoDO.setManagerRegionId(regionDO.getId());
|
||||
updateList.add(shopInfoDO);
|
||||
}
|
||||
shopInfoDAO.updateManagerRegionId(updateList);
|
||||
if (CollectionUtils.isNotEmpty(errorList)) {
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.cool.store.service.impl;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.BigRegionDAO;
|
||||
import com.cool.store.dao.RegionAreaConfigDao;
|
||||
import com.cool.store.dao.RegionDao;
|
||||
import com.cool.store.entity.BigRegionDO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.ThirdRegionTypeEnum;
|
||||
@@ -49,6 +51,8 @@ public class RegionServiceImpl implements RegionService {
|
||||
@Resource
|
||||
private RegionAreaConfigDao regionAreaConfigDao;
|
||||
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
|
||||
@Override
|
||||
public RegionPathNameVO getAllRegionName(Long regionId) {
|
||||
@@ -165,6 +169,11 @@ public class RegionServiceImpl implements RegionService {
|
||||
if (Objects.isNull(regionId)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
BigRegionDO byRegionId = bigRegionDAO.getByRegionId(regionId);
|
||||
if (byRegionId.getRegionName().endsWith("大区")){
|
||||
//找门店-XX大区
|
||||
regionId = byRegionId.getStoreManageRegionId() ;
|
||||
}
|
||||
return regionMapper.getSubRegionByParentIdAndRegionType(regionId,"path");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import static com.cool.store.enums.ExtendFieldTypeEnum.*;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String active;
|
||||
@Resource
|
||||
@@ -85,7 +87,17 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
requestBody.setLocation_address(shopInfo.getDetailAddress());
|
||||
requestBody.setStore_address(shopInfo.getDetailAddress());
|
||||
//todo 等待王硕确认
|
||||
requestBody.setStore_area(shopInfo.getManagerRegionId().toString());
|
||||
if (shopInfo.getManagerRegionId() == null) {
|
||||
BigRegionDO byRegionId = bigRegionDAO.getByRegionId(shopInfo.getRegionId());
|
||||
if (byRegionId != null){
|
||||
requestBody.setStore_area(byRegionId.getStoreManageRegionId() == null
|
||||
? shopInfo.getRegionId().toString() : shopInfo.getManagerRegionId().toString());
|
||||
}else{
|
||||
requestBody.setStore_area(shopInfo.getRegionId().toString());
|
||||
}
|
||||
} else {
|
||||
requestBody.setStore_area(shopInfo.getManagerRegionId().toString());
|
||||
}
|
||||
//未开业
|
||||
requestBody.setStore_status("not_open");
|
||||
requestBody.setStore_acreage(pointInfoDO.getPointArea());
|
||||
@@ -106,7 +118,7 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
}
|
||||
Map<String, ExtendFieldTypeEnum> configMapByActive = ExtendFieldTypeEnum.getConfigMapByActive(active);
|
||||
Map<String, String> extendField = new HashMap<>();
|
||||
extendField.put(configMapByActive.get(ONLINE_STORE_MANAGER_MOBILE.getMsg()).getKey(),"");
|
||||
extendField.put(configMapByActive.get(ONLINE_STORE_MANAGER_MOBILE.getMsg()).getKey(), "");
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_1.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatoryFirst());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_MOBILE_1.getMsg()).getKey(), lineInfoDO.getMobile());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_2.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatorySecond());
|
||||
|
||||
Reference in New Issue
Block a user