|
@@ -1,20 +1,19 @@
|
|
|
using Aspose.Cells;
|
|
|
+using Aspose.Cells.Drawing.Texts;
|
|
|
using Aspose.Words;
|
|
|
using Aspose.Words.Tables;
|
|
|
-using Microsoft.AspNetCore.Mvc;
|
|
|
-using NetTaste;
|
|
|
-using Newtonsoft.Json.Serialization;
|
|
|
-using NPOI.OpenXmlFormats.Spreadsheet;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
+using NPOI.Util;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
+using OASystem.API.OAMethodLib.File;
|
|
|
using OASystem.Domain.Dtos.Groups;
|
|
|
-using OASystem.Domain.Entities.Business;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
-using OASystem.Infrastructure.Tools;
|
|
|
-using System.Web;
|
|
|
+using System.Data;
|
|
|
+using static OASystem.Infrastructure.Repositories.Resource.AirTicketResRepository;
|
|
|
using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
|
|
|
+using Cell = Aspose.Words.Tables.Cell;
|
|
|
+using Row = Aspose.Words.Tables.Row;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -918,10 +917,15 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ Dictionary<string, string> transDic = new Dictionary<string, string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 行程单导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> ItineraryAirTicketRes(AirTicketResDto dto)
|
|
|
+ public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -933,80 +937,542 @@ namespace OASystem.API.Controllers
|
|
|
else
|
|
|
{
|
|
|
List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
|
|
|
-
|
|
|
- //WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
- //designer.Workbook = new Workbook(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
|
|
|
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
|
|
|
- DocumentBuilder builder = new DocumentBuilder();
|
|
|
- foreach (var item in _AirTicketReservations)
|
|
|
+ if (dto.Language=="CN")
|
|
|
{
|
|
|
+ Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
int tableIndex = 0;//表格索引
|
|
|
//得到文档中的第一个表格
|
|
|
Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
- Paragraph lastParagraph = new Paragraph(doc);
|
|
|
- //第一个表格末尾加段落
|
|
|
- table.ParentNode.InsertAfter(lastParagraph, table);
|
|
|
- //复制第一个表格
|
|
|
- Table cloneTable = (Table)table.Clone(true);
|
|
|
- //在文档末尾段落后面加入复制的表格
|
|
|
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
|
|
|
- Itinerary itinerary = new Itinerary();
|
|
|
- itinerary.ClientName = item.ClientName;
|
|
|
- itinerary.AirlineCompany = "航空公司";
|
|
|
- itinerary.TimeIssue = "2023-5-23 10:09:06";
|
|
|
- itinerary.DrawingAgent = "代理人";
|
|
|
- itinerary.AgentsAddress = "代理人地址";
|
|
|
- itinerary.AgentPhone = "代理人电话";
|
|
|
- itinerary.AgentFacsimile = "代理人传真";
|
|
|
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
|
|
|
- List<AirInfo> airInfos = new List<AirInfo>();
|
|
|
- for (int i = 0; i < DayArray.Length; i++)
|
|
|
+
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
{
|
|
|
- string[] FlightStr = item.FlightsCode.Split('/');
|
|
|
- string[] tempstr = DayArray[i]
|
|
|
- .Replace("\r\n", string.Empty)
|
|
|
- .Replace("\\r\\n", string.Empty)
|
|
|
- .TrimStart().TrimEnd()
|
|
|
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
- AirInfo air = new AirInfo();
|
|
|
- string [] city = item.FlightsCity.Split('/');
|
|
|
- string cityStr = city[i];
|
|
|
- string startCity = cityStr.Substring(0, 2);
|
|
|
- Res_ThreeCode startCityThree = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == startCity && a.IsDel == 0);
|
|
|
- string endCity = cityStr.Substring(3, 5);
|
|
|
- Res_ThreeCode endCityThree = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == endCity && a.IsDel == 0);
|
|
|
- air.Destination= startCityThree.City+"-"+endCityThree.City;
|
|
|
- air.Flight = FlightStr[i];
|
|
|
- air.SeatingClass = item.CTypeName;
|
|
|
+ #region 处理固定数据
|
|
|
+ string[] FlightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
|
|
|
+ string name = "";
|
|
|
+ foreach (string clientName in nameArray)
|
|
|
+ {
|
|
|
+ if (!name.Contains(clientName))
|
|
|
+ {
|
|
|
+ name += clientName + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(name))
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["TicketNumber"].Text = "--";
|
|
|
+ table.Range.Bookmarks["IdentificationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["JointTicket"].Text = "--";
|
|
|
+ table.Range.Bookmarks["TimeIssue"].Text = "--";
|
|
|
+ table.Range.Bookmarks["DrawingAgent"].Text = "--";
|
|
|
+ table.Range.Bookmarks["NavigationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentsAddress"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentPhone"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentFacsimile"].Text = "--";
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ #region 循环数据处理
|
|
|
+ List<AirInfo> airs = new List<AirInfo>();
|
|
|
+ string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
|
|
|
+ for (int i = 0; i < FlightsCode.Length; i++)
|
|
|
+ {
|
|
|
+ AirInfo air = new AirInfo();
|
|
|
+ string[] tempstr = DayArray[i]
|
|
|
+ .Replace("\r\n", string.Empty)
|
|
|
+ .Replace("\\r\\n", string.Empty)
|
|
|
+ .TrimStart().TrimEnd()
|
|
|
+ .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+
|
|
|
+ Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
|
|
|
+ string starCity = "";
|
|
|
+ if (star_Three != null)
|
|
|
+ {
|
|
|
+ starCity = star_Three.AirPort;
|
|
|
+ }
|
|
|
+ Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
+ string EndCity = "";
|
|
|
+ if (End_Three != null)
|
|
|
+ {
|
|
|
+ EndCity = End_Three.AirPort;
|
|
|
+ }
|
|
|
+ air.Destination = starCity + "/" + EndCity;
|
|
|
+ air.Flight = FlightsCode[i];
|
|
|
+ air.SeatingClass = item.CTypeName;
|
|
|
+ string dateTime = tempstr[2];
|
|
|
+ string DateTemp = dateTime.Substring(2, 5).ToUpper();
|
|
|
+ air.FlightDate = DateTemp;
|
|
|
+ air.DepartureTime = tempstr[5];
|
|
|
+ air.LandingTime = tempstr[6];
|
|
|
+ air.ValidityPeriod = DateTemp + "/" + DateTemp;
|
|
|
+ air.TicketStatus = "--";
|
|
|
+ air.Luggage = "--";
|
|
|
+ air.DepartureTerminal = "--";
|
|
|
+ air.LandingTerminal = "--";
|
|
|
+ airs.Add(air);
|
|
|
+ }
|
|
|
+ int row = 13;
|
|
|
+ for (int i = 0; i < airs.Count; i++)
|
|
|
+ {
|
|
|
+ if (airs.Count > 2)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < airs.Count - 2; j++)
|
|
|
+ {
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PropertyInfo[] properties = airs[i].GetType().GetProperties();
|
|
|
+ int index = 0;
|
|
|
+ foreach (PropertyInfo property in properties)
|
|
|
+ {
|
|
|
+ string value = property.GetValue(airs[i]).ToString();
|
|
|
+ Cell ishcel0 = table.Rows[row].Cells[index];
|
|
|
+ Paragraph p = new Paragraph(doc);
|
|
|
+ string s = value;
|
|
|
+ p.AppendChild(new Run(doc, s));
|
|
|
+ ishcel0.AppendChild(p);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ row++;
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
+ Paragraph lastParagraph = new Paragraph(doc);
|
|
|
+ //第一个表格末尾加段落
|
|
|
+ table.ParentNode.InsertAfter(lastParagraph, table);
|
|
|
+ //复制第一个表格
|
|
|
+ Table cloneTable = (Table)table.Clone(true);
|
|
|
+ //在文档末尾段落后面加入复制的表格
|
|
|
+ table.ParentNode.InsertAfter(cloneTable, lastParagraph);
|
|
|
+
|
|
|
+ if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
|
|
|
+ {
|
|
|
+ int rownewsIndex = 13;
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.RemoveAt(13);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ rownewsIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ cloneTable.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ if (_AirTicketReservations.Count != 0)
|
|
|
+ {
|
|
|
+ string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
|
|
|
+ string name = "";
|
|
|
+ foreach (string clientName in nameArray)
|
|
|
+ {
|
|
|
+ if (!name.Contains(clientName))
|
|
|
+ {
|
|
|
+ name = name + "," + clientName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(name))
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = name;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["TicketNumber"].Text = "--";
|
|
|
+ table.Range.Bookmarks["IdentificationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["JointTicket"].Text = "--";
|
|
|
+ table.Range.Bookmarks["TimeIssue"].Text = "--";
|
|
|
+ table.Range.Bookmarks["DrawingAgent"].Text = "--";
|
|
|
+ table.Range.Bookmarks["NavigationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentsAddress"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentPhone"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentFacsimile"].Text = "--";
|
|
|
}
|
|
|
- //designer.SetDataSource("Export", AirTicketReservations);
|
|
|
- //string AirlineRecordCode = "--";//航空公司记录编码
|
|
|
- //string ReservationRecordCode = "--";//订座记录编码
|
|
|
- //string ClientName = "--";//旅客姓名
|
|
|
- //string TicketNumber = "--";//票号
|
|
|
- //string IdentificationCode = "--";//身份识别代码
|
|
|
- //string JointTicket = "--";//联票
|
|
|
- //string AirlineCompany = "--";//出票航空公司
|
|
|
- //string TimeIssue = "--";//出票时间
|
|
|
- //string DrawingAgent = "--";//代理人
|
|
|
- //string NavigationCode = "--";//航协代码
|
|
|
- //string AgentsAddress = "--";//代理人地址
|
|
|
- //string AgentPhone = "--";//代理人电话
|
|
|
- //string AgentFacsimile = "--";//代理人传真
|
|
|
- //doc.SetDataSource("AirlineRecordCode", AirlineRecordCode);
|
|
|
- //Itinerary itinerary = new Itinerary();
|
|
|
|
|
|
|
|
|
+ doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
|
|
|
+ //保存合并后的文档
|
|
|
+ string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
|
|
|
+ string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "成功!", rst));
|
|
|
}
|
|
|
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
|
|
|
- //保存合并后的文档
|
|
|
- string fileName = "AirItinerary/电子客票行程单_CN.docx";
|
|
|
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
|
|
|
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+ int tableIndex = 0;//表格索引
|
|
|
+ //得到文档中的第一个表格
|
|
|
+ Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
+
|
|
|
+ List<string> texts = new List<string>();
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
+ {
|
|
|
+ string[] FlightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(_AirCompany.CnName))
|
|
|
+ {
|
|
|
+ transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey("--"))
|
|
|
+ {
|
|
|
+ transDic.Add("--", "--");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
|
|
|
+ string name = "";
|
|
|
+ foreach (string clientName in nameArray)
|
|
|
+ {
|
|
|
+ name += clientName+",";
|
|
|
+ }
|
|
|
+ if (!texts.Contains(name))
|
|
|
+ {
|
|
|
+ texts.Add(name);
|
|
|
+ }
|
|
|
+ List<AirInfo> airs = new List<AirInfo>();
|
|
|
+ string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
|
|
|
+ for (int i = 0; i < FlightsCode.Length; i++)
|
|
|
+ {
|
|
|
+ AirInfo air = new AirInfo();
|
|
|
+ string[] tempstr = DayArray[i]
|
|
|
+ .Replace("\r\n", string.Empty)
|
|
|
+ .Replace("\\r\\n", string.Empty)
|
|
|
+ .TrimStart().TrimEnd()
|
|
|
+ .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+
|
|
|
+ Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
|
|
|
+ if (star_Three != null)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(star_Three.AirPort))
|
|
|
+ {
|
|
|
+ transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
+
|
|
|
+ if (End_Three != null)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(End_Three.AirPort))
|
|
|
+ {
|
|
|
+ transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!texts.Contains(item.CTypeName))
|
|
|
+ {
|
|
|
+ texts.Add(item.CTypeName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
|
|
|
+ if (transData.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (TranslateResult item in transData)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(item.Query))
|
|
|
+ {
|
|
|
+
|
|
|
+ transDic.Add(item.Query, item.Translation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
+ {
|
|
|
+ #region 处理固定数据
|
|
|
+ string[] FlightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
+ {
|
|
|
+ str = translateResult;
|
|
|
+ str =_airTicketResRep.Processing(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = str;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
|
|
|
+ string names = "";
|
|
|
+ foreach (string clientName in nameArray)
|
|
|
+ {
|
|
|
+ names += clientName + ",";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(names))
|
|
|
+ {
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
+ {
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = str;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["TicketNumber"].Text = "--";
|
|
|
+ table.Range.Bookmarks["IdentificationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["JointTicket"].Text = "--";
|
|
|
+ table.Range.Bookmarks["TimeIssue"].Text = "--";
|
|
|
+ table.Range.Bookmarks["DrawingAgent"].Text = "--";
|
|
|
+ table.Range.Bookmarks["NavigationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentsAddress"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentPhone"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentFacsimile"].Text = "--";
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ #region 循环数据处理
|
|
|
+ List<AirInfo> airs = new List<AirInfo>();
|
|
|
+ string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
|
|
|
+ for (int i = 0; i < FlightsCode.Length; i++)
|
|
|
+ {
|
|
|
+ AirInfo air = new AirInfo();
|
|
|
+ string[] tempstr = DayArray[i]
|
|
|
+ .Replace("\r\n", string.Empty)
|
|
|
+ .Replace("\\r\\n", string.Empty)
|
|
|
+ .TrimStart().TrimEnd()
|
|
|
+ .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+
|
|
|
+ Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
|
|
|
+ string starCity = "";
|
|
|
+ if (star_Three != null)
|
|
|
+ {
|
|
|
+ string str2 = "--";
|
|
|
+ string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult2))
|
|
|
+ {
|
|
|
+ str2 = translateResult2;
|
|
|
+ str2 = _airTicketResRep.Processing(str2);
|
|
|
+ }
|
|
|
+ starCity = str2;
|
|
|
+ }
|
|
|
+ Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
+ string EndCity = "";
|
|
|
+ if (End_Three != null)
|
|
|
+ {
|
|
|
+ string str1 = "--";
|
|
|
+ string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult1))
|
|
|
+ {
|
|
|
+ str1 = translateResult1;
|
|
|
+ str1= _airTicketResRep.Processing(str1);
|
|
|
+ }
|
|
|
+ EndCity = str1;
|
|
|
+ }
|
|
|
+ air.Destination = starCity + "/" + EndCity;
|
|
|
+ air.Flight = FlightsCode[i];
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
+ {
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
+ }
|
|
|
+ air.SeatingClass = str;
|
|
|
+ string dateTime = tempstr[2];
|
|
|
+ string DateTemp = dateTime.Substring(2, 5).ToUpper();
|
|
|
+ air.FlightDate = DateTemp;
|
|
|
+ air.DepartureTime = tempstr[5];
|
|
|
+ air.LandingTime = tempstr[6];
|
|
|
+ air.ValidityPeriod = DateTemp + "/" + DateTemp;
|
|
|
+ air.TicketStatus = "--";
|
|
|
+ air.Luggage = "--";
|
|
|
+ air.DepartureTerminal = "--";
|
|
|
+ air.LandingTerminal = "--";
|
|
|
+ airs.Add(air);
|
|
|
+ }
|
|
|
+ int row = 13;
|
|
|
+ for (int i = 0; i < airs.Count; i++)
|
|
|
+ {
|
|
|
+ if (airs.Count > 2)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < airs.Count - 2; j++)
|
|
|
+ {
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PropertyInfo[] properties = airs[i].GetType().GetProperties();
|
|
|
+ int index = 0;
|
|
|
+ foreach (PropertyInfo property in properties)
|
|
|
+ {
|
|
|
+ string value = property.GetValue(airs[i]).ToString();
|
|
|
+ Cell ishcel0 = table.Rows[row].Cells[index];
|
|
|
+ Paragraph p = new Paragraph(doc);
|
|
|
+ string s = value;
|
|
|
+ p.AppendChild(new Run(doc, s));
|
|
|
+ ishcel0.AppendChild(p);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ row++;
|
|
|
|
|
|
- return Ok(JsonView(false, "程序错误!"));
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ Paragraph lastParagraph = new Paragraph(doc);
|
|
|
+ //第一个表格末尾加段落
|
|
|
+ table.ParentNode.InsertAfter(lastParagraph, table);
|
|
|
+ //复制第一个表格
|
|
|
+ Table cloneTable = (Table)table.Clone(true);
|
|
|
+ //在文档末尾段落后面加入复制的表格
|
|
|
+ table.ParentNode.InsertAfter(cloneTable, lastParagraph);
|
|
|
+
|
|
|
+ if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
|
|
|
+ {
|
|
|
+ int rownewsIndex = 13;
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.RemoveAt(13);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ rownewsIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ cloneTable.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ if (_AirTicketReservations.Count != 0)
|
|
|
+ {
|
|
|
+ string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
+ {
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = str;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
|
|
|
+ nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
|
|
|
+ string names = "";
|
|
|
+ foreach (string clientName in nameArray)
|
|
|
+ {
|
|
|
+ names += clientName + ",";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(names))
|
|
|
+ {
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
+ {
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = str;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["TicketNumber"].Text = "--";
|
|
|
+ table.Range.Bookmarks["IdentificationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["JointTicket"].Text = "--";
|
|
|
+ table.Range.Bookmarks["TimeIssue"].Text = "--";
|
|
|
+ table.Range.Bookmarks["DrawingAgent"].Text = "--";
|
|
|
+ table.Range.Bookmarks["NavigationCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentsAddress"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentPhone"].Text = "--";
|
|
|
+ table.Range.Bookmarks["AgentFacsimile"].Text = "--";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
|
|
|
+ //保存合并后的文档
|
|
|
+ string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
|
|
|
+ string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "成功!", rst));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|