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
邬吉朋
relation
Commits
029e3e71
Commit
029e3e71
authored
Aug 27, 2025
by
wujipeng
Browse files
文件解析优化
parent
92e7440e
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/com/platform/model/vo/AnalysisVO.java
View file @
029e3e71
package
com.platform.model.vo
;
package
com.platform.model.vo
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Builder
;
...
@@ -17,6 +18,7 @@ import java.util.List;
...
@@ -17,6 +18,7 @@ import java.util.List;
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Builder
@Builder
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AnalysisVO
{
public
class
AnalysisVO
{
@ApiModelProperty
(
"文件夹数"
)
@ApiModelProperty
(
"文件夹数"
)
...
...
src/main/java/com/platform/service/impl/AnalysisServiceImpl.java
View file @
029e3e71
...
@@ -62,6 +62,33 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -62,6 +62,33 @@ public class AnalysisServiceImpl implements AnalysisService {
@Override
@Override
@Transactional
@Transactional
public
Result
<?>
canvas
(
List
<
MultipartFile
>
files
,
int
caseId
,
String
folderName
)
throws
IOException
{
public
Result
<?>
canvas
(
List
<
MultipartFile
>
files
,
int
caseId
,
String
folderName
)
throws
IOException
{
//检查文件
List
<
AnalysisVO
>
detail
=
Lists
.
newArrayList
();
int
errorCount
=
0
;
int
totalCount
=
0
;
for
(
MultipartFile
file
:
files
)
{
if
(
isExcelFile
(
file
.
getOriginalFilename
()))
{
File
tempFile
=
convertMultipartFileToFile
(
file
);
Workbook
workbook
=
getWorkbook
(
tempFile
);
if
(
ObjectUtils
.
isEmpty
(
workbook
))
{
errorCount
++;
detail
.
add
(
AnalysisVO
.
builder
().
fileName
(
file
.
getOriginalFilename
()).
errorReason
(
"文件格式错误"
).
build
());
}
totalCount
++;
}
else
{
errorCount
++;
totalCount
++;
detail
.
add
(
AnalysisVO
.
builder
().
fileName
(
file
.
getOriginalFilename
()).
errorReason
(
"文件格式错误"
).
build
());
}
}
if
(
errorCount
>
0
)
{
return
Result
.
data
(
400
,
AnalysisVO
.
builder
()
.
detail
(
detail
)
.
totalCount
(
totalCount
)
.
errorCount
(
errorCount
)
.
build
(),
"部分文件格式错误"
);
}
//查询模板
//查询模板
ExcelTemplateEntity
ExcelTemplate
=
excelTemplateService
.
getMaxId
();
ExcelTemplateEntity
ExcelTemplate
=
excelTemplateService
.
getMaxId
();
List
<
TableHeaderVO
>
tableHeaderList
;
List
<
TableHeaderVO
>
tableHeaderList
;
...
@@ -94,10 +121,6 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -94,10 +121,6 @@ public class AnalysisServiceImpl implements AnalysisService {
return
Result
.
fail
(
"上传的文件为空"
);
return
Result
.
fail
(
"上传的文件为空"
);
}
}
List
<
FileUploadVO
>
fileUploadList
=
Lists
.
newArrayList
();
List
<
FileUploadVO
>
fileUploadList
=
Lists
.
newArrayList
();
//错误数量
List
<
AnalysisVO
>
detail
=
Lists
.
newArrayList
();
int
errorCount
=
0
;
int
totalCount
=
0
;
Map
<
String
,
String
>
groupedMap
=
Maps
.
newHashMap
();
Map
<
String
,
String
>
groupedMap
=
Maps
.
newHashMap
();
List
<
UserAccountEntity
>
userAccountList
=
Lists
.
newArrayList
();
List
<
UserAccountEntity
>
userAccountList
=
Lists
.
newArrayList
();
List
<
ExcelDataEntity
>
excelData
=
Lists
.
newArrayList
();
List
<
ExcelDataEntity
>
excelData
=
Lists
.
newArrayList
();
...
@@ -115,16 +138,7 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -115,16 +138,7 @@ public class AnalysisServiceImpl implements AnalysisService {
if
(
b
)
{
if
(
b
)
{
//文件上传
//文件上传
fileUploadList
.
add
(
fileUploadVO
);
fileUploadList
.
add
(
fileUploadVO
);
totalCount
++;
}
else
{
errorCount
++;
totalCount
++;
detail
.
add
(
AnalysisVO
.
builder
().
folderName
(
folderName
).
fileName
(
file
.
getOriginalFilename
()).
errorReason
(
"文件格式错误"
).
build
());
}
}
}
else
{
errorCount
++;
totalCount
++;
detail
.
add
(
AnalysisVO
.
builder
().
folderName
(
folderName
).
fileName
(
file
.
getOriginalFilename
()).
errorReason
(
"文件格式错误"
).
build
());
}
}
}
}
//把tableHeaderList中filter为true索引组成一个数字类型的集合
//把tableHeaderList中filter为true索引组成一个数字类型的集合
...
@@ -231,11 +245,7 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -231,11 +245,7 @@ public class AnalysisServiceImpl implements AnalysisService {
.
caseId
(
caseId
).
build
());
.
caseId
(
caseId
).
build
());
}
}
}
}
if
(
errorCount
==
0
)
{
return
Result
.
data
(
fileUploadList
);
return
Result
.
data
(
fileUploadList
);
}
else
{
return
Result
.
data
(
AnalysisVO
.
builder
().
folderCount
(
1
).
totalCount
(
totalCount
).
errorCount
(
errorCount
).
detail
(
detail
).
build
());
}
}
}
private
void
deduplicationData
(
Map
<
String
,
ExcelDataEntity
>
excelDataMap
,
List
<
ExcelDataEntity
>
excelData
,
List
<
Integer
>
filterIndex
)
{
private
void
deduplicationData
(
Map
<
String
,
ExcelDataEntity
>
excelDataMap
,
List
<
ExcelDataEntity
>
excelData
,
List
<
Integer
>
filterIndex
)
{
...
...
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