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
8335b3d1
Commit
8335b3d1
authored
Aug 03, 2025
by
wujipeng
Browse files
解析excel错误提示
parent
acc846db
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/com/platform/model/vo/AnalysisVO.java
0 → 100644
View file @
8335b3d1
package
com.platform.model.vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
* @author wujipeng
* @version 1.0
* @create 2025-08-03 9:52
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
AnalysisVO
{
@ApiModelProperty
(
"文件夹数"
)
private
Integer
folderCount
;
@ApiModelProperty
(
"总数"
)
private
Integer
totalCount
;
@ApiModelProperty
(
"错误数量"
)
private
Integer
errorCount
;
private
String
folderName
;
private
String
fileName
;
@ApiModelProperty
(
"错误原因"
)
private
String
errorReason
;
@ApiModelProperty
(
"调整方案建议"
)
private
String
adjustSuggest
;
@ApiModelProperty
(
"明细"
)
private
List
<
AnalysisVO
>
detail
;
}
src/main/java/com/platform/service/impl/AnalysisServiceImpl.java
View file @
8335b3d1
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
com.platform.model.entity.*
;
import
com.platform.model.entity.*
;
import
com.platform.model.resp.Result
;
import
com.platform.model.resp.Result
;
import
com.platform.model.vo.AnalysisVO
;
import
com.platform.model.vo.FileUploadVO
;
import
com.platform.model.vo.FileUploadVO
;
import
com.platform.model.vo.TableHeaderVO
;
import
com.platform.model.vo.TableHeaderVO
;
import
com.platform.service.*
;
import
com.platform.service.*
;
...
@@ -74,6 +75,11 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -74,6 +75,11 @@ 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
;
for
(
MultipartFile
file
:
files
)
{
for
(
MultipartFile
file
:
files
)
{
// 检查是否是Excel文件
// 检查是否是Excel文件
if
(
isExcelFile
(
file
.
getOriginalFilename
()))
{
if
(
isExcelFile
(
file
.
getOriginalFilename
()))
{
...
@@ -82,9 +88,27 @@ public class AnalysisServiceImpl implements AnalysisService {
...
@@ -82,9 +88,27 @@ public class AnalysisServiceImpl implements AnalysisService {
processSingleExcelFile
(
tempFile
,
tableHeaderList
,
folderName
,
fileUploadVO
.
getId
(),
caseId
);
processSingleExcelFile
(
tempFile
,
tableHeaderList
,
folderName
,
fileUploadVO
.
getId
(),
caseId
);
//文件上传
//文件上传
fileUploadList
.
add
(
fileUploadVO
);
fileUploadList
.
add
(
fileUploadVO
);
totalCount
++;
}
else
{
errorCount
++;
totalCount
++;
detail
.
add
(
AnalysisVO
.
builder
()
.
folderName
(
folderName
)
.
fileName
(
file
.
getOriginalFilename
())
.
errorReason
(
"文件格式错误"
)
.
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
());
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
e
.
getMessage
());
throw
new
BusinessException
(
e
.
getMessage
());
}
}
...
...
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