using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.Common; using System.Data.Entity.Migrations; using System.Diagnostics; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; using DSWeb.Areas.CommMng.Models; using DSWeb.Areas.MvcShipping.DB; using DSWeb.Areas.MvcShipping.Models.Message.VGM; using DSWeb.Common.DB; using DSWeb.Common.Helper; using DSWeb.Dispatch.DAL; using DSWeb.EntityDA; using DSWeb.MvcShipping.Models.MsOpSeae; using DSWeb.TruckMng.Comm.Cookie; using HcUtility.Comm; using java.nio.file; using Microsoft.Practices.EnterpriseLibrary.Data; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace DSWeb.Areas.CommMng.DAL { public class PubSysDAL { public static List GetEnumValueList(decimal enumTypeId) { return GetEnumValueList(enumTypeId, String.Empty); } public static List GetEnumValueList(decimal enumTypeId, string sCondition) { var strSql = new StringBuilder(); strSql.Append("Select LangId,EnumTypeId,EnumValueId,EnumValueName,EnumValueName_2,IsDefault,DispIndex,VerNo "); strSql.Append(" from tSysEnumValue "); strSql.Append(" where EnumTypeId=" + enumTypeId); if (sCondition != String.Empty) { strSql.Append(" and " + sCondition); } strSql.Append(" order by EnumTypeID,dispindex,EnumValueID"); Database db = DatabaseFactory.CreateDatabase(); var evList = new List(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = new Models.SysEnumValue(); evData.LangId = Convert.ToDecimal(reader["LangId"]); evData.EnumTypeId = Convert.ToDecimal(reader["EnumTypeId"]); evData.EnumValueId = Convert.ToString(reader["EnumValueId"]); evData.EnumValueName = Convert.ToString(reader["EnumValueName"]); evData.EnumValueName_2 = Convert.ToString(reader["EnumValueName_2"]); evData.IsDefault = Convert.ToString(reader["IsDefault"]); evData.DispIndex = Convert.ToDecimal(reader["DispIndex"]); evData.VerNo = Convert.ToString(reader["VerNo"]); evData.EnumValueAndName = evData.EnumValueId + "-" + evData.EnumValueName; evList.Add(evData); } reader.Close(); } var evDatanew = new Models.SysEnumValue(); evDatanew.LangId =100; evDatanew.EnumTypeId =100; evDatanew.EnumValueId =""; evDatanew.EnumValueName =""; evDatanew.EnumValueName_2 =""; evDatanew.IsDefault =""; evDatanew.DispIndex =100; evDatanew.VerNo =""; evDatanew.EnumValueAndName =""; evList.Add(evDatanew); return evList; } public static string GetBillNo(string billType) { var cookies = new Cookies(); var orgCode = cookies.getCookie(CookieConstant.OrgCode);//登录组织 Database db = DatabaseFactory.CreateDatabase(); var cmd = db.GetStoredProcCommand("sSysGetBillNo"); db.AddInParameter(cmd, "@ps_BillType", DbType.String, billType); db.AddInParameter(cmd, "@ps_OrgCode", DbType.String, orgCode); db.AddOutParameter(cmd, "@ps_BillNo", DbType.String, 20); db.AddInParameter(cmd, "@ps_RefBillNo", DbType.String, null); db.ExecuteNonQuery(cmd); return Convert.ToString(db.GetParameterValue(cmd, "@ps_BillNo")); } public static DBResult Account(string billno, string ywtype, string userId, string userCode, string userName) { Database db = DatabaseFactory.CreateDatabase(); var cmd = db.GetStoredProcCommand("sMsSysAccount"); db.AddInParameter(cmd, "@ps_BillNo", DbType.String, billno); db.AddInParameter(cmd, "@ps_YwType", DbType.String, ywtype); db.AddInParameter(cmd, "@ps_UserId", DbType.String, userId); db.AddInParameter(cmd, "@ps_UserCode", DbType.String, userCode); db.AddInParameter(cmd, "@ps_UserName", DbType.String, userName); db.AddOutParameter(cmd, "@pi_Result", DbType.Int32, 20); db.AddOutParameter(cmd, "@ps_Message", DbType.String, 2000); db.ExecuteNonQuery(cmd); var result = new DBResult(); result.Success = Convert.ToInt32(db.GetParameterValue(cmd, "@pi_Result")) == 1; result.Message = Convert.ToString(db.GetParameterValue(cmd, "@ps_Message")); return result; } #region 调用存储过程返回数据集 /// /// 根据存储过程返回DataSet /// /// 存储过程名称 /// 参数列表(不包含存储过程的返回游标) /// 存储过程的返回游标名称列表 /// DataSet public static DBDataSetResult GetMsSqlPrcDataSet(string prcName, List dbparams, List curnames) { var dbrptResult = new DBDataSetResult(); dbrptResult.Success = false; Debug.Assert(curnames != null, "参数curnames不能为空"); if (curnames.Count == 0) { dbrptResult.Message = "参数curnames长度不能为0"; } int iResult = -1; string sMessage = String.Empty; var dataSet = new DataSet(); var ConnectionStringLocalTransaction = ""; var connectstr = ConfigurationManager.ConnectionStrings["DongShengRpt"]; if (connectstr != null) ConnectionStringLocalTransaction = ConfigurationManager.ConnectionStrings["DongShengRpt"].ConnectionString; Database db = DatabaseFactory.CreateDatabase(); if (!string.IsNullOrEmpty(ConnectionStringLocalTransaction)) db = DatabaseFactory.CreateDatabase("DongShengRpt"); using (IDbConnection idbconn = db.CreateConnection()) { using (DbCommand cmd = db.GetStoredProcCommand(prcName)) { cmd.CommandTimeout = 1200000; //要加这一句 idbconn.Open(); try { IDbTransaction idbtran = idbconn.BeginTransaction(); try { cmd.Transaction = (DbTransaction)idbtran; foreach (DbParameter param in dbparams) { switch (param.Direction) { case ParameterDirection.Input: db.AddInParameter(cmd, param.ParameterName, param.DbType, param.Value); break; case ParameterDirection.Output: db.AddOutParameter(cmd, param.ParameterName, param.DbType, param.Size); break; case ParameterDirection.InputOutput: case ParameterDirection.ReturnValue: db.AddParameter(cmd, param.ParameterName, param.DbType, param.Direction, param.SourceColumn, DataRowVersion.Default, param.Value); break; } } db.AddOutParameter(cmd, "@pi_result", DbType.Int32, 32); db.AddOutParameter(cmd, "@ps_Message", DbType.String, 2000); db.LoadDataSet(cmd, dataSet, curnames.ToArray(), (DbTransaction)idbtran); iResult = Convert.ToInt32(db.GetParameterValue(cmd, "@pi_Result")); sMessage = Convert.ToString(db.GetParameterValue(cmd, "@ps_Message")); idbtran.Commit(); } catch (Exception e) { idbtran.Rollback(); iResult = -1; // Convert.ToInt32(db.GetParameterValue(cmd, "pi_Result")); sMessage = e.Message;//sMessage = Convert.ToString(db.GetParameterValue(cmd, "ps_Message")); } } finally { idbconn.Close(); } } } if (iResult == 1) { dbrptResult.Success = true; dbrptResult.Message = "查询成功!"; dbrptResult.DataSet = dataSet; } else { dbrptResult.Success = false; dbrptResult.Message = "查询失败:" + sMessage; dbrptResult.Success = false; } return dbrptResult; } /// /// 根据存储过程返回DataTable /// /// 存储过程名称 /// 参数列表(不包含存储过程的返回游标) /// DataSet public static DBDataSetResult GetMsSqlPrcDataSet(string prcName, List dbparams, string curName) { var curnames = new List(); curnames.Add(curName); return GetMsSqlPrcDataSet(prcName, dbparams, curnames); } #endregion public static string getGuid() { Guid guid = Guid.NewGuid(); return guid.ToString().Replace("-", "").ToUpper(); } #region 直接执行sql命令 static public int ExecSql ( string StrSql ) { Database db = DatabaseFactory.CreateDatabase(); var _count = db.ExecuteNonQuery(CommandType.Text, StrSql); return _count; } #endregion } public class MqWorkDAL { private static List DoingIDList { get; set; } = new List(); private static bool InWorking(long DJYID) { if (DoingIDList.Exists(x => x == DJYID)) { return true; } else { DoingIDList.Add(DJYID); return false; } } private static void WorkingDone(long DJYID) { if (DoingIDList.Exists(x => x == DJYID)) { DoingIDList.RemoveAll(s => s == DJYID); } } public static void DingCangToDS7(string strBody) { try { var jarr = JArray.Parse(strBody); var itemstr = ""; var cdc = new CommonDataContext(); var dolist = new List(); foreach (var item in jarr) { var obj = item as JObject; itemstr = item.ToString(); //var head = JsonConvert.DeserializeObject(itemstr); //ThreadSaveDS6_Single SaveThread = new ThreadSaveDS6_Single(); //有参调用实例方法,ParameterizedThreadStart是一个委托,input为object,返回值为void //Thread thread1 = new Thread(new ParameterizedThreadStart(SaveThread.FuncSend)); //thread1.Start(itemstr); Task.Run(() => { Do_DingCangToDS7(itemstr); }); //Do_DingCangToDS6(itemstr); } //注释部分 为每消息队列文本包 起一个线程 //ThreadSaveDS6_List SaveThread = new ThreadSaveDS6_List(); ////有参调用实例方法,ParameterizedThreadStart是一个委托,input为object,返回值为void //Thread thread1 = new Thread(new ParameterizedThreadStart(SaveThread.FuncSend)); //thread1.Start(dolist); } catch (Exception e) { //var errorobjstr = JsonConvert.SerializeObject(e); //logger.Error($"导入出错:{e}//{errorobjstr}"); } } public static void Do_DingCangToDS7(string itemstr, int count = 0) { //LoggerHelper loggerHelper = new LoggerHelper("接收大简云订舱"); if (count > 3) { //loggerHelper.Save($"重试完结"); return; } //BasicDataRefDAL.SaveLog(itemstr, "", "接收大简云订舱", "接收"); var head = JsonConvert.DeserializeObject(itemstr); var cdc = new CommonDataContext(); try { if (InWorking(head.Id)) { Task.Run(() => { Do_DingCangToDS7(itemstr); }); return; } var newhead = head.GetOpseae(); var OPUser = new VW_user_md(); var OPUserList = cdc.VW_user.Where(x => x.SHOWNAME == head.op).ToList(); if (OPUserList != null && OPUserList.Count > 0) { OPUser = OPUserList[0]; } var currentBill = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.GetData($" (B.DJYID={head.Id} or B.BSNO='{head.bsno}')", OPUser.USERID); if (currentBill != null && !string.IsNullOrWhiteSpace( currentBill.BSNO) && currentBill.BSNO== head.bsno) { //更新业务 var updrec = currentBill; if (currentBill.BSSTATUS == true) { //业务锁定 不做任何操作 return; } var headid = updrec.BSNO; newhead.BSNO = updrec.BSNO; newhead.MASTERNO = updrec.MASTERNO; //newhead.INPUTBY = updrec.INPUTBY; //newhead.INPUTBY = updrec.INPUTBY; //var ctnlist = head.GetCtnList(updrec.BSNO); //20240320 彩虹保存业务变动 //根据一个标记SyncType 的值 判断同步哪些字段 head.SetField(ref updrec); var _r = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.DoSave( "edit", updrec, null, OPUser.USERID, OPUser.SHOWNAME, OPUser.COMPANYID, OPUser.companyname); } else { BasicDataRefDAL.SaveLog(itemstr, "", "接收大简云订舱", "未找到BSNO"); //新增业务 //var ctnlist = head.GetCtnList("*"); //newhead.BSNO = "topseae" + Guid.NewGuid().ToString(); //var _r = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.DoSave( // "add", // newhead, // ctnlist, // OPUser.USERID, // OPUser.SHOWNAME, // OPUser.COMPANYID, // OPUser.companyname); WorkingDone(head.Id); return; } //20240403 保存完成后 保存附件信息 //根据url判断是否重复 var 附件List = cdc.Receipt_Doc.Where(x => x.BSNO == newhead.BSNO).ToList(); var newlist = new List(); foreach (var file in head.Files) { if (!附件List.Exists(x => x.Driect_URL == file.FilePath)) { var newrec = new Receipt_Doc_md(newhead.BSNO); newrec.RECEIPTTYPE = file.FileType; newrec.URL = file.FileName; newrec.Driect_URL = file.FilePath; newrec.MODIFIEDUSER = "1BEC90E1-9780-472F-90C2-0C6390C044A4"; newrec.MODIFIEDTIME = DateTime.Now; //在同一包中也判断地址是否重复 if (newlist.Exists(x => x.Driect_URL == newrec.Driect_URL)) { continue; } newlist.Add(newrec); cdc.Receipt_Doc.Add(newrec); cdc.SaveChanges(); } else { //已有此url的不做任何处理 } } } catch (Exception e) { BasicDataRefDAL.SaveLog(e.Message, "", "接收大简云订舱", "错误"); count++; Do_DingCangToDS7(itemstr, count); } finally { WorkingDone(head.Id); } } private static List DoingBSNOList { get; set; } = new List(); private static bool InWorking_CustOrderStatus(string BSNO) { if (DoingBSNOList.Exists(x => x == BSNO)) { return true; } else { DoingBSNOList.Add(BSNO); return false; } } private static void WorkingDone_CustOrderStatus(string BSNO) { if (DoingBSNOList.Exists(x => x == BSNO)) { DoingBSNOList.RemoveAll(s => s == BSNO); } } public static void CustOrderStatusToDS7(string strBody) { try { //itemstr = item.ToString(); //var head = JsonConvert.DeserializeObject(itemstr); //ThreadSaveDS6_Single SaveThread = new ThreadSaveDS6_Single(); //有参调用实例方法,ParameterizedThreadStart是一个委托,input为object,返回值为void //Thread thread1 = new Thread(new ParameterizedThreadStart(SaveThread.FuncSend)); //thread1.Start(itemstr); Task.Run(() => { Do_CustOrderStatusToDS7(strBody); }); //Do_DingCangToDS6(itemstr); } catch (Exception e) { var errorobjstr = JsonConvert.SerializeObject(e); BasicDataRefDAL.SaveLog($"导入出错:{e}//{errorobjstr}","","大简云订舱审批","错误"); } } public static void Do_CustOrderStatusToDS7(string itemstr, int count = 0) { //LoggerHelper loggerHelper = new LoggerHelper("接收大简云订舱"); //if (count > 3) //{ // //loggerHelper.Save($"重试完结"); // return; //} var headinfo = JsonConvert.DeserializeObject(itemstr); if (InWorking_CustOrderStatus(headinfo.Data.BSNO)) { Task.Run(() => { Do_DingCangToDS7(itemstr); }); return; } var cdc = new CommonDataContext(); try { if (headinfo.is通过()) { //var head = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.GetData($"BSNO='{headinfo.Data.BSNO}'"); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdDeletectn = db.GetSqlStringCommand($" update op_Seae set djyid={headinfo.Data.BookingOrderId} where BSNO='{headinfo.Data.BSNO}' "); db.ExecuteNonQuery(cmdDeletectn, tran); tran.Commit(); BasicDataRefDAL.SaveLogicInfo(headinfo.Data.BSNO, "大简云订舱审批", "审批通过", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } catch (Exception e) { tran.Rollback(); BasicDataRefDAL.SaveLog(itemstr + ":" + e.Message, "", "大简云订舱审批", "审批通过"); //return result; } } } if (headinfo.is驳回()) { Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); //var tran = conn.BeginTransaction(); try { //var cmdDeletectn = db.GetSqlStringCommand($" update op_Seae set djyid={headinfo.Data.BookingOrderId} where BSNO='{headinfo.Data.BSNO}' "); //db.ExecuteNonQuery(cmdDeletectn, tran); var dic = new Dictionary { {"审批驳回", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, {"驳回理由", headinfo.Data.COMMENT } }; BasicDataRefDAL.SaveLogicInfo(headinfo.Data.BSNO, "大简云订舱审批", dic); } catch (Exception e) { BasicDataRefDAL.SaveLog(itemstr + ":" + e.Message, "", "大简云订舱审批", "审批驳回"); //tran.Rollback(); //return result; } } } } catch (Exception e) { BasicDataRefDAL.SaveLog(e.Message, "", "接收大简云订舱", "错误"); count++; Do_DingCangToDS7(itemstr, count); } finally { WorkingDone_CustOrderStatus(headinfo.Data.BSNO); } } #region 大简云订舱数据解析类 public class DingCangHead { public long Id { get; set; } public string bsno { get; set; } //"string", public string bsstatus { get; set; } //"string", public string bsstatusname { get; set; } //"string", public DateTime? bsdate { get; set; } //"2023-03-30T03:12:51.033Z", public string mblno { get; set; } //"string", public string tmblno { get; set; } //"string", public string hblno { get; set; } //"string", public string bookingno { get; set; } //"string", public string contractno { get; set; } //"string", public string servicecontractno { get; set; } //"string", public string shipperid { get; set; } //"string", public string consigneeid { get; set; } //"string", public string notifypartyid { get; set; } //"string", public string shipper { get; set; } //"string", public string consignee { get; set; } //"string", public string notifyparty { get; set; } //"string", public string notifypartY2 { get; set; } //"string", public string foreignAgent { get; set; } //"string", public string yardid { get; set; } //"string", public string yard { get; set; } //"string", public string vesselid { get; set; } //"string", public string vessel { get; set; } //"string", public string voyno { get; set; } //"string", public string voynoinner { get; set; } //"string", public DateTime? etd { get; set; } //"2023-03-30T03:12:51.033Z", /// /// 云港通ETD(爬取的ETD) 写入 /// public DateTime? YgtETD { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? atd { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closingdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closedocdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closevgmdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? eta { get; set; } //"2023-03-30T03:12:51.033Z", public string placereceiptid { get; set; } //"string", public string placereceipt { get; set; } //"string", public string portloadid { get; set; } //"string", public string portload { get; set; } //"string", public string portdischargeid { get; set; } //"string", public string portdischarge { get; set; } //"string", public string placedeliveryid { get; set; } //"string", public string placedelivery { get; set; } //"string", public string destinationid { get; set; } //"string", public string destination { get; set; } //"string", public string nobill { get; set; } //"string", public string copynobill { get; set; } //"string", public string issuetype { get; set; } //"string", public DateTime? issuedate { get; set; } //"2023-03-30T03:12:51.033Z", public string issueplaceid { get; set; } //"string", public string issueplace { get; set; } //"string", public string blfrt { get; set; } //"string", public string prepardat { get; set; } //"string", public string payableat { get; set; } //"string", public string service { get; set; } //"string", public string marks { get; set; } //"string", public string hscode { get; set; } //"string", public string description { get; set; } //"string", public int? pkgs { get; set; } = 0; public string kindpkgs { get; set; } //"string", public decimal? kgs { get; set; } = 0; public decimal? cbm { get; set; } = 0; public string totalno { get; set; } //"string", public string cntrtotal { get; set; } //"string", public string carrierid { get; set; } //"string", public string carrier { get; set; } //"string", public string cargoid { get; set; } //"string", public string dclass { get; set; } //"string", public string dunno { get; set; } //"string", public string dpage { get; set; } //"string", public string dlabel { get; set; } //"string", public string linkman { get; set; } //"string", public string tempid { get; set; } //"string", public string tempset { get; set; } //"string", public string reeferf { get; set; } //"string", public string humidity { get; set; } //"string", public string tempmin { get; set; } //"string", public string tempmax { get; set; } //"string", public bool? iscontainersoc { get; set; } //true, public string soremark { get; set; } //"订舱备注", public string siremark { get; set; } //"截单备注", public string yardremark { get; set; } //"string", public string compid { get; set; } //"string", public string compname { get; set; } //"string", public string shippername { get; set; } //"string", public string shipperaddR1 { get; set; } //"string", public string shipperaddR2 { get; set; } //"string", public string shipperaddR3 { get; set; } //"string", public string shippercity { get; set; } //"string", public string shipperprovince { get; set; } //"string", public string shipperpostcode { get; set; } //"string", public string shippercountry { get; set; } //"string", public string shipperattn { get; set; } //"string", public string shippertel { get; set; } //"string", public string consigneename { get; set; } //"string", public string consigneeaddR1 { get; set; } //"string", public string consigneeaddR2 { get; set; } //"string", public string consigneeaddR3 { get; set; } //"string", public string consigneecity { get; set; } //"string", public string consigneeprovince { get; set; } //"string", public string consigneepostcode { get; set; } //"string", public string consigneercountry { get; set; } //"string", public string consigneeattn { get; set; } //"string", public string consigneetel { get; set; } //"string", public string notifypartyname { get; set; } //"string", public string notifypartyaddR1 { get; set; } //"string", public string notifypartyaddR2 { get; set; } //"string", public string notifypartyaddR3 { get; set; } //"string", public string notifypartycity { get; set; } //"string", public string notifypartyprovince { get; set; } //"string", public string notifypartypostcode { get; set; } //"string", public string notifypartycountry { get; set; } //"string", public string notifypartyattn { get; set; } //"string", public string notifypartytel { get; set; } //"string", public string pono { get; set; } //"string", public string opid { get; set; } //"string", public string docid { get; set; } //"string", public string op { get; set; } //"string", public string doc { get; set; } //"string", public string saleid { get; set; } //"string", public string sale { get; set; } //"string", public string custserviceid { get; set; } //"string", public string custservice { get; set; } //"string", public string customername { get; set; } //"string", public string thirdPay { get; set; } //"第三方 第三方付费", public string forwarder { get; set; } //"string", public string shipagency { get; set; } //"string", public string customser { get; set; } //"string", public string trucker { get; set; } //"string", public string agentid { get; set; } //"string", public long? customerid { get; set; } //= 0; public string forwarderid { get; set; } //"string", public string shipagencyid { get; set; } //"string", public string customserid { get; set; } //"string", public string truckerid { get; set; } //"string", public string agentname { get; set; } //"string", public string weituo { get; set; } //"string", public string consigneedooraddr { get; set; } //"string", public string shipperdooraddr { get; set; } //"string", public string scaccode { get; set; } //"string", public string itncode { get; set; } //"string", public string prepardatid { get; set; } //"string", public string payableatid { get; set; } //"string", public string custno { get; set; } //"string", CC号 public string transportid { get; set; } //"string", public string transport { get; set; } //"string", public string thirdpayaddr { get; set; } //"string", public string yardcontract { get; set; } //"string", public string yardcontracttel { get; set; } //"string", public string yardcontractemail { get; set; } //"string", public bool? feeself { get; set; } //true, public string lanecode { get; set; } //"string", public string lanename { get; set; } //"string", public string freightpayer { get; set; } //"string", public string goodscode { get; set; } //"string", public string goodsname { get; set; } //"string", public string pkgstotal { get; set; } //"string", public string kgstotal { get; set; } //"string", public string cbmtotal { get; set; } //"string", public string routeid { get; set; } //"string", public string route { get; set; } //"string", public string warehouse { get; set; } //"string", public string warehouseID { get; set; } //"string", public string epCode { get; set; } //"string", /// /// 用户自定义航线 /// public string lineName { get; set; } //"string", public string dzRemark { get; set; } //"string", public string czRemark { get; set; } //"string", public string createdUserName { get; set; } //"string", public string ZhanCangFlag { get; set; } = ""; //"string", public string SourceName { get; set; } = ""; //"string", //public string CtnDayNum { get; set; } = "";//箱使堆存 废弃 public string ShenQingXiangShi { get; set; } = "";//箱使堆存 public string VERSION { get; set; } = "";//版本号 内容为一个gid,用来记录数据是否为最新 public string LineManage { get; set; } = "";//航线管理 public string ShippingMethod { get; set; } = "";//装运方式 整箱/拼箱 /// /// 20240320增加 同步方式 /// bc:更新bc, /// public string SyncType { get; set; } public List ctnInputs { get; set; } public DingCangbookingEDIExt bookingEDIExt { get; set; } /// /// 原来使用DingCangTDXX /// public List childrens { get; set; } public List goodsStatus { get; set; } public DateTime StartDatetime { get; set; } public List Files { get; set; } class 箱型箱量item { public CODE_CTN_md 箱型 { get; set; } public int 箱量 { get; set; } = 0; public 箱型箱量item(CODE_CTN_md _箱型, int _箱量) { 箱型 = _箱型; 箱量 = _箱量; } } class 箱型箱量 { public List<箱型箱量item> 箱型箱量信息 { get; set; } public 箱型箱量() { var cdc = new CommonDataContext(); 箱型箱量信息 = new List<箱型箱量item>(); } public void Add(箱型箱量item newitem) { if (箱型箱量信息.Exists(x => x.箱型 == newitem.箱型)) { 箱型箱量信息.First(x => x.箱型 == newitem.箱型).箱量 += newitem.箱量; } else { 箱型箱量信息.Add(newitem); } } public string get集装箱() { var result = ""; foreach (var item in 箱型箱量信息) { if (result != "") result += " "; result += item.箱型.CTN + "*" + item.箱量.ToString(); } return result; } public string get计费标准() { var result = ""; foreach (var item in 箱型箱量信息) { if (result != "") result += "\r\n"; result += item.箱型.CTN + "*" + item.箱量.ToString() + "-" + item.箱型.CTN; } return result; } public string get箱数大写() { var result = "SAY: "; foreach (var item in 箱型箱量信息) { if (result != "SAY: ") result += " AND "; result += NumberToEnglishString(item.箱量).ToUpper() + " (" + item.箱型.CTN + "*" + item.箱量.ToString() + ")"; } result += " CONTAINER ONLY. "; return result; } public int getTeu() { var result = 0; foreach (var item in 箱型箱量信息) { if (item.箱型.CTNSIZE == "20") { result += 1 * item.箱量; } else { result += 2 * item.箱量; } } return result; } } public int get周次(DateTime? etd) { try { DateTime dateTime = new DateTime(((DateTime)etd).Year, 1, 1); TimeSpan ts1 = ((DateTime)etd).Subtract(dateTime).Duration(); var days = ts1.Days; var weeks = (int)(Math.Ceiling(days / 7.0)); return weeks; } catch (Exception e) { return 0; } } //记录品名 public MsOpSeae GetOpseae() { //var weeks = get周次(etd); //20230410 根据箱信息重新计算 集装箱 和 箱数大写 var cdc = new CommonDataContext(); var 箱型箱量 = new 箱型箱量(); var tcodectn = cdc.CODE_CTN.Where(x => 1 == 1).ToList(); if (ctnInputs != null) foreach (var ctn in ctnInputs) { var 箱型infoList = tcodectn.Where(x => (x.CTNSIZE + x.CTNTYPE) == ctn.ctnall || (x.CTNSIZE + "'" + x.CTNTYPE) == ctn.ctnall || x.CTN == ctn.ctnall).ToList(); var 箱型info = new CODE_CTN_md(); if (箱型infoList != null && 箱型infoList.Count > 0) { 箱型info = 箱型infoList[0]; } else { continue; } 箱型箱量.Add(new 箱型箱量item(箱型info, ctn.ctnnum == null ? 1 : (int)ctn.ctnnum)); } var 集装箱 = 箱型箱量.get集装箱(); var 箱数大写 = 箱型箱量.get箱数大写(); var 计费标准 = 箱型箱量.get计费标准(); //处理货名 //HS编码 = hscode, //货物名称 = bookingEDIExt.goodsName, //货物描述 = description, var 货物名称 = ""; //var 当前货名 = d6.t_code_goods.Where(x => x.代码 == goodscode).ToList(); //if (当前货名 == null || 当前货名.Count == 0) //{ // if(!string.IsNullOrWhiteSpace(goodscode)) { // var newrec = new t_code_goods_md(); // newrec.代码 = SetLength(goodscode, 10); // newrec.货物名称 = SetLength(goodsname, 100); // 货物名称 = newrec.货物名称; // newrec.货物描述 = SetLength(description, 600); // newrec.商品编码 = SetLength(hscode, 10); // d6.t_code_goods.Add(newrec); // d6.SaveChanges(); // } //} //else //{ // 货物名称 = 当前货名[0].货物名称; //} 货物名称 = dealGoodsinfo(goodscode, goodsname, description, hscode); var _etd = new DateTime(); var _eta = new DateTime(); if (etd != null) _etd = new DateTime(((DateTime)etd).Year, ((DateTime)etd).Month, ((DateTime)etd).Day); if (eta != null) _eta = new DateTime(((DateTime)etd).Year, ((DateTime)etd).Month, ((DateTime)etd).Day); var 操作 = op; var 操作部门名称 = ""; var 操作部门 = cdc.VW_user.FirstOrDefault(x => x.SHOWNAME == 操作); if (操作部门 != null) 操作部门名称 = 操作部门.DEPTNAME; var 销售 = sale; var 销售部门名称 = ""; var 销售部门 = cdc.VW_user.FirstOrDefault(x => x.SHOWNAME == 销售); if (销售部门 != null) 销售部门名称 = 销售部门.DEPTNAME; //carrier var 船公司 = carrier; var 船公司edi代码List = cdc.CodeCustEdi.Where(x => x.EDINAME == "大简云船公司" && x.EDICODE == carrier).ToList(); if (船公司edi代码List != null && 船公司edi代码List.Count > 0) { 船公司 = 船公司edi代码List[0].CUST; } var carrier_clientList = cdc.info_client.Where(x => x.SHORTNAME == 船公司).ToList(); if (carrier_clientList != null && carrier_clientList.Count > 0) { var carrier_client = carrier_clientList[0]; 船公司 = carrier_client.SHORTNAME; } //int? 申请箱使天数 = null; DateTime now = DateTime.Now; DateTime today2 = new DateTime(now.Year, now.Month, now.Day); var 装运方式 = "整箱"; if (!string.IsNullOrWhiteSpace(ShippingMethod)) { //if (船公司.IndexOf("拼箱") >= 0) //{ // 装运方式 = "拼箱"; //} 装运方式 = ShippingMethod; } var result = new MsOpSeae(); result = new MsOpSeae { BSNO = bsno, BSSTATUS = false, FEESTATUS = false, //会计期间 = SetDayZero(atd), //装运方式 = 装运方式, //周次 = weeks, //录入日期 = bsdate, //bsdate new DateTime(2070, 1, 1) ? DateTime.Now: bsdate, MBLNO = mblno, //真提单号 = tmblno, //主提单标准 = string.IsNullOrWhiteSpace( mblno)?, HBLNO = hblno, TRANSNO = custno,//20240320 CUSTNO(CC号)写入TRANSNO(运单号) CONTRACTNO = contractno, SHIPPER = 设置换行(shipper), CONSIGNEE = 设置换行(consignee), NOTIFYPARTY = 设置换行(notifyparty), YARD = yard, VESSEL = vessel, VOYNO = voynoinner, ETD = SetDayMinute_Str(YgtETD), //ETD = SetDayMinute_Str(YgtETD), ETA = SetDayZero_Str(eta), ATD = SetDayMinute_Str(atd), CLOSINGDATE = SetDayZero_Str(closingdate), PORTLOADID = portloadid, PORTLOAD = portload, PORTDISCHARGEID = portdischargeid, PORTDISCHARGE = portdischarge, PLACEDELIVERYID = placedeliveryid, PLACEDELIVERY = placedelivery, DESTINATIONID = destinationid, DESTINATION = destination, NOBILL = nobill, COPYNOBILL = copynobill, ISSUETYPE = issuetype, ISSUEDATE = issuedate == null ? "" : ((DateTime)issuedate).ToString("yyyy-MM-dd"), ISSUEPLACE = issueplace, BLFRT = blfrt, PREPARDAT = prepardat, PAYABLEAT = payableat, SERVICE = service, MARKS = 设置换行(marks), CUSTSERVICE = service, HSCODE = hscode, GOODSNAME = 货物名称, DESCRIPTION = 设置换行(description), PKGS = pkgs.ToString(), KINDPKGS = kindpkgs, KGS = kgs.ToString(), CBM = cbm.ToString(), TOTALNO = totalno, CNTRTOTAL = 集装箱,//cntrtotal,// //TOTALNO = 箱数大写, //计费标准 = 计费标准, CARRIER = 船公司,//carrier, CARGOID = cargoid, DCLASS = dclass, DUNNO = dunno, TEMPSET = tempset, REEFERF = reeferf, TEMPMIN = tempmin, TEMPMAX = tempmax, ISCONTAINERSOC = iscontainersoc == null ? false : (bool)iscontainersoc, //订舱备注 = 设置换行(soremark),//订舱备注 //分单列表 = 设置换行(soremark), //附加条款 = 设置换行(soremark), //全称= compname, //合同号 = pono, ORDERNO = pono, //合同号备注 = pono, FRCUSTSERVICE = custservice, OP = op, DOC = doc, SALE = sale, //航线操作 = route, CUSTOMERNAME = customername, //第三方付费 = thirdPay, CUSTOMSER = customser, TRUCKER = trucker, FORWARDER = forwarder,//大简云“订舱代理”,ds6界面的“订舱代理”,ds6数据库的货代 //备案号 = lanename, LANE = lineName, SHIPAGENCY = shipagency, AGENT = agentname,//大简云“国外代理”,ds6界面的“代理”,ds6数据库的代理 //其他备注 = 设置换行(dzRemark), //是否占舱 = ZhanCangFlag == "是" ? "Y" : "N", //占舱备注 = 设置换行(czRemark),//注意 CZREMARK 数据来源于 ds7上,点大简云订舱时,弹出窗口的“订舱要求”格;发送成功后记录在op_Logic表中,显示编辑页时单独查询并显示在“订舱要求”格中。因此回传时不做处理。 REMARK = 设置换行(dzRemark), INPUTBY = createdUserName, EDIREMARK = (bookingEDIExt == null) ? "" : 设置换行(bookingEDIExt.orderRemark), DJYID = Id, //通知到港 = null, //是否提货 = null, //是否提交VGM = null, //是否提交舱单 = null, //是否装载放行 = null, SOURCECODE = SourceName, //箱使堆存 = 设置换行(ShenQingXiangShi), //总价 = (bookingEDIExt == null) ? "" : bookingEDIExt.kingTareweight == null ? "" : bookingEDIExt.kingTareweight.ToString().Replace(".0", ""), //箱TEU = 箱型箱量.getTeu(), //箱型1 = 箱型箱量.get箱型1(), //箱型2 = 箱型箱量.get箱型2(), //箱型3 = 箱型箱量.get箱型3(), //箱型4 = 箱型箱量.get箱型4(), //箱型5 = 箱型箱量.get箱型5(), //箱型6 = 箱型箱量.get箱型6(), //箱型7 = 箱型箱量.get箱型7(), //箱型8 = 箱型箱量.get箱型8(), //箱型9 = 箱型箱量.get箱型9(), //箱型10 = 箱型箱量.get箱型10(), //辅助字段一 = 设置换行(bookingEDIExt == null ? "" : bookingEDIExt.exRemark1), //辅助字段二 = 设置换行(bookingEDIExt == null ? "" : bookingEDIExt.exRemark2), //辅助字段三 = 设置换行(bookingEDIExt == null ? "" : bookingEDIExt.exRemark3), //辅助字段四 = 设置换行(bookingEDIExt == null ? "" : bookingEDIExt.exRemark4), //操作部门 = 操作部门名称, SALEDEPT = 销售部门名称, //DJYVERSION = VERSION, //航线管理 = LineManage }; //if (goodsStatus != null) // foreach (var status in goodsStatus) // { // if (status.statusName == "通知到港") // { // if (status.finishTime != null) // result.通知到港 = true; // } // if (status.statusName == "是否提货") // { // if (status.finishTime != null) // result.是否提货 = true; // } // if (status.statusName == "提交VGM") // { // if (status.finishTime != null) // result.是否提交VGM = true; // } // if (status.statusName == "提交舱单") // { // if (status.finishTime != null) // result.是否提交舱单 = true; // } // if (status.statusName == "装载放行") // { // if (status.finishTime != null) // result.是否装载放行 = true; // } // } #region 设定字符串长度 超长的截断 //var lengthDic = new Dictionary //{ // {"业务状态",80}, // {"主提单号",20}, // {"分提单号",30}, // {"委托编号",20}, // {"装运方式",8}, // {"委托单位",20}, // {"发货人",20}, // {"收货人",20}, // {"通知人",20}, // {"发货人代码",1000}, // {"收货人代码",1000}, // {"通知人代码",1000}, // {"代理",20}, // {"代理内容",1000}, // {"场站",20}, // {"船名",60}, // {"航次",20}, // {"起运港",60}, // {"装货港",60}, // {"装港代码",10}, // {"卸货港",100}, // {"卸货代码",10}, // {"二程港口",60}, // {"二程船名",60}, // {"二程航次",20}, // {"目的地",30}, // {"交货地点",100}, // {"交货代码",10}, // {"提单份数",10}, // {"签单方式",50}, // {"签单地点",30}, // {"付费方式",60}, // {"预付地点",100}, // {"到付地点",100}, // {"运输条款",10}, // {"唛头",800}, // {"箱号封号",3000}, // {"件数包装",1000}, // {"货物描述",1400}, // {"货物名称",100}, // {"货物重量",1000}, // {"货物尺码",1000}, // {"包装",60}, // {"件数大写",100}, // {"箱数大写",100}, // {"集装箱",200}, // {"录入人",12}, // {"操作员",10}, // {"揽货人",10}, // {"客服员",10}, // {"航线",30}, // {"船公司",20}, // {"货代公司",20}, // {"备注",800}, // {"报关行",20}, // {"承运车队",20}, // {"分单列表",2000}, // {"计费标准",1000}, // {"报关员",10}, // {"报关单号",20}, // {"核销单号",50}, // {"手册号",20}, // {"经营单位",60}, // {"单位代码",20}, // {"合同号",50}, // {"合同号备注",50}, // {"报关备注",600}, // {"危险品分类",5}, // {"危险品编号",20}, // {"冷藏通风量",12}, // {"温度单位",1}, // {"设置温度",16}, // {"最低温度",5}, // {"最高温度",5}, // {"货物标识",1}, // {"发票号",20}, // {"商品编码",400}, // {"销售部门",30}, // {"操作部门",30}, // {"业务来源",8}, // {"英文船期",12}, // {"三程港口",60}, // {"三程船名",60}, // {"三程航次",20}, // {"辅助字段一",600}, // {"辅助字段二",600}, // {"辅助字段三",600}, // {"辅助字段四",600}, // {"解锁人",10}, // {"主提单标准",30}, // {"分提单标准",30}, // {"委托标准",30}, // {"财务凭证",30}, // {"附加条款",600}, // {"备案号",20}, // {"运抵国",60}, // {"境内货源地",60}, // {"批准文号",20}, // {"成交方式",20}, // {"单价",100}, // {"总价",100}, // {"商品名称",400}, // {"数量单位",400}, // {"报检单号",20}, // {"实验内容",100}, // {"报关操作",10}, // {"报检操作",10}, // {"币制",100}, // {"单证信息",100}, // {"核销标准",20}, // {"报关标准",20}, // {"报检标准",20}, // {"目的地代码",10}, // {"包装代码",10}, // {"发货人编号",10}, // {"运输方式",10}, // {"运费协议号",20}, // {"航线操作",10}, // //{"分票编号",12}, // //{"特殊要求",30}, // {"HS编码",30}, // {"船代",20}, // {"单证员",10}, // {"箱使堆存",30}, // {"EDI备注",2000}, // {"航线管理",20} //}; //foreach (var item in lengthDic) //{ // try // { // var property = result.GetType().GetProperty(item.Key); // if (property != null) // { // var _v = result.GetType().GetProperty(item.Key).GetValue(result); // if (_v != null) // { // var newvalue = SetLength(_v.ToString(), item.Value); // result.GetType().GetProperty(item.Key).SetValue(result, newvalue); // } // } // //var value = result.GetType().GetProperty(item.Key).GetValue(result).ToString(); // //var newvalue = SetLength(value, item.Value); // //result.GetType().GetProperty(item.Key).SetValue(result, newvalue); // } // catch (Exception e) // { // continue; // } //} #endregion return result; } public void SetField(ref MsOpSeae updrec) { if (SyncType == "BC") { //updrec.MBLNO = mblno == null ? "" : mblno; ////updrec.MBLNO = custno == null ? "" : custno; //updrec.EDI_TIME = closedocdate == null ? "" : ((DateTime)closedocdate).ToString("yyyy-MM-dd HH:mm:ss"); //updrec.VGM_TIME = closevgmdate == null ? "" : ((DateTime)closevgmdate).ToString("yyyy-MM-dd HH:mm:ss"); //updrec.VESSEL = vessel == null ? "" : vessel; //updrec.VOYNO = voyno == null ? "" : voyno; //updrec.ATD = etd == null ? "" : ((DateTime)etd).ToString("yyyy-MM-dd"); //updrec.CARRIER = carrierid == null ? "" : carrierid; //updrec.TRANSNO = custno == null ? "" : custno; //updrec.DJYID = Id; var saveinfo = new DJY_SYNC_BC_md(updrec.BSNO); saveinfo.MBLNO = mblno ; saveinfo.EDI_TIME = closedocdate ; saveinfo.VGM_TIME = closevgmdate ; saveinfo.VESSEL = vessel ; saveinfo.VOYNO = voyno ; saveinfo.ATD = etd ; saveinfo.CARRIER = carrierid ; saveinfo.TRANSNO = custno ; DJY_SYNC_BC_Helper.Add(saveinfo); BasicDataRefDAL.OP_STATUSHelper.MakeOpStatus("系统管理员", updrec.BSNO, "已出号","1"); } if (SyncType == "CC") { updrec.TRANSNO = custno == null ? "" : custno; //var saveinfo = new DJY_SYNC_BC_md(updrec.BSNO); //CC号同步 直接更新业务中的cc号 不通过“同步BC信息”的方式 //saveinfo.TRANSNO = custno; //DJY_SYNC_BC_Helper.Add(saveinfo); } } public List GetCtnList(string BSNO) { var result = new List(); if (ctnInputs != null) { var cdc = new CommonDataContext(); var CurrCtnList = new List(); if (BSNO != "*") { CurrCtnList = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.GetBodyList($" BSNO='{BSNO}'"); var djyctnids = ctnInputs.Select(x => x.id).ToList(); var 需删除Ctn = CurrCtnList.Where(x => !djyctnids.Contains(x.DJYCTNID)).ToList(); if (需删除Ctn != null && 需删除Ctn.Count > 0) { var delidstr = string.Join(",", 需删除Ctn.Select(s => s.DJYCTNID)); Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); var tran = conn.BeginTransaction(); try { var cmdDeletectn = db.GetSqlStringCommand(" delete from op_ctn where DJYCTNID in(" + delidstr + ") "); db.ExecuteNonQuery(cmdDeletectn, tran); } catch (Exception) { tran.Rollback(); //return result; } } } } foreach (var ctn in ctnInputs) { var 箱型infoList = cdc.CODE_CTN.Where(x => (x.CTNSIZE + "'" + x.CTNTYPE) == ctn.ctnall || (x.CTNSIZE + x.CTNTYPE) == ctn.ctnall || (x.CTNSIZE + "'" + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall || (x.CTNSIZE + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall ).ToList(); var 箱型info = new CODE_CTN_md(); if (箱型infoList != null && 箱型infoList.Count > 0) { 箱型info = 箱型infoList[0]; } else { continue; } var ctnbsno = BSNO; if (BSNO != "*" && !CurrCtnList.Exists(x => x.DJYCTNID == ctn.id)) { ctnbsno = BSNO; var updctn = CurrCtnList.FirstOrDefault(x => x.DJYCTNID == ctn.id); updctn.CTNCODE = 箱型info.CTNID; updctn.SIZE = 箱型info.CTNSIZE; updctn.CTN = 箱型info.CTN; updctn.BSNO = ctnbsno; updctn.CTNALL = ctn.ctnall; updctn.CTNNUM = ctn.ctnnum == null ? 0 : (int)ctn.ctnnum; updctn.CNTRNO = ctn.cntrno; updctn.SEALNO = ctn.sealno; updctn.PKGS = ctn.pkgs == null ? 0 : (int)ctn.pkgs; updctn.KINDPKGS = ctn.kindpkgs; updctn.KGS = ctn.kgs == null ? 0 : (decimal)ctn.kgs; updctn.CBM = ctn.cbm == null ? 0 : (decimal)ctn.cbm; updctn.TAREWEIGHT = ctn.tareweight == null ? 0 : (decimal)ctn.tareweight; updctn.TEU = 箱型info.TEU == null ? 0 : (int)箱型info.TEU; updctn.WEIGHKGS = ctn.weighkgs == null ? 0 : (decimal)ctn.weighkgs; //DJYCTNID = ctn.id; } else { //如果DS7里面没有这个djyctnid,保存时新增,依据BSNO=*作为标记(ds7现有逻辑) ctnbsno = "*"; var newctn = new MsOpSeaeDetail { CTNCODE = 箱型info.CTNID, SIZE = 箱型info.CTNSIZE, CTN = 箱型info.CTN, BSNO = ctnbsno, CTNALL = ctn.ctnall, CTNNUM = ctn.ctnnum == null ? 0 : (int)ctn.ctnnum, CNTRNO = ctn.cntrno, SEALNO = ctn.sealno, PKGS = ctn.pkgs == null ? 0 : (int)ctn.pkgs, KINDPKGS = ctn.kindpkgs, KGS = ctn.kgs == null ? 0 : (decimal)ctn.kgs, CBM = ctn.cbm == null ? 0 : (decimal)ctn.cbm, TAREWEIGHT = ctn.tareweight == null ? 0 : (decimal)ctn.tareweight, TEU = 箱型info.TEU == null ? 0 : (int)箱型info.TEU, WEIGHKGS = ctn.weighkgs == null ? 0 : (decimal)ctn.weighkgs, DJYCTNID = ctn.id }; result.Add(newctn); } } } return result; } public string dealGoodsinfo(string goodscode, string goodsname, string description, string hscode) { var result = ""; try { if (string.IsNullOrWhiteSpace(goodsname)) return ""; var cdc = new CommonDataContext(); var 当前货名 = cdc.code_goods.Where(x => x.GOODNAME == goodsname).ToList(); if (当前货名 == null || 当前货名.Count == 0) { if (!string.IsNullOrWhiteSpace(goodsname)) { var newrec = new code_goods_md(); newrec.GID = Guid.NewGuid().ToString(); newrec.GOODCODE = SetLength(goodscode, 10); newrec.GOODNAME = SetLength(goodsname, 60); result = newrec.GOODNAME; newrec.DESCRIP = SetLength(description, 600); newrec.HSCODE = SetLength(hscode, 10); cdc.code_goods.Add(newrec); cdc.SaveChanges(); } } else { result = 当前货名[0].GOODNAME; } } catch (Exception e) { var str = JsonConvert.SerializeObject(e); if (e.InnerException != null) { str += ";;;InnerException:" + JsonConvert.SerializeObject(e.InnerException); } //logger.Error(str); BasicDataRefDAL.SaveLog(e, "", "接收大简云订舱", "错误"); } return result; } public static void GetCtn(ref t_op_ctn_md curr, t_op_ctn_md ctn) { curr.代码 = ctn.代码; curr.尺寸 = ctn.尺寸; curr.箱型 = ctn.箱型; //curr.编号 = head.编号, curr.表现形式 = ctn.表现形式; curr.数量 = ctn.数量; curr.箱号 = ctn.箱号; curr.封号 = ctn.封号; curr.件数 = ctn.件数; curr.包装 = ctn.包装; curr.重量 = ctn.重量; curr.尺码 = ctn.尺码; curr.皮重 = ctn.皮重; curr.TEU = ctn.TEU; curr.称重重量 = ctn.称重重量; curr.DJYCTNID = ctn.DJYCTNID; } public List GetAmsList(t_op_seae_md head) { var result = new List(); //foreach (var item in bookingEDIExt) //{ var item = bookingEDIExt; if (bookingEDIExt != null) { var newrec = new t_op_ams_md { 编号 = head.编号, 发货人代码 = SetLength(item.shipperEdiCode, 10), 收货人代码 = SetLength(item.consigneeEdiCode, 10), 销售代码 = SetLength(item.salerCode, 10), 危险品联系人 = SetLength(item.ediAttn, 30), 危险品联系方式 = SetLength(item.ediAttnTel, 50), 欧盟HSCODE = SetLength(item.ckhi, 100), 南美东NCM = 设置换行(SetLength(item.cncm, 600)), 巴西木质包装说明 = 设置换行(SetLength(item.wncm, 300)), 实际开船日期 = head.开船日期, HBL发送方式 = SetLength(item.masterBolIndicator, 1), ESL航线代码 = SetLength(lanename, 20), SI备注 = 设置换行(SetLength(siremark, 1000)) }; //20230530 如果船公司不是太平PIL 则将部分字段设为空白 if (head.船公司 == "PIL") { newrec.HBL发送方式 = ""; newrec.销售代码 = ""; newrec.实际开船日期 = null; newrec.南美东NCM = ""; newrec.巴西木质包装说明 = ""; newrec.欧盟HSCODE = ""; } result.Add(newrec); } //} return result; } //public List GetAssistantList(t_op_seae_md head) //{ // var result = new List(); // var d6 = new DS6DataContext(); // var 货物名称 = ""; // if (childrens != null) // foreach (var item in childrens) // { // var weeks = get周次(item.etd); // var 箱型箱量 = new 箱型箱量(); // var 箱号封号 = ""; // var 件数包装 = item.pkgs.ToString() + item.kindpkgs; // var 货物重量 = item.kgs.ToString() + "KGS"; // var 货物尺码 = item.cbm.ToString() + "CBM"; // foreach (var ctn in item.ctnInputs) // { // var 箱型infoList = d6.t_code_ctn.Where(x => // (x.尺寸 + "'" + x.箱型) == ctn.ctnall // || (x.尺寸 + x.箱型) == ctn.ctnall // || (x.尺寸 + "'" + x.箱型.Replace("OT", "O/T")) == ctn.ctnall // || (x.尺寸 + x.箱型.Replace("OT", "O/T")) == ctn.ctnall // ).ToList(); // var 箱型info = new t_code_ctn_md(); // if (箱型infoList != null && 箱型infoList.Count > 0) // { // 箱型info = 箱型infoList[0]; // } // else // { // continue; // } // 箱型箱量.Add(new 箱型箱量item(箱型info, ctn.ctnnum == null ? 1 : (int)ctn.ctnnum)); // if (!string.IsNullOrWhiteSpace(ctn.cntrno) || !string.IsNullOrWhiteSpace(ctn.sealno)) // { // if (箱号封号 != "") 箱号封号 += "\r\n"; // 箱号封号 += (string.IsNullOrWhiteSpace(ctn.cntrno) ? "" : ctn.cntrno) + (string.IsNullOrWhiteSpace(ctn.sealno) ? "" : "/" + ctn.sealno); // } // //if (ctn.pkgs != null && ctn.pkgs != 0 && !string.IsNullOrWhiteSpace(ctn.kindpkgs)) // //{ // // if (件数包装 != "") 件数包装 += "\r\n"; // // 件数包装 += ctn.pkgs.ToString() + ctn.kindpkgs; // //} // //if (ctn.kgs != null)// && ctn.重量 != 0 // //{ // // if (货物重量 != "") 货物重量 += "\r\n"; // // 货物重量 += ctn.kgs.ToString() + "KGS"; // //} // //if (ctn.cbm != null)//&& ctn.尺码 != 0 // //{ // // if (货物尺码 != "") 货物尺码 += "\r\n"; // // 货物尺码 += ctn.cbm.ToString() + "CBM"; // //} // } // var 集装箱 = 箱型箱量.get集装箱(); // var 箱数大写 = 箱型箱量.get箱数大写(); // //var 当前货名 = new t_code_goods_md(); // 货物名称 = dealGoodsinfo(item.goodscode, item.goodsname, item.description, item.hscode); // // var 当前货名 = d6.t_code_goods.Where(x => x.代码 == item.goodscode).ToList(); // //if (当前货名 == null || 当前货名.Count == 0) // //{ // // if (!string.IsNullOrWhiteSpace(item.goodscode)) // // { // // var newcodegoods = new t_code_goods_md(); // // newcodegoods.代码 = SetLength(item.goodscode, 10); // // newcodegoods.货物名称 = SetLength(item.goodsname, 100); // // 货物名称 = newcodegoods.货物名称; // // newcodegoods.货物描述 = SetLength(item.description, 600); // // newcodegoods.商品编码 = SetLength(item.hscode, 10); // // d6.t_code_goods.Add(newcodegoods); // // d6.SaveChanges(); // // } // //} // //else // //{ // // 货物名称 = 当前货名[0].货物名称; // //} // var newrec = new t_op_seae_assistant_md // { // 编号 = head.编号, // 主编号 = head.编号, // DJYCHILDRENID = item.Id, // BSNO = item.bsno, // 录入日期 = item.bsdate, // 主提单号 = item.mblno, // 分提单号 = item.hblno, // //订舱序列号 = item.bookingno, // 发货人代码 = 设置换行(item.shipper), // 收货人代码 = 设置换行(item.consignee), // 通知人代码 = 设置换行(item.notifyparty), // //20230605 // 代理内容 = 设置换行(item.foreignAgent), // 提单份数 = item.nobill, // 签单方式 = item.issuetype, // 签单日期 = item.issuedate, // 签单地点 = item.issueplace, // 付费方式 = item.blfrt, // 预付地点 = item.prepardat, // 到付地点 = item.payableat, // 运输条款 = item.service, // 唛头 = 设置换行(item.marks), // 运输方式 = item.hscode, // 货物名称 = 货物名称, // 货物描述 = 设置换行(item.description), // 件数 = item.pkgs, // 包装 = item.kindpkgs, // 重量 = item.kgs, // 尺码 = item.cbm, // 件数大写 = item.totalno, // 集装箱 = item.cntrtotal, // 船公司 = item.carrier, // 货物标识 = item.cargoid, // 危险品分类 = item.dclass, // 危险品编号 = item.dunno, // 设置温度 = item.tempset, // 冷藏通风量 = item.reeferf, // 最低温度 = item.tempmin, // 最高温度 = item.tempmax, // 是否自有箱 = item.iscontainersoc, // 委托编号 = item.pono, // 操作员 = item.op, // 揽货人 = item.sale, // 客服员 = item.custservice, // //总价 = (item.bookingEDIExt == null) ? 0M : item.bookingEDIExt.kingTareweight == null ? 0M : item.bookingEDIExt.kingTareweight, // //预付地点= item.prepardatid, // //到付地点= item.payableatid, // 周次 = weeks, // 运费协议号 = item.contractno, // 场站 = item.yard, // 船名 = item.vessel, // 航次 = item.voynoinner, // 开船日期 = SetDayMinute(item.etd), // 截港日期 = SetDayZero(item.closingdate), // 预抵日期 = SetDayMinute(item.eta), // 装港代码 = item.portloadid, // 装货港 = item.portload, // 卸货代码 = item.portdischargeid, // 卸货港 = item.portdischarge, // 交货代码 = item.placedeliveryid, // 交货地点 = item.placedelivery, // 目的地代码 = item.destinationid, // 目的地 = item.destination, // //集装箱 = 集装箱, // 箱数大写 = 箱数大写, // 合同号 = item.pono, // 委托单位 = item.customername, // 报关行 = item.customser, // 承运车队 = item.trucker, // 货代公司 = item.forwarder,//大简云“订舱代理”,ds6界面的“订舱代理”,ds6数据库的货代 // 备案号 = item.lanename, // 航线 = item.lineName, // 代理 = item.agentname,//大简云“国外代理”,ds6界面的“代理”,ds6数据库的代理 // 录入人 = createdUserName, // 箱TEU = 箱型箱量.getTeu(), // 箱型1 = 箱型箱量.get箱型1(), // 箱型2 = 箱型箱量.get箱型2(), // 箱型3 = 箱型箱量.get箱型3(), // 箱型4 = 箱型箱量.get箱型4(), // 箱型5 = 箱型箱量.get箱型5(), // 箱型6 = 箱型箱量.get箱型6(), // 箱型7 = 箱型箱量.get箱型7(), // 箱型8 = 箱型箱量.get箱型8(), // 箱型9 = 箱型箱量.get箱型9(), // 箱型10 = 箱型箱量.get箱型10(), // 辅助字段一 = 设置换行(item.bookingEDIExt.exRemark1), // 辅助字段二 = 设置换行(item.bookingEDIExt.exRemark2), // 辅助字段三 = 设置换行(item.bookingEDIExt.exRemark3), // 辅助字段四 = 设置换行(item.bookingEDIExt.exRemark4), // 箱号封号 = 箱号封号, // 件数包装 = 件数包装, // 货物重量 = 货物重量, // 货物尺码 = 货物尺码 // }; // var lengthDic = new Dictionary // { // {"主提单号",20}, // {"分提单号",20}, // {"发货人代码",1000}, // {"收货人代码",1000}, // {"通知人代码",1000}, // {"提单份数",10}, // {"签单方式",10}, // {"签单地点",30}, // {"付费方式",60}, // {"预付地点",100}, // {"到付地点",100}, // {"运输条款",10}, // {"唛头",800}, // {"运输方式",10}, // {"HS编码",30}, // {"货物描述",1000}, // //{"货物描述",1000}, // {"包装",60}, // {"件数大写",100}, // {"集装箱",200}, // {"船公司",20}, // {"货物标识",1}, // {"危险品分类",5}, // {"危险品编号",20}, // {"设置温度",16}, // {"冷藏通风量",12}, // {"最低温度",5}, // {"最高温度",5}, // {"委托编号",20}, // {"操作员",10}, // {"揽货人",10}, // {"客服员",10}, // {"运费协议号",20}, // {"场站",20}, // {"船名",60}, // {"航次",20}, // {"装港代码",10}, // {"装货港",60}, // {"卸货代码",10}, // {"卸货港",100}, // {"交货代码",10}, // {"交货地点",100}, // {"目的地代码",10}, // {"目的地",30}, // {"合同号",50}, // {"委托单位",20}, // {"报关行",20}, // {"承运车队",20}, // {"货代公司",20}, // {"备案号",20}, // {"航线",30}, // {"代理",20}, // {"录入人",12}, // {"辅助字段一",600}, // {"辅助字段二",600}, // {"辅助字段三",600}, // {"辅助字段四",600}, // }; // //Set分单箱封号件重尺(ref newrec, item); // foreach (var _item in lengthDic) // { // try // { // var value = newrec.GetType().GetProperty(_item.Key).GetValue(newrec).ToString(); // var newvalue = SetLength(value, _item.Value); // newrec.GetType().GetProperty(_item.Key).SetValue(newrec, newvalue); // } // catch (Exception e) // { // continue; // } // } // result.Add(newrec); // } // return result; //} public static void GetAssistant(ref t_op_seae_assistant_md curr, t_op_seae_assistant_md item) { //curr.编号 = head.编号; //curr.主编号 = item.编号; curr.DJYCHILDRENID = item.DJYCHILDRENID; curr.BSNO = item.BSNO; curr.录入日期 = item.录入日期; curr.主提单号 = item.主提单号; curr.分提单号 = item.分提单号; //订舱序列号 = item.bookingno; curr.发货人代码 = item.发货人代码; curr.收货人代码 = item.收货人代码; curr.通知人代码 = item.通知人代码; curr.代理内容 = item.代理内容; curr.提单份数 = item.提单份数; curr.签单方式 = item.签单方式; curr.签单日期 = item.签单日期; curr.签单地点 = item.签单地点; curr.付费方式 = item.付费方式; curr.预付地点 = item.预付地点; curr.到付地点 = item.到付地点; curr.运输条款 = item.运输条款; curr.唛头 = item.唛头; curr.运输方式 = item.运输方式; curr.货物名称 = item.货物名称; curr.货物描述 = item.货物描述; curr.件数 = item.件数; curr.包装 = item.包装; curr.重量 = item.重量; curr.尺码 = item.尺码; curr.件数大写 = item.件数大写; curr.集装箱 = item.集装箱; curr.船公司 = item.船公司; curr.货物标识 = item.货物标识; curr.危险品分类 = item.危险品分类; curr.危险品编号 = item.危险品编号; curr.设置温度 = item.设置温度; curr.冷藏通风量 = item.冷藏通风量; curr.最低温度 = item.最低温度; curr.最高温度 = item.最高温度; curr.是否自有箱 = item.是否自有箱; curr.委托编号 = item.委托编号; curr.操作员 = item.操作员; curr.揽货人 = item.揽货人; curr.客服员 = item.客服员; curr.周次 = item.周次; curr.运费协议号 = item.运费协议号; curr.运费协议号 = item.运费协议号; curr.场站 = item.场站; curr.船名 = item.船名; curr.航次 = item.航次; curr.开船日期 = item.开船日期; curr.截港日期 = item.截港日期; curr.预抵日期 = item.预抵日期; curr.装港代码 = item.装港代码; curr.装货港 = item.装货港; curr.卸货代码 = item.卸货代码; curr.卸货港 = item.卸货港; curr.交货代码 = item.交货代码; curr.交货地点 = item.交货地点; curr.目的地代码 = item.目的地代码; curr.目的地 = item.目的地; curr.箱数大写 = item.箱数大写; curr.合同号 = item.合同号; curr.委托单位 = item.委托单位; curr.报关行 = item.报关行; curr.承运车队 = item.承运车队; curr.货代公司 = item.货代公司; curr.备案号 = item.备案号; curr.航线 = item.航线; curr.代理 = item.代理; curr.录入人 = item.录入人; curr.箱TEU = item.箱TEU; curr.箱型1 = item.箱型1; curr.箱型2 = item.箱型2; curr.箱型3 = item.箱型3; curr.箱型4 = item.箱型4; curr.箱型5 = item.箱型5; curr.箱型6 = item.箱型6; curr.箱型7 = item.箱型7; curr.箱型8 = item.箱型8; curr.箱型9 = item.箱型9; curr.箱型10 = item.箱型10; curr.辅助字段一 = item.辅助字段一; curr.辅助字段二 = item.辅助字段二; curr.辅助字段三 = item.辅助字段三; curr.辅助字段四 = item.辅助字段四; curr.箱号封号 = item.箱号封号; curr.件数包装 = item.件数包装; curr.货物重量 = item.货物重量; curr.货物尺码 = item.货物尺码; } public List GetOpStatus(t_op_seae_md head) { var result = new List(); if (goodsStatus != null && goodsStatus.Count > 0) { foreach (var item in goodsStatus) { var status = new t_op_state_md() { 编号 = head.编号, 业务状态 = item.statusName, 是否完成 = item.finishTime == null ? false : true, 完成时间 = item.finishTime, 完成人 = item.finishTime == null ? null : head.操作员, 备注 = item.remark, 录入人 = head.操作员, 录入日期 = item.finishTime == null ? DateTime.Now : item.finishTime }; result.Add(status); } var _order = 1; foreach (var item in result.OrderBy(x => x.录入日期)) { item.顺序 = _order; _order++; } } return result; } //public DingCangHead() { // StartDatetime=DateTime.Now; //} } public class DingCangCtn { public long? id { get; set; } public long? billid { get; set; } public string ctncode { get; set; } //"string", public string ctnall { get; set; } //"string", public int? ctnnum { get; set; } = 0; public int? teu { get; set; } = 0; public string cntrno { get; set; } //"string", public string sealno { get; set; } //"string", public int? pkgs { get; set; } = 0; public string kindpkgs { get; set; } //"string", public decimal? kgs { get; set; } = 0M; public decimal? cbm { get; set; } = 0M; public decimal? tareweight { get; set; } = 0M; public string ctnstatus { get; set; } //"string", public string weightype { get; set; } //"string", public decimal? weighkgs { get; set; } = 0M; public string weighattn { get; set; } //"string", public string vgmconncom { get; set; } //"string", public string weightel { get; set; } //"string", public string weighdate { get; set; } //"string", public string vgmaddr { get; set; } //"string", public string vgmemail { get; set; } //"string", public string remark { get; set; } //"string", public List ctnDetailInputs { get; set; } } public class DingCangCtnDetail { public long? id { get; set; } public string ctnid { get; set; } public decimal? pkgs { get; set; } = 0M; public string kindpkgs { get; set; } //"string", public decimal? kgs { get; set; } = 0M; public decimal? cbm { get; set; } = 0M; public string hscode { get; set; } //"string", public string marks { get; set; } //"string", public string description { get; set; } //"string", public string remark { get; set; } } public class DingCangbookingEDIExt { public string weiTuoFang { get; set; } //"string", public string sendCode { get; set; } //"string", public string receiveCode { get; set; } //"string", public string notifyCdoe { get; set; } //"string", public string salerCode { get; set; } //"string", public string masterBolIndicator { get; set; } //"string", public string emanifestHbl { get; set; } //"string", public string consigneeEdiCode { get; set; } //"string", public string shipperEdiCode { get; set; } //"string", public string ediAttn { get; set; } //"string", public string ediAttnTel { get; set; } //"string", public string ediAttnMail { get; set; } //"string", public string amsConsignee { get; set; } //"string", public string amsNotifyParty { get; set; } //"string", public string opEName { get; set; } //"string", public string opTel { get; set; } //"string", public string opEmail { get; set; } //"string", public string acihbl { get; set; } //"string", public string s0CC0C { get; set; } //"string", public string goodsName { get; set; } //"string", public string masterBolIndicatorName { get; set; } //"string", public string salerCodeName { get; set; } //"string", public string ckhi { get; set; } //"string", public string cncm { get; set; } //"string", public string wncm { get; set; } //"string", public string orderRemark { get; set; } //"string", public string exRemark1 { get; set; } //"string", public string exRemark2 { get; set; } //"string", public string exRemark3 { get; set; } //"string", public string exRemark4 { get; set; } //"string", public decimal? kingTareweight { get; set; } = 0M; } public class DownloadFile { public string FileName { get; set; } public string FileType { get; set; } public string FilePath { get; set; } } /// /// 提单信息 /// public class DingCangTDXX { public long Id { get; set; } public string bsno { get; set; } //"string", public string bsstatus { get; set; } //"string", public string bsstatusname { get; set; } //"string", public DateTime? bsdate { get; set; } //"2023-03-30T03:12:51.033Z", public string mblno { get; set; } //"string", public string hblno { get; set; } //"string", public string bookingno { get; set; } //"string", public string contractno { get; set; } //"string", public string servicecontractno { get; set; } //"string", public string shipperid { get; set; } //"string", public string consigneeid { get; set; } //"string", public string notifypartyid { get; set; } //"string", public string shipper { get; set; } //"string", public string consignee { get; set; } //"string", public string notifyparty { get; set; } //"string", public string notifypartY2 { get; set; } //"string", public string yardid { get; set; } //"string", public string yard { get; set; } //"string", public string vesselid { get; set; } //"string", public string vessel { get; set; } //"string", public string voyno { get; set; } //"string", public string voynoinner { get; set; } //"string", public DateTime? etd { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? atd { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closingdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closedocdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? closevgmdate { get; set; } //"2023-03-30T03:12:51.033Z", public DateTime? eta { get; set; } //"2023-03-30T03:12:51.033Z", public string placereceiptid { get; set; } //"string", public string placereceipt { get; set; } //"string", public string portloadid { get; set; } //"string", public string portload { get; set; } //"string", public string portdischargeid { get; set; } //"string", public string portdischarge { get; set; } //"string", public string placedeliveryid { get; set; } //"string", public string placedelivery { get; set; } //"string", public string destinationid { get; set; } //"string", public string destination { get; set; } //"string", public string nobill { get; set; } //"string", public string copynobill { get; set; } //"string", public string issuetype { get; set; } //"string", public DateTime? issuedate { get; set; } //"2023-03-30T03:12:51.033Z", public string issueplaceid { get; set; } //"string", public string issueplace { get; set; } //"string", public string blfrt { get; set; } //"string", public string prepardat { get; set; } //"string", public string payableat { get; set; } //"string", public string service { get; set; } //"string", public string marks { get; set; } //"string", public string hscode { get; set; } //"string", public string description { get; set; } //"string", public int? pkgs { get; set; } = 0; public string kindpkgs { get; set; } //"string", public decimal? kgs { get; set; } = 0; public decimal? cbm { get; set; } = 0; public string totalno { get; set; } //"string", public string cntrtotal { get; set; } //"string", public string carrierid { get; set; } //"string", public string carrier { get; set; } //"string", public string cargoid { get; set; } //"string", public string dclass { get; set; } //"string", public string dunno { get; set; } //"string", public string dpage { get; set; } //"string", public string dlabel { get; set; } //"string", public string linkman { get; set; } //"string", public string tempid { get; set; } //"string", public string tempset { get; set; } //"string", public string reeferf { get; set; } //"string", public string humidity { get; set; } //"string", public string tempmin { get; set; } //"string", public string tempmax { get; set; } //"string", public bool? iscontainersoc { get; set; } //true, public string soremark { get; set; } //"string", public string siremark { get; set; } //"string", public string yardremark { get; set; } //"string", public string compid { get; set; } //"string", public string compname { get; set; } //"string", public string shippername { get; set; } //"string", public string shipperaddR1 { get; set; } //"string", public string shipperaddR2 { get; set; } //"string", public string shipperaddR3 { get; set; } //"string", public string shippercity { get; set; } //"string", public string shipperprovince { get; set; } //"string", public string shipperpostcode { get; set; } //"string", public string shippercountry { get; set; } //"string", public string shipperattn { get; set; } //"string", public string shippertel { get; set; } //"string", public string consigneename { get; set; } //"string", public string consigneeaddR1 { get; set; } //"string", public string consigneeaddR2 { get; set; } //"string", public string consigneeaddR3 { get; set; } //"string", public string consigneecity { get; set; } //"string", public string consigneeprovince { get; set; } //"string", public string consigneepostcode { get; set; } //"string", public string consigneercountry { get; set; } //"string", public string consigneeattn { get; set; } //"string", public string consigneetel { get; set; } //"string", public string notifypartyname { get; set; } //"string", public string notifypartyaddR1 { get; set; } //"string", public string notifypartyaddR2 { get; set; } //"string", public string notifypartyaddR3 { get; set; } //"string", public string notifypartycity { get; set; } //"string", public string notifypartyprovince { get; set; } //"string", public string notifypartypostcode { get; set; } //"string", public string notifypartycountry { get; set; } //"string", public string notifypartyattn { get; set; } //"string", public string notifypartytel { get; set; } //"string", public string pono { get; set; } //"string", public string opid { get; set; } //"string", public string docid { get; set; } //"string", public string op { get; set; } //"string", public string doc { get; set; } //"string", public string saleid { get; set; } //"string", public string sale { get; set; } //"string", public string custserviceid { get; set; } //"string", public string custservice { get; set; } //"string", public string customername { get; set; } //"string", public string forwarder { get; set; } //"string", public string shipagency { get; set; } //"string", public string customser { get; set; } //"string", public string trucker { get; set; } //"string", public string agentid { get; set; } //"string", public long? customerid { get; set; } //= 0; public string forwarderid { get; set; } //"string", public string shipagencyid { get; set; } //"string", public string customserid { get; set; } //"string", public string truckerid { get; set; } //"string", public string agentname { get; set; } //"string", /// /// 境外代理 内容 /// public string foreignAgent { get; set; } //境外代理, public string weituo { get; set; } //"string", public string consigneedooraddr { get; set; } //"string", public string shipperdooraddr { get; set; } //"string", public string scaccode { get; set; } //"string", public string itncode { get; set; } //"string", public string prepardatid { get; set; } //"string", public string payableatid { get; set; } //"string", public string custno { get; set; } //"string", public string transportid { get; set; } //"string", public string transport { get; set; } //"string", public string thirdpayaddr { get; set; } //"string", public string yardcontract { get; set; } //"string", public string yardcontracttel { get; set; } //"string", public string yardcontractemail { get; set; } //"string", public bool? feeself { get; set; } //true, public string lanecode { get; set; } //"string", public string lanename { get; set; } //"string", public string freightpayer { get; set; } //"string", public string goodscode { get; set; } //"string", public string goodsname { get; set; } //"string", public string pkgstotal { get; set; } //"string", public string kgstotal { get; set; } //"string", public string cbmtotal { get; set; } //"string", public string routeid { get; set; } //"string", public string route { get; set; } //"string", public string warehouse { get; set; } //"string", public string warehouseID { get; set; } //"string", public string epCode { get; set; } //"string", public string lineName { get; set; } //"string", public List ctnInputs { get; set; } public DingCangbookingEDIExt bookingEDIExt { get; set; } } public class DingCanggoodsStatus { public string statusName { get; set; } //"string", public DateTime? finishTime { get; set; }//2023-03-30T03:12:51.034Z", public string remark { get; set; } //"string", public string extData { get; set; }//"string", } public class 大简云业务函电 { public t_op_seae_md opseae { get; set; } public t_op_letter_md HeadLetter { get; set; } = new t_op_letter_md(); public OpLetterBase ChildLetter { get; set; } public 大简云业务函电() { } public bool IsDeleted { get; set; } = false; public static 大简云业务函电 getHelper(string lettername, OpLetterBase childletter) { var ds6 = new DS6DataContext(); var opseaeList = ds6.t_op_seae.Where(x => x.DJYID == childletter.DJYBOOKINGID).ToList(); var result = new 大简云业务函电(); if (opseaeList == null || opseaeList.Count == 0) { return result; } result.opseae = opseaeList[0]; result.HeadLetter = new t_op_letter_md(); result.HeadLetter.编号 = result.opseae.编号; result.HeadLetter.函电名称 = lettername; //该字段用于:保存新增的业务函电时,需先保存op_letter ,但该表是自增序列号表, //如这种业务函电在一个订舱中多于一个(如派车),则无法定位到正确的新增op_letter //故增加此字段,以记录该条业务函电的主键。 //如这种业务函电在一个订舱中只有一个(如订舱),则djyid和DJYBOOKINGID字符串相同; //如多于一个(如派车),则op_letter.djybookingid=op_letter_pc.djybookingid //且这种业务函电 需要在调用getHelper方法获得【大简云业务函电】对象时,传DJYBOOKINGID字段值 result.HeadLetter.DJYBOOKINGID = childletter.DJYBOOKINGID; result.HeadLetter.DJYLETTERID = childletter.DJYLETTERID; result.ChildLetter = childletter; return result; } public void DoSave() { if (string.IsNullOrWhiteSpace(HeadLetter.编号)) { return; } else { //如果具体业务函电已存在 则更新之 //判断依据为是否存在 SaveLetter(); } } public void SaveLetter(object 大简云对象 = null) { var result = new OpLetterBase(); var ds6 = new DS6DataContext(); void SaveHeadLetter(string 函电名称) { // ds6.t_op_letter.Add(HeadLetter); ds6.SaveChanges(); var letterheads = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.函电名称 == HeadLetter.函电名称).ToList(); if (letterheads != null || letterheads.Count > 0) { HeadLetter = letterheads[0]; } //return new t_op_letter_md(); } void UpdHeadLetter(string 函电名称) { // var UpdHeadLetterList = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.函电名称 == 函电名称).ToList(); if (UpdHeadLetterList != null || UpdHeadLetterList.Count > 0) { var UpdHead = UpdHeadLetterList[0]; UpdHead.HEAD_TO = HeadLetter.HEAD_TO; UpdHead.HEAD_ATTN = HeadLetter.HEAD_ATTN; UpdHead.签发人 = HeadLetter.签发人; UpdHead.签发日期 = HeadLetter.签发日期; } //return new t_op_letter_md(); } void DelHeadLetter(string 函电名称) { var delheadList = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.函电名称 == 函电名称).ToList(); if (delheadList != null && delheadList.Count > 0) { var delhead = delheadList[0]; ds6.t_op_letter.Remove(delhead); } } //没有找到业务 也就没有可以保存的op_letter 直接退出 if (HeadLetter == null) return; //var currlist = new List(); if (HeadLetter.函电名称 == "入货通知") { var currHeadLetterList = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.函电名称 == HeadLetter.函电名称).ToList(); var currlist = new List(); if (currHeadLetterList != null && currHeadLetterList.Count > 0) { var headid = currHeadLetterList[0].LE_ID; currlist = ds6.t_op_letter_rh.Where(x => x.LE_ID == headid).ToList(); } //首先判断是否为删除 如果是 执行删除 if (IsDeleted) { //找到具体letter 如有则定位到opletter //两个都要删除 if (currHeadLetterList != null && currHeadLetterList.Count > 0) { //ds6.t_op_letter.Remove(currHeadLetterList[0]); if (currlist != null && currlist.Count > 0) { var delrec = currlist[0]; ds6.t_op_letter_rh.Remove(delrec); } DelHeadLetter(HeadLetter.函电名称); ds6.SaveChanges(); return; } } else { if (currlist != null && currlist.Count > 0) { UpdHeadLetter(HeadLetter.函电名称); //寻找 var updrec = currlist[0]; updrec.getCopy(ChildLetter, typeof(t_op_letter_rh_md)); ds6.t_op_letter_rh.AddOrUpdate(updrec); } else { SaveHeadLetter(HeadLetter.函电名称); if (HeadLetter.LE_ID == 0) return; ChildLetter.LE_ID = HeadLetter.LE_ID; ds6.t_op_letter_rh.Add((t_op_letter_rh_md)ChildLetter); } } } if (HeadLetter.函电名称 == "派车通知") { var 派车对象 = (大简云派车)大简云对象; var currHeadLetterList = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.函电名称 == HeadLetter.函电名称 && x.DJYLETTERID == HeadLetter.DJYLETTERID).ToList(); var currlist = new List(); if (currHeadLetterList != null && currHeadLetterList.Count > 0) { var headid = currHeadLetterList[0].LE_ID; currlist = ds6.t_op_letter_pc.Where(x => x.LE_ID == headid).ToList(); } if (IsDeleted) { //找到具体letter 如有则定位到opletter //两个都要删除 if (currlist != null && currlist.Count > 0) { var delrec = currlist[0]; ds6.t_op_letter_pc.Remove(delrec); DelHeadLetter(HeadLetter.函电名称); ds6.SaveChanges(); return; } opseae.承运车队 = ""; opseae.派车日期 = null; ds6.t_op_seae.AddOrUpdate(opseae); } else { opseae.承运车队 = ((t_op_letter_pc_md)ChildLetter).承运车队; var 派车日 = new DateTime(); try { if (派车对象.main.truckTime != null) { 派车日 = (DateTime)(派车对象.main.truckTime); 派车日 = new DateTime(派车日.Year, 派车日.Month, 派车日.Day); } } catch (Exception) { } opseae.派车日期 = 派车日; ds6.t_op_seae.AddOrUpdate(opseae); if (currHeadLetterList == null || currHeadLetterList.Count == 0) { ds6.t_op_letter.Add(HeadLetter); ds6.SaveChanges(); var letterheads = ds6.t_op_letter.Where(x => x.编号 == opseae.编号 && x.DJYLETTERID == HeadLetter.DJYLETTERID).ToList(); if (letterheads != null || letterheads.Count > 0) { HeadLetter = letterheads[0]; } } if (currlist != null && currlist.Count > 0) { //寻找 var updrec = currlist[0]; updrec.getCopy(ChildLetter, typeof(t_op_letter_pc_md)); ds6.t_op_letter_pc.AddOrUpdate(updrec); } else { if (HeadLetter.LE_ID == 0) return; ChildLetter.LE_ID = HeadLetter.LE_ID; ds6.t_op_letter_pc.Add((t_op_letter_pc_md)ChildLetter); } var ctninfo = 派车对象.main.contaList; var currctn = ds6.t_op_letter_pc_ctn.Where(x => x.LE_ID == HeadLetter.LE_ID).ToList(); if (currctn != null && currctn.Count > 0) { ds6.t_op_letter_pc_ctn.RemoveRange(currctn); } if (ctninfo != null && ctninfo.Count > 0) { foreach (var djyctn in ctninfo) { var newctn = djyctn.GetPcCtn(HeadLetter); ds6.t_op_letter_pc_ctn.Add(newctn); } } } } ds6.SaveChanges(); } } public class 大简云入货通知 { public long BookingId { get; set; } public long Id { get; set; } /// /// TO /// public string ToName { get; set; } /// /// ATTN /// public string Attn { get; set; } /// /// ATTN电话 /// public string AttnTel { get; set; } /// /// ATTN邮箱 /// public string AttnMail { get; set; } /// /// FROM /// public string FromName { get; set; } /// /// FROM电话 /// public string FromTel { get; set; } /// /// FROM邮箱 /// public string FromMail { get; set; } /// /// 描述 /// public string Description { get; set; } /// /// 截单时间 /// public DateTime? CloseDocTime { get; set; } /// /// 截港时间 /// public DateTime? ClosingTime { get; set; } /// /// 截VGM时间 /// public DateTime? VgmTime { get; set; } /// /// 备注 /// public string Remark { get; set; } /// /// 场站代码 /// public string YARDID { get; set; } /// /// 场站 /// public string YARD { get; set; } /// /// 场站联系人 /// public string YARDCONTRACT { get; set; } /// /// 场站联系人电话 /// public string YARDCONTRACTTEL { get; set; } /// /// 是否删除 ture删除 否则新增或修改 /// public bool IsDeleted { get; set; } = false; public 大简云业务函电 GetLetter() { var letterchild = new t_op_letter_rh_md { LE_ID = 0, 入货场站 = SetLength(YARD, 30), 入货截至时间 = ClosingTime == null ? "" : ((DateTime)ClosingTime).ToString("yyyy-MM-dd"), 场站联系人 = SetLength(YARDCONTRACT, 60), 场站联系电话 = SetLength(YARDCONTRACTTEL, 60), 备注 = SetLength(Remark, 200), DJYLETTERID = Id, DJYBOOKINGID = BookingId }; var result = 大简云业务函电.getHelper("入货通知", letterchild); result.HeadLetter.HEAD_TO = SetLength(ToName, 60); result.HeadLetter.HEAD_ATTN = SetLength(Attn, 60); result.HeadLetter.签发人 = SetLength(FromName, 10); result.HeadLetter.签发日期 = DateTime.Now; result.IsDeleted = IsDeleted; //result.IsDeleted = true; return result; } } public class 大简云派车 { public class 派车head { public long gid { get; set; } public string messageType { get; set; } public string senderId { get; set; } public string senderName { get; set; } public string receiverId { get; set; } public string receiverName { get; set; } public string token { get; set; } public string version { get; set; } public string requestDate { get; set; } public string senderKey { get; set; } public string requestAction { get; set; } } public class 派车main { public string operType { get; set; } //tenantId /// /// 派车单ID /// public long id { get; set; } /// /// 订舱ID /// public long bookingId { get; set; } public long? truckId { get; set; } public string truckCode { get; set; } public string truckName { get; set; } public string toName { get; set; } public string attn { get; set; } public string attnTel { get; set; } public string attnMail { get; set; } public string attnFax { get; set; } public string fromName { get; set; } public string fromTel { get; set; } public string fromMail { get; set; } public string fromFax { get; set; } public decimal? kgs { get; set; } public decimal? fee { get; set; } public string payMethod { get; set; } public string payMethodName { get; set; } public DateTime? truckTime { get; set; } public string yardid { get; set; } public string yard { get; set; } public string yardcontract { get; set; } public string yardcontracttel { get; set; } public string factoryId { get; set; } public string factoryCode { get; set; } public string factoryName { get; set; } public string factoryContact { get; set; } public string factoryTel { get; set; } public string returnTime { get; set; } public string inYardID { get; set; } public string inYard { get; set; } public string inYardContact { get; set; } public string inYardContractTel { get; set; } public DateTime? needArriveTime { get; set; } public string closingTime { get; set; } public string pickUpTime { get; set; } public string isGuaJi { get; set; } public string attention { get; set; } public string remark { get; set; } public string dispatcherId { get; set; } public string dispatcherName { get; set; } public string factoryAddr { get; set; } public string callBackStatus { get; set; } public bool IsDeleted { get { return operType == "Delete"; } } public List contaList { get; set; } = new List(); public string 箱型箱量() { var result = ""; var 箱型箱量dic = new Dictionary(); foreach (var conta in contaList) { if (箱型箱量dic.ContainsKey(conta.ctnall)) { 箱型箱量dic[conta.ctnall] += conta.ctnnum == null ? 0 : (int)conta.ctnnum; } else { 箱型箱量dic.Add(conta.ctnall, conta.ctnnum == null ? 0 : (int)conta.ctnnum); } } if (箱型箱量dic.Count > 0) { foreach (var item in 箱型箱量dic) { if (result == "") result += " "; result += item.Key + "*" + item.Value.ToString(); } } return result; } } public class conta { public string ctncode { get; set; } public string ctnall { get; set; } public int? ctnnum { get; set; } public int? teu { get; set; } public string cntrno { get; set; } public string sealno { get; set; } public decimal? pkgs { get; set; } public string kindpkgs { get; set; } public decimal? kgs { get; set; } public decimal? cbm { get; set; } public decimal? tareweight { get; set; } public string ctnstatus { get; set; } public string weightype { get; set; } public string weighkgs { get; set; } public string weighattn { get; set; } public string vgmconncom { get; set; } public string weightel { get; set; } public string weighdate { get; set; } public string vgmaddr { get; set; } public string vgmemail { get; set; } public string remark { get; set; } public string carNumber { get; set; } public string carDriver { get; set; } public string carDriverTel { get; set; } public t_op_letter_pc_ctn_md GetPcCtn(t_op_letter_md HeadLetter) { var result = new t_op_letter_pc_ctn_md() { LE_ID = HeadLetter.LE_ID, 表现形式 = ctnall, 箱号 = cntrno, 封号 = sealno, 数量 = ctnnum == null ? 0 : (int)ctnnum, 件数 = pkgs == null ? 0 : (int)pkgs, 包装 = kindpkgs, 重量 = kgs, 尺码 = cbm, 车牌号 = carNumber, 司机 = carDriver, 司机电话 = carDriverTel }; return result; } } public 派车head head { get; set; } public 派车main main { get; set; } public 大简云业务函电 GetLetter() { var letterchild = new t_op_letter_pc_md { 承运车队 = SetLength(main.truckName, 30), 箱型箱量 = SetLength(main.箱型箱量(), 50), 背箱场站 = SetLength(main.yard, 30), 场站联系人 = SetLength(main.yardcontract, 60), 场站电话 = SetLength(main.yardcontracttel, 60), 要求到厂时间 = main.needArriveTime == null ? "" : ((DateTime)main.needArriveTime).ToString("yyyy-MM-dd HH:mm:ss"), 厂家地址 = SetLength(main.factoryAddr, 100), 厂家联系人 = SetLength(main.factoryContact, 60), 厂家联系电话 = SetLength(main.factoryTel, 60), 返箱地址 = SetLength(main.inYard, 100), 返箱联系人 = SetLength(main.inYardContact, 60), 返箱联系电话 = SetLength(main.inYardContractTel, 60), 备注 = SetLength(main.remark, 200), 陆运费 = main.fee, 结算方式 = main.payMethodName, DJYLETTERID = main.id, DJYBOOKINGID = main.bookingId }; var result = 大简云业务函电.getHelper("派车通知", letterchild); if (result.HeadLetter == null) return result; result.IsDeleted = main.IsDeleted; if (!string.IsNullOrWhiteSpace(main.toName)) result.HeadLetter.HEAD_TO = SetLength(main.toName, 60); if (!string.IsNullOrWhiteSpace(main.attn)) result.HeadLetter.HEAD_ATTN = SetLength(main.attn, 60); if (!string.IsNullOrWhiteSpace(main.fromName)) result.HeadLetter.签发人 = SetLength(main.fromName, 10); if (!string.IsNullOrWhiteSpace(main.fromName)) result.HeadLetter.签发日期 = DateTime.Now; return result; } } /// /// 回推客户订舱审核状态 /// public class CustOrderStatus { public string Type { get; set; } public CustOrderStatus_Data Data { get; set; } public bool is通过() { return Type == "CustOrderStatusAccept"; } public bool is驳回() { return Type == "CustOrderStatusReject"; } } public class CustOrderStatus_Data { public string BSNO { get; set; } public string BSSTATUS { get; set; } public long? BookingOrderId { get; set; } public string COMMENT { get; set; }//驳回原因 } public static string NumberToEnglishString(int number) { if (number < 0) //暂不考虑负数 { return ""; } if (number < 20) //0到19 { switch (number) { case 0: return "zero"; case 1: return "one"; case 2: return "two"; case 3: return "three"; case 4: return "four"; case 5: return "five"; case 6: return "sex"; case 7: return "seven"; case 8: return "eight"; case 9: return "nine"; case 10: return "ten"; case 11: return "eleven"; case 12: return "twelve"; case 13: return "thirteen"; case 14: return "fourteen"; case 15: return "fifteen"; case 16: return "sixteen"; case 17: return "seventeen"; case 18: return "eighteen"; case 19: return "nineteen"; default: return ""; } } if (number < 100) //20到99 { if (number % 10 == 0) //20,30,40,...90的输出 { switch (number) { case 20: return "twenty"; case 30: return "thirty"; case 40: return "forty"; case 50: return "fifty"; case 60: return "sixty"; case 70: return "seventy"; case 80: return "eighty"; case 90: return "ninety"; default: return ""; } } else //21.22,.99 思路:26=20+6 { return string.Format("{0} {1}", NumberToEnglishString(10 * (number / 10)), NumberToEnglishString(number % 10)); } } if (number < 1000) //100到999 百级 { if (number % 100 == 0) { return string.Format("{0} hundred", NumberToEnglishString(number / 100)); } else { return string.Format("{0} hundred and {1}", NumberToEnglishString(number / 100), NumberToEnglishString(number % 100)); } } if (number < 1000000) //1000到999999 千级 { if (number % 1000 == 0) { return string.Format("{0} thousand", NumberToEnglishString(number / 1000)); } else { return string.Format("{0} thousand and {1}", NumberToEnglishString(number / 1000), NumberToEnglishString(number % 1000)); } } if (number < 1000000000) //1000 000到999 999 999 百万级 { if (number % 1000 == 0) { return string.Format("{0} million", NumberToEnglishString(number / 1000000)); } else { return string.Format("{0} million and {1}", NumberToEnglishString(number / 1000000), NumberToEnglishString(number % 1000000)); } } if (number <= int.MaxValue) //十亿 级 { if (number % 1000000000 == 0) { return string.Format("{0} billion", NumberToEnglishString(number / 1000000000)); } else { return string.Format("{0} billion and {1}", NumberToEnglishString(number / 1000000000), NumberToEnglishString(number % 1000000000)); } } return ""; } public static string SetLength(string oldstr, int length) { var str = string.IsNullOrWhiteSpace(oldstr) ? "" : (len(oldstr) > length) ? SubString2(oldstr, 0, length) : oldstr; return str; } public static int len(string str) { System.Text.ASCIIEncoding n = new System.Text.ASCIIEncoding(); byte[] b = n.GetBytes(str); int length = 0; // l 为字符串的实际长度 for (int i = 0; i <= b.Length - 1; i++) { if (b[i] == 63) //判断是否为汉字或全脚符号 { length++; } length++; } return length; } public static string SubString2(string str, int startIndex, int length) { byte[] b = System.Text.Encoding.Default.GetBytes(str); if (length > b.Length) { length = b.Length; } return System.Text.Encoding.Default.GetString(b, startIndex, length); } public static DateTime? SetDayZero(DateTime? dt) { var result = new DateTime?(); result = null; if (dt != null) result = new DateTime(((DateTime)dt).Year, ((DateTime)dt).Month, ((DateTime)dt).Day); return result; } public static DateTime? SetDayMinute(DateTime? dt) { var result = new DateTime?(); result = null; if (dt != null) result = new DateTime(((DateTime)dt).Year, ((DateTime)dt).Month, ((DateTime)dt).Day, ((DateTime)dt).Hour, ((DateTime)dt).Minute, ((DateTime)dt).Second); return result; } public static string SetDayMinute_Str(DateTime? dt) { var _dt = SetDayMinute(dt); var result = _dt == null ? "" : ((DateTime)SetDayMinute(_dt)).ToString("yyyy-MM-dd"); return result; } public static string SetDayZero_Str(DateTime? dt) { var _dt = SetDayZero(dt); var result = _dt == null ? "" : ((DateTime)SetDayMinute(_dt)).ToString("yyyy-MM-dd"); return result; } public static string 设置换行(string str) { if (string.IsNullOrWhiteSpace(str)) return ""; var myStr = Regex.Replace(str, "(?