Commit c0d2ad161cf83287f5c3fb74854a458a752a0ff6

Authored by 潘钊
1 parent 5ee4d437

update...

src/main/java/com/bsth/Application.java
@@ -11,7 +11,7 @@ import java.util.concurrent.ScheduledExecutorService; @@ -11,7 +11,7 @@ import java.util.concurrent.ScheduledExecutorService;
11 @SpringBootApplication 11 @SpringBootApplication
12 public class Application extends SpringBootServletInitializer { 12 public class Application extends SpringBootServletInitializer {
13 13
14 - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(5); 14 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(10);
15 15
16 @Override 16 @Override
17 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 17 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
src/main/java/com/bsth/redis/OilRedisService.java
1 package com.bsth.redis; 1 package com.bsth.redis;
2 2
3 import com.bsth.entity.OilInfo; 3 import com.bsth.entity.OilInfo;
  4 +import com.bsth.redis.util.RedisUtils;
4 import com.bsth.repository.OilInfoRepository; 5 import com.bsth.repository.OilInfoRepository;
5 import com.bsth.util.ConfigUtil; 6 import com.bsth.util.ConfigUtil;
6 import com.bsth.util.ConvertUtil; 7 import com.bsth.util.ConvertUtil;
@@ -32,6 +33,9 @@ public class OilRedisService implements CommandLineRunner { @@ -32,6 +33,9 @@ public class OilRedisService implements CommandLineRunner {
32 @Autowired 33 @Autowired
33 OilInfoRepository oilInfoRepository; 34 OilInfoRepository oilInfoRepository;
34 35
  36 + @Autowired
  37 + RedisUtils redisUtils;
  38 +
35 Logger logger = LoggerFactory.getLogger(this.getClass()); 39 Logger logger = LoggerFactory.getLogger(this.getClass());
36 40
37 private final static String REDIS_KEY_PREFIX = "oil:"; 41 private final static String REDIS_KEY_PREFIX = "oil:";
@@ -107,10 +111,9 @@ public class OilRedisService implements CommandLineRunner { @@ -107,10 +111,9 @@ public class OilRedisService implements CommandLineRunner {
107 if (!list.contains(oil)) 111 if (!list.contains(oil))
108 list.add(oil); 112 list.add(oil);
109 } 113 }
110 - //删除redis数据  
111 - redisTemplate.delete(key);  
112 - //重新写入  
113 - ops.leftPushAll(key, list); 114 +
  115 + //更新
  116 + redisTemplate.execute(redisUtils.getUpdateCallback(key, list));
114 } 117 }
115 118
116 @Override 119 @Override
src/main/java/com/bsth/redis/PlanScheduleRedisService.java
1 package com.bsth.redis; 1 package com.bsth.redis;
2 2
  3 +import com.bsth.Application;
3 import com.bsth.entity.SchedulePlanInfo; 4 import com.bsth.entity.SchedulePlanInfo;
  5 +import com.bsth.redis.util.RedisUtils;
4 import com.bsth.repository.SchedulePlanInfoRepository; 6 import com.bsth.repository.SchedulePlanInfoRepository;
  7 +import com.bsth.server_rs.base_info.line.Line;
  8 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
5 import com.bsth.util.ConfigUtil; 9 import com.bsth.util.ConfigUtil;
6 import com.bsth.util.ConvertUtil; 10 import com.bsth.util.ConvertUtil;
7 import com.google.common.collect.ArrayListMultimap; 11 import com.google.common.collect.ArrayListMultimap;
@@ -14,15 +18,17 @@ import org.springframework.core.annotation.Order; @@ -14,15 +18,17 @@ import org.springframework.core.annotation.Order;
14 import org.springframework.data.redis.core.ListOperations; 18 import org.springframework.data.redis.core.ListOperations;
15 import org.springframework.data.redis.core.RedisTemplate; 19 import org.springframework.data.redis.core.RedisTemplate;
16 import org.springframework.data.redis.serializer.StringRedisSerializer; 20 import org.springframework.data.redis.serializer.StringRedisSerializer;
  21 +import org.springframework.stereotype.Component;
17 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
18 23
19 import java.util.ArrayList; 24 import java.util.ArrayList;
20 import java.util.Date; 25 import java.util.Date;
21 import java.util.Iterator; 26 import java.util.Iterator;
22 import java.util.List; 27 import java.util.List;
  28 +import java.util.concurrent.TimeUnit;
23 29
24 /** 30 /**
25 - * 计调的 计划排班redis缓存 31 + * 计调的 计划排班redis缓存
26 * Created by panzhao on 2017/3/27. 32 * Created by panzhao on 2017/3/27.
27 */ 33 */
28 @Service 34 @Service
@@ -35,7 +41,10 @@ public class PlanScheduleRedisService implements CommandLineRunner { @@ -35,7 +41,10 @@ public class PlanScheduleRedisService implements CommandLineRunner {
35 @Autowired 41 @Autowired
36 SchedulePlanInfoRepository planInfoRepository; 42 SchedulePlanInfoRepository planInfoRepository;
37 43
38 - Logger logger = LoggerFactory.getLogger(this.getClass()); 44 + @Autowired
  45 + RedisUtils redisUtils;
  46 +
  47 + static Logger logger = LoggerFactory.getLogger(PlanScheduleRedisService.class);
39 48
40 private final static String REDIS_KEY_PREFIX = "plan:"; 49 private final static String REDIS_KEY_PREFIX = "plan:";
41 50
@@ -58,7 +67,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { @@ -58,7 +67,7 @@ public class PlanScheduleRedisService implements CommandLineRunner {
58 String key; 67 String key;
59 while (iterator.hasNext()) { 68 while (iterator.hasNext()) {
60 key = iterator.next(); 69 key = iterator.next();
61 - mergeData(key, multimap.get(key)); 70 + replace(key, multimap.get(key));
62 } 71 }
63 } catch (Exception e) { 72 } catch (Exception e) {
64 logger.error("", e); 73 logger.error("", e);
@@ -81,10 +90,20 @@ public class PlanScheduleRedisService implements CommandLineRunner { @@ -81,10 +90,20 @@ public class PlanScheduleRedisService implements CommandLineRunner {
81 if (!list.contains(plan)) 90 if (!list.contains(plan))
82 list.add(plan); 91 list.add(plan);
83 } 92 }
84 - //删除redis数据  
85 - redisTemplate.delete(key);  
86 - //重新写入  
87 - ops.leftPushAll(key, list); 93 +
  94 + //更新
  95 + redisTemplate.execute(redisUtils.getUpdateCallback(key, list));
  96 + }
  97 +
  98 + /**
  99 + * 覆盖数据
  100 + *
  101 + * @param key
  102 + * @param list
  103 + */
  104 + public void replace(String key, List<SchedulePlanInfo> list) {
  105 + key = REDIS_KEY_PREFIX + key.replaceAll("-", "");
  106 + redisTemplate.execute(redisUtils.getUpdateCallback(key, list));
88 } 107 }
89 108
90 /** 109 /**
@@ -98,6 +117,10 @@ public class PlanScheduleRedisService implements CommandLineRunner { @@ -98,6 +117,10 @@ public class PlanScheduleRedisService implements CommandLineRunner {
98 return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + lineCode + ":" + dateStr, 0, -1); 117 return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + lineCode + ":" + dateStr, 0, -1);
99 } 118 }
100 119
  120 +
  121 + @Autowired
  122 + PlanClearThread planClearThread;
  123 +
101 @Override 124 @Override
102 public void run(String... strings) throws Exception { 125 public void run(String... strings) throws Exception {
103 int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); 126 int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days"));
@@ -108,17 +131,50 @@ public class PlanScheduleRedisService implements CommandLineRunner { @@ -108,17 +131,50 @@ public class PlanScheduleRedisService implements CommandLineRunner {
108 dt = dt.minusDays(cacheDays); 131 dt = dt.minusDays(cacheDays);
109 dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); 132 dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays);
110 List<SchedulePlanInfo> list = planInfoRepository.findByDateRange(dt.toDate(), new Date()); 133 List<SchedulePlanInfo> list = planInfoRepository.findByDateRange(dt.toDate(), new Date());
111 -  
112 //写入redis 134 //写入redis
113 wirte(list); 135 wirte(list);
  136 +
  137 + //24小时清理一次计划排班数据
  138 + Application.mainServices.scheduleWithFixedDelay(planClearThread, 24, 24, TimeUnit.HOURS);
114 } 139 }
115 140
116 public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { 141 public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) {
117 rq = rq.replaceAll("-", ""); 142 rq = rq.replaceAll("-", "");
118 List<SchedulePlanInfo> rs = new ArrayList<>(); 143 List<SchedulePlanInfo> rs = new ArrayList<>();
119 - for(String lineCode : lineArray){ 144 + for (String lineCode : lineArray) {
120 rs.addAll(read(rq, lineCode)); 145 rs.addAll(read(rq, lineCode));
121 } 146 }
122 return rs; 147 return rs;
123 } 148 }
  149 +
  150 + @Component
  151 + public static class PlanClearThread extends Thread {
  152 +
  153 + @Autowired
  154 + PlanScheduleRedisService planRedisService;
  155 +
  156 + @Override
  157 + public void run() {
  158 + try {
  159 + logger.info("redis -清理计划排班");
  160 +
  161 + int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days"));
  162 + DateTime dt = new DateTime();
  163 + dt = dt.minusDays(cacheDays);
  164 + String rq = dt.toString("yyyy-MM-dd");
  165 +
  166 + List<Line> lines = LineBufferData.findAll();
  167 + for (Line line : lines) {
  168 + planRedisService.delete(line.getLineCode(), rq);
  169 + }
  170 + } catch (Exception e) {
  171 + logger.error("", e);
  172 + }
  173 + }
  174 + }
  175 +
  176 + private void delete(String lineCode, String rq) {
  177 + String key = REDIS_KEY_PREFIX + (lineCode + ":" + rq).replaceAll("-", "");
  178 + redisTemplate.delete(key);
  179 + }
124 } 180 }
src/main/java/com/bsth/redis/ScheduleRedisService.java
1 package com.bsth.redis; 1 package com.bsth.redis;
2 2
  3 +import com.bsth.Application;
3 import com.bsth.entity.ScheduleRealInfo; 4 import com.bsth.entity.ScheduleRealInfo;
  5 +import com.bsth.redis.util.RedisUtils;
4 import com.bsth.repository.ScheduleRealInfoRepository; 6 import com.bsth.repository.ScheduleRealInfoRepository;
  7 +import com.bsth.server_rs.base_info.line.Line;
  8 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
  9 +import com.bsth.server_ws.WebServiceProxy;
5 import com.bsth.util.ConfigUtil; 10 import com.bsth.util.ConfigUtil;
6 import com.bsth.util.ConvertUtil; 11 import com.bsth.util.ConvertUtil;
7 -import com.bsth.server_ws.WebServiceProxy;  
8 import com.google.common.collect.ArrayListMultimap; 12 import com.google.common.collect.ArrayListMultimap;
9 import org.joda.time.DateTime; 13 import org.joda.time.DateTime;
10 import org.slf4j.Logger; 14 import org.slf4j.Logger;
@@ -15,11 +19,13 @@ import org.springframework.core.annotation.Order; @@ -15,11 +19,13 @@ import org.springframework.core.annotation.Order;
15 import org.springframework.data.redis.core.ListOperations; 19 import org.springframework.data.redis.core.ListOperations;
16 import org.springframework.data.redis.core.RedisTemplate; 20 import org.springframework.data.redis.core.RedisTemplate;
17 import org.springframework.data.redis.serializer.StringRedisSerializer; 21 import org.springframework.data.redis.serializer.StringRedisSerializer;
  22 +import org.springframework.stereotype.Component;
18 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
19 24
20 import java.util.ArrayList; 25 import java.util.ArrayList;
21 import java.util.Iterator; 26 import java.util.Iterator;
22 import java.util.List; 27 import java.util.List;
  28 +import java.util.concurrent.TimeUnit;
23 29
24 /** 30 /**
25 * 班次 redis 缓存管理 31 * 班次 redis 缓存管理
@@ -40,7 +46,10 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -40,7 +46,10 @@ public class ScheduleRedisService implements CommandLineRunner {
40 @Autowired 46 @Autowired
41 WebServiceProxy webServiceProxy; 47 WebServiceProxy webServiceProxy;
42 48
43 - Logger logger = LoggerFactory.getLogger(this.getClass()); 49 + @Autowired
  50 + RedisUtils redisUtils;
  51 +
  52 + static Logger logger = LoggerFactory.getLogger(ScheduleRedisService.class);
44 53
45 /** 54 /**
46 * 将一批班次写入redis 55 * 将一批班次写入redis
@@ -61,7 +70,7 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -61,7 +70,7 @@ public class ScheduleRedisService implements CommandLineRunner {
61 String key; 70 String key;
62 while (iterator.hasNext()) { 71 while (iterator.hasNext()) {
63 key = iterator.next(); 72 key = iterator.next();
64 - mergeData(key, multimap.get(key)); 73 + replace(key, multimap.get(key));
65 } 74 }
66 } catch (Exception e) { 75 } catch (Exception e) {
67 logger.error("", e); 76 logger.error("", e);
@@ -84,10 +93,30 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -84,10 +93,30 @@ public class ScheduleRedisService implements CommandLineRunner {
84 if (!list.contains(sch)) 93 if (!list.contains(sch))
85 list.add(sch); 94 list.add(sch);
86 } 95 }
87 - //删除redis数据  
88 - redisTemplate.delete(key);  
89 - //重新写入  
90 - ops.leftPushAll(key, list); 96 +
  97 + //更新
  98 + redisTemplate.execute(redisUtils.getUpdateCallback(key, list));
  99 + }
  100 +
  101 + /**
  102 + * 覆盖数据
  103 + *
  104 + * @param key
  105 + * @param list
  106 + */
  107 + public void replace(String key, List<ScheduleRealInfo> list) {
  108 + key = REDIS_KEY_PREFIX + key.replaceAll("-", "");
  109 + redisTemplate.execute(redisUtils.getUpdateCallback(key, list));
  110 + }
  111 +
  112 + /**
  113 + * 删除数据
  114 + *
  115 + * @param key
  116 + */
  117 + public void delete(String lineCode, String rq) {
  118 + String key = REDIS_KEY_PREFIX + (lineCode + ":" + rq).replaceAll("-", "");
  119 + redisTemplate.delete(key);
91 } 120 }
92 121
93 /** 122 /**
@@ -103,22 +132,23 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -103,22 +132,23 @@ public class ScheduleRedisService implements CommandLineRunner {
103 132
104 /** 133 /**
105 * 返回指定日期,公司的实际排班,并按线路_车辆分组 134 * 返回指定日期,公司的实际排班,并按线路_车辆分组
106 - * (新老系统并行时调用这个函数) 135 + * (新老系统并行时调用这个函数)
  136 + *
107 * @param rq 137 * @param rq
108 * @param companyId 138 * @param companyId
109 * @return 139 * @return
110 */ 140 */
111 - public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByNbbm_bingxing(String rq, String companyId){ 141 + public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByNbbm_bingxing(String rq, String companyId) {
112 List<String> lineArray = webServiceProxy.findLinesByCompany_new(companyId); 142 List<String> lineArray = webServiceProxy.findLinesByCompany_new(companyId);
113 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create(); 143 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create();
114 144
115 rq = rq.replaceAll("-", ""); 145 rq = rq.replaceAll("-", "");
116 List<ScheduleRealInfo> list; 146 List<ScheduleRealInfo> list;
117 - for(String lineCode : lineArray){ 147 + for (String lineCode : lineArray) {
118 148
119 list = read(rq, lineCode); 149 list = read(rq, lineCode);
120 150
121 - for(ScheduleRealInfo sch : list){ 151 + for (ScheduleRealInfo sch : list) {
122 rs.put(sch.getXlBm() + "_" + sch.getClZbh(), sch); 152 rs.put(sch.getXlBm() + "_" + sch.getClZbh(), sch);
123 } 153 }
124 } 154 }
@@ -127,21 +157,22 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -127,21 +157,22 @@ public class ScheduleRedisService implements CommandLineRunner {
127 157
128 /** 158 /**
129 * 返回指定日期,公司的实际排班,并按线路_车辆分组 159 * 返回指定日期,公司的实际排班,并按线路_车辆分组
  160 + *
130 * @param rq 161 * @param rq
131 * @param companyId 162 * @param companyId
132 * @return 163 * @return
133 */ 164 */
134 - public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByNbbm(String rq, String companyId){ 165 + public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByNbbm(String rq, String companyId) {
135 List<String> lineArray = webServiceProxy.findLinesByCompany(companyId); 166 List<String> lineArray = webServiceProxy.findLinesByCompany(companyId);
136 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create(); 167 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create();
137 168
138 rq = rq.replaceAll("-", ""); 169 rq = rq.replaceAll("-", "");
139 List<ScheduleRealInfo> list; 170 List<ScheduleRealInfo> list;
140 - for(String lineCode : lineArray){ 171 + for (String lineCode : lineArray) {
141 172
142 list = read(rq, lineCode); 173 list = read(rq, lineCode);
143 174
144 - for(ScheduleRealInfo sch : list){ 175 + for (ScheduleRealInfo sch : list) {
145 rs.put(sch.getXlBm() + "_" + sch.getClZbh(), sch); 176 rs.put(sch.getXlBm() + "_" + sch.getClZbh(), sch);
146 } 177 }
147 } 178 }
@@ -150,28 +181,34 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -150,28 +181,34 @@ public class ScheduleRedisService implements CommandLineRunner {
150 181
151 /** 182 /**
152 * 返回指定日期,公司的实际排班,并按线路分组 183 * 返回指定日期,公司的实际排班,并按线路分组
  184 + *
153 * @param rq 185 * @param rq
154 * @param companyId 186 * @param companyId
155 * @return 187 * @return
156 */ 188 */
157 - public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByLine(String rq, String companyId){ 189 + public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByLine(String rq, String companyId) {
158 190
159 List<String> lineArray = webServiceProxy.findLinesByCompany(companyId); 191 List<String> lineArray = webServiceProxy.findLinesByCompany(companyId);
160 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create(); 192 ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create();
161 193
162 rq = rq.replaceAll("-", ""); 194 rq = rq.replaceAll("-", "");
163 List<ScheduleRealInfo> list; 195 List<ScheduleRealInfo> list;
164 - for(String lineCode : lineArray){ 196 + for (String lineCode : lineArray) {
165 197
166 list = read(rq, lineCode); 198 list = read(rq, lineCode);
167 199
168 - for(ScheduleRealInfo sch : list){ 200 + for (ScheduleRealInfo sch : list) {
169 rs.put(sch.getXlBm(), sch); 201 rs.put(sch.getXlBm(), sch);
170 } 202 }
171 } 203 }
172 return rs; 204 return rs;
173 } 205 }
174 206
  207 + @Autowired
  208 + ScheduleRefreshThread scheduleRefreshThread;
  209 + @Autowired
  210 + ScheduleClearThread scheduleClearThread;
  211 +
175 @Override 212 @Override
176 public void run(String... strings) throws Exception { 213 public void run(String... strings) throws Exception {
177 int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); 214 int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days"));
@@ -183,14 +220,65 @@ public class ScheduleRedisService implements CommandLineRunner { @@ -183,14 +220,65 @@ public class ScheduleRedisService implements CommandLineRunner {
183 List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDateLT(dt.toString("yyyy-MM-dd")); 220 List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDateLT(dt.toString("yyyy-MM-dd"));
184 //写入redis 221 //写入redis
185 wirte(list); 222 wirte(list);
  223 +
  224 + //定时刷新一次当日实际排班
  225 + int minute = 30;
  226 + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, minute, minute, TimeUnit.MINUTES);
  227 + //24小时清理一次实际排班数据
  228 + Application.mainServices.scheduleWithFixedDelay(scheduleClearThread, 24, 24, TimeUnit.HOURS);
186 } 229 }
187 230
188 public List<ScheduleRealInfo> findByMultiLine(List<String> lineArray, String rq) { 231 public List<ScheduleRealInfo> findByMultiLine(List<String> lineArray, String rq) {
189 rq = rq.replaceAll("-", ""); 232 rq = rq.replaceAll("-", "");
190 List<ScheduleRealInfo> rs = new ArrayList<>(); 233 List<ScheduleRealInfo> rs = new ArrayList<>();
191 - for(String lineCode : lineArray){ 234 + for (String lineCode : lineArray) {
192 rs.addAll(read(rq, lineCode)); 235 rs.addAll(read(rq, lineCode));
193 } 236 }
194 return rs; 237 return rs;
195 } 238 }
  239 +
  240 + @Component
  241 + public static class ScheduleRefreshThread extends Thread {
  242 +
  243 + @Autowired
  244 + ScheduleRealInfoRepository realInfoRepository;
  245 +
  246 + @Autowired
  247 + ScheduleRedisService scheduleRedisService;
  248 +
  249 + @Override
  250 + public void run() {
  251 + try {
  252 + DateTime dt = new DateTime();
  253 + List<ScheduleRealInfo> list = realInfoRepository.findAll(dt.toString("yyyy-MM-dd"));
  254 + scheduleRedisService.wirte(list);
  255 + } catch (Exception e) {
  256 + logger.error("", e);
  257 + }
  258 + }
  259 + }
  260 +
  261 + @Component
  262 + public static class ScheduleClearThread extends Thread {
  263 +
  264 + @Autowired
  265 + ScheduleRedisService scheduleRedisService;
  266 +
  267 + @Override
  268 + public void run() {
  269 + try {
  270 + int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days"));
  271 + DateTime dt = new DateTime();
  272 + dt = dt.minusDays(cacheDays);
  273 + String rq = dt.toString("yyyy-MM-dd");
  274 +
  275 + List<Line> lines = LineBufferData.findAll();
  276 + for (Line line : lines) {
  277 + scheduleRedisService.delete(line.getLineCode(), rq);
  278 + }
  279 + } catch (Exception e) {
  280 + logger.error("", e);
  281 + }
  282 + }
  283 + }
196 } 284 }
src/main/java/com/bsth/redis/util/RedisUtils.java 0 → 100644
  1 +package com.bsth.redis.util;
  2 +
  3 +import org.springframework.dao.DataAccessException;
  4 +import org.springframework.data.redis.core.RedisOperations;
  5 +import org.springframework.data.redis.core.SessionCallback;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by panzhao on 2017/3/30.
  12 + */
  13 +@Component
  14 +public class RedisUtils<T> {
  15 +
  16 + public SessionCallback getUpdateCallback(final String key, final List<T> list){
  17 +
  18 + SessionCallback<Object> sessionCallback = new SessionCallback<Object>() {
  19 +
  20 + @Override
  21 + public Object execute(RedisOperations redisOperations) throws DataAccessException {
  22 + redisOperations.multi();
  23 + redisOperations.delete(key);
  24 + redisOperations.opsForList().leftPushAll(key, list);
  25 + return redisOperations.exec();
  26 + }
  27 + };
  28 +
  29 + return sessionCallback;
  30 + }
  31 +}
src/main/java/com/bsth/server_rs/AuthorizeInterceptor_IN.java
@@ -57,7 +57,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor&lt;Message&gt; i @@ -57,7 +57,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor&lt;Message&gt; i
57 return ; 57 return ;
58 } 58 }
59 59
60 - //获取参数,不包括 url 路径参数 ?号之后的 60 + //获取参数,不包括 url 路径参数 只包括?号之后的
61 String queryString = StringEscapeUtils.unescapeHtml4(message.get(Message.QUERY_STRING).toString()); 61 String queryString = StringEscapeUtils.unescapeHtml4(message.get(Message.QUERY_STRING).toString());
62 MultiMap<String> params = new MultiMap<>(); 62 MultiMap<String> params = new MultiMap<>();
63 UrlEncoded.decodeTo(queryString, params, "utf-8"); 63 UrlEncoded.decodeTo(queryString, params, "utf-8");