记得上下班打卡 | git大法好,push需谨慎

Commit f04dff16 authored by jiangxiulong's avatar jiangxiulong

同步数据异常处理

parent b568f5f5
......@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
......@@ -19,6 +20,7 @@ import java.io.*;
@Api(tags = "同步微信用户数据")
@RestController
@RequestMapping("/wechatSync")
@Slf4j
public class SweetWechatSyncDataController {
@Autowired
......@@ -35,8 +37,7 @@ public class SweetWechatSyncDataController {
BufferedReader bufferedReader = new BufferedReader(read);
String mobile = null;
while ((mobile = bufferedReader.readLine()) != null) {
System.out.println(mobile);
log.info("regMobilen:mobile:[{}]", mobile);
try {
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("mobile", mobile);
......@@ -46,7 +47,7 @@ public class SweetWechatSyncDataController {
String url = "";
HttpUtil.post(url, params);
} catch (Exception e) {
e.printStackTrace();
log.info("regMobileException:mobile:[{}]", mobile);
}
}
......@@ -62,7 +63,7 @@ public class SweetWechatSyncDataController {
try {
sweetWechatMpService.userInfo();
} catch (Exception e) {
e.printStackTrace();
log.error("getUsers", e);
}
}
......@@ -75,7 +76,7 @@ public class SweetWechatSyncDataController {
try {
sweetWechatMpService.getUser(openId);
} catch (Exception e) {
e.printStackTrace();
log.error("getUser", e);
}
}
......
......@@ -47,9 +47,12 @@ public class SweetWechatMpService {
log.info("nextOpenid:[{}] ", nextOpenid);
for (String openId : openids) {
try {
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(openId);
log.info("openId:[{}],wxMpUsers:[{}]", openId, wxMpUser);
if (!wxMpUser.getSubscribe()) {
log.info("getSubscribeFalse:openId:[{}]", openId);
continue;
}
SweetWechatUser userInfo = redisDataUtils.getSweetWechatUser(wxMpUser.getUnionId());
if (null == userInfo) {
SweetWechatUser sweetWechatUser = SweetWechatUser.getNew();
......@@ -80,9 +83,13 @@ public class SweetWechatMpService {
// 入缓存
redisDataUtils.setSweetWechatUser(sweetWechatUser);
}
} catch (Exception e) {
log.info("forException:openId:[{}]", openId);
}
}
log.info("nextOpenidSuccess:[{}] ", nextOpenid);
} while (!nextOpenid.isEmpty());
log.info("同步微信用户完成");
}
public void getUser(String openId) throws WxErrorException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment