|
|
|
@@ -518,27 +518,25 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { |
|
|
|
|
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
|
|
|
|
String importKey = "import-" + userId; |
|
|
|
|
|
|
|
//默认添加到redis里 |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "allCount", ""); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "successCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "failCount", "0"); |
|
|
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
//IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); |
|
|
|
//handler.setNeedHandlerFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"});// 注意这里对应的是excel的列名。也就是对象上指定的列名。 |
|
|
|
//params.setDataHandler(handler); |
|
|
|
//params.setVerifyHandler(); |
|
|
|
// 需要验证 |
|
|
|
params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); |
|
|
|
params.setNeedVerify(true); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ExcelImportResult<CUserBaseInfoT> datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params); |
|
|
|
List<CUserBaseInfoT> successList = datalist.getList(); |
|
|
|
List<CUserBaseInfoT> failList = datalist.getFailList(); |
|
|
|
logger.info("验证通过的数量:" + successList.size()); |
|
|
|
logger.info("验证未通过的数量:" + failList.size()); |
|
|
|
//如果不存在就添加 |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "allCount", successList.size() + failList.size() + ""); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "allSuccessCount", successList.size() + ""); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "successCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "failCount", failList.size() + ""); |
|
|
|
logger.info("验证通过的数量: " + successList.size()); |
|
|
|
logger.info("验证未通过的数量: " + failList.size()); |
|
|
|
|
|
|
|
successList.parallelStream().forEach(uBase->{ |
|
|
|
|
|
|
|
@@ -650,12 +648,12 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { |
|
|
|
stringRedisTemplate.opsForHash().increment(userId,"successCount",1); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "allCount", "1"); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "successCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(importKey, "failCount", "1"); |
|
|
|
e.printStackTrace(); |
|
|
|
logger.error("导入模板失败:"+e.getMessage()); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "allCount", "1"); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "allSuccessCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "successCount", "0"); |
|
|
|
stringRedisTemplate.opsForHash().put(userId, "failCount", "1"); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
|