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.

590 lines
23 KiB
C#

11 months ago
using System;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsOpAireDAL;
using DSWeb.MvcShipping.Models.MsOpAire;
using DSWeb.MvcShipping.Models.MsOpAireBill;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using DSWeb.MvcShipping.Comm.Cookie;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpAireController : 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 SeaeFeeView()
{
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 PiLiangOpBill()
{
return View();
}
public ActionResult EditView()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition,string load)
{
var dataList = MsOpAireDAL.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 = MsOpAireDAL.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 = MsOpAireDAL.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 GetFenList(int start, int limit, string sort, string condition)
{
var dataList = MsOpAireDAL.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 GetData(string handle, string condition)
{
MsOpAire head = null;
if (handle == "edit")
{
head = MsOpAireDAL.GetData(condition);
}
if (head == null)
{
head = new MsOpAire();
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<MsOpAire>(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_aire");
}
else
{
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
iscreatecustno = true;
}
}
}
else {
//if (!isuse) {
// {
var ct = MsOpAireDAL.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 = CookieConfig.GetCookie_CompanyId(Request);
}
if (headData.MBLNO != "" && headData.MBLNO != null && headData.BLTYPE != "拼箱分票" && headData.BLTYPE != "空运分票")
{
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='AireMblrepeat'");
if (mblreapeat.PARAMVALUE != "1")
{
var ct = MsOpAireDAL.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='AireHblrepeat'");
if (mblreapeat.PARAMVALUE != "1")
{
var ct = MsOpAireDAL.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.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
headData.HBLNO = hblno;
}
}
if (headData.ORDERNO != "" && headData.ORDERNO != null)
{
var ct = MsOpAireDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND ORDERNO='" + headData.ORDERNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "订舱编号";
}
}
if (headData.ETD != "" && headData.CUSTOMERNAME != "")// headData.STLDATE == "" &&
{
//根据客户、开船日计算账期
var _dmb = MsInfoClientDAL.GetSTLDATE(headData.CUSTOMERNAME, "海运出口", headData.ETD, 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.DELIVERYDATE == "") headData.DELIVERYDATE = null;
if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
headData.PORTLOAD = MsBaseInfoDAL.DelPortCn(headData.PORTLOAD);
headData.PORTDISCHARGE = MsBaseInfoDAL.DelPortCn(headData.PORTDISCHARGE);
if (headData.KGS == "") headData.KGS = "0";
if (headData.PKGS == "") headData.PKGS = "0";
if (headData.CBM == "") headData.CBM = "0";
if (headData.FEEKGS == "") headData.FEEKGS = "0";
if (headData.PRICE == "") headData.PRICE = "0";
if (headData.TTLFREIGHT == "") headData.TTLFREIGHT = "0";
if (headData.OTFEE1AMOUNT == "") headData.OTFEE1AMOUNT = "0";
if (headData.OTFEE2AMOUNT == "") headData.OTFEE2AMOUNT = "0";
if (headData.OTFEE3AMOUNT == "") headData.OTFEE3AMOUNT = "0";
if (headData.OTFEE4AMOUNT == "") headData.OTFEE4AMOUNT = "0";
if (headData.OTFEE5AMOUNT == "") headData.OTFEE5AMOUNT = "0";
if (headData.OTFEE6AMOUNT == "") headData.OTFEE6AMOUNT = "0";
if (headData.OTFEE7AMOUNT == "") headData.OTFEE7AMOUNT = "0";
if (headData.OTFEE8AMOUNT == "") headData.OTFEE8AMOUNT = "0";
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 = MsOpAireDAL.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) };
}
}
public ContentResult Delete(string data)
{
var head = JsonConvert.Deserialize<MsOpAire>(data);
var isfee = MsOpAireDAL.GetFeeCount(head.BSNO);
if (isfee)
{
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
if (head.BLTYPE == "空运主票")
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from OP_SEAE WHERE MASTERNO='" + head.BSNO + "' AND BSNO<>'" + head.BSNO + "'");
if (BLCOUNT == "0")
{
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) };
}
else
{
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 GetBillList(int start, int limit, string sort, string condition)
{
var dataList = MsOpAireDAL.GetBillList(condition, 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 GetBillData(string handle, string condition)
{
MsOpAireBill head = null;
if (handle == "edit")
{
head = MsOpAireDAL.GetBillData(condition);
}
if (head == null)
{
head = new MsOpAireBill();
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult BillSave(string opstatus, string data,string body)
{
var headData = JsonConvert.Deserialize<MsOpAireBill>(data);
if (opstatus == "add")
{
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
headData.AS_ID = Guid.NewGuid().ToString();
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.ETA == "") headData.ETA = null;
if (headData.ETD == "") headData.ETD = null;
if (headData.ISSUEDATE == "") headData.ISSUEDATE = null;
if (headData.KGS == "") headData.KGS = "0";
if (headData.PKGS == "") headData.PKGS = "0";
if (headData.CBM == "") headData.CBM = "0";
if (headData.FEEKGS == "") headData.FEEKGS = "0";
if (headData.PRICE == "") headData.PRICE = "0";
if (headData.TTLFREIGHT == "") headData.TTLFREIGHT = "0";
if (headData.TOTALAMOUNT == "") headData.TOTALAMOUNT = "0";
if (headData.OTFEE1AMOUNT == "") headData.OTFEE1AMOUNT = "0";
if (headData.OTFEE2AMOUNT == "") headData.OTFEE2AMOUNT = "0";
if (headData.OTFEE3AMOUNT == "") headData.OTFEE3AMOUNT = "0";
if (headData.OTFEE4AMOUNT == "") headData.OTFEE4AMOUNT = "0";
if (headData.OTFEE5AMOUNT == "") headData.OTFEE5AMOUNT = "0";
if (headData.OTFEE6AMOUNT == "") headData.OTFEE6AMOUNT = "0";
if (headData.OTFEE7AMOUNT == "") headData.OTFEE7AMOUNT = "0";
if (headData.OTFEE8AMOUNT == "") headData.OTFEE8AMOUNT = "0";
var modb = new ModelObjectDB();
var AS_ID = headData.AS_ID;
DBResult result = modb.Save(headData);
//if (result.Success == true)
//{
// result = MsOpSeaeDAL.SaveBillDetail(AS_ID, bodyList, Convert.ToString(Session["USERID"]));
//}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpAireDAL.GetBillData("AS_ID='" + AS_ID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult BillDelete(string data)
{
var head = JsonConvert.Deserialize<MsOpAireBill>(data);
var modb = new ModelObjectDB();
var AS_ID = head.AS_ID;
DBResult result = modb.Delete(head);
//if (result.Success == true) { MsOpSeaeDAL.DeleteDetail(AS_ID); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 生成报关信息
public ContentResult SaveBG(string data, string data2)
{
var aaa = "";
var head = JsonConvert.Deserialize<MsOpAire>(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;
if (head.PKGS == "")
headData.PKGS = 0;
else
headData.PKGS =Convert.ToInt32(head.PKGS);
if (head.KGS=="")
headData.KGS =0;
else
headData.KGS = Convert.ToDecimal(head.KGS);
if (head.CBM == "")
headData.CBM = 0;
else
headData.CBM = Convert.ToDecimal(head.CBM);
headData.PORTLOAD = head.PORTLOAD;
headData.PORTDISCHARGE = head.PORTDISCHARGE;
headData.SALE = head.SALE;
headData.SALEDEPT = head.SALEDEPT;
headData.BSTYPE = "3";
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
//
}
}