提交获取id的方法
This commit is contained in:
@@ -56,16 +56,18 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
@RequestMapping(value = "/save", method = RequestMethod.GET)
|
@RequestMapping(value = "/save", method = RequestMethod.GET)
|
||||||
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
|
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
|
||||||
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
|
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
|
||||||
public String testRedis(String id) {
|
public String testRedis() {
|
||||||
try {
|
try {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("cfg_id", id);
|
|
||||||
|
long id=configRedisServiceimpl.getIncrId("seq_compileid");
|
||||||
|
map.put("cfg_id", id+"");
|
||||||
map.put("is_valid", "1");
|
map.put("is_valid", "1");
|
||||||
map.put("dst_file", "/home/1234/");
|
map.put("dst_file", "/home/1234/");
|
||||||
map.put("dst_file_md5", "fasdfdasfsdafdsafadsf");
|
map.put("dst_file_md5", "fasdfdasfsdafdsafadsf");
|
||||||
map.put("time_stamp", new Date().getTime() + "");
|
map.put("time_stamp", new Date().getTime() + "");
|
||||||
map.put("level", "20");
|
map.put("level", "20");
|
||||||
map.put("file_id",id);
|
map.put("file_id",id+"");
|
||||||
configRedisServiceimpl.saveConfigYSPDemoCompile(96,map);
|
configRedisServiceimpl.saveConfigYSPDemoCompile(96,map);
|
||||||
return "ok";
|
return "ok";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -13,4 +13,11 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface ConfigRedisService {
|
public interface ConfigRedisService {
|
||||||
public void saveConfigYSPDemoCompile(int service, Map<String, String> map);
|
public void saveConfigYSPDemoCompile(int service, Map<String, String> map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定key的自增长值
|
||||||
|
* @param key 需要自增的key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Long getIncrId(String key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.nis.web.service.restful;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -34,7 +36,6 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuffer valBF = new StringBuffer();
|
StringBuffer valBF = new StringBuffer();
|
||||||
//valBF.append("\"");
|
|
||||||
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
|
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
|
||||||
for (String valStr : valSplit) {
|
for (String valStr : valSplit) {
|
||||||
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
|
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
|
||||||
@@ -46,13 +47,15 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
|||||||
valBF.append(valStr.trim());
|
valBF.append(valStr.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//valBF.append("\"");
|
|
||||||
DynamicJedisDataBase.setRedisDataBase(maatXmlExpr.getRedisDB(), redisTemplate);
|
// DynamicJedisDataBase.setRedisDataBase(maatXmlExpr.getRedisDB(),
|
||||||
// redisTemplate.boundValueOps(keyBF.toString()).append(valBF.toString());
|
// redisTemplate);
|
||||||
System.out.println(keyBF.toString());
|
// System.out.println(keyBF.toString());
|
||||||
System.out.println(valBF.toString());
|
// System.out.println(valBF.toString());
|
||||||
|
//redisTemplate.boundValueOps(keyBF.toString()).
|
||||||
|
|
||||||
redisTemplate.opsForValue().set(keyBF.toString(), valBF.toString());
|
redisTemplate.opsForValue().set(keyBF.toString(), valBF.toString());
|
||||||
//redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
// redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
||||||
@@ -72,8 +75,6 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
|||||||
System.out.println("\\t");
|
System.out.println("\\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
||||||
@@ -100,4 +101,19 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getIncrId(String key) {
|
||||||
|
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
||||||
|
// RedisAtomicLong atomicLong = new RedisAtomicLong(key,
|
||||||
|
// redisTemplate.getConnectionFactory());
|
||||||
|
//
|
||||||
|
// Long id = atomicLong.getAndIncrement() + 1;
|
||||||
|
// if ((id == null || id.longValue() == 0) && liveTime > 0) {
|
||||||
|
// atomicLong.expire(liveTime, TimeUnit.SECONDS);
|
||||||
|
// }
|
||||||
|
// return id;
|
||||||
|
|
||||||
|
return redisTemplate.boundValueOps(key).increment(1l);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user