fix(common): 统一异常处理并迁移打印功能到hiprint
- 替换所有System.out.println和printStackTrace为slf4j日志记录 - 在BeanUtils、AuditFieldUtil、DateUtils、ServletUtils等工具类中添加Logger实例 - 在Flowable相关控制器和服务中统一错误日志记录格式 - 在代码生成器中添加日志记录功能 - 将前端打印组件从Lodop迁移到hiprint打印方案 - 更新体温单打印功能使用hiprint预览打印 - 移除调试用的console.log语句 - 修复打印模板中线条元素类型定义
This commit is contained in:
@@ -7,6 +7,8 @@ import com.openhis.common.annotation.Dict;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -20,6 +22,8 @@ import java.util.List;
|
||||
@Component
|
||||
public class DictAspect {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DictAspect.class);
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate; // 使用 JdbcTemplate 执行 SQL
|
||||
|
||||
@@ -99,15 +103,15 @@ public class DictAspect {
|
||||
// 查询字典值
|
||||
String dictLabel = queryDictLabel(dictTable, dictCode, dictText, deleteFlag, fieldValue.toString());
|
||||
if (dictLabel != null) {
|
||||
// 动态生成 _dictText 字段名
|
||||
String textFieldName = field.getName() + "_dictText";
|
||||
try {
|
||||
// 动态生成 _dictText 字段名
|
||||
String textFieldName = field.getName() + "_dictText";
|
||||
Field textField = dto.getClass().getDeclaredField(textFieldName);
|
||||
textField.setAccessible(true);
|
||||
textField.set(dto, dictLabel); // 设置 _dictText 字段的值
|
||||
} catch (NoSuchFieldException e) {
|
||||
// 如果 _dictText 字段不存在,忽略错误
|
||||
e.printStackTrace();
|
||||
log.debug("字段 {} 不存在,跳过字典翻译", textFieldName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.core.common.utils.DateUtils;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.framework.config.TenantContext;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -21,6 +23,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class HisQueryUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HisQueryUtils.class);
|
||||
|
||||
/**
|
||||
* 条件查询构造器
|
||||
*
|
||||
@@ -72,7 +76,7 @@ public class HisQueryUtils {
|
||||
queryWrapper.ge(dbFieldName, startDate); // 大于等于 STime
|
||||
queryWrapper.le(dbFieldName, endDate); // 小于等于 ETime
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("日期解析失败: startValue={}, endValue={}", startValue, endValue, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,7 +104,7 @@ public class HisQueryUtils {
|
||||
queryWrapper.eq(fieldName, value);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("反射获取字段值失败: field={}", field.getName(), e);
|
||||
}
|
||||
}
|
||||
currentClass = currentClass.getSuperclass();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.openhis.common.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -16,6 +18,8 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class RedisUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RedisUtil.class);
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
@Autowired
|
||||
@@ -35,7 +39,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.hasKey(key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +108,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,7 +131,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +198,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +219,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +237,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForHash().put(key, item, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +259,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -316,7 +320,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -332,7 +336,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForSet().isMember(key, value);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +352,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForSet().add(key, values);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -369,7 +373,7 @@ public class RedisUtil {
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -384,7 +388,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForSet().size(key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -401,7 +405,7 @@ public class RedisUtil {
|
||||
Long count = redisTemplate.opsForSet().remove(key, values);
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -419,7 +423,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForList().range(key, start, end);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -434,7 +438,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForList().size(key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -450,7 +454,7 @@ public class RedisUtil {
|
||||
try {
|
||||
return redisTemplate.opsForList().index(key, index);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -468,7 +472,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForList().rightPush(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -489,7 +493,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +511,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForList().rightPushAll(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -528,7 +532,7 @@ public class RedisUtil {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -546,7 +550,7 @@ public class RedisUtil {
|
||||
redisTemplate.opsForList().set(key, index, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis expire操作失败, key: {}", key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -564,7 +568,7 @@ public class RedisUtil {
|
||||
Long remove = redisTemplate.opsForList().remove(key, count, value);
|
||||
return remove;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis操作失败, key: {}", key, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -590,7 +594,7 @@ public class RedisUtil {
|
||||
return binaryKeys;
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis scan操作失败, keyPrefix: {}", keyPrefix, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -605,7 +609,7 @@ public class RedisUtil {
|
||||
Set<String> keys = keys(keyPrefix);
|
||||
redisTemplate.delete(keys);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
log.error("Redis删除操作失败, keyPrefix: {}", keyPrefix, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user