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
f47f50b5
Commit
f47f50b5
authored
Jun 30, 2021
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加配置数据仓库表结构功能
parent
f8e96060
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
578 additions
and
4 deletions
+578
-4
GlobalConfig.cs
Bailun.DC.Common/GlobalConfig.cs
+13
-1
relation_salesplatform_tb.cs
Bailun.DC.Models/DataWareHouse/relation_salesplatform_tb.cs
+40
-0
sys_table_info.cs
Bailun.DC.Models/DataWareHouse/sys_table_info.cs
+65
-0
Program.cs
Bailun.DC.MonthSaleProfit/Program.cs
+1
-1
Services.cs
Bailun.DC.MonthSaleProfit/Services.cs
+0
-2
TbConfigServices.cs
Bailun.DC.Services/DataWareHouse/TbConfigServices.cs
+133
-0
ConfigController.cs
...C.Web/Areas/DataWareHouse/Controllers/ConfigController.cs
+109
-0
AddTbConfig.cshtml
...C.Web/Areas/DataWareHouse/Views/Config/AddTbConfig.cshtml
+125
-0
TbConfigList.cshtml
....Web/Areas/DataWareHouse/Views/Config/TbConfigList.cshtml
+90
-0
Bailun.DC.Web.csproj
Bailun.DC.Web/Bailun.DC.Web.csproj
+2
-0
No files found.
Bailun.DC.Common/GlobalConfig.cs
View file @
f47f50b5
...
...
@@ -9,8 +9,15 @@ namespace Bailun.DC.Common
public
class
GlobalConfig
{
#if DEBUG
/// <summary>
/// 数据中心 读写库
/// </summary>
public
static
string
ConnectionString
=
"server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;SslMode=none;"
;
//public static string ConnectionString_read = "server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;";
/// <summary>
/// 数据中心 只读库
/// </summary>
public
static
string
ConnectionString_read
=
"server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;SslMode=none;"
;
/// <summary>
/// sku分类url
...
...
@@ -26,6 +33,11 @@ namespace Bailun.DC.Common
public
static
string
SkumsCategory
=
"http://10.0.6.13:8001/api/BailunCateData/GetAllCategoryList"
;
#endif
public
static
string
OAUrl
=
"http://www.bailuntec.com"
;
/// <summary>
/// 数据仓库
/// </summary>
public
static
string
ConnectionString_DW
=
"server=gz-cdb-ncg4yhjb.sql.tencentcdb.com;port=58537;database=datawarehouse;uid=root;password=#7kfnymAM$Y9-Ntf;SslMode=none;"
;
}
}
Bailun.DC.Models/DataWareHouse/relation_salesplatform_tb.cs
0 → 100644
View file @
f47f50b5
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.DC.Models.DataWareHouse
{
public
class
relation_salesplatform_tb
{
/// <summary>
///
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 平台
/// </summary>
public
string
platform
{
get
;
set
;
}
/// <summary>
/// 站点
/// </summary>
public
string
website
{
get
;
set
;
}
/// <summary>
/// 表名称
/// </summary>
public
string
tbname
{
get
;
set
;
}
public
DateTime
createtime
{
get
;
set
;
}
public
string
createusername
{
get
;
set
;
}
public
DateTime
lastupdatetime
{
get
;
set
;
}
public
string
lastupdateusername
{
get
;
set
;
}
}
}
Bailun.DC.Models/DataWareHouse/sys_table_info.cs
0 → 100644
View file @
f47f50b5
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.DC.Models.DataWareHouse
{
public
class
sys_table_info
{
/// <summary>
///
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 编码(唯一)
/// </summary>
public
string
code
{
get
;
set
;
}
/// <summary>
/// 中文名称
/// </summary>
public
string
name
{
get
;
set
;
}
/// <summary>
/// 字段类型
/// </summary>
public
string
fieldtype
{
get
;
set
;
}
/// <summary>
/// 长度
/// </summary>
public
int
length
{
get
;
set
;
}
/// <summary>
/// 小数位
/// </summary>
public
int
decimals
{
get
;
set
;
}
/// <summary>
/// 1:表格名称,2:字段名称
/// </summary>
public
int
type
{
get
;
set
;
}
/// <summary>
/// 说明
/// </summary>
public
string
note
{
get
;
set
;
}
public
DateTime
createtime
{
get
;
set
;
}
public
string
createusername
{
get
;
set
;
}
public
DateTime
lastupdatetime
{
get
;
set
;
}
public
string
lastupdateusername
{
get
;
set
;
}
}
}
Bailun.DC.MonthSaleProfit/Program.cs
View file @
f47f50b5
...
...
@@ -22,7 +22,7 @@ namespace Bailun.DC.MonthSaleProfit
{
var
_services
=
new
Services
();
var
start
=
DateTime
.
Parse
(
"2021-
3
-01"
);
var
start
=
DateTime
.
Parse
(
"2021-
5
-01"
);
//_services.Init(start);
_services
.
InitNew
(
start
);
//_services.InitNew4K(start);
...
...
Bailun.DC.MonthSaleProfit/Services.cs
View file @
f47f50b5
...
...
@@ -693,8 +693,6 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
m
.
rate_profit_actual
=
m
.
amount_sales
>
0
?
m
.
profit_balance
/
m
.
amount_sales
:
0
;
}
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
...
...
Bailun.DC.Services/DataWareHouse/TbConfigServices.cs
0 → 100644
View file @
f47f50b5
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
MySql.Data.MySqlClient
;
using
Dapper
;
using
Bailun.DC.Models.DataWareHouse
;
using
Bailun.DC.Models
;
using
Bailun.DC.Common
;
namespace
Bailun.DC.Services.DataWareHouse
{
public
class
TbConfigServices
{
#
region
数据仓库
-
表结构配置
/// <summary>
/// 获取表配置列表
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="code">code关键字</param>
/// <param name="total">符合条件的记录数</param>
/// <returns></returns>
public
List
<
sys_table_info
>
ListTbConfig
(
BtTableParameter
parameter
,
string
code
,
ref
int
total
)
{
var
sql
=
"select * from sys_table_info where 1=1 "
;
var
sqlparam
=
new
DynamicParameters
();
if
(!
string
.
IsNullOrEmpty
(
code
))
{
sql
+=
" and code like @code "
;
sqlparam
.
Add
(
"code"
,
"%"
+
code
+
"%"
);
}
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_DW
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
var
obj
=
cn
.
Page
<
sys_table_info
>(
parameter
.
pageIndex
,
parameter
.
limit
,
sql
,
ref
total
).
AsList
();
return
obj
;
}
}
/// <summary>
/// 获取库存结构详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
sys_table_info
GetTbConfig
(
int
id
)
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_DW
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
var
obj
=
cn
.
QueryFirstOrDefault
<
sys_table_info
>(
"select * from sys_table_info where id="
+
id
);
return
obj
;
}
}
/// <summary>
/// 保存库存配置信息
/// </summary>
/// <param name="m"></param>
/// <param name="username"></param>
/// <returns></returns>
public
string
SaveTbConfig
(
sys_table_info
m
,
string
username
)
{
try
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_DW
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
var
obj
=
cn
.
QueryFirstOrDefault
<
sys_table_info
>(
"select * from sys_table_info where id="
+
m
.
id
);
if
(
obj
==
null
)
{
obj
=
new
sys_table_info
{
createtime
=
DateTime
.
Now
,
createusername
=
username
,
code
=
m
.
code
,
};
}
obj
.
name
=
m
.
name
??
""
;
obj
.
decimals
=
m
.
decimals
;
obj
.
fieldtype
=
m
.
fieldtype
??
""
;
obj
.
lastupdatetime
=
DateTime
.
Now
;
obj
.
lastupdateusername
=
username
;
obj
.
length
=
m
.
length
;
obj
.
note
=
m
.
note
??
""
;
obj
.
type
=
m
.
type
;
if
(
obj
.
id
>
0
)
{
cn
.
Update
(
obj
);
}
else
{
cn
.
Insert
(
obj
);
}
}
return
""
;
}
catch
(
Exception
ex
)
{
return
ex
.
Message
;
}
}
#
endregion
}
}
Bailun.DC.Web/Areas/DataWareHouse/Controllers/ConfigController.cs
0 → 100644
View file @
f47f50b5
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Bailun.DC.Models
;
using
Newtonsoft.Json
;
using
Bailun.DC.Models.DataWareHouse
;
using
Bailun.ServiceFabric.Authorize
;
using
Bailun.ServiceFabric.Core.Extension.HttpContext
;
using
Bailun.ServiceFabric.Core.Extension
;
namespace
Bailun.DC.Web.Areas.DataWareHouse.Controllers
{
[
Area
(
"DataWareHouse"
)]
public
class
ConfigController
:
Controller
{
public
IActionResult
TbConfigList
()
{
return
View
();
}
/// <summary>
/// 库表结构的分页信息
/// </summary>
/// <param name="parameter"></param>
/// <param name="code"></param>
/// <returns></returns>
public
string
TbConfigListJson
(
BtTableParameter
parameter
,
string
code
)
{
var
total
=
0
;
var
obj
=
new
Services
.
DataWareHouse
.
TbConfigServices
().
ListTbConfig
(
parameter
,
code
,
ref
total
);
var
list
=
obj
.
Select
(
a
=>
new
{
a
.
code
,
a
.
name
,
a
.
fieldtype
,
a
.
length
,
a
.
decimals
,
a
.
note
,
type
=
a
.
type
==
1
?
"表"
:
"字段"
});
return
JsonConvert
.
SerializeObject
(
new
{
rows
=
list
,
total
=
total
});
}
public
IActionResult
AddTbConfig
(
int
?
id
)
{
var
m
=
new
sys_table_info
();
if
(
id
.
HasValue
&&
id
.
Value
>
0
)
{
m
=
new
Services
.
DataWareHouse
.
TbConfigServices
().
GetTbConfig
(
id
.
Value
);
if
(
m
==
null
)
{
m
=
new
sys_table_info
();
}
}
ViewBag
.
m
=
m
;
return
View
();
}
/// <summary>
/// 保存表结构配置信息
/// </summary>
/// <param name="id">id</param>
/// <param name="code">编码</param>
/// <param name="name">中文名称</param>
/// <param name="fieldtype">字段类型</param>
/// <param name="length">长度</param>
/// <param name="decimals">小数位</param>
/// <param name="note">备注说明</param>
/// <param name="type">1:表格名称,2:字段名称</param>
/// <returns></returns>
[
BailunAuthentication
(
LoginMode
.
Enforce
)]
[
HttpPost
]
public
JsonResult
SaveTbConfig
(
int
id
,
string
code
,
string
name
,
string
fieldtype
,
int
length
,
int
decimals
,
string
note
,
int
type
)
{
var
user
=
HttpContextHelper
.
Current
?.
User
;
var
result
=
new
Services
.
DataWareHouse
.
TbConfigServices
().
SaveTbConfig
(
new
sys_table_info
{
id
=
id
,
code
=
code
,
name
=
name
,
decimals
=
decimals
,
length
=
length
,
fieldtype
=
fieldtype
,
note
=
note
,
type
=
type
,
},
(
user
!=
null
?
user
.
GetUserName
()
:
""
));
return
Json
(
new
{
success
=
string
.
IsNullOrEmpty
(
result
),
msg
=
result
});
}
}
}
Bailun.DC.Web/Areas/DataWareHouse/Views/Config/AddTbConfig.cshtml
0 → 100644
View file @
f47f50b5
@{
ViewData["Title"] = "数据仓库-库表结构配置";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "数据仓库", "库表结构配置列表", "库表结构配置详情" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div style="line-height:40px;">
<input id="id" name="id" type="hidden" value="@ViewBag.m.id" />
<div class="row">
<div class="col-sm-12">
<label style="width:110px">结构配置类型:</label>
<select id="type" name="type" class="form-control" style="width:110px;display:inline">
<option value="1">表</option>
<option value="2">字段</option>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">编码(唯一):</label>
<input id="code" name="code" class="form-control" placeholder="请输入表或字段编码" value="@ViewBag.m.code" style="width:160px;display:inline" />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">中文名称:</label>
<input id="name" name="name" class="form-control" placeholder="请输入表或字段的中文名称" value="@ViewBag.m.name" style="width:160px;display:inline" />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">字段类型:</label>
<select id="fieldtype" name="fieldtype" class="form-control" style="width:160px;display:inline">
<option value="">无</option>
<option value="VARCHAR">字符串</option>
<option value="decimal">数值</option>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">字段长度:</label>
<input id="length" name="length" class="form-control" placeholder="请输入字段值的长度" value="@ViewBag.m.length" style="width:160px;display: inline" />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">小数位:</label>
<input id="decimals" name="decimals" class="form-control" placeholder="请输入字段有几位小数" value="@ViewBag.m.decimals" style="width:160px;display:inline" />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label style="width:110px">备注说明:</label>
<input id="note" name="note" class="form-control" placeholder="请输入备注说明" value="@ViewBag.m.note" />
</div>
</div>
</div>
</form>
<div style="margin-top:10px;text-align:center;">
<button class="btn btn-primary" onclick="Save();">保存</button>
</div>
</div>
</div>
</div>
@section scripts{
<script>
$(document).ready(function () {
if ('@ViewBag.m.id' > 0) {
$('#type').val('@ViewBag.m.type');
$('#fieldtype').val('@ViewBag.m.fieldtype');
}
})
function Save() {
var type = $('#type').val();
var code = $('#code').val();
var name = $('#name').val();
var fieldtype = $('#fieldtype').val();
var length = $('#length').val();
var decimals = $('#decimals').val();
var note = $('#note').val();
if (code == '') {
alert('请输入编码');
return false;
}
if (type == 2) {
if (fieldtype == '' || length == '' || decimals == '') {
alert('字段类型、字段长度、字段小数位都不能为空');
return false;
}
}
$.submit({
url: '@Url.Content("~/DataWareHouse/Config/SaveTbConfig")',
paramData: $('#toolbar').serialize(),
type:'Post',
func: function (result) {
if (result.success) {
alert('提交成功!');
window.location = window.location;
}
else {
alert(result.msg);
}
}
})
}
</script>
}
\ No newline at end of file
Bailun.DC.Web/Areas/DataWareHouse/Views/Config/TbConfigList.cshtml
0 → 100644
View file @
f47f50b5
@{
ViewData["Title"] = "数据仓库-库表结构配置";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "数据仓库", "库表结构配置列表" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<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)
{
<option value="@(item.data_type)">@(item.data_type_name)</option>
}
}
</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>*@
</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>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section scripts{
<script>
var tb;
$(document).ready(function () {
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170));
list();
})
function list() {
var columns = [
{ field: 'code', title: '编码', width: '130'},
{ field: 'name', title: '中文名称', width: '130' },
{ field: 'fieldtype', title: '字段类型', width: '130'},
{ field: 'length', title: '长度', width: '130' },
{ field: 'decimals', title: '小数位', width: '80' },
{ field: 'type', title: '类型', width: '130' },
{ field: 'note', title: '备注说明', width: '130' }
];
var url = '@Url.Content("~/DataWareHouse/Config/TbConfigListJson")' + '?' + $('#toolbar').serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "");
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
function Add() {
layer_show('新增库表结构配置', '@Url.Content("~/DataWareHouse/Config/AddTbConfig?id=0")', '90%', '90%');
}
</script>
}
Bailun.DC.Web/Bailun.DC.Web.csproj
View file @
f47f50b5
...
...
@@ -38,6 +38,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\DataWareHouse\Data\" />
<Folder Include="Areas\DataWareHouse\Models\" />
<Folder Include="Areas\ExportFile\Data\" />
<Folder Include="Areas\ExportFile\Models\" />
<Folder Include="Areas\ExportFile\Views\" />
...
...
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