Commit 49e82627 by guanzhenshan

上传物流流水调整为分片上传

parent 20ab0b02
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using Dapper;
using Bailun.DC.Models.DataWareHouse;
using System.Linq;
namespace Bailun.DC.Services.DataWareHouse
{
public class UploadFileServices
{
/// <summary>
/// 获取上传的流水数据文件解析情况
/// </summary>
/// <param name="platform">平台类型</param>
/// <param name="website">站点</param>
/// <param name="month">月份</param>
/// <param name="datatype">数据类型,1:销售平台,2:物流商流水</param>
/// <returns></returns>
public List<uploadfiles> GetPlatformUploadfile(string platform, string website, string month, int datatype)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if(cn.State== System.Data.ConnectionState.Closed)
{
cn.Open();
}
var sql = $"select * from uploadfiles where platform='{platform}' and month='{month}' and datatype={datatype}";
if (!string.IsNullOrEmpty(website))
{
sql += $" and website='{website}'";
}
return cn.Query<uploadfiles>(sql).ToList();
}
}
}
}
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</div> </div>
<div class="form-group" style="margin-left:10px"> <div class="form-group" style="margin-left:10px">
<label>账单月份</label> <label>账单月份</label>
<input id="month" name="month" class="form-control" style="width:135px" placeholder="账单归属月份" /> <input id="month" name="month" class="form-control" style="width:110px" placeholder="账单归属月份" />
</div> </div>
<div class="form-group" style="margin-left:10px"> <div class="form-group" style="margin-left:10px">
<label>时间</label> <label>时间</label>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</div> </div>
<div class="form-group" style="margin-left:10px"> <div class="form-group" style="margin-left:10px">
<label>单号</label> <label>单号</label>
<input id="orderno" name="orderno" class="form-control" style="width:200px" placeholder="请输入单号" /> <input id="orderno" name="orderno" class="form-control" style="width:110px" placeholder="请输入单号" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label>&nbsp;</label> <label>&nbsp;</label>
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
<button type="button" style="margin-left:10px" class="btn btn-warning" onclick="downloadTemplate()">模版下载</button> <button type="button" style="margin-left:10px" class="btn btn-warning" onclick="downloadTemplate()">模版下载</button>
<button id="btn_Upload" type="button" style="" class="btn btn-warning">导入流水</button> <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_Upload_Merge" type="button" style="" class="btn btn-warning">导入站点合并流水</button>*@
<span id="txt_tip"></span>
</div> </div>
</div> </div>
</form> </form>
...@@ -357,11 +358,11 @@ ...@@ -357,11 +358,11 @@
} }
uploadfile('btn_Upload', uploadfile('btn_Upload',
'@Url.Content("~/DataWareHouse/Logistics/UploadFlowing")' + '?platform=' + platform + '&month=' + month + '&website=' + website, '@Url.Content("~/DataWareHouse/Logistics/UploadFileFragment")' + '?platform=' + platform + '&month=' + month + '&website=' + website,
function(result){ function(result){
if(result.success) if(result.success)
{ {
alert('上传成功!'); alert('文件上传成功,后台会自动解析文件,请稍后再查看数据解析情况!');
} }
else else
{ {
...@@ -462,7 +463,8 @@ ...@@ -462,7 +463,8 @@
function uploadfile(id,url,callback) function uploadfile(id,url,callback)
{ {
uploader = new WebUploader.Uploader({ var _GUID = WebUploader.Base.guid();//一个GUID
var uploader = new WebUploader.Uploader({
// swf文件路径 // swf文件路径
swf: BASE_URL + 'Uploader.swf', swf: BASE_URL + 'Uploader.swf',
// 文件接收服务端。 // 文件接收服务端。
...@@ -477,14 +479,38 @@ ...@@ -477,14 +479,38 @@
accept: { accept: {
extensions: "xls,xlsx", extensions: "xls,xlsx",
mimeTypes: ".xls,.xlsx" mimeTypes: ".xls,.xlsx"
},
chunked: true,//开始分片上传
chunkSize: 2048000,//每一片的大小
formData: {
guid: _GUID //自定义参数,待会儿解释
} }
}); });
uploader.on('uploadSuccess', function (file, response) { uploader.on('uploadSuccess', function (file, response) {
if(callback!=undefined) $.submit({
{ type:'post',
callback(response); url: '@Url.Content("~/DataWareHouse/Logistics/MergeUploadFile")',
} paramData: 'guid=' + _GUID + '&filename=' + file.name + '&platform=' + platform + '&website=' + website+'&month='+month+'&datatype=2',
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) { uploader.on('uploadError', function (file) {
...@@ -505,7 +531,7 @@ ...@@ -505,7 +531,7 @@
if (result.data.length > 0) { if (result.data.length > 0) {
for (var i in result.data) { for (var i in result.data) {
$('#website').append('<button class="btn btn-info wsites" type="button" aria-pressed="false" onclick="selWebsite(\'' + result.data[i] + '\',this)">' + result.data[i]+'</button>'); $('#website').append('<button class="btn btn-info wsites" type="button" aria-pressed="false" onclick="selWebsite(\'' + result.data[i] + '\',this)">' + result.data[i]+'</button>');
} }
} }
......
...@@ -546,7 +546,7 @@ ...@@ -546,7 +546,7 @@
}); });
uploader.on('uploadSuccess', function () { uploader.on('uploadSuccess', function () {
$('#txt_tip').html('上传成功'); $('#txt_tip').html('上传成功,待保存数据');
}); });
uploader.on('uploadError', function (file) { uploader.on('uploadError', function (file) {
......
...@@ -195,7 +195,7 @@ namespace Bailun.DC.Web.Base ...@@ -195,7 +195,7 @@ namespace Bailun.DC.Web.Base
} }
[HttpPost] [HttpPost]
public JsonResult MergeUploadFile(string guid, string platform, string website, string month, string filename) public JsonResult MergeUploadFile(string guid, string platform, string website, string month, string filename,int datatype=1)
{ {
//uploadfiles //uploadfiles
...@@ -228,7 +228,7 @@ namespace Bailun.DC.Web.Base ...@@ -228,7 +228,7 @@ namespace Bailun.DC.Web.Base
hashcode = "", hashcode = "",
filekey = "", filekey = "",
datatype = 1 //销售平台 datatype = datatype //1=销售平台
}; };
var _platformService = new Services.DataWareHouse.PlatformOrderServices(); var _platformService = new Services.DataWareHouse.PlatformOrderServices();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment