Browse Source

update 优化 异常日志输出方式

疯狂的狮子Li 5 months ago
parent
commit
81293c9368

+ 9 - 4
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java

@@ -10,6 +10,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.excel.util.StringUtils;
 import com.alibaba.excel.util.StringUtils;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.batik.transcoder.TranscoderInput;
 import org.apache.batik.transcoder.TranscoderInput;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.image.PNGTranscoder;
 import org.apache.batik.transcoder.image.PNGTranscoder;
@@ -59,6 +60,7 @@ import java.util.zip.ZipOutputStream;
  *
  *
  * @author may
  * @author may
  */
  */
+@Slf4j
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 @Service
 @Service
 public class ActModelServiceImpl implements IActModelService {
 public class ActModelServiceImpl implements IActModelService {
@@ -131,7 +133,7 @@ public class ActModelServiceImpl implements IActModelService {
             repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(xml));
             repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(xml));
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -157,6 +159,7 @@ public class ActModelServiceImpl implements IActModelService {
                 modelVo.setDescription(model.getMetaInfo());
                 modelVo.setDescription(model.getMetaInfo());
                 return modelVo;
                 return modelVo;
             } catch (Exception e) {
             } catch (Exception e) {
+                log.error(e.getMessage(), e);
                 throw new ServiceException(e.getMessage());
                 throw new ServiceException(e.getMessage());
             }
             }
         }
         }
@@ -181,6 +184,7 @@ public class ActModelServiceImpl implements IActModelService {
             model.setMetaInfo(modelBo.getDescription());
             model.setMetaInfo(modelBo.getDescription());
             repositoryService.saveModel(model);
             repositoryService.saveModel(model);
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
         return true;
         return true;
@@ -230,7 +234,7 @@ public class ActModelServiceImpl implements IActModelService {
             repositoryService.addModelEditorSourceExtra(model.getId(), result);
             repositoryService.addModelEditorSourceExtra(model.getId(), result);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -325,7 +329,7 @@ public class ActModelServiceImpl implements IActModelService {
             }
             }
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -370,7 +374,7 @@ public class ActModelServiceImpl implements IActModelService {
             // 刷出响应流
             // 刷出响应流
             response.flushBuffer();
             response.flushBuffer();
         } catch (IOException e) {
         } catch (IOException e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
         }
         }
     }
     }
 
 
@@ -417,6 +421,7 @@ public class ActModelServiceImpl implements IActModelService {
                 }
                 }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
         return true;
         return true;

+ 6 - 3
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java

@@ -9,6 +9,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.StreamUtils;
 import org.dromara.common.core.utils.StreamUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -55,6 +56,7 @@ import java.util.zip.ZipInputStream;
  *
  *
  * @author may
  * @author may
  */
  */
+@Slf4j
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 @Service
 @Service
 public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService {
 public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService {
@@ -208,7 +210,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             wfNodeConfigService.deleteByDefIds(processDefinitionIds);
             wfNodeConfigService.deleteByDefIds(processDefinitionIds);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -233,7 +235,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             }
             }
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException("操作失败:" + e.getMessage());
             throw new ServiceException("操作失败:" + e.getMessage());
         }
         }
     }
     }
@@ -262,6 +264,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
                 .migrateProcessInstances(fromProcessDefinitionId);
                 .migrateProcessInstances(fromProcessDefinitionId);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -291,7 +294,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             }
             }
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }

+ 4 - 4
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java

@@ -488,7 +488,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
                 historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false);
                 historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -523,7 +523,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -547,7 +547,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -597,7 +597,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
                 processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false);
                 processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false);
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("撤销失败:" + e.getMessage(), e);
             throw new ServiceException("撤销失败:" + e.getMessage());
             throw new ServiceException("撤销失败:" + e.getMessage());
         }
         }
     }
     }

+ 9 - 4
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.domain.dto.RoleDTO;
 import org.dromara.common.core.domain.dto.RoleDTO;
 import org.dromara.common.core.domain.dto.UserDTO;
 import org.dromara.common.core.domain.dto.UserDTO;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.ServiceException;
@@ -65,6 +66,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.*;
  *
  *
  * @author may
  * @author may
  */
  */
+@Slf4j
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 @Service
 @Service
 public class ActTaskServiceImpl implements IActTaskService {
 public class ActTaskServiceImpl implements IActTaskService {
@@ -227,6 +229,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             }
             }
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -475,7 +478,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             taskService.complete(newTask.getId());
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -545,7 +548,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.setAssignee(task.getId(), transmitBo.getUserId());
             taskService.setAssignee(task.getId(), transmitBo.getUserId());
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -593,7 +596,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             taskService.complete(newTask.getId());
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -643,7 +646,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             taskService.complete(newTask.getId());
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
     }
     }
@@ -723,6 +726,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             //删除驳回后的流程节点
             //删除驳回后的流程节点
             wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId());
             wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId());
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
             throw new ServiceException(e.getMessage());
         }
         }
         return task.getProcessInstanceId();
         return task.getProcessInstanceId();
@@ -743,6 +747,7 @@ public class ActTaskServiceImpl implements IActTaskService {
                 taskService.setAssignee(task.getId(), userId);
                 taskService.setAssignee(task.getId(), userId);
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error("修改失败:" + e.getMessage(), e);
             throw new ServiceException("修改失败:" + e.getMessage());
             throw new ServiceException("修改失败:" + e.getMessage());
         }
         }
         return true;
         return true;

+ 3 - 1
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.satoken.utils.LoginHelper;
@@ -29,6 +30,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.USER_TASK;
  * @author may
  * @author may
  * @date 2024-03-13
  * @date 2024-03-13
  */
  */
+@Slf4j
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 @Service
 @Service
 public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
 public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
@@ -109,7 +111,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
             }
             }
             return true;
             return true;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException("删除失败");
             throw new ServiceException("删除失败");
         }
         }
     }
     }