Quellcode durchsuchen

update 优化 异常日志输出方式

疯狂的狮子Li vor 5 Monaten
Ursprung
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 jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.batik.transcoder.TranscoderInput;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.image.PNGTranscoder;
@@ -59,6 +60,7 @@ import java.util.zip.ZipOutputStream;
  *
  * @author may
  */
+@Slf4j
 @RequiredArgsConstructor
 @Service
 public class ActModelServiceImpl implements IActModelService {
@@ -131,7 +133,7 @@ public class ActModelServiceImpl implements IActModelService {
             repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(xml));
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -157,6 +159,7 @@ public class ActModelServiceImpl implements IActModelService {
                 modelVo.setDescription(model.getMetaInfo());
                 return modelVo;
             } catch (Exception e) {
+                log.error(e.getMessage(), e);
                 throw new ServiceException(e.getMessage());
             }
         }
@@ -181,6 +184,7 @@ public class ActModelServiceImpl implements IActModelService {
             model.setMetaInfo(modelBo.getDescription());
             repositoryService.saveModel(model);
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
         return true;
@@ -230,7 +234,7 @@ public class ActModelServiceImpl implements IActModelService {
             repositoryService.addModelEditorSourceExtra(model.getId(), result);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -325,7 +329,7 @@ public class ActModelServiceImpl implements IActModelService {
             }
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -370,7 +374,7 @@ public class ActModelServiceImpl implements IActModelService {
             // 刷出响应流
             response.flushBuffer();
         } catch (IOException e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
         }
     }
 
@@ -417,6 +421,7 @@ public class ActModelServiceImpl implements IActModelService {
                 }
             }
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
         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 lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.StreamUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -55,6 +56,7 @@ import java.util.zip.ZipInputStream;
  *
  * @author may
  */
+@Slf4j
 @RequiredArgsConstructor
 @Service
 public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService {
@@ -208,7 +210,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             wfNodeConfigService.deleteByDefIds(processDefinitionIds);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -233,7 +235,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             }
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException("操作失败:" + e.getMessage());
         }
     }
@@ -262,6 +264,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
                 .migrateProcessInstances(fromProcessDefinitionId);
             return true;
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -291,7 +294,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
             }
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             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);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -523,7 +523,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -547,7 +547,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
             wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -597,7 +597,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
                 processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false);
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("撤销失败:" + e.getMessage(), e);
             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.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.domain.dto.RoleDTO;
 import org.dromara.common.core.domain.dto.UserDTO;
 import org.dromara.common.core.exception.ServiceException;
@@ -65,6 +66,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.*;
  *
  * @author may
  */
+@Slf4j
 @RequiredArgsConstructor
 @Service
 public class ActTaskServiceImpl implements IActTaskService {
@@ -227,6 +229,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             }
             return true;
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -475,7 +478,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -545,7 +548,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.setAssignee(task.getId(), transmitBo.getUserId());
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -593,7 +596,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -643,7 +646,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             taskService.complete(newTask.getId());
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
     }
@@ -723,6 +726,7 @@ public class ActTaskServiceImpl implements IActTaskService {
             //删除驳回后的流程节点
             wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId());
         } catch (Exception e) {
+            log.error(e.getMessage(), e);
             throw new ServiceException(e.getMessage());
         }
         return task.getProcessInstanceId();
@@ -743,6 +747,7 @@ public class ActTaskServiceImpl implements IActTaskService {
                 taskService.setAssignee(task.getId(), userId);
             }
         } catch (Exception e) {
+            log.error("修改失败:" + e.getMessage(), e);
             throw new ServiceException("修改失败:" + e.getMessage());
         }
         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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
@@ -29,6 +30,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.USER_TASK;
  * @author may
  * @date 2024-03-13
  */
+@Slf4j
 @RequiredArgsConstructor
 @Service
 public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
@@ -109,7 +111,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
             }
             return true;
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
             throw new ServiceException("删除失败");
         }
     }