Commit ee0ec9da authored by wujipeng's avatar wujipeng
Browse files

增加排序

parent 3c307cc7
package com.ruzhoukj.sms.controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* 文件内容读取接口
* 接收一个以 .out 结尾的日志文件,将其内容转换为字符串返回
*/
@RestController
@RequestMapping("/api/log")
public class LogFileController {
/**
* 处理日志文件上传并返回文件内容
*
* @param file 上传的日志文件,必须以 .out 结尾
* @return 文件内容字符串
* @throws IllegalArgumentException 当文件不符合要求时抛出异常
*/
@PostMapping("/read-content")
public String readLogFileContent(@RequestParam("file") MultipartFile file) {
// 1. 检查文件是否为空
if (file.isEmpty()) {
throw new IllegalArgumentException("上传的文件不能为空");
}
// 2. 验证文件扩展名是否为 .out
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || !originalFilename.endsWith(".out")) {
throw new IllegalArgumentException("文件必须以 .out 结尾");
}
try {
// 3. 将文件内容转换为字符串
// 使用StandardCharsets.UTF_8确保正确的字符编码
String content = new String(file.getBytes(), StandardCharsets.UTF_8);
//只取最后两万个字符
content = content.substring(Math.max(0, content.length() - 20000));
// 4. 返回文件内容
return content;
} catch (IOException e) {
// 5. 处理文件读取异常
throw new RuntimeException("文件读取失败: " + e.getMessage(), e);
}
}
}
\ No newline at end of file
...@@ -8,6 +8,16 @@ spring: ...@@ -8,6 +8,16 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.10.3:3307/ops?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true url: jdbc:mysql://192.168.10.3:3307/ops?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
servlet:
multipart:
# 单个文件大小限制
max-file-size: 2048MB
# 整个请求大小限制(包括文件和其他表单数据)
max-request-size: 2048MB
mybatis-plus: mybatis-plus:
configuration: configuration:
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
and project like concat('%',#{project},'%') and project like concat('%',#{project},'%')
</if> </if>
</where> </where>
order by
reservation_time de
</select> </select>
<select id="record" resultType="com.ruzhoukj.sms.model.vo.KzWorkVO"> <select id="record" resultType="com.ruzhoukj.sms.model.vo.KzWorkVO">
select select
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment