From 6804c493087548a8a8410a7e3d5ec3675e52878f Mon Sep 17 00:00:00 2001 From: Burce Date: Mon, 28 Oct 2019 17:19:11 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF]=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invest/InvestCustomerController.java | 8 ++- .../domain/vo/invest/InvestDemandQuery.java | 6 +-- .../service/invest/InvestBizService.java | 2 + .../invest/impl/InvestBizServiceImpl.java | 49 ++++++++++++++++--- .../invest/impl/InvestDemandServiceImpl.java | 7 +-- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java index 95dfa326b..c675ce312 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java @@ -95,7 +95,7 @@ public class InvestCustomerController extends InvestBaseController{ @ApiOperation("导出客户信息模板") @GetMapping("/exportCustomerTemplate") - @SystemControllerLog(description = "招商管理-导出客户信息模板") + @SystemControllerLog(description = "导出客户信息模板") public void exportCustomerTemplate(HttpServletResponse response) { exportData(null, response, (p, u) -> investBizService.exportCustomerTemplate(u)); } @@ -107,4 +107,10 @@ public class InvestCustomerController extends InvestBaseController{ return importData(file, p -> investBizService.importCustomer(p)); } + @GetMapping("/queryTemplateCount") + @SystemControllerLog(description = "查询导入数据") + public InvestResultData queryTemplateCount() { + return execute(null, p -> investBizService.queryCustomerImportCount()); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java index 6951906b7..3d8629a58 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java @@ -9,10 +9,10 @@ import lombok.EqualsAndHashCode; 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-谈判失败 diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java index ef15c5708..2e305d9fc 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -23,6 +23,8 @@ public interface InvestBizService { void importCustomer(@RequestParam("file") MultipartFile mFile); + Map queryCustomerImportCount() ; + List queryCustomer(); InvestPageResult queryPageTask(InvestTaskQuery params); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 68e507816..2ae0aea71 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -89,7 +89,7 @@ public class InvestBizServiceImpl implements InvestBizService { } List demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); LambdaQueryWrapper 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 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 brandMap, Map businesseMap, Map shopMap, InvestCustomerEntity dbCustomer, Map demandMap) { + private InvestDemandDto convetCustomer(String importKey, InvestCustomerVo importCustomerVo, Map brandMap, Map businesseMap, Map shopMap, InvestCustomerEntity dbCustomer, Map 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()); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java index 2291abc16..dbc0ba1c1 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java @@ -44,13 +44,14 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl