Commit 8649cc207146a10b4eb3ae18fcb0fed45cc9ad4a

Authored by qianbao
1 parent 35a28b80

AI添加问题 历史问题记录

... ... @@ -79,6 +79,15 @@
79 79 <groupId>org.springframework.boot</groupId>
80 80 <artifactId>spring-boot-starter-thymeleaf</artifactId>
81 81 </dependency>
  82 + <dependency>
  83 + <groupId>org.springframework.boot</groupId>
  84 + <artifactId>spring-boot-starter-data-redis</artifactId>
  85 + </dependency>
  86 + <!-- 如果需要连接池,可以引入 commons-pool2 (可选) -->
  87 + <dependency>
  88 + <groupId>org.apache.commons</groupId>
  89 + <artifactId>commons-pool2</artifactId>
  90 + </dependency>
82 91  
83 92 <!-- MyBatis -->
84 93 <dependency>
... ...
src/main/java/com/xly/config/JedisUtil.java deleted
1   -//package com.xly.utils.redis;
2   -//
3   -//import java.io.ByteArrayInputStream;
4   -//import java.io.ByteArrayOutputStream;
5   -//import java.io.ObjectInputStream;
6   -//import java.io.ObjectOutputStream;
7   -//import java.util.*;
8   -//import java.util.concurrent.TimeUnit;
9   -//
10   -//import cn.hutool.core.util.StrUtil;
11   -//import cn.hutool.json.JSONUtil;
12   -//import com.alibaba.fastjson.JSONObject;
13   -//import com.google.common.collect.Sets;
14   -//import groovy.util.logging.Slf4j;
15   -//import org.slf4j.Logger;
16   -//import org.slf4j.LoggerFactory;
17   -//import org.springframework.beans.factory.annotation.Autowired;
18   -//import org.springframework.beans.factory.annotation.Value;
19   -//import org.springframework.cache.annotation.Cacheable;
20   -//import org.springframework.stereotype.Component;
21   -//
22   -//import org.springframework.util.ObjectUtils;
23   -//import redis.clients.jedis.*;
24   -//import redis.clients.jedis.BinaryClient.LIST_POSITION;
25   -//
26   -//@Component
27   -//@Slf4j
28   -//public class JedisUtil {
29   -//
30   -// private static final Logger logger = LoggerFactory.getLogger(JedisUtil.class);
31   -//
32   -// private static final String LOCK_SUCCESS = "OK";
33   -// private static final String SET_IF_NOT_EXIST = "NX";
34   -// private static final String SET_WITH_EXPIRE_TIME = "PX";
35   -// private static final String SET_WITH_EXPIRE_TIME_EX = "EX";
36   -// private static final Long RELEASE_SUCCESS = 1L;
37   -// public static final int lockWaitTime = 4000;
38   -// public static final int scanlimit = 10000;
39   -//
40   -// @Value("${spring.redis.database}")
41   -// private int indexdb;
42   -//
43   -// @Autowired
44   -// private JedisPool jedisPool;
45   -//
46   -// /**
47   -// * <p>
48   -// * 通过key获取储存在redis中的value
49   -// * </p>
50   -// * <p>
51   -// * 并释放连接
52   -// * </p>
53   -// *
54   -// * @param key
55   -// * @return 成功返回value 失败返回null
56   -// */
57   -// public String get(String key) {
58   -// Jedis jedis = null;
59   -// String value = null;
60   -// try {
61   -// jedis = jedisPool.getResource();
62   -// jedis.select(indexdb);
63   -// value = jedis.get(key);
64   -// } catch (Exception e) {
65   -// logger.error(e.getMessage());
66   -// } finally {
67   -// returnResource(jedis);
68   -// }
69   -// return value;
70   -// }
71   -// /**
72   -// * <p>
73   -// * 通过key获取储存在redis中的value
74   -// * </p>
75   -// * <p>
76   -// * 并释放连接
77   -// * </p>
78   -// *
79   -// * @param key
80   -// * @return 成功返回value 失败返回null
81   -// */
82   -// public Object getObject(String key) {
83   -// Jedis jedis = null;
84   -// Object value = null;
85   -// try {
86   -// jedis = jedisPool.getResource();
87   -// jedis.select(indexdb);
88   -// String jedV = jedis.get(key);
89   -// if(StrUtil.isNotEmpty(jedV) && JSONUtil.isJsonObj(jedV)){
90   -// value = JSONUtil.parseObj(jedV);
91   -// }else{
92   -// value = jedV;
93   -// }
94   -// } catch (Exception e) {
95   -// logger.error(e.getMessage());
96   -// } finally {
97   -// returnResource(jedis);
98   -// }
99   -// return value;
100   -// }
101   -//
102   -// /**
103   -// * 递增
104   -// * @param key 键
105   -// * @return
106   -// */
107   -// public long incr(String key, long delta){
108   -// if(delta<0){
109   -// throw new RuntimeException("递增因子必须大于0");
110   -// }
111   -// Jedis jedis = null;
112   -// try {
113   -// jedis = jedisPool.getResource();
114   -// jedis.select(indexdb);
115   -// return jedis.incrBy(key,delta);
116   -// } catch (Exception e) {
117   -//
118   -// logger.error(e.getMessage());
119   -// return 0L;
120   -// } finally {
121   -// returnResource(jedis);
122   -// }
123   -// }
124   -//
125   -// /**
126   -// * <p>
127   -// * 通过key获取储存在redis中的value
128   -// * </p>
129   -// * <p>
130   -// * 并释放连接
131   -// * </p>
132   -// *
133   -// * @param key
134   -// * @param indexdb 选择redis库 0-15
135   -// * @return 成功返回value 失败返回null
136   -// */
137   -// public byte[] get(byte[] key, int indexdb) {
138   -// Jedis jedis = null;
139   -// byte[] value = null;
140   -// try {
141   -// jedis = jedisPool.getResource();
142   -// jedis.select(indexdb);
143   -// value = jedis.get(key);
144   -// } catch (Exception e) {
145   -//
146   -// logger.error(e.getMessage());
147   -// } finally {
148   -// returnResource(jedis);
149   -// }
150   -// return value;
151   -// }
152   -//
153   -// /**
154   -// * <p>
155   -// * 向redis存入key和value,并释放连接资源
156   -// * </p>
157   -// * <p>
158   -// * 如果key已经存在 则覆盖
159   -// * </p>
160   -// *
161   -// * @param key
162   -// * @param value
163   -// * @param indexdb 选择redis库 0-15
164   -// * @return 成功 返回OK 失败返回 0
165   -// */
166   -// public String set(String key, String value, int indexdb) {
167   -// Jedis jedis = null;
168   -// try {
169   -// jedis = jedisPool.getResource();
170   -// jedis.select(indexdb);
171   -// return jedis.set(key, value);
172   -// } catch (Exception e) {
173   -//
174   -// logger.error(e.getMessage());
175   -// return "0";
176   -// } finally {
177   -// returnResource(jedis);
178   -// }
179   -// }
180   -// /**
181   -// * <p>
182   -// * 向redis存入key和value,并释放连接资源
183   -// * </p>
184   -// * <p>
185   -// * 如果key已经存在 则覆盖
186   -// * </p>
187   -// *
188   -// * @param key
189   -// * @param value
190   -// * @return 成功 返回OK 失败返回 0
191   -// */
192   -// public String set(String key, String value) {
193   -// return set( key, value, indexdb);
194   -// }
195   -// /**
196   -// * <p>
197   -// * 向redis存入key和value,并释放连接资源
198   -// * </p>
199   -// * <p>
200   -// * 如果key已经存在 则覆盖
201   -// * </p>
202   -// *
203   -// * @param key
204   -// * @param value
205   -// * @return 成功 返回OK 失败返回 0
206   -// */
207   -// public String setObject(String key, Object value) {
208   -// Jedis jedis = null;
209   -// try {
210   -// jedis = jedisPool.getResource();
211   -// jedis.select(indexdb);
212   -// String objJson = JSONUtil.toJsonStr(value);
213   -// return jedis.set( key,objJson);
214   -// } catch (Exception e) {
215   -//
216   -// logger.error(e.getMessage());
217   -// return "0";
218   -// } finally {
219   -// returnResource(jedis);
220   -// }
221   -// }
222   -//
223   -// /**
224   -// * <p>
225   -// * 向redis存入key和value,并释放连接资源
226   -// * </p>
227   -// * <p>
228   -// * 如果key已经存在 则覆盖
229   -// * </p>
230   -// *
231   -// * @param key
232   -// * @param value
233   -// * @param indexdb 选择redis库 0-15
234   -// * @return 成功 返回OK 失败返回 0
235   -// */
236   -// public String set(byte[] key, byte[] value, int indexdb) {
237   -// Jedis jedis = null;
238   -// try {
239   -// jedis = jedisPool.getResource();
240   -// jedis.select(indexdb);
241   -// return jedis.set(key, value);
242   -// } catch (Exception e) {
243   -//
244   -// logger.error(e.getMessage());
245   -// return "0";
246   -// } finally {
247   -// returnResource(jedis);
248   -// }
249   -// }
250   -//
251   -// /**
252   -// * <p>
253   -// * 删除指定的key,也可以传入一个包含key的数组
254   -// * </p>
255   -// *
256   -// * @param keys 一个key 也可以使 string 数组
257   -// * @return 返回删除成功的个数
258   -// */
259   -// public Long del(String... keys) {
260   -// Jedis jedis = null;
261   -// try {
262   -// jedis = jedisPool.getResource();
263   -// jedis.select(indexdb);
264   -// return jedis.del(keys);
265   -// } catch (Exception e) {
266   -//
267   -// logger.error(e.getMessage());
268   -// return 0L;
269   -// } finally {
270   -// returnResource(jedis);
271   -// }
272   -// }
273   -// /**
274   -// * <p>
275   -// * 删除指定的key,也可以传入一个包含key的数组
276   -// * </p>
277   -// *
278   -// * @param keysSet 一个key 也可以使 string 数组
279   -// * @return 返回删除成功的个数
280   -// */
281   -// public Long delSet(Set<String> keysSet) {
282   -// return del(keysSet.toArray(new String[keysSet.size()]));
283   -// }
284   -//
285   -// /**
286   -// * <p>
287   -// * 删除指定的key,也可以传入一个包含key的数组
288   -// * </p>
289   -// *
290   -// * @param indexdb 选择redis库 0-15
291   -// * @param keys 一个key 也可以使 string 数组
292   -// * @return 返回删除成功的个数
293   -// */
294   -// public Long del(int indexdb, String... keys) {
295   -// Jedis jedis = null;
296   -// try {
297   -// jedis = jedisPool.getResource();
298   -// jedis.select(indexdb);
299   -// return jedis.del(keys);
300   -// } catch (Exception e) {
301   -//
302   -// logger.error(e.getMessage());
303   -// return 0L;
304   -// } finally {
305   -// returnResource(jedis);
306   -// }
307   -// }
308   -//
309   -// /**
310   -// * <p>
311   -// * 删除指定的key,也可以传入一个包含key的数组
312   -// * </p>
313   -// *
314   -// * @param indexdb 选择redis库 0-15
315   -// * @param keys 一个key 也可以使 string 数组
316   -// * @return 返回删除成功的个数
317   -// */
318   -// public Long del(int indexdb, byte[]... keys) {
319   -// Jedis jedis = null;
320   -// try {
321   -// jedis = jedisPool.getResource();
322   -// jedis.select(indexdb);
323   -// return jedis.del(keys);
324   -// } catch (Exception e) {
325   -//
326   -// logger.error(e.getMessage());
327   -// return 0L;
328   -// } finally {
329   -// returnResource(jedis);
330   -// }
331   -// }
332   -//
333   -// /**
334   -// * <p>
335   -// * 通过key向指定的value值追加值
336   -// * </p>
337   -// *
338   -// * @param key
339   -// * @param str
340   -// * @return 成功返回 添加后value的长度 失败 返回 添加的 value 的长度 异常返回0L
341   -// */
342   -// public Long append(String key, String str) {
343   -// Jedis jedis = null;
344   -// Long res = null;
345   -// try {
346   -// jedis = jedisPool.getResource();
347   -// jedis.select(indexdb);
348   -// res = jedis.append(key, str);
349   -// } catch (Exception e) {
350   -// logger.error(e.getMessage());
351   -// return 0L;
352   -// } finally {
353   -// returnResource(jedis);
354   -// }
355   -// return res;
356   -// }
357   -//
358   -// /**
359   -// * <p>
360   -// * 判断key是否存在
361   -// * </p>
362   -// *
363   -// * @param key
364   -// * @return true OR false
365   -// */
366   -// public Boolean exists(String key) {
367   -// Jedis jedis = null;
368   -// try {
369   -// jedis = jedisPool.getResource();
370   -// jedis.select(indexdb);
371   -// return jedis.exists(key);
372   -// } catch (Exception e) {
373   -//
374   -// logger.error(e.getMessage());
375   -// return false;
376   -// } finally {
377   -// returnResource(jedis);
378   -// }
379   -// }
380   -//
381   -// /**
382   -// * <p>
383   -// * 清空当前数据库中的所有 key,此命令从不失败。
384   -// * </p>
385   -// *
386   -// * @return 总是返回 OK
387   -// */
388   -// public String flushDB() {
389   -// Jedis jedis = null;
390   -// try {
391   -// jedis = jedisPool.getResource();
392   -// jedis.select(indexdb);
393   -// return jedis.flushDB();
394   -// } catch (Exception e) {
395   -// logger.error(e.getMessage());
396   -// } finally {
397   -// returnResource(jedis);
398   -// }
399   -// return null;
400   -// }
401   -//
402   -// /**
403   -// * <p>
404   -// * 为给定 key 设置生存时间,当 key 过期时(生存时间为 0 ),它会被自动删除。
405   -// * </p>
406   -// *
407   -// * @param key
408   -// * @param value 过期时间,单位:秒
409   -// * @return 成功返回1 如果存在 和 发生异常 返回 0
410   -// */
411   -// public Long expire(String key, int value, int indexdb) {
412   -// Jedis jedis = null;
413   -// try {
414   -// jedis = jedisPool.getResource();
415   -// jedis.select(indexdb);
416   -// return jedis.expire(key, value);
417   -// } catch (Exception e) {
418   -// logger.error(e.getMessage());
419   -// return 0L;
420   -// } finally {
421   -// returnResource(jedis);
422   -// }
423   -// }
424   -//
425   -// /**
426   -// * 普通缓存放入并设置时间
427   -// * @param key 键
428   -// * @param value 值
429   -// * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
430   -// * @return true成功 false 失败
431   -// */
432   -// public boolean setObjectExpire(String key,Object value,long time){
433   -// String valueJson = JSONUtil.toJsonStr(value);
434   -// this.setex( key, new Long(time).intValue(), valueJson);
435   -// return true;
436   -// }
437   -//
438   -// /**
439   -// * <p>
440   -// * 以秒为单位,返回给定 key 的剩余生存时间
441   -// * </p>
442   -// *
443   -// * @param key
444   -// * @return 当 key 不存在时,返回 -2 。当 key 存在但没有设置剩余生存时间时,返回 -1 。否则,以秒为单位,返回 key
445   -// * 的剩余生存时间。 发生异常 返回 0
446   -// */
447   -// public Long ttl(String key, int indexdb) {
448   -// Jedis jedis = null;
449   -// try {
450   -// jedis = jedisPool.getResource();
451   -// jedis.select(indexdb);
452   -// return jedis.ttl(key);
453   -// } catch (Exception e) {
454   -//
455   -// logger.error(e.getMessage());
456   -// return 0L;
457   -// } finally {
458   -// returnResource(jedis);
459   -// }
460   -// }
461   -// /**
462   -// * 普通缓存放入并设置时间
463   -// * @param key 键
464   -// * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
465   -// * @return true成功 false 失败
466   -// */
467   -// public Long expireSeconds(String key,long time){
468   -// return expire( key, new Long(time).intValue(), indexdb);
469   -// }
470   -// /**
471   -// * 普通缓存放入并设置时间
472   -// * @param key 键
473   -// * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
474   -// * @return true成功 false 失败
475   -// */
476   -// public Long expireMinutes(String key,long time){
477   -// time = time * 60;
478   -// return expire( key, new Long(time).intValue(), indexdb);
479   -// }
480   -// /**
481   -// * 普通缓存放入并设置时间
482   -// * @param key 键
483   -// * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
484   -// * @return true成功 false 失败
485   -// */
486   -// public String createAndExpireMinutes(String key,String value,long time){
487   -// return setexMinutes(key,new Long(time).intValue(), value);
488   -// }
489   -//
490   -// /**
491   -// * <p>
492   -// * 移除给定 key 的生存时间,将这个 key 从『易失的』(带生存时间 key )转换成『持久的』(一个不带生存时间、永不过期的 key )
493   -// * </p>
494   -// *
495   -// * @param key
496   -// * @return 当生存时间移除成功时,返回 1 .如果 key 不存在或 key 没有设置生存时间,返回 0 , 发生异常 返回 -1
497   -// */
498   -// public Long persist(String key) {
499   -// Jedis jedis = null;
500   -// try {
501   -// jedis = jedisPool.getResource();
502   -// jedis.select(indexdb);
503   -// return jedis.persist(key);
504   -// } catch (Exception e) {
505   -//
506   -// logger.error(e.getMessage());
507   -// return -1L;
508   -// } finally {
509   -// returnResource(jedis);
510   -// }
511   -// }
512   -//
513   -// /**
514   -// * <p>
515   -// * 新增key,并将 key 的生存时间 (以秒为单位)
516   -// * </p>
517   -// *
518   -// * @param key
519   -// * @param seconds 生存时间 单位:秒
520   -// * @param value
521   -// * @return 设置成功时返回 OK 。当 seconds 参数不合法时,返回一个错误。
522   -// */
523   -// public String setex(String key, int seconds, String value) {
524   -// Jedis jedis = null;
525   -// try {
526   -// jedis = jedisPool.getResource();
527   -// jedis.select(indexdb);
528   -// return jedis.setex(key, seconds, value);
529   -// } catch (Exception e) {
530   -//
531   -// logger.error(e.getMessage());
532   -// } finally {
533   -// returnResource(jedis);
534   -// }
535   -// return null;
536   -// }
537   -// /**
538   -// * <p>
539   -// * 新增key,并将 key 的生存时间 (以秒为单位)
540   -// * </p>
541   -// *
542   -// * @param key
543   -// * @param seconds 生存时间 单位:秒
544   -// * @param value
545   -// * @return 设置成功时返回 OK 。当 seconds 参数不合法时,返回一个错误。
546   -// */
547   -// public String setexMinutes(String key, int seconds, String value) {
548   -// Jedis jedis = null;
549   -// try {
550   -// jedis = jedisPool.getResource();
551   -// jedis.select(indexdb);
552   -// seconds = seconds*60;
553   -// return jedis.setex(key, seconds, value);
554   -// } catch (Exception e) {
555   -// logger.error(e.getMessage());
556   -// } finally {
557   -// returnResource(jedis);
558   -// }
559   -// return null;
560   -// }
561   -//
562   -// /**
563   -// * <p>
564   -// * 设置key value,如果key已经存在则返回0,nx==> not exist
565   -// * </p>
566   -// *
567   -// * @param key
568   -// * @param value
569   -// * @return 成功返回1 如果存在 和 发生异常 返回 0
570   -// */
571   -// public Long setnx(String key, String value) {
572   -// Jedis jedis = null;
573   -// try {
574   -// jedis = jedisPool.getResource();
575   -// jedis.select(indexdb);
576   -// return jedis.setnx(key, value);
577   -// } catch (Exception e) {
578   -//
579   -// logger.error(e.getMessage());
580   -// return 0L;
581   -// } finally {
582   -// returnResource(jedis);
583   -// }
584   -// }
585   -//
586   -// /**
587   -// * <p>
588   -// * 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。
589   -// * </p>
590   -// * <p>
591   -// * 当 key 存在但不是字符串类型时,返回一个错误。
592   -// * </p>
593   -// *
594   -// * @param key
595   -// * @param value
596   -// * @return 返回给定 key 的旧值。当 key 没有旧值时,也即是, key 不存在时,返回 nil
597   -// */
598   -// public String getSet(String key, String value) {
599   -// Jedis jedis = null;
600   -// try {
601   -// jedis = jedisPool.getResource();
602   -// jedis.select(indexdb);
603   -// return jedis.getSet(key, value);
604   -// } catch (Exception e) {
605   -//
606   -// logger.error(e.getMessage());
607   -// } finally {
608   -// returnResource(jedis);
609   -// }
610   -// return null;
611   -// }
612   -//
613   -// /**
614   -// * <p>
615   -// * 设置key value并制定这个键值的有效期
616   -// * </p>
617   -// *
618   -// * @param key
619   -// * @param value
620   -// * @param seconds 单位:秒
621   -// * @return 成功返回OK 失败和异常返回null
622   -// */
623   -// public String setex(String key, String value, int seconds) {
624   -// Jedis jedis = null;
625   -// String res = null;
626   -// try {
627   -// jedis = jedisPool.getResource();
628   -// jedis.select(indexdb);
629   -// res = jedis.setex(key, seconds, value);
630   -// } catch (Exception e) {
631   -//
632   -// logger.error(e.getMessage());
633   -// } finally {
634   -// returnResource(jedis);
635   -// }
636   -// return res;
637   -// }
638   -//
639   -// /**
640   -// * <p>
641   -// * 通过key 和offset 从指定的位置开始将原先value替换
642   -// * </p>
643   -// * <p>
644   -// * 下标从0开始,offset表示从offset下标开始替换
645   -// * </p>
646   -// * <p>
647   -// * 如果替换的字符串长度过小则会这样
648   -// * </p>
649   -// * <p>
650   -// * example:
651   -// * </p>
652   -// * <p>
653   -// * value : bigsea@zto.cn
654   -// * </p>
655   -// * <p>
656   -// * str : abc
657   -// * </p>
658   -// * <P>
659   -// * 从下标7开始替换 则结果为
660   -// * </p>
661   -// * <p>
662   -// * RES : bigsea.abc.cn
663   -// * </p>
664   -// *
665   -// * @param key
666   -// * @param str
667   -// * @param offset 下标位置
668   -// * @return 返回替换后 value 的长度
669   -// */
670   -// public Long setrange(String key, String str, int offset) {
671   -// Jedis jedis = null;
672   -// try {
673   -// jedis = jedisPool.getResource();
674   -// jedis.select(indexdb);
675   -// return jedis.setrange(key, offset, str);
676   -// } catch (Exception e) {
677   -//
678   -// logger.error(e.getMessage());
679   -// return 0L;
680   -// } finally {
681   -// returnResource(jedis);
682   -// }
683   -// }
684   -//
685   -// /**
686   -// * <p>
687   -// * 通过批量的key获取批量的value
688   -// * </p>
689   -// *
690   -// * @param keys string数组 也可以是一个key
691   -// * @return 成功返回value的集合, 失败返回null的集合 ,异常返回空
692   -// */
693   -// public List<String> mget(String... keys) {
694   -// Jedis jedis = null;
695   -// List<String> values = null;
696   -// try {
697   -// jedis = jedisPool.getResource();
698   -// jedis.select(indexdb);
699   -// values = jedis.mget(keys);
700   -// } catch (Exception e) {
701   -//
702   -// logger.error(e.getMessage());
703   -// } finally {
704   -// returnResource(jedis);
705   -// }
706   -// return values;
707   -// }
708   -//
709   -// /**
710   -// * <p>
711   -// * 批量的设置key:value,可以一个
712   -// * </p>
713   -// * <p>
714   -// * example:
715   -// * </p>
716   -// * <p>
717   -// * obj.mset(new String[]{"key2","value1","key2","value2"})
718   -// * </p>
719   -// *
720   -// * @param keysvalues
721   -// * @return 成功返回OK 失败 异常 返回 null
722   -// */
723   -// public String mset(String... keysvalues) {
724   -// Jedis jedis = null;
725   -// String res = null;
726   -// try {
727   -// jedis = jedisPool.getResource();
728   -// jedis.select(indexdb);
729   -// res = jedis.mset(keysvalues);
730   -// } catch (Exception e) {
731   -//
732   -// logger.error(e.getMessage());
733   -// } finally {
734   -// returnResource(jedis);
735   -// }
736   -// return res;
737   -// }
738   -//
739   -// /**
740   -// * <p>
741   -// * 批量的设置key:value,可以一个,如果key已经存在则会失败,操作会回滚
742   -// * </p>
743   -// * <p>
744   -// * example:
745   -// * </p>
746   -// * <p>
747   -// * obj.msetnx(new String[]{"key2","value1","key2","value2"})
748   -// * </p>
749   -// *
750   -// * @param keysvalues
751   -// * @return 成功返回1 失败返回0
752   -// */
753   -// public Long msetnx(String... keysvalues) {
754   -// Jedis jedis = null;
755   -// Long res = 0L;
756   -// try {
757   -// jedis = jedisPool.getResource();
758   -// jedis.select(indexdb);
759   -// res = jedis.msetnx(keysvalues);
760   -// } catch (Exception e) {
761   -//
762   -// logger.error(e.getMessage());
763   -// } finally {
764   -// returnResource(jedis);
765   -// }
766   -// return res;
767   -// }
768   -//
769   -// /**
770   -// * <p>
771   -// * 设置key的值,并返回一个旧值
772   -// * </p>
773   -// *
774   -// * @param key
775   -// * @param value
776   -// * @return 旧值 如果key不存在 则返回null
777   -// */
778   -// public String getset(String key, String value) {
779   -// Jedis jedis = null;
780   -// String res = null;
781   -// try {
782   -// jedis = jedisPool.getResource();
783   -// jedis.select(indexdb);
784   -// res = jedis.getSet(key, value);
785   -// } catch (Exception e) {
786   -//
787   -// logger.error(e.getMessage());
788   -// } finally {
789   -// returnResource(jedis);
790   -// }
791   -// return res;
792   -// }
793   -//
794   -// /**
795   -// * <p>
796   -// * 通过下标 和key 获取指定下标位置的 value
797   -// * </p>
798   -// *
799   -// * @param key
800   -// * @param startOffset 开始位置 从0 开始 负数表示从右边开始截取
801   -// * @param endOffset
802   -// * @return 如果没有返回null
803   -// */
804   -// public String getrange(String key, int startOffset, int endOffset) {
805   -// Jedis jedis = null;
806   -// String res = null;
807   -// try {
808   -// jedis = jedisPool.getResource();
809   -// jedis.select(indexdb);
810   -// res = jedis.getrange(key, startOffset, endOffset);
811   -// } catch (Exception e) {
812   -//
813   -// logger.error(e.getMessage());
814   -// } finally {
815   -// returnResource(jedis);
816   -// }
817   -// return res;
818   -// }
819   -//
820   -// /**
821   -// * <p>
822   -// * 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
823   -// * </p>
824   -// *
825   -// * @param key
826   -// * @return 加值后的结果
827   -// */
828   -// public Long incr(String key) {
829   -// Jedis jedis = null;
830   -// Long res = null;
831   -// try {
832   -// jedis = jedisPool.getResource();
833   -// jedis.select(indexdb);
834   -// res = jedis.incr(key);
835   -// } catch (Exception e) {
836   -//
837   -// logger.error(e.getMessage());
838   -// } finally {
839   -// returnResource(jedis);
840   -// }
841   -// return res;
842   -// }
843   -//
844   -// /**
845   -// * <p>
846   -// * 通过key给指定的value加值,如果key不存在,则这是value为该值
847   -// * </p>
848   -// *
849   -// * @param key
850   -// * @param integer
851   -// * @return
852   -// */
853   -// public Long incrBy(String key, Long integer) {
854   -// Jedis jedis = null;
855   -// Long res = null;
856   -// try {
857   -// jedis = jedisPool.getResource();
858   -// jedis.select(indexdb);
859   -// res = jedis.incrBy(key, integer);
860   -// } catch (Exception e) {
861   -//
862   -// logger.error(e.getMessage());
863   -// } finally {
864   -// returnResource(jedis);
865   -// }
866   -// return res;
867   -// }
868   -//
869   -// /**
870   -// * <p>
871   -// * 对key的值做减减操作,如果key不存在,则设置key为-1
872   -// * </p>
873   -// *
874   -// * @param key
875   -// * @return
876   -// */
877   -// public Long decr(String key) {
878   -// Jedis jedis = null;
879   -// Long res = null;
880   -// try {
881   -// jedis = jedisPool.getResource();
882   -// jedis.select(indexdb);
883   -// res = jedis.decr(key);
884   -// } catch (Exception e) {
885   -//
886   -// logger.error(e.getMessage());
887   -// } finally {
888   -// returnResource(jedis);
889   -// }
890   -// return res;
891   -// }
892   -//
893   -// /**
894   -// * <p>
895   -// * 减去指定的值
896   -// * </p>
897   -// *
898   -// * @param key
899   -// * @param integer
900   -// * @return
901   -// */
902   -// public Long decrBy(String key, Long integer) {
903   -// Jedis jedis = null;
904   -// Long res = null;
905   -// try {
906   -// jedis = jedisPool.getResource();
907   -// jedis.select(indexdb);
908   -// res = jedis.decrBy(key, integer);
909   -// } catch (Exception e) {
910   -//
911   -// logger.error(e.getMessage());
912   -// } finally {
913   -// returnResource(jedis);
914   -// }
915   -// return res;
916   -// }
917   -//
918   -// /**
919   -// * <p>
920   -// * 通过key获取value值的长度
921   -// * </p>
922   -// *
923   -// * @param key
924   -// * @return 失败返回null
925   -// */
926   -// public Long serlen(String key) {
927   -// Jedis jedis = null;
928   -// Long res = null;
929   -// try {
930   -// jedis = jedisPool.getResource();
931   -// jedis.select(indexdb);
932   -// res = jedis.strlen(key);
933   -// } catch (Exception e) {
934   -//
935   -// logger.error(e.getMessage());
936   -// } finally {
937   -// returnResource(jedis);
938   -// }
939   -// return res;
940   -// }
941   -//
942   -// /**
943   -// * <p>
944   -// * 通过key给field设置指定的值,如果key不存在,则先创建
945   -// * </p>
946   -// *
947   -// * @param key
948   -// * @param field 字段
949   -// * @param value
950   -// * @return 如果存在返回0 异常返回null
951   -// */
952   -// public Long hset(String key, String field, String value) {
953   -// Jedis jedis = null;
954   -// Long res = null;
955   -// try {
956   -// jedis = jedisPool.getResource();
957   -// jedis.select(indexdb);
958   -// res = jedis.hset(key, field, value);
959   -// } catch (Exception e) {
960   -//
961   -// logger.error(e.getMessage());
962   -// } finally {
963   -// returnResource(jedis);
964   -// }
965   -// return res;
966   -// }
967   -//
968   -// /**
969   -// * <p>
970   -// * 通过key给field设置指定的值,如果key不存在则先创建,如果field已经存在,返回0
971   -// * </p>
972   -// *
973   -// * @param key
974   -// * @param field
975   -// * @param value
976   -// * @return
977   -// */
978   -// public Long hsetnx(String key, String field, String value) {
979   -// Jedis jedis = null;
980   -// Long res = null;
981   -// try {
982   -// jedis = jedisPool.getResource();
983   -// jedis.select(indexdb);
984   -// res = jedis.hsetnx(key, field, value);
985   -// } catch (Exception e) {
986   -//
987   -// logger.error(e.getMessage());
988   -// } finally {
989   -// returnResource(jedis);
990   -// }
991   -// return res;
992   -// }
993   -//
994   -// /**
995   -// * <p>
996   -// * 通过key同时设置 hash的多个field
997   -// * </p>
998   -// *
999   -// * @param key
1000   -// * @param hash
1001   -// * @return 返回OK 异常返回null
1002   -// */
1003   -// public String hmset(String key, Map<String, String> hash, int indexdb) {
1004   -// Jedis jedis = null;
1005   -// String res = null;
1006   -// try {
1007   -// jedis = jedisPool.getResource();
1008   -// jedis.select(indexdb);
1009   -// res = jedis.hmset(key, hash);
1010   -// } catch (Exception e) {
1011   -//
1012   -// logger.error(e.getMessage());
1013   -// } finally {
1014   -// returnResource(jedis);
1015   -// }
1016   -// return res;
1017   -// }
1018   -//
1019   -// /**
1020   -// * <p>
1021   -// * 通过key 和 field 获取指定的 value
1022   -// * </p>
1023   -// *
1024   -// * @param key
1025   -// * @param field
1026   -// * @return 没有返回null
1027   -// */
1028   -// public String hget(String key, String field) {
1029   -// Jedis jedis = null;
1030   -// String res = null;
1031   -// try {
1032   -// jedis = jedisPool.getResource();
1033   -// jedis.select(indexdb);
1034   -// res = jedis.hget(key, field);
1035   -// } catch (Exception e) {
1036   -//
1037   -// logger.error(e.getMessage());
1038   -// } finally {
1039   -// returnResource(jedis);
1040   -// }
1041   -// return res;
1042   -// }
1043   -//
1044   -// /**
1045   -// * <p>
1046   -// * 通过key 和 fields 获取指定的value 如果没有对应的value则返回null
1047   -// * </p>
1048   -// *
1049   -// * @param key
1050   -// * @param fields 可以使 一个String 也可以是 String数组
1051   -// * @return
1052   -// */
1053   -// public List<String> hmget(String key, int indexdb, String... fields) {
1054   -// Jedis jedis = null;
1055   -// List<String> res = null;
1056   -// try {
1057   -// jedis = jedisPool.getResource();
1058   -// jedis.select(indexdb);
1059   -// res = jedis.hmget(key, fields);
1060   -// } catch (Exception e) {
1061   -//
1062   -// logger.error(e.getMessage());
1063   -// } finally {
1064   -// returnResource(jedis);
1065   -// }
1066   -// return res;
1067   -// }
1068   -//
1069   -// /**
1070   -// * <p>
1071   -// * 通过key给指定的field的value加上给定的值
1072   -// * </p>
1073   -// *
1074   -// * @param key
1075   -// * @param field
1076   -// * @param value
1077   -// * @return
1078   -// */
1079   -// public Long hincrby(String key, String field, Long value) {
1080   -// Jedis jedis = null;
1081   -// Long res = null;
1082   -// try {
1083   -// jedis = jedisPool.getResource();
1084   -// jedis.select(indexdb);
1085   -// res = jedis.hincrBy(key, field, value);
1086   -// } catch (Exception e) {
1087   -//
1088   -// logger.error(e.getMessage());
1089   -// } finally {
1090   -// returnResource(jedis);
1091   -// }
1092   -// return res;
1093   -// }
1094   -//
1095   -// /**
1096   -// * <p>
1097   -// * 通过key和field判断是否有指定的value存在
1098   -// * </p>
1099   -// *
1100   -// * @param key
1101   -// * @param field
1102   -// * @return
1103   -// */
1104   -// public Boolean hexists(String key, String field) {
1105   -// Jedis jedis = null;
1106   -// Boolean res = false;
1107   -// try {
1108   -// jedis = jedisPool.getResource();
1109   -// jedis.select(indexdb);
1110   -// res = jedis.hexists(key, field);
1111   -// } catch (Exception e) {
1112   -//
1113   -// logger.error(e.getMessage());
1114   -// } finally {
1115   -// returnResource(jedis);
1116   -// }
1117   -// return res;
1118   -// }
1119   -//
1120   -// /**
1121   -// * <p>
1122   -// * 通过key返回field的数量
1123   -// * </p>
1124   -// *
1125   -// * @param key
1126   -// * @return
1127   -// */
1128   -// public Long hlen(String key) {
1129   -// Jedis jedis = null;
1130   -// Long res = null;
1131   -// try {
1132   -// jedis = jedisPool.getResource();
1133   -// jedis.select(indexdb);
1134   -// res = jedis.hlen(key);
1135   -// } catch (Exception e) {
1136   -//
1137   -// logger.error(e.getMessage());
1138   -// } finally {
1139   -// returnResource(jedis);
1140   -// }
1141   -// return res;
1142   -//
1143   -// }
1144   -//
1145   -// /**
1146   -// * <p>
1147   -// * 通过key 删除指定的 field
1148   -// * </p>
1149   -// *
1150   -// * @param key
1151   -// * @param fields 可以是 一个 field 也可以是 一个数组
1152   -// * @return
1153   -// */
1154   -// public Long hdel(String key, String... fields) {
1155   -// Jedis jedis = null;
1156   -// Long res = null;
1157   -// try {
1158   -// jedis = jedisPool.getResource();
1159   -// jedis.select(indexdb);
1160   -// res = jedis.hdel(key, fields);
1161   -// } catch (Exception e) {
1162   -//
1163   -// logger.error(e.getMessage());
1164   -// } finally {
1165   -// returnResource(jedis);
1166   -// }
1167   -// return res;
1168   -// }
1169   -//
1170   -// /**
1171   -// * <p>
1172   -// * 通过key返回所有的field
1173   -// * </p>
1174   -// *
1175   -// * @param key
1176   -// * @return
1177   -// */
1178   -// public Set<String> hkeys(String key) {
1179   -// Jedis jedis = null;
1180   -// Set<String> res = null;
1181   -// try {
1182   -// jedis = jedisPool.getResource();
1183   -// jedis.select(indexdb);
1184   -// res = jedis.hkeys(key);
1185   -// } catch (Exception e) {
1186   -//
1187   -// logger.error(e.getMessage());
1188   -// } finally {
1189   -// returnResource(jedis);
1190   -// }
1191   -// return res;
1192   -// }
1193   -//
1194   -// /**
1195   -// * <p>
1196   -// * 通过key返回所有和key有关的value
1197   -// * </p>
1198   -// *
1199   -// * @param key
1200   -// * @return
1201   -// */
1202   -// public List<String> hvals(String key) {
1203   -// Jedis jedis = null;
1204   -// List<String> res = null;
1205   -// try {
1206   -// jedis = jedisPool.getResource();
1207   -// jedis.select(indexdb);
1208   -// res = jedis.hvals(key);
1209   -// } catch (Exception e) {
1210   -//
1211   -// logger.error(e.getMessage());
1212   -// } finally {
1213   -// returnResource(jedis);
1214   -// }
1215   -// return res;
1216   -// }
1217   -//
1218   -// /**
1219   -// * <p>
1220   -// * 通过key获取所有的field和value
1221   -// * </p>
1222   -// *
1223   -// * @param key
1224   -// * @return
1225   -// */
1226   -// public Map<String, String> hgetall(String key, int indexdb) {
1227   -// Jedis jedis = null;
1228   -// Map<String, String> res = null;
1229   -// try {
1230   -// jedis = jedisPool.getResource();
1231   -// jedis.select(indexdb);
1232   -// res = jedis.hgetAll(key);
1233   -// } catch (Exception e) {
1234   -// logger.error(e.getMessage());
1235   -// } finally {
1236   -// returnResource(jedis);
1237   -// }
1238   -// return res;
1239   -// }
1240   -//
1241   -// /**
1242   -// * <p>
1243   -// * 通过key向list头部添加字符串
1244   -// * </p>
1245   -// *
1246   -// * @param key
1247   -// * @param strs 可以使一个string 也可以使string数组
1248   -// * @return 返回list的value个数
1249   -// */
1250   -// public Long lpush(int indexdb, String key, String... strs) {
1251   -// Jedis jedis = null;
1252   -// Long res = null;
1253   -// try {
1254   -// jedis = jedisPool.getResource();
1255   -// jedis.select(indexdb);
1256   -// res = jedis.lpush(key, strs);
1257   -// } catch (Exception e) {
1258   -//
1259   -// logger.error(e.getMessage());
1260   -// } finally {
1261   -// returnResource(jedis);
1262   -// }
1263   -// return res;
1264   -// }
1265   -//
1266   -// /**
1267   -// * <p>
1268   -// * 通过key向list尾部添加字符串
1269   -// * </p>
1270   -// *
1271   -// * @param key
1272   -// * @param strs 可以使一个string 也可以使string数组
1273   -// * @return 返回list的value个数
1274   -// */
1275   -// public Long rpush(String key, String... strs) {
1276   -// Jedis jedis = null;
1277   -// Long res = null;
1278   -// try {
1279   -// jedis = jedisPool.getResource();
1280   -// jedis.select(indexdb);
1281   -// res = jedis.rpush(key, strs);
1282   -// } catch (Exception e) {
1283   -//
1284   -// logger.error(e.getMessage());
1285   -// } finally {
1286   -// returnResource(jedis);
1287   -// }
1288   -// return res;
1289   -// }
1290   -//
1291   -// /**
1292   -// * <p>
1293   -// * 通过key在list指定的位置之前或者之后 添加字符串元素
1294   -// * </p>
1295   -// *
1296   -// * @param key
1297   -// * @param where LIST_POSITION枚举类型
1298   -// * @param pivot list里面的value
1299   -// * @param value 添加的value
1300   -// * @return
1301   -// */
1302   -// public Long linsert(String key, LIST_POSITION where, String pivot,
1303   -// String value) {
1304   -// Jedis jedis = null;
1305   -// Long res = null;
1306   -// try {
1307   -// jedis = jedisPool.getResource();
1308   -// jedis.select(indexdb);
1309   -// res = jedis.linsert(key, where, pivot, value);
1310   -// } catch (Exception e) {
1311   -//
1312   -// logger.error(e.getMessage());
1313   -// } finally {
1314   -// returnResource(jedis);
1315   -// }
1316   -// return res;
1317   -// }
1318   -//
1319   -// /**
1320   -// * <p>
1321   -// * 通过key设置list指定下标位置的value
1322   -// * </p>
1323   -// * <p>
1324   -// * 如果下标超过list里面value的个数则报错
1325   -// * </p>
1326   -// *
1327   -// * @param key
1328   -// * @param index 从0开始
1329   -// * @param value
1330   -// * @return 成功返回OK
1331   -// */
1332   -// public String lset(String key, Long index, String value) {
1333   -// Jedis jedis = null;
1334   -// String res = null;
1335   -// try {
1336   -// jedis = jedisPool.getResource();
1337   -// jedis.select(indexdb);
1338   -// res = jedis.lset(key, index, value);
1339   -// } catch (Exception e) {
1340   -//
1341   -// logger.error(e.getMessage());
1342   -// } finally {
1343   -// returnResource(jedis);
1344   -// }
1345   -// return res;
1346   -// }
1347   -//
1348   -// /**
1349   -// * <p>
1350   -// * 通过key从对应的list中删除指定的count个 和 value相同的元素
1351   -// * </p>
1352   -// *
1353   -// * @param key
1354   -// * @param count 当count为0时删除全部
1355   -// * @param value
1356   -// * @return 返回被删除的个数
1357   -// */
1358   -// public Long lrem(String key, long count, String value) {
1359   -// Jedis jedis = null;
1360   -// Long res = null;
1361   -// try {
1362   -// jedis = jedisPool.getResource();
1363   -// jedis.select(indexdb);
1364   -// res = jedis.lrem(key, count, value);
1365   -// } catch (Exception e) {
1366   -//
1367   -// logger.error(e.getMessage());
1368   -// } finally {
1369   -// returnResource(jedis);
1370   -// }
1371   -// return res;
1372   -// }
1373   -//
1374   -// /**
1375   -// * <p>
1376   -// * 通过key保留list中从strat下标开始到end下标结束的value值
1377   -// * </p>
1378   -// *
1379   -// * @param key
1380   -// * @param start
1381   -// * @param end
1382   -// * @return 成功返回OK
1383   -// */
1384   -// public String ltrim(String key, long start, long end) {
1385   -// Jedis jedis = null;
1386   -// String res = null;
1387   -// try {
1388   -// jedis = jedisPool.getResource();
1389   -// jedis.select(indexdb);
1390   -// res = jedis.ltrim(key, start, end);
1391   -// } catch (Exception e) {
1392   -//
1393   -// logger.error(e.getMessage());
1394   -// } finally {
1395   -// returnResource(jedis);
1396   -// }
1397   -// return res;
1398   -// }
1399   -//
1400   -// /**
1401   -// * <p>
1402   -// * 通过key从list的头部删除一个value,并返回该value
1403   -// * </p>
1404   -// *
1405   -// * @param key
1406   -// * @return
1407   -// */
1408   -// synchronized public String lpop(String key) {
1409   -// Jedis jedis = null;
1410   -// String res = null;
1411   -// try {
1412   -// jedis = jedisPool.getResource();
1413   -// jedis.select(indexdb);
1414   -// res = jedis.lpop(key);
1415   -// } catch (Exception e) {
1416   -//
1417   -// logger.error(e.getMessage());
1418   -// } finally {
1419   -// returnResource(jedis);
1420   -// }
1421   -// return res;
1422   -// }
1423   -//
1424   -// /**
1425   -// * <p>
1426   -// * 通过key从list尾部删除一个value,并返回该元素
1427   -// * </p>
1428   -// *
1429   -// * @param key
1430   -// * @return
1431   -// */
1432   -// synchronized public String rpop(String key, int indexdb) {
1433   -// Jedis jedis = null;
1434   -// String res = null;
1435   -// try {
1436   -// jedis = jedisPool.getResource();
1437   -// jedis.select(indexdb);
1438   -// res = jedis.rpop(key);
1439   -// } catch (Exception e) {
1440   -//
1441   -// logger.error(e.getMessage());
1442   -// } finally {
1443   -// returnResource(jedis);
1444   -// }
1445   -// return res;
1446   -// }
1447   -//
1448   -// /**
1449   -// * <p>
1450   -// * 通过key从一个list的尾部删除一个value并添加到另一个list的头部,并返回该value
1451   -// * </p>
1452   -// * <p>
1453   -// * 如果第一个list为空或者不存在则返回null
1454   -// * </p>
1455   -// *
1456   -// * @param srckey
1457   -// * @param dstkey
1458   -// * @return
1459   -// */
1460   -// public String rpoplpush(String srckey, String dstkey, int indexdb) {
1461   -// Jedis jedis = null;
1462   -// String res = null;
1463   -// try {
1464   -// jedis = jedisPool.getResource();
1465   -// jedis.select(indexdb);
1466   -// res = jedis.rpoplpush(srckey, dstkey);
1467   -// } catch (Exception e) {
1468   -//
1469   -// logger.error(e.getMessage());
1470   -// } finally {
1471   -// returnResource(jedis);
1472   -// }
1473   -// return res;
1474   -// }
1475   -//
1476   -// /**
1477   -// * <p>
1478   -// * 通过key获取list中指定下标位置的value
1479   -// * </p>
1480   -// *
1481   -// * @param key
1482   -// * @param index
1483   -// * @return 如果没有返回null
1484   -// */
1485   -// public String lindex(String key, long index) {
1486   -// Jedis jedis = null;
1487   -// String res = null;
1488   -// try {
1489   -// jedis = jedisPool.getResource();
1490   -// jedis.select(indexdb);
1491   -// res = jedis.lindex(key, index);
1492   -// } catch (Exception e) {
1493   -//
1494   -// logger.error(e.getMessage());
1495   -// } finally {
1496   -// returnResource(jedis);
1497   -// }
1498   -// return res;
1499   -// }
1500   -//
1501   -// /**
1502   -// * <p>
1503   -// * 通过key返回list的长度
1504   -// * </p>
1505   -// *
1506   -// * @param key
1507   -// * @return
1508   -// */
1509   -// public Long llen(String key) {
1510   -// Jedis jedis = null;
1511   -// Long res = null;
1512   -// try {
1513   -// jedis = jedisPool.getResource();
1514   -// jedis.select(indexdb);
1515   -// res = jedis.llen(key);
1516   -// } catch (Exception e) {
1517   -//
1518   -// logger.error(e.getMessage());
1519   -// } finally {
1520   -// returnResource(jedis);
1521   -// }
1522   -// return res;
1523   -// }
1524   -//
1525   -// /**
1526   -// * <p>
1527   -// * 通过key获取list指定下标位置的value
1528   -// * </p>
1529   -// * <p>
1530   -// * 如果start 为 0 end 为 -1 则返回全部的list中的value
1531   -// * </p>
1532   -// *
1533   -// * @param key
1534   -// * @param start
1535   -// * @param end
1536   -// * @return
1537   -// */
1538   -// public List<String> lrange(String key, long start, long end, int indexdb) {
1539   -// Jedis jedis = null;
1540   -// List<String> res = null;
1541   -// try {
1542   -// jedis = jedisPool.getResource();
1543   -// jedis.select(indexdb);
1544   -// res = jedis.lrange(key, start, end);
1545   -// } catch (Exception e) {
1546   -//
1547   -// logger.error(e.getMessage());
1548   -// } finally {
1549   -// returnResource(jedis);
1550   -// }
1551   -// return res;
1552   -// }
1553   -//
1554   -// /**
1555   -// * <p>
1556   -// * 将列表 key 下标为 index 的元素的值设置为 value
1557   -// * </p>
1558   -// *
1559   -// * @param key
1560   -// * @param index
1561   -// * @param value
1562   -// * @return 操作成功返回 ok ,否则返回错误信息
1563   -// */
1564   -// public String lset(String key, long index, String value) {
1565   -// Jedis jedis = null;
1566   -// try {
1567   -// jedis = jedisPool.getResource();
1568   -// jedis.select(indexdb);
1569   -// return jedis.lset(key, index, value);
1570   -// } catch (Exception e) {
1571   -//
1572   -// logger.error(e.getMessage());
1573   -// } finally {
1574   -// returnResource(jedis);
1575   -// }
1576   -// return null;
1577   -// }
1578   -//
1579   -// /**
1580   -// * <p>
1581   -// * 返回给定排序后的结果
1582   -// * </p>
1583   -// *
1584   -// * @param key
1585   -// * @param sortingParameters
1586   -// * @return 返回列表形式的排序结果
1587   -// */
1588   -// public List<String> sort(String key, SortingParams sortingParameters) {
1589   -// Jedis jedis = null;
1590   -// try {
1591   -// jedis = jedisPool.getResource();
1592   -// jedis.select(indexdb);
1593   -// return jedis.sort(key, sortingParameters);
1594   -// } catch (Exception e) {
1595   -//
1596   -// logger.error(e.getMessage());
1597   -// } finally {
1598   -// returnResource(jedis);
1599   -// }
1600   -// return null;
1601   -// }
1602   -//
1603   -// /**
1604   -// * <p>
1605   -// * 返回排序后的结果,排序默认以数字作为对象,值被解释为双精度浮点数,然后进行比较。
1606   -// * </p>
1607   -// *
1608   -// * @param key
1609   -// * @return 返回列表形式的排序结果
1610   -// */
1611   -// public List<String> sort(String key) {
1612   -// Jedis jedis = null;
1613   -// try {
1614   -// jedis = jedisPool.getResource();
1615   -// jedis.select(indexdb);
1616   -// return jedis.sort(key);
1617   -// } catch (Exception e) {
1618   -//
1619   -// logger.error(e.getMessage());
1620   -// } finally {
1621   -// returnResource(jedis);
1622   -// }
1623   -// return null;
1624   -// }
1625   -//
1626   -// /**
1627   -// * <p>
1628   -// * 通过key向指定的set中添加value
1629   -// * </p>
1630   -// *
1631   -// * @param key
1632   -// * @param members 可以是一个String 也可以是一个String数组
1633   -// * @return 添加成功的个数
1634   -// */
1635   -// public Long sadd(String key, String... members) {
1636   -// Jedis jedis = null;
1637   -// Long res = null;
1638   -// try {
1639   -// jedis = jedisPool.getResource();
1640   -// jedis.select(indexdb);
1641   -// res = jedis.sadd(key, members);
1642   -// } catch (Exception e) {
1643   -//
1644   -// logger.error(e.getMessage());
1645   -// } finally {
1646   -// returnResource(jedis);
1647   -// }
1648   -// return res;
1649   -// }
1650   -//
1651   -// /**
1652   -// * <p>
1653   -// * 通过key删除set中对应的value值
1654   -// * </p>
1655   -// *
1656   -// * @param key
1657   -// * @param members 可以是一个String 也可以是一个String数组
1658   -// * @return 删除的个数
1659   -// */
1660   -// public Long srem(String key, String... members) {
1661   -// Jedis jedis = null;
1662   -// Long res = null;
1663   -// try {
1664   -// jedis = jedisPool.getResource();
1665   -// jedis.select(indexdb);
1666   -// res = jedis.srem(key, members);
1667   -// } catch (Exception e) {
1668   -//
1669   -// logger.error(e.getMessage());
1670   -// } finally {
1671   -// returnResource(jedis);
1672   -// }
1673   -// return res;
1674   -// }
1675   -//
1676   -// /**
1677   -// * <p>
1678   -// * 通过key随机删除一个set中的value并返回该值
1679   -// * </p>
1680   -// *
1681   -// * @param key
1682   -// * @return
1683   -// */
1684   -// public String spop(String key) {
1685   -// Jedis jedis = null;
1686   -// String res = null;
1687   -// try {
1688   -// jedis = jedisPool.getResource();
1689   -// jedis.select(indexdb);
1690   -// res = jedis.spop(key);
1691   -// } catch (Exception e) {
1692   -//
1693   -// logger.error(e.getMessage());
1694   -// } finally {
1695   -// returnResource(jedis);
1696   -// }
1697   -// return res;
1698   -// }
1699   -//
1700   -// /**
1701   -// * <p>
1702   -// * 通过key获取set中的差集
1703   -// * </p>
1704   -// * <p>
1705   -// * 以第一个set为标准
1706   -// * </p>
1707   -// *
1708   -// * @param keys 可以使一个string 则返回set中所有的value 也可以是string数组
1709   -// * @return
1710   -// */
1711   -// public Set<String> sdiff(String... keys) {
1712   -// Jedis jedis = null;
1713   -// Set<String> res = null;
1714   -// try {
1715   -// jedis = jedisPool.getResource();
1716   -// jedis.select(indexdb);
1717   -// res = jedis.sdiff(keys);
1718   -// } catch (Exception e) {
1719   -//
1720   -// logger.error(e.getMessage());
1721   -// } finally {
1722   -// returnResource(jedis);
1723   -// }
1724   -// return res;
1725   -// }
1726   -//
1727   -// /**
1728   -// * <p>
1729   -// * 通过key获取set中的差集并存入到另一个key中
1730   -// * </p>
1731   -// * <p>
1732   -// * 以第一个set为标准
1733   -// * </p>
1734   -// *
1735   -// * @param dstkey 差集存入的key
1736   -// * @param keys 可以使一个string 则返回set中所有的value 也可以是string数组
1737   -// * @return
1738   -// */
1739   -// public Long sdiffstore(String dstkey, String... keys) {
1740   -// Jedis jedis = null;
1741   -// Long res = null;
1742   -// try {
1743   -// jedis = jedisPool.getResource();
1744   -// jedis.select(indexdb);
1745   -// res = jedis.sdiffstore(dstkey, keys);
1746   -// } catch (Exception e) {
1747   -//
1748   -// logger.error(e.getMessage());
1749   -// } finally {
1750   -// returnResource(jedis);
1751   -// }
1752   -// return res;
1753   -// }
1754   -//
1755   -// /**
1756   -// * <p>
1757   -// * 通过key获取指定set中的交集
1758   -// * </p>
1759   -// *
1760   -// * @param keys 可以使一个string 也可以是一个string数组
1761   -// * @return
1762   -// */
1763   -// public Set<String> sinter(String... keys) {
1764   -// Jedis jedis = null;
1765   -// Set<String> res = null;
1766   -// try {
1767   -// jedis = jedisPool.getResource();
1768   -// jedis.select(indexdb);
1769   -// res = jedis.sinter(keys);
1770   -// } catch (Exception e) {
1771   -//
1772   -// logger.error(e.getMessage());
1773   -// } finally {
1774   -// returnResource(jedis);
1775   -// }
1776   -// return res;
1777   -// }
1778   -//
1779   -// /**
1780   -// * <p>
1781   -// * 通过key获取指定set中的交集 并将结果存入新的set中
1782   -// * </p>
1783   -// *
1784   -// * @param dstkey
1785   -// * @param keys 可以使一个string 也可以是一个string数组
1786   -// * @return
1787   -// */
1788   -// public Long sinterstore(String dstkey, String... keys) {
1789   -// Jedis jedis = null;
1790   -// Long res = null;
1791   -// try {
1792   -// jedis = jedisPool.getResource();
1793   -// jedis.select(indexdb);
1794   -// res = jedis.sinterstore(dstkey, keys);
1795   -// } catch (Exception e) {
1796   -//
1797   -// logger.error(e.getMessage());
1798   -// } finally {
1799   -// returnResource(jedis);
1800   -// }
1801   -// return res;
1802   -// }
1803   -//
1804   -// /**
1805   -// * <p>
1806   -// * 通过key返回所有set的并集
1807   -// * </p>
1808   -// *
1809   -// * @param keys 可以使一个string 也可以是一个string数组
1810   -// * @return
1811   -// */
1812   -// public Set<String> sunion(String... keys) {
1813   -// Jedis jedis = null;
1814   -// Set<String> res = null;
1815   -// try {
1816   -// jedis = jedisPool.getResource();
1817   -// jedis.select(indexdb);
1818   -// res = jedis.sunion(keys);
1819   -// } catch (Exception e) {
1820   -//
1821   -// logger.error(e.getMessage());
1822   -// } finally {
1823   -// returnResource(jedis);
1824   -// }
1825   -// return res;
1826   -// }
1827   -//
1828   -// /**
1829   -// * <p>
1830   -// * 通过key返回所有set的并集,并存入到新的set中
1831   -// * </p>
1832   -// *
1833   -// * @param dstkey
1834   -// * @param keys 可以使一个string 也可以是一个string数组
1835   -// * @return
1836   -// */
1837   -// public Long sunionstore(String dstkey, String... keys) {
1838   -// Jedis jedis = null;
1839   -// Long res = null;
1840   -// try {
1841   -// jedis = jedisPool.getResource();
1842   -// jedis.select(indexdb);
1843   -// res = jedis.sunionstore(dstkey, keys);
1844   -// } catch (Exception e) {
1845   -//
1846   -// logger.error(e.getMessage());
1847   -// } finally {
1848   -// returnResource(jedis);
1849   -// }
1850   -// return res;
1851   -// }
1852   -//
1853   -// /**
1854   -// * <p>
1855   -// * 通过key将set中的value移除并添加到第二个set中
1856   -// * </p>
1857   -// *
1858   -// * @param srckey 需要移除的
1859   -// * @param dstkey 添加的
1860   -// * @param member set中的value
1861   -// * @return
1862   -// */
1863   -// public Long smove(String srckey, String dstkey, String member) {
1864   -// Jedis jedis = null;
1865   -// Long res = null;
1866   -// try {
1867   -// jedis = jedisPool.getResource();
1868   -// jedis.select(indexdb);
1869   -// res = jedis.smove(srckey, dstkey, member);
1870   -// } catch (Exception e) {
1871   -//
1872   -// logger.error(e.getMessage());
1873   -// } finally {
1874   -// returnResource(jedis);
1875   -// }
1876   -// return res;
1877   -// }
1878   -//
1879   -// /**
1880   -// * <p>
1881   -// * 通过key获取set中value的个数
1882   -// * </p>
1883   -// *
1884   -// * @param key
1885   -// * @return
1886   -// */
1887   -// public Long scard(String key) {
1888   -// Jedis jedis = null;
1889   -// Long res = null;
1890   -// try {
1891   -// jedis = jedisPool.getResource();
1892   -// jedis.select(indexdb);
1893   -// res = jedis.scard(key);
1894   -// } catch (Exception e) {
1895   -//
1896   -// logger.error(e.getMessage());
1897   -// } finally {
1898   -// returnResource(jedis);
1899   -// }
1900   -// return res;
1901   -// }
1902   -//
1903   -// /**
1904   -// * <p>
1905   -// * 通过key判断value是否是set中的元素
1906   -// * </p>
1907   -// *
1908   -// * @param key
1909   -// * @param member
1910   -// * @return
1911   -// */
1912   -// public Boolean sismember(String key, String member) {
1913   -// Jedis jedis = null;
1914   -// Boolean res = null;
1915   -// try {
1916   -// jedis = jedisPool.getResource();
1917   -// jedis.select(indexdb);
1918   -// res = jedis.sismember(key, member);
1919   -// } catch (Exception e) {
1920   -//
1921   -// logger.error(e.getMessage());
1922   -// } finally {
1923   -// returnResource(jedis);
1924   -// }
1925   -// return res;
1926   -// }
1927   -//
1928   -// /**
1929   -// * <p>
1930   -// * 通过key获取set中随机的value,不删除元素
1931   -// * </p>
1932   -// *
1933   -// * @param key
1934   -// * @return
1935   -// */
1936   -// public String srandmember(String key) {
1937   -// Jedis jedis = null;
1938   -// String res = null;
1939   -// try {
1940   -// jedis = jedisPool.getResource();
1941   -// jedis.select(indexdb);
1942   -// res = jedis.srandmember(key);
1943   -// } catch (Exception e) {
1944   -//
1945   -// logger.error(e.getMessage());
1946   -// } finally {
1947   -// returnResource(jedis);
1948   -// }
1949   -// return res;
1950   -// }
1951   -//
1952   -// /**
1953   -// * <p>
1954   -// * 通过key获取set中所有的value
1955   -// * </p>
1956   -// *
1957   -// * @param key
1958   -// * @return
1959   -// */
1960   -// public Set<String> smembers(String key) {
1961   -// Jedis jedis = null;
1962   -// Set<String> res = null;
1963   -// try {
1964   -// jedis = jedisPool.getResource();
1965   -// jedis.select(indexdb);
1966   -// res = jedis.smembers(key);
1967   -// } catch (Exception e) {
1968   -//
1969   -// logger.error(e.getMessage());
1970   -// } finally {
1971   -// returnResource(jedis);
1972   -// }
1973   -// return res;
1974   -// }
1975   -//
1976   -// /**
1977   -// * <p>
1978   -// * 通过key向zset中添加value,score,其中score就是用来排序的
1979   -// * </p>
1980   -// * <p>
1981   -// * 如果该value已经存在则根据score更新元素
1982   -// * </p>
1983   -// *
1984   -// * @param key
1985   -// * @param score
1986   -// * @param member
1987   -// * @return
1988   -// */
1989   -// public Long zadd(String key, double score, String member) {
1990   -// Jedis jedis = null;
1991   -// Long res = null;
1992   -// try {
1993   -// jedis = jedisPool.getResource();
1994   -// jedis.select(indexdb);
1995   -// res = jedis.zadd(key, score, member);
1996   -// } catch (Exception e) {
1997   -//
1998   -// logger.error(e.getMessage());
1999   -// } finally {
2000   -// returnResource(jedis);
2001   -// }
2002   -// return res;
2003   -// }
2004   -//
2005   -// /**
2006   -// * <p>
2007   -// * 返回有序集 key 中,指定区间内的成员。min=0,max=-1代表所有元素
2008   -// * </p>
2009   -// *
2010   -// * @param key
2011   -// * @param min
2012   -// * @param max
2013   -// * @return 指定区间内的有序集成员的列表。
2014   -// */
2015   -// public Set<String> zrange(String key, long min, long max) {
2016   -// Jedis jedis = null;
2017   -// try {
2018   -// jedis = jedisPool.getResource();
2019   -// jedis.select(indexdb);
2020   -// return jedis.zrange(key, min, max);
2021   -// } catch (Exception e) {
2022   -//
2023   -// logger.error(e.getMessage());
2024   -// } finally {
2025   -// returnResource(jedis);
2026   -// }
2027   -// return null;
2028   -// }
2029   -//
2030   -// /**
2031   -// * <p>
2032   -// * 统计有序集 key 中,值在 min 和 max 之间的成员的数量
2033   -// * </p>
2034   -// *
2035   -// * @param key
2036   -// * @param min
2037   -// * @param max
2038   -// * @return 值在 min 和 max 之间的成员的数量。异常返回0
2039   -// */
2040   -// public Long zcount(String key, double min, double max) {
2041   -// Jedis jedis = null;
2042   -// try {
2043   -// jedis = jedisPool.getResource();
2044   -// jedis.select(indexdb);
2045   -// return jedis.zcount(key, min, max);
2046   -// } catch (Exception e) {
2047   -//
2048   -// logger.error(e.getMessage());
2049   -// return 0L;
2050   -// } finally {
2051   -// returnResource(jedis);
2052   -// }
2053   -//
2054   -// }
2055   -//
2056   -// /**
2057   -// * <p>
2058   -// * 为哈希表 key 中的域 field 的值加上增量 increment 。增量也可以为负数,相当于对给定域进行减法操作。 如果 key
2059   -// * 不存在,一个新的哈希表被创建并执行 HINCRBY 命令。如果域 field 不存在,那么在执行命令前,域的值被初始化为 0 。
2060   -// * 对一个储存字符串值的域 field 执行 HINCRBY 命令将造成一个错误。本操作的值被限制在 64 位(bit)有符号数字表示之内。
2061   -// * </p>
2062   -// * <p>
2063   -// * 将名称为key的hash中field的value增加integer
2064   -// * </p>
2065   -// *
2066   -// * @param key
2067   -// * @param value
2068   -// * @param increment
2069   -// * @return 执行 HINCRBY 命令之后,哈希表 key 中域 field的值。异常返回0
2070   -// */
2071   -// public Long hincrBy(String key, String value, long increment) {
2072   -// Jedis jedis = null;
2073   -// try {
2074   -// jedis = jedisPool.getResource();
2075   -// jedis.select(indexdb);
2076   -// return jedis.hincrBy(key, value, increment);
2077   -// } catch (Exception e) {
2078   -// logger.error(e.getMessage());
2079   -// return 0L;
2080   -// } finally {
2081   -// returnResource(jedis);
2082   -// }
2083   -//
2084   -// }
2085   -//
2086   -// /**
2087   -// * <p>
2088   -// * 通过key删除在zset中指定的value
2089   -// * </p>
2090   -// *
2091   -// * @param key
2092   -// * @param members 可以使一个string 也可以是一个string数组
2093   -// * @return
2094   -// */
2095   -// public Long zrem(String key, String... members) {
2096   -// Jedis jedis = null;
2097   -// Long res = null;
2098   -// try {
2099   -// jedis = jedisPool.getResource();
2100   -// jedis.select(indexdb);
2101   -// res = jedis.zrem(key, members);
2102   -// } catch (Exception e) {
2103   -//
2104   -// logger.error(e.getMessage());
2105   -// } finally {
2106   -// returnResource(jedis);
2107   -// }
2108   -// return res;
2109   -// }
2110   -//
2111   -// /**
2112   -// * <p>
2113   -// * 通过key增加该zset中value的score的值
2114   -// * </p>
2115   -// *
2116   -// * @param key
2117   -// * @param score
2118   -// * @param member
2119   -// * @return
2120   -// */
2121   -// public Double zincrby(String key, double score, String member) {
2122   -// Jedis jedis = null;
2123   -// Double res = null;
2124   -// try {
2125   -// jedis = jedisPool.getResource();
2126   -// jedis.select(indexdb);
2127   -// res = jedis.zincrby(key, score, member);
2128   -// } catch (Exception e) {
2129   -//
2130   -// logger.error(e.getMessage());
2131   -// } finally {
2132   -// returnResource(jedis);
2133   -// }
2134   -// return res;
2135   -// }
2136   -//
2137   -// /**
2138   -// * <p>
2139   -// * 通过key返回zset中value的排名
2140   -// * </p>
2141   -// * <p>
2142   -// * 下标从小到大排序
2143   -// * </p>
2144   -// *
2145   -// * @param key
2146   -// * @param member
2147   -// * @return
2148   -// */
2149   -// public Long zrank(String key, String member) {
2150   -// Jedis jedis = null;
2151   -// Long res = null;
2152   -// try {
2153   -// jedis = jedisPool.getResource();
2154   -// jedis.select(indexdb);
2155   -// res = jedis.zrank(key, member);
2156   -// } catch (Exception e) {
2157   -//
2158   -// logger.error(e.getMessage());
2159   -// } finally {
2160   -// returnResource(jedis);
2161   -// }
2162   -// return res;
2163   -// }
2164   -//
2165   -// /**
2166   -// * <p>
2167   -// * 通过key返回zset中value的排名
2168   -// * </p>
2169   -// * <p>
2170   -// * 下标从大到小排序
2171   -// * </p>
2172   -// *
2173   -// * @param key
2174   -// * @param member
2175   -// * @return
2176   -// */
2177   -// public Long zrevrank(String key, String member) {
2178   -// Jedis jedis = null;
2179   -// Long res = null;
2180   -// try {
2181   -// jedis = jedisPool.getResource();
2182   -// jedis.select(indexdb);
2183   -// res = jedis.zrevrank(key, member);
2184   -// } catch (Exception e) {
2185   -//
2186   -// logger.error(e.getMessage());
2187   -// } finally {
2188   -// returnResource(jedis);
2189   -// }
2190   -// return res;
2191   -// }
2192   -//
2193   -// /**
2194   -// * <p>
2195   -// * 通过key将获取score从start到end中zset的value
2196   -// * </p>
2197   -// * <p>
2198   -// * socre从大到小排序
2199   -// * </p>
2200   -// * <p>
2201   -// * 当start为0 end为-1时返回全部
2202   -// * </p>
2203   -// *
2204   -// * @param key
2205   -// * @param start
2206   -// * @param end
2207   -// * @return
2208   -// */
2209   -// public Set<String> zrevrange(String key, long start, long end) {
2210   -// Jedis jedis = null;
2211   -// Set<String> res = null;
2212   -// try {
2213   -// jedis = jedisPool.getResource();
2214   -// jedis.select(indexdb);
2215   -// res = jedis.zrevrange(key, start, end);
2216   -// } catch (Exception e) {
2217   -//
2218   -// logger.error(e.getMessage());
2219   -// } finally {
2220   -// returnResource(jedis);
2221   -// }
2222   -// return res;
2223   -// }
2224   -//
2225   -// /**
2226   -// * <p>
2227   -// * 通过key返回指定score内zset中的value
2228   -// * </p>
2229   -// *
2230   -// * @param key
2231   -// * @param max
2232   -// * @param min
2233   -// * @return
2234   -// */
2235   -// public Set<String> zrangebyscore(String key, String max, String min) {
2236   -// Jedis jedis = null;
2237   -// Set<String> res = null;
2238   -// try {
2239   -// jedis = jedisPool.getResource();
2240   -// jedis.select(indexdb);
2241   -// res = jedis.zrevrangeByScore(key, max, min);
2242   -// } catch (Exception e) {
2243   -//
2244   -// logger.error(e.getMessage());
2245   -// } finally {
2246   -// returnResource(jedis);
2247   -// }
2248   -// return res;
2249   -// }
2250   -//
2251   -// /**
2252   -// * <p>
2253   -// * 通过key返回指定score内zset中的value
2254   -// * </p>
2255   -// *
2256   -// * @param key
2257   -// * @param max
2258   -// * @param min
2259   -// * @return
2260   -// */
2261   -// public Set<String> zrangeByScore(String key, double max, double min) {
2262   -// Jedis jedis = null;
2263   -// Set<String> res = null;
2264   -// try {
2265   -// jedis = jedisPool.getResource();
2266   -// jedis.select(indexdb);
2267   -// res = jedis.zrevrangeByScore(key, max, min);
2268   -// } catch (Exception e) {
2269   -//
2270   -// logger.error(e.getMessage());
2271   -// } finally {
2272   -// returnResource(jedis);
2273   -// }
2274   -// return res;
2275   -// }
2276   -//
2277   -// /**
2278   -// * <p>
2279   -// * 返回指定区间内zset中value的数量
2280   -// * </p>
2281   -// *
2282   -// * @param key
2283   -// * @param min
2284   -// * @param max
2285   -// * @return
2286   -// */
2287   -// public Long zcount(String key, String min, String max) {
2288   -// Jedis jedis = null;
2289   -// Long res = null;
2290   -// try {
2291   -// jedis = jedisPool.getResource();
2292   -// jedis.select(indexdb);
2293   -// res = jedis.zcount(key, min, max);
2294   -// } catch (Exception e) {
2295   -//
2296   -// logger.error(e.getMessage());
2297   -// } finally {
2298   -// returnResource(jedis);
2299   -// }
2300   -// return res;
2301   -// }
2302   -//
2303   -// /**
2304   -// * <p>
2305   -// * 通过key返回zset中的value个数
2306   -// * </p>
2307   -// *
2308   -// * @param key
2309   -// * @return
2310   -// */
2311   -// public Long zcard(String key) {
2312   -// Jedis jedis = null;
2313   -// Long res = null;
2314   -// try {
2315   -// jedis = jedisPool.getResource();
2316   -// jedis.select(indexdb);
2317   -// res = jedis.zcard(key);
2318   -// } catch (Exception e) {
2319   -//
2320   -// logger.error(e.getMessage());
2321   -// } finally {
2322   -// returnResource(jedis);
2323   -// }
2324   -// return res;
2325   -// }
2326   -//
2327   -// /**
2328   -// * <p>
2329   -// * 通过key获取zset中value的score值
2330   -// * </p>
2331   -// *
2332   -// * @param key
2333   -// * @param member
2334   -// * @return
2335   -// */
2336   -// public Double zscore(String key, String member) {
2337   -// Jedis jedis = null;
2338   -// Double res = null;
2339   -// try {
2340   -// jedis = jedisPool.getResource();
2341   -// jedis.select(indexdb);
2342   -// res = jedis.zscore(key, member);
2343   -// } catch (Exception e) {
2344   -//
2345   -// logger.error(e.getMessage());
2346   -// } finally {
2347   -// returnResource(jedis);
2348   -// }
2349   -// return res;
2350   -// }
2351   -//
2352   -// /**
2353   -// * <p>
2354   -// * 通过key删除给定区间内的元素
2355   -// * </p>
2356   -// *
2357   -// * @param key
2358   -// * @param start
2359   -// * @param end
2360   -// * @return
2361   -// */
2362   -// public Long zremrangeByRank(String key, long start, long end) {
2363   -// Jedis jedis = null;
2364   -// Long res = null;
2365   -// try {
2366   -// jedis = jedisPool.getResource();
2367   -// jedis.select(indexdb);
2368   -// res = jedis.zremrangeByRank(key, start, end);
2369   -// } catch (Exception e) {
2370   -//
2371   -// logger.error(e.getMessage());
2372   -// } finally {
2373   -// returnResource(jedis);
2374   -// }
2375   -// return res;
2376   -// }
2377   -//
2378   -// /**
2379   -// * <p>
2380   -// * 通过key删除指定score内的元素
2381   -// * </p>
2382   -// *
2383   -// * @param key
2384   -// * @param start
2385   -// * @param end
2386   -// * @return
2387   -// */
2388   -// public Long zremrangeByScore(String key, double start, double end) {
2389   -// Jedis jedis = null;
2390   -// Long res = null;
2391   -// try {
2392   -// jedis = jedisPool.getResource();
2393   -// jedis.select(indexdb);
2394   -// res = jedis.zremrangeByScore(key, start, end);
2395   -// } catch (Exception e) {
2396   -//
2397   -// logger.error(e.getMessage());
2398   -// } finally {
2399   -// returnResource(jedis);
2400   -// }
2401   -// return res;
2402   -// }
2403   -//
2404   -// /**返回满足pattern表达式的所有 key*/
2405   -// public Set<String> keys(String pattern) {
2406   -// Set<String> res = this.scan(pattern);
2407   -// return res;
2408   -// }
2409   -//
2410   -// /**
2411   -// * key模糊查找
2412   -// * @param keys 要查找的key 例: aaa* ,aaa开头的所有key
2413   -// * @return 匹配到的key集合
2414   -// */
2415   -// public Set<String> scan(String keys) {
2416   -// return scan(keys,scanlimit);
2417   -// }
2418   -//
2419   -// /**
2420   -// * 根据match 查询redis中中的所有key
2421   -// * @param match input the argument "ONLINE_*"
2422   -// * @param limit 每次查询个数,不要太大
2423   -// */
2424   -// public Set<String> scan(String match,int limit) {
2425   -// HashSet<String> keySet = Sets.newHashSet();
2426   -// Jedis jedis = null;
2427   -// try {
2428   -// jedis = jedisPool.getResource();
2429   -// jedis.select(indexdb);
2430   -// //指定规则
2431   -// ScanParams scanParams = new ScanParams().match(match).count(limit);
2432   -// boolean hasNext = true;
2433   -// //第一次查询的游标
2434   -// String cursor = "0";
2435   -// while (hasNext) {
2436   -// ScanResult<String> scanResult = jedis.scan(cursor,scanParams);
2437   -// //返回当前查询的key
2438   -// List<String> keyList = scanResult.getResult();
2439   -// keySet.addAll(keyList);
2440   -//
2441   -// cursor = scanResult.getStringCursor();
2442   -// if ("0".equals(cursor)) {
2443   -// hasNext = false;
2444   -// }
2445   -// }
2446   -// } catch (Exception e) {
2447   -// logger.error(e.getMessage());
2448   -// } finally {
2449   -// returnResource(jedis);
2450   -// }
2451   -// return keySet;
2452   -// }
2453   -//
2454   -// /**
2455   -// * <p>
2456   -// * 通过key判断值得类型
2457   -// * </p>
2458   -// *
2459   -// * @param key
2460   -// * @return
2461   -// */
2462   -// public String type(String key) {
2463   -// Jedis jedis = null;
2464   -// String res = null;
2465   -// try {
2466   -// jedis = jedisPool.getResource();
2467   -// jedis.select(indexdb);
2468   -// res = jedis.type(key);
2469   -// } catch (Exception e) {
2470   -//
2471   -// logger.error(e.getMessage());
2472   -// } finally {
2473   -// returnResource(jedis);
2474   -// }
2475   -// return res;
2476   -// }
2477   -//
2478   -// /**
2479   -// * 序列化对象
2480   -// *
2481   -// * @param obj
2482   -// * @return 对象需实现Serializable接口
2483   -// */
2484   -// public static byte[] ObjTOSerialize(Object obj) {
2485   -// ObjectOutputStream oos = null;
2486   -// ByteArrayOutputStream byteOut = null;
2487   -// try {
2488   -// byteOut = new ByteArrayOutputStream();
2489   -// oos = new ObjectOutputStream(byteOut);
2490   -// oos.writeObject(obj);
2491   -// byte[] bytes = byteOut.toByteArray();
2492   -// return bytes;
2493   -// } catch (Exception e) {
2494   -// }
2495   -// return null;
2496   -// }
2497   -//
2498   -// /**
2499   -// * 反序列化对象
2500   -// *
2501   -// * @param bytes
2502   -// * @return 对象需实现Serializable接口
2503   -// */
2504   -// public static Object unserialize(byte[] bytes) {
2505   -// ByteArrayInputStream bais = null;
2506   -// try {
2507   -// //反序列化
2508   -// bais = new ByteArrayInputStream(bytes);
2509   -// ObjectInputStream ois = new ObjectInputStream(bais);
2510   -// return ois.readObject();
2511   -// } catch (Exception e) {
2512   -// }
2513   -// return null;
2514   -// }
2515   -//
2516   -// /**
2517   -// * 返还到连接池
2518   -// *
2519   -// * @param jedis
2520   -// */
2521   -// public static void returnResource(Jedis jedis) {
2522   -// if (jedis != null) {
2523   -// jedis.close();
2524   -// }
2525   -// }
2526   -//
2527   -// /**
2528   -// * jedis 上锁
2529   -// * @param lockKey
2530   -// * @param requestId 锁的值
2531   -// * @param expireTime
2532   -// * @return
2533   -// */
2534   -// public boolean tryLock(String lockKey, String requestId, int expireTime) {
2535   -// Jedis jedis = null;
2536   -// try {
2537   -// jedis = jedisPool.getResource();
2538   -// jedis.select(indexdb);
2539   -// String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME_EX, expireTime);
2540   -// if (LOCK_SUCCESS.equals(result)) {
2541   -// return true;
2542   -// }
2543   -// } catch (Exception e) {
2544   -// e.printStackTrace();
2545   -// return false;
2546   -// } finally {
2547   -// returnResource(jedis);
2548   -// }
2549   -// return false;
2550   -// }
2551   -// /**
2552   -// * jedis 上锁
2553   -// * @param lockKey
2554   -// * @param requestId 锁的值
2555   -// * @param expireTime
2556   -// * @return
2557   -// */
2558   -// public boolean tryLockSec(String lockKey, String requestId, int expireTime) {
2559   -// Jedis jedis = null;
2560   -// try {
2561   -// jedis = jedisPool.getResource();
2562   -// jedis.select(indexdb);
2563   -// String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME_EX, expireTime);
2564   -// if (LOCK_SUCCESS.equals(result)) {
2565   -// return true;
2566   -// }
2567   -// } catch (Exception e) {
2568   -// e.printStackTrace();
2569   -// return false;
2570   -// } finally {
2571   -// returnResource(jedis);
2572   -// }
2573   -// return false;
2574   -// }
2575   -// /**
2576   -// * jedis 上锁
2577   -// * @param lockKey
2578   -// * @param requestId 锁的值
2579   -// * @return
2580   -// */
2581   -// public boolean tryLock(String lockKey, String requestId) {
2582   -// return this.tryLock( lockKey, requestId, lockWaitTime);
2583   -// }
2584   -//
2585   -//
2586   -// /**
2587   -// * jedis 上锁没返回
2588   -// * @param lockKey
2589   -// * @param requestId
2590   -// * @param expireTime
2591   -// */
2592   -// public void lock(String lockKey, String requestId, int expireTime) {
2593   -// while (true) {
2594   -// if (tryLock(lockKey, requestId, expireTime)) {
2595   -// return;
2596   -// }
2597   -// }
2598   -// }
2599   -//
2600   -// /**
2601   -// * jedis解锁
2602   -// * @param lockKey
2603   -// * @param requestId
2604   -// * @return
2605   -// */
2606   -// public boolean unLock(String lockKey, String requestId) {
2607   -// String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
2608   -// Jedis jedis = null;
2609   -// try {
2610   -// jedis = jedisPool.getResource();
2611   -// jedis.select(indexdb);
2612   -// Object result = jedis.eval(script, Collections.singletonList(lockKey),
2613   -// Collections.singletonList(requestId));
2614   -// if (RELEASE_SUCCESS.equals(result)) {
2615   -// System.out.println("unlock "+ Thread.currentThread().getName()+ " requestId:" + requestId);
2616   -// return true;
2617   -// }
2618   -// jedis.del(lockKey);
2619   -// } catch (Exception e) {
2620   -// throw e;
2621   -// } finally {
2622   -// returnResource(jedis);
2623   -// }
2624   -// return false;
2625   -// }
2626   -//
2627   -//
2628   -// @Cacheable(value="getSelectRedis" ,key="#sCacheableName")
2629   -// public List<Map<String,Object>> getSelectRedis(String sCacheableName,List<Map<String,Object>> selectDate) {
2630   -// return selectDate;
2631   -// }
2632   -//
2633   -// public static void main(String[] args) {
2634   -// /*JedisPool jedisPool = new JedisPool(null,"localhost",6379,100,"123456");
2635   -// Jedis jedis = jedisPool.getResource();
2636   -// //r.get("", RedisConstants.datebase4);
2637   -// jedis.select(RedisConstants.datebase4);
2638   -// Set<String> str = jedis.keys("*");
2639   -// for (String string : str) {
2640   -// System.out.println(string);
2641   -// }*/
2642   -// }
2643   -//}
2644 0 \ No newline at end of file
src/main/java/com/xly/config/RedisConfig.java 0 → 100644
  1 +package com.xly.config;
  2 +
  3 +import org.springframework.context.annotation.Bean;
  4 +import org.springframework.context.annotation.Configuration;
  5 +import org.springframework.data.redis.connection.RedisConnectionFactory;
  6 +import org.springframework.data.redis.core.RedisTemplate;
  7 +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
  8 +import org.springframework.data.redis.serializer.StringRedisSerializer;
  9 +
  10 +@Configuration
  11 +public class RedisConfig {
  12 +
  13 + @Bean
  14 + public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
  15 + RedisTemplate<String, Object> template = new RedisTemplate<>();
  16 + template.setConnectionFactory(factory);
  17 +
  18 + // key 采用 String 序列化
  19 + template.setKeySerializer(new StringRedisSerializer());
  20 + // hash 的 key 也采用 String 序列化
  21 + template.setHashKeySerializer(new StringRedisSerializer());
  22 +
  23 + // value 采用 Jackson 序列化
  24 + GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer();
  25 + template.setValueSerializer(jsonSerializer);
  26 + template.setHashValueSerializer(jsonSerializer);
  27 +
  28 + template.afterPropertiesSet();
  29 + return template;
  30 + }
  31 +}
0 32 \ No newline at end of file
... ...
src/main/java/com/xly/config/SpringContextHolder.java 0 → 100644
  1 +package com.xly.config;
  2 +
  3 +import org.apache.commons.lang3.Validate;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.DisposableBean;
  7 +import org.springframework.context.ApplicationContext;
  8 +import org.springframework.context.ApplicationContextAware;
  9 +import org.springframework.context.annotation.Lazy;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +/**
  13 + * 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候取出ApplicaitonContext.
  14 + */
  15 +@Service
  16 +@Lazy(false)
  17 +public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
  18 +
  19 + private static ApplicationContext applicationContext = null;
  20 +
  21 + private static Logger logger = LoggerFactory.getLogger(SpringContextHolder.class);
  22 +
  23 + /**
  24 + * 取得存储在静态变量中的ApplicationContext.
  25 + */
  26 + public static ApplicationContext getApplicationContext() {
  27 + assertContextInjected();
  28 + return applicationContext;
  29 + }
  30 +
  31 + /**
  32 + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
  33 + */
  34 + @SuppressWarnings("unchecked")
  35 + public static <T> T getBean(String name) {
  36 + assertContextInjected();
  37 + return (T) applicationContext.getBean(name);
  38 + }
  39 +
  40 + /**
  41 + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
  42 + */
  43 + public static <T> T getBean(Class<T> requiredType) {
  44 + assertContextInjected();
  45 + return applicationContext.getBean(requiredType);
  46 + }
  47 +
  48 + /**
  49 + * 清除SpringContextHolder中的ApplicationContext为Null.
  50 + */
  51 + public static void clearHolder() {
  52 + if (logger.isDebugEnabled()){
  53 + logger.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
  54 + }
  55 + applicationContext = null;
  56 + }
  57 +
  58 + /**
  59 + * 实现ApplicationContextAware接口, 注入Context到静态变量中.
  60 + */
  61 + @Override
  62 + public void setApplicationContext(ApplicationContext applicationContext) {
  63 + SpringContextHolder.applicationContext = applicationContext;
  64 + }
  65 +
  66 + /**
  67 + * 实现DisposableBean接口, 在Context关闭时清理静态变量.
  68 + */
  69 + @Override
  70 + public void destroy() throws Exception {
  71 + SpringContextHolder.clearHolder();
  72 + }
  73 +
  74 + /**
  75 + * 检查ApplicationContext不为空.
  76 + */
  77 + private static void assertContextInjected() {
  78 + Validate.validState(applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.");
  79 + }
  80 +}
0 81 \ No newline at end of file
... ...
src/main/java/com/xly/entity/AiSqlErrorHistory.java 0 → 100644
  1 +package com.xly.entity;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import lombok.Data;
  5 +
  6 +import java.util.Date;
  7 +
  8 +@Data
  9 +public class AiSqlErrorHistory {
  10 +
  11 + private Integer iIncrement;
  12 + private String sId;
  13 + private Integer iOrder;
  14 + private Date tCreateDate;
  15 + private String sBrandsId;
  16 + private String sSubsidiaryId;
  17 + private String sMakePerson;
  18 + private String sBillNo;
  19 + private String sFormId= StrUtil.EMPTY;
  20 + private Integer sStatus;
  21 + private String sSceneId;
  22 + private String sMethodId;
  23 + private String sQuestion;
  24 + private String sError_sql;
  25 + private String sError_mes;
  26 + private String sCorrect_sql;
  27 + private Boolean bCheck = false;
  28 + private Boolean bInvalid = false;
  29 + private String sLoginId;
  30 +}
... ...
src/main/java/com/xly/entity/AiUserAgentQuestion.java 0 → 100644
  1 +package com.xly.entity;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import lombok.Data;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +@Data
  11 +public class AiUserAgentQuestion {
  12 +
  13 + private Integer iIncrement;
  14 + private String sId;
  15 + private Integer iOrder;
  16 + private Date tCreateDate;
  17 + private String sBrandsId;
  18 + private String sSubsidiaryId;
  19 + private String sMakePerson;
  20 + private String sBillNo;
  21 + private String sFormId= StrUtil.EMPTY;
  22 + private Integer sStatus;
  23 + private String sSceneId;
  24 + private String sMethodId;
  25 + private String sQuestion;
  26 + private String sSqlContent;
  27 + private Boolean bCheck = false;
  28 + private Boolean bInvalid = false;
  29 + private String sLoginId;
  30 + private String sQuestionGroupNo;
  31 + private Boolean bRedis = false;
  32 + private Date tUpdateDate;
  33 + private Integer iUpdate;
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +}
... ...
src/main/java/com/xly/entity/UserSceneSession.java
... ... @@ -29,6 +29,10 @@ public class UserSceneSession {
29 29 * 该用户权限内可访问的所有场景(从权限映射中获取)
30 30 */
31 31 private List<SceneDto> authScenes;
  32 + /***
  33 + * 用户问题集合
  34 + **/
  35 + private List<String> sUserQuestionList;
32 36  
33 37 private List<ToolMeta> authTool;
34 38 /**
... ...
src/main/java/com/xly/service/DynamicExeDbService.java
... ... @@ -214,16 +214,7 @@ public class DynamicExeDbService {
214 214 public Map<String, Object> getDoProMap(String sProName, Map<String, Object> params) throws BusinessException{
215 215 Map<String,Object> searMap = new HashMap<>(4);
216 216 try{
217   - //根据过程名称获取过程参数
218   - //添加公司子公司
219   -// if((ObjectUtil.isEmpty(params.get("sBrId"))
220   -// || ObjectUtil.isEmpty(params.get("sSuId")))){
221   -// params.put("sBrId",params.get("sBrandsId"));
222   -// params.put("sSuId",params.get("sSubsidiaryId"));
223   -// }
224   -// if(ObjectUtil.isEmpty(params.get("sLoginId"))){
225   -// params.put("sLoginId",params.get("sUserId"));
226   -// }
  217 +
227 218 List<Map<String, Object>> proList = getProcParam( sProName);
228 219 //{CALL mytest(#{ownerid,mode=IN,jdbcType=INTEGER},#{examcount,mode=OUT,jdbcType=INTEGER})}
229 220 StringBuffer sb = new StringBuffer();
... ...
src/main/java/com/xly/service/RedisService.java 0 → 100644
  1 +package com.xly.service;
  2 +
  3 +import lombok.RequiredArgsConstructor;
  4 +import lombok.extern.slf4j.Slf4j;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.data.redis.core.*;
  7 +import org.springframework.stereotype.Service;
  8 +import org.springframework.util.CollectionUtils;
  9 +
  10 +import java.util.*;
  11 +import java.util.concurrent.TimeUnit;
  12 +
  13 +@Slf4j
  14 +@Service("redisService")
  15 +@RequiredArgsConstructor
  16 +public class RedisService {
  17 +
  18 + @Autowired
  19 + private RedisTemplate<String, Object> redisTemplate;
  20 +
  21 + // ============================= common ============================
  22 +
  23 + /**
  24 + * 指定缓存失效时间
  25 + */
  26 + public boolean expire(String key, long time) {
  27 + try {
  28 + if (time > 0) {
  29 + redisTemplate.expire(key, time, TimeUnit.SECONDS);
  30 + }
  31 + return true;
  32 + } catch (Exception e) {
  33 + e.printStackTrace();
  34 + return false;
  35 + }
  36 + }
  37 +
  38 + /**
  39 + * 根据key获取过期时间
  40 + */
  41 + public long getExpire(String key) {
  42 + return redisTemplate.getExpire(key, TimeUnit.SECONDS);
  43 + }
  44 +
  45 + /**
  46 + * 判断key是否存在
  47 + */
  48 + public boolean hasKey(String key) {
  49 + try {
  50 + return redisTemplate.hasKey(key);
  51 + } catch (Exception e) {
  52 + e.printStackTrace();
  53 + return false;
  54 + }
  55 + }
  56 +
  57 + /**
  58 + * 删除缓存
  59 + */
  60 + @SuppressWarnings("unchecked")
  61 + public boolean del(String... key) {
  62 + try {
  63 + if (key != null && key.length > 0) {
  64 + if (key.length == 1) {
  65 + redisTemplate.delete(key[0]);
  66 + } else {
  67 + redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key));
  68 + }
  69 + }
  70 + return true;
  71 + } catch (Exception e) {
  72 + e.printStackTrace();
  73 + return false;
  74 + }
  75 + }
  76 +
  77 + // ============================ String =============================
  78 +
  79 + /**
  80 + * 普通缓存获取
  81 + */
  82 + public Object get(String key) {
  83 + return key == null ? null : redisTemplate.opsForValue().get(key);
  84 + }
  85 +
  86 + /**
  87 + * 普通缓存放入
  88 + */
  89 + public boolean set(String key, Object value) {
  90 + try {
  91 + redisTemplate.opsForValue().set(key, value);
  92 + return true;
  93 + } catch (Exception e) {
  94 + e.printStackTrace();
  95 + return false;
  96 + }
  97 + }
  98 +
  99 + /**
  100 + * 普通缓存放入并设置时间
  101 + */
  102 + public boolean set(String key, Object value, long time) {
  103 + try {
  104 + if (time > 0) {
  105 + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
  106 + } else {
  107 + set(key, value);
  108 + }
  109 + return true;
  110 + } catch (Exception e) {
  111 + e.printStackTrace();
  112 + return false;
  113 + }
  114 + }
  115 +
  116 + /**
  117 + * 递增
  118 + */
  119 + public long incr(String key, long delta) {
  120 + if (delta < 0) {
  121 + throw new RuntimeException("递增因子必须大于0");
  122 + }
  123 + return redisTemplate.opsForValue().increment(key, delta);
  124 + }
  125 +
  126 + /**
  127 + * 递减
  128 + */
  129 + public long decr(String key, long delta) {
  130 + if (delta < 0) {
  131 + throw new RuntimeException("递减因子必须大于0");
  132 + }
  133 + return redisTemplate.opsForValue().increment(key, -delta);
  134 + }
  135 +
  136 + // ================================ Map =================================
  137 +
  138 + /**
  139 + * HashGet
  140 + */
  141 + public Object hget(String key, String item) {
  142 + return redisTemplate.opsForHash().get(key, item);
  143 + }
  144 +
  145 + /**
  146 + * 获取hashKey对应的所有键值
  147 + */
  148 + public Map<Object, Object> hmget(String key) {
  149 + return redisTemplate.opsForHash().entries(key);
  150 + }
  151 +
  152 + /**
  153 + * HashSet
  154 + */
  155 + public boolean hmset(String key, Map<String, Object> map) {
  156 + try {
  157 + redisTemplate.opsForHash().putAll(key, map);
  158 + return true;
  159 + } catch (Exception e) {
  160 + e.printStackTrace();
  161 + return false;
  162 + }
  163 + }
  164 +
  165 + /**
  166 + * HashSet 并设置时间
  167 + */
  168 + public boolean hmset(String key, Map<String, Object> map, long time) {
  169 + try {
  170 + redisTemplate.opsForHash().putAll(key, map);
  171 + if (time > 0) {
  172 + expire(key, time);
  173 + }
  174 + return true;
  175 + } catch (Exception e) {
  176 + e.printStackTrace();
  177 + return false;
  178 + }
  179 + }
  180 +
  181 + /**
  182 + * 向一张hash表中放入数据,如果不存在将创建
  183 + */
  184 + public boolean hset(String key, String item, Object value) {
  185 + try {
  186 + redisTemplate.opsForHash().put(key, item, value);
  187 + return true;
  188 + } catch (Exception e) {
  189 + e.printStackTrace();
  190 + return false;
  191 + }
  192 + }
  193 +
  194 + /**
  195 + * 向一张hash表中放入数据,并设置时间
  196 + */
  197 + public boolean hset(String key, String item, Object value, long time) {
  198 + try {
  199 + redisTemplate.opsForHash().put(key, item, value);
  200 + if (time > 0) {
  201 + expire(key, time);
  202 + }
  203 + return true;
  204 + } catch (Exception e) {
  205 + e.printStackTrace();
  206 + return false;
  207 + }
  208 + }
  209 +
  210 + /**
  211 + * 删除hash表中的值
  212 + */
  213 + public void hdel(String key, Object... item) {
  214 + redisTemplate.opsForHash().delete(key, item);
  215 + }
  216 +
  217 + /**
  218 + * 判断hash表中是否有该项的值
  219 + */
  220 + public boolean hHasKey(String key, String item) {
  221 + return redisTemplate.opsForHash().hasKey(key, item);
  222 + }
  223 +
  224 + /**
  225 + * hash递增
  226 + */
  227 + public double hincr(String key, String item, double by) {
  228 + return redisTemplate.opsForHash().increment(key, item, by);
  229 + }
  230 +
  231 + /**
  232 + * hash递减
  233 + */
  234 + public double hdecr(String key, String item, double by) {
  235 + return redisTemplate.opsForHash().increment(key, item, -by);
  236 + }
  237 +
  238 + // ============================ set =============================
  239 +
  240 + /**
  241 + * 根据key获取Set中的所有值
  242 + */
  243 + public Set<Object> sGet(String key) {
  244 + try {
  245 + return redisTemplate.opsForSet().members(key);
  246 + } catch (Exception e) {
  247 + e.printStackTrace();
  248 + return null;
  249 + }
  250 + }
  251 +
  252 + /**
  253 + * 根据value从一个set中查询,是否存在
  254 + */
  255 + public boolean sHasKey(String key, Object value) {
  256 + try {
  257 + return redisTemplate.opsForSet().isMember(key, value);
  258 + } catch (Exception e) {
  259 + e.printStackTrace();
  260 + return false;
  261 + }
  262 + }
  263 +
  264 + /**
  265 + * 将数据放入set缓存
  266 + */
  267 + public long sSet(String key, Object... values) {
  268 + try {
  269 + return redisTemplate.opsForSet().add(key, values);
  270 + } catch (Exception e) {
  271 + e.printStackTrace();
  272 + return 0;
  273 + }
  274 + }
  275 +
  276 + /**
  277 + * 将set数据放入缓存
  278 + */
  279 + public long sSetAndTime(String key, long time, Object... values) {
  280 + try {
  281 + Long count = redisTemplate.opsForSet().add(key, values);
  282 + if (time > 0) {
  283 + expire(key, time);
  284 + }
  285 + return count;
  286 + } catch (Exception e) {
  287 + e.printStackTrace();
  288 + return 0;
  289 + }
  290 + }
  291 +
  292 + /**
  293 + * 获取set缓存的长度
  294 + */
  295 + public long sGetSetSize(String key) {
  296 + try {
  297 + return redisTemplate.opsForSet().size(key);
  298 + } catch (Exception e) {
  299 + e.printStackTrace();
  300 + return 0;
  301 + }
  302 + }
  303 +
  304 + /**
  305 + * 移除值为value的
  306 + */
  307 + public long setRemove(String key, Object... values) {
  308 + try {
  309 + return redisTemplate.opsForSet().remove(key, values);
  310 + } catch (Exception e) {
  311 + e.printStackTrace();
  312 + return 0;
  313 + }
  314 + }
  315 +
  316 + // =============================== list =================================
  317 +
  318 + /**
  319 + * 获取list缓存的内容
  320 + */
  321 + public List<Object> lGet(String key, long start, long end) {
  322 + try {
  323 + return redisTemplate.opsForList().range(key, start, end);
  324 + } catch (Exception e) {
  325 + e.printStackTrace();
  326 + return null;
  327 + }
  328 + }
  329 +
  330 + /**
  331 + * 获取list缓存的长度
  332 + */
  333 + public long lGetListSize(String key) {
  334 + try {
  335 + return redisTemplate.opsForList().size(key);
  336 + } catch (Exception e) {
  337 + e.printStackTrace();
  338 + return 0;
  339 + }
  340 + }
  341 +
  342 + /**
  343 + * 通过索引获取list中的值
  344 + */
  345 + public Object lGetIndex(String key, long index) {
  346 + try {
  347 + return redisTemplate.opsForList().index(key, index);
  348 + } catch (Exception e) {
  349 + e.printStackTrace();
  350 + return null;
  351 + }
  352 + }
  353 +
  354 + /**
  355 + * 将list放入缓存
  356 + */
  357 + public boolean lSet(String key, Object value) {
  358 + try {
  359 + redisTemplate.opsForList().rightPush(key, value);
  360 + return true;
  361 + } catch (Exception e) {
  362 + e.printStackTrace();
  363 + return false;
  364 + }
  365 + }
  366 +
  367 + /**
  368 + * 将list放入缓存
  369 + */
  370 + public boolean lSet(String key, Object value, long time) {
  371 + try {
  372 + redisTemplate.opsForList().rightPush(key, value);
  373 + if (time > 0) {
  374 + expire(key, time);
  375 + }
  376 + return true;
  377 + } catch (Exception e) {
  378 + e.printStackTrace();
  379 + return false;
  380 + }
  381 + }
  382 +
  383 + /**
  384 + * 将list放入缓存
  385 + */
  386 + public boolean lSet(String key, List<Object> value) {
  387 + try {
  388 + redisTemplate.opsForList().rightPushAll(key, value);
  389 + return true;
  390 + } catch (Exception e) {
  391 + e.printStackTrace();
  392 + return false;
  393 + }
  394 + }
  395 +
  396 + /**
  397 + * 将list放入缓存
  398 + */
  399 + public boolean lSet(String key, List<Object> value, long time) {
  400 + try {
  401 + redisTemplate.opsForList().rightPushAll(key, value);
  402 + if (time > 0) {
  403 + expire(key, time);
  404 + }
  405 + return true;
  406 + } catch (Exception e) {
  407 + e.printStackTrace();
  408 + return false;
  409 + }
  410 + }
  411 +
  412 + /**
  413 + * 根据索引修改list中的某条数据
  414 + */
  415 + public boolean lUpdateIndex(String key, long index, Object value) {
  416 + try {
  417 + redisTemplate.opsForList().set(key, index, value);
  418 + return true;
  419 + } catch (Exception e) {
  420 + e.printStackTrace();
  421 + return false;
  422 + }
  423 + }
  424 +
  425 + /**
  426 + * 移除N个值为value
  427 + */
  428 + public long lRemove(String key, long count, Object value) {
  429 + try {
  430 + return redisTemplate.opsForList().remove(key, count, value);
  431 + } catch (Exception e) {
  432 + e.printStackTrace();
  433 + return 0;
  434 + }
  435 + }
  436 +}
0 437 \ No newline at end of file
... ...
src/main/java/com/xly/service/XlyErpService.java
... ... @@ -3,6 +3,7 @@ package com.xly.service;
3 3 import cn.hutool.core.collection.ListUtil;
4 4 import cn.hutool.core.date.DatePattern;
5 5 import cn.hutool.core.date.DateUtil;
  6 +import cn.hutool.core.util.IdUtil;
6 7 import cn.hutool.core.util.ObjectUtil;
7 8 import cn.hutool.core.util.StrUtil;
8 9 import com.alibaba.fastjson2.JSON;
... ... @@ -16,8 +17,10 @@ import com.xly.constant.ReturnTypeCode;
16 17 import com.xly.entity.*;
17 18 import com.xly.exception.sqlexception.SqlGenerateException;
18 19 import com.xly.exception.sqlexception.SqlValidateException;
19   -import com.xly.mapper.ToolMetaMapper;
20 20 import com.xly.runner.AppStartupRunner;
  21 +import com.xly.thread.AiSqlErrorHistoryThread;
  22 +import com.xly.thread.AiUserAgentQuestionThread;
  23 +import com.xly.thread.MultiThreadPoolServer;
21 24 import com.xly.tool.DynamicToolProvider;
22 25 import com.xly.util.EnhancedErrorGuidance;
23 26 import com.xly.util.InputPreprocessor;
... ... @@ -34,6 +37,7 @@ import lombok.RequiredArgsConstructor;
34 37 import lombok.extern.slf4j.Slf4j;
35 38 import org.springframework.beans.factory.annotation.Value;
36 39 import org.springframework.stereotype.Service;
  40 +import org.springframework.util.IdGenerator;
37 41  
38 42 import java.time.Duration;
39 43 import java.util.*;
... ... @@ -51,6 +55,7 @@ public class XlyErpService {
51 55 private final DynamicToolProvider dynamicToolProvider;
52 56 private final OperableChatMemoryProvider operableChatMemoryProvider;
53 57 private final DynamicExeDbService dynamicExeDbService;
  58 + private final RedisService redisService;
54 59  
55 60 //执行动态语句 执行异常的情况下 最多执行次数
56 61 private final Integer maxRetries = 5;
... ... @@ -186,6 +191,18 @@ public class XlyErpService {
186 191 while (attempt < maxRetries) {
187 192 try{
188 193 attempt = attempt+1;
  194 + if(attempt==1){
  195 + List<String> userQuestionList = session.getSUserQuestionList();
  196 + if(ObjectUtil.isEmpty(userQuestionList)){
  197 + userQuestionList = new ArrayList<>();
  198 + }
  199 + String sQuestion = StrUtil.replace(userInput," ",StrUtil.EMPTY);
  200 + sQuestion = StrUtil.replace(sQuestion,"\t",StrUtil.EMPTY);
  201 + sQuestion = StrUtil.replace(sQuestion,"\n",StrUtil.EMPTY);
  202 + sQuestion = sQuestion.toLowerCase();
  203 + userQuestionList.add(sQuestion);
  204 + session.setSUserQuestionList(userQuestionList);
  205 + }
189 206 return getDynamicTableSqlExec(session, input, userId, userInput,errorSql,errorMessage,iErroCount,historySqlList, aiAgent);
190 207 }catch (SqlValidateException e){
191 208 return "本场景没有识别到您的意图<br/> 如果切换场景,点[回首页],如果在本场景下,转换意图,点[清除记忆]";
... ... @@ -243,38 +260,63 @@ public class XlyErpService {
243 260 **/
244 261 private String getDynamicTableSqlExec(UserSceneSession session,String input,String userId,String userInput,String errorSql,String errorMessage,String iErroCount,String historySqlList,ErpAiAgent aiAgent){
245 262 // 1. 构建自然语言转SQLAgent,
246   - DynamicTableNl2SqlAiAgent aiDynamicTableNl2SqlAiAgent = createDynamicTableNl2SqlAiAgent(userId, input, session);
247   - String tableNames = session.getCurrentTool().getSInputTabelName();
248   - // "订单表:viw_salsalesorder,客户信息表:elecustomer,结算方式表:sispayment,产品表(无单价,无金额,无数量):viw_product_sort,销售人员表:viw_sissalesman_depart";
249   - String tableStruct = session.getCurrentTool().getSStructureMemo();
250   - String sDataNow = DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_FORMAT);
251   - String rawSql = StrUtil.EMPTY;
252   - if(ObjectUtil.isEmpty(errorSql) && ObjectUtil.isEmpty(errorMessage)){
253   - rawSql = aiDynamicTableNl2SqlAiAgent.generateMysqlSql(userId,tableNames,tableStruct,sDataNow,userInput);
254   - }else{
255   - rawSql = aiDynamicTableNl2SqlAiAgent.regenerateSqlWithError(userId, tableNames,tableStruct,sDataNow,userInput,errorSql,errorMessage,iErroCount,historySqlList);
256   - }
257   - log.info("rawSql:"+rawSql);
258   - if (rawSql == null || rawSql.trim().isEmpty()) {
259   - throw new SqlValidateException("SQL EMPTY");
260   - }
261   - // 2. 清理SQL多余符号 + 生产级强校验(核心安全保障,不可省略)
262   - String cleanSql = SqlValidateUtil.cleanSqlSymbol(rawSql);
263   -// String[] cleanSqlA = rawSql.split(";");
264   -// if(cleanSqlA.length>1){
265   -// cleanSql = cleanSqlA[cleanSqlA.length-1];
266   -// }
267   - SqlValidateUtil.validateMysqlSql(cleanSql);
268   - // 4. 执行SQL获取结构化结果
269   -// Map<String,Object> params = new HashMap<>();
270 263 List<Map<String, Object>> sqlResult = new ArrayList<>();
  264 + String cleanSql = StrUtil.EMPTY;
  265 + String rawSql;
  266 + String tableStruct;
  267 + String sError_mes = StrUtil.EMPTY;
  268 + Boolean doSqlErro = false;
  269 + List<ChatMessage> chatMessage = operableChatMemoryProvider.getCurrentChatMessages(session.getUserId());
271 270 try{
272   - sqlResult = dynamicExeDbService.findSql(new HashMap<>(),cleanSql);
273   - }catch (Exception e){
274   - throw new SqlGenerateException(e.getMessage()+" OLDSQL "+cleanSql);
  271 + DynamicTableNl2SqlAiAgent aiDynamicTableNl2SqlAiAgent = createDynamicTableNl2SqlAiAgent(userId, input, session);
  272 + String tableNames = session.getCurrentTool().getSInputTabelName();
  273 + // "订单表:viw_salsalesorder,客户信息表:elecustomer,结算方式表:sispayment,产品表(无单价,无金额,无数量):viw_product_sort,销售人员表:viw_sissalesman_depart";
  274 + tableStruct = session.getCurrentTool().getSStructureMemo();
  275 + String sDataNow = DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_FORMAT);
  276 +
  277 + if(ObjectUtil.isEmpty(errorSql) && ObjectUtil.isEmpty(errorMessage)){
  278 + rawSql = aiDynamicTableNl2SqlAiAgent.generateMysqlSql(userId,tableNames,tableStruct,sDataNow,userInput);
  279 + }else{
  280 + rawSql = aiDynamicTableNl2SqlAiAgent.regenerateSqlWithError(userId, tableNames,tableStruct,sDataNow,userInput,errorSql,errorMessage,iErroCount,historySqlList);
  281 + }
  282 + log.info("rawSql:"+rawSql);
  283 + if (rawSql == null || rawSql.trim().isEmpty()) {
  284 + throw new SqlValidateException("SQL EMPTY");
  285 + }
  286 + // 2. 清理SQL多余符号 + 生产级强校验(核心安全保障,不可省略)
  287 + cleanSql = SqlValidateUtil.cleanSqlSymbol(rawSql);
  288 + // String[] cleanSqlA = rawSql.split(";");
  289 + // if(cleanSqlA.length>1){
  290 + // cleanSql = cleanSqlA[cleanSqlA.length-1];
  291 + // }
  292 + SqlValidateUtil.validateMysqlSql(cleanSql);
  293 + // 4. 执行SQL获取结构化结果
  294 + // Map<String,Object> params = new HashMap<>();
  295 + try{
  296 + sqlResult = dynamicExeDbService.findSql(new HashMap<>(),cleanSql);
  297 + }catch (Exception e){
  298 + throw new SqlGenerateException(e.getMessage()+" OLDSQL "+cleanSql);
  299 + }
  300 + }catch (SqlValidateException e){
  301 + sError_mes = e.getMessage();
  302 + doAiSqlErrorHistoryThread(session, StrUtil.EMPTY, cleanSql, sError_mes,input);
  303 + throw e;
  304 + }catch (SqlGenerateException e){
  305 + sError_mes = e.getMessage();
  306 + doAiSqlErrorHistoryThread(session, StrUtil.EMPTY, cleanSql, sError_mes,input);
  307 + throw e;
275 308 }
  309 +
276 310 // 5. 调用AI服务生成自然语言解释(传入表结构,让解释更贴合业务)
277 311 String resultJson = JSON.toJSONString(sqlResult);
  312 +
  313 + //执行正确去修改对应正确的SQl
  314 + if(Integer.valueOf(iErroCount)>0){
  315 + doAiSqlErrorHistoryThread(session, cleanSql, StrUtil.EMPTY, StrUtil.EMPTY,input);
  316 + }
  317 +
  318 + //执行操作记录表
  319 + doAiUserAgentQuestion(session,input,cleanSql,chatMessage);
278 320 String sText = aiAgent.explainSqlResult(
279 321 userId,
280 322 userInput,
... ... @@ -282,10 +324,49 @@ public class XlyErpService {
282 324 tableStruct,
283 325 resultJson
284 326 );
285   - log.info("sText:"+sText);
286 327 return sText;
287 328 }
288 329  
  330 +
  331 + /***
  332 + * @Author 钱豹
  333 + * @Date 16:57 2026/3/14
  334 + * @Param
  335 + * @return
  336 + * @Description 记录动态SQL日志(多线程)
  337 + **/
  338 + public void doAiSqlErrorHistoryThread(UserSceneSession session,
  339 + String sSqlContent,
  340 + String sError_sql,
  341 + String sError_mes,
  342 + String sQuestion
  343 +
  344 + ){
  345 + MultiThreadPoolServer mts = MultiThreadPoolServer.getInstance();
  346 + AiSqlErrorHistoryThread at = new AiSqlErrorHistoryThread(session, sSqlContent, sError_sql, sError_mes,sQuestion);
  347 + mts.service(at);
  348 + }
  349 +
  350 + /***
  351 + * @Author 钱豹
  352 + * @Date 16:57 2026/3/14
  353 + * @Param
  354 + * @return
  355 + * @Description 记录动态SQL日志(多线程)
  356 + **/
  357 + public void doAiUserAgentQuestion(UserSceneSession session,
  358 + String sQuestion,
  359 + String sSqlContent,
  360 + List<ChatMessage> chatMessage
  361 +
  362 + ){
  363 + MultiThreadPoolServer mts = MultiThreadPoolServer.getInstance();
  364 + AiUserAgentQuestionThread at = new AiUserAgentQuestionThread(session,sQuestion,sSqlContent,chatMessage);
  365 + mts.service(at);
  366 + }
  367 +
  368 +
  369 +
289 370 /***
290 371 * @Author 钱豹
291 372 * @Date 11:22 2026/1/31
... ...
src/main/java/com/xly/thread/AiSqlErrorHistoryThread.java 0 → 100644
  1 +package com.xly.thread;
  2 +
  3 +
  4 +import cn.hutool.core.util.StrUtil;
  5 +import com.xly.config.SpringContextHolder;
  6 +import com.xly.entity.UserSceneSession;
  7 +import com.xly.service.DynamicExeDbService;
  8 +
  9 +import java.util.HashMap;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +
  14 +public class AiSqlErrorHistoryThread implements Runnable {
  15 + private UserSceneSession session;
  16 + private String sSqlContent;
  17 + private String sError_sql;
  18 + private String sError_mes;
  19 + private String sQuestion;
  20 + public final String sProName="Sp_Ai_AiSqlErrorHistoryThread";
  21 +
  22 + public AiSqlErrorHistoryThread(UserSceneSession session, String sSqlContent, String sError_sql,String sError_mes,String sQuestion) {
  23 + this.session = session;
  24 + this.sSqlContent = sSqlContent;
  25 + this.sError_sql = sError_sql;
  26 + this.sError_mes = sError_mes;
  27 + this.sQuestion = sQuestion;
  28 + }
  29 + @Override
  30 + public void run() {
  31 + String sSceneId = session.getCurrentScene().getSId();
  32 + String sMethodId = session.getCurrentTool().getSId();
  33 + DynamicExeDbService dynamicExeDbService = SpringContextHolder.getBean(DynamicExeDbService.class);
  34 + Map<String, Object> data = getMap(sSceneId, sMethodId);
  35 + data.put("sQuestion",getsQuestion(session.getSUserQuestionList()));
  36 + Map<String, Object> searMap = dynamicExeDbService.getDoProMap(sProName, data);
  37 + dynamicExeDbService.getCallPro(searMap, sProName);
  38 + }
  39 + private String getsQuestion(List<String> sUserQuestionList){
  40 + return String.join(",", sUserQuestionList);
  41 + }
  42 + /***
  43 + * @Author 钱豹
  44 + * @Date 4:22 2026/3/15
  45 + * @Param [sSceneId, sMethodId]
  46 + * @return java.util.Map<java.lang.String,java.lang.Object>
  47 + * @Description 获取执行的动态Map
  48 + **/
  49 + private Map<String, Object> getMap(String sSceneId, String sMethodId) {
  50 + Map<String,Object> data = new HashMap<>(16);
  51 + data.put("sSceneId", sSceneId);
  52 + data.put("sMethodId", sMethodId);
  53 + data.put("sSqlContent",sSqlContent);
  54 + data.put("sError_sql",sError_sql);
  55 + data.put("sError_mes",sError_mes);
  56 + data.put("sBrId",session.getSBrandsId());
  57 + data.put("sBrandsId",session.getSBrandsId());
  58 + data.put("sSuId",session.getSSubsidiaryId());
  59 + data.put("sSubsidiaryId",session.getSSubsidiaryId());
  60 + data.put("sLoginId",session.getUserName());
  61 + data.put("sUserName",session.getUserName());
  62 + data.put("sUserId",session.getUserId());
  63 + return data;
  64 + }
  65 +}
... ...
src/main/java/com/xly/thread/AiUserAgentQuestionThread.java 0 → 100644
  1 +package com.xly.thread;
  2 +
  3 +
  4 +import cn.hutool.core.util.ObjectUtil;
  5 +import cn.hutool.core.util.StrUtil;
  6 +import com.xly.config.OperableChatMemoryProvider;
  7 +import com.xly.config.SpringContextHolder;
  8 +import com.xly.entity.UserSceneSession;
  9 +import com.xly.service.DynamicExeDbService;
  10 +import dev.langchain4j.data.message.ChatMessage;
  11 +import dev.langchain4j.data.message.ChatMessageType;
  12 +import jnr.ffi.annotations.In;
  13 +
  14 +import java.util.Arrays;
  15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +
  19 +public class AiUserAgentQuestionThread implements Runnable {
  20 + private UserSceneSession session;
  21 + private String sSqlContent;
  22 + private String sQuestion;
  23 + List<ChatMessage> userMessage;
  24 + public final String sProName="Sp_Ai_AiUserAgentQuestionThread";
  25 +
  26 + public AiUserAgentQuestionThread(UserSceneSession session,String sQuestion,String sSqlContent, List<ChatMessage> userMessage ) {
  27 + this.session = session;
  28 + this.sSqlContent = sSqlContent;
  29 + this.sQuestion = sQuestion;
  30 + this.userMessage = userMessage;
  31 + }
  32 +
  33 + @Override
  34 + public void run() {
  35 + sQuestion = sQuestion.replace("用户输入:",StrUtil.EMPTY);
  36 + String sSceneId = session.getCurrentScene().getSId();
  37 + String sMethodId = session.getCurrentTool().getSId();
  38 + DynamicExeDbService dynamicExeDbService = SpringContextHolder.getBean(DynamicExeDbService.class);
  39 + String sQuestionGroupNo = session.getSUserQuestionList().get(0);
  40 + Integer bRedis = (session.getSUserQuestionList().size()==1)?1:0;
  41 + Map<String, Object> data = getMap(sSceneId, sMethodId,bRedis,sQuestionGroupNo);
  42 + data.put("sQuestion",getsQuestion(session.getSUserQuestionList()));
  43 + Map<String, Object> searMap = dynamicExeDbService.getDoProMap(sProName, data);
  44 + dynamicExeDbService.getCallPro(searMap, sProName);
  45 + }
  46 +
  47 + private String getsQuestion(List<String> sUserQuestionList){
  48 + return String.join(",", sUserQuestionList);
  49 + }
  50 +
  51 + //获取组ID
  52 + private String getQuestionGroupNo(){
  53 + String sQuestionGroupNo = userMessage.stream()
  54 + .filter(one -> one.type().equals(ChatMessageType.USER) && !"用户输入:initAiService".equals(one.text()))
  55 + .findFirst()
  56 + .map(one->one.text())
  57 + .orElse(StrUtil.EMPTY);
  58 + sQuestionGroupNo = sQuestionGroupNo.replace("用户输入:",StrUtil.EMPTY);
  59 + sQuestionGroupNo = sQuestionGroupNo.replace(" ",StrUtil.EMPTY);
  60 + sQuestionGroupNo = sQuestionGroupNo.replace("\\t",StrUtil.EMPTY);
  61 + sQuestionGroupNo = sQuestionGroupNo.replace("\\n",StrUtil.EMPTY);
  62 + sQuestionGroupNo = sQuestionGroupNo.toLowerCase();
  63 + return sQuestionGroupNo;
  64 + }
  65 +
  66 +
  67 + /***
  68 + * @Author 钱豹
  69 + * @Date 4:22 2026/3/15
  70 + * @Param [sSceneId, sMethodId]
  71 + * @return java.util.Map<java.lang.String,java.lang.Object>
  72 + * @Description 获取执行的动态Map
  73 + **/
  74 + private Map<String, Object> getMap(String sSceneId, String sMethodId,Integer bRedis,String sQuestionGroupNo) {
  75 + Map<String,Object> data = new HashMap<>(16);
  76 + data.put("sSceneId", sSceneId);
  77 + data.put("sMethodId", sMethodId);
  78 + data.put("sSqlContent",sSqlContent);
  79 + data.put("sBrId",session.getSBrandsId());
  80 + data.put("sBrandsId",session.getSBrandsId());
  81 + data.put("sSuId",session.getSSubsidiaryId());
  82 + data.put("sSubsidiaryId",session.getSSubsidiaryId());
  83 + data.put("sLoginId",session.getUserName());
  84 + data.put("sUserName",session.getUserName());
  85 + data.put("sUserId",session.getUserId());
  86 + data.put("bRedis",bRedis);
  87 + data.put("sQuestionGroupNo",sQuestionGroupNo);
  88 + return data;
  89 + }
  90 +}
... ...
src/main/java/com/xly/thread/MultiThreadPoolServer.java 0 → 100644
  1 +package com.xly.thread;
  2 +
  3 +import java.util.concurrent.ArrayBlockingQueue;
  4 +import java.util.concurrent.Callable;
  5 +import java.util.concurrent.ExecutorService;
  6 +import java.util.concurrent.Future;
  7 +import java.util.concurrent.ThreadFactory;
  8 +import java.util.concurrent.ThreadPoolExecutor;
  9 +import java.util.concurrent.TimeUnit;
  10 +
  11 +import org.apache.poi.ss.formula.functions.T;
  12 +import org.python.google.common.util.concurrent.ThreadFactoryBuilder;
  13 +
  14 +
  15 +/**
  16 + *
  17 + * 线程池不允许使用Executors去创建,而是通过ThreadPoolExecutor的方式,
  18 + * 这样的处理方式让写的同学更加明确线程池的运行规则,规避资源耗尽的风险。
  19 + * 说明:Executors各个方法的弊端:
  20 + * 1)newFixedThreadPool和newSingleThreadExecutor:
  21 + *   主要问题是堆积的请求处理队列可能会耗费非常大的内存,甚至OOM。
  22 + * 2)newCachedThreadPool和newScheduledThreadPool:
  23 + *   主要问题是线程数最大数是Integer.MAX_VALUE,可能会创建数量非常多的线程,甚至OOM。
  24 + * 功能:任务线程池类(2秒更新一次线程单独用)
  25 + * 工具类参考https://blog.csdn.net/bunnycoffer/article/details/82908024
  26 + * 作者:qb
  27 + * 日期:2018-11-13
  28 + * @author qianbao
  29 + */
  30 +public class MultiThreadPoolServer {
  31 +
  32 + /** ˽������线程池服务*/
  33 + private ExecutorService executorService;
  34 + private static MultiThreadPoolServer mts;
  35 + private final static int poolSize = 30000;
  36 + private final static int queueSize = 30000;
  37 +
  38 + private static ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("theadpool" + "-%d").setDaemon(true).build();
  39 + /** 单例方法 */
  40 + public static MultiThreadPoolServer getInstance() {
  41 +
  42 + //生成实例
  43 + if (mts == null) {
  44 + //锁类ͬ����
  45 + synchronized(MultiThreadPoolServer.class) {
  46 + if (mts == null) {
  47 + //实例化
  48 + mts = new MultiThreadPoolServer();
  49 + mts.executorService = new ThreadPoolExecutor(poolSize,
  50 + poolSize,
  51 + 0L,
  52 + TimeUnit.SECONDS,
  53 + new ArrayBlockingQueue<Runnable>(queueSize),
  54 + threadFactory,
  55 + new ThreadPoolExecutor.AbortPolicy() {
  56 + // 队列已满,而且当前线程数已经超过最大线程数时的异常处理策略
  57 + @Override
  58 + public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  59 + super.rejectedExecution(r, e);
  60 + }
  61 + });
  62 + }
  63 + }
  64 + }
  65 +
  66 + //返回值
  67 + return mts;
  68 +
  69 + }
  70 +
  71 + /** 线程池调用方法 */
  72 + public void service(Runnable handler) {
  73 + try {
  74 + //调用线程
  75 + this.executorService.execute(handler);
  76 + } catch (Exception e) {
  77 + e.printStackTrace();
  78 + }
  79 + }
  80 +
  81 + /**
  82 + * 开启一个有返回结果的线程
  83 + * @param
  84 + * @return
  85 + */
  86 + public Future<T> submit(Callable<T> handler) {
  87 + // 把一个任务丢到了线程池中
  88 + try {
  89 + //调用线程
  90 + return this.executorService.submit(handler);
  91 + } catch (Exception e) {
  92 + e.printStackTrace();
  93 + }
  94 + return null;
  95 + }
  96 +
  97 +
  98 + /** 线程池结束 */
  99 + public void shutdown() {
  100 + this.executorService.shutdown();
  101 + }
  102 +
  103 +}
... ...
src/main/resources/application.yml
... ... @@ -50,23 +50,18 @@ spring:
50 50 idle-timeout: 600000
51 51 max-lifetime: 1800000
52 52 # REDIS (RedisProperties)
53   -# redis:
54   -# host: 127.0.0.1
55   -# password: xlyXLY2015
56   -# port: 6380
57   -# database: 8 # index
58   -# timeout: 30000ms # 连接超时时长(毫秒)
59   -# block-when-exhausted: true #redis配置结束
60   -# lettuce:
61   -# pool:
62   -# # 连接池中的最大空闲连接
63   -# max-idle: 20
64   -# # 连接池中的最小空闲连接
65   -# min-idle: 20
66   -# # 连接池最大连接数(使用负值表示没有限制)
67   -# max-active: 200
68   -# # 连接池最大阻塞等待时间(使用负值表示没有限制)
69   -# max-wait: -1
  53 + data:
  54 + redis:
  55 + host: localhost
  56 + port: 6379 # Redis 端口
  57 + database: 0 # 使用的数据库索引(默认为0)
  58 + password: # 密码(如果没有设置则为空)
  59 + timeout: 3000ms # 连接超时时间
  60 + lettuce:
  61 + pool:
  62 + max-active: 8 # 连接池最大连接数
  63 + max-idle: 8 # 连接池最大空闲连接
  64 + min-idle: 0 # 连接池最小空闲连接
70 65  
71 66 # application.yml 或 application.properties
72 67 langchain4j:
... ...