You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs

2844 lines
124 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
12 months ago
using System.Data.Entity.Migrations;
using System.Data.SqlClient;
2 years ago
using System.Diagnostics;
using System.Linq;
using System.Text;
12 months ago
using System.Text.RegularExpressions;
using System.Threading.Tasks;
2 years ago
using System.Web;
using DSWeb.Areas.CommMng.Models;
12 months ago
using DSWeb.Common.DB;
2 years ago
using DSWeb.EntityDA;
using DSWeb.TruckMng.Comm.Cookie;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
12 months ago
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.OpenXmlFormats.Wordprocessing;
using static DSWeb.Areas.CommMng.DAL.BasicDataRefDAL;
using DSWeb.MvcShipping.Models.MsOpSeae;
using DSWeb.Dispatch.DAL;
using DSWeb.Areas.Account.Models.BSNOLB;
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiPortDAL;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
2 years ago
namespace DSWeb.Areas.CommMng.DAL
{
public class PubSysDAL
{
public static List<SysEnumValue> GetEnumValueList(decimal enumTypeId)
{
return GetEnumValueList(enumTypeId, String.Empty);
}
public static List<SysEnumValue> 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<SysEnumValue>();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var evData = new 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 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 调用存储过程返回数据集
/// <summary>
/// 根据存储过程返回DataSet
/// </summary>
/// <param name="prcName">存储过程名称</param>
/// <param name="dbparams">参数列表(不包含存储过程的返回游标)</param>
/// <param name="curnames">存储过程的返回游标名称列表</param>
/// <returns>DataSet</returns>
public static DBDataSetResult GetMsSqlPrcDataSet(string prcName, List<CustomDbParamter> dbparams,
List<string> 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;
}
/// <summary>
/// 根据存储过程返回DataTable
/// </summary>
/// <param name="prcName">存储过程名称</param>
/// <param name="dbparams">参数列表(不包含存储过程的返回游标)</param>
/// <returns>DataSet</returns>
public static DBDataSetResult GetMsSqlPrcDataSet(string prcName, List<CustomDbParamter> dbparams, string curName)
{
var curnames = new List<string>();
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
}
12 months ago
public class MqWorkDAL
{
public static void DingCangToDS7(string strBody)
{
try
{
var jarr = JArray.Parse(strBody);
var itemstr = "";
var cdc = new CommonDataContext();
var dolist = new List<DingCangHead>();
foreach (var item in jarr)
{
var obj = item as JObject;
itemstr = item.ToString();
//var head = JsonConvert.DeserializeObject<DingCangHead>(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;
}
var head = JsonConvert.DeserializeObject<DingCangHead>(itemstr);
var cdc = new CommonDataContext();
try
{
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}", OPUser.USERID);
if (currentBill != null && currentBill.DJYID!=null)
{
//更新业务
var updrec = currentBill;
var headid = updrec.BSNO;
newhead.BSNO = updrec.BSNO;
newhead.MASTERNO = updrec.MASTERNO;
//newhead.INPUTBY = updrec.INPUTBY;
//newhead.INPUTBY = updrec.INPUTBY;
}
else {
//新增业务
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);
}
}
catch (Exception e)
{
}
finally
{
}
}
#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",
/// <summary>
/// 云港通ETD爬取的ETD 写入
/// </summary>
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",
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",
/// <summary>
/// 用户自定义航线
/// </summary>
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; } = "";//装运方式 整箱/拼箱
public List<DingCangCtn> ctnInputs { get; set; }
public DingCangbookingEDIExt bookingEDIExt { get; set; }
/// <summary>
/// 原来使用DingCangTDXX
/// </summary>
public List<DingCangHead> childrens { get; set; }
public List<DingCanggoodsStatus> goodsStatus { 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 ediList = cdc.CodeCustEdi.Where(x => x.EDINAME == "大简云船公司" && x.EDICODE == carrier).ToList();
if (ediList != null && ediList.Count > 0) {
= ediList[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
{
BSNO = bsno,
BSSTATUS = false,
FEESTATUS = false,
//会计期间 = SetDayZero(atd),
//装运方式 = 装运方式,
//周次 = weeks,
//录入日期 = bsdate, //bsdate<new DateTime(2000,1,1)|| bsdate > new DateTime(2070, 1, 1) ? DateTime.Now: bsdate,
MBLNO = mblno,
//真提单号 = tmblno,
//主提单标准 = string.IsNullOrWhiteSpace( mblno)?,
HBLNO = hblno,
CUSTNO = custno,
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),
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<string, int>
//{
// {"业务状态",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 List<MsOpSeaeDetail> GetCtnList(string BSNO)
{
var result = new List<MsOpSeaeDetail>();
if (ctnInputs != null)
{
var cdc = new CommonDataContext();
var CurrCtnList = new List<MsOpSeaeDetail>();
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
{
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);
//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<t_op_ams_md> GetAmsList(t_op_seae_md head)
{
var result = new List<t_op_ams_md>();
//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<t_op_seae_assistant_md> GetAssistantList(t_op_seae_md head)
//{
// var result = new List<t_op_seae_assistant_md>();
// 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<string, int>
// {
// {"主提单号",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<t_op_state_md> GetOpStatus(t_op_seae_md head)
{
var result = new List<t_op_state_md>();
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 DateTime StartDatetime { get; set; }
//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<DingCangCtnDetail> 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;
}
/// <summary>
/// 提单信息
/// </summary>
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",
/// <summary>
/// 境外代理 内容
/// </summary>
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<DingCangCtn> 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<OpLetterBase>();
if (HeadLetter. == "入货通知")
{
var currHeadLetterList = ds6.t_op_letter.Where(x => x. == opseae. && x. == HeadLetter.).ToList();
var currlist = new List<t_op_letter_rh_md>();
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<t_op_letter_pc_md>();
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; }
/// <summary>
/// TO
/// </summary>
public string ToName { get; set; }
/// <summary>
/// ATTN
/// </summary>
public string Attn { get; set; }
/// <summary>
/// ATTN电话
/// </summary>
public string AttnTel { get; set; }
/// <summary>
/// ATTN邮箱
/// </summary>
public string AttnMail { get; set; }
/// <summary>
/// FROM
/// </summary>
public string FromName { get; set; }
/// <summary>
/// FROM电话
/// </summary>
public string FromTel { get; set; }
/// <summary>
/// FROM邮箱
/// </summary>
public string FromMail { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 截单时间
/// </summary>
public DateTime? CloseDocTime { get; set; }
/// <summary>
/// 截港时间
/// </summary>
public DateTime? ClosingTime { get; set; }
/// <summary>
/// 截VGM时间
/// </summary>
public DateTime? VgmTime { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 场站代码
/// </summary>
public string YARDID { get; set; }
/// <summary>
/// 场站
/// </summary>
public string YARD { get; set; }
/// <summary>
/// 场站联系人
/// </summary>
public string YARDCONTRACT { get; set; }
/// <summary>
/// 场站联系人电话
/// </summary>
public string YARDCONTRACTTEL { get; set; }
/// <summary>
/// 是否删除 ture删除 否则新增或修改
/// </summary>
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
/// <summary>
/// 派车单ID
/// </summary>
public long id { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
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<conta> contaList { get; set; } = new List<conta>();
public string ()
{
var result = "";
var dic = new Dictionary<string, int>();
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;
}
}
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;
}
2 years ago
12 months ago
public static string (string str)
{
if (string.IsNullOrWhiteSpace(str)) return "";
var myStr = Regex.Replace(str, "(?<!\r)\n", "\r\n");
return myStr;
}
#endregion
}
2 years ago
}