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
20ab0b02
Commit
20ab0b02
authored
Aug 13, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://code.bailuntec.com/bltdc/DataCenter_Core2.1_20190520
parents
7dd56f9d
25cc6b3f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
379 additions
and
10 deletions
+379
-10
.gitignore
.gitignore
+1
-0
Services.cs
Bailun.DC.DailyLogisticSupplierTransaction/Services.cs
+2
-0
uploadfiles.cs
Bailun.DC.Models/DataWareHouse/uploadfiles.cs
+83
-0
PlatformOrderServices.cs
Bailun.DC.Services/DataWareHouse/PlatformOrderServices.cs
+58
-0
PlatformOrderController.cs
...reas/DataWareHouse/Controllers/PlatformOrderController.cs
+3
-1
OrderBillings.cshtml
...as/DataWareHouse/Views/PlatformOrder/OrderBillings.cshtml
+32
-7
Bailun.DC.Web.csproj
Bailun.DC.Web/Bailun.DC.Web.csproj
+1
-0
BaseController.cs
Bailun.DC.Web/Base/BaseController.cs
+104
-0
QiNiuCloudHelper.cs
Bailun.DC.Web/Base/QiNiuCloudHelper.cs
+89
-0
Startup.cs
Bailun.DC.Web/Startup.cs
+1
-2
appsettings.json
Bailun.DC.Web/appsettings.json
+5
-0
No files found.
.gitignore
View file @
20ab0b02
...
...
@@ -330,6 +330,7 @@ ASALocalRun/
.mfractor/
UploadFile/
tempUploadFile/
.svn/
Files/
...
...
Bailun.DC.DailyLogisticSupplierTransaction/Services.cs
View file @
20ab0b02
...
...
@@ -48,6 +48,8 @@ namespace Bailun.DC.DailyLogisticSupplierTransaction
Console
.
WriteLine
(
"重跑 "
+
day
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
+
" 完成"
);
day
=
day
.
AddDays
(
1
);
}
}
}
...
...
Bailun.DC.Models/DataWareHouse/uploadfiles.cs
0 → 100644
View file @
20ab0b02
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.DC.Models.DataWareHouse
{
public
class
uploadfiles
{
/// <summary>
///
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 数据类型,1:销售平台的,2:物流费用
/// </summary>
public
int
datatype
{
get
;
set
;
}
/// <summary>
/// 文件名称
/// </summary>
public
string
filename
{
get
;
set
;
}
/// <summary>
/// 文件类型
/// </summary>
public
string
filetype
{
get
;
set
;
}
/// <summary>
/// 文件长度
/// </summary>
public
double
filelen
{
get
;
set
;
}
/// <summary>
/// 分片唯一文件码
/// </summary>
public
string
guidcode
{
get
;
set
;
}
/// <summary>
/// 文件上传时带的参数
/// </summary>
public
string
paramdata
{
get
;
set
;
}
/// <summary>
/// 文件状态:0:待解析,1:解析成功
/// </summary>
public
int
status
{
get
;
set
;
}
/// <summary>
/// 月份
/// </summary>
public
string
month
{
get
;
set
;
}
/// <summary>
/// 销售平台类型
/// </summary>
public
string
platform
{
get
;
set
;
}
/// <summary>
/// 销售平台站点
/// </summary>
public
string
website
{
get
;
set
;
}
/// <summary>
/// 上传七牛云返回的hask码
/// </summary>
public
string
hashcode
{
get
;
set
;
}
/// <summary>
/// 上传七牛云返回的key
/// </summary>
public
string
filekey
{
get
;
set
;
}
}
}
Bailun.DC.Services/DataWareHouse/PlatformOrderServices.cs
View file @
20ab0b02
...
...
@@ -190,5 +190,63 @@ namespace Bailun.DC.Services.DataWareHouse
}
#
region
上传文件相关
/// <summary>
/// 保存文件信息到库
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public
string
SaveFileData
(
Models
.
DataWareHouse
.
uploadfiles
m
)
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_DW
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
var
id
=
cn
.
Insert
(
m
);
m
.
id
=
id
??
0
;
return
""
;
}
}
/// <summary>
/// 更新文件的七牛云标记信息
/// </summary>
/// <param name="id"></param>
/// <param name="hashcode"></param>
/// <param name="filekey"></param>
/// <returns></returns>
public
string
UpdateFileData
(
int
id
,
string
hashcode
,
string
filekey
)
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_DW
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
var
m
=
cn
.
QueryFirstOrDefault
<
Models
.
DataWareHouse
.
uploadfiles
>(
"select * from uploadfiles where id="
+
id
);
if
(
m
!=
null
)
{
m
.
hashcode
=
hashcode
;
m
.
filekey
=
filekey
;
cn
.
Update
(
m
);
return
""
;
}
return
"找不到该记录"
;
}
}
#
endregion
}
}
Bailun.DC.Web/Areas/DataWareHouse/Controllers/PlatformOrderController.cs
View file @
20ab0b02
...
...
@@ -286,7 +286,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <returns></returns>
//[BailunAuthentication(LoginMode.Enforce)]
[
DisableRequestSizeLimit
]
public
JsonResult
UploadOrderBilling
(
string
platform
,
string
website
,
string
month
)
public
JsonResult
UploadOrderBilling
(
string
platform
,
string
website
,
string
month
,
string
guid
)
{
if
(
string
.
IsNullOrEmpty
(
platform
))
{
...
...
@@ -315,6 +315,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
});
}
//var user = HttpContextHelper.Current?.User;
var
file
=
Request
.
Form
.
Files
[
0
];
...
...
Bailun.DC.Web/Areas/DataWareHouse/Views/PlatformOrder/OrderBillings.cshtml
View file @
20ab0b02
...
...
@@ -63,6 +63,7 @@
<button id="btn_Upload" type="button" style="" class="btn btn-warning">导入流水</button>
@*<button id="btn_Upload_Merge" type="button" style="" class="btn btn-warning">导入站点合并流水</button>*@
<button id="btn_Export_Voucher" type="button" style="" onclick="Export_Voucher()" class="btn btn-warning">导出凭证</button>
<span id="txt_tip"></span>
</div>
</div>
</form>
...
...
@@ -369,11 +370,11 @@
//}
uploadfile('btn_Upload',
'@Url.Content("~/DataWareHouse/PlatformOrder/Upload
OrderBilling
")' + '?platform=' + platform + '&website=' + website + '&month=' + month,
'@Url.Content("~/DataWareHouse/PlatformOrder/Upload
FileFragment
")' + '?platform=' + platform + '&website=' + website + '&month=' + month,
function(result){
if(result.success)
{
alert('
上传成功
!');
alert('
文件上传成功,后台会自动解析文件,请稍后再查看数据解析情况
!');
}
else
{
...
...
@@ -420,7 +421,6 @@
}
};
container.bootstrapPaginator(options);
...
...
@@ -499,6 +499,7 @@
function uploadfile(id,url,callback)
{
var _GUID = WebUploader.Base.guid();//一个GUID
var uploader = new WebUploader.Uploader({
// swf文件路径
swf: BASE_URL + 'Uploader.swf',
...
...
@@ -514,14 +515,38 @@
accept: {
extensions: "xls,xlsx",
mimeTypes: ".xls,.xlsx"
},
chunked: true,//开始分片上传
chunkSize: 2048000,//每一片的大小
formData: {
guid: _GUID //自定义参数,待会儿解释
}
});
uploader.on('uploadSuccess', function (file, response) {
if(callback!=undefined)
{
callback(response);
}
$.submit({
type:'post',
url: '@Url.Content("~/DataWareHouse/PlatformOrder/MergeUploadFile")',
paramData: 'guid=' + _GUID + '&filename=' + file.name + '&platform=' + platform + '&website=' + website+'&month='+month,
func: function (result) {
if (result.success) {
alert('文件上传成功,后台会自动解析文件,请稍后再查看数据解析情况!');
}
else {
alert(result.msg);
}
}
})
});
uploader.on('uploadProgress', function (file, percentage) {
//$("#uploader .progress-bar").width(percentage * 100 + '%');
$('#txt_tip').html('正在上传文件,当前进度:' + percentage * 100 + '%');
});
uploader.on('uploadSuccess', function () {
$('#txt_tip').html('上传成功');
});
uploader.on('uploadError', function (file) {
...
...
Bailun.DC.Web/Bailun.DC.Web.csproj
View file @
20ab0b02
...
...
@@ -30,6 +30,7 @@
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.10" />
<PackageReference Include="NPOI" Version="2.4.1" />
<PackageReference Include="Qiniu.Shared" Version="7.2.15" />
</ItemGroup>
<ItemGroup>
...
...
Bailun.DC.Web/Base/BaseController.cs
View file @
20ab0b02
...
...
@@ -158,6 +158,110 @@ namespace Bailun.DC.Web.Base
#
endregion
/// <summary>
/// 文件分片上传
/// </summary>
/// <returns></returns>
public
JsonResult
UploadFileFragment
()
{
string
fileName
=
Request
.
Form
[
"name"
];
int
index
=
Convert
.
ToInt32
(
Request
.
Form
[
"chunk"
]);
//当前分块序号
var
guid
=
Request
.
Form
[
"guid"
];
//前端传来的GUID号
var
dir
=
Directory
.
GetCurrentDirectory
()+
"\\tempUploadFile"
;
//Server.MapPath("~/Upload");//文件上传目录
dir
=
Path
.
Combine
(
dir
,
guid
);
//临时保存分块的目录
if
(!
System
.
IO
.
Directory
.
Exists
(
dir
))
System
.
IO
.
Directory
.
CreateDirectory
(
dir
);
string
filePath
=
Path
.
Combine
(
dir
,
index
.
ToString
());
//分块文件名为索引名,更严谨一些可以加上是否存在的判断,防止多线程时并发冲突
var
data
=
Request
.
Form
.
Files
[
"file"
];
//表单中取得分块文件
if
(
data
!=
null
)
//为null可能是暂停的那一瞬间
{
var
file
=
new
FileStream
(
filePath
,
FileMode
.
Create
);
var
stream
=
data
.
OpenReadStream
();
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
stream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
BinaryWriter
bw
=
new
BinaryWriter
(
file
);
bw
.
Write
(
bytes
);
bw
.
Close
();
file
.
Close
();
file
.
Dispose
();
}
return
Json
(
new
{
erron
=
0
});
//Demo,随便返回了个值,请勿参考
}
[
HttpPost
]
public
JsonResult
MergeUploadFile
(
string
guid
,
string
platform
,
string
website
,
string
month
,
string
filename
)
{
//uploadfiles
var
uploadDir
=
Directory
.
GetCurrentDirectory
()
+
"\\tempUploadFile"
;
//Upload 文件夹
var
dir
=
Path
.
Combine
(
uploadDir
,
guid
);
//临时保存分块的目录
var
files
=
System
.
IO
.
Directory
.
GetFiles
(
dir
);
//获得下面的所有文件
var
finalPath
=
Path
.
Combine
(
uploadDir
,
filename
);
//最终的文件名(demo中保存的是它上传时候的文件名,实际操作肯定不能这样)
var
fs
=
new
FileStream
(
finalPath
,
FileMode
.
Create
);
foreach
(
var
part
in
files
.
OrderBy
(
x
=>
x
.
Length
).
ThenBy
(
x
=>
x
))
//排一下序,保证从0-N Write
{
var
bytes
=
System
.
IO
.
File
.
ReadAllBytes
(
part
);
fs
.
Write
(
bytes
,
0
,
bytes
.
Length
);
bytes
=
null
;
System
.
IO
.
File
.
Delete
(
part
);
//删除分块
}
var
arr
=
filename
.
Split
(
'.'
);
var
uploadFile
=
new
Models
.
DataWareHouse
.
uploadfiles
{
filelen
=
fs
.
Length
,
filename
=
filename
,
filetype
=
arr
[
arr
.
Length
-
1
],
status
=
0
,
guidcode
=
guid
,
month
=
month
,
platform
=
platform
,
website
=
website
??
""
,
paramdata
=
""
,
hashcode
=
""
,
filekey
=
""
,
datatype
=
1
//销售平台
};
var
_platformService
=
new
Services
.
DataWareHouse
.
PlatformOrderServices
();
var
result
=
_platformService
.
SaveFileData
(
uploadFile
);
fs
.
Close
();
Directory
.
Delete
(
dir
);
//删除文件夹
fs
=
new
FileStream
(
finalPath
,
FileMode
.
OpenOrCreate
);
var
_hashcode
=
""
;
var
_filekey
=
""
;
//把文件上传到七牛云
var
qiuniu
=
new
QiNiuCloudHelper
(
ServiceFabric
.
Extension
.
ConfigManagerConf
.
GetValue
(
"QiNiu:AccessKey"
),
ServiceFabric
.
Extension
.
ConfigManagerConf
.
GetValue
(
"QiNiu:SecretKey"
));
qiuniu
.
UploadStream
(
fs
,
guid
+
"."
+
uploadFile
.
filetype
,
ref
_hashcode
,
ref
_filekey
);
uploadFile
.
hashcode
=
_hashcode
;
uploadFile
.
filekey
=
_filekey
;
//把七牛云返回的hash值更新到文件记录里面
result
+=
_platformService
.
UpdateFileData
(
uploadFile
.
id
,
uploadFile
.
hashcode
,
uploadFile
.
filekey
);
return
Json
(
new
{
success
=
string
.
IsNullOrEmpty
(
result
),
msg
=
result
}
);
}
public
System
.
Collections
.
ArrayList
Dtb2Json
(
DataTable
dtb
)
{
...
...
Bailun.DC.Web/Base/QiNiuCloudHelper.cs
0 → 100644
View file @
20ab0b02
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Qiniu.IO
;
using
Qiniu.IO.Model
;
using
Qiniu.Util
;
namespace
Bailun.DC.Web.Base
{
public
class
QiNiuCloudHelper
{
private
static
string
AK
=
""
;
private
static
string
SK
=
""
;
/// <summary>
///
/// </summary>
/// <param name="ak">AccessKey</param>
/// <param name="sk">SecretKey</param>
public
QiNiuCloudHelper
(
string
ak
,
string
sk
)
{
AK
=
ak
;
SK
=
sk
;
}
/// <summary>
/// 上传文件到七牛云
/// </summary>
public
string
UploadStream
(
System
.
IO
.
Stream
stream
,
string
filename
,
ref
string
hashcode
,
ref
string
key
)
{
// 生成(上传)凭证时需要使用此Mac
// 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey
// 实际应用中,请自行设置您的AccessKey和SecretKey
Mac
mac
=
new
Mac
(
AK
,
SK
);
string
bucket
=
"bailun-data-center"
;
string
saveKey
=
filename
;
//设置区域
Qiniu
.
Common
.
Config
.
AutoZone
(
AK
,
bucket
,
false
);
// 上传策略,参见
// https://developer.qiniu.com/kodo/manual/put-policy
PutPolicy
putPolicy
=
new
PutPolicy
();
// 如果需要设置为"覆盖"上传(如果云端已有同名文件则覆盖),请使用 SCOPE = "BUCKET:KEY"
putPolicy
.
Scope
=
bucket
+
":"
+
saveKey
;
//putPolicy.Scope = bucket;
// 上传策略有效期(对应于生成的凭证的有效期)
putPolicy
.
SetExpires
(
3600
);
// 上传到云端多少天后自动删除该文件,如果不设置(即保持默认默认)则不删除
putPolicy
.
DeleteAfterDays
=
7
;
// 生成上传凭证,参见
// https://developer.qiniu.com/kodo/manual/upload-token
string
jstr
=
putPolicy
.
ToJsonString
();
string
token
=
Auth
.
CreateUploadToken
(
mac
,
jstr
);
try
{
FormUploader
fu
=
new
FormUploader
();
var
result
=
fu
.
UploadStream
(
stream
,
filename
,
token
);
//{"hash":"Fto5o-5ea0sNMlW_75VgGJCv2AcJ","key":"ebay7月账单汇总.xlsx"}
if
(
result
.
Code
==
200
)
{
//return filename;
var
json
=
Newtonsoft
.
Json
.
Linq
.
JObject
.
Parse
(
result
.
Text
);
if
(
json
!=
null
)
{
hashcode
=
json
[
"hash"
].
ToString
();
key
=
json
[
"key"
].
ToString
();
}
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
);
}
return
""
;
}
}
}
Bailun.DC.Web/Startup.cs
View file @
20ab0b02
...
...
@@ -43,9 +43,8 @@ namespace Bailun.DC.Web
options
.
ValueCountLimit
=
int
.
MaxValue
;
options
.
MultipartBodyLengthLimit
=
200
*
1024
*
1024
;
//最大200M 解决文件上传Request body too large
options
.
MultipartHeadersCountLimit
=
10
;
options
.
MultipartHeadersCountLimit
=
200
*
1024
*
1024
;
options
.
MemoryBufferThreshold
=
int
.
MaxValue
;
});
...
...
Bailun.DC.Web/appsettings.json
View file @
20ab0b02
...
...
@@ -19,5 +19,10 @@
"BrowseLogSetting"
:
{
"Url"
:
"http://10.0.0.11:5001/operationloginfo/addoperationloginfo"
,
"CanLog"
:
"yes"
},
"QiNiu"
:
{
"AccessKey"
:
"QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn"
,
"SecretKey"
:
"yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm"
,
"DCFileUrl"
:
"http://dcfile.blsct.com"
}
}
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