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

Commit f04dff16 authored by jiangxiulong's avatar jiangxiulong

同步数据异常处理

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