From c42a8402b8638d1a9a37e6865fe934e978a95fa1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 13 Nov 2024 10:14:38 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=B5=8B=E8=AF=95html=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ServiceProjectSyncWin/Program.cs | 690 +++++++++++++++++++++++++++++++ 1 file changed, 690 insertions(+) diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index 8239c339..6ae4ce9c 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -27,6 +27,8 @@ using static System.Net.Mime.MediaTypeNames; using RabbitMQ.Client.Events; using Org.BouncyCastle.Utilities.Bzip2; using ICSharpCode.SharpZipLib.BZip2; +using StackExchange.Profiling.Internal; +using System.Drawing; Serve.RunGeneric(additional: services => { @@ -796,6 +798,694 @@ public class SyncHisRecord: ISyncHisRecord,ITransient /* 按照舱位提取未识别合约号的记录,重新调取 */ + string mailFilePath = "C:\\Users\\Administrator\\Desktop\\日志\\Your Transport Plan has Changed - Maersk241111.eml"; + //string mailFilePath = "C:\\Users\\Administrator\\Desktop\\日志\\Your Transport Plan has Changed - Maersk-带reason.eml"; + + + //读取邮件,解析邮件正文 + MimeMessage mimeMsg = MimeMessage.Load(mailFilePath); + + + HtmlDocument html = new HtmlDocument(); + html.LoadHtml(mimeMsg.HtmlBody); + + var divWrapperList = html.DocumentNode.SelectNodes("//div[@class='wrapper']"); + + int perNum = divWrapperList.Count / 4; + + List list = new List(); + + int start = 1; + int currListIdx = 0; + + for (int i = 0; i < divWrapperList.Count; i++) + { + /* + 每隔4行算一票数据 + 1、第一行 BILLNO, 原因 + 2、第二行 装货港、ETD、卸货港、ETA、船名 + 3、第三行 集装箱 + */ + if (start == 1) + { + #region 第一行 BILLNO, 原因 + TransPlanHasChangeDto dto = new TransPlanHasChangeDto + { + From = new TransPlanHasChangeDetailDto + { + portList = new List(), + dateList = new List(), + vesselList = new List() + }, + To = new TransPlanHasChangeDetailDto + { + portList = new List(), + dateList = new List(), + vesselList = new List() + }, + Carrier = "MSK", + ContaNoList = new List() + }; + + list.Add(dto); + + currListIdx = list.Count - 1; + + var billnoNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[1]/td[1]/div"); + + if (billnoNode != null && !string.IsNullOrWhiteSpace(billnoNode.InnerText)) + { + var s = billnoNode.InnerText; + + if (Regex.IsMatch(s, "Bill\\s+of\\s+Lading\\s{0,}:")) + { + var name = Regex.Match(s, "Bill\\s+of\\s+Lading\\s{0,}:").Value; + + list[currListIdx].BillNo = Regex.Match(s, "(?<=" + name + ")\\s{0,}\\w+").Value?.Trim(); + } + } + + var bookNoNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/div"); + + if (bookNoNode != null && !string.IsNullOrWhiteSpace(bookNoNode.InnerText)) + { + var s = bookNoNode.InnerText; + + if (Regex.IsMatch(s, "Booking\\s+Number\\s{0,}:")) + { + var name = Regex.Match(s, "Booking\\s+Number\\s{0,}:").Value; + + list[currListIdx].BookingNo = Regex.Match(s, "(?<=" + name + ")\\s{0,}\\w+").Value?.Trim(); + } + } + + var reasonNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[1]/td[1]/div"); + + if (reasonNode != null && !string.IsNullOrWhiteSpace(reasonNode.InnerText) && + Regex.IsMatch(reasonNode.InnerText, "Reason\\s+for\\s+the\\s+change:")) + { + var reasonTxtNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/div"); + + if (reasonTxtNode != null && !string.IsNullOrWhiteSpace(reasonTxtNode.InnerText)) + { + list[currListIdx].ChangeReasonNotes = reasonTxtNode.InnerText; + } + } + #endregion + } + else if (start == 3) + { + #region 处理装货港 + TransPlanHasChangePortDto from = null; + TransPlanHasChangePortDto from2 = null; + + var loadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/b"); + + if (loadPortNode != null && !string.IsNullOrWhiteSpace(loadPortNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(loadPortNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + from = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from.PortName = sArg[0].Trim(); + from.TerminalName = sArg[1].Trim(); + } + } + } + else + { + loadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div"); + + if (loadPortNode != null && !string.IsNullOrWhiteSpace(loadPortNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(loadPortNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + from = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from.PortName = sArg[0].Trim(); + from.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (from != null) + { + list[currListIdx].From.portList.Add(from); + } + + var wasLoadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/div"); + + if (wasLoadPortNode != null && !string.IsNullOrWhiteSpace(wasLoadPortNode.InnerText)) + { + var s = wasLoadPortNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + from2 = new TransPlanHasChangePortDto + { + Indx = 2, + PortName = s.Trim(), + IsRemoved = true, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from2.PortName = sArg[0].Trim(); + from2.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (from2 != null) + { + list[currListIdx].From.portList.Add(from2); + } + #endregion + + #region 处理ETD + TransPlanHasChangeDateDto fromETD = null; + TransPlanHasChangeDateDto fromETD2 = null; + + var etdNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/b"); + + if (etdNode != null && !string.IsNullOrWhiteSpace(etdNode.InnerText)) + { + var s = etdNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s,","," "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = etd, + OrigDateTxt = Regex.Replace(etdNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + else + { + etdNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div"); + + if (etdNode != null && !string.IsNullOrWhiteSpace(etdNode.InnerText)) + { + var s = etdNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = etd, + OrigDateTxt = Regex.Replace(etdNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + } + + if (fromETD != null) + { + list[currListIdx].From.dateList.Add(fromETD); + } + + var wasETDNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/div"); + + if (wasETDNode != null && !string.IsNullOrWhiteSpace(wasETDNode.InnerText)) + { + var s = wasETDNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD2 = new TransPlanHasChangeDateDto + { + Indx = 2, + DateVal = etd, + OrigDateTxt = Regex.Replace(wasETDNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = true, + }; + } + } + + if (fromETD2 != null) + { + list[currListIdx].From.dateList.Add(fromETD2); + } + #endregion + + #region 处理船名 + TransPlanHasChangeVesselVoynoDto vessel = null; + TransPlanHasChangeVesselVoynoDto vessel2 = null; + + var vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/b"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vessel = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + else + { + vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vessel = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + } + + if (vessel != null) + { + list[currListIdx].From.vesselList.Add(vessel); + } + + var wasVesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/div"); + + if (wasVesselNode != null && !string.IsNullOrWhiteSpace(wasVesselNode.InnerText)) + { + var s = wasVesselNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + vessel2 = new TransPlanHasChangeVesselVoynoDto + { + Indx = 2, + Vessel = s.Trim(), + IsRemoved = true, + }; + } + } + + if (vessel2 != null) + { + list[currListIdx].From.vesselList.Add(vessel2); + } + #endregion + + + #region 处理卸货港 + TransPlanHasChangePortDto to = null; + TransPlanHasChangePortDto to2 = null; + + var dischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/b"); + + if (dischargeNode != null && !string.IsNullOrWhiteSpace(dischargeNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(dischargeNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + to = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to.PortName = sArg[0].Trim(); + to.TerminalName = sArg[1].Trim(); + } + } + } + else + { + dischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div"); + + if (dischargeNode != null && !string.IsNullOrWhiteSpace(dischargeNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(dischargeNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + to = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to.PortName = sArg[0].Trim(); + to.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (to != null) + { + list[currListIdx].To.portList.Add(to); + } + + var wasDischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/div"); + + if (wasDischargeNode != null && !string.IsNullOrWhiteSpace(wasDischargeNode.InnerText)) + { + var s = wasDischargeNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + to2 = new TransPlanHasChangePortDto + { + Indx = 2, + PortName = s.Trim(), + IsRemoved = true, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to2.PortName = sArg[0].Trim(); + to2.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (to2 != null) + { + list[currListIdx].To.portList.Add(to2); + } + #endregion + + #region 处理ETD + TransPlanHasChangeDateDto toETA = null; + TransPlanHasChangeDateDto toETA2 = null; + + var etaNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/b"); + + if (etaNode != null && !string.IsNullOrWhiteSpace(etaNode.InnerText)) + { + var s = etaNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = eta, + OrigDateTxt = Regex.Replace(etaNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + else + { + etaNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div"); + + if (etaNode != null && !string.IsNullOrWhiteSpace(etaNode.InnerText)) + { + var s = etaNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = eta, + OrigDateTxt = Regex.Replace(etaNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + } + + if (toETA != null) + { + list[currListIdx].To.dateList.Add(toETA); + } + + var wasETANode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/div"); + + if (wasETANode != null && !string.IsNullOrWhiteSpace(wasETANode.InnerText)) + { + var s = wasETANode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA2 = new TransPlanHasChangeDateDto + { + Indx = 2, + DateVal = eta, + OrigDateTxt = Regex.Replace(wasETANode.InnerText, "\r\n", " ").Trim(), + IsRemoved = true, + }; + } + } + + if (toETA2 != null) + { + list[currListIdx].To.dateList.Add(toETA2); + } + #endregion + + #region 处理船名 + TransPlanHasChangeVesselVoynoDto vesselPOD = null; + TransPlanHasChangeVesselVoynoDto vesselPOD2 = null; + + var vesselPODNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/b"); + + if (vesselPODNode != null && !string.IsNullOrWhiteSpace(vesselPODNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselPODNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vesselPOD = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + else + { + vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vesselPOD = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + } + + if (vesselPOD != null) + { + list[currListIdx].To.vesselList.Add(vesselPOD); + } + + var wasVesselPODNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/div"); + + if (wasVesselPODNode != null && !string.IsNullOrWhiteSpace(wasVesselPODNode.InnerText)) + { + var s = wasVesselPODNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + vesselPOD2 = new TransPlanHasChangeVesselVoynoDto + { + Indx = 2, + Vessel = s.Trim(), + IsRemoved = true, + }; + } + } + + if (vesselPOD2 != null) + { + list[currListIdx].To.vesselList.Add(vesselPOD2); + } + #endregion + } + + + //每4行处理一次 + if ((start + 1) == 5) + { + start = 1; + } + else + { + start++; + } + } + + + var jsonRlt = JSON.Serialize(list); + + } + + public string SplitSubjectValue(string subjectText, string strStart, string strEnd = null) + { + var startIdx = subjectText.IndexOf(strStart); + if (startIdx > -1) + { + subjectText = subjectText.Substring(startIdx + strStart.Length); + + if (!string.IsNullOrEmpty(strEnd)) + { + startIdx = subjectText.IndexOf(strEnd); + if (startIdx > -1) + { + subjectText = subjectText.Substring(0, startIdx); + } + } + + return subjectText.Trim(); + } + + return string.Empty; + } + + /// + /// 文本类型的正文,根据条件提取字段内容 + /// + /// 邮件正文(文本类型) + /// 行起始关键字文本 + /// 行结束关键字文本 + /// 从指定行之后提取 + /// + public string SplitFieldValue(string bodyText, string strStart, string strEnd = null, string afterLine = null) + { + var lines = bodyText.Split("\r\n".ToArray(), StringSplitOptions.RemoveEmptyEntries); + var findArr = new List(lines); + if (!string.IsNullOrEmpty(afterLine)) + { + var strList = findArr.Where(l => l.Trim().StartsWith(afterLine)).ToList(); + if (strList.Count > 0) + { + var idx = findArr.IndexOf(strList[0]); + if (idx > -1) + { + findArr.RemoveRange(0, idx + 1); + } + } + } + + //没有开始标志,取afterLine的下一行 + if (string.IsNullOrEmpty(strStart) && !string.IsNullOrEmpty(afterLine)) + { + return findArr[0].Trim(); + } + else + { + var lineFind = findArr.FirstOrDefault(x => x.Trim().StartsWith(strStart)); + if (lineFind != null) + { + if (string.IsNullOrEmpty(strEnd)) + { + return lineFind.Replace(strStart, "").Trim(); + } + else + { + var tmp = lineFind.Substring(strStart.Length); + var endIdx = tmp.IndexOf(strEnd); + if (endIdx == -1) + { + return tmp.Trim(); + } + else + { + return tmp.Substring(0, endIdx).Trim(); + } + } + } + } + + return string.Empty; } public void SyncServiceProjectRecord5() From cbdc6abdaee4cf4bcef16ea37cda9f174fd0a901 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 15 Nov 2024 17:33:09 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingSlotChangeRecord.cs | 71 +++++++++++++++++++ .../BookingSlotChangeRecordNotify.cs | 12 ++++ .../Myshipping.Application.csproj | 1 + 3 files changed, 84 insertions(+) create mode 100644 Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs create mode 100644 Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs diff --git a/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs new file mode 100644 index 00000000..bb905731 --- /dev/null +++ b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using Myshipping.Core.Entity; +using System.ComponentModel; + +namespace Myshipping.Application +{ + /// + /// 舱位管理主信息 + /// + [SugarTable("booking_slot_base", TableDescription = "舱位管理主信息")] + public class BookingSlotChangeRecord : DBEntityTenant + { + /// + /// 舱位主键 + /// + [SugarColumn(ColumnName = "SLOT_ID")] + [Description("舱位主键")] + public Nullable SLOT_ID { get; set; } + + /// + /// 订单主键 + /// + [SugarColumn(ColumnName = "BOOKING_ID")] + [Description("订单主键")] + public Nullable BOOKING_ID { get; set; } + + /// + /// 变更类型标记 BEFORE-变更前,CURRENT-变更后 + /// + [SugarColumn(ColumnName = "CHANGE_FLAG")] + [Description("变更类型标记")] + public string CHANGE_FLAG { get; set; } + + /// + /// 变更范围类型 SINGLE-单票变更,ALLSHIP-整船变更(例如截止时间变更) + /// + [SugarColumn(ColumnName = "CHANGE_RANGE")] + [Description("变更类型标记")] + public string CHANGE_RANGE { get; set; } + + /// + /// 主提单号 + /// + [SugarColumn(ColumnName = "MBL_NO")] + [Description("主提单号")] + public string MBL_NO { get; set; } + + /// + /// 真提单号 + /// + [SugarColumn(ColumnName = "REAL_MBL_NO")] + [Description("真提单号")] + public string REAL_MBL_NO { get; set; } + + /// + /// 合约号 + /// + [SugarColumn(ColumnName = "CONTRACT_NO")] + [Description("合约号")] + public string CONTRACT_NO { get; set; } + + /// + /// 订舱抬头 + /// + [SugarColumn(ColumnName = "BOOKING_PARTY")] + [Description("订舱抬头")] + public string BOOKING_PARTY { get; set; } + } +} diff --git a/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs new file mode 100644 index 00000000..9ca963ed --- /dev/null +++ b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class BookingSlotChangeRecordNotify + { + } +} diff --git a/Myshipping.Application/Myshipping.Application.csproj b/Myshipping.Application/Myshipping.Application.csproj index b636ec8f..77e3a3ba 100644 --- a/Myshipping.Application/Myshipping.Application.csproj +++ b/Myshipping.Application/Myshipping.Application.csproj @@ -26,6 +26,7 @@ + From 5bd0ebe79f92a5546fdafe2bc6a0c306a3d9353c Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 19 Nov 2024 09:41:31 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9ESITC?= =?UTF-8?q?=E4=B8=AD=E8=BD=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EDI/Dtos/EDIBaseModel.cs | 198 ++++++++++++++++++ Myshipping.Application/EDI/SITCEdiHelper.cs | 40 ++++ .../Entity/BookingMultiLineSplitRecord.cs | 190 +++++++++++++++++ .../BookingOrder/BookingOrderService.cs | 10 + .../BookingMultiLineSplitDto.cs | 190 +++++++++++++++++ 5 files changed, 628 insertions(+) diff --git a/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs b/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs index 85f74849..1e84fe4a 100644 --- a/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs +++ b/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs @@ -91,5 +91,203 @@ namespace Myshipping.Application /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 海丰扩展信息 + /// + public SITCExtInfo SITCExt { get; set; } + } + + public class SITCExtInfo + { + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } diff --git a/Myshipping.Application/EDI/SITCEdiHelper.cs b/Myshipping.Application/EDI/SITCEdiHelper.cs index 5ce06f6f..17e2e0db 100644 --- a/Myshipping.Application/EDI/SITCEdiHelper.cs +++ b/Myshipping.Application/EDI/SITCEdiHelper.cs @@ -1,5 +1,6 @@ using DocumentFormat.OpenXml.ExtendedProperties; using Google.Protobuf.WellKnownTypes; +using Mapster.Utils; using Myshipping.Application.EDI.ESL; using MySqlX.XDevAPI.Common; using Newtonsoft.Json; @@ -203,6 +204,30 @@ namespace Myshipping.Application.EDI.SITC }); } + /* + 1.直达无需处理 OUT特殊设置TRA + 2.若有中转,根据一程 二程 三程 处理 json中 clen的值‘1-3’ + 3.干线支线的选择,如接口文档中 支线:0 干线:1 + 4.港口及代码的处理,均按照映射中 船公司为SITC的港口代码进行处理 + 5.运输类型 cCommodity 默认为0 + */ + if (InttrEdi.SITCExt != null && !string.IsNullOrWhiteSpace(InttrEdi.SITCExt.TransferType) && !InttrEdi.SITCExt.TransferType.Equals("DIRECT",StringComparison.OrdinalIgnoreCase)) + { + //if (InttrEdi.SITCExt.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + //{ + // postModel.extras.Add(new SitcApiPostModelExtra + // { + // ctype = "TRA", + // clen = 1, + // cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, + // vent = InttrEdi.SITCExt.FstVessel?.Trim(), + // humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), + // soc = InttrEdi.SITCExt.FstLaneName?.Trim(), + // unit = + // }); + //} + } + string json = JsonConvert.SerializeObject(postModel, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore @@ -573,6 +598,21 @@ namespace Myshipping.Application.EDI.SITC /// 类型 /// public string ctype { get; set; } + + /// + /// 程次(TRA) + /// + public Nullable clen { get; set; } + + /// + /// 支线:0;干线:1(TRA) + /// + public Nullable cnum { get; set; } + + /// + /// 航线代码 + /// + public string soc { get; set; } } public class SitcApiPostModelDangerInfo diff --git a/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs b/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs index 6081a167..f56d313d 100644 --- a/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs +++ b/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs @@ -75,5 +75,195 @@ namespace Myshipping.Application.Entity /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index e7c64160..033aad25 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8246,6 +8246,10 @@ namespace Myshipping.Application primaryModel.FEETYPE = multiline.FEETYPE; primaryModel.PAYABLEEXT = multiline.PAYABLE; + + ediModel.SITCExt = multiline.Adapt(); + + //这里做个检查 } } @@ -12386,6 +12390,12 @@ namespace Myshipping.Application result.succ = true; result.extra = sitcModel; + var record = _repBookingMultiLineSplitRecord.AsQueryable().Where(a => a.BOOKING_ID == model.Id).OrderByDescending(a => a.CreatedTime).First(); + if (record != null) + { + result.extra2 = record; + } + return result; } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs index 9ffff857..5037d13f 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs @@ -70,5 +70,195 @@ namespace Myshipping.Application /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } From 389ccc02709ea7117ecb4ebcb802d3845730d241 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 19 Nov 2024 10:38:26 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A3=85=E8=B4=A7?= =?UTF-8?q?=E6=B8=AF=E6=9C=AA=E6=8F=90=E7=AE=B1=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/TaskPOLContainerNotPickUpService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs index 6b84eb05..24eb347f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs @@ -376,7 +376,9 @@ namespace Myshipping.Application if (opEmailList.Count > 0) opEmail = string.Join(";", opEmailList.Distinct().ToArray()); - string emailTitle = $"{model.MBL_NO}-{model.VESSEL}/{model.VOYNO}/ 未提箱订舱取消确认"; + var fstOrder = bookingOrderList.FirstOrDefault(); + + string emailTitle = $"{model.MBL_NO}-{fstOrder.VESSEL}/{fstOrder.VOYNO}/ 未提箱订舱取消确认"; //提取当前公共邮箱的配置 DjyUserMailAccount publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" @@ -530,9 +532,11 @@ namespace Myshipping.Application baseHtml = baseHtml.Replace("#BillNo#", ""); } - if (!string.IsNullOrWhiteSpace(model.VESSEL)) + var fstOrderInfo = bookingOrderList.FirstOrDefault(); + + if (!string.IsNullOrWhiteSpace(fstOrderInfo.VESSEL)) { - string s = $"{model.VESSEL}/{model.VOYNO}"; + string s = $"{fstOrderInfo.VESSEL}/{fstOrderInfo.VOYNO}"; baseHtml = baseHtml.Replace("#VesselVoyno#", s); } else From 9e0ae1b2d2430e3c89f58a4c79a11de8206ed903 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 19 Nov 2024 10:46:17 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E7=A5=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=83=B3=E4=BF=A1=E6=81=AF=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=88=E6=88=AA=E5=8D=95=E4=B8=8D=E5=90=8C=E6=AD=A5=E5=88=86?= =?UTF-8?q?=E7=A5=A8=E7=9A=84=E7=AE=B1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 033aad25..5035e797 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -11021,7 +11021,10 @@ namespace Myshipping.Application } } - List statusList = new List(); + //是否已截单 + bool hasJDStatus = false; + + List statusList = new List(); if (App.Configuration["ServiceStatusOpenAuto"] == "1") { @@ -11046,6 +11049,11 @@ namespace Myshipping.Application { dto.CtnDayNum = statusList.FirstOrDefault(x => x.StatusSKUCode == "SQXS" && x.IsYield)?.ActVal; } + + if (statusList != null && statusList.Any(x => x.StatusSKUCode == "JD" && x.IsYield)) + { + hasJDStatus = statusList.FirstOrDefault(x => x.StatusSKUCode == "JD" && x.IsYield).IsYield; + } } else { @@ -11079,7 +11087,7 @@ namespace Myshipping.Application { List allOrderList = new List(); - if (!string.IsNullOrWhiteSpace(oddCode) && oddCode.Equals("SIReceipt", StringComparison.OrdinalIgnoreCase)) + if ((!string.IsNullOrWhiteSpace(oddCode) && oddCode.Equals("SIReceipt", StringComparison.OrdinalIgnoreCase)) || hasJDStatus) { allOrderList = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); From d67477f29774a43547a425b9b02d55734a84f6c4 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 19 Nov 2024 12:39:37 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A3=85=E8=B4=A7?= =?UTF-8?q?=E6=B8=AF=E6=9C=AA=E6=8F=90=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskPOLContainerNotPickUpService.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs index 24eb347f..99a029e1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs @@ -378,7 +378,16 @@ namespace Myshipping.Application var fstOrder = bookingOrderList.FirstOrDefault(); - string emailTitle = $"{model.MBL_NO}-{fstOrder.VESSEL}/{fstOrder.VOYNO}/ 未提箱订舱取消确认"; + string emailTitle = string.Empty; + + if (fstOrder != null && !string.IsNullOrWhiteSpace(fstOrder.VESSEL)) + { + emailTitle = $"{model.MBL_NO}-{fstOrder.VESSEL}/{fstOrder.VOYNO}/ 未提箱订舱取消确认"; + } + else + { + emailTitle = $"{model.MBL_NO}-{model.VESSEL}/{model.VOYNO}/ 未提箱订舱取消确认"; + } //提取当前公共邮箱的配置 DjyUserMailAccount publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" @@ -539,6 +548,11 @@ namespace Myshipping.Application string s = $"{fstOrderInfo.VESSEL}/{fstOrderInfo.VOYNO}"; baseHtml = baseHtml.Replace("#VesselVoyno#", s); } + else if (!string.IsNullOrWhiteSpace(model.VESSEL)) + { + string s = $"{model.VESSEL}/{model.VOYNO}"; + baseHtml = baseHtml.Replace("#VesselVoyno#", s); + } else { baseHtml = baseHtml.Replace("#VesselVoyno#", ""); From 9314ae86386d6626faed3efe3bef48f967ac6b02 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 19 Nov 2024 19:19:59 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9SITC=20=E4=B8=AD?= =?UTF-8?q?=E8=BD=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/SITCEdiHelper.cs | 108 +++++++++-- .../BookingOrder/BookingOrderService.cs | 176 +++++++++++++++++- 2 files changed, 269 insertions(+), 15 deletions(-) diff --git a/Myshipping.Application/EDI/SITCEdiHelper.cs b/Myshipping.Application/EDI/SITCEdiHelper.cs index 17e2e0db..3c843216 100644 --- a/Myshipping.Application/EDI/SITCEdiHelper.cs +++ b/Myshipping.Application/EDI/SITCEdiHelper.cs @@ -1,6 +1,7 @@ using DocumentFormat.OpenXml.ExtendedProperties; using Google.Protobuf.WellKnownTypes; using Mapster.Utils; +using MathNet.Numerics.LinearAlgebra.Factorization; using Myshipping.Application.EDI.ESL; using MySqlX.XDevAPI.Common; using Newtonsoft.Json; @@ -213,19 +214,90 @@ namespace Myshipping.Application.EDI.SITC */ if (InttrEdi.SITCExt != null && !string.IsNullOrWhiteSpace(InttrEdi.SITCExt.TransferType) && !InttrEdi.SITCExt.TransferType.Equals("DIRECT",StringComparison.OrdinalIgnoreCase)) { - //if (InttrEdi.SITCExt.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) - //{ - // postModel.extras.Add(new SitcApiPostModelExtra - // { - // ctype = "TRA", - // clen = 1, - // cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, - // vent = InttrEdi.SITCExt.FstVessel?.Trim(), - // humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), - // soc = InttrEdi.SITCExt.FstLaneName?.Trim(), - // unit = - // }); - //} + if (InttrEdi.SITCExt.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 1, + cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.FstVessel?.Trim(), + humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), + soc = InttrEdi.SITCExt.FstLaneName?.Trim(), + unit = InttrEdi.SITCExt.FstPortLoad, + tempSetting = InttrEdi.SITCExt.FstPortDischarge, + tempMax = InttrEdi.SITCExt.FstPortLoadCode, + tempMin = InttrEdi.SITCExt.FstPortDischargeCode, + etd = InttrEdi.SITCExt.FstETD.HasValue? InttrEdi.SITCExt.FstETD.Value.ToString("yyyy-MM-dd"):"", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 2, + cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.SecVessel?.Trim(), + humdity = InttrEdi.SITCExt.SecVoyno?.Trim(), + soc = InttrEdi.SITCExt.SecLaneName?.Trim(), + unit = InttrEdi.SITCExt.SecPortLoad, + tempSetting = InttrEdi.SITCExt.SecPortDischarge, + tempMax = InttrEdi.SITCExt.SecPortLoadCode, + tempMin = InttrEdi.SITCExt.SecPortDischargeCode, + etd = InttrEdi.SITCExt.SecETD.HasValue ? InttrEdi.SITCExt.SecETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + } + else if (InttrEdi.SITCExt.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 1, + cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.FstVessel?.Trim(), + humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), + soc = InttrEdi.SITCExt.FstLaneName?.Trim(), + unit = InttrEdi.SITCExt.FstPortLoad, + tempSetting = InttrEdi.SITCExt.FstPortDischarge, + tempMax = InttrEdi.SITCExt.FstPortLoadCode, + tempMin = InttrEdi.SITCExt.FstPortDischargeCode, + etd = InttrEdi.SITCExt.FstETD.HasValue ? InttrEdi.SITCExt.FstETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 2, + cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.SecVessel?.Trim(), + humdity = InttrEdi.SITCExt.SecVoyno?.Trim(), + soc = InttrEdi.SITCExt.SecLaneName?.Trim(), + unit = InttrEdi.SITCExt.SecPortLoad, + tempSetting = InttrEdi.SITCExt.SecPortDischarge, + tempMax = InttrEdi.SITCExt.SecPortLoadCode, + tempMin = InttrEdi.SITCExt.SecPortDischargeCode, + etd = InttrEdi.SITCExt.SecETD.HasValue ? InttrEdi.SITCExt.SecETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 3, + cnum = InttrEdi.SITCExt.ThdShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.ThdVessel?.Trim(), + humdity = InttrEdi.SITCExt.ThdVoyno?.Trim(), + soc = InttrEdi.SITCExt.ThdLaneName?.Trim(), + unit = InttrEdi.SITCExt.ThdPortLoad, + tempSetting = InttrEdi.SITCExt.ThdPortDischarge, + tempMax = InttrEdi.SITCExt.ThdPortLoadCode, + tempMin = InttrEdi.SITCExt.ThdPortDischargeCode, + etd = InttrEdi.SITCExt.ThdETD.HasValue ? InttrEdi.SITCExt.ThdETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + } } string json = JsonConvert.SerializeObject(postModel, Formatting.Indented, new JsonSerializerSettings @@ -613,6 +685,16 @@ namespace Myshipping.Application.EDI.SITC /// 航线代码 /// public string soc { get; set; } + + /// + /// 开航日 + /// + public string etd { get; set; } + + /// + /// 运输类型 + /// + public string cCommodity { get; set; } } public class SitcApiPostModelDangerInfo diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 5035e797..0d7c3c4e 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8247,9 +8247,181 @@ namespace Myshipping.Application primaryModel.FEETYPE = multiline.FEETYPE; primaryModel.PAYABLEEXT = multiline.PAYABLE; - ediModel.SITCExt = multiline.Adapt(); - //这里做个检查 + #region 映射港口 + //一程装货港 + if (!string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的映射EDI代码未找到"); + + multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortLoad = currPortInfo.MapName?.Trim(); + } + //一程卸货港 + if (!string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.FstPortDischargeCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + + multiline.FstPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortDischarge = currPortInfo.MapName?.Trim(); + } + + //二程装货港 + if (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的映射EDI代码未找到"); + + multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortLoad = currPortInfo.MapName?.Trim(); + } + //二程卸货港 + if (!string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.SecPortDischargeCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}的映射EDI代码未找到"); + + multiline.SecPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortDischarge = currPortInfo.MapName?.Trim(); + } + + //三程装货港 + if (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的映射EDI代码未找到"); + + multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); + } + //三程卸货港 + if (!string.IsNullOrWhiteSpace(multiline.ThdPortDischargeCode)) + { + var sameList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.ThdPortDischargeCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (sameList == null || sameList.Count == 0) + throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}基础港口代码未找到"); + + var currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo == null) + { + currPortInfo = ediPortList.FirstOrDefault(a => + sameList.Contains(a.Code)); + } + + if (currPortInfo == null) + throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}的映射EDI代码未找到"); + + multiline.ThdPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortDischarge = currPortInfo.MapName?.Trim(); + } + #endregion + + ediModel.SITCExt = multiline.Adapt(); } } From abbcbed49b08a624e1c56d513419e9df53036a18 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 20 Nov 2024 10:19:21 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E6=B8=AF=E5=92=8C=E7=9B=AE=E7=9A=84=E6=B8=AF=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E4=BF=AE=E6=94=B9SITC=20=E6=B8=AF?= =?UTF-8?q?=E5=8F=A3=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 66 +++---------------- .../Service/CommonDB/CommonDBService.cs | 50 ++++++++++++++ 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0d7c3c4e..22dba39c 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8252,27 +8252,11 @@ namespace Myshipping.Application //一程装货港 if (!string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) { - var sameList = portList.Where(a => - !string.IsNullOrWhiteSpace(a.EdiCode) - && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) - .Select(a => a.Code).ToList(); - - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); - } + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)); if (currPortInfo == null) - throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的映射EDI代码未找到"); + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的EDI代码未找到"); multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); multiline.FstPortLoad = currPortInfo.MapName?.Trim(); @@ -8309,27 +8293,11 @@ namespace Myshipping.Application //二程装货港 if (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) { - var sameList = portList.Where(a => - !string.IsNullOrWhiteSpace(a.EdiCode) - && a.EdiCode.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)) - .Select(a => a.Code).ToList(); - - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); - } + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)); if (currPortInfo == null) - throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的映射EDI代码未找到"); + throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的EDI代码未找到"); multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); multiline.SecPortLoad = currPortInfo.MapName?.Trim(); @@ -8366,27 +8334,11 @@ namespace Myshipping.Application //三程装货港 if (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) { - var sameList = portList.Where(a => - !string.IsNullOrWhiteSpace(a.EdiCode) - && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) - .Select(a => a.Code).ToList(); - - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); - } + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)); if (currPortInfo == null) - throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的映射EDI代码未找到"); + throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的EDI代码未找到"); multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index fd41684b..ce6179a0 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using Myshipping.Core.Entity.CommonDB; using Microsoft.AspNetCore.Authorization; using System.Reflection.Metadata.Ecma335; +using StackExchange.Profiling.Internal; namespace Myshipping.Core.Service; /// @@ -2430,4 +2431,53 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } #endregion + #region 起始港和目的港合并查询 + /// + /// 起始港和目的港合并查询 + /// + [HttpGet("/commondb/portmixlist")] + public async Task PortMixList([FromQuery] NameQueryDto input) + { + List resultList = new List(); + + List codePortLoadlist = await _sysCacheService.GetAllCodePortLoad(); + List codePortDischargelist = await _sysCacheService.GetAllCodePort(); + + var queryList = codePortLoadlist.WhereIF(!string.IsNullOrEmpty(input.KeyWord), + x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || + x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || + x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) + .Take(input.Limit).OrderBy(x => x.Sort).ToList(); + + if (queryList.Count > 0) + { + resultList = queryList.Select(a => new CodePort + { + Code = a.Code, + CnName = a.CnName, + EnName = a.EnName, + EdiCode = a.EdiCode, + }).ToList(); + } + + if (queryList.Count < input.Limit) + { + int lessNum = input.Limit - queryList.Count; + + var queryList2 = codePortDischargelist + .WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) + + .Take(lessNum).OrderBy(x => x.Sort).ToList(); + + if (queryList2.Count > 0) + resultList.AddRange(queryList2); + } + + return resultList; + } + #endregion } From d8000c33f20bd6fac0af5c66723bea4ef5b7eaf1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 20 Nov 2024 14:15:26 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9SITC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 291 ++++++++++++++---- Myshipping.Core/Myshipping.Core.xml | 5 + 2 files changed, 228 insertions(+), 68 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 22dba39c..4735a2e3 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8255,121 +8255,245 @@ namespace Myshipping.Application var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.FstPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.FstPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.FstPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}基础港口代码未找到"); + } + } } //一程卸货港 if (!string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.FstPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.FstPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.FstPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.FstPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.FstPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); - - multiline.FstPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.FstPortDischarge = currPortInfo.MapName?.Trim(); } - //二程装货港 if (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) { var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.SecPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.SecPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.SecPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"二程装货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"二程装货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } + } } //二程卸货港 if (!string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.SecPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.SecPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.SecPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.SecPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.SecPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"二程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"二程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}的映射EDI代码未找到"); - - multiline.SecPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.SecPortDischarge = currPortInfo.MapName?.Trim(); } - //三程装货港 if (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) { var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.ThdPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.ThdPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"三程装货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"三程装货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } + } } //三程卸货港 if (!string.IsNullOrWhiteSpace(multiline.ThdPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.ThdPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.ThdPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.ThdPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.ThdPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.ThdPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"三程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"三程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}的映射EDI代码未找到"); - - multiline.ThdPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.ThdPortDischarge = currPortInfo.MapName?.Trim(); } #endregion @@ -12527,6 +12651,37 @@ namespace Myshipping.Application { result.extra2 = record; } + else + { + record = new BookingMultiLineSplitRecord(); + + if (!string.IsNullOrWhiteSpace(order.PORTLOADID)) + { + record.FstPortLoadCode = order.PORTLOADID; + record.FstPortLoad = order.PORTLOAD; + } + + if (!string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.FstPortDischargeCode = order.PORTDISCHARGEID; + record.FstPortDischarge = order.PORTDISCHARGE; + } + + if (!string.IsNullOrWhiteSpace(order.VESSEL)) + { + record.FstVessel = order.VESSEL; + } + + if (!string.IsNullOrWhiteSpace(order.VOYNO)) + { + record.FstVoyno = order.VOYNO; + } + + if (order.ETD.HasValue) + { + record.FstETD = order.ETD.Value; + } + } return result; } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 52acf7a6..8de9c240 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -9750,6 +9750,11 @@ 公开数据:获取箱型映射代码 + + + 起始港和目的港合并查询 + + 代码 From d6df670eb8c91fb19ef37b2a30226487eb2f81cc Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 20 Nov 2024 15:12:25 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9SITC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/SITCEdiHelper.cs | 20 +- .../BookingOrder/BookingOrderService.cs | 290 +++++++++++++++++- 2 files changed, 298 insertions(+), 12 deletions(-) diff --git a/Myshipping.Application/EDI/SITCEdiHelper.cs b/Myshipping.Application/EDI/SITCEdiHelper.cs index 3c843216..04b6c42c 100644 --- a/Myshipping.Application/EDI/SITCEdiHelper.cs +++ b/Myshipping.Application/EDI/SITCEdiHelper.cs @@ -221,8 +221,8 @@ namespace Myshipping.Application.EDI.SITC ctype = "TRA", clen = 1, cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, - vent = InttrEdi.SITCExt.FstVessel?.Trim(), - humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), + vent = InttrEdi.SITCExt.FstVoyno?.Trim(), + humdity = InttrEdi.SITCExt.FstVessel?.Trim(), soc = InttrEdi.SITCExt.FstLaneName?.Trim(), unit = InttrEdi.SITCExt.FstPortLoad, tempSetting = InttrEdi.SITCExt.FstPortDischarge, @@ -237,8 +237,8 @@ namespace Myshipping.Application.EDI.SITC ctype = "TRA", clen = 2, cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, - vent = InttrEdi.SITCExt.SecVessel?.Trim(), - humdity = InttrEdi.SITCExt.SecVoyno?.Trim(), + vent = InttrEdi.SITCExt.SecVoyno?.Trim(), + humdity = InttrEdi.SITCExt.SecVessel?.Trim(), soc = InttrEdi.SITCExt.SecLaneName?.Trim(), unit = InttrEdi.SITCExt.SecPortLoad, tempSetting = InttrEdi.SITCExt.SecPortDischarge, @@ -255,8 +255,8 @@ namespace Myshipping.Application.EDI.SITC ctype = "TRA", clen = 1, cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, - vent = InttrEdi.SITCExt.FstVessel?.Trim(), - humdity = InttrEdi.SITCExt.FstVoyno?.Trim(), + vent = InttrEdi.SITCExt.FstVoyno?.Trim(), + humdity = InttrEdi.SITCExt.FstVessel?.Trim(), soc = InttrEdi.SITCExt.FstLaneName?.Trim(), unit = InttrEdi.SITCExt.FstPortLoad, tempSetting = InttrEdi.SITCExt.FstPortDischarge, @@ -271,8 +271,8 @@ namespace Myshipping.Application.EDI.SITC ctype = "TRA", clen = 2, cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, - vent = InttrEdi.SITCExt.SecVessel?.Trim(), - humdity = InttrEdi.SITCExt.SecVoyno?.Trim(), + vent = InttrEdi.SITCExt.SecVoyno?.Trim(), + humdity = InttrEdi.SITCExt.SecVessel?.Trim(), soc = InttrEdi.SITCExt.SecLaneName?.Trim(), unit = InttrEdi.SITCExt.SecPortLoad, tempSetting = InttrEdi.SITCExt.SecPortDischarge, @@ -287,8 +287,8 @@ namespace Myshipping.Application.EDI.SITC ctype = "TRA", clen = 3, cnum = InttrEdi.SITCExt.ThdShipCapacity == "MAIN" ? 1 : 0, - vent = InttrEdi.SITCExt.ThdVessel?.Trim(), - humdity = InttrEdi.SITCExt.ThdVoyno?.Trim(), + vent = InttrEdi.SITCExt.ThdVoyno?.Trim(), + humdity = InttrEdi.SITCExt.ThdVessel?.Trim(), soc = InttrEdi.SITCExt.ThdLaneName?.Trim(), unit = InttrEdi.SITCExt.ThdPortLoad, tempSetting = InttrEdi.SITCExt.ThdPortDischarge, diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 4735a2e3..6b81c2f5 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -39,6 +39,7 @@ using Myshipping.Core.Service; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NPOI.HSSF.UserModel; +using NPOI.POIFS.Properties; using NPOI.SS.UserModel; using RabbitMQ.Client; using SqlSugar; @@ -8247,6 +8248,245 @@ namespace Myshipping.Application primaryModel.FEETYPE = multiline.FEETYPE; primaryModel.PAYABLEEXT = multiline.PAYABLE; + #region 必填校验 + //校验所有填写项必填,ETD必须顺序填写 + if (string.IsNullOrWhiteSpace(multiline.TransferType) && multiline.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + List checkSITCList = new List(); + + if(!multiline.FstETD.HasValue) + { + checkSITCList.Add("一程开船日期"); + } + + if (!multiline.SecETD.HasValue) + { + checkSITCList.Add("二程开船日期"); + } + + if (multiline.FstETD.Value >= multiline.SecETD.Value) + { + checkSITCList.Add("一程开船日期不能大于等于二程开船日期"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + checkSITCList.Add("一程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoad)) + { + checkSITCList.Add("一程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) + { + checkSITCList.Add("一程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischarge)) + { + checkSITCList.Add("一程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVessel)) + { + checkSITCList.Add("一程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVoyno)) + { + checkSITCList.Add("一程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstLaneName)) + { + checkSITCList.Add("一程航线"); + } + + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + checkSITCList.Add("二程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoad)) + { + checkSITCList.Add("二程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) + { + checkSITCList.Add("二程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischarge)) + { + checkSITCList.Add("二程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVessel)) + { + checkSITCList.Add("二程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVoyno)) + { + checkSITCList.Add("二程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecLaneName)) + { + checkSITCList.Add("二程航线"); + } + + if (checkSITCList.Count > 0) + { + throw Oops.Oh(string.Join(",", checkSITCList.ToArray()) + " 必填"); + } + } + + if (string.IsNullOrWhiteSpace(multiline.TransferType) && multiline.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + List checkSITCList = new List(); + + if (!multiline.FstETD.HasValue) + { + checkSITCList.Add("一程开船日期必填"); + } + + if (!multiline.SecETD.HasValue) + { + checkSITCList.Add("二程开船日期必填"); + } + + if (!multiline.ThdETD.HasValue) + { + checkSITCList.Add("三程开船日期必填"); + } + + if (multiline.FstETD.Value >= multiline.SecETD.Value) + { + checkSITCList.Add("一程开船日期不能大于等于二程开船日期"); + } + + if (multiline.SecETD.Value >= multiline.ThdETD.Value) + { + checkSITCList.Add("二程开船日期不能大于等于三程开船日期"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + checkSITCList.Add("一程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoad)) + { + checkSITCList.Add("一程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) + { + checkSITCList.Add("一程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischarge)) + { + checkSITCList.Add("一程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVessel)) + { + checkSITCList.Add("一程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVoyno)) + { + checkSITCList.Add("一程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstLaneName)) + { + checkSITCList.Add("一程航线"); + } + + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + checkSITCList.Add("二程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoad)) + { + checkSITCList.Add("二程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) + { + checkSITCList.Add("二程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischarge)) + { + checkSITCList.Add("二程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVessel)) + { + checkSITCList.Add("二程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVoyno)) + { + checkSITCList.Add("二程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecLaneName)) + { + checkSITCList.Add("二程航线"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) + { + checkSITCList.Add("三程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortLoad)) + { + checkSITCList.Add("三程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortDischargeCode)) + { + checkSITCList.Add("三程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortDischarge)) + { + checkSITCList.Add("三程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdVessel)) + { + checkSITCList.Add("三程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdVoyno)) + { + checkSITCList.Add("三程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdLaneName)) + { + checkSITCList.Add("三程航线"); + } + + if (checkSITCList.Count > 0) + { + throw Oops.Oh(string.Join(",", checkSITCList.ToArray()) + " 必填"); + } + } + #endregion #region 映射港口 //一程装货港 @@ -12649,6 +12889,49 @@ namespace Myshipping.Application var record = _repBookingMultiLineSplitRecord.AsQueryable().Where(a => a.BOOKING_ID == model.Id).OrderByDescending(a => a.CreatedTime).First(); if (record != null) { + if(string.IsNullOrWhiteSpace(record.TransferType) || record.TransferType.Equals("SECOND",StringComparison.OrdinalIgnoreCase) + || record.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + if(string.IsNullOrWhiteSpace(record.FstPortLoadCode) && !string.IsNullOrWhiteSpace(order.PORTLOADID)) + { + record.FstPortLoadCode = order.PORTLOADID; + record.FstPortLoad = order.PORTLOAD; + } + + if(record.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(record.SecPortDischargeCode) && !string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.SecPortDischargeCode = order.PORTDISCHARGEID; + record.SecPortDischarge = order.PORTDISCHARGE; + } + } + else if (record.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(record.ThdPortDischargeCode) && !string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.ThdPortDischargeCode = order.PORTDISCHARGEID; + record.ThdPortDischarge = order.PORTDISCHARGE; + } + } + + + if (string.IsNullOrWhiteSpace(record.FstVessel) && !string.IsNullOrWhiteSpace(order.VESSEL)) + { + record.FstVessel = order.VESSEL; + } + + if (string.IsNullOrWhiteSpace(record.FstVoyno) && !string.IsNullOrWhiteSpace(order.VOYNO)) + { + record.FstVoyno = order.VOYNO; + } + + if (!record.FstETD.HasValue && order.ETD.HasValue) + { + record.FstETD = order.ETD.Value; + } + } + result.extra2 = record; } else @@ -12663,8 +12946,11 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) { - record.FstPortDischargeCode = order.PORTDISCHARGEID; - record.FstPortDischarge = order.PORTDISCHARGE; + record.SecPortDischargeCode = order.PORTDISCHARGEID; + record.SecPortDischarge = order.PORTDISCHARGE; + + record.ThdPortDischargeCode = order.PORTDISCHARGEID; + record.ThdPortDischarge = order.PORTDISCHARGE; } if (!string.IsNullOrWhiteSpace(order.VESSEL)) From cc86da789c9aed8bbccae48095c7bfd017443c70 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 20 Nov 2024 15:16:34 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9SITC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 6b81c2f5..9576eb24 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -12967,6 +12967,8 @@ namespace Myshipping.Application { record.FstETD = order.ETD.Value; } + + result.extra2 = record; } return result;