|
|
|
@ -831,6 +831,84 @@ namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
return new ContentResult { Content = jsonRespose };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult FileUpload2()
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = JsonConvert.Serialize(new { success = false, message = "未上传文件" });
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 型号 提单号 箱号 批次号 件数 净重(吨) 毛重(吨) 包装 备注
|
|
|
|
|
var file = Request.Files["file"];//获取文件
|
|
|
|
|
if (file == null)//未上传文件
|
|
|
|
|
return new ContentResult { Content = jsonRespose };
|
|
|
|
|
//var path = Server.MapPath("../../UploadFiles/CtnTkDetail");//获取物理路径
|
|
|
|
|
//if (!Directory.Exists(path))
|
|
|
|
|
// Directory.CreateDirectory(path);
|
|
|
|
|
//var name = Path.GetFileName(file.FileName);
|
|
|
|
|
//var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
|
|
//string filepath = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
//if (System.IO.File.Exists(filepath))
|
|
|
|
|
// System.IO.File.Delete(filepath);
|
|
|
|
|
//file.SaveAs(filepath);
|
|
|
|
|
//DataSet ds = GetExcelDs(filepath);
|
|
|
|
|
|
|
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
|
|
|
|
|
var strMsg = "";
|
|
|
|
|
|
|
|
|
|
DataTable dt = BasicDataRefDAL.ExcelToDatatable(file.InputStream, ext, out strMsg);
|
|
|
|
|
|
|
|
|
|
if (dt!=null)
|
|
|
|
|
{
|
|
|
|
|
//DataTable dt = ds.Tables[0];
|
|
|
|
|
//修改导入的列名为字段名
|
|
|
|
|
string[] arr =
|
|
|
|
|
{
|
|
|
|
|
"GOODSMODEL","BLNO","CNTRNO","PICIHAO","件数","净重","毛重", "KINDPKGS", "REMARK"
|
|
|
|
|
};
|
|
|
|
|
for (int i = 0; i < arr.Length; i++)
|
|
|
|
|
dt.Columns[i].ColumnName = arr[i];
|
|
|
|
|
//增加显示品名
|
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAMEID" });
|
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAMEDISPLAY" });
|
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAME" });
|
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "GID" });
|
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "ZHONGLIANG2" });
|
|
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
item["GID"] = Guid.NewGuid().ToString();
|
|
|
|
|
item["ZHONGLIANG2"] = "0";
|
|
|
|
|
var model = BasicDataRefDAL.GetCodeGoodsList(string.Format("GOODCODE = '{0}' or GOODNAME like '%{0}%'", item["GOODSMODEL"]), "").FirstOrDefault();
|
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
item["GOODSNAMEID"] = model.GID;
|
|
|
|
|
item["GOODSNAMEDISPLAY"] = model.CodeAndName;
|
|
|
|
|
item["GOODSNAME"] = model.GOODNAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = ToJson(dt);
|
|
|
|
|
jsonRespose = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
success = true,
|
|
|
|
|
data = list,
|
|
|
|
|
totalCount = dt.Rows.Count,
|
|
|
|
|
message = "导入成功"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return new ContentResult { Content = jsonRespose };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception se)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
success = false,
|
|
|
|
|
message = se.Message
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult { Content = jsonRespose };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取DataSet
|
|
|
|
|
/// </summary>
|
|
|
|
|