|
|
|
@@ -13,6 +13,9 @@ import com.iformall.service.WxTagsService; |
|
|
|
import com.iformall.shiro.UserSession; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.apache.shiro.session.Session; |
|
|
|
import org.apache.shiro.session.UnknownSessionException; |
|
|
|
import org.apache.shiro.subject.Subject; |
|
|
|
import org.apache.shiro.util.ThreadContext; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -91,33 +94,33 @@ public class AsyncTask { |
|
|
|
List<CUserBaseInfoT> successList = datalist.getList(); |
|
|
|
List<CUserBaseInfoT> failList = datalist.getFailList(); |
|
|
|
|
|
|
|
logger.info("验证通过的数量: " + successList.size()); |
|
|
|
logger.info("验证未通过的数量: " + failList.size()); |
|
|
|
|
|
|
|
int total = successList.size() + failList.size(); |
|
|
|
int all_success = successList.size(); |
|
|
|
int all_fail = failList.size(); |
|
|
|
|
|
|
|
//添加到redis里 |
|
|
|
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, false); |
|
|
|
|
|
|
|
logger.info("验证通过的数量: " + successList.size()); |
|
|
|
logger.info("验证未通过的数量: " + failList.size()); |
|
|
|
|
|
|
|
WxTags wxTagsQ = new WxTags(); |
|
|
|
List<WxTags> tagList = wxTagsService.findList(wxTagsQ); |
|
|
|
|
|
|
|
try { |
|
|
|
successList.parallelStream().forEach(uBase -> { |
|
|
|
// 异步无法获取到原有的session,所以再注入一下session |
|
|
|
Session session = SecurityUtils.getSubject().getSession(); |
|
|
|
session.setAttribute(UserSession.userInfo, user); |
|
|
|
session.setAttribute(UserSession.userId, user.getId()); |
|
|
|
session.setAttribute(UserSession.tenantId, tenantId); |
|
|
|
|
|
|
|
wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
set_redis_value(importKey, "1", "0", "0", "1", true); |
|
|
|
e.printStackTrace(); |
|
|
|
logger.error("导入模板失败:"+e.getMessage()); |
|
|
|
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); |
|
|
|
|
|
|
|
if(successList.size() > 0) { |
|
|
|
WxTags wxTagsQ = new WxTags(); |
|
|
|
List<WxTags> tagList = wxTagsService.findList(wxTagsQ); |
|
|
|
|
|
|
|
try { |
|
|
|
successList.parallelStream().forEach(uBase -> { |
|
|
|
try { |
|
|
|
wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase); |
|
|
|
} catch (UnknownSessionException ue) { |
|
|
|
logger.error("session :"+ue.getMessage()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
set_redis_value(importKey, "1", "0", "0", "1", true); |
|
|
|
e.printStackTrace(); |
|
|
|
logger.error("导入模板失败:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |