Commit 6e9463ac by 陶光胜

门店保存修改

parent 35f5302d
......@@ -179,53 +179,57 @@ public class StoreDictApiServiceImpl implements StoreDictApiService {
List<String> newList = Arrays.asList(values.split(","));
List<String> add = newList.stream().filter(s -> !existList.contains(s)).collect(Collectors.toList());
List<String> del = existList.stream().filter(s -> !newList.contains(s)).collect(Collectors.toList());
add.forEach(s -> {
TabStoreField tabStoreField = this.storeFieldService.getStoreFieldById(Integer.valueOf(s));
if(tabStoreField.getStoreFieldType() != null && tabStoreField.getStoreFieldType().intValue() == 1){
return;
}
TabStoreDict tabStoreDict = new TabStoreDict();
tabStoreDict.setEnterpriseId(enterpriseId);
tabStoreDict.setCreateTime(new Date());
tabStoreDict.setValue(s);
this.storeDictService.saveStoreField(tabStoreDict);
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
Object existObj = RedisUtil.getCache(key);
if(existObj == null){
for(int i=1; i<=10; i++){
Object obj = RedisUtil.getCache(keyc+"c"+i);
if(obj == null){
RedisUtil.setCache(keyc+"c"+i, s);
RedisUtil.setCache(key, "c"+i);
break;
}
if(CollectionUtils.isNotEmpty(add)){
add.forEach(s -> {
TabStoreField tabStoreField = this.storeFieldService.getStoreFieldById(Integer.valueOf(s));
if(tabStoreField.getStoreFieldType() != null && tabStoreField.getStoreFieldType().intValue() == 1){
return;
}
}
});
del.forEach(s -> {
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
this.storeDictService.deleteStoreField(enterpriseId, s);
Object c = RedisUtil.getCache(key);
String storeListSourceKey = StoreRedisKeyUtils.getStoreListSourceKey(enterpriseId, userId);
if(c != null){
RedisUtil.delCache(c.toString());
//门店列表自定义字段配置,取消时需要删除当前已经配置的列表显示字段
Object storeListSource = RedisUtil.getCache(storeListSourceKey);
if(storeListSource != null){
String[] arr = storeListSource.toString().split(",");
String result = "";
for(String a : arr){
if(!c.toString().equals(a)){
result += a+",";
TabStoreDict tabStoreDict = new TabStoreDict();
tabStoreDict.setEnterpriseId(enterpriseId);
tabStoreDict.setCreateTime(new Date());
tabStoreDict.setValue(s);
this.storeDictService.saveStoreField(tabStoreDict);
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
Object existObj = RedisUtil.getCache(key);
if(existObj == null){
for(int i=1; i<=10; i++){
Object obj = RedisUtil.getCache(keyc+"c"+i);
if(obj == null){
RedisUtil.setCache(keyc+"c"+i, s);
RedisUtil.setCache(key, "c"+i);
break;
}
}
if(StringUtils.isNotBlank(result)){
RedisUtil.setCache(storeListSourceKey, result);
}
});
}
if(CollectionUtils.isNotEmpty(del)){
del.forEach(s -> {
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
this.storeDictService.deleteStoreField(enterpriseId, s);
Object c = RedisUtil.getCache(key);
String storeListSourceKey = StoreRedisKeyUtils.getStoreListSourceKey(enterpriseId, userId);
if(c != null){
RedisUtil.delCache(c.toString());
//门店列表自定义字段配置,取消时需要删除当前已经配置的列表显示字段
Object storeListSource = RedisUtil.getCache(storeListSourceKey);
if(storeListSource != null){
String[] arr = storeListSource.toString().split(",");
String result = "";
for(String a : arr){
if(!c.toString().equals(a)){
result += a+",";
}
}
if(StringUtils.isNotBlank(result)){
RedisUtil.setCache(storeListSourceKey, result);
}
}
}
}
RedisUtil.delCache(key);
});
RedisUtil.delCache(key);
});
}
return ServiceResponse.success();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment