Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
bc7a6070
提交
bc7a6070
authored
6月 02, 2024
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Excel注解新增属性comboReadDict
上级
161cd2b1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
83 行增加
和
22 行删除
+83
-22
Excel.java
...mmon/src/main/java/com/ruoyi/common/annotation/Excel.java
+5
-0
DictUtils.java
...ommon/src/main/java/com/ruoyi/common/utils/DictUtils.java
+63
-18
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+15
-4
没有找到文件。
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
浏览文件 @
bc7a6070
...
...
@@ -88,6 +88,11 @@ public @interface Excel
*/
public
String
[]
combo
()
default
{};
/**
* 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
*/
public
boolean
comboReadDict
()
default
false
;
/**
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
*/
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
浏览文件 @
bc7a6070
...
...
@@ -91,31 +91,31 @@ public class DictUtils
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
SysDictData
>
datas
=
getDictCache
(
dictType
);
if
(
StringUtils
.
isNotNull
(
datas
))
if
(
StringUtils
.
isNull
(
datas
))
{
return
StringUtils
.
EMPTY
;
}
if
(
StringUtils
.
containsAny
(
separator
,
dictValue
))
{
if
(
StringUtils
.
containsAny
(
separator
,
dictValue
)
)
for
(
SysDictData
dict
:
datas
)
{
for
(
S
ysDictData
dict
:
datas
)
for
(
S
tring
value
:
dictValue
.
split
(
separator
)
)
{
for
(
String
value
:
dictValue
.
split
(
separator
))
if
(
value
.
equals
(
dict
.
getDictValue
()
))
{
if
(
value
.
equals
(
dict
.
getDictValue
()))
{
propertyString
.
append
(
dict
.
getDictLabel
()).
append
(
separator
);
break
;
}
propertyString
.
append
(
dict
.
getDictLabel
()).
append
(
separator
);
break
;
}
}
}
else
}
else
{
for
(
SysDictData
dict
:
datas
)
{
for
(
SysDictData
dict
:
datas
)
if
(
dictValue
.
equals
(
dict
.
getDictValue
())
)
{
if
(
dictValue
.
equals
(
dict
.
getDictValue
()))
{
return
dict
.
getDictLabel
();
}
return
dict
.
getDictLabel
();
}
}
}
...
...
@@ -134,8 +134,11 @@ public class DictUtils
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
SysDictData
>
datas
=
getDictCache
(
dictType
);
if
(
StringUtils
.
containsAny
(
separator
,
dictLabel
)
&&
StringUtils
.
isNotEmpty
(
datas
))
if
(
StringUtils
.
isNull
(
datas
))
{
return
StringUtils
.
EMPTY
;
}
if
(
StringUtils
.
containsAny
(
separator
,
dictLabel
))
{
for
(
SysDictData
dict
:
datas
)
{
...
...
@@ -162,6 +165,48 @@ public class DictUtils
return
StringUtils
.
stripEnd
(
propertyString
.
toString
(),
separator
);
}
/**
* 根据字典类型获取字典所有值
*
* @param dictType 字典类型
* @return 字典值
*/
public
static
String
getDictValues
(
String
dictType
)
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
SysDictData
>
datas
=
getDictCache
(
dictType
);
if
(
StringUtils
.
isNull
(
datas
))
{
return
StringUtils
.
EMPTY
;
}
for
(
SysDictData
dict
:
datas
)
{
propertyString
.
append
(
dict
.
getDictValue
()).
append
(
SEPARATOR
);
}
return
StringUtils
.
stripEnd
(
propertyString
.
toString
(),
SEPARATOR
);
}
/**
* 根据字典类型获取字典所有标签
*
* @param dictType 字典类型
* @return 字典值
*/
public
static
String
getDictLabels
(
String
dictType
)
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
SysDictData
>
datas
=
getDictCache
(
dictType
);
if
(
StringUtils
.
isNull
(
datas
))
{
return
StringUtils
.
EMPTY
;
}
for
(
SysDictData
dict
:
datas
)
{
propertyString
.
append
(
dict
.
getDictLabel
()).
append
(
SEPARATOR
);
}
return
StringUtils
.
stripEnd
(
propertyString
.
toString
(),
SEPARATOR
);
}
/**
* 删除指定字典缓存
*
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
浏览文件 @
bc7a6070
...
...
@@ -1042,17 +1042,28 @@ public class ExcelUtil<T>
// 设置列宽
sheet
.
setColumnWidth
(
column
,
(
int
)
((
attr
.
width
()
+
0.72
)
*
256
));
}
if
(
StringUtils
.
isNotEmpty
(
attr
.
prompt
())
||
attr
.
combo
().
length
>
0
)
if
(
StringUtils
.
isNotEmpty
(
attr
.
prompt
())
||
attr
.
combo
().
length
>
0
||
attr
.
comboReadDict
()
)
{
if
(
attr
.
combo
().
length
>
15
||
StringUtils
.
join
(
attr
.
combo
()).
length
()
>
255
)
String
[]
comboArray
=
attr
.
combo
();
if
(
attr
.
comboReadDict
())
{
if
(!
sysDictMap
.
containsKey
(
"combo_"
+
attr
.
dictType
()))
{
String
labels
=
DictUtils
.
getDictLabels
(
attr
.
dictType
());
sysDictMap
.
put
(
"combo_"
+
attr
.
dictType
(),
labels
);
}
String
val
=
sysDictMap
.
get
(
"combo_"
+
attr
.
dictType
());
comboArray
=
StringUtils
.
split
(
val
,
DictUtils
.
SEPARATOR
);
}
if
(
comboArray
.
length
>
15
||
StringUtils
.
join
(
comboArray
).
length
()
>
255
)
{
// 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到
setXSSFValidationWithHidden
(
sheet
,
attr
.
combo
()
,
attr
.
prompt
(),
1
,
100
,
column
,
column
);
setXSSFValidationWithHidden
(
sheet
,
comboArray
,
attr
.
prompt
(),
1
,
100
,
column
,
column
);
}
else
{
// 提示信息或只能选择不能输入的列内容.
setPromptOrValidation
(
sheet
,
attr
.
combo
()
,
attr
.
prompt
(),
1
,
100
,
column
,
column
);
setPromptOrValidation
(
sheet
,
comboArray
,
attr
.
prompt
(),
1
,
100
,
column
,
column
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论