fix: 81861 企标复审流程--强制撤回后,草稿中数据不正确

This commit is contained in:
2024-02-19 11:35:19 +08:00
parent d71e0bd0d0
commit e1b429a08c
3 changed files with 45 additions and 2 deletions
@@ -1,5 +1,6 @@
package com.jero.common.aspect;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -98,6 +99,13 @@ public class TranslationAspect {
}
}
/**
* 手动发起流程
* 流程发起将数据翻译后保存为json以供强制撤回后使用
* @param data
* @param user
* @return
*/
public String manualParseDictText(Object data, Object user) {
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
if (CollectionUtils.isEmpty(listDict)) {
@@ -108,6 +116,40 @@ public class TranslationAspect {
return dataJsonObject.toJSONString();
}
/**
* 自动发起流程的
* 流程发起将数据翻译后保存为json以供强制撤回后使用
* @param data
* @param user
* @return
*/
public String autoParseDictText(Object data, Map<String, Object> user) {
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
if (CollectionUtils.isEmpty(listDict)) {
return "";
}
JSONObject dataJsonObject = (JSONObject) translateObject(data, listDict);
// 对人员进行翻译
dataJsonObject.put("personnelObj", this.translateUser(user, listDict));
return dataJsonObject.toJSONString();
}
private Object translateUser(Map<String, Object> user, List<SysDictItemCore> listDict) {
Map<String, Object> result = new HashMap<>();
for (Map.Entry<String, Object> entry : user.entrySet()) {
String value = (String) entry.getValue();
if (StrUtil.isBlank(value)) {
continue;
}
String code = "id";
String text = "CONCAT(realname, '(', username, ')')";
String table = "sys_user";
String textValue = translateDictValue(code, text, table, value, listDict);
result.put(entry.getKey(), value);
result.put(entry.getKey() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
return result;
}
private Object translateObject(Object record, List<SysDictItemCore> listDict) {
ObjectMapper mapper = new ObjectMapper();