Browse Source

[招商][客户信息]导入

release_toaliyun_real
Burce 6 years ago
parent
commit
6804c49308
5 changed files with 58 additions and 14 deletions
  1. +7
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java
  2. +3
    -3
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java
  4. +42
    -7
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java
  5. +4
    -3
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java

+ 7
- 1
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java View File

@@ -95,7 +95,7 @@ public class InvestCustomerController extends InvestBaseController{


@ApiOperation("导出客户信息模板") @ApiOperation("导出客户信息模板")
@GetMapping("/exportCustomerTemplate") @GetMapping("/exportCustomerTemplate")
@SystemControllerLog(description = "招商管理-导出客户信息模板")
@SystemControllerLog(description = "导出客户信息模板")
public void exportCustomerTemplate(HttpServletResponse response) { public void exportCustomerTemplate(HttpServletResponse response) {
exportData(null, response, (p, u) -> investBizService.exportCustomerTemplate(u)); exportData(null, response, (p, u) -> investBizService.exportCustomerTemplate(u));
} }
@@ -107,4 +107,10 @@ public class InvestCustomerController extends InvestBaseController{
return importData(file, p -> investBizService.importCustomer(p)); return importData(file, p -> investBizService.importCustomer(p));
} }


@GetMapping("/queryTemplateCount")
@SystemControllerLog(description = "查询导入数据")
public InvestResultData queryTemplateCount() {
return execute(null, p -> investBizService.queryCustomerImportCount());
}

} }

+ 3
- 3
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java View File

@@ -9,10 +9,10 @@ import lombok.EqualsAndHashCode;
public class InvestDemandQuery extends InvestPageQuery { public class InvestDemandQuery extends InvestPageQuery {


/** /**
* 客户
* 客户手机
*/ */
@io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerNo")
private String customerNo;
@io.swagger.annotations.ApiModelProperty(value = "客户手机号", name = "phone")
private String phone;


/** /**
* 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败 * 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败


+ 2
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java View File

@@ -23,6 +23,8 @@ public interface InvestBizService {


void importCustomer(@RequestParam("file") MultipartFile mFile); void importCustomer(@RequestParam("file") MultipartFile mFile);


Map queryCustomerImportCount() ;

List<InvestDemandVo> queryCustomer(); List<InvestDemandVo> queryCustomer();


InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params); InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params);


+ 42
- 7
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java View File

@@ -89,7 +89,7 @@ public class InvestBizServiceImpl implements InvestBizService {
} }
List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams));
LambdaQueryWrapper<InvestCustomerEntity> queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); 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 (Objects.isNull(InvestUserContext.getDataUser())) {
if (CollectionUtils.isEmpty(demandList) && Objects.nonNull(params.getDemandOwner())) { 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(); ImportParams params = new ImportParams();
// 需要验证 // 需要验证
params.setImportFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*", "意向租凭面积", "预计开业时间"}); params.setImportFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*", "意向租凭面积", "预计开业时间"});
@@ -334,7 +368,7 @@ public class InvestBizServiceImpl implements InvestBizService {
log.error("经营业态为空", customer.toString()); log.error("经营业态为空", customer.toString());
return; 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) { if (toImportCustomer == null) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("customerBase null"); log.error("customerBase null");
@@ -351,8 +385,6 @@ public class InvestBizServiceImpl implements InvestBizService {
setRedisValue(importKey, "1", "0", "0", "1", true); setRedisValue(importKey, "1", "0", "0", "1", true);
log.error("导入模板失败", e); log.error("导入模板失败", e);
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "导入模板失败"); 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); 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; InvestCustomerEntity customerEntity = null;
InvestDemandEntity demandEntity = null; InvestDemandEntity demandEntity = null;
if (Objects.isNull(dbCustomer)) { if (Objects.isNull(dbCustomer)) {
@@ -379,16 +411,19 @@ public class InvestBizServiceImpl implements InvestBizService {
demandEntity = new InvestDemandEntity(); demandEntity = new InvestDemandEntity();
} }
if (Objects.isNull(brandMap.get(importCustomerVo.getBrandName()))) { if (Objects.isNull(brandMap.get(importCustomerVo.getBrandName()))) {
log.warn("品牌:{} 不存在", importCustomerVo.getBrandName());
return null; return null;
} }
customerEntity.setBrandId(brandMap.get(importCustomerVo.getBrandName()).getId()); customerEntity.setBrandId(brandMap.get(importCustomerVo.getBrandName()).getId());


if (Objects.isNull(businesseMap.get(importCustomerVo.getBusiness()))) { if (Objects.isNull(businesseMap.get(importCustomerVo.getBusiness()))) {
log.warn("业态:{} 不存在", importCustomerVo.getBusiness());
return null; return null;
} }
customerEntity.setBusinessId(businesseMap.get(importCustomerVo.getBusiness()).getId()); customerEntity.setBusinessId(businesseMap.get(importCustomerVo.getBusiness()).getId());


if (Objects.isNull(shopMap.get(importCustomerVo.getShopNumber()))) { if (Objects.isNull(shopMap.get(importCustomerVo.getShopNumber()))) {
log.warn("意向铺位:{} 不存在", importCustomerVo.getShopNumber());
return null; return null;
} }
customerEntity.setName(importCustomerVo.getName()); customerEntity.setName(importCustomerVo.getName());


+ 4
- 3
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java View File

@@ -44,13 +44,14 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl<InvestDemandM


private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) {
checkCustomerExit(customerService, entity.getCustomerId()); checkCustomerExit(customerService, entity.getCustomerId());
checkUserExit(userInfoService, entity.getOwner());
checkShop(shopService, entity); checkShop(shopService, entity);
if(Objects.nonNull(entity.getIntent())) {
if (Objects.nonNull(entity.getIntent())) {
entity.setIntent(stringToJson(entity.getIntent())); entity.setIntent(stringToJson(entity.getIntent()));
} }
if(Objects.isNull(entity.getOwner())) {
if (Objects.isNull(entity.getOwner()) || Objects.equals(entity.getOwner(), 0L)) {
entity.setOwner(0L); entity.setOwner(0L);
} else {
checkUserExit(userInfoService, entity.getOwner());
} }
} }




Loading…
Cancel
Save