Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-oss
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-oss
Commits
dedc1814
Commit
dedc1814
authored
Oct 15, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置
parent
69b63b70
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
195 additions
and
17 deletions
+195
-17
yd-oss-api/src/main/java/com/yd/oss/api/service/impl/ApiExcelServiceImpl.java
+1
-0
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelCollection.java
+61
-5
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelField.java
+104
-8
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelSheet.java
+29
-4
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelParserServiceImpl.java
+0
-0
No files found.
yd-oss-api/src/main/java/com/yd/oss/api/service/impl/ApiExcelServiceImpl.java
View file @
dedc1814
...
@@ -79,6 +79,7 @@ public class ApiExcelServiceImpl implements ApiExcelService {
...
@@ -79,6 +79,7 @@ public class ApiExcelServiceImpl implements ApiExcelService {
response
.
setMap
(
result
);
response
.
setMap
(
result
);
return
Result
.
success
(
response
);
return
Result
.
success
(
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"Excel解析异常:{}"
,
e
.
getMessage
());
throw
new
BusinessException
(
"Excel解析异常!"
);
throw
new
BusinessException
(
"Excel解析异常!"
);
}
}
}
}
...
...
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelCollection.java
View file @
dedc1814
...
@@ -5,11 +5,66 @@ import java.lang.annotation.Retention;
...
@@ -5,11 +5,66 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
// Excel集合注解
/**
@Retention
(
RetentionPolicy
.
RUNTIME
)
* 增强的Excel集合注解,支持复杂数据结构
*/
@Target
(
ElementType
.
FIELD
)
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ExcelCollection
{
public
@interface
ExcelCollection
{
Class
<?>
type
();
// 集合元素类型
int
startRow
();
// 集合起始行
/**
int
endRow
()
default
-
1
;
// 集合结束行(-1表示自动检测)
* 集合元素类型
*/
Class
<?>
type
();
/**
* 起始行(0-based)
*/
int
startRow
();
/**
* 结束行(0-based,-1表示自动检测)
*/
int
endRow
()
default
-
1
;
/**
* 每个对象占用的行数(默认1行)
*/
int
rowSpan
()
default
1
;
/**
* 数据分组模式
*/
GroupMode
groupMode
()
default
GroupMode
.
SINGLE_ROW
;
/**
* 分组键字段(用于GROUP_BY_KEY模式)
*/
String
groupKey
()
default
""
;
// 在 ExcelCollection 注解中添加
String
endFlagField
()
default
""
;
// 用于判断集合结束的字段名
/**
* 下一个对象的第一个字段标题,用于判断集合结束
*/
String
nextFieldTitle
()
default
""
;
/**
* 数据分组模式枚举
*/
enum
GroupMode
{
/**
* 单行模式:每行一个对象
*/
SINGLE_ROW
,
/**
* 固定行跨度:每个对象占用固定行数
*/
FIXED_ROW_SPAN
,
/**
* 按键分组:根据指定字段的值进行分组
*/
GROUP_BY_KEY
}
}
}
\ No newline at end of file
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelField.java
View file @
dedc1814
...
@@ -5,14 +5,110 @@ import java.lang.annotation.Retention;
...
@@ -5,14 +5,110 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
// Excel字段注解
/**
@Retention
(
RetentionPolicy
.
RUNTIME
)
* 通用Excel字段注解
*/
@Target
(
ElementType
.
FIELD
)
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ExcelField
{
public
@interface
ExcelField
{
String
name
();
// 标题名称
int
titleRow
();
// 标题所在行
/**
int
titleCol
();
// 标题所在列
* 字段名称(用于日志和错误提示)
int
valueRow
()
default
-
1
;
// 值所在行(默认与标题同行)
*/
int
valueCol
()
default
-
1
;
// 值所在列(默认标题列+1)
String
name
()
default
""
;
String
dateFormat
()
default
"yyyy/MM/dd"
;
// 日期格式
/**
* 标题行(0-based)
*/
int
titleRow
()
default
-
1
;
/**
* 标题列(0-based)
*/
int
titleCol
()
default
-
1
;
/**
* 值行(0-based,-1表示使用titleRow)
*/
int
valueRow
()
default
-
1
;
/**
* 值列(0-based,-1表示使用titleCol + 1)
*/
int
valueCol
()
default
-
1
;
/**
* 日期格式
*/
String
dateFormat
()
default
"yyyy/MM/dd"
;
/**
* 是否必须
*/
boolean
required
()
default
false
;
/**
* 默认值
*/
String
defaultValue
()
default
""
;
/**
* 字段类型
*/
FieldType
fieldType
()
default
FieldType
.
SINGLE
;
/**
* 字段类型枚举
*/
enum
FieldType
{
/**
* 单值字段
*/
SINGLE
,
/**
* 列表字段(水平方向)
*/
HORIZONTAL_LIST
,
/**
* 列表字段(垂直方向)
*/
VERTICAL_LIST
}
/**
* 列表字段配置(当fieldType为LIST时使用)
*/
ListConfig
listConfig
()
default
@ListConfig
;
@interface
ListConfig
{
/**
* 起始行(0-based)
*/
int
startRow
()
default
-
1
;
/**
* 起始列(0-based)
*/
int
startCol
()
default
-
1
;
/**
* 结束行(0-based,-1表示自动检测)
*/
int
endRow
()
default
-
1
;
/**
* 结束列(0-based,-1表示自动检测)
*/
int
endCol
()
default
-
1
;
/**
* 方向:true为水平,false为垂直
*/
boolean
horizontal
()
default
true
;
/**
* 元素类型
*/
Class
<?>
elementType
()
default
String
.
class
;
}
}
}
yd-oss-feign/src/main/java/com/yd/oss/feign/annotation/ExcelSheet.java
View file @
dedc1814
...
@@ -5,10 +5,35 @@ import java.lang.annotation.Retention;
...
@@ -5,10 +5,35 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
// Excel Sheet注解
/**
@Retention
(
RetentionPolicy
.
RUNTIME
)
* 通用Excel Sheet注解
*/
@Target
(
ElementType
.
TYPE
)
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ExcelSheet
{
public
@interface
ExcelSheet
{
int
sheetIndex
()
default
0
;
// Sheet索引
String
sheetName
()
default
""
;
// Sheet名称
/**
* Sheet索引(0-based)
*/
int
sheetIndex
()
default
0
;
/**
* Sheet名称
*/
String
sheetName
()
default
""
;
/**
* 数据起始行(0-based)
*/
int
dataStartRow
()
default
0
;
/**
* 是否跳过空行
*/
boolean
skipEmptyRows
()
default
true
;
/**
* 最大行数限制
*/
int
maxRows
()
default
1000
;
}
}
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelParserServiceImpl.java
View file @
dedc1814
This diff is collapsed.
Click to expand it.
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