数据处理代码
This commit is contained in:
@@ -65,4 +65,13 @@ public class BigRegionDAO {
|
||||
return bigRegionMapper.queryBigRegion(queryBigRegionRequest);
|
||||
}
|
||||
|
||||
public BigRegionDO getByRegionId(Long regionId){
|
||||
if (regionId==null){
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||
}
|
||||
Example example = new Example(BigRegionDO.class);
|
||||
example.createCriteria().andEqualTo("regionId", regionId).andEqualTo("joinMode",0);
|
||||
return bigRegionMapper.selectOneByExample(example);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
@@ -201,4 +202,12 @@ public class RegionDao {
|
||||
}
|
||||
return regionMapper.getRegionByNameListAndIsPath(name);
|
||||
}
|
||||
|
||||
|
||||
public List<RegionDO> getSubRegionByParentIdsAndRegionType (List<Long> parentIdList, String regionType){
|
||||
if (CollectionUtils.isEmpty(parentIdList)|| StringUtils.isBlank(regionType)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return regionMapper.getSubRegionByParentIdsAndRegionType(parentIdList, regionType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,4 +115,7 @@ public interface RegionMapper {
|
||||
List<RegionResponse> getSubRegionByParentIdAndRegionType( @Param("regionId")Long regionId, @Param("regionType")String regionType);
|
||||
|
||||
List<RegionDO> getRegionByNameListAndIsPath(@Param("regionNameList") List<String> regionNameList);
|
||||
|
||||
|
||||
List<RegionDO> getSubRegionByParentIdsAndRegionType( @Param("parentIds")List<Long> parentIds, @Param("regionType")String regionType);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
|
||||
<result column="store_manage_region_id" jdbcType="BIGINT" property="storeManageRegionId" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
@@ -439,6 +439,15 @@
|
||||
</if>
|
||||
and region_type = 'path'
|
||||
</select>
|
||||
<select id="getSubRegionByParentIdsAndRegionType" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
<include refid="fields"></include>
|
||||
from region_${enterpriseId}
|
||||
where deleted = 0
|
||||
and parent_id in
|
||||
<foreach collection="parentIds" open="(" close=")" separator="," item="region">#{region}</foreach>
|
||||
and region_type = #{regionType}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -14,4 +14,6 @@ public class BigRegionDTO {
|
||||
|
||||
private String regionName;
|
||||
|
||||
private String groupName;
|
||||
private Long storeManageRegionId;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,17 @@ public class BigRegionDO {
|
||||
//集团名称
|
||||
@Column(name = "group_name")
|
||||
private String groupName;
|
||||
//区域对应的管理区域
|
||||
@Column(name = "store_manage_region_id")
|
||||
private Long storeManageRegionId;
|
||||
|
||||
public Long getStoreManageRegionId() {
|
||||
return storeManageRegionId;
|
||||
}
|
||||
|
||||
public void setStoreManageRegionId(Long storeManageRegionId) {
|
||||
this.storeManageRegionId = storeManageRegionId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RegionController {
|
||||
return ResponseResult.success(regionService.getBelongWarRegionName(regionId));
|
||||
}
|
||||
|
||||
@ApiOperation("获取下级区域")
|
||||
@ApiOperation("获取管理下级区域")
|
||||
@GetMapping("/getSubRegionByParentId")
|
||||
public ResponseResult<List<RegionResponse>> getSubRegionByParentId(@RequestParam(value = "regionId", required = true) Long regionId) {
|
||||
return ResponseResult.success(regionService.getSubRegionByParentId(regionId));
|
||||
|
||||
Reference in New Issue
Block a user