|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using log4net;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Common.Helper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下货纸辅助类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class XiahuozhiHelpler
|
|
|
|
|
{
|
|
|
|
|
private static ILog log = LogManager.GetLogger("XiahuozhiHelpler");
|
|
|
|
|
|
|
|
|
|
public static bool Send(CommonDataContext commonData, BookingDB bookingDB, string ordno, string filerole, string filePath, out string msg, string attShowName = "系统")
|
|
|
|
|
{
|
|
|
|
|
var order = bookingDB.Orders.AsNoTracking().FirstOrDefault(o => o.ORDNO == ordno);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
msg = "订舱信息未找到";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var yardArr = new string[] { "港联捷场站", "港捷丰场站", "捷丰场站", "港联欣场站", "中创场站" };
|
|
|
|
|
if (!yardArr.Contains(order.YARD))
|
|
|
|
|
{
|
|
|
|
|
msg = "不支持的场站";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(order.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
msg = "主提单号不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(order.VESSEL))
|
|
|
|
|
{
|
|
|
|
|
msg = "船名不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(order.VoynoCustom))
|
|
|
|
|
{
|
|
|
|
|
msg = "海关航次不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//操作用户
|
|
|
|
|
User opUser = null;
|
|
|
|
|
if (!string.IsNullOrEmpty(order.OP_ID))
|
|
|
|
|
{
|
|
|
|
|
opUser = commonData.Users.AsNoTracking().FirstOrDefault(u => u.GID == order.OP_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opUser == null)
|
|
|
|
|
{
|
|
|
|
|
opUser = commonData.Users.AsNoTracking().FirstOrDefault(u => u.GID == order.USERID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserBaseinfo opBase = commonData.UserBases.AsNoTracking().First(ub => ub.USERID == opUser.GID);
|
|
|
|
|
|
|
|
|
|
#region 港联捷场站
|
|
|
|
|
if (order.YARD == "港联捷场站")
|
|
|
|
|
{
|
|
|
|
|
var paraXHZ = commonData.ParamValues.AsNoTracking().FirstOrDefault(p => p.CompId == order.CORPID && p.ParaCode == "CODE_GLJ_XHZ");
|
|
|
|
|
if (paraXHZ == null || string.IsNullOrEmpty(paraXHZ.ItemCode))
|
|
|
|
|
{
|
|
|
|
|
msg = "下货纸代号未找到或配置有误";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ediFile = Path.Combine(filePath, $"{paraXHZ.ItemCode}_{order.MBLNO}_{DateTime.Now.Ticks}.txt");
|
|
|
|
|
var paraServer = commonData.ParamSets.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "xhz_glj_server");
|
|
|
|
|
var paraUser = commonData.ParamSets.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "xhz_glj_user");
|
|
|
|
|
var paraPwd = commonData.ParamSets.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "xhz_glj_pwd");
|
|
|
|
|
|
|
|
|
|
if (paraServer == null || paraUser == null || paraPwd == null)
|
|
|
|
|
{
|
|
|
|
|
msg = "港联捷下货纸参数未配置";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder sbData = new StringBuilder();
|
|
|
|
|
sbData.AppendLine($"01:{order.VESSEL}:{order.VoynoCustom}"); //船名 航次
|
|
|
|
|
sbData.AppendLine($"12:{order.MBLNO}:{order.TRANSPORTID}:{order.PORTDISCHARGEID}:{paraXHZ.ItemCode}:{order.CARRIERID}::{ExchangeStr(order.YardRemark)}"); //主提单 中转港代码 目的港代码 货代代码 船公司 HPL参考号 备注
|
|
|
|
|
//2021-8-17,报文中不能体现英文字符①【:】②【,】,以空格代替
|
|
|
|
|
/*
|
|
|
|
|
* 表象:QDAC064651 客户毛重28600 EDI进来28
|
|
|
|
|
港联捷回复:是前面货名太长,后面内容截断了,每行不超过255字符就行
|
|
|
|
|
解决方案:每行不超过255,品名只取前100就行
|
|
|
|
|
*/
|
|
|
|
|
var despStr = ExchangeStr(order.DESCRIPTION.Replace(":", " ").Replace(",", " ")).Replace("\r\n", " ").Replace("\n", " ");
|
|
|
|
|
if (despStr.Length > 100)
|
|
|
|
|
{
|
|
|
|
|
despStr = despStr.Substring(0, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbData.AppendLine($"22:{despStr}:{order.PKGS}:{order.KINDPKGS}:{order.KGS}:{order.CBM}:{(order.CARGOID == "D" ? "Y" : "N")}:{order.DCLASS}:{order.DUNNO}::{order.TEMPSET}:{order.REEFERF}:{order.HUMIDITY}");//货名 件数 包装代码 总重量 总体积 危品标志 危品等级 危规号 副危品等级 副危规号 温度 通风度 湿度
|
|
|
|
|
|
|
|
|
|
var ctnCodes = commonData.Ctns.AsNoTracking().Select(x => new { x.CTN, x.CTNSIZE, x.CMACTN }).ToList();
|
|
|
|
|
var ctnEdiList = commonData.CodeCtnEdi.AsNoTracking().Where(x => x.EDINAME == "XHZ_GLJ").ToList();
|
|
|
|
|
|
|
|
|
|
var ctns = bookingDB.Ctns.Where(c => c.ORDNO == ordno).ToList();
|
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
|
{
|
|
|
|
|
var ctnFind = ctnCodes.FirstOrDefault(c => c.CTN == ctn.CTNALL);
|
|
|
|
|
if (ctnFind == null)
|
|
|
|
|
{
|
|
|
|
|
msg = $"未找到箱型 {ctn.CTNALL},请联系管理员";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctnEdi = ctnEdiList.FirstOrDefault(cc => cc.CTN == ctn.CTNALL);
|
|
|
|
|
if (ctnEdi == null)
|
|
|
|
|
{
|
|
|
|
|
msg = $"箱型({ctn.CTNALL})不匹配,无法发送下货纸,请联系管理员";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbData.AppendLine($"13:{(order.ISCONTAINERSOC == "1" ? "SOC" : order.CARRIERID)}:{ctnFind.CTNSIZE}:{ctnEdi.EDICODE}:{ctn.CTNNUM}:{ExchangeStr(ctn.REMARK)}:N");//箱经营人代码 尺寸 箱型 箱数 备注 加重箱
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Debug($"生成下货纸报文:{sbData.ToString()}");
|
|
|
|
|
File.WriteAllText(ediFile, sbData.ToString());
|
|
|
|
|
|
|
|
|
|
//后续发送
|
|
|
|
|
BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
|
|
|
|
|
ftpTask.GID = Guid.NewGuid().ToString();
|
|
|
|
|
ftpTask.FtpHost = paraServer.PARAMVALUE;
|
|
|
|
|
ftpTask.FtpUser = paraUser.PARAMVALUE;
|
|
|
|
|
ftpTask.FtpPassword = paraPwd.PARAMVALUE;
|
|
|
|
|
ftpTask.FtpData = FtpTaskHelper.GenTaskJson("", ediFile, null);
|
|
|
|
|
ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
|
|
|
|
|
commonData.BackgroundTaskFtp.Add(ftpTask);
|
|
|
|
|
commonData.SaveChanges();
|
|
|
|
|
|
|
|
|
|
//挂载附件
|
|
|
|
|
var attNew = new OP_ATTACH();
|
|
|
|
|
attNew.OP_TIME = DateTime.Now;
|
|
|
|
|
attNew.OP_USER = attShowName;
|
|
|
|
|
attNew.RELATIVEID = ordno;
|
|
|
|
|
attNew.TITLE = Path.GetFileName(ediFile);
|
|
|
|
|
attNew.GID = Guid.NewGuid().ToString();
|
|
|
|
|
attNew.FILETYPE = Path.GetExtension(ediFile);
|
|
|
|
|
attNew.ExtData = "10"; //下货纸
|
|
|
|
|
attNew.FILEPATH = ediFile;
|
|
|
|
|
bookingDB.Attaches.Add(attNew);
|
|
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
|
|
|
|
|
msg = "已发送";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 港捷丰场站 捷丰场站 NOTE:港捷丰场站和捷丰场站下货纸功能,根据东胜7同功能模块代码翻译而来
|
|
|
|
|
else if (order.YARD == "港捷丰场站" || order.YARD == "捷丰场站")
|
|
|
|
|
{
|
|
|
|
|
if (!order.PKGS.HasValue || order.PKGS.Value == 0)
|
|
|
|
|
{
|
|
|
|
|
msg = "件数不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(order.KINDPKGS))
|
|
|
|
|
{
|
|
|
|
|
msg = "件数包装不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!order.KGS.HasValue || order.KGS.Value == 0)
|
|
|
|
|
{
|
|
|
|
|
msg = "重量不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!order.CBM.HasValue || order.CBM.Value == 0)
|
|
|
|
|
{
|
|
|
|
|
msg = "尺码不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ediFile = Path.Combine(filePath, $"{order.VESSEL}_{order.VoynoCustom}_{order.MBLNO}_{DateTime.Now.Ticks}.txt");
|
|
|
|
|
CodeFtpset ftpset = null;
|
|
|
|
|
if (order.YARD == "港捷丰场站")
|
|
|
|
|
{
|
|
|
|
|
ftpset = commonData.FtpSet.AsNoTracking().FirstOrDefault(f => f.EDINAME == "XHZ_GJF" && f.CompId == order.CORPID);
|
|
|
|
|
}
|
|
|
|
|
else if (order.YARD == "捷丰场站")
|
|
|
|
|
{
|
|
|
|
|
ftpset = commonData.FtpSet.AsNoTracking().FirstOrDefault(f => f.EDINAME == "XHZ_JIEFENG" && f.CompId == order.CORPID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ftpset == null)
|
|
|
|
|
{
|
|
|
|
|
msg = "ftp设置未找到";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ediParaName = "XHZ_GJF";
|
|
|
|
|
if (order.YARD == "捷丰场站")
|
|
|
|
|
{
|
|
|
|
|
ediParaName = "XHZ_JIEFENG";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<string> listJoinStr = new List<string>();
|
|
|
|
|
listJoinStr.Add("00:IFCSUM:BK:" + filerole + ":" + ftpset.SENDCODE + ":" + ftpset.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + ":2.1'");
|
|
|
|
|
|
|
|
|
|
//提单号
|
|
|
|
|
listJoinStr.Add("02:" + order.ORDERNO.Trim() + ":" + order.MBLNO.Trim() + ":" + order.SERVICE + ":" + ftpset.SENDNAME + ":" + ftpset.RECEIVECODE + "::::::::::" + order.CONTRACTNO + "::'");
|
|
|
|
|
|
|
|
|
|
//提单地址
|
|
|
|
|
var ISSUETYPE = "";
|
|
|
|
|
if (order.ISSUETYPE == "正本")
|
|
|
|
|
{
|
|
|
|
|
ISSUETYPE = "ORI";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ISSUETYPE = "EXP";
|
|
|
|
|
}
|
|
|
|
|
listJoinStr.Add("03:" + ISSUETYPE + ":" + order.ISSUEPLACEID + ":" + order.ISSUEPLACE + ":" + GetDateStr(order.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(order.NOBILL) + ":" + order.PORTLOADID + ":" + order.PREPARDAT + ":" + order.PAYABLEAT + "::'");//美国AMS标志、加拿大AMS标志
|
|
|
|
|
|
|
|
|
|
//船
|
|
|
|
|
listJoinStr.Add("11:" + GetVesselEDICode(commonData, order.VESSEL, ediParaName) + ":" + order.VESSEL + ":" + order.VoynoCustom + ":::" + GetCustEDICode(commonData, order.CARRIERID, ediParaName) + "::" + GetDateStr(order.ETD, "yyyyMMdd") + "::::::" + order.YardContract + ":" + formatEdiStr("txt", order.YardRemark) + ":'");
|
|
|
|
|
|
|
|
|
|
//港口 (咨询韩工,代码不转换,直接传原始代码)
|
|
|
|
|
//listJoinStr.Add("12:" + GetPortEDICode(commonData, order.PLACERECEIPTID, type) + ":" + order.PLACERECEIPT + ":" + GetPortEDICode(order.PORTLOADID, type) + ":" + order.PORTLOAD + ":" + GetPortEDICode(order.PORTDISCHARGEID, type) + ":" + order.PORTDISCHARGE + ":::" + GetPortEDICode(order.PLACEDELIVERYID, type) + ":" + order.PLACEDELIVERY + ":" + GetPortEDICode(order.DESTINATIONID, type) + ":" + order.DESTINATION + "'");
|
|
|
|
|
listJoinStr.Add("12:" + order.PLACERECEIPTID + ":" + order.PLACERECEIPT + ":" + order.PORTLOADID + ":" + order.PORTLOAD + ":" + order.PORTDISCHARGEID + ":" + order.PORTDISCHARGE + ":::" + order.PLACEDELIVERYID + ":" + order.PLACEDELIVERY + ":" + order.DESTINATIONID + ":" + order.DESTINATION + "'");
|
|
|
|
|
|
|
|
|
|
//付费方式
|
|
|
|
|
var frtstr = GetFrtEDICode(commonData, order.BLFRT);
|
|
|
|
|
if (frtstr != "")
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("14:" + frtstr + ":" + order.BLFRT + "'");
|
|
|
|
|
listJoinStr.Add("15:::" + frtstr + ":::::::'");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("14:P:" + order.BLFRT + "'");
|
|
|
|
|
listJoinStr.Add("15:::P:::::::'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var Shipping = "";
|
|
|
|
|
List<string> ShippingList = null;
|
|
|
|
|
|
|
|
|
|
//2021年9月1日修改,17行取消,放到11行原FAX位置(于斐)
|
|
|
|
|
////EDI备注
|
|
|
|
|
//if (!string.IsNullOrWhiteSpace(order.YardRemark))
|
|
|
|
|
//{
|
|
|
|
|
// Shipping = formatEdiStr("txt", order.YardRemark);
|
|
|
|
|
// ShippingList = formatlengthStr(Shipping, 70);
|
|
|
|
|
// if (Shipping != "")
|
|
|
|
|
// {
|
|
|
|
|
// listJoinStr.Add("17:" + formatListStr(ShippingList, 5) + "'");
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//发货人
|
|
|
|
|
Shipping = formatEdiStr("txt", order.SHIPPER);
|
|
|
|
|
ShippingList = formatlengthStr(Shipping, 35);
|
|
|
|
|
if (ShippingList.Count != 0 && Shipping.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("18::" + formatListStr(ShippingList, 6) + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//收货人
|
|
|
|
|
Shipping = formatEdiStr("txt", order.CONSIGNEE);
|
|
|
|
|
ShippingList = formatlengthStr(Shipping, 35);
|
|
|
|
|
if (ShippingList.Count != 0 && Shipping.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("19::" + formatListStr(ShippingList, 6) + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通知人
|
|
|
|
|
Shipping = formatEdiStr("txt", order.NOTIFYPARTY);
|
|
|
|
|
ShippingList = formatlengthStr(Shipping, 35);
|
|
|
|
|
if (ShippingList.Count != 0 && Shipping.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("20::" + formatListStr(ShippingList, 6) + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//货物标识
|
|
|
|
|
var cargoid = order.CARGOID;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(cargoid))
|
|
|
|
|
{
|
|
|
|
|
cargoid = "S";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listJoinStr.Add("41:1::" + cargoid + ":" + order.PKGS.ToString() + ":" + order.KINDPKGS + ":" + order.KINDPKGS + ":" + order.KGS.ToString() + ":" + order.CBM.ToString() + "::::::" + order.KGS.ToString() + ":::'");//bill.HSCODE
|
|
|
|
|
|
|
|
|
|
if (cargoid == "R")
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("43:::::::::::" + order.REEFERF + ":C:" + order.TEMPSET + ":" + order.TEMPMIN + ":" + order.TEMPMAX + "::::::" + order.HUMIDITY + "::::'");
|
|
|
|
|
}
|
|
|
|
|
else if (cargoid == "D")
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("43:" + order.DCLASS + ":" + order.DPAGE + ":" + order.DUNNO + ":" + order.DLABEL + "::::::::::::::::::::'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//唛头
|
|
|
|
|
Shipping = formatEdiStr("txt", order.MARKS);
|
|
|
|
|
ShippingList = formatlengthStr(Shipping, 35);
|
|
|
|
|
for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(9))); i++)
|
|
|
|
|
{
|
|
|
|
|
var tempstr = "44:";
|
|
|
|
|
for (var z = 0; z < 9; z++)
|
|
|
|
|
{
|
|
|
|
|
if ((i * 9 + z) < ShippingList.Count)
|
|
|
|
|
tempstr = tempstr + ShippingList[i * 9 + z];
|
|
|
|
|
if (z < 8) tempstr = tempstr + ":";
|
|
|
|
|
}
|
|
|
|
|
if (tempstr != "44:")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
listJoinStr.Add(tempstr + "'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//货物描述
|
|
|
|
|
Shipping = formatEdiStr("txt", order.DESCRIPTION);
|
|
|
|
|
ShippingList = formatlengthStr(Shipping, 70);
|
|
|
|
|
var m = 1;
|
|
|
|
|
var strtemp = "";
|
|
|
|
|
if (ShippingList.Count != 0 && Shipping.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < ShippingList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (m <= 5)
|
|
|
|
|
{
|
|
|
|
|
if (m == 1) strtemp = "47:" + ShippingList[i] + ":";
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m == 5)
|
|
|
|
|
strtemp = strtemp + ShippingList[i];
|
|
|
|
|
else
|
|
|
|
|
strtemp = strtemp + ShippingList[i] + ":";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m = 1;
|
|
|
|
|
listJoinStr.Add(strtemp + "'");
|
|
|
|
|
strtemp = "47:" + ShippingList[i] + ":";
|
|
|
|
|
}
|
|
|
|
|
m = m + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strtemp != "")
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add(strtemp + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//集装箱
|
|
|
|
|
var ctns = bookingDB.Ctns.AsNoTracking().Where(c => c.ORDNO == order.ORDNO).ToList();
|
|
|
|
|
var groupList = ctns.Where(c => c.CTNNUM.HasValue).GroupBy(c => c.CTNALL).Select(c => new { c.Key, CTNNUM = c.Sum(cc => cc.CTNNUM) }).ToList();
|
|
|
|
|
foreach (var g in groupList)
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("48:" + GetCtnEDICode(commonData, g.Key, ediParaName) + ":" + g.CTNNUM + $":F:::::{(order.ISCONTAINERSOC == "1" ? "Y" : "N")}'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
|
{
|
|
|
|
|
if (ctn.CNTRNO != "")
|
|
|
|
|
{
|
|
|
|
|
listJoinStr.Add("51:" + ctn.CNTRNO + ":" + GetCtnEDICode(commonData, ctn.CTNALL, ediParaName) + ":" + ctn.SEALNO + ":M:CA:F:" + ctn.PKGS.ToString() + ":" + ctn.KGS.ToString() + "::" + ctn.CBM + "'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listJoinStr.Add("99:" + listJoinStr.Count + 1 + "'");
|
|
|
|
|
|
|
|
|
|
var strJoin = string.Join(Environment.NewLine, listJoinStr);
|
|
|
|
|
log.Debug($"生成下货纸报文:{strJoin}");
|
|
|
|
|
File.WriteAllText(ediFile, strJoin, Encoding.Default);
|
|
|
|
|
|
|
|
|
|
//后续发送
|
|
|
|
|
BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
|
|
|
|
|
ftpTask.GID = Guid.NewGuid().ToString();
|
|
|
|
|
ftpTask.FtpHost = ftpset.SERVERIP;
|
|
|
|
|
ftpTask.FtpUser = ftpset.USERNAME;
|
|
|
|
|
ftpTask.FtpPassword = ftpset.PASSWORD;
|
|
|
|
|
ftpTask.FtpData = FtpTaskHelper.GenTaskJson(ftpset.FOLDERNAME, ediFile, null);
|
|
|
|
|
ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
|
|
|
|
|
commonData.BackgroundTaskFtp.Add(ftpTask);
|
|
|
|
|
commonData.SaveChanges();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//挂载附件
|
|
|
|
|
var attNew = new OP_ATTACH();
|
|
|
|
|
attNew.OP_TIME = DateTime.Now;
|
|
|
|
|
attNew.OP_USER = attShowName;
|
|
|
|
|
attNew.RELATIVEID = ordno;
|
|
|
|
|
attNew.TITLE = Path.GetFileName(ediFile);
|
|
|
|
|
attNew.GID = Guid.NewGuid().ToString();
|
|
|
|
|
attNew.FILETYPE = Path.GetExtension(ediFile);
|
|
|
|
|
attNew.ExtData = "10"; //下货纸
|
|
|
|
|
attNew.FILEPATH = ediFile;
|
|
|
|
|
bookingDB.Attaches.Add(attNew);
|
|
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
|
|
|
|
|
msg = "完成";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 港联欣场站
|
|
|
|
|
else if (order.YARD == "港联欣场站" || order.YARD == "中创场站")
|
|
|
|
|
{
|
|
|
|
|
//2022年6月15日增加:港联欣场站若配置了通过港联捷EDI发送,则使用港联捷报文格式
|
|
|
|
|
var pGlxEdi = commonData.ParamValues.AsNoTracking().FirstOrDefault(x => x.CompId == opUser.CompId && x.ParaCode == "XIAHUOZHI_GLX_SEND_TYPE");
|
|
|
|
|
if (order.YARD == "港联欣场站" && pGlxEdi != null && pGlxEdi.ItemCode == "EDI_GLJ")
|
|
|
|
|
{
|
|
|
|
|
var ftpset = commonData.FtpSet.AsNoTracking().FirstOrDefault(f => f.EDINAME == "XHZ_GLX" && f.CompId == order.CORPID);
|
|
|
|
|
if (ftpset == null)
|
|
|
|
|
{
|
|
|
|
|
msg = "港联欣下货纸ftp设置未找到";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var paraXHZ = commonData.ParamValues.AsNoTracking().FirstOrDefault(p => p.CompId == order.CORPID && p.ParaCode == "CODE_GLX_XHZ");
|
|
|
|
|
if (paraXHZ == null || string.IsNullOrEmpty(paraXHZ.ItemCode))
|
|
|
|
|
{
|
|
|
|
|
msg = "下货纸代号未找到或配置有误";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ediFile = Path.Combine(filePath, $"{paraXHZ.ItemCode}_{order.MBLNO}_{DateTime.Now.Ticks}.txt");
|
|
|
|
|
|
|
|
|
|
StringBuilder sbData = new StringBuilder();
|
|
|
|
|
sbData.AppendLine($"01:{order.VESSEL}:{order.VoynoCustom}"); //船名 航次
|
|
|
|
|
sbData.AppendLine($"12:{order.MBLNO}:{order.TRANSPORTID}:{order.PORTDISCHARGEID}:{paraXHZ.ItemCode}:{order.CARRIERID}::{order.PORTDISCHARGE}"); //主提单 中转港代码 目的港代码 货代代码 船公司 HPL参考号 备注
|
|
|
|
|
var despStr = ExchangeStr(order.DESCRIPTION.Replace(":", " ").Replace(",", " ")).Replace("\r\n", " ").Replace("\n", " ");
|
|
|
|
|
if (despStr.Length > 100)
|
|
|
|
|
{
|
|
|
|
|
despStr = despStr.Substring(0, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbData.AppendLine($"22:{despStr}:{order.PKGS}:{order.KINDPKGS}:{order.KGS}:{order.CBM}:{(order.CARGOID == "D" ? "Y" : "N")}:{order.DCLASS}:{order.DUNNO}::::{order.TEMPSET}:{order.REEFERF}:{order.HUMIDITY}:");//货名 件数 包装代码 总重量 总体积 危品标志 危品等级 危规号 副危品等级 副危规号 温度 通风度 湿度
|
|
|
|
|
|
|
|
|
|
var ctnCodes = commonData.Ctns.AsNoTracking().Select(x => new { x.CTN, x.CTNSIZE, x.CMACTN }).ToList();
|
|
|
|
|
var ctnEdiList = commonData.CodeCtnEdi.AsNoTracking().Where(x => x.EDINAME == "XHZ_GLX").ToList();
|
|
|
|
|
|
|
|
|
|
var ctns = bookingDB.Ctns.Where(c => c.ORDNO == ordno).ToList();
|
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
|
{
|
|
|
|
|
var ctnFind = ctnCodes.FirstOrDefault(c => c.CTN == ctn.CTNALL);
|
|
|
|
|
if (ctnFind == null)
|
|
|
|
|
{
|
|
|
|
|
msg = $"未找到箱型 {ctn.CTNALL},请联系管理员";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctnEdi = ctnEdiList.FirstOrDefault(cc => cc.CTN == ctn.CTNALL);
|
|
|
|
|
if (ctnEdi == null)
|
|
|
|
|
{
|
|
|
|
|
msg = $"箱型({ctn.CTNALL})不匹配,无法发送下货纸,请联系管理员";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbData.AppendLine($"13:{(order.ISCONTAINERSOC == "1" ? "SOC" : order.CARRIERID)}:{ctnFind.CTNSIZE}:{ctnEdi.EDICODE}:{ctn.CTNNUM}:{ExchangeStr(ctn.REMARK)}:N");//箱经营人代码 尺寸 箱型 箱数 备注 加重箱
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Debug($"生成下货纸报文:{sbData.ToString()}");
|
|
|
|
|
File.WriteAllText(ediFile, sbData.ToString());
|
|
|
|
|
|
|
|
|
|
//后续发送
|
|
|
|
|
BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
|
|
|
|
|
ftpTask.GID = Guid.NewGuid().ToString();
|
|
|
|
|
ftpTask.FtpHost = ftpset.SERVERIP;
|
|
|
|
|
ftpTask.FtpUser = ftpset.USERNAME;
|
|
|
|
|
ftpTask.FtpPassword = ftpset.PASSWORD;
|
|
|
|
|
ftpTask.FtpData = FtpTaskHelper.GenTaskJson("", ediFile, null);
|
|
|
|
|
ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
|
|
|
|
|
commonData.BackgroundTaskFtp.Add(ftpTask);
|
|
|
|
|
commonData.SaveChanges();
|
|
|
|
|
|
|
|
|
|
//挂载附件
|
|
|
|
|
var attNew = new OP_ATTACH();
|
|
|
|
|
attNew.OP_TIME = DateTime.Now;
|
|
|
|
|
attNew.OP_USER = attShowName;
|
|
|
|
|
attNew.RELATIVEID = ordno;
|
|
|
|
|
attNew.TITLE = Path.GetFileName(ediFile);
|
|
|
|
|
attNew.GID = Guid.NewGuid().ToString();
|
|
|
|
|
attNew.FILETYPE = Path.GetExtension(ediFile);
|
|
|
|
|
attNew.ExtData = "10"; //下货纸
|
|
|
|
|
attNew.FILEPATH = ediFile;
|
|
|
|
|
bookingDB.Attaches.Add(attNew);
|
|
|
|
|
bookingDB.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
else //邮件方式
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(order.YardContractEmail))
|
|
|
|
|
{
|
|
|
|
|
msg = "场站联系人邮箱不能为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
MailDataContext mailData = new MailDataContext();
|
|
|
|
|
var userMail = mailData.UserAccounts.AsNoTracking().FirstOrDefault(ua => ua.UserId == order.USERID);
|
|
|
|
|
if (userMail == null
|
|
|
|
|
|| string.IsNullOrEmpty(userMail.SmtpServer)
|
|
|
|
|
|| userMail.SmtpPort == 0)
|
|
|
|
|
{
|
|
|
|
|
msg = "发件邮箱未配置";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var comp = commonData.CompanyNew.AsNoTracking().First(c => c.CompId == order.CORPID);
|
|
|
|
|
var userbase = commonData.UserBases.AsNoTracking().First(ub => ub.USERID == order.USERID);
|
|
|
|
|
var title = $"下货纸:{order.MBLNO}/{order.CARRIER}/{order.VESSEL}/{order.VoynoCustom}/{order.CompName}";
|
|
|
|
|
|
|
|
|
|
var bodyExt = string.Empty;
|
|
|
|
|
if (order.CARGOID == "R")
|
|
|
|
|
{
|
|
|
|
|
bodyExt = $@"温度:{order.TEMPSET}{order.TEMPID}<br/>
|
|
|
|
|
通风:{order.REEFERF}<br/>
|
|
|
|
|
湿度:{order.HUMIDITY}<br/>";
|
|
|
|
|
}
|
|
|
|
|
else if (order.CARGOID == "D")
|
|
|
|
|
{
|
|
|
|
|
bodyExt = $@"危险品等级:{order.DCLASS}<br/>
|
|
|
|
|
危险品编号:{order.DUNNO}<br/>
|
|
|
|
|
危险品联系方式:{order.LINKMAN}<br/>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var body = $@"提单号:{order.MBLNO}<br/>
|
|
|
|
|
船名航次:{order.VESSEL}/{order.VoynoCustom}<br/>
|
|
|
|
|
起运港:{order.PORTLOAD},{order.PORTLOADID}<br/>
|
|
|
|
|
目的港:{order.PORTDISCHARGE},{order.PORTDISCHARGEID}<br/>
|
|
|
|
|
目的地:{order.DESTINATION},{order.DESTINATIONID}<br/>
|
|
|
|
|
预计船期:{(order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : "")}<br/>
|
|
|
|
|
箱型箱量:{order.CNTRTOTAL}<br/>
|
|
|
|
|
件重尺:{order.PKGS} {order.KINDPKGS}/{order.KGS}KGS/{order.CBM}CBM<br/>
|
|
|
|
|
货物描述:{order.DESCRIPTION}<br/>
|
|
|
|
|
{bodyExt}
|
|
|
|
|
备注:{order.YardRemark}<br/>
|
|
|
|
|
<br/>
|
|
|
|
|
订舱代理:{order.CompName}<br/>
|
|
|
|
|
联系人:{order.INPUTBY}<br/>
|
|
|
|
|
地址:{comp.Address}<br/>
|
|
|
|
|
电话:{userbase.OFFICEPHONE} 手机:{userbase.MOBILE}<br/>
|
|
|
|
|
邮箱:{userbase.EMAIL1}<br/>
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
MailHelper.SendMail(userMail.GID, title, body, order.YardContractEmail, customerSend: true);
|
|
|
|
|
}
|
|
|
|
|
msg = "已发送";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
msg = "不支持的场站";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//转义处理字符串中的特殊字符
|
|
|
|
|
private static string ExchangeStr(string str)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(str))
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str.Replace("?", "??").Replace("'", "?'").Replace("+", "?+").Replace(":", "?:");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据船名,获取船名edi代码(根据东胜7同功能模块代码翻译而成)
|
|
|
|
|
public static string GetVesselEDICode(CommonDataContext commonData, string vessel, string EDINAME)
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = "";
|
|
|
|
|
vessel = vessel.Replace("'", "''");
|
|
|
|
|
|
|
|
|
|
var codeVesselEdi = commonData.CodeVesselEdi.AsNoTracking().FirstOrDefault(v => v.VESSEL == vessel && v.EDINAME == EDINAME);
|
|
|
|
|
if (codeVesselEdi != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = codeVesselEdi.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(EDICODE))
|
|
|
|
|
{
|
|
|
|
|
var codeVessel = commonData.Vessels.AsNoTracking().FirstOrDefault(v => v.VESSEL == vessel);
|
|
|
|
|
if (codeVessel != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = codeVessel.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取时间字符串
|
|
|
|
|
public static string GetDateStr(DateTime? dt, string dateformat)
|
|
|
|
|
{
|
|
|
|
|
var result = "";
|
|
|
|
|
if (!dt.HasValue)
|
|
|
|
|
{
|
|
|
|
|
result = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = dt.Value.ToString(dateformat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取客户edi代码(根据东胜7同功能模块代码翻译而成)
|
|
|
|
|
public static string GetCustEDICode(CommonDataContext commonData, string CUST, string EDINAME)
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = "";
|
|
|
|
|
CUST = CUST.Replace("'", "''");
|
|
|
|
|
|
|
|
|
|
var custEdi = commonData.CodeCustEdi.AsNoTracking().FirstOrDefault(c => c.CUST == CUST && c.EDINAME == EDINAME);
|
|
|
|
|
if (custEdi != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = custEdi.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(EDICODE))
|
|
|
|
|
{
|
|
|
|
|
var infoclient = commonData.InfoClients.AsNoTracking().FirstOrDefault(c => c.SHORTNAME == CUST);
|
|
|
|
|
if (infoclient != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = infoclient.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取港口edi代码(根据东胜7同功能模块代码翻译而成)
|
|
|
|
|
public static string GetPortEDICode(CommonDataContext commonData, string port, string EDINAME = "")
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = port;
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
if (string.IsNullOrEmpty(EDINAME))
|
|
|
|
|
{
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var custEdi = commonData.CodeDisportEdi.AsNoTracking().FirstOrDefault(c => c.PORTID == port && c.EDINAME == EDINAME);
|
|
|
|
|
if (custEdi != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = custEdi.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取付费方式edi代码(根据东胜7同功能模块代码翻译而成)
|
|
|
|
|
public static string GetFrtEDICode(CommonDataContext commonData, string FRT)
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = "P";
|
|
|
|
|
|
|
|
|
|
var ediFRT = commonData.Frts.AsNoTracking().FirstOrDefault(c => c.FRT == FRT);
|
|
|
|
|
if (ediFRT != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = ediFRT.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取edi代码(根据东胜7同功能模块移植)
|
|
|
|
|
public static string GetBillNum2(string str)
|
|
|
|
|
{
|
|
|
|
|
if (str == "ZERO") return "00";
|
|
|
|
|
if (str == "ONE") return "01";
|
|
|
|
|
if (str == "TWO") return "02";
|
|
|
|
|
if (str == "THREE") return "03";
|
|
|
|
|
if (str == "FOUR") return "04";
|
|
|
|
|
if (str == "FIVE") return "05";
|
|
|
|
|
if (str == "SIX") return "06";
|
|
|
|
|
if (str == "SERVEN") return "07";
|
|
|
|
|
if (str == "EIGHT") return "08";
|
|
|
|
|
if (str == "NINE") return "09";
|
|
|
|
|
if (str == "TEN") return "10";
|
|
|
|
|
else return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 各种文本转义字符(东胜7移植)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileType">文件类型(例如:txt、xml)</param>
|
|
|
|
|
/// <param name="str">文本字符串</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string formatEdiStr(string fileType, string str)
|
|
|
|
|
{
|
|
|
|
|
if (str == null)
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fileType == "txt")
|
|
|
|
|
{
|
|
|
|
|
return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
|
|
|
|
|
}
|
|
|
|
|
else if (fileType == "xml")
|
|
|
|
|
{
|
|
|
|
|
return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
|
|
|
|
|
}
|
|
|
|
|
else if (fileType == "sitc")
|
|
|
|
|
{
|
|
|
|
|
return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//东胜7移植
|
|
|
|
|
public static List<string> formatlengthStr(string str, int length, bool formatstr = false, bool nodelsp = false)
|
|
|
|
|
{
|
|
|
|
|
str = str.Replace("\r\n", "\\");
|
|
|
|
|
str = str.Replace("\n", "\\");
|
|
|
|
|
str = str.Replace("\r", " ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] StrList = str.Split('\\');
|
|
|
|
|
|
|
|
|
|
//List<System.String> StrListtmp = new List<System.String>();
|
|
|
|
|
//for (var i = StrList.Length - 1; i >=0; i--)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var strtemp = "";
|
|
|
|
|
var strnewline = "";
|
|
|
|
|
var strtempnewline = "";
|
|
|
|
|
char[] spstring = { ' ', ';', ',', '.', ':', '/', '(', ')', '?', '+', '-' };
|
|
|
|
|
List<System.String> DestList = new List<System.String>();
|
|
|
|
|
for (var i = 0; i <= StrList.Length - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (StrList[i].Length <= length)
|
|
|
|
|
{
|
|
|
|
|
if (formatstr)
|
|
|
|
|
DestList.Add(formatEdiStr("txt", StrList[i]));
|
|
|
|
|
else
|
|
|
|
|
DestList.Add(StrList[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strtemp = StrList[i] + " ";
|
|
|
|
|
strtempnewline = "";
|
|
|
|
|
strnewline = "";
|
|
|
|
|
for (var j = 0; j < strtemp.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
strtempnewline = strtempnewline + strtemp[j];
|
|
|
|
|
if (strtemp[j] == ' ' || strtemp[j] == ':' || strtemp[j] == ',' || strtemp[j] == '.' || strtemp[j] == ':' || strtemp[j] == '/'
|
|
|
|
|
|| strtemp[j] == '?' || strtemp[j] == ')' || strtemp[j] == '}' || strtemp[j] == '+' || strtemp[j] == '-')
|
|
|
|
|
{
|
|
|
|
|
if ((strnewline.Length + strtempnewline.Length) <= length)
|
|
|
|
|
strnewline = strnewline + strtempnewline;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (formatstr)
|
|
|
|
|
DestList.Add(formatEdiStr("txt", strnewline));
|
|
|
|
|
else
|
|
|
|
|
DestList.Add(strnewline);
|
|
|
|
|
strnewline = strtempnewline;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strtempnewline = "";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (nodelsp)
|
|
|
|
|
{
|
|
|
|
|
if (formatstr)
|
|
|
|
|
DestList.Add(formatEdiStr("txt", strnewline));
|
|
|
|
|
else DestList.Add(strnewline);
|
|
|
|
|
}
|
|
|
|
|
else if (strnewline.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
if (formatstr)
|
|
|
|
|
DestList.Add(formatEdiStr("txt", strnewline));
|
|
|
|
|
else DestList.Add(strnewline);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DestList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//东胜7移植
|
|
|
|
|
public static string formatListStr(List<string> DestList, int lineCount)
|
|
|
|
|
{
|
|
|
|
|
var result = "";
|
|
|
|
|
for (var i = 0; i < lineCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (DestList.Count > i)
|
|
|
|
|
{
|
|
|
|
|
result = result + DestList[i];
|
|
|
|
|
}
|
|
|
|
|
if (i != (lineCount - 1))
|
|
|
|
|
result = result + ":";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//东胜7移植
|
|
|
|
|
public static string GetCtnEDICode(CommonDataContext commonData, string Ctn, string EDINAME)
|
|
|
|
|
{
|
|
|
|
|
string EDICODE = "";
|
|
|
|
|
Ctn = Ctn.Replace("'", "''");
|
|
|
|
|
|
|
|
|
|
var ctnEdi = commonData.CodeCtnEdi.AsNoTracking().FirstOrDefault(c => c.CTN == Ctn && c.EDINAME == EDINAME);
|
|
|
|
|
if (ctnEdi != null)
|
|
|
|
|
{
|
|
|
|
|
EDICODE = ctnEdi.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(EDICODE))
|
|
|
|
|
{
|
|
|
|
|
var codeCtn = commonData.Ctns.AsNoTracking().FirstOrDefault(c => c.CTN == Ctn);
|
|
|
|
|
EDICODE = codeCtn.EDICODE.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EDICODE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|