update 流程节点绑定审批人

This commit is contained in:
lijiarao
2023-10-16 15:35:59 +08:00
parent 2410acf525
commit 658a3d7656
31 changed files with 548 additions and 508 deletions
@@ -138,4 +138,6 @@ public interface CommonAPI {
* @return JSONObject
*/
String queryTableDictTextByKey(String table,String text,String code, String key);
String translateUserRealNameFromTable(String id);
}
@@ -1,5 +1,6 @@
package com.jero.common.aspect;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -52,6 +53,9 @@ public class DictAspect {
public void excudeService() {
// do other
}
@Pointcut("@annotation(com.jero.common.aspect.annotation.DictPoint)")
public void dictPointCut() {
}
@Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
@@ -66,6 +70,19 @@ public class DictAspect {
return result;
}
@Around("dictPointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable {
long time1 = System.currentTimeMillis();
Object result = point.proceed();
long time2 = System.currentTimeMillis();
log.debug("获取JSON数据 耗时:" + (time2 - time1) + "ms");
long start = System.currentTimeMillis();
this.parseMethodDictText(result);
long end = System.currentTimeMillis();
log.debug("解析注入JSON数据 耗时" + (end - start) + "ms");
return result;
}
/**
* 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
* 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 table字典 code table text配合使用与原来jero的用法相同
@@ -396,7 +413,12 @@ public class DictAspect {
log.warn(e.getMessage());
}
}else {
tmpValue= commonAPI.translateDictFromTable(table,text,code,k.trim());
//处理用户要翻译为姓名加工号
if ("sys_user".equals(table)&&"realname".equals(text)&&"id".equals(code)){
tmpValue= commonAPI.translateUserRealNameFromTable(k.trim());
}else {
tmpValue= commonAPI.translateDictFromTable(table,text,code,k.trim());
}
}
}else {
String keyString = String.format(SYS_CACHE_DICT_S_S,code,k.trim());
@@ -413,5 +435,66 @@ public class DictAspect {
return tmpValue;
}
/**
* @param result
*/
private void parseMethodDictText(Object result) {
if (result instanceof Result) {
Object result1 = ((Result<Object>) result).getResult();
String jsonStr = JSONUtil.toJsonStr(result1);
if (JSONUtil.isTypeJSONObject(jsonStr)) {
JSONObject translate = translate(result1);
((Result<Object>) result).setResult(translate);
} else {
List<JSONObject> items = new ArrayList<>();
for (Object o : (List<Object>) result1) {
JSONObject translate = translate(o);
items.add(translate);
}
((Result<Object>) result).setResult(items);
}
}
}
/**
* @param record
* @return
*/
private JSONObject translate(Object record) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json);
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
//for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
//翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + " " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
//date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
return item;
}
}
@@ -0,0 +1,17 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 字典转换点注解
* 加到方法上,返回值会返回字典数据
* @author liJiaRao
* @date 2021-08-02 9:44
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DictPoint {
}