Commit 501e1e115bafa79fcc2c548fe5291d011e985080

Authored by fangcheng
1 parent d12a41c50e
Exists in master

添加容错处理

Showing 3 changed files with 12 additions and 5 deletions

parent/center.manager/src/main/java/com/lyms/cm/job/SyncFixJob.java View file @ 501e1e1
... ... @@ -11,6 +11,7 @@
11 11 import org.springframework.beans.factory.annotation.Autowired;
12 12 import org.springframework.data.redis.core.RedisTemplate;
13 13  
  14 +import com.alibaba.fastjson.JSONException;
14 15 import com.baomidou.mybatisplus.mapper.EntityWrapper;
15 16 import com.lyms.base.common.entity.organ.OrganGroup;
16 17 import com.lyms.base.common.service.organ.OrganGroupService;
... ... @@ -92,7 +93,7 @@
92 93 ChannelData data = null;
93 94 try{
94 95 data = JsonUtils.jsonToBean(result, ChannelData.class);
95   - }catch(Exception e){
  96 + }catch(JSONException e){
96 97 LOG.error("同步数据转换异常,请求结果:{} ",result);
97 98 return;
98 99 }
parent/center.manager/src/main/java/com/lyms/cm/job/SyncTmpJob.java View file @ 501e1e1
... ... @@ -3,11 +3,13 @@
3 3 import java.io.Serializable;
4 4 import java.util.concurrent.atomic.AtomicBoolean;
5 5  
  6 +import org.apache.commons.lang3.StringUtils;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.data.redis.core.RedisTemplate;
10 11  
  12 +import com.alibaba.fastjson.JSONException;
11 13 import com.alibaba.fastjson.JSONObject;
12 14 import com.lyms.sync.SyncCallback;
13 15 import com.lyms.sync.SyncCenter;
14 16  
... ... @@ -62,11 +64,15 @@
62 64 if (model != null) {
63 65 // 任务发送执行
64 66 String result = HttpUtils.REMOTE.post(model);
65   - if(result == null){//远程无法访问等情况
  67 + if(StringUtils.isBlank(result)){//远程无法访问等情况
66 68 work.backPressure();
67 69 return;
68 70 }
69   - model = JsonUtils.jsonToBean(result, ChannelData.class);
  71 + try{
  72 + model = JsonUtils.jsonToBean(result, ChannelData.class);
  73 + }catch(JSONException e){
  74 + LOG.error("推送到节点数据返回异常,返回结果:{} ",result);
  75 + }
70 76 if (model != null && model.getAck()) {
71 77 work.backPressure();
72 78 }
parent/hospital.web/src/main/java/com/lyms/hospital/controller/RouterController.java View file @ 501e1e1
... ... @@ -30,7 +30,7 @@
30 30  
31 31 private static final Logger log = LoggerFactory.getLogger(RouterController.class);
32 32  
33   - @RequestMapping(value = "/pull", produces = { MediaType.APPLICATION_JSON_VALUE })
  33 + //@RequestMapping(value = "/pull", produces = { MediaType.APPLICATION_JSON_VALUE })
34 34 public Object pull(HttpServletRequest request) throws Exception {
35 35 ChannelData data = SyncUtils.conver(request);
36 36 log.debug("节点数据被中心拉取:" + ToStringBuilder.reflectionToString(data));
... ... @@ -44,7 +44,7 @@
44 44 return data;
45 45 }
46 46  
47   - @RequestMapping(value = "/push", produces = { MediaType.APPLICATION_JSON_VALUE })
  47 + //@RequestMapping(value = "/push", produces = { MediaType.APPLICATION_JSON_VALUE })
48 48 public Object push(HttpServletRequest request) throws Exception {
49 49 ChannelData data = SyncUtils.conver(request);
50 50 log.debug("中心推送数据到节点:" + ToStringBuilder.reflectionToString(data));