|
|
|
@ -10,13 +10,13 @@ import com.project.operation.domain.dto.OperationLogExportDTO; |
|
|
|
import com.project.operation.domain.param.OperationLogParam; |
|
|
|
import com.project.operation.domain.service.SaveOperationLogDomainService; |
|
|
|
import com.project.operation.domain.service.SearchOperationLogDomainService; |
|
|
|
import jakarta.servlet.http.HttpServletResponse;; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class OperationLogApplicationServiceImpl implements OperationLogApplicationService { |
|
|
|
@ -30,6 +30,7 @@ public class OperationLogApplicationServiceImpl implements OperationLogApplicati |
|
|
|
private static final String EXCEL_FILENAME = "operationLog"; |
|
|
|
private static final Integer PAGE_MAX_SIZE = 5001; |
|
|
|
private static final Integer PAGE_DEFAULT_CURRENT = 1; |
|
|
|
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存日志 |
|
|
|
@ -61,14 +62,27 @@ public class OperationLogApplicationServiceImpl implements OperationLogApplicati |
|
|
|
//获取日志列表
|
|
|
|
param.setSize(PAGE_MAX_SIZE); |
|
|
|
param.setCurrent(PAGE_DEFAULT_CURRENT); |
|
|
|
List<OperationLogExportDTO> operationLogExportDTOList = searchOperationLogDomainService.list(param).getData().getContent() |
|
|
|
.stream().map(dto -> dto.toEntity(OperationLogExportDTO::new)).collect(Collectors.toList()); |
|
|
|
if (operationLogExportDTOList.size() == PAGE_MAX_SIZE) { |
|
|
|
|
|
|
|
List<OperationLogDTO> operationLogDTOList = searchOperationLogDomainService.list(param).getData().getContent(); |
|
|
|
|
|
|
|
if (operationLogDTOList.size() == PAGE_MAX_SIZE) { |
|
|
|
throw new BusinessErrorException("最大条数限制5000条超过最大限制不允许导出"); |
|
|
|
} |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); |
|
|
|
|
|
|
|
List<OperationLogExportDTO> operationLogExportDTOList = new java.util.ArrayList<>(operationLogDTOList.size()); |
|
|
|
for (OperationLogDTO dto : operationLogDTOList) { |
|
|
|
OperationLogExportDTO exportDTO = dto.toEntity(OperationLogExportDTO::new); |
|
|
|
// 格式化操作时间为字符串
|
|
|
|
if (dto.getCreateTime() != null) { |
|
|
|
exportDTO.setCreateTime(sdf.format(dto.getCreateTime())); |
|
|
|
} |
|
|
|
operationLogExportDTOList.add(exportDTO); |
|
|
|
} |
|
|
|
|
|
|
|
ExcelUtil<OperationLogExportDTO> util = new ExcelUtil<>(); |
|
|
|
util.exportExcel(response,operationLogExportDTOList,SHEET_NAME,EXCEL_FILENAME,OperationLogExportDTO.class); |
|
|
|
util.exportExcel(response, operationLogExportDTOList, SHEET_NAME, EXCEL_FILENAME, OperationLogExportDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|