1:修改配置新增或取消时,修改id对应关系为当新增或取消成功后才修改id关系,否则不修改id关系
This commit is contained in:
@@ -88,6 +88,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
|
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
|
||||||
configMap.put(1, listMap);
|
configMap.put(1, listMap);
|
||||||
configRedisService.saveUnMaatConfig(configMap);
|
configRedisService.saveUnMaatConfig(configMap);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Integer service = 100;
|
Integer service = 100;
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
@@ -145,7 +146,10 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
Map<Integer, Map<Integer, List<Long>>> idMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
Map<Integer, Map<Integer, List<Long>>> idMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||||
idMap.put(redisDB, map);
|
idMap.put(redisDB, map);
|
||||||
|
|
||||||
configRedisService.delMaatConfig(idMap);
|
boolean delMaatConfig = configRedisService.delMaatConfig(idMap);
|
||||||
|
if (delMaatConfig) {
|
||||||
|
configRedisService.delMaatRelation(idMap);
|
||||||
|
}
|
||||||
return "ok";
|
return "ok";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -165,7 +169,9 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
listMap = new ArrayList<MaatConfig>();
|
listMap = new ArrayList<MaatConfig>();
|
||||||
listMap.add(getMaatConfig(service));
|
listMap.add(getMaatConfig(service));
|
||||||
configMap.put(2, listMap);
|
configMap.put(2, listMap);
|
||||||
configRedisService.saveMaatConfig(configMap);
|
if (configRedisService.saveMaatConfig(configMap)) {
|
||||||
|
configRedisService.addMaatRelation(configMap);
|
||||||
|
}
|
||||||
// configRedisService.saveMaatConfig(listMap, service);
|
// configRedisService.saveMaatConfig(listMap, service);
|
||||||
// new ConfigRedisServiceimpl().GETMaatConfig(listMap);
|
// new ConfigRedisServiceimpl().GETMaatConfig(listMap);
|
||||||
return "ok";
|
return "ok";
|
||||||
@@ -373,7 +379,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||||
RestBusinessCode.missing_args.getValue());
|
RestBusinessCode.missing_args.getValue());
|
||||||
}
|
}
|
||||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
// if ((configCompile.getActiveSys() != null) ||
|
||||||
|
// (configCompile.getEffectiveRange() != null
|
||||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||||
// count++;
|
// count++;
|
||||||
// configSourcesService.setCompileInvalid(configCompile);
|
// configSourcesService.setCompileInvalid(configCompile);
|
||||||
@@ -405,7 +412,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||||
RestBusinessCode.missing_args.getValue());
|
RestBusinessCode.missing_args.getValue());
|
||||||
}
|
}
|
||||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
// if ((configCompile.getActiveSys() != null) ||
|
||||||
|
// (configCompile.getEffectiveRange() != null
|
||||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||||
// try {
|
// try {
|
||||||
// configSourcesService.setCompileValid(configCompile);
|
// configSourcesService.setCompileValid(configCompile);
|
||||||
@@ -515,13 +523,14 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
|
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||||
|
null);
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
|
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
|
||||||
|
|
||||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置数据插入成功",
|
||||||
"配置数据插入成功" , Constants.IS_DEBUG ? jsonString : null);
|
Constants.IS_DEBUG ? jsonString : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
||||||
@@ -531,10 +540,12 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
|
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||||
|
null);
|
||||||
String filePath = "";
|
String filePath = "";
|
||||||
try {
|
try {
|
||||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
||||||
|
FileDesc.class);
|
||||||
if (null == file) {
|
if (null == file) {
|
||||||
thread.setExceptionInfo("请选择上传文件到file参数");
|
thread.setExceptionInfo("请选择上传文件到file参数");
|
||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请选择上传文件到file参数",
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请选择上传文件到file参数",
|
||||||
@@ -554,7 +565,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
||||||
// NameValuePair[] meta_list = new NameValuePair[5];
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
||||||
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
||||||
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
|
// meta_list[1] = new NameValuePair("fileLength",
|
||||||
|
// String.valueOf(file.getSize()));
|
||||||
// meta_list[2] = new NameValuePair("fileExt", ext);
|
// meta_list[2] = new NameValuePair("fileExt", ext);
|
||||||
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||||
@@ -572,17 +584,16 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
JSONObject jsonObj = new JSONObject();
|
JSONObject jsonObj = new JSONObject();
|
||||||
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||||
// jsonObj.put("accessUrl", "filePath");
|
// jsonObj.put("accessUrl", "filePath");
|
||||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
|
||||||
"文件上传成功" ,jsonObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/cfg/v1/fileDigestSources", method = RequestMethod.POST)
|
@RequestMapping(value = "/cfg/v1/fileDigestSources", method = RequestMethod.POST)
|
||||||
@ApiOperation(value = "文件摘要获取", httpMethod = "POST", response = Map.class, notes = "文件摘要获取")
|
@ApiOperation(value = "文件摘要获取", httpMethod = "POST", response = Map.class, notes = "文件摘要获取")
|
||||||
@ApiParam(value = "摘要文件", name = "MultipartFile", required = true)
|
@ApiParam(value = "摘要文件", name = "MultipartFile", required = true)
|
||||||
public Map fileDigestSources(MultipartFile file,HttpServletRequest request,
|
public Map fileDigestSources(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
||||||
HttpServletResponse response){
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,file,null);
|
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||||
|
file, null);
|
||||||
// JSONArray fileArray=new JSONArray();
|
// JSONArray fileArray=new JSONArray();
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
thread.setExceptionInfo("请上传获取摘要的文件到file");
|
thread.setExceptionInfo("请上传获取摘要的文件到file");
|
||||||
@@ -590,7 +601,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
RestBusinessCode.missing_args.getValue());
|
RestBusinessCode.missing_args.getValue());
|
||||||
}
|
}
|
||||||
JSONObject resultObject = new JSONObject();
|
JSONObject resultObject = new JSONObject();
|
||||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
||||||
|
FileDesc.class);
|
||||||
try {
|
try {
|
||||||
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
||||||
// 验证Md5
|
// 验证Md5
|
||||||
@@ -605,7 +617,8 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
||||||
// NameValuePair[] meta_list = new NameValuePair[5];
|
// NameValuePair[] meta_list = new NameValuePair[5];
|
||||||
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
||||||
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
|
// meta_list[1] = new NameValuePair("fileLength",
|
||||||
|
// String.valueOf(file.getSize()));
|
||||||
// meta_list[2] = new NameValuePair("fileExt", ext);
|
// meta_list[2] = new NameValuePair("fileExt", ext);
|
||||||
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||||
@@ -641,6 +654,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
}
|
}
|
||||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBlank(Date datetime) {
|
private boolean isBlank(Date datetime) {
|
||||||
if (null != datetime) {
|
if (null != datetime) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -15,18 +15,24 @@ import com.nis.domain.restful.MaatConfig;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface ConfigRedisService {
|
public interface ConfigRedisService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下发非maat配置接口,key是redisDBIndex,value是配置集合
|
* 下发非maat配置接口,key是redisDBIndex,value是配置集合
|
||||||
* @param configMap
|
* @param configMap
|
||||||
|
* @return 成功返回true,失败返回false或抛出异常
|
||||||
*/
|
*/
|
||||||
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap);
|
public boolean saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存 maat配置接口,key是redisDBIndex,value是配置集合
|
* 保存 maat配置接口,key是redisDBIndex,value是配置集合
|
||||||
* @param configMap
|
* @param configMap
|
||||||
|
* @return 成功返回true,失败返回false或抛出异常
|
||||||
*/
|
*/
|
||||||
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap);
|
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap);
|
||||||
|
/**
|
||||||
|
* 下发配置成功后,需要更新编译,组,域等配置id的对应关系
|
||||||
|
* @param configMap
|
||||||
|
*/
|
||||||
|
public void addMaatRelation(Map<Integer, List<MaatConfig>> configMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定key的自增长值
|
* 获取指定key的自增长值
|
||||||
@@ -38,14 +44,21 @@ public interface ConfigRedisService {
|
|||||||
/**
|
/**
|
||||||
* 删除非maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
* 删除非maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||||
* @param idMap
|
* @param idMap
|
||||||
|
* @return 成功返回true,失败返回false或抛出异常
|
||||||
*/
|
*/
|
||||||
public void delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
* 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||||
* @param idMap
|
* @param idMap
|
||||||
|
* @return 成功返回true,失败返回false或抛出异常
|
||||||
*/
|
*/
|
||||||
public void delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除maat类配置成功后,需要更新编译,组,域等配置id的对应关系
|
||||||
|
* @param idMap
|
||||||
|
*/
|
||||||
|
public void delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.nis.domain.restful.MaatConfig;
|
|||||||
import com.nis.domain.restful.MaatRelation;
|
import com.nis.domain.restful.MaatRelation;
|
||||||
import com.nis.listener.CompileGroupRegionRela;
|
import com.nis.listener.CompileGroupRegionRela;
|
||||||
import com.nis.util.Configurations;
|
import com.nis.util.Configurations;
|
||||||
|
import com.nis.util.Exceptions;
|
||||||
import com.nis.util.ReadMaatXmlUtil;
|
import com.nis.util.ReadMaatXmlUtil;
|
||||||
import com.nis.util.ServiceAndRDBIndexReal;
|
import com.nis.util.ServiceAndRDBIndexReal;
|
||||||
import com.nis.web.service.SpringContextHolder;
|
import com.nis.web.service.SpringContextHolder;
|
||||||
@@ -32,7 +33,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
public boolean saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
||||||
if (configMap != null && configMap.size() > 0) {
|
if (configMap != null && configMap.size() > 0) {
|
||||||
for (Integer redisDBIndex : configMap.keySet()) {
|
for (Integer redisDBIndex : configMap.keySet()) {
|
||||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||||
@@ -136,10 +137,11 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||||
Integer.valueOf(maatVersionStr) + 1);
|
Integer.valueOf(maatVersionStr) + 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +201,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
||||||
if (configMap != null && configMap.size() > 0) {
|
if (configMap != null && configMap.size() > 0) {
|
||||||
for (Integer redisDBIndex : configMap.keySet()) {
|
for (Integer redisDBIndex : configMap.keySet()) {
|
||||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||||
@@ -218,16 +220,19 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate, redisDBIndex);
|
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate, redisDBIndex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||||
Integer.valueOf(maatVersionStr) + 1);
|
Integer.valueOf(maatVersionStr) + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addMaatRelation(configMap);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -401,7 +406,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||||
if (idMap != null && idMap.size() > 0) {
|
if (idMap != null && idMap.size() > 0) {
|
||||||
for (Integer redisDBIndex : idMap.keySet()) {
|
for (Integer redisDBIndex : idMap.keySet()) {
|
||||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||||
@@ -500,18 +505,19 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||||
Integer.valueOf(maatVersionStr) + 1);
|
Integer.valueOf(maatVersionStr) + 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||||
if (idMap != null && idMap.size() > 0) {
|
if (idMap != null && idMap.size() > 0) {
|
||||||
for (Integer redisDBIndex : idMap.keySet()) {
|
for (Integer redisDBIndex : idMap.keySet()) {
|
||||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||||
@@ -525,6 +531,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
||||||
if (maatVersionStr != null) {
|
if (maatVersionStr != null) {
|
||||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||||
|
if (maatRelation != null && redisTemplate != null) {
|
||||||
for (Integer service : serviceConfigMap.keySet()) {
|
for (Integer service : serviceConfigMap.keySet()) {
|
||||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||||
removeConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service,
|
removeConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service,
|
||||||
@@ -534,13 +541,13 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||||
Integer.valueOf(maatVersionStr) + 1);
|
Integer.valueOf(maatVersionStr) + 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除配置成功后开始删除id对应关系
|
|
||||||
delMaatRelation(idMap);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,7 +602,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
* @param service
|
* @param service
|
||||||
* @param redisTemplate
|
* @param redisTemplate
|
||||||
*/
|
*/
|
||||||
public void removeCommonConfig(MaatXmlConfig maatXmlConfig, Set<Long> idList, int type, Double maatVersion,
|
private void removeCommonConfig(MaatXmlConfig maatXmlConfig, Set<Long> idList, int type, Double maatVersion,
|
||||||
int service, RedisTemplate<String, String> redisTemplate, int redisDBIndex) {
|
int service, RedisTemplate<String, String> redisTemplate, int redisDBIndex) {
|
||||||
if (maatXmlConfig != null && idList != null && idList.size() > 0) {
|
if (maatXmlConfig != null && idList != null && idList.size() > 0) {
|
||||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||||
@@ -621,10 +628,14 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|||||||
}
|
}
|
||||||
String oldKey = keyBF.toString().toUpperCase();
|
String oldKey = keyBF.toString().toUpperCase();
|
||||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||||
|
if (redisTemplate.hasKey(oldKey)) {
|
||||||
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
||||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex, oldKey,
|
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex, oldKey,
|
||||||
maatKey.toUpperCase());
|
maatKey.toUpperCase());
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(redisDBIndex + "号redis库中不存在key=" + oldKey + "请检查id映射关系是否正确");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||||
|
|||||||
Reference in New Issue
Block a user