Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
7da2bd5d
Commit
7da2bd5d
authored
Mar 12, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 问答知识库 新增/更新分片内容,字数校验
parent
f4a7df26
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
33 deletions
+33
-33
KnowledgeServiceImpl.java
...om/poc/knowledge/aggregate/impl/KnowledgeServiceImpl.java
+33
-33
No files found.
src/main/java/cn/com/poc/knowledge/aggregate/impl/KnowledgeServiceImpl.java
View file @
7da2bd5d
...
@@ -419,39 +419,39 @@ public class KnowledgeServiceImpl implements KnowledgeService {
...
@@ -419,39 +419,39 @@ public class KnowledgeServiceImpl implements KnowledgeService {
if
(
fileSizeInMB
>
10
)
{
if
(
fileSizeInMB
>
10
)
{
throw
new
I18nMessageException
(
"exception/upload.more.than.10m"
);
throw
new
I18nMessageException
(
"exception/upload.more.than.10m"
);
}
}
//
ExcelReader
excelReader
=
ExcelUtil
.
getReader
(
file
);
//
ExcelReader excelReader = ExcelUtil.getReader(file);
Workbook
workbook
=
excelReader
.
getWorkbook
();
//
Workbook workbook = excelReader.getWorkbook();
Sheet
sheetAt
=
workbook
.
getSheetAt
(
0
);
//
Sheet sheetAt = workbook.getSheetAt(0);
int
rowNum
=
sheetAt
.
getLastRowNum
()
-
2
;
//行数
//
int rowNum = sheetAt.getLastRowNum() - 2;//行数
if
(
rowNum
>
1500
)
{
//
if (rowNum > 1500) {
throw
new
I18nMessageException
(
"exception/file.rows.more.than.1500"
);
//
throw new I18nMessageException("exception/file.rows.more.than.1500");
}
//
}
Row
row
=
sheetAt
.
getRow
(
2
);
//
Row row = sheetAt.getRow(2);
short
lastCellNum
=
row
.
getLastCellNum
();
//列数
//
short lastCellNum = row.getLastCellNum();//列数
if
(
lastCellNum
>
10
)
{
//
if (lastCellNum > 10) {
throw
new
I18nMessageException
(
"exception/file.columns.more.than.10"
);
//
throw new I18nMessageException("exception/file.columns.more.than.10");
}
//
}
int
lastRowNum
=
sheetAt
.
getLastRowNum
();
//最后一行索引
//
int lastRowNum = sheetAt.getLastRowNum();//最后一行索引
for
(
int
i
=
2
;
i
<=
lastRowNum
;
i
++)
{
//
for (int i = 2; i <= lastRowNum; i++) {
row
=
sheetAt
.
getRow
(
i
);
//
row = sheetAt.getRow(i);
//获取单元格内容
//
//获取单元格内容
Iterator
<
Cell
>
cellIterator
=
row
.
cellIterator
();
//
Iterator<Cell> cellIterator = row.cellIterator();
//每行字数不能超过3000字
//
//每行字数不能超过3000字
int
totalWordCount
=
0
;
//
int totalWordCount = 0;
while
(
cellIterator
.
hasNext
())
{
//
while (cellIterator.hasNext()) {
Cell
next
=
cellIterator
.
next
();
//
Cell next = cellIterator.next();
if
(
StringUtils
.
isNotBlank
(
next
.
toString
()))
{
//
if (StringUtils.isNotBlank(next.toString())) {
if
(
next
.
toString
().
length
()
>
700
)
{
// 每格字数不可超1000字
//
if (next.toString().length() > 700) { // 每格字数不可超1000字
throw
new
I18nMessageException
(
"exception/file.cell.content.more.than.700"
);
//
throw new I18nMessageException("exception/file.cell.content.more.than.700");
}
//
}
totalWordCount
+=
next
.
toString
().
length
();
//
totalWordCount += next.toString().length();
}
//
}
}
//
}
if
(
totalWordCount
>
3000
)
{
//每行字数不可超3000字
//
if (totalWordCount > 3000) { //每行字数不可超3000字
throw
new
I18nMessageException
(
"exception/file.rows.content.more.than.3000"
);
//
throw new I18nMessageException("exception/file.rows.content.more.than.3000");
}
//
}
}
//
}
return
true
;
return
true
;
}
}
}
}
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