Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
DataCenter_Core2.1_20190520
Commits
afc5a103
Commit
afc5a103
authored
Jun 30, 2021
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加导入数据结构模版功能
parent
f47f50b5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
18 deletions
+195
-18
TbConfigServices.cs
Bailun.DC.Services/DataWareHouse/TbConfigServices.cs
+1
-1
ConfigController.cs
...C.Web/Areas/DataWareHouse/Controllers/ConfigController.cs
+112
-0
TbConfigList.cshtml
....Web/Areas/DataWareHouse/Views/Config/TbConfigList.cshtml
+82
-17
数据仓库字段配置模版.xlsx
Bailun.DC.Web/wwwroot/templatefile/数据仓库字段配置模版.xlsx
+0
-0
No files found.
Bailun.DC.Services/DataWareHouse/TbConfigServices.cs
View file @
afc5a103
...
...
@@ -82,7 +82,7 @@ namespace Bailun.DC.Services.DataWareHouse
cn
.
Open
();
}
var
obj
=
cn
.
QueryFirstOrDefault
<
sys_table_info
>(
"select * from sys_table_info where
id="
+
m
.
id
);
var
obj
=
cn
.
QueryFirstOrDefault
<
sys_table_info
>(
"select * from sys_table_info where
code='"
+
m
.
code
+
"'"
);
if
(
obj
==
null
)
...
...
Bailun.DC.Web/Areas/DataWareHouse/Controllers/ConfigController.cs
View file @
afc5a103
...
...
@@ -9,6 +9,7 @@ using Bailun.DC.Models.DataWareHouse;
using
Bailun.ServiceFabric.Authorize
;
using
Bailun.ServiceFabric.Core.Extension.HttpContext
;
using
Bailun.ServiceFabric.Core.Extension
;
using
System.Data
;
namespace
Bailun.DC.Web.Areas.DataWareHouse.Controllers
{
...
...
@@ -102,8 +103,119 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
});
}
/// <summary>
/// 批量导入表结构配置数据
/// </summary>
/// <returns></returns>
public
JsonResult
UploadTbConfig
()
{
if
(
Request
.
Form
.
Files
.
Count
==
0
)
{
return
Json
(
new
{
success
=
false
,
msg
=
"请上传文件!"
});
}
var
user
=
HttpContextHelper
.
Current
?.
User
;
var
file
=
Request
.
Form
.
Files
[
0
];
Dictionary
<
string
,
DataTable
>
dic
=
Base
.
NpolHelper
.
ExcelToDataTable
(
file
.
OpenReadStream
(),
file
.
FileName
,
true
);
if
(
dic
.
Count
>
0
)
{
var
tb
=
dic
.
FirstOrDefault
();
var
list
=
new
List
<
sys_table_info
>();
var
_service
=
new
Services
.
DataWareHouse
.
TbConfigServices
();
for
(
var
i
=
0
;
i
<
tb
.
Value
.
Rows
.
Count
;
i
++)
{
var
row
=
tb
.
Value
.
Rows
[
i
];
var
code
=
row
[
"编码"
].
ToString
();
var
name
=
row
[
"中文名称"
].
ToString
();
var
fieldtype
=
row
[
"字段类型"
].
ToString
();
var
length
=
row
[
"字段长度"
].
ToString
();
var
decimals
=
row
[
"小数位"
].
ToString
();
var
note
=
row
[
"备注"
].
ToString
();
var
type
=
row
[
"编码类型"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
code
))
{
continue
;
}
if
(
string
.
IsNullOrEmpty
(
type
))
{
return
Json
(
new
{
success
=
false
,
msg
=
$"第
{(
i
+
1
)}
行的编码类型为空,请填写表或者字段"
});
}
if
(
type
.
Trim
()
==
"字段"
&&
(
fieldtype
.
Trim
()
==
""
||
length
.
Trim
()
==
""
))
{
return
Json
(
new
{
success
=
false
,
msg
=
$"第
{(
i
+
1
)}
行的字段类型或长度为空,请填写。"
});
}
var
n_length
=
0
;
var
n_decimal
=
0
;
int
.
TryParse
(
length
,
out
n_length
);
int
.
TryParse
(
decimals
,
out
n_decimal
);
if
(
type
.
Trim
()
==
"字段"
&&
n_length
==
0
)
{
return
Json
(
new
{
success
=
false
,
msg
=
$"第
{(
i
+
1
)}
行的字段长度不能为0。"
});
}
var
m
=
new
sys_table_info
{
code
=
code
.
Trim
(),
name
=
name
.
Trim
(),
fieldtype
=
fieldtype
.
Trim
(),
length
=
n_length
,
decimals
=
n_decimal
,
note
=
note
.
Trim
(),
type
=
type
.
Trim
()==
"表"
?
1
:
2
,
id
=
0
,
};
list
.
Add
(
m
);
}
//保存数据
foreach
(
var
item
in
list
)
{
var
result
=
_service
.
SaveTbConfig
(
item
,
(
user
!=
null
?
user
.
GetUserName
()
:
""
));
if
(!
string
.
IsNullOrEmpty
(
result
))
{
return
Json
(
new
{
success
=
false
,
msg
=
"上传失败,请重试!失败原因:"
+
result
,
});
}
}
return
Json
(
new
{
success
=
true
,
msg
=
""
,
});
}
return
Json
(
new
{
success
=
false
,
msg
=
"没有找到表格的内容数据"
,
});
}
}
}
Bailun.DC.Web/Areas/DataWareHouse/Views/Config/TbConfigList.cshtml
View file @
afc5a103
...
...
@@ -11,32 +11,32 @@
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
@*<label>下载类型</label>
<select id="datatype" name="datatype" class="form-control" style="width:150px">
<option value="">请选择下载类型</option>
@if (ViewBag.datatypes.Count > 0)
{
foreach (var item in ViewBag.datatypes)
<select id="datatype" name="datatype" class="form-control" style="width:150px">
<option value="">请选择下载类型</option>
@if (ViewBag.datatypes.Count > 0)
{
<option value="@(item.data_type)">@(item.data_type_name)</option>
foreach (var item in ViewBag.datatypes)
{
<option value="@(item.data_type)">@(item.data_type_name)</option>
}
}
}
</select>*@
</select>*@
</div>
<div class="form-group">
@*<label></label>
<select id="status" name="status" class="form-control" style="width:150px">
<option value="">请选择任务状态</option>
<option value="0">未认领</option>
<option value="1">任务执行失败</option>
<option value="2">已认领</option>
<option value="3">执行成功</option>
</select>*@
<select id="status" name="status" class="form-control" style="width:150px">
<option value="">请选择任务状态</option>
<option value="0">未认领</option>
<option value="1">任务执行失败</option>
<option value="2">已认领</option>
<option value="3">执行成功</option>
</select>*@
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="list();">查询</button>
<button type="button" class="btn btn-success" onclick="Add();">新增</button>
<button
type="button" class="btn btn-success" onclick="importxls();
">导入</button>
<
button type="button" class="btn btn-warning" onclick="downloadxls();">模版下载</button
>
<button
id="btn_Upload" class="btn btn-warning
">导入</button>
<
a id="btn_UpdateTemplate" class="btn btn-default" href="@Url.Content("~/templatefile/数据仓库字段配置模版.xlsx")" target="_blank">下载导入模版</a
>
</div>
</div>
</form>
...
...
@@ -47,14 +47,52 @@
</div>
</div>
@section css{
<link href="~/js/webuploader-0.1.5/webuploader.css" rel="stylesheet" />
<style>
.webuploader-pick {
position: relative;
display: block;
cursor: pointer;
background: none;
padding: 0px;
color: #fff;
text-align: center;
border-radius: 3px;
overflow: hidden;
}
.webuploader-container {
background-color: cornflowerblue !important;
}
</style>
}
@section scripts{
<script src="~/js/webuploader-0.1.5/webuploader.min.js"></script>
<script>
var BASE_URL = '@(Url.Content("~/js/webuploader-0.1.5/"))';
var tb;
$(document).ready(function () {
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170));
list();
uploadfile('btn_Upload',
'@Url.Content("~/DataWareHouse/Config/UploadTbConfig")',
function(result){
if(result.success)
{
alert('上传成功!');
list();
}
else
{
alert(result.msg);
}
});
})
function list() {
...
...
@@ -83,6 +121,33 @@
layer_show('新增库表结构配置', '@Url.Content("~/DataWareHouse/Config/AddTbConfig?id=0")', '90%', '90%');
}
function uploadfile(id,url,callback)
{
var uploader = new WebUploader.Uploader({
// swf文件路径
swf: BASE_URL + 'Uploader.swf',
// 文件接收服务端。
server: url!=undefined?url:'@Url.Content("~/File/UploadFile")',
// 选择文件的按钮。可选。
// 内部根据当前运行是创建,可能是input元素,也可能是flash.
pick: '#'+id,
// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize: false,
auto:true
});
uploader.on('uploadSuccess', function (file, response) {
if(callback!=undefined)
{
callback(response);
}
});
uploader.on('uploadError', function (file) {
layer.msg("上传出错");
});
}
</script>
}
...
...
Bailun.DC.Web/wwwroot/templatefile/数据仓库字段配置模版.xlsx
0 → 100644
View file @
afc5a103
File added
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