【fix sonar】DictAspect文件
This commit is contained in:
+9
-7
@@ -13,6 +13,7 @@ import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
@@ -143,8 +144,8 @@ public class DictAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private void addItems(Result result, List<JSONObject> items, List<Field> dictFieldList, Map<String, List<String>> dataListMap) {
|
||||
for (Object obj : ((IPage) result.getResult()).getRecords()) {
|
||||
private void addItems(Result<IPage<T>> result, List<JSONObject> items, List<Field> dictFieldList, Map<String, List<String>> dataListMap) {
|
||||
for (Object obj : result.getResult().getRecords()) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json="{}";
|
||||
try {
|
||||
@@ -155,7 +156,6 @@ public class DictAspect {
|
||||
}
|
||||
JSONObject item = JSON.parseObject(json);
|
||||
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
|
||||
//for (Field field : record.getClass().getDeclaredFields()) {
|
||||
// 遍历所有字段,把字典Code取出来,放到 map 里
|
||||
putItem(dictFieldList, dataListMap, obj, item);
|
||||
items.add(item);
|
||||
@@ -215,8 +215,9 @@ public class DictAspect {
|
||||
// 需要翻译的数据(有些可以从redis缓存中获取,就不走数据库查询)
|
||||
List<String> needTranslData = new ArrayList<>();
|
||||
//step.1 先通过redis中获取缓存字典数据
|
||||
for (String dictCode : dataListMap.keySet()) {
|
||||
List<String> dataList = dataListMap.get(dictCode);
|
||||
for (Map.Entry<String, List<String>> entry : dataListMap.entrySet()) {
|
||||
String dictCode = entry.getKey();
|
||||
List<String> dataList = entry.getValue();
|
||||
if (dataList.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -252,9 +253,10 @@ public class DictAspect {
|
||||
log.info("translateManyDict.values:" + values);
|
||||
Map<String, List<DictModel>> manyDict = commonAPI.translateManyDict(dictCodes, values);
|
||||
log.info("translateManyDict.result:" + manyDict);
|
||||
for (String dictCode : manyDict.keySet()) {
|
||||
for (Map.Entry<String, List<DictModel>> entry : manyDict.entrySet()) {
|
||||
String dictCode = entry.getKey();
|
||||
List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
List<DictModel> newList = manyDict.get(dictCode);
|
||||
List<DictModel> newList = entry.getValue();
|
||||
list.addAll(newList);
|
||||
|
||||
// 做 redis 缓存
|
||||
|
||||
Reference in New Issue
Block a user