feat: 复审流程保存自翻译
This commit is contained in:
+31
-18
@@ -61,16 +61,17 @@ public class TranslationAspect {
|
||||
|
||||
/**
|
||||
* 在切入点return内容之后切入内容(可以用来对处理返回值做一些加工处理)
|
||||
*
|
||||
* @param joinPoint
|
||||
*/
|
||||
@AfterReturning(returning="rvt",pointcut = "annotationPointcut()")
|
||||
@AfterReturning(returning = "rvt", pointcut = "annotationPointcut()")
|
||||
public void doAfterReturning(JoinPoint joinPoint, Object rvt) {
|
||||
|
||||
}
|
||||
|
||||
private void parseDictText(Object result) {
|
||||
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
|
||||
if(CollectionUtils.isEmpty(listDict)){
|
||||
if (CollectionUtils.isEmpty(listDict)) {
|
||||
return;
|
||||
}
|
||||
if (result instanceof Result) {
|
||||
@@ -78,25 +79,36 @@ public class TranslationAspect {
|
||||
List<Object> items = new ArrayList<>();
|
||||
|
||||
for (Object record : ((IPage) ((Result) result).getResult()).getRecords()) {
|
||||
Object item = translateObject(record,listDict);
|
||||
Object item = translateObject(record, listDict);
|
||||
items.add(item);
|
||||
}
|
||||
((IPage) ((Result) result).getResult()).setRecords(items);
|
||||
}else if (((Result) result).getResult() instanceof List) {
|
||||
} else if (((Result) result).getResult() instanceof List) {
|
||||
List<Object> items = new ArrayList<>();
|
||||
for (Object record : ((List) ((Result) result).getResult())) {
|
||||
Object item = translateObject(record,listDict);
|
||||
Object item = translateObject(record, listDict);
|
||||
items.add(item);
|
||||
}
|
||||
((Result) result).setResult(items);
|
||||
}else{
|
||||
} else {
|
||||
Object record = (Object) ((Result) result).getResult();
|
||||
Object item = translateObject(record,listDict);
|
||||
Object item = translateObject(record, listDict);
|
||||
((Result) result).setResult(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String manualParseDictText(Object data, Object user) {
|
||||
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
|
||||
if (CollectionUtils.isEmpty(listDict)) {
|
||||
return "";
|
||||
}
|
||||
JSONObject dataJsonObject = (JSONObject) translateObject(data, listDict);
|
||||
dataJsonObject.put("personnelObj", user);
|
||||
return dataJsonObject.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
private Object translateObject(Object record, List<SysDictItemCore> listDict) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json;
|
||||
@@ -172,15 +184,16 @@ public class TranslationAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译字典文本
|
||||
* @param code 编码
|
||||
* @param text 值
|
||||
* @param table 表名
|
||||
* @param key 键
|
||||
* 翻译字典文本
|
||||
*
|
||||
* @param code 编码
|
||||
* @param text 值
|
||||
* @param table 表名
|
||||
* @param key 键
|
||||
* @param listDict 字典集合
|
||||
*/
|
||||
private String translateDictValue(String code, String text, String table, String key, List<SysDictItemCore> listDict) {
|
||||
if(oConvertUtils.isEmpty(key)) {
|
||||
if (oConvertUtils.isEmpty(key)) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder textValue = new StringBuilder();
|
||||
@@ -190,11 +203,11 @@ public class TranslationAspect {
|
||||
if (k.trim().length() == 0) {
|
||||
continue; //跳过循环
|
||||
}
|
||||
if (!StringUtils.isEmpty(table)){
|
||||
tmpValue = commonAPI.queryTableDictTextByKey(table,text,code,k.trim());
|
||||
}else {
|
||||
List<SysDictItemCore> listNew = listDict.stream().filter(o-> Objects.equals(o.getDictCode(),code) && Objects.equals(o.getItemValue(),k.trim())).collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(listNew)){
|
||||
if (!StringUtils.isEmpty(table)) {
|
||||
tmpValue = commonAPI.queryTableDictTextByKey(table, text, code, k.trim());
|
||||
} else {
|
||||
List<SysDictItemCore> listNew = listDict.stream().filter(o -> Objects.equals(o.getDictCode(), code) && Objects.equals(o.getItemValue(), k.trim())).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(listNew)) {
|
||||
tmpValue = listNew.get(0).getItemText();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user