fix(common): 统一异常处理并迁移打印功能到hiprint

- 替换所有System.out.println和printStackTrace为slf4j日志记录
- 在BeanUtils、AuditFieldUtil、DateUtils、ServletUtils等工具类中添加Logger实例
- 在Flowable相关控制器和服务中统一错误日志记录格式
- 在代码生成器中添加日志记录功能
- 将前端打印组件从Lodop迁移到hiprint打印方案
- 更新体温单打印功能使用hiprint预览打印
- 移除调试用的console.log语句
- 修复打印模板中线条元素类型定义
This commit is contained in:
2026-03-06 22:16:44 +08:00
parent 8ef334ba1b
commit b65841c0cc
58 changed files with 678 additions and 888 deletions

View File

@@ -2,6 +2,8 @@ package com.core.common.utils;
import com.core.common.core.domain.model.LoginUser;
import com.core.common.utils.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
@@ -13,6 +15,8 @@ import java.util.Date;
*/
@Component
public class AuditFieldUtil {
private static final Logger log = LoggerFactory.getLogger(AuditFieldUtil.class);
/**
* 为实体设置创建相关的审计字段
@@ -65,8 +69,7 @@ public class AuditFieldUtil {
}
} catch (Exception e) {
System.err.println("设置创建审计字段时发生异常: " + e.getMessage());
e.printStackTrace();
log.error("设置创建审计字段时发生异常", e);
}
}
@@ -110,8 +113,7 @@ public class AuditFieldUtil {
}
} catch (Exception e) {
System.err.println("设置更新审计字段时发生异常: " + e.getMessage());
e.printStackTrace();
log.error("设置更新审计字段时发生异常", e);
}
}

View File

@@ -1,6 +1,8 @@
package com.core.common.utils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.management.ManagementFactory;
import java.text.ParseException;
@@ -13,10 +15,13 @@ import java.util.Date;
/**
* 时间工具类
*
*
* @author system
*/
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
private static final Logger log = LoggerFactory.getLogger(DateUtils.class);
public static String YYYY = "yyyy";
public static String YYYY_MM = "yyyy-MM";
@@ -227,7 +232,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return endTime;
}
} catch (DateTimeParseException e) {
e.printStackTrace();
log.warn("日期解析失败: {}", strDate, e);
}
return null;
}
@@ -250,7 +255,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
// 检查日期是否是未来的时间
return dateToCheck.isAfter(currentDate);
} catch (Exception e) {
e.printStackTrace();
log.warn("日期解析失败: {}", dateString, e);
// 解析失败或其他异常,返回 false 或根据需要处理异常
return false;
}

View File

@@ -2,6 +2,8 @@ package com.core.common.utils;
import com.core.common.constant.Constants;
import com.core.common.core.text.Convert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -20,10 +22,13 @@ import java.util.Map;
/**
* 客户端工具类
*
*
* @author system
*/
public class ServletUtils {
private static final Logger log = LoggerFactory.getLogger(ServletUtils.class);
/**
* 获取String参数
*/
@@ -130,7 +135,7 @@ public class ServletUtils {
response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
} catch (IOException e) {
e.printStackTrace();
log.error("渲染响应字符串失败", e);
}
}

View File

@@ -1,5 +1,8 @@
package com.core.common.utils.bean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@@ -12,6 +15,9 @@ import java.util.regex.Pattern;
* @author system
*/
public class BeanUtils extends org.springframework.beans.BeanUtils {
private static final Logger log = LoggerFactory.getLogger(BeanUtils.class);
/**
* Bean方法名中属性名开始的下标
*/
@@ -37,7 +43,7 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
try {
copyProperties(src, dest);
} catch (Exception e) {
e.printStackTrace();
log.error("Bean属性复制失败", e);
}
}