You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
574 lines
22 KiB
C#
574 lines
22 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.DAL.MsOpAiriDAL;
|
|
using DSWeb.MvcShipping.Models.MsOpAiri;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Data;
|
|
using System.Data.OleDb;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
|
|
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
|
|
using DSWeb.MvcShipping.Models.MsOpApply;
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using DSWeb.MvcShipping.DAL.MsInfoClient;
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class MsOpAiriController : Controller
|
|
{
|
|
//
|
|
// GET:
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult SaleEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult SaleIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FeeEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FenList()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult AiriFeeView()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FeeAmendEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult ReceiptEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult BillEdit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult FenEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult PiLiangFeeEdit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult HistryFeeIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult HistryBillIndex()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult FenBillList()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult PiLiangFenFee()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult EditView()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition,string load)
|
|
{
|
|
var dataList = MsOpAiriDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort,load);
|
|
var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult GetSaleDataList(int start, int limit, string sort, string condition, string load)
|
|
{
|
|
var dataList = MsOpAiriDAL.GetSaleDataList(condition, Convert.ToString(Session["SHOWNAME"]), sort, load, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
|
|
var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetDataListStr( string sort, string condition)
|
|
{
|
|
var dataListStr = MsOpAiriDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功",data = dataListStr });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
MsOpAiri head = null;
|
|
if (handle == "edit")
|
|
{
|
|
head = MsOpAiriDAL.GetData(condition);
|
|
}
|
|
if (head == null)
|
|
{
|
|
head = new MsOpAiri();
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
head.INPUTBY= Convert.ToString(Session["SHOWNAME"]);
|
|
head.CUSTSERVICE = Convert.ToString(Session["SHOWNAME"]);
|
|
var SALEORDERDEPTBYOP = MsSysParamSetDAL.GetData("PARAMNAME='SALEORDERDEPTBYOP'");
|
|
if (SALEORDERDEPTBYOP.PARAMVALUE == "1")
|
|
{
|
|
head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]);
|
|
}
|
|
}
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
|
|
public ContentResult Save(string opstatus, string data, string data2)
|
|
{
|
|
var aaa = "";
|
|
var dataall = data.Replace("}", ",") + data2.Replace("{", "");
|
|
var headData = JsonConvert.Deserialize<MsOpAiri>(dataall);
|
|
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
var isuse = false;
|
|
var iscreatecustno = false;
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='空运进口' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
|
|
if (billnoset.BILLTYPE != "")
|
|
isuse = true;
|
|
if (headData.CUSTNO == "")
|
|
{
|
|
if (isuse)
|
|
{
|
|
var FENCUSTNOE = MsSysParamSetDAL.GetData("PARAMNAME='FENCUSTNOE'");
|
|
if (FENCUSTNOE.PARAMVALUE == "1" && headData.MASTERNO != "" && headData.BSNO != headData.MASTERNO)
|
|
{
|
|
headData.CUSTNO = MsSysBillNoSetDAL.GetFenCustNo(headData.MASTERNO, "op_airi");
|
|
|
|
}
|
|
else
|
|
{
|
|
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETA.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
|
|
iscreatecustno = true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else {
|
|
//if (!isuse) {
|
|
// {
|
|
var ct = MsOpAiriDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND CUSTNO='" + headData.CUSTNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "委托编号";
|
|
}
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
if (headData.CORPID == ""||headData.CORPID ==null)
|
|
{
|
|
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
}
|
|
|
|
if (headData.MBLNO != "" && headData.MBLNO != null&&headData.BLTYPE!="空运分票")
|
|
{
|
|
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='AiriMblrepeat'");
|
|
if (mblreapeat.PARAMVALUE != "1")
|
|
{
|
|
var ct = MsOpAiriDAL.GetRdCount("MASTERNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "主提单号";
|
|
}
|
|
}
|
|
}
|
|
|
|
if (headData.HBLNO != "" && headData.HBLNO != null)
|
|
{
|
|
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='AiriHblrepeat'");
|
|
if (mblreapeat.PARAMVALUE != "1")
|
|
{
|
|
var ct = MsOpAiriDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "分提单号";
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
|
|
var billnosethblno = MsSysBillNoSetDAL.GetData("OPLBNAME='空运进口' AND RULEBLNO='分提单号' ", Convert.ToString(Session["COMPANYID"]));
|
|
if (billnosethblno.BILLTYPE != "" && billnosethblno.ISAUTO == "1")
|
|
{
|
|
var hblno = MsSysBillNoSetDAL.GetBillNo(billnosethblno, headData.ETA.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
|
|
headData.HBLNO = hblno;
|
|
|
|
}
|
|
|
|
}
|
|
if (headData.ORDERNO != "" && headData.ORDERNO != null)
|
|
{
|
|
var ct = MsOpAiriDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND ORDERNO='" + headData.ORDERNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "订舱编号";
|
|
}
|
|
}
|
|
|
|
if (headData.ETA != "" && headData.CUSTOMERNAME != "")// headData.STLDATE == "" &&
|
|
{
|
|
//根据客户、开船日计算账期
|
|
|
|
var _dmb = MsInfoClientDAL.GetSTLDATE(headData.CUSTOMERNAME, "海运出口", headData.ETA, headData.SALE);
|
|
headData.STLNAME = _dmb.STLNAME;
|
|
headData.STLDATE = _dmb.STLDATE;
|
|
|
|
if (_dmb.STLNAME == "")
|
|
{
|
|
headData.STLNAME = "现结买单";
|
|
headData.STLDATE = headData.ETD;
|
|
}
|
|
if (_dmb.BSSOURCE != "") headData.BSSOURCE = _dmb.BSSOURCE;
|
|
}
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
headData.BSDATE = DateTime.Now;
|
|
headData.BSSTATUS = false;
|
|
headData.FEESTATUS = false;
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
if (headData.MASTERNO == null || headData.MASTERNO =="") { headData.MASTERNO = headData.BSNO; }
|
|
|
|
if (headData.ETA == "") headData.ETA = null;
|
|
if (headData.ETD == "") headData.ETD = null;
|
|
if (headData.STLDATE == "") headData.STLDATE = null;
|
|
if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
|
|
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
|
|
if (headData.CHANGEDOCDATE == "") headData.CHANGEDOCDATE = null;
|
|
if (headData.DELIVERYDATE == "") headData.DELIVERYDATE = null;
|
|
|
|
headData.PORTLOAD = MsBaseInfoDAL.DelPortCn(headData.PORTLOAD);
|
|
headData.PORTDISCHARGE = MsBaseInfoDAL.DelPortCn(headData.PORTDISCHARGE);
|
|
|
|
|
|
var BSNO = headData.BSNO;
|
|
|
|
if (isPost)
|
|
{
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(headData);
|
|
if (result.Success == true) { }
|
|
else
|
|
{
|
|
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsOpAiriDAL.GetData("BSNO='" + BSNO + "'")
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
if (iscreatecustno == true)
|
|
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
|
|
var jsonRespose = new JsonResponse { Success = false, Message =errorstr+"重复,不允许保存!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
#region 拼箱操作
|
|
public ContentResult GetFenList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsOpAiriDAL.GetFenList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult GetDataListSum(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsOpAiriDAL.GetDataListSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult SaveFen(string bsno, string fenbody)
|
|
{
|
|
var bodyList = JsonConvert.Deserialize<List<MsOpAiri>>(fenbody);
|
|
var bodyList2 = new List<MsOpAiri>();
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
|
|
if (enumValue.CUSTNO == "")
|
|
{
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='空运进口'", Convert.ToString(Session["COMPANYID"]));
|
|
var FENCUSTNOE = MsSysParamSetDAL.GetData("PARAMNAME='FENCUSTNOE'");
|
|
if (FENCUSTNOE.PARAMVALUE != "1" && enumValue.MASTERNO != "" && enumValue.BSNO != enumValue.MASTERNO)
|
|
{
|
|
enumValue.CUSTNO = MsSysBillNoSetDAL.GetFenCustNo(enumValue.MASTERNO, "op_airi");
|
|
|
|
}
|
|
else
|
|
{
|
|
enumValue.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, enumValue.ETA.ToString().Trim(), enumValue.ACCDATE.ToString().Trim(), "", enumValue.OP, enumValue.SALECORPID);
|
|
}
|
|
}
|
|
if (enumValue.ETA == "") enumValue.ETA = null;
|
|
if (enumValue.ETD == "") enumValue.ETD = null;
|
|
if (enumValue.STLDATE == "") enumValue.STLDATE = null;
|
|
if (enumValue.HBLNO != "" && enumValue.HBLNO != null)
|
|
{
|
|
var ct = MsOpAiriDAL.GetRdCount("BSNO<>'" + enumValue.BSNO + "' AND HBLNO='" + enumValue.HBLNO + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = enumValue.HBLNO + "," + errorstr;
|
|
}
|
|
else
|
|
{
|
|
bodyList2.Add(enumValue);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bodyList2.Add(enumValue);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
DBResult result = null;
|
|
if (isPost == false)
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "分提单号:" + errorstr + "分提单号重复,请修改后重新保存!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
else
|
|
{
|
|
result = MsOpAiriDAL.SaveFenList(bsno, bodyList2, Convert.ToString(Session["COMPANYID"]));
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
public ContentResult DeleteFen(string fenbody)
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsOpAiri>>(fenbody);
|
|
DBResult result = null;
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
var isfee = MsOpAiriDAL.GetFeeCount(enumValue.BSNO);
|
|
if (isfee)
|
|
{
|
|
isPost = false;
|
|
errorstr = enumValue.HBLNO + "," + errorstr;
|
|
}
|
|
else
|
|
{
|
|
result = MsOpAiriDAL.DeleteFen(enumValue.BSNO);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (isPost == false)
|
|
{
|
|
result.Success = true;
|
|
result.Message = "分提单号:" + errorstr + "存在费用信息,无法直接删除!";
|
|
};
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult CancelFenAdd(string data)
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsOpAiri>>(data);
|
|
DBResult result = null;
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
result = MsOpAiriDAL.CancelFenAdd(enumValue.BSNO);
|
|
}
|
|
}
|
|
|
|
if (isPost == false)
|
|
{
|
|
result.Success = true;
|
|
result.Message = "分提单号:" + errorstr + "存在费用信息,无法直接删除!";
|
|
};
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<MsOpAiri>(data);
|
|
var isfee = MsOpAiriDAL.GetFeeCount(head.BSNO);
|
|
if (isfee)
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
var BSNO = head.BSNO;
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Delete(head);
|
|
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
#region 生成报关信息
|
|
public ContentResult SaveBG(string data, string data2)
|
|
{
|
|
var aaa = "";
|
|
|
|
var head = JsonConvert.Deserialize<MsOpAiri>(data.Replace("}", ",") + data2.Replace("{", ""));
|
|
|
|
var headData = new MsOpApply();
|
|
|
|
|
|
|
|
if (headData.CORPID == "" || headData.CORPID == null)
|
|
{
|
|
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
}
|
|
headData.MASTERNO = head.BSNO;
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
headData.BSDATE = DateTime.Now;
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
headData.CUSTOMERNAME = head.CUSTOMERNAME;
|
|
headData.MBLNO = head.MBLNO;
|
|
headData.VESSEL = head.VESSEL;
|
|
headData.BSSOURCE = head.BSSOURCE;
|
|
headData.BSSOURCEDETAIL = head.BSSOURCEDETAIL;
|
|
headData.ETD = head.ETD;
|
|
headData.ETA = head.ETA;
|
|
headData.PKGS = head.PKGS;
|
|
headData.KGS = head.KGS;
|
|
headData.CBM = head.CBM;
|
|
headData.PORTLOAD = head.PORTLOAD;
|
|
headData.PORTDISCHARGE = head.PORTDISCHARGE;
|
|
headData.SALE = head.SALE;
|
|
headData.SALEDEPT = head.SALEDEPT;
|
|
headData.BSTYPE = "4";
|
|
headData.CUSTOMNO = head.CUSTOMNO;
|
|
headData.CUSTOMDATE = head.CUSTOMDATE;
|
|
headData.INSPECTIONNO = head.INSPECTIONNO;
|
|
headData.INSPECTIONDATE = head.INSPECTIONDATE;
|
|
headData.ENTERP = head.ENTERP;
|
|
headData.ENTERPID = head.ENTERPID;
|
|
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(headData);
|
|
|
|
if (result.Success == true)
|
|
{
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "生成过程发生错误";
|
|
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
}
|
|
}
|
|
|