|
|
@ -9450,6 +9450,290 @@ namespace DSWeb.MvcShipping.Controllers
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
|
|
public ContentResult ImportYaHang()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var file = Request.Files["LoadExcel"];
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
|
|
|
if (ext == ".asp" || ext == ".aspx")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "不允许上传ASP或ASPX文件";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/BulkDetail");
|
|
|
|
|
|
|
|
var path2 = Server.MapPath("../../UploadFiles/BulkDetail/");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
|
|
|
|
|
string filenamepath = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string filename = path + "\\" + filenamepath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string excelFilePath = path2 + filenamepath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "上传的Excel不包含数据01";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (excel == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "无法创建Excel对象,可能您的服务器计算机未安装Excel!!";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//List<string> sheets = ExcelSheetName(filename);
|
|
|
|
|
|
|
|
//if (sheets.Count == 0)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// jsonRespose.Success = false;
|
|
|
|
|
|
|
|
// jsonRespose.Message = "上传的Excel不包含数据02";
|
|
|
|
|
|
|
|
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Workbook workbook = excel.Workbooks.Open(excelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
|
|
|
|
|
|
|
|
Worksheet mySheet = workbook.Sheets[1] as Worksheet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int excelline = 5;
|
|
|
|
|
|
|
|
var VESSEL = "";
|
|
|
|
|
|
|
|
var VOYNO = "";
|
|
|
|
|
|
|
|
var tmpopseae = new MsOpSeae();
|
|
|
|
|
|
|
|
var errostr = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
object aaa = mySheet.Cells.get_Range("A1").Value2;
|
|
|
|
|
|
|
|
object v11new = aaa;
|
|
|
|
|
|
|
|
if (v11new != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string strtmp3 = v11new.ToString();
|
|
|
|
|
|
|
|
if (strtmp3 != "")
|
|
|
|
|
|
|
|
VESSEL = strtmp3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
aaa = mySheet.Cells.get_Range("A2").Value2;
|
|
|
|
|
|
|
|
v11new = aaa;
|
|
|
|
|
|
|
|
if (v11new != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string strtmp3 = v11new.ToString();
|
|
|
|
|
|
|
|
if (strtmp3 != "")
|
|
|
|
|
|
|
|
VOYNO = strtmp3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var issave = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bodyList = new List<MsOpSeaeDetail>();
|
|
|
|
|
|
|
|
while (GetExcelValue(mySheet, "O" + excelline.ToString()) != "")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aaa = mySheet.Cells.get_Range("A" + excelline.ToString()).Value2;
|
|
|
|
|
|
|
|
v11new = aaa;
|
|
|
|
|
|
|
|
if (v11new != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string opstr = v11new.ToString();
|
|
|
|
|
|
|
|
if (opstr != "")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(tmpopseae.MBLNO)&&tmpopseae.MBLNO != opstr) {
|
|
|
|
|
|
|
|
issave = true;
|
|
|
|
|
|
|
|
if (issave)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var headData = new MsOpSeae();
|
|
|
|
|
|
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
|
|
|
|
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
headData.BSSTATUS = false;
|
|
|
|
|
|
|
|
headData.FEESTATUS = false;
|
|
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
|
|
|
headData.ISCANCEL = "0";
|
|
|
|
|
|
|
|
headData.MBLNO = tmpopseae.MBLNO;
|
|
|
|
|
|
|
|
headData.PORTLOAD = tmpopseae.PORTLOAD;
|
|
|
|
|
|
|
|
headData.PORTDISCHARGE = tmpopseae.PORTDISCHARGE;
|
|
|
|
|
|
|
|
headData.DESTINATION = tmpopseae.DESTINATION;
|
|
|
|
|
|
|
|
headData.SHIPPER = tmpopseae.SHIPPER;
|
|
|
|
|
|
|
|
headData.CONSIGNEE = tmpopseae.CONSIGNEE;
|
|
|
|
|
|
|
|
headData.NOTIFYPARTY = tmpopseae.NOTIFYPARTY;
|
|
|
|
|
|
|
|
headData.MARKS = tmpopseae.MARKS;
|
|
|
|
|
|
|
|
headData.DESCRIPTION = tmpopseae.DESCRIPTION;
|
|
|
|
|
|
|
|
headData.KGS = tmpopseae.KGS;
|
|
|
|
|
|
|
|
headData.GROSSWEIGHT = tmpopseae.GROSSWEIGHT;
|
|
|
|
|
|
|
|
headData.CBM = tmpopseae.CBM;
|
|
|
|
|
|
|
|
headData.MEASUREMENT = tmpopseae.MEASUREMENT;
|
|
|
|
|
|
|
|
headData.PKGS = tmpopseae.PKGS;
|
|
|
|
|
|
|
|
headData.KINDPKGS = tmpopseae.KINDPKGS;
|
|
|
|
|
|
|
|
headData.NOPKGS = tmpopseae.NOPKGS;
|
|
|
|
|
|
|
|
headData.MASTERNO = headData.BSNO;
|
|
|
|
|
|
|
|
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
|
|
|
|
|
|
headData.BSDATE = DateTime.Now;
|
|
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
|
|
|
|
|
var result = modb.Save(headData);
|
|
|
|
|
|
|
|
issave = false;
|
|
|
|
|
|
|
|
if (result.Success == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = MsOpSeaeDAL.SaveDetail(headData.BSNO, bodyList, Convert.ToString(Session["USERID"]), true);
|
|
|
|
|
|
|
|
bodyList.Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
errostr = errostr + result.Message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpopseae.MBLNO = opstr;
|
|
|
|
|
|
|
|
tmpopseae.PORTLOAD = GetExcelValue(mySheet, "C" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.PORTDISCHARGE = GetExcelValue(mySheet, "D" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.DESTINATION = GetExcelValue(mySheet, "E" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.SHIPPER = GetExcelValue(mySheet, "F" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.CONSIGNEE = GetExcelValue(mySheet, "G" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.NOTIFYPARTY = GetExcelValue(mySheet, "H" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.MARKS = GetExcelValue(mySheet, "I" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.DESCRIPTION = GetExcelValue(mySheet, "J" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.KGS = GetExcelValue(mySheet, "K" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.GROSSWEIGHT = tmpopseae.KGS + "KGS";
|
|
|
|
|
|
|
|
tmpopseae.CBM = GetExcelValue(mySheet, "L" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.MEASUREMENT = tmpopseae.CBM + "CBM";
|
|
|
|
|
|
|
|
tmpopseae.PKGS = GetExcelValue(mySheet, "M" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.KINDPKGS = GetExcelValue(mySheet, "N" + excelline.ToString());
|
|
|
|
|
|
|
|
tmpopseae.NOPKGS = tmpopseae.PKGS + tmpopseae.KINDPKGS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MsOpSeaeDetail data = new MsOpSeaeDetail();
|
|
|
|
|
|
|
|
data.BSNO = "*";
|
|
|
|
|
|
|
|
data.CTN_ID = Guid.NewGuid().ToString();
|
|
|
|
|
|
|
|
data.CTNALL = GetExcelValue(mySheet, "Q" + excelline.ToString()) + GetExcelValue(mySheet, "R" + excelline.ToString());
|
|
|
|
|
|
|
|
data.CNTRNO = GetExcelValue(mySheet, "O" + excelline.ToString());
|
|
|
|
|
|
|
|
data.SEALNO = GetExcelValue(mySheet, "P" + excelline.ToString());
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data.PKGS = Convert.ToInt32(GetExcelValue(mySheet, "T" + excelline.ToString()));
|
|
|
|
|
|
|
|
data.KINDPKGS = GetExcelValue(mySheet, "U" + excelline.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data.CTNSTATUS = GetExcelValue(mySheet, "S" + excelline.ToString());
|
|
|
|
|
|
|
|
var tmpkgs = GetExcelValue(mySheet, "V" + excelline.ToString());
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(tmpkgs))
|
|
|
|
|
|
|
|
data.WEIGHKGS = Convert.ToDecimal(tmpkgs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
excelline = excelline + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bodyList.Count != 0) {
|
|
|
|
|
|
|
|
var headData = new MsOpSeae();
|
|
|
|
|
|
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
|
|
|
|
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
headData.BSSTATUS = false;
|
|
|
|
|
|
|
|
headData.FEESTATUS = false;
|
|
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
|
|
|
headData.ISCANCEL = "0";
|
|
|
|
|
|
|
|
headData.MBLNO = tmpopseae.MBLNO;
|
|
|
|
|
|
|
|
headData.PORTLOAD = tmpopseae.PORTLOAD;
|
|
|
|
|
|
|
|
headData.PORTDISCHARGE = tmpopseae.PORTDISCHARGE;
|
|
|
|
|
|
|
|
headData.DESTINATION = tmpopseae.DESTINATION;
|
|
|
|
|
|
|
|
headData.SHIPPER = tmpopseae.SHIPPER;
|
|
|
|
|
|
|
|
headData.CONSIGNEE = tmpopseae.CONSIGNEE;
|
|
|
|
|
|
|
|
headData.NOTIFYPARTY = tmpopseae.NOTIFYPARTY;
|
|
|
|
|
|
|
|
headData.MARKS = tmpopseae.MARKS;
|
|
|
|
|
|
|
|
headData.DESCRIPTION = tmpopseae.DESCRIPTION;
|
|
|
|
|
|
|
|
headData.KGS = tmpopseae.KGS;
|
|
|
|
|
|
|
|
headData.GROSSWEIGHT = tmpopseae.GROSSWEIGHT;
|
|
|
|
|
|
|
|
headData.CBM = tmpopseae.CBM;
|
|
|
|
|
|
|
|
headData.MEASUREMENT = tmpopseae.MEASUREMENT;
|
|
|
|
|
|
|
|
headData.PKGS = tmpopseae.PKGS;
|
|
|
|
|
|
|
|
headData.KINDPKGS = tmpopseae.KINDPKGS;
|
|
|
|
|
|
|
|
headData.NOPKGS = tmpopseae.NOPKGS;
|
|
|
|
|
|
|
|
headData.MASTERNO = headData.BSNO;
|
|
|
|
|
|
|
|
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
|
|
|
|
|
|
headData.BSDATE = DateTime.Now;
|
|
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
|
|
|
|
|
var result = modb.Save(headData);
|
|
|
|
|
|
|
|
issave = false;
|
|
|
|
|
|
|
|
if (result.Success == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = MsOpSeaeDAL.SaveDetail(headData.BSNO, bodyList, Convert.ToString(Session["USERID"]), true);
|
|
|
|
|
|
|
|
bodyList.Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
errostr = errostr + result.Message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workbook.Close(true, Type.Missing, Type.Missing);
|
|
|
|
|
|
|
|
workbook = null;
|
|
|
|
|
|
|
|
excel.Quit();
|
|
|
|
|
|
|
|
excel = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功"+errostr });
|
|
|
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
workbook.Close(true, Type.Missing, Type.Missing);
|
|
|
|
|
|
|
|
workbook = null;
|
|
|
|
|
|
|
|
excel.Quit();
|
|
|
|
|
|
|
|
excel = null;
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
|
|
|
jsonRespose.Message = "读取Excel文件出错,请确认文件正确性";
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ContentResult ImportMSCEdit()
|
|
|
|
public ContentResult ImportMSCEdit()
|
|
|
|