using System; using System.Linq; using System.Web.Mvc; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using DSWeb.MvcShipping.Models.MsOpSeae; using DSWeb.MvcShipping.Models.MsOpSeai; using DSWeb.Areas.MvcShipping.DAL.BookingConfirm; using DSWeb.MvcShipping.Models.BookingConfirm; using HcUtility.Core; using System.Collections.Generic; using HcUtility.Comm; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.Dispatch.DAL; using DSWeb.MvcShipping.Models.MsSeaeOrder; using System.Data.Entity; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.DAL.MsOpSeaeDAL; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; using MsOpSeaeDAL = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.SoftMng.DAL.SoftSysTable; using DSWeb.EntityDA; using DSWeb.Areas.MvcShipping.DAL; using System.Text; using DSWeb.MvcShipping.Models.MsOpSeaeBill; using DSWeb.MvcShipping.DAL.MsOpSeaeEdiPortDAL; using BookingWeb.DB; using BookingWeb.DB.Model; using DSWeb.MvcShipping.DAL.DsSendmail; using DSWeb.MvcShipping.DAL.MsChFeeYsAutoDui; using DSWeb.Areas.SysMng.DAL.SysUser; namespace DSWeb.MvcShipping.Controllers { public class BookingConfirmController : Controller { // // GET: public ActionResult Index ( ) { return View(); } // public ActionResult Edit() { return View(); } public ActionResult Index_SI() { return View(); } // public ActionResult Edit_SI() { return View(); } // public ActionResult OpCtnDetailEdit() { return View(); } #region 订舱 订舱审核 /// /// 从订舱平台获取向本公司订舱的所有订舱信息,默认条件:业务状态BSSTATUS不为create /// /// /// public ContentResult GetBookingList (int start, int limit, string BOOKING_COMPANYID, string condition,string sort="") { //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var dataList = BookingConfirmDAL.GetBookingList( condition, Convert.ToString(Session["USERID"]), sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); var list_3 = list_2.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count(), data = list_3.ToList()}); return new ContentResult() { Content = json }; } public ContentResult GetBookingData(string BOOKING_COMPANYID, string condition, string sort = "") { //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var dataList = BookingConfirmDAL.GetBookingList(condition, Convert.ToString(Session["USERID"]), sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); if (list_2.Count > 0) { var resultdata = list_2[0]; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 0, data = resultdata }); return new ContentResult() { Content = json }; } else { var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 0, data = "" }); return new ContentResult() { Content = json }; } } private BookingConfirmmb GetBookingData(string condition, string sort = "") { var dataList = BookingConfirmDAL.GetBookingList(condition, Convert.ToString(Session["USERID"]), sort); if (dataList.Count > 0) { var resultdata = dataList[0]; return resultdata; } else { return new BookingConfirmmb(); } } public class DoingOrder { private static List ORDERNOList { get; set; } private static void makesureHave() { if (ORDERNOList == null) ORDERNOList = new List(); } public static bool IsDoing(string ORDERNO) { makesureHave(); return ORDERNOList.Exists(x => x == ORDERNO); } public static void Add(string ORDERNO) { makesureHave(); ORDERNOList.Add(ORDERNO); } public static void Del(string ORDERNO) { makesureHave(); ORDERNOList.RemoveAll(x => x == ORDERNO); } } /**************************************/ /* 审核订舱 */ /**************************************/ public ContentResult AuditWebOrderForm(string data, string data2, string body, string accdate, string op, string custservice, string sale) { DBResult result = new DBResult(); var BSNO = ""; var modb = new ModelObjectRepository(); Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase(); var head = new BookingConfirmmb(); var headDataStr = data.Replace("}", ",") + data2.Replace("{", ""); head.SetValue(db, headDataStr); var candoresult = BookingConfirmDAL.Order_CanConfirm(head.GetValue("BSNO"), OrderStatus.Confirm.ToString()); if (candoresult.Success == false) { var jsonRespose = new JsonResponse(); jsonRespose.SetDBResult(candoresult); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var _op = SysUserDAL.GetData(" SHOWNAME='" + op + "'"); var OrderData = head;//JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", "")); var basebody = new Booking_Ctnmb(); basebody.GetTableField(db); var bodyList = new List(); if (body != "") { var savedl = JsonConvert.Deserialize>>(body); foreach (var sdl in savedl) { var _body = new Booking_Ctnmb(); basebody.Copy(_body); _body.SetValue(sdl); bodyList.Add(_body); } } //var bodyList = JsonConvert.Deserialize>(body); var oldHeadData = MsOpSeaeDAL.GetData(" B.ORDERTYPE='网上订舱' and B.ORDENO='" + OrderData.GetValue("ORDERNO") + "'"); if (!string.IsNullOrWhiteSpace(oldHeadData.ORDERNO)) { var jsonRespose = new JsonResponse { Success = false, Message = "已存在该订单号的海运出口业务,", Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var headData = new MsOpSeae(); //var headData2 = new MsOpSeai(); headData.CORPID = Convert.ToString(Session["COMPANYID"]); headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]); headData.BSDATE = DateTime.Now; headData.BSSTATUS = false; headData.FEESTATUS = false; headData.DbOperationType = DbOperationType.DbotIns; BSNO= "topseae" + Guid.NewGuid().ToString(); headData.BSNO = BSNO;//获得新的海运出口业务编号; headData.MBLNO = OrderData.GetValue("MBLNO"); headData.HBLNO = OrderData.GetValue("HBLNO"); headData.CUSTOMERNAME = OrderData.GetValue("CUSTOMERNAME"); headData.ORDERNO = OrderData.GetValue("ORDERNO"); headData.ORDERTYPE = "网上订舱"; headData.SHIPPER = OrderData.GetValue("SHIPPER"); headData.CONSIGNEE = OrderData.GetValue("CONSIGNEE"); headData.NOTIFYPARTY = OrderData.GetValue("NOTIFYPARTY"); headData.VESSEL = OrderData.GetValue("VESSEL"); headData.VOYNO = OrderData.GetValue("VOYNO"); headData.ETD = OrderData.GetValue("ETD"); headData.PORTLOADID = OrderData.GetValue("PORTLOADID"); headData.PORTLOAD = OrderData.GetValue("PORTLOAD"); headData.PORTDISCHARGEID = OrderData.GetValue("PORTDISCHARGEID"); headData.PORTDISCHARGE = OrderData.GetValue("PORTDISCHARGE"); headData.PLACERECEIPT = OrderData.GetValue("PLACERECEIPT"); headData.PLACERECEIPTID = OrderData.GetValue("PLACERECEIPTID"); headData.PLACEDELIVERYID = OrderData.GetValue("PLACEDELIVERYID"); headData.PLACEDELIVERY = OrderData.GetValue("PLACEDELIVERY"); headData.DESTINATIONID = OrderData.GetValue("DESTINATIONID"); headData.DESTINATION = OrderData.GetValue("DESTINATION"); headData.NOBILL = OrderData.GetValue("NOBILL"); headData.ISSUETYPE = OrderData.GetValue("ISSUETYPE"); headData.ISSUEDATE = OrderData.GetValue("ISSUEDATE"); headData.ISSUEPLACE = OrderData.GetValue("ISSUEPLACE"); headData.ISSUEPLACEID = OrderData.GetValue("ISSUEPLACEID"); headData.BLFRT = OrderData.GetValue("BLFRT"); headData.PREPARDAT = OrderData.GetValue("PREPARDAT"); headData.PAYABLEAT = OrderData.GetValue("PAYABLEAT"); headData.COPYNOBILL = OrderData.GetValue("COPYNOBILL"); headData.SERVICE = OrderData.GetValue("SERVICE"); headData.MARKS = OrderData.GetValue("MARKS"); headData.NOPKGS = OrderData.GetValue("NOPKGS"); headData.DESCRIPTION = OrderData.GetValue("DESCRIPTION"); headData.GOODSNAME = OrderData.GetValue("GOODSNAME"); headData.GROSSWEIGHT = OrderData.GetValue("GROSSWEIGHT"); headData.MEASUREMENT = OrderData.GetValue(""); headData.PKGS = OrderData.GetValue("PKGS"); headData.KINDPKGS = OrderData.GetValue("KINDPKGS"); headData.KGS = OrderData.GetValue("KGS"); headData.CBM = OrderData.GetValue("CBM"); headData.TOTALNO = OrderData.GetValue("TOTALNO"); headData.CNTRTOTAL = OrderData.GetValue("CNTRTOTAL"); headData.CARRIER = OrderData.GetValue("CARRIER"); headData.CARGOID = OrderData.GetValue("CARGOID"); headData.HSCODE = OrderData.GetValue("HSCODE"); headData.DCLASS = OrderData.GetValue("DCLASS"); headData.DPAGE = OrderData.GetValue("DPAGE"); headData.DUNNO = OrderData.GetValue("DUNNO"); headData.DLABEL = OrderData.GetValue("DLABEL"); headData.LINKMAN = OrderData.GetValue("LINKMAN"); headData.REEFERF = OrderData.GetValue("REEFERF"); headData.TEMPID = OrderData.GetValue("TEMPID"); headData.TEMPSET = OrderData.GetValue("TEMPSET"); headData.TEMPMAX = OrderData.GetValue("TEMPMAX"); headData.TEMPMIN = OrderData.GetValue("TEMPMIN"); //headData.CUSTOMSNUM = OrderData.GetValue("CUSTOMSNUM"); headData.REMARK = OrderData.GetValue("REMARK");//备注 headData.ISFUMIGATION = OrderData.GetBoolen("ISFUMIGATION");//熏蒸 headData.ISSTORAGE = OrderData.GetBoolen("ISSTORAGE");//仓储 headData.ISLAND = OrderData.GetBoolen("ISLAND");//陆运 headData.ISCUSTOMS = OrderData.GetBoolen("ISCUSTOMS");//报关 headData.ISINSPECTION = OrderData.GetBoolen("ISINSPECTION");//报检 headData.ISBOOKING = OrderData.GetBoolen("ISBOOKING");//订舱 headData.ISAGENT = OrderData.GetBoolen("ISAGENT");//使用代理 headData.ISHBLNO = OrderData.GetBoolen("ISHBLNO");//分单签单 headData.SERVICE9 = OrderData.GetBoolen("SERVICE9");//服务项目9 headData.SERVICE10 = OrderData.GetBoolen("SERVICE10");//服务项目10 headData.STLNAME = OrderData.GetValue("STLNAME");//结算方式 headData.STLDATE = OrderData.GetValue("STLDATE");//结算时间 //headData.SALE = OrderData.SALE");//揽货人 headData.PACKINGTYPE = OrderData.GetValue("PACKINGTYPE");//装箱类型 headData.BLTYPE = "整箱";//装运方式 headData.OP = op;//T_ALL_DA.GetShowName(op); ////操作员 headData.CUSTSERVICE = custservice;//T_ALL_DA.GetShowName(custservice);//客服员 headData.SALE = sale; //headData.DOC = OrderData.DOC");//单证 headData.CONTRACTNO = OrderData.GetValue("CONTRACTNO"); headData.EDIREMARK = OrderData.GetValue("EDIREMARK"); 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.ISSUEDATE == "") headData.ISSUEDATE = null; if (headData.CLOSINGDATE == "") headData.CLOSINGDATE = null; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='海运出口' AND RULEBLNO='委托编号'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETD.ToString().Trim(), accdate); else { var jsonRespose = new JsonResponse { Success = false, Message = "请先设定当前公司的海运出口编码规则", Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } headData.ACCDATE = accdate; //var modb = new ModelObjectDB(); result = modb.Save(headData); BSNO = headData.BSNO; DoingOrder.Del(head.GetValue("ORDERNO")); if (result.Success == true && !string.IsNullOrEmpty(body)) { //引入箱明细 List ctnlist = new List(); foreach (var item in bodyList) { var ctn = new MsOpSeaeDetail(); ctn.GID = System.Guid.NewGuid().ToString(); ctn.CTN_ID = ctn.GID; ctn.BSNO = "*";//用来令其执行insert操作 ctn.SIZE = item.GetValue("SIZE"); ctn.CTN = item.GetValue("CTN"); ctn.CTNNUM = item.GetInt32("CTNNUM"); ctn.TEU = item.GetInt32("TEU"); ctn.PKGS = item.GetInt32("PKGS"); ctn.KGS = item.GetInt32("KGS"); ctn.CBM = item.GetInt32("CBM"); ctn.REMARK = item.GetValue("REMARK"); ctn.CTNALL = item.GetValue("CTNALL"); ctnlist.Add(ctn); } result = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.SaveDetail(BSNO, ctnlist, CookieConfig.GetCookie_UserId(Request), true); } if (result.Success == true) { //Audit_SaveBack(OrderData, "Confirm", headData.BSNO); BookingConfirmDAL.BookingStatus_Order(OrderData.GetValue("ORDNO"), headData.BSNO, OrderStatus.Confirm.ToString(), Session["COMPANYNAME"].ToString(),_op.EMAIL1); var email = head.GetValue("OPERATOREMAIL"); var _r = BookingConfirmDAL.SendMail_Order(head.GetValue("ORDNO"), "接受订舱", "", email, Session["USERID"].ToString(), Session["COMPANYNAME"].ToString(), headData); var datareturn = GetBookingData(" ORDNO='"+ OrderData.GetValue("ORDNO") + "'","").ExtendDic; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = datareturn }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult AuditWebOrderBack(string data, string data2,string orreason,string email) { Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase(); var head = new BookingConfirmmb(); var headDataStr = data.Replace("}", ",") + data2.Replace("{", ""); head.SetValue(db, headDataStr); var candoresult = BookingConfirmDAL.Order_CanConfirm(head.GetValue("BSNO"), OrderStatus.Back.ToString()); if (candoresult.Success == false) { var jsonRespose1 = new JsonResponse(); jsonRespose1.SetDBResult(candoresult); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; } BookingConfirmDAL.BookingStatus_Order(head.GetValue("ORDNO"),head.GetValue("BSNO"), OrderStatus.Back.ToString(),Session["COMPANYNAME"].ToString()); //Audit_SaveBack(head, "Back","", orreason); var datareturn = GetBookingData(" ORDNO='" + head.GetValue("ORDNO") + "'", "").ExtendDic; var _r = BookingConfirmDAL.SendMail_Order(head.GetValue("ORDNO"), "驳回订舱", orreason, email,Session["USERID"].ToString(),Session["COMPANYNAME"].ToString()); var jsonRespose = new JsonResponse { Success = true, Message = "驳回成功", Data = datareturn }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 后处理 已不再使用 /// /// private void Audit_SaveBack(BookingConfirmmb Bookinghead, string audittype, string BSNO="",string ORREASON="") { var str = string.Format(" update OP_SEAE_ORDER set BSNO='{1}',BSSTATUS='{2}' where ORDNO='{0}' ", Bookinghead.GetValue("ORDNO"),BSNO, audittype); BasicDataRefDAL.ExecSql_DB(str, "BookingDB"); } #endregion #region 提单确认 /// /// 从订舱平台获取向本公司订舱的所有订舱信息,默认条件:业务状态BSSTATUS不为create /// /// /// public ContentResult GetBooking_SIList(int start, int limit, string BOOKING_COMPANYID, string condition, string sort = "") { //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var dataList = BookingConfirmDAL.GetBooking_SIList(condition, Convert.ToString(Session["USERID"]), sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); var list_3 = list_2.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count(), data = list_3.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBooking_SIData(string BOOKING_COMPANYID, string condition, string sort = "") //, string SIFieldList { //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var dataList = BookingConfirmDAL.GetBooking_SIList(condition, Convert.ToString(Session["USERID"]), sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); Dictionary resultdata = list_2[0]; Dictionary t_dic = new Dictionary(resultdata); //var HeadSIFieldList = JsonConvert.Deserialize>(SIFieldList); //给前台需要打勾的复选框赋值 foreach (var item in t_dic) { resultdata.Add("IS" + item.Key, "1"); } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count(), data = resultdata }); return new ContentResult() { Content = json }; } #region 保存 public ContentResult SaveSI(string SINO ,string data1,string data2,string SIFieldList, string CtnFieldList, string CtnDetailFieldList,string DelMore="false") { //远程SI的SINO,需要将SI信息同步至本地的字段名列表,需要将SI的CTN信息同步至本地的字段名列表,需要将SI的CTNDetail信息同步至本地的字段名列表, //是否需要 var HeadSIFieldList = JsonConvert.Deserialize>(SIFieldList); var CtnSIFieldList = JsonConvert.Deserialize>(CtnFieldList); var CtnDetailSIFieldList = JsonConvert.Deserialize>(CtnDetailFieldList); var DiffData = JsonConvert.Deserialize(data1.Replace("}", ",") + data2.Replace("{", "")); var dataList_1 = BookingConfirmDAL.GetBooking_SIList(" SINO='"+ SINO + "'", Convert.ToString(Session["USERID"]), ""); var list_1 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList_1)); var SIData = list_1[0];//SI 提单确认数据 var result = new DBResult(); var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; var cando = BookingConfirmDAL.SI_CanConfirm(SIData["SINO"], OrderConfirmStatus.Confirm.ToString()); if (!cando.Success) { jsonRespose.SetDBResult(cando); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var dataList_2 = BookingConfirmDAL.GetCtnList(" ORDNO='" + SINO + "'", ""); //SI CTN数据 var SICtnList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList_2)); var dataList_3 = BookingConfirmDAL.GetCtnDetailList(" CTN_ID in(select CTN_ID from OP_CTN where ORDNO='" + SINO + "')", Convert.ToString(Session["USERID"]), ""); //SI 多品名数据 var SICtnDetailList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList_3)); var BillData = new MsOpSeaeBill(); var OpSeaeData = new MsOpSeae(); var OpSeaeAms = new MsOpSeaeAms(); var CtnCondition = ""; var CtnDetailCondition = ""; var DelCtnList = new List();//需要删除的多余ctn信息 var DelCtnDetailList = new List();//需要删除的多余ctnDetail信息 OpSeaeData = MsOpSeaeDAL.GetData(" BSNO = '" + SIData["ORDER_BSNO"] + "'"); OpSeaeAms = MsOpSeaeEdiPortDAL.GetAmsData(" BSNO = '" + SIData["ORDER_BSNO"] + "'"); if (OpSeaeAms.BSNO == "") { OpSeaeAms.AMSNO = System.Guid.NewGuid().ToString(); OpSeaeAms.BSNO = SIData["ORDER_BSNO"]; OpSeaeAms.DbOperationType = DbOperationType.DbotIns; } //本地 OPSEAE数据/提单信息数据 if (SIData["ISMULTI"] == "true") { //使用提单信息 提单信息下的集装箱信息 集装箱明细(附着于OP_SEAE的,通过CNTRNO箱号关联) BillData = MsOpSeaeDAL.GetBillData(" MBLNO = '" + SIData["MBLNO"] + "' "); if (BillData.MBLNO == "") { //代表需要新建一条提单信息 BillData.MBLNO = SIData["MBLNO"]; BillData.BSNO = SIData["ORDER_BSNO"]; BillData.AS_ID = System.Guid.NewGuid().ToString(); BillData.DbOperationType = DbOperationType.DbotIns; } CtnCondition = " BSNO = '" + BillData.AS_ID + "' "; CtnDetailCondition = "CTN_ID in(select CTN_ID from op_ctn where " + CtnCondition + ") "; } else { CtnCondition = " BSNO = '" + OpSeaeData.BSNO + "' "; CtnDetailCondition = "CTN_ID in(select CTN_ID from op_ctn where " + CtnCondition + ") "; } var CtnList = MsOpSeaeDAL.GetBodyList(CtnCondition); //var HeadCtnList = MsOpSeaeDAL.GetBodyList("CTN_ID in(select CTN_ID from op_ctn where BSNO = '" + OpSeaeData.BSNO + "') "); //当前正在同步的业务的多品名信息(可能是主业务的,也可能是一条提单信息下的) var CtnDetailList = MsOpSeaeDAL.GetOpCtnDetailList(CtnDetailCondition); var ChangeCtnDetailList = new List(); var ctnParentIDValue = ""; //1: 遍历 字段名 列表 将相应值赋给对象里的相应对象 if (SIData["ISMULTI"] == "true") { foreach (var item in HeadSIFieldList) { if (!DiffData.getChecked(item.FieldName)) continue; if (item.FieldName == "PKGS") { BillData.SetPropertyValue("PKGS",Convert.ToInt32(DiffFieldmb.GetValue(HeadSIFieldList, SIData, "PKGS"))); } else if (item.FieldName == "KGS") { BillData.SetPropertyValue("KGS", Convert.ToDecimal(DiffFieldmb.GetValue(HeadSIFieldList, SIData, "KGS"))); } else if (item.FieldName == "CBM") { BillData.SetPropertyValue("CBM", Convert.ToDecimal(DiffFieldmb.GetValue(HeadSIFieldList, SIData, "CBM"))); } else BillData.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(HeadSIFieldList, SIData, item.FieldName)); } //20191218 将一些字段用主业务信息填充 var head = MsOpSeaeDAL.GetData("BSNO='"+ SIData["ORDER_BSNO"] + "'"); BillData.VESSEL = head.VESSEL; BillData.VOYNO = head.VOYNO; BillData.YARD = head.YARD; BillData.ETD = head.ETD; BillData.CLOSINGDATE = head.CLOSINGDATE; //BillData.CLOSEDOCDATE = head.CLOSEDOCDATE; //BillData.VESSELID = head.VESSELID; BillData.CARRIER = head.CARRIER; //然后将一些op_seae_billmanage当中不存在 所以需要保存到主表的字段数据加入主业务表 var MainList = BookingConfirmDAL.GetMoreField(HeadSIFieldList); foreach (var item in MainList) { if (!DiffData.getChecked(item.FieldName)) continue; OpSeaeData.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(HeadSIFieldList, SIData, item.FieldName)); } //将 SIREMARK字段写入OpseaeAms对象 if (!DiffData.getChecked("SIREMARK" )) { } else { OpSeaeAms.SIREMARK = DiffFieldmb.GetValue(HeadSIFieldList, SIData, "SIREMARK").ToString(); } ctnParentIDValue = BillData.AS_ID; } else { foreach (var item in HeadSIFieldList) { if (!DiffData.getChecked(item.FieldName)) continue; OpSeaeData.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(HeadSIFieldList, SIData, item.FieldName)); } //将 SIREMARK字段写入OpseaeAms对象 OpSeaeAms.SIREMARK = DiffFieldmb.GetValue(HeadSIFieldList, SIData, "SIREMARK").ToString(); ctnParentIDValue = OpSeaeData.BSNO; } //2: 赋值ctn数据 依靠CNTRNO关联 var needinsert = true; foreach (var SICtn in SICtnList) { needinsert = true; foreach (var ctn in CtnList) { if (ctn.CNTRNO == SICtn["CNTRNO"]) { foreach (var item in CtnSIFieldList) { ctn.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(CtnSIFieldList, SICtn, item.FieldName)); } needinsert = false; continue; } } if (needinsert) { //代表这条SI数据在本地不存在 需要增加 var newCtn = new MsOpSeaeDetail(); newCtn.BSNO = "";//保持为空按插入处理; newCtn.VGMCONNCOM = ""; newCtn.CTN_ID = System.Guid.NewGuid().ToString(); foreach (var item in CtnSIFieldList) { newCtn.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(CtnSIFieldList, SICtn, item.FieldName)); } newCtn.SIZE = SICtn["CTNALL"].Substring(0, 2); newCtn.CTN = SICtn["CTNALL"].Substring(2, 2); newCtn.DbOperationType = DbOperationType.DbotIns; CtnList.Add(newCtn); } } //3: 赋值多品名ctnDetail数据 ///循环SI内的多品名 CtnDetailList foreach (var SICtnDetail in SICtnDetailList) { needinsert = true; ///本地CtnDetailList(当前进行保存的);可能是主业务的,也可能是提单列表中的一票下的 foreach (var LocalCtnDetail in CtnDetailList) { var _localcntrno = ""; var _localCTN_ID = ""; foreach (var LocalCtn in CtnList) { if (LocalCtn.CTN_ID == LocalCtnDetail.CTN_ID) { _localcntrno = LocalCtn.CNTRNO; _localCTN_ID = LocalCtn.CTN_ID; break; } } var _SIcntrno = ""; foreach (var SICtn in SICtnList) { if (SICtn["CTN_ID"] == SICtnDetail["CTN_ID"]) { _SIcntrno = SICtn["CNTRNO"]; break; } } if (_localcntrno == _SIcntrno && LocalCtnDetail.HSCODE== SICtnDetail["HSCODE"]) { foreach (var item in CtnDetailSIFieldList) { LocalCtnDetail.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(CtnDetailSIFieldList, SICtnDetail, item.FieldName)); } needinsert = false; LocalCtnDetail.CTN_ID = _localCTN_ID; LocalCtnDetail.DbOperationType = DbOperationType.DbotUpd; ChangeCtnDetailList.Add(LocalCtnDetail); break; } } if (needinsert) { var newCtnDetail = new MsOpCtnDetail(); //寻找这条明细的CTN_ID应该是谁 //首先找到它的父节点 SI的CTN 获得它的CNTRNO //然后在本地CTN信息里找到这个CTN,获取它的CTN_ID;这就是本地即将插入的CTNDetail的BSNO var _localCTN_ID = ""; var _cntrno = ""; foreach (var SICtn in SICtnList) { if (SICtn["CTN_ID"] == SICtnDetail["CTN_ID"]) { _cntrno = SICtn["CNTRNO"]; break; } } foreach (var LocalCtn in CtnList) { if (LocalCtn.CNTRNO == _cntrno) { _localCTN_ID = LocalCtn.CTN_ID; } } foreach (var item in CtnDetailSIFieldList) { newCtnDetail.SetPropertyValue(item.FieldName, DiffFieldmb.GetValue(CtnDetailSIFieldList, SICtnDetail, item.FieldName)); } newCtnDetail.GID = System.Guid.NewGuid().ToString(); newCtnDetail.CTN_ID = _localCTN_ID; newCtnDetail.DbOperationType = DbOperationType.DbotIns; ChangeCtnDetailList.Add(newCtnDetail); } } var modb = new ModelObjectRepository(); var detailmodb = new ModelObjectDB(); OpSeaeData.NOPKGS = OpSeaeData.PKGS.ToString() + OpSeaeData.KINDPKGS.ToString(); if (SIData["ISMULTI"] == "true") { BillData.INPUTBY = Session["SHOWNAME"].ToString(); result = modb.SaveHead(BillData); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } result = modb.SaveHead(OpSeaeData); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } result = modb.SaveHead(OpSeaeAms); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } result = modb.SaveComm("BSNO", ctnParentIDValue , ModelObjectConvert.ToModelObjectList(CtnList) ,null); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } foreach (var ctndetail in ChangeCtnDetailList) { result = detailmodb.Save(ctndetail); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } if (DelMore == "true") { result = Do_DelMore(SICtnList,SICtnDetailList,CtnList,CtnDetailList); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } if (SIData["ISMULTI"] == "true") { result = Do_SetSeaeChildValue(BillData.AS_ID,"true"); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } else { result = Do_SetSeaeChildValue(OpSeaeData.BSNO, "false"); if (!result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } if (result.Success) { //SI_SaveBack(SINO, "Confirm"); BookingConfirmDAL.BookingStatus_Confirm(SIData["SINO"], OrderConfirmStatus.Confirm.ToString(),Session["COMPANYNAME"].ToString(),Session["USERID"].ToString()); //var sidata = GetBooking_SIData(" SINO='" + SIData["SINO"] + "'", Session["USERID"].ToString()); var _r = BookingConfirmDAL.SendMail_SI(SIData["SINO"], "接收提单确认", "", OpSeaeData, SIData["OPERATORMAIL"], Session["USERID"].ToString(), Session["COMPANYNAME"].ToString()); //OpSeaeData } jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private static BookingDB bookingDB = new BookingDB(); public ContentResult RejectSI(string SINO,string orreason="",string email="") { var confirm = bookingDB.Confirms.FirstOrDefault(o => o.SINO == SINO); var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; var cando = BookingConfirmDAL.SI_CanConfirm(SINO, OrderConfirmStatus.Reject.ToString()); if (!cando.Success) { jsonRespose.SetDBResult(cando); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var result = BookingConfirmDAL.BookingStatus_Confirm(SINO, OrderConfirmStatus.Reject.ToString(), Session["COMPANYNAME"].ToString()); var _order = bookingDB.Orders.FirstOrDefault(o => o.ORDNO == confirm.ORDNO); var OpSeaeData = MsOpSeaeDAL.GetData(" BSNO = '" + _order.BSNO + "'"); var _r = BookingConfirmDAL.SendMail_SI(SINO, "拒绝截单", orreason, OpSeaeData, email, Session["USERID"].ToString(), Session["COMPANYNAME"].ToString()); jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private void SI_SaveBack(string SINO,string audittype) { var str = string.Format(" update OP_SEAE_SI set BSSTATUS='{1}' where SINO='{0}' ", SINO, audittype); BasicDataRefDAL.ExecSql_DB(str, "BookingDB"); } /// /// 将本地的多余ctn信息和ctndetail信息删除 /// /// /// /// public static ContentResult DelMore(List> SICtnList, List> SICtnDetailList, List LocalCtnList, List LocalCtnDetailList) { var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; var result = Do_DelMore(SICtnList, SICtnDetailList, LocalCtnList, LocalCtnDetailList); jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private static DBResult Do_DelMore(List> SICtnList, List> SICtnDetailList, List LocalCtnList, List LocalCtnDetailList) { var needdelete = true; var DelCtnList = new List(); var DelCtnDetailList = new List(); foreach (var Localctn in LocalCtnList) { needdelete = true; foreach (var SICtn in SICtnList) { if (SICtn["CNTRNO"] == Localctn.CNTRNO) { needdelete = false; break; } } if (needdelete) { Localctn.DbOperationType = DbOperationType.DbotDel; DelCtnList.Add(Localctn); } } //foreach (var LocalctnDetail in LocalCtnDetailList) //{ // needdelete = true; // foreach (var SICtnDetail in SICtnDetailList) // { // if (SICtnDetail["CNTRNO"] == LocalctnDetail.CNTRNO) // { // needdelete = false; // break; // } // } // if (needdelete) // { // LocalctnDetail.DbOperationType = DbOperationType.DbotDel; // DelCtnDetailList.Add(LocalctnDetail); // } //} var detailmodb = new ModelObjectDB(); var result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(DelCtnList)); if (!result.Success) { return result; } else { //删除所有无集装箱的集装箱明细 T_ALL_DA.ExecuteSqlCommand("delete from op_ctn_detail where CTN_ID not in(select ctn_id from op_ctn)"); //result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(DelCtnDetailList)); } return result; } /// /// 根据SI的ctn信息和ctndetail信息,重新计算Opseae主表下的ctn信息和ctndetail信息 /// /// 传入的OP_Seae.BSNO /// public static ContentResult SetSeaeChildValue(string BSNO,string ISMULTI = "false") { var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; var result = Do_SetSeaeChildValue(BSNO, ISMULTI); jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private static DBResult Do_SetSeaeChildValue(string BSNO, string ISMULTI = "false") { var Main_BSNO = ""; var detailmodb = new ModelObjectDB(); var result = new DBResult(); var CTNDetailList = new List(); Main_BSNO = ""; bool needinsert = true; var Main_CTNList = new List(); //1首先看该截单对应的是否是一条提单信息 如是 if (ISMULTI == "true") { var BillManage = MsOpSeaeDAL.GetBillData(" AS_ID = '" + BSNO + "' "); Main_BSNO = BillManage.BSNO; //查询所有主业务下的集装箱信息 Main_CTNList = MsOpSeaeDAL.GetBodyList(" BSNO='" + Main_BSNO + "' "); //查找所有提单列表信息 var BillManageList = MsOpSeaeDAL.GetBillList(" BSNO = '" + Main_BSNO + "' "); //所有提单列表信息下的集装箱信息 var billManage_CTNList = MsOpSeaeDAL.GetBodyList(" BSNO in(select AS_ID from op_seae_billmanage where BSNO='" + Main_BSNO + "') "); //查找其所有提单信息下的多品名明细信息 var billManage_CTNDetailList = MsOpSeaeDAL.GetOpCtnDetailList(" CTN_ID in(select CTN_ID from op_ctn where BSNO in(select AS_ID from op_seae_billmanage where BSNO='" + Main_BSNO + "')) "); //首先查看主业务下的集装箱信息 如缺少则添加 // foreach (var bill_ctn in billManage_CTNList) { needinsert = true; foreach (var ctn in Main_CTNList) { if (bill_ctn.CNTRNO == ctn.CNTRNO) { needinsert = false; break; } } if (needinsert) { MsOpSeaeDetail newctn = new MsOpSeaeDetail(); //newctn = MsOpSeaeDetail.Copy(bill_ctn); bill_ctn.Copy(newctn); newctn.DbOperationType = DbOperationType.DbotIns; //newctn.GID = System.Guid.NewGuid().ToString(); newctn.CTN_ID = System.Guid.NewGuid().ToString(); newctn.BSNO = Main_BSNO; Main_CTNList.Add(newctn); } } //查找所有主业务下的多品名信息 并根据CNTRNO和HSCODE合计所有主业务下的多品名信息 //但如果SI当中没有多品名信息 则不进行此操作 CTNDetailList = MsOpSeaeDAL.GetOpCtnDetailList(" CTN_ID in(select CTN_ID from op_ctn where BSNO='" + Main_BSNO + "') "); if (billManage_CTNDetailList.Count > 0) { foreach (var billmanage_ctndetail in billManage_CTNDetailList) { foreach (var CTNDetail in CTNDetailList) if (CTNDetail.CNTRNO == billmanage_ctndetail.CNTRNO) { CTNDetail.PKGS = 0; CTNDetail.KGS = 0; CTNDetail.CBM = 0; CTNDetail.DbOperationType = DbOperationType.DbotUpd; } } } if (billManage_CTNDetailList.Count > 0) { //首先根据多品名合计多品名 foreach (var billmanage_ctndetail in billManage_CTNDetailList) { needinsert = true; foreach (var ctndetail in CTNDetailList) { if (ctndetail.CNTRNO == billmanage_ctndetail.CNTRNO && ctndetail.HSCODE == billmanage_ctndetail.HSCODE) { ctndetail.PKGS += billmanage_ctndetail.PKGS; ctndetail.KGS += billmanage_ctndetail.KGS; ctndetail.CBM += billmanage_ctndetail.CBM; needinsert = false; break; } } if (needinsert) { var _ctn_id = ""; foreach (var ctn in Main_CTNList) { if (ctn.CNTRNO == billmanage_ctndetail.CNTRNO) { _ctn_id = ctn.CTN_ID; break; } } MsOpCtnDetail newctndetail = new MsOpCtnDetail(); newctndetail.GID = System.Guid.NewGuid().ToString(); newctndetail.CTN_ID = _ctn_id; newctndetail.KINDPKGS = billmanage_ctndetail.KINDPKGS; newctndetail.PKGS = billmanage_ctndetail.PKGS; newctndetail.KGS = billmanage_ctndetail.KGS; newctndetail.CBM = billmanage_ctndetail.CBM; newctndetail.CNTRNO = billmanage_ctndetail.CNTRNO; newctndetail.HSCODE = billmanage_ctndetail.HSCODE; newctndetail.DbOperationType = DbOperationType.DbotIns; CTNDetailList.Add(newctndetail); } } } else { //SI中的该业务没有多品名 } //按CTN_ID合计计算各个提单信息内的集装箱信息 if (billManage_CTNDetailList.Count > 0) { foreach (var ctndetail in billManage_CTNDetailList) { foreach (var ctn in billManage_CTNList) if (ctndetail.CTN_ID == ctn.CTN_ID) { ctn.PKGS = 0; ctn.KGS = 0; ctn.CBM = 0; ctn.DbOperationType = DbOperationType.DbotUpd; } } } if (billManage_CTNDetailList.Count > 0) { foreach (var ctn in billManage_CTNList) { foreach (var ctndetail in billManage_CTNDetailList) { if (ctndetail.CTN_ID == ctn.CTN_ID) { ctn.PKGS += ctndetail.PKGS; ctn.KGS += ctndetail.KGS; ctn.CBM += ctndetail.CBM; } } } } //按CNTRNO合计计算主业务下 各个集装箱的信息 foreach (var ctn in Main_CTNList) { ctn.PKGS = 0; ctn.KGS = 0; ctn.CBM = 0; } foreach (var bill_ctn in billManage_CTNList) { foreach (var ctn in Main_CTNList) { if (ctn.CNTRNO == bill_ctn.CNTRNO) { ctn.PKGS += bill_ctn.PKGS; ctn.KGS += bill_ctn.KGS; ctn.CBM += bill_ctn.CBM; } } } //保存各个提单信息内的集装箱信息 result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(billManage_CTNList)); if (!result.Success) { return result; } ////保存主业务下的多品名信息 //result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(CTNDetailList)); //if (!result.Success) //{ // return result; //} } //如对应的不是一条提单信息 而是一对一的业务 else { Main_BSNO = BSNO; //查询所有主业务下的多品名信息//查询所有主业务下的集装箱信息 Main_CTNList = MsOpSeaeDAL.GetBodyList(" BSNO='" + Main_BSNO + "' "); CTNDetailList = MsOpSeaeDAL.GetOpCtnDetailList(" CTN_ID in(select CTN_ID from op_ctn where BSNO='" + Main_BSNO + "') "); //如果有多品名 则根据CTN_ID合计主业务的集装箱信息 if (CTNDetailList.Count > 0) { foreach (var ctn in Main_CTNList) foreach (var ctndetail in CTNDetailList) if(ctn.CTN_ID == ctndetail.CTN_ID) { ctn.PKGS = 0; ctn.KGS = 0; ctn.CBM = 0; } } if (CTNDetailList.Count > 0) { foreach (var ctn in Main_CTNList) { foreach (var ctndetail in CTNDetailList) { if (ctn.CTN_ID == ctndetail.CTN_ID) { ctn.PKGS += ctndetail.PKGS; ctn.KGS += ctndetail.KGS; ctn.CBM += ctndetail.CBM; } } } } } result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(Main_CTNList)); if (!result.Success) { return result; } result = detailmodb.Save(ModelObjectConvert.ToModelObjectList(CTNDetailList)); if (!result.Success) { return result; } SetSeaeMainCount(Main_BSNO); return result; } private static void SetSeaeMainCount(string BSNO) { var str = string.Format(" update op_seae set pkgs = (select sum(isnull(pkgs, 0)) from op_ctn where bsno = op_seae.bsno),kgs = (select sum(isnull(kgs, 0)) from op_ctn where bsno = op_seae.bsno) ,CBM = (select sum(isnull(cbm, 0)) from op_ctn where bsno = op_seae.bsno) where bsno = '{0}'", BSNO); BasicDataRefDAL.ExecSql(str); var str2 = string.Format(" update op_seae_billmanage set pkgs = (select sum(isnull(pkgs, 0)) from op_ctn where bsno = op_seae_billmanage.AS_ID),kgs = (select sum(isnull(kgs, 0)) from op_ctn where bsno = op_seae_billmanage.AS_ID) ,CBM = (select sum(isnull(cbm, 0)) from op_ctn where bsno = op_seae_billmanage.AS_ID) where BSNO = '{0}'", BSNO); BasicDataRefDAL.ExecSql(str2); } /// /// 检查主业务下的集装箱信息是否有不存在于对应的Booking.OP_SEAE_SI当中的 /// /// /// public ContentResult CheckDiff_Main(string SINO) { var result = new DBResult(false, "", null); var jsonRespose = new JsonResponse(result); //booking端的 SI下的 CTN数据 var booking_ctnlist_main_data = BookingConfirmDAL.GetCtnList(" ORDNO in(select SINO from op_seae_SI where ORDNO=(select ORDNO from op_seae_SI where SINO='" + SINO + "'))", ""); var booking_ctnlist_main_DicList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(booking_ctnlist_main_data)); var BSNO = booking_ctnlist_main_DicList[0]["BSNO_PARENT"]; var CtnCondition = " BSNO ='"+ BSNO + "' "; var CtnList = MsOpSeaeDAL.GetBodyList(CtnCondition); foreach (var localctn in CtnList) { var ismore = true; foreach (var BookingCtnDic in booking_ctnlist_main_DicList) { if (localctn.CNTRNO == BookingCtnDic["CNTRNO"]) { ismore = false; break; } } if (ismore) { result.Success = true; result.Message += localctn.CNTRNO+" "; } } jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DelDiff_Main(string SINO) { var result = new DBResult(false, "", null); var jsonRespose = new JsonResponse(result); //booking端的 SI下的 CTN数据 var booking_ctnlist_main_data = BookingConfirmDAL.GetCtnList(" ORDNO in(select SINO from op_seae_SI where ORDNO=(select ORDNO from op_seae_SI where SINO='" + SINO + "'))", ""); var booking_ctnlist_main_DicList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(booking_ctnlist_main_data)); var BSNO = booking_ctnlist_main_DicList[0]["BSNO_PARENT"]; var CtnCondition = " BSNO ='" + BSNO + "' "; var CtnList = MsOpSeaeDAL.GetBodyList(CtnCondition); var cntrlist = ""; foreach (var BookingCtnDic in booking_ctnlist_main_DicList) { if (cntrlist != "") cntrlist += ","; cntrlist +="'"+ BookingCtnDic["CNTRNO"]+ "'"; } var str = string.Format(" delete from op_ctn where {0} and CNTRNO not in({1})", CtnCondition, cntrlist); BasicDataRefDAL.ExecSql(str); jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 检查 提单信息 下的集装箱信息是否有不存在于对应的Booking.OP_SEAE_SI当中的 /// /// /// public ContentResult CheckDiff_Bill(string SINO) { var result = new DBResult(false, "", null); var jsonRespose = new JsonResponse(result); //booking端的 SI下的 CTN数据 var booking_ctnlist_main_data = BookingConfirmDAL.GetCtnList(" ORDNO ='" + SINO + "'", ""); var booking_ctnlist_main_DicList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(booking_ctnlist_main_data)); var BSNO = booking_ctnlist_main_DicList[0]["BSNO_PARENT"]; var MBLNO = booking_ctnlist_main_DicList[0]["SI_MBLNO"]; var CtnCondition = " BSNO in(select AS_ID from op_seae_billmanage where BSNO='" + BSNO + "' and MBLNO='"+ MBLNO + "') "; var CtnList = MsOpSeaeDAL.GetBodyList(CtnCondition); foreach (var localctn in CtnList) { var ismore = true; foreach (var BookingCtnDic in booking_ctnlist_main_DicList) { if (localctn.CNTRNO == BookingCtnDic["CNTRNO"]) { ismore = false; break; } } if (ismore) { result.Success = true; result.Message += localctn.CNTRNO + " "; } } if (result.Success) { jsonRespose.SetDBResult(result); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else{ return CheckDiff_Main(SINO); } } public ContentResult DelDiff_Bill(string SINO) { var result = new DBResult(false, "", null); var jsonRespose = new JsonResponse(result); //booking端的 SI下的 CTN数据 var booking_ctnlist_main_data = BookingConfirmDAL.GetCtnList(" ORDNO ='" + SINO + "'", ""); var booking_ctnlist_main_DicList = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(booking_ctnlist_main_data)); var BSNO = booking_ctnlist_main_DicList[0]["BSNO_PARENT"]; var MBLNO = booking_ctnlist_main_DicList[0]["SI_MBLNO"]; var CtnCondition = " BSNO in(select AS_ID from op_seae_billmanage where BSNO='" + BSNO + "' and MBLNO='" + MBLNO + "') "; var CtnList = MsOpSeaeDAL.GetBodyList(CtnCondition); var cntrlist = ""; foreach (var BookingCtnDic in booking_ctnlist_main_DicList) { if (cntrlist != "") cntrlist += ","; cntrlist += "'" + BookingCtnDic["CNTRNO"] + "'"; } var str = string.Format(" delete from op_ctn where {0} and CNTRNO not in({1})", CtnCondition, cntrlist); BasicDataRefDAL.ExecSql(str); //jsonRespose.SetDBResult(result); //return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; return DelDiff_Main(SINO); } public static string ToDBC(string input) { char[] c = input.ToCharArray(); for (int i = 0; i < c.Length; i++) { if (c[i] == 12288) { c[i] = (char)32; continue; } if (c[i] > 65280 && c[i] < 65375) c[i] = (char)(c[i] - 65248); } return new string(c); } public static string DelEndSpace(string input) { if (input == "") return ""; input = input.Replace("\n", "\\"); input = input.Replace("\r", " "); string[] StrList = input.Split('\\'); var result = ""; for (var i = 0; i <= StrList.Length - 1; i++) { var tmpstr = StrList[i].TrimEnd(); if (tmpstr != "") { if (result == "") result = tmpstr; else result = result + Environment.NewLine + tmpstr; } } return result; } #region 全角空格转半角空格 public static string FullWidthToHalfWidth(string str) { byte[] t = Encoding.Default.GetBytes(str); for (int i = 0; i < t.Length; i++) { if ((t[i].ToString() == "161") && (t[i + 1].ToString() == "161")) { t[i] = 32; if (i + 1 == t.Length - 1) { t[i + 1] = 0; } else { for (int j = i + 1; j + 1 < t.Length; j++) { t[j] = t[j + 1]; if (j + 1 == t.Length - 1) { t[j + 1] = 0; } } } } } return Encoding.Default.GetString(t); } #endregion #endregion #endregion #region 集装箱明细信息 public ContentResult GetBookingCtnList(string condition, string sort = "") { var dataList = BookingConfirmDAL.GetCtnList(condition, sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count(), data = list_2.ToList() }); return new ContentResult() { Content = json }; } #endregion #region 集装箱 内 明细信息 public ContentResult GetBookingCtnDetailList(string condition, string sort = "") { var dataList = BookingConfirmDAL.GetCtnDetailList(condition, Convert.ToString(Session["USERID"]), sort); var list_2 = ModelObjectBill.getDicList(ModelObjectConvert.ToModelObjectList(dataList)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count(), data = list_2.ToList() }); return new ContentResult() { Content = json }; } #endregion } }