|
|
|
@@ -89,7 +89,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
} |
|
|
|
List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); |
|
|
|
LambdaQueryWrapper<InvestCustomerEntity> queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); |
|
|
|
queryWrapperCustomer.like(StringUtils.isNotBlank(params.getCustomerNo()), InvestCustomerEntity::getCustomerNo, params.getCustomerNo()); |
|
|
|
queryWrapperCustomer.like(StringUtils.isNotBlank(params.getPhone()), InvestCustomerEntity::getPhone, params.getPhone()); |
|
|
|
|
|
|
|
if (Objects.isNull(InvestUserContext.getDataUser())) { |
|
|
|
if (CollectionUtils.isEmpty(demandList) && Objects.nonNull(params.getDemandOwner())) { |
|
|
|
@@ -226,10 +226,44 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
doImport(lFile, tenantId, importKey); |
|
|
|
doImport(lFile, importKey); |
|
|
|
} |
|
|
|
|
|
|
|
private void doImport(File file, String tenantId, String importKey) { |
|
|
|
@Override |
|
|
|
public Map queryCustomerImportCount() { |
|
|
|
String importKey = Constant.importInvestCustomerPrev + InvestUserContext.getUserId(); |
|
|
|
Map<Object, Object> entries = stringRedisTemplate.opsForHash().entries(importKey); |
|
|
|
log.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); |
|
|
|
if (entries.size() < 4) { |
|
|
|
entries.clear(); |
|
|
|
return entries; |
|
|
|
} |
|
|
|
String allCount = entries.get("allCount").toString(); |
|
|
|
String allSuccessCount = entries.get("allSuccessCount").toString(); |
|
|
|
String processCount = entries.get("processCount").toString(); |
|
|
|
String failCount = entries.get("failCount").toString(); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); |
|
|
|
log.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2"); |
|
|
|
//完全失败 |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "allCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "processCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "failCount"); |
|
|
|
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR); |
|
|
|
} |
|
|
|
//导入完成 |
|
|
|
if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) { |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "allCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "processCount"); |
|
|
|
stringRedisTemplate.opsForHash().delete(importKey, "failCount"); |
|
|
|
return entries; |
|
|
|
} |
|
|
|
return entries; |
|
|
|
} |
|
|
|
|
|
|
|
private void doImport(File file, String importKey) { |
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
// 需要验证 |
|
|
|
params.setImportFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*", "意向租凭面积", "预计开业时间"}); |
|
|
|
@@ -334,7 +368,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
log.error("经营业态为空", customer.toString()); |
|
|
|
return; |
|
|
|
} |
|
|
|
InvestDemandDto toImportCustomer = convetCustomer(customer, brandMap, businesseMap, shopMap, customerMap.get(customer.getPhone()), demandMap); |
|
|
|
InvestDemandDto toImportCustomer = convetCustomer(importKey, customer, brandMap, businesseMap, shopMap, customerMap.get(customer.getPhone()), demandMap); |
|
|
|
if (toImportCustomer == null) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
log.error("customerBase null"); |
|
|
|
@@ -351,8 +385,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
setRedisValue(importKey, "1", "0", "0", "1", true); |
|
|
|
log.error("导入模板失败", e); |
|
|
|
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "导入模板失败"); |
|
|
|
} finally { |
|
|
|
stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -366,7 +398,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return getMap(brands, WxBrand::getName); |
|
|
|
} |
|
|
|
|
|
|
|
private InvestDemandDto convetCustomer(InvestCustomerVo importCustomerVo, Map<String, WxBrand> brandMap, Map<String, WxBusiness> businesseMap, Map<String, WxShop> shopMap, InvestCustomerEntity dbCustomer, Map<Long, InvestDemandEntity> demandMap) { |
|
|
|
private InvestDemandDto convetCustomer(String importKey, InvestCustomerVo importCustomerVo, Map<String, WxBrand> brandMap, Map<String, WxBusiness> businesseMap, Map<String, WxShop> shopMap, InvestCustomerEntity dbCustomer, Map<Long, InvestDemandEntity> demandMap) { |
|
|
|
InvestCustomerEntity customerEntity = null; |
|
|
|
InvestDemandEntity demandEntity = null; |
|
|
|
if (Objects.isNull(dbCustomer)) { |
|
|
|
@@ -379,16 +411,19 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
demandEntity = new InvestDemandEntity(); |
|
|
|
} |
|
|
|
if (Objects.isNull(brandMap.get(importCustomerVo.getBrandName()))) { |
|
|
|
log.warn("品牌:{} 不存在", importCustomerVo.getBrandName()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
customerEntity.setBrandId(brandMap.get(importCustomerVo.getBrandName()).getId()); |
|
|
|
|
|
|
|
if (Objects.isNull(businesseMap.get(importCustomerVo.getBusiness()))) { |
|
|
|
log.warn("业态:{} 不存在", importCustomerVo.getBusiness()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
customerEntity.setBusinessId(businesseMap.get(importCustomerVo.getBusiness()).getId()); |
|
|
|
|
|
|
|
if (Objects.isNull(shopMap.get(importCustomerVo.getShopNumber()))) { |
|
|
|
log.warn("意向铺位:{} 不存在", importCustomerVo.getShopNumber()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
customerEntity.setName(importCustomerVo.getName()); |
|
|
|
|