Commit 3bb5d8370ac99ab671f33fa43fa0c18d9b27f5eb

Authored by fangcheng
1 parent 0a4e4b6997
Exists in master

修改包名称

Showing 19 changed files with 384 additions and 414 deletions

center.manager/src/main/java/com/lyms/cm/controller/sys/SysRemoteController.java View file @ 3bb5d83
... ... @@ -9,10 +9,10 @@
9 9 import org.springframework.web.bind.annotation.RequestMapping;
10 10 import org.springframework.web.bind.annotation.ResponseBody;
11 11  
12   -import com.lyms.sycn.channel.ChannelData;
13 12 import com.lyms.sync.ParamsAdpter;
14 13 import com.lyms.sync.SyncHandler;
15 14 import com.lyms.sync.SyncUtils;
  15 +import com.lyms.sync.channel.ChannelData;
16 16 import com.lyms.web.controller.BaseController;
17 17  
18 18 @Controller
center.manager/src/main/java/com/lyms/cm/job/SyncFixJob.java View file @ 3bb5d83
... ... @@ -6,12 +6,12 @@
6 6 import org.slf4j.LoggerFactory;
7 7 import org.springframework.beans.factory.annotation.Autowired;
8 8  
9   -import com.lyms.sycn.channel.ChannelData;
10 9 import com.lyms.sync.ParamsAdpter;
11 10 import com.lyms.sync.SyncCallback;
12 11 import com.lyms.sync.SyncCenter;
13 12 import com.lyms.sync.SyncHandler;
14 13 import com.lyms.sync.SyncCenter.Work;
  14 +import com.lyms.sync.channel.ChannelData;
15 15 import com.lyms.util.HttpUtils;
16 16 import com.lyms.util.JsonUtils;
17 17  
center.manager/src/main/java/com/lyms/cm/job/SyncTmpJob.java View file @ 3bb5d83
... ... @@ -4,10 +4,10 @@
4 4 import org.slf4j.LoggerFactory;
5 5 import org.springframework.beans.factory.annotation.Autowired;
6 6  
7   -import com.lyms.sycn.channel.ChannelData;
8 7 import com.lyms.sync.SyncCallback;
9 8 import com.lyms.sync.SyncCenter;
10 9 import com.lyms.sync.SyncCenter.Work;
  10 +import com.lyms.sync.channel.ChannelData;
11 11 import com.lyms.util.HttpUtils;
12 12 import com.lyms.util.JsonUtils;
13 13  
center.manager/src/main/resources/xml/app-timer.xml View file @ 3bb5d83
... ... @@ -15,10 +15,10 @@
15 15 <!-- 同步远程数据, 定时任务处理同步任务 -->
16 16 <task:scheduled-tasks>
17 17 <!-- <task:scheduled ref="sycnTmpJob" method="excute" cron="*/10 * * * * ?"/> -->
18   - <task:scheduled ref="sycnFixJob" method="excute" cron="*/30 * * * * ?"/>
  18 + <task:scheduled ref="syncFixJob" method="excute" cron="*/30 * * * * ?"/>
19 19 </task:scheduled-tasks>
20 20  
21   - <bean class="com.lyms.cm.job.SycnTmpJob" id="sycnTmpJob"/>
22   - <bean class="com.lyms.cm.job.SycnFixJob" id="sycnFixJob"/>
  21 + <bean class="com.lyms.cm.job.SyncTmpJob" id="sycnTmpJob"/>
  22 + <bean class="com.lyms.cm.job.SyncFixJob" id="sycnFixJob"/>
23 23 </beans>
center.manager/src/test/java/center/manager/test/user/WorkTest.java View file @ 3bb5d83
... ... @@ -4,9 +4,9 @@
4 4 import org.junit.Test;
5 5 import org.springframework.beans.factory.annotation.Autowired;
6 6  
7   -import com.lyms.sycn.channel.ChannelData;
8 7 import com.lyms.sync.SyncCallback;
9 8 import com.lyms.sync.SyncCenter;
  9 +import com.lyms.sync.channel.ChannelData;
10 10 import com.lyms.util.StrUtils;
11 11  
12 12 /**
core.sdk/src/main/java/com/lyms/sycn/channel/ChannelData.java View file @ 3bb5d83
1   -package com.lyms.sycn.channel;
2   -
3   -import java.io.Serializable;
4   -
5   -import org.apache.commons.lang3.StringUtils;
6   -
7   -import com.lyms.util.JsonUtils;
8   -import com.lyms.util.StrUtils;
9   -
10   -/**
11   - * <li>@ClassName: ChannelData
12   - * <li>@Description: 通道实体
13   - * <li>@author maliang
14   - * <li>@date 2017年3月15日
15   - * <li>
16   - */
17   -public class ChannelData implements Serializable {
18   -
19   - /**
20   - */
21   - private static final long serialVersionUID = -4448732709523865922L;
22   -
23   - public ChannelData() {
24   - this.ts = System.currentTimeMillis();
25   - };
26   -
27   - public static ChannelData emtpy() {
28   - return new ChannelData();
29   - }
30   -
31   - /**
32   - * 数据传输ID
33   - */
34   - private String id;
35   -
36   - /**
37   - * remote address
38   - */
39   - private String remote;
40   -
41   - /**
42   - * remote class name
43   - */
44   - private String remoteClazz;
45   -
46   - /**
47   - * remote method name
48   - */
49   - private String remoteMethod;
50   -
51   - /**
52   - * remote body json
53   - */
54   - private String data;
55   -
56   - private Boolean loop = Boolean.FALSE;
57   -
58   - /**
59   - * 是否回执信息
60   - */
61   - private Boolean ack = Boolean.FALSE;
62   -
63   - /**
64   - * 创建时间
65   - */
66   - private Long ts;
67   -
68   - public ChannelData(String remote, String remoteClazz, String remoteMethod, String data, boolean loop) {
69   - this.id = StrUtils.uuid();
70   - this.remote = remote;
71   - this.remoteClazz = remoteClazz;
72   - this.remoteMethod = remoteMethod;
73   - this.data = data;
74   - this.ts = System.currentTimeMillis();
75   - this.loop = loop;
76   - }
77   -
78   - /**
79   - *
80   - * 使用不为空的ID,与业务数据保持一个相同的ID
81   - * <p>
82   - * 如果为空将会创建新的ID
83   - *
84   - * @param id
85   - * @param remote
86   - * @param remoteClazz
87   - * @param remoteMethod
88   - * @param data
89   - * {@link ChannelData#toJsonString()}
90   - * @param loop
91   - */
92   - public ChannelData(String id, String remote, String remoteClazz, String remoteMethod, String data, boolean loop) {
93   - this.id = StringUtils.isBlank(id) ? StrUtils.uuid() : id;
94   - this.remote = remote;
95   - this.remoteClazz = remoteClazz;
96   - this.remoteMethod = remoteMethod;
97   - this.data = data;
98   - this.ts = System.currentTimeMillis();
99   - this.loop = loop;
100   - }
101   -
102   - public String getId() {
103   - return id;
104   - }
105   -
106   - public void setId(String id) {
107   - this.id = id;
108   - }
109   -
110   - public String getRemote() {
111   - return remote;
112   - }
113   -
114   - public void setRemote(String remote) {
115   - this.remote = remote;
116   - }
117   -
118   - public String getRemoteClazz() {
119   - return remoteClazz;
120   - }
121   -
122   - public void setRemoteClazz(String remoteClazz) {
123   - this.remoteClazz = remoteClazz;
124   - }
125   -
126   - public String getRemoteMethod() {
127   - return remoteMethod;
128   - }
129   -
130   - public void setRemoteMethod(String remoteMethod) {
131   - this.remoteMethod = remoteMethod;
132   - }
133   -
134   - public String getData() {
135   - return data;
136   - }
137   -
138   - public void setData(String data) {
139   - this.data = data;
140   - }
141   -
142   - public Long getTs() {
143   - return ts;
144   - }
145   -
146   - public void setTs(Long ts) {
147   - this.ts = ts;
148   - }
149   -
150   - public Boolean getLoop() {
151   - return loop;
152   - }
153   -
154   - public void setLoop(Boolean loop) {
155   - this.loop = loop;
156   - }
157   -
158   - public Boolean getAck() {
159   - return ack;
160   - }
161   -
162   - public void setAck(Boolean ack) {
163   - this.ack = ack;
164   - }
165   -
166   - public String toJsonString() {
167   - return JsonUtils.beanToJson(this);
168   - }
169   -
170   -}
core.sdk/src/main/java/com/lyms/sycn/channel/package-info.java View file @ 3bb5d83
1   -/**
2   - * <li>@Title: package-info.java
3   - * <li>@Package com.lyms.sycn.channel
4   - * <li>@Description: TODO(文件描述)
5   - * <li>@author maliang
6   - * <li>@date 2017年3月16日
7   - */
8   -/**
9   - * <li>@ClassName: package-info
10   - * <li>@Description: TODO(类描述)
11   - * <li>@author maliang
12   - * <li>@date 2017年3月16日
13   - * <li>
14   - */
15   -package com.lyms.sycn.channel;
core.sdk/src/main/java/com/lyms/sycn/queue/SycnQueue.java View file @ 3bb5d83
1   -package com.lyms.sycn.queue;
2   -
3   -import java.io.Serializable;
4   -
5   -import org.springframework.data.redis.core.RedisTemplate;
6   -
7   -import com.lyms.spring.redis.operation.RedisLock;
8   -import com.lyms.sycn.channel.ChannelData;
9   -
10   -/**
11   - * <li>@ClassName: SyncnQueue
12   - * <li>@Description: 数据队列
13   - * <li>@author maliang
14   - * <li>@date 2017年3月13日
15   - * <li>
16   - */
17   -public class SycnQueue {
18   -
19   - public RedisTemplate<Serializable, Serializable> template;
20   -
21   - /**
22   - * 构建临时任务队列,固定任务队列锁
23   - * <p>
24   - * 区分锁,避免高并发下锁释放的错误
25   - */
26   - public static RedisLock Fix_Lock;
27   -
28   - public static RedisLock Tmp_Lock;
29   -
30   - /**
31   - * 针对数据获取的时候添加锁
32   - */
33   - private static final String LOCK_TMP_NAME = "TMP_lock";
34   -
35   - private static final String LOCK_FIXATION_NAME = "FIXATION_lock";
36   -
37   - /**
38   - * 等待获取锁的时间5 S
39   - */
40   - private static final Long WAIT_LOCK_TIME = 5000L;
41   -
42   - /**
43   - * 固定任务
44   - */
45   - private static final String FIXATION_WORK = "FIXATION_WORK";
46   -
47   - /**
48   - * 临时任务
49   - */
50   - private static final String TMP_WORK = "TMP_WORK";
51   -
52   - /**
53   - * 回执消息任务
54   - */
55   - @Deprecated
56   - private static final String ACK_WORK = "ACK_WORK";
57   -
58   - public SycnQueue(RedisTemplate<Serializable, Serializable> template) {
59   - this.template = template;
60   - Fix_Lock = new RedisLock(template);
61   - Tmp_Lock = new RedisLock(template);
62   - }
63   -
64   - /**
65   - * <li>@Description:固定任务 {@link ModelType#GET}
66   - * <p>
67   - * 固定任务执行效率跟任务链表的长度有关系
68   - * <li>@param model
69   - * <li>@return
70   - * <li>创建人:maliang
71   - * <li>创建时间:2017年3月13日
72   - * <li>修改人:
73   - * <li>修改时间:
74   - */
75   - private Boolean pushFixationWork(ChannelData data) {
76   - Long tag = template.opsForList().leftPush(FIXATION_WORK, data);
77   - return tag >= 1;
78   - }
79   -
80   - private ChannelData pullFixationData() {
81   - // 添加锁
82   - try {
83   - if (Fix_Lock.acquireLock(LOCK_FIXATION_NAME, WAIT_LOCK_TIME)) {
84   - ChannelData obj = (ChannelData) template.opsForList().rightPopAndLeftPush(FIXATION_WORK, FIXATION_WORK);
85   - return obj;
86   - }
87   - } catch (Exception e) {
88   - e.printStackTrace();
89   - } finally {
90   - try {
91   - if (Fix_Lock != null) {
92   - Fix_Lock.releaseLock();
93   - }
94   - } catch (Exception e) {
95   - e.printStackTrace();
96   - }
97   - }
98   - return null;
99   -
100   - }
101   -
102   - /**
103   - * <li>@Description:临时任务
104   - * <p>
105   - * {@link ModelType#ADD ModelType#UPDATE ModelType#DEL}
106   - * <li>@param model
107   - * <li>@return
108   - * <li>创建人:maliang
109   - * <li>创建时间:2017年3月13日
110   - * <li>修改人:
111   - * <li>修改时间:
112   - */
113   - private boolean pushTempWork(ChannelData data) {
114   - Long tag = template.opsForList().leftPush(TMP_WORK, data);
115   - return tag >= 1;
116   - }
117   -
118   - /**
119   - * <li>@Description:临时队列数据弹出
120   - * <li>@return
121   - * <li>创建人:maliang
122   - * <li>创建时间:2017年3月13日
123   - * <li>修改人:
124   - * <li>修改时间:
125   - */
126   - private ChannelData pullTempData() {
127   -
128   - try {
129   - if (Tmp_Lock.acquireLock(LOCK_TMP_NAME, WAIT_LOCK_TIME)) {
130   - Serializable object = template.opsForList().rightPop(TMP_WORK);
131   - return object != null ? (ChannelData) object : null;
132   - }
133   - } catch (Exception e) {
134   - e.printStackTrace();
135   - } finally {
136   - if (Tmp_Lock != null) {
137   - try {
138   - Tmp_Lock.releaseLock();
139   - } catch (Exception e) {
140   - e.printStackTrace();
141   - }
142   - }
143   - }
144   - return null;
145   - }
146   -
147   - /**
148   - * <li>@Description:将任务信息添加到队列中,任务分为固定任务,临时任务,目前拉取数据的任务为固定任务
149   - * {@link ModelType#GET}
150   - * <li>@param model
151   - * <li>@return
152   - * <li>创建人:maliang
153   - * <li>创建时间:2017年3月13日
154   - * <li>修改人:
155   - * <li>修改时间:
156   - */
157   - public Boolean push(ChannelData data) {
158   - if (template == null || data == null)
159   - return Boolean.FALSE;
160   - // 设置任务添加时间
161   - /*
162   - * model.setTs(System.currentTimeMillis()); String modelType =
163   - * model.getType(); if (ModelType.isGet(modelType)) { return
164   - * this.pushFixationWork(model); } else { return
165   - * this.pushTempWork(model); }
166   - */
167   - boolean loop = data.getLoop();
168   - return loop ? this.pushFixationWork(data) : this.pushTempWork(data);
169   - }
170   -
171   - /**
172   - * <li>@Description:获取队列中的数据
173   - * <p>
174   - * <li>@param type
175   - * <li>@return
176   - * <li>创建人:maliang
177   - * <li>创建时间:2017年3月13日
178   - * <li>修改人:
179   - * <li>修改时间:
180   - */
181   - public ChannelData pull(boolean loop) {
182   - // boolean loop = data != null && data.getLoop();
183   - return loop ? this.pullFixationData() : this.pullTempData();
184   - /*
185   - * if (ModelType.isGet(type)) { return this.pullFixationModel(); } else
186   - * { return this.pullTempModel(); }
187   - */
188   - }
189   -
190   - public RedisTemplate<Serializable, Serializable> getTemplate() {
191   - return template;
192   - }
193   -
194   - public void setTemplate(RedisTemplate<Serializable, Serializable> template) {
195   - this.template = template;
196   - }
197   -
198   -}
core.sdk/src/main/java/com/lyms/sycn/queue/package-info.java View file @ 3bb5d83
1   -/**
2   - * <li>@Title: package-info.java
3   - * <li>@Package com.lyms.sycn.queue
4   - * <li>@Description: TODO(文件描述)
5   - * <li>@author maliang
6   - * <li>@date 2017年3月16日
7   - */
8   -/**
9   - * <li>@ClassName: package-info
10   - * <li>@Description: TODO(类描述)
11   - * <li>@author maliang
12   - * <li>@date 2017年3月16日
13   - * <li>
14   - */
15   -package com.lyms.sycn.queue;
core.sdk/src/main/java/com/lyms/sync/SyncCenter.java View file @ 3bb5d83
... ... @@ -3,8 +3,8 @@
3 3 import java.util.concurrent.Executors;
4 4 import java.util.concurrent.ScheduledExecutorService;
5 5  
6   -import com.lyms.sycn.channel.ChannelData;
7   -import com.lyms.sycn.queue.SycnQueue;
  6 +import com.lyms.sync.channel.ChannelData;
  7 +import com.lyms.sync.queue.SycnQueue;
8 8 import com.lyms.util.HttpUtils;
9 9  
10 10 /**
core.sdk/src/main/java/com/lyms/sync/SyncHandler.java View file @ 3bb5d83
... ... @@ -9,8 +9,8 @@
9 9 import org.slf4j.LoggerFactory;
10 10  
11 11 import com.lyms.spring.SpringContextHolder;
12   -import com.lyms.sycn.channel.ChannelData;
13 12 import com.lyms.sync.ParamsAdpter.Param;
  13 +import com.lyms.sync.channel.ChannelData;
14 14 import com.lyms.util.JsonUtils;
15 15  
16 16 /**
core.sdk/src/main/java/com/lyms/sync/SyncUtils.java View file @ 3bb5d83
... ... @@ -4,7 +4,7 @@
4 4  
5 5 import javax.servlet.http.HttpServletRequest;
6 6  
7   -import com.lyms.sycn.channel.ChannelData;
  7 +import com.lyms.sync.channel.ChannelData;
8 8  
9 9 /**
10 10 * <li>@ClassName: SyncUtils
core.sdk/src/main/java/com/lyms/sync/channel/ChannelData.java View file @ 3bb5d83
  1 +package com.lyms.sync.channel;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +import org.apache.commons.lang3.StringUtils;
  6 +
  7 +import com.lyms.util.JsonUtils;
  8 +import com.lyms.util.StrUtils;
  9 +
  10 +/**
  11 + * <li>@ClassName: ChannelData
  12 + * <li>@Description: 通道实体
  13 + * <li>@author maliang
  14 + * <li>@date 2017年3月15日
  15 + * <li>
  16 + */
  17 +public class ChannelData implements Serializable {
  18 +
  19 + /**
  20 + */
  21 + private static final long serialVersionUID = -4448732709523865922L;
  22 +
  23 + public ChannelData() {
  24 + this.ts = System.currentTimeMillis();
  25 + };
  26 +
  27 + public static ChannelData emtpy() {
  28 + return new ChannelData();
  29 + }
  30 +
  31 + /**
  32 + * 数据传输ID
  33 + */
  34 + private String id;
  35 +
  36 + /**
  37 + * remote address
  38 + */
  39 + private String remote;
  40 +
  41 + /**
  42 + * remote class name
  43 + */
  44 + private String remoteClazz;
  45 +
  46 + /**
  47 + * remote method name
  48 + */
  49 + private String remoteMethod;
  50 +
  51 + /**
  52 + * remote body json
  53 + */
  54 + private String data;
  55 +
  56 + private Boolean loop = Boolean.FALSE;
  57 +
  58 + /**
  59 + * 是否回执信息
  60 + */
  61 + private Boolean ack = Boolean.FALSE;
  62 +
  63 + /**
  64 + * 创建时间
  65 + */
  66 + private Long ts;
  67 +
  68 + public ChannelData(String remote, String remoteClazz, String remoteMethod, String data, boolean loop) {
  69 + this.id = StrUtils.uuid();
  70 + this.remote = remote;
  71 + this.remoteClazz = remoteClazz;
  72 + this.remoteMethod = remoteMethod;
  73 + this.data = data;
  74 + this.ts = System.currentTimeMillis();
  75 + this.loop = loop;
  76 + }
  77 +
  78 + /**
  79 + *
  80 + * 使用不为空的ID,与业务数据保持一个相同的ID
  81 + * <p>
  82 + * 如果为空将会创建新的ID
  83 + *
  84 + * @param id
  85 + * @param remote
  86 + * @param remoteClazz
  87 + * @param remoteMethod
  88 + * @param data
  89 + * {@link ChannelData#toJsonString()}
  90 + * @param loop
  91 + */
  92 + public ChannelData(String id, String remote, String remoteClazz, String remoteMethod, String data, boolean loop) {
  93 + this.id = StringUtils.isBlank(id) ? StrUtils.uuid() : id;
  94 + this.remote = remote;
  95 + this.remoteClazz = remoteClazz;
  96 + this.remoteMethod = remoteMethod;
  97 + this.data = data;
  98 + this.ts = System.currentTimeMillis();
  99 + this.loop = loop;
  100 + }
  101 +
  102 + public String getId() {
  103 + return id;
  104 + }
  105 +
  106 + public void setId(String id) {
  107 + this.id = id;
  108 + }
  109 +
  110 + public String getRemote() {
  111 + return remote;
  112 + }
  113 +
  114 + public void setRemote(String remote) {
  115 + this.remote = remote;
  116 + }
  117 +
  118 + public String getRemoteClazz() {
  119 + return remoteClazz;
  120 + }
  121 +
  122 + public void setRemoteClazz(String remoteClazz) {
  123 + this.remoteClazz = remoteClazz;
  124 + }
  125 +
  126 + public String getRemoteMethod() {
  127 + return remoteMethod;
  128 + }
  129 +
  130 + public void setRemoteMethod(String remoteMethod) {
  131 + this.remoteMethod = remoteMethod;
  132 + }
  133 +
  134 + public String getData() {
  135 + return data;
  136 + }
  137 +
  138 + public void setData(String data) {
  139 + this.data = data;
  140 + }
  141 +
  142 + public Long getTs() {
  143 + return ts;
  144 + }
  145 +
  146 + public void setTs(Long ts) {
  147 + this.ts = ts;
  148 + }
  149 +
  150 + public Boolean getLoop() {
  151 + return loop;
  152 + }
  153 +
  154 + public void setLoop(Boolean loop) {
  155 + this.loop = loop;
  156 + }
  157 +
  158 + public Boolean getAck() {
  159 + return ack;
  160 + }
  161 +
  162 + public void setAck(Boolean ack) {
  163 + this.ack = ack;
  164 + }
  165 +
  166 + public String toJsonString() {
  167 + return JsonUtils.beanToJson(this);
  168 + }
  169 +
  170 +}
core.sdk/src/main/java/com/lyms/sync/queue/SycnQueue.java View file @ 3bb5d83
  1 +package com.lyms.sync.queue;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +import org.springframework.data.redis.core.RedisTemplate;
  6 +
  7 +import com.lyms.spring.redis.operation.RedisLock;
  8 +import com.lyms.sync.channel.ChannelData;
  9 +
  10 +/**
  11 + * <li>@ClassName: SyncnQueue
  12 + * <li>@Description: 数据队列
  13 + * <li>@author maliang
  14 + * <li>@date 2017年3月13日
  15 + * <li>
  16 + */
  17 +public class SycnQueue {
  18 +
  19 + public RedisTemplate<Serializable, Serializable> template;
  20 +
  21 + /**
  22 + * 构建临时任务队列,固定任务队列锁
  23 + * <p>
  24 + * 区分锁,避免高并发下锁释放的错误
  25 + */
  26 + public static RedisLock Fix_Lock;
  27 +
  28 + public static RedisLock Tmp_Lock;
  29 +
  30 + /**
  31 + * 针对数据获取的时候添加锁
  32 + */
  33 + private static final String LOCK_TMP_NAME = "TMP_lock";
  34 +
  35 + private static final String LOCK_FIXATION_NAME = "FIXATION_lock";
  36 +
  37 + /**
  38 + * 等待获取锁的时间5 S
  39 + */
  40 + private static final Long WAIT_LOCK_TIME = 5000L;
  41 +
  42 + /**
  43 + * 固定任务
  44 + */
  45 + private static final String FIXATION_WORK = "FIXATION_WORK";
  46 +
  47 + /**
  48 + * 临时任务
  49 + */
  50 + private static final String TMP_WORK = "TMP_WORK";
  51 +
  52 + /**
  53 + * 回执消息任务
  54 + */
  55 + @Deprecated
  56 + private static final String ACK_WORK = "ACK_WORK";
  57 +
  58 + public SycnQueue(RedisTemplate<Serializable, Serializable> template) {
  59 + this.template = template;
  60 + Fix_Lock = new RedisLock(template);
  61 + Tmp_Lock = new RedisLock(template);
  62 + }
  63 +
  64 + /**
  65 + * <li>@Description:固定任务 {@link ModelType#GET}
  66 + * <p>
  67 + * 固定任务执行效率跟任务链表的长度有关系
  68 + * <li>@param model
  69 + * <li>@return
  70 + * <li>创建人:maliang
  71 + * <li>创建时间:2017年3月13日
  72 + * <li>修改人:
  73 + * <li>修改时间:
  74 + */
  75 + private Boolean pushFixationWork(ChannelData data) {
  76 + Long tag = template.opsForList().leftPush(FIXATION_WORK, data);
  77 + return tag >= 1;
  78 + }
  79 +
  80 + private ChannelData pullFixationData() {
  81 + // 添加锁
  82 + try {
  83 + if (Fix_Lock.acquireLock(LOCK_FIXATION_NAME, WAIT_LOCK_TIME)) {
  84 + ChannelData obj = (ChannelData) template.opsForList().rightPopAndLeftPush(FIXATION_WORK, FIXATION_WORK);
  85 + return obj;
  86 + }
  87 + } catch (Exception e) {
  88 + e.printStackTrace();
  89 + } finally {
  90 + try {
  91 + if (Fix_Lock != null) {
  92 + Fix_Lock.releaseLock();
  93 + }
  94 + } catch (Exception e) {
  95 + e.printStackTrace();
  96 + }
  97 + }
  98 + return null;
  99 +
  100 + }
  101 +
  102 + /**
  103 + * <li>@Description:临时任务
  104 + * <p>
  105 + * {@link ModelType#ADD ModelType#UPDATE ModelType#DEL}
  106 + * <li>@param model
  107 + * <li>@return
  108 + * <li>创建人:maliang
  109 + * <li>创建时间:2017年3月13日
  110 + * <li>修改人:
  111 + * <li>修改时间:
  112 + */
  113 + private boolean pushTempWork(ChannelData data) {
  114 + Long tag = template.opsForList().leftPush(TMP_WORK, data);
  115 + return tag >= 1;
  116 + }
  117 +
  118 + /**
  119 + * <li>@Description:临时队列数据弹出
  120 + * <li>@return
  121 + * <li>创建人:maliang
  122 + * <li>创建时间:2017年3月13日
  123 + * <li>修改人:
  124 + * <li>修改时间:
  125 + */
  126 + private ChannelData pullTempData() {
  127 +
  128 + try {
  129 + if (Tmp_Lock.acquireLock(LOCK_TMP_NAME, WAIT_LOCK_TIME)) {
  130 + Serializable object = template.opsForList().rightPop(TMP_WORK);
  131 + return object != null ? (ChannelData) object : null;
  132 + }
  133 + } catch (Exception e) {
  134 + e.printStackTrace();
  135 + } finally {
  136 + if (Tmp_Lock != null) {
  137 + try {
  138 + Tmp_Lock.releaseLock();
  139 + } catch (Exception e) {
  140 + e.printStackTrace();
  141 + }
  142 + }
  143 + }
  144 + return null;
  145 + }
  146 +
  147 + /**
  148 + * <li>@Description:将任务信息添加到队列中,任务分为固定任务,临时任务,目前拉取数据的任务为固定任务
  149 + * {@link ModelType#GET}
  150 + * <li>@param model
  151 + * <li>@return
  152 + * <li>创建人:maliang
  153 + * <li>创建时间:2017年3月13日
  154 + * <li>修改人:
  155 + * <li>修改时间:
  156 + */
  157 + public Boolean push(ChannelData data) {
  158 + if (template == null || data == null)
  159 + return Boolean.FALSE;
  160 + // 设置任务添加时间
  161 + /*
  162 + * model.setTs(System.currentTimeMillis()); String modelType =
  163 + * model.getType(); if (ModelType.isGet(modelType)) { return
  164 + * this.pushFixationWork(model); } else { return
  165 + * this.pushTempWork(model); }
  166 + */
  167 + boolean loop = data.getLoop();
  168 + return loop ? this.pushFixationWork(data) : this.pushTempWork(data);
  169 + }
  170 +
  171 + /**
  172 + * <li>@Description:获取队列中的数据
  173 + * <p>
  174 + * <li>@param type
  175 + * <li>@return
  176 + * <li>创建人:maliang
  177 + * <li>创建时间:2017年3月13日
  178 + * <li>修改人:
  179 + * <li>修改时间:
  180 + */
  181 + public ChannelData pull(boolean loop) {
  182 + // boolean loop = data != null && data.getLoop();
  183 + return loop ? this.pullFixationData() : this.pullTempData();
  184 + /*
  185 + * if (ModelType.isGet(type)) { return this.pullFixationModel(); } else
  186 + * { return this.pullTempModel(); }
  187 + */
  188 + }
  189 +
  190 + public RedisTemplate<Serializable, Serializable> getTemplate() {
  191 + return template;
  192 + }
  193 +
  194 + public void setTemplate(RedisTemplate<Serializable, Serializable> template) {
  195 + this.template = template;
  196 + }
  197 +
  198 +}
core.sdk/src/main/java/com/lyms/util/remote/HttpRemote.java View file @ 3bb5d83
... ... @@ -11,7 +11,7 @@
11 11 import org.apache.http.client.protocol.HttpClientContext;
12 12 import org.apache.http.entity.SerializableEntity;
13 13  
14   -import com.lyms.sycn.channel.ChannelData;
  14 +import com.lyms.sync.channel.ChannelData;
15 15  
16 16 /**
17 17 * http,https 远程调用
hospital.web/src/main/java/com/lyms/hospital/controller/RouterController.java View file @ 3bb5d83
... ... @@ -9,10 +9,10 @@
9 9 import org.springframework.web.bind.annotation.RequestMapping;
10 10 import org.springframework.web.bind.annotation.RestController;
11 11  
12   -import com.lyms.sycn.channel.ChannelData;
13 12 import com.lyms.sync.ParamsAdpter;
14 13 import com.lyms.sync.SyncHandler;
15 14 import com.lyms.sync.SyncUtils;
  15 +import com.lyms.sync.channel.ChannelData;
16 16 import com.lyms.web.controller.BaseController;
17 17  
18 18 /**
hospital.web/src/main/java/com/lyms/hospital/entity/sys/SyncDataBasic.java View file @ 3bb5d83
... ... @@ -6,7 +6,7 @@
6 6 import com.baomidou.mybatisplus.annotations.TableField;
7 7 import com.baomidou.mybatisplus.annotations.TableId;
8 8 import com.baomidou.mybatisplus.annotations.TableName;
9   -import com.lyms.sycn.channel.ChannelData;
  9 +import com.lyms.sync.channel.ChannelData;
10 10  
11 11 /**
12 12 *
hospital.web/src/main/java/com/lyms/hospital/service/sys/SyncDataBasicService.java View file @ 3bb5d83
... ... @@ -4,7 +4,7 @@
4 4 import java.util.List;
5 5  
6 6 import com.lyms.hospital.entity.sys.SyncDataBasic;
7   -import com.lyms.sycn.channel.ChannelData;
  7 +import com.lyms.sync.channel.ChannelData;
8 8 import com.lyms.web.service.BaseService;
9 9  
10 10 /**
hospital.web/src/main/java/com/lyms/hospital/service/sys/impl/SyncDataBasicServiceImpl.java View file @ 3bb5d83
... ... @@ -12,7 +12,7 @@
12 12 import com.lyms.hospital.dao.sys.SyncDataBasicMapper;
13 13 import com.lyms.hospital.entity.sys.SyncDataBasic;
14 14 import com.lyms.hospital.service.sys.SyncDataBasicService;
15   -import com.lyms.sycn.channel.ChannelData;
  15 +import com.lyms.sync.channel.ChannelData;
16 16 import com.lyms.util.JsonUtils;
17 17  
18 18 /**