田源
2025-01-16 a13255b4129ee8a7a7b7e1ecd8e02dd2c78f7c17
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/LogBasicController.java
@@ -4,13 +4,20 @@
import com.vci.starter.web.annotation.log.VciBusinessLog;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.util.ControllerUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.web.service.LogBasicServiceI;
import com.vci.starter.web.util.Lcm.Func;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
/**
 * 平台日志控制器
@@ -88,6 +95,7 @@
         throw new VciBaseException(errorMsg);
      }
   }
   /**
    * 查询日志
    * @param dto 查询条件传输对象
@@ -95,7 +103,7 @@
    * @throws PLException
    */
   @VciBusinessLog(operateName="日志查询")
   @GetMapping(value = "/getLogListByContion")
   @PostMapping(value = "/getLogListByContion")
   @ResponseBody
   public BaseResult getLogListByContion(@RequestBody LogQueryCriteriaDTO dto){
      try {
@@ -124,4 +132,28 @@
         throw new VciBaseException(errorMsg);
      }
   }
   /**
    * 导出日志
    * @param dto 导出查询传参数对象
    * @param response
    */
   @PostMapping( "/exportLogs")
   @VciBusinessLog(operateName = "导出日志")
   public void exportLogs(@RequestBody LogQueryCriteriaDTO dto, HttpServletResponse response){
      try {
         String excelPath = logBasicServiceI.exportLogs(dto);
         ControllerUtil.writeFileToResponse(response,excelPath);
      } catch (Exception e) {
         String msg = "导出日志时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
         try {
            //出错时
            e.printStackTrace();
            ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
         } catch (IOException ioException) {
            ioException.printStackTrace();
         }
      }
   }
}