Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
ee0ec9da
Commit
ee0ec9da
authored
Nov 03, 2025
by
wujipeng
Browse files
增加排序
parent
3c307cc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/LogFileController.java
0 → 100644
View file @
ee0ec9da
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
src/main/resources/application.yml
View file @
ee0ec9da
...
@@ -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
:
...
...
src/main/resources/com/ruzhoukj/sms/dao/KzWorkDao.xml
View file @
ee0ec9da
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment