Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
48ed6218
提交
48ed6218
authored
7月 12, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 追加/更新 excel 数据集时,列名与原数据集保持一致
上级
fb186e9c
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
43 行增加
和
7 行删除
+43
-7
DataSetTableController.java
...o/dataease/controller/dataset/DataSetTableController.java
+2
-2
DataSetTableService.java
...java/io/dataease/service/dataset/DataSetTableService.java
+19
-1
messages_en_US.properties
backend/src/main/resources/i18n/messages_en_US.properties
+2
-0
messages_zh_CN.properties
backend/src/main/resources/i18n/messages_zh_CN.properties
+1
-0
messages_zh_TW.properties
backend/src/main/resources/i18n/messages_zh_TW.properties
+2
-0
AddExcel.vue
frontend/src/views/dataset/add/AddExcel.vue
+17
-4
没有找到文件。
backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java
浏览文件 @
48ed6218
...
...
@@ -100,8 +100,8 @@ public class DataSetTableController {
}
@PostMapping
(
"excel/upload"
)
public
Map
<
String
,
Object
>
excelUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
return
dataSetTableService
.
excelSaveAndParse
(
file
);
public
Map
<
String
,
Object
>
excelUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"tableId"
)
String
tableId
)
throws
Exception
{
return
dataSetTableService
.
excelSaveAndParse
(
file
,
tableId
);
}
@PostMapping
(
"checkDorisTableIsExists/{id}"
)
...
...
backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java
浏览文件 @
48ed6218
...
...
@@ -878,10 +878,28 @@ public class DataSetTableService {
return
map
;
}
public
Map
<
String
,
Object
>
excelSaveAndParse
(
MultipartFile
file
)
throws
Exception
{
public
Map
<
String
,
Object
>
excelSaveAndParse
(
MultipartFile
file
,
String
tableId
)
throws
Exception
{
String
filename
=
file
.
getOriginalFilename
();
// parse file
Map
<
String
,
Object
>
fileMap
=
parseExcel
(
filename
,
file
.
getInputStream
(),
true
);
if
(
StringUtils
.
isNotEmpty
(
tableId
)){
List
<
DatasetTableField
>
datasetTableFields
=
dataSetTableFieldsService
.
getFieldsByTableId
(
tableId
);
datasetTableFields
.
sort
((
o1
,
o2
)
->
{
if
(
o1
.
getColumnIndex
()
==
null
)
{
return
-
1
;
}
if
(
o2
.
getColumnIndex
()
==
null
)
{
return
1
;
}
return
o1
.
getColumnIndex
().
compareTo
(
o2
.
getColumnIndex
());
});
List
<
TableFiled
>
fields
=
(
List
<
TableFiled
>)
fileMap
.
get
(
"fields"
);
List
<
String
>
newFields
=
fields
.
stream
().
map
(
TableFiled:
:
getRemarks
).
collect
(
Collectors
.
toList
());
List
<
String
>
oldFields
=
datasetTableFields
.
stream
().
map
(
DatasetTableField:
:
getOriginName
).
collect
(
Collectors
.
toList
());
if
(!
oldFields
.
equals
(
newFields
))
{
DataEaseException
.
throwException
(
Translator
.
get
(
"i18n_excel_colume_change"
));
}
}
// save file
String
filePath
=
saveFile
(
file
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
fileMap
);
...
...
backend/src/main/resources/i18n/messages_en_US.properties
浏览文件 @
48ed6218
...
...
@@ -273,3 +273,4 @@ i18n_msg_type_dataset_sync=Data set synchronization
i18n_msg_type_dataset_sync_success
=
Dataset synchronization successful
i18n_msg_type_dataset_sync_faild
=
Dataset synchronization failed
i18n_data_not_sync
=
Please sync data first
i18n_excel_colume_change
=
The column name of Excel is inconsistent with the original data set
\ No newline at end of file
backend/src/main/resources/i18n/messages_zh_CN.properties
浏览文件 @
48ed6218
...
...
@@ -272,3 +272,4 @@ i18n_msg_type_dataset_sync=数据集同步
i18n_msg_type_dataset_sync_success
=
数据集同步成功
i18n_msg_type_dataset_sync_faild
=
数据集同步失败
i18n_data_not_sync
=
请先完成数据同步
i18n_excel_colume_change
=
Excel的列名与原数据集不一致
backend/src/main/resources/i18n/messages_zh_TW.properties
浏览文件 @
48ed6218
...
...
@@ -275,3 +275,4 @@ i18n_msg_type_dataset_sync=數據集同步
i18n_msg_type_dataset_sync_success
=
數據集同步成功
i18n_msg_type_dataset_sync_faild
=
數據集同步失敗
i18n_data_not_sync
=
請先完成數據同步
i18n_excel_colume_change
=
Excel的列名與原數據集不一致
\ No newline at end of file
frontend/src/views/dataset/add/AddExcel.vue
浏览文件 @
48ed6218
...
...
@@ -28,6 +28,7 @@
:multiple=
"false"
:show-file-list=
"false"
:file-list=
"fileList"
:data=
"param"
accept=
".xls,.xlsx,"
:before-upload=
"beforeUpload"
:on-success=
"uploadSuccess"
...
...
@@ -80,6 +81,7 @@
<
script
>
import
{
post
}
from
'@/api/dataset/dataset'
import
{
getToken
}
from
'@/utils/auth'
import
i18n
from
"@/lang"
;
const
token
=
getToken
()
...
...
@@ -89,6 +91,10 @@ export default {
param
:
{
type
:
Object
,
default
:
null
},
tableId
:
{
type
:
String
,
default
:
null
}
},
data
()
{
...
...
@@ -100,7 +106,7 @@ export default {
mode
:
'1'
,
height
:
600
,
fileList
:
[],
headers
:
{
Authorization
:
token
},
headers
:
{
Authorization
:
token
,
'Accept-Language'
:
i18n
.
locale
.
replace
(
'_'
,
'-'
)
},
baseUrl
:
process
.
env
.
VUE_APP_BASE_API
,
path
:
''
,
uploading
:
false
...
...
@@ -115,6 +121,11 @@ export default {
}
this
.
calHeight
()
},
created
()
{
if
(
!
this
.
param
.
tableId
)
{
this
.
param
.
tableId
=
""
}
},
methods
:
{
// initDataSource() {
// listDatasource().then(response => {
...
...
@@ -132,6 +143,10 @@ export default {
this
.
uploading
=
true
},
uploadFail
(
response
,
file
,
fileList
)
{
let
myError
=
response
.
toString
();
myError
=
myError
.
replace
(
"Error: "
,
""
)
const
errorMessage
=
JSON
.
parse
(
myError
).
message
+
", "
+
this
.
$t
(
'dataset.parse_error'
);
this
.
path
=
''
this
.
fields
=
[]
this
.
sheets
=
[]
...
...
@@ -143,7 +158,7 @@ export default {
this
.
uploading
=
false
this
.
$message
({
type
:
'error'
,
message
:
this
.
$t
(
'dataset.parse_error'
)
,
message
:
errorMessage
,
showClose
:
true
})
},
...
...
@@ -166,8 +181,6 @@ export default {
},
save
()
{
// console.log(this.checkTableList);
// console.log(this.scene);
if
(
!
this
.
name
||
this
.
name
===
''
)
{
this
.
$message
({
showClose
:
true
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论