|
|
@@ -10,6 +10,7 @@ using iTextSharp.xmp.impl.xpath;
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
using Microsoft.AspNetCore.Routing.Template;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
+using Microsoft.Graph.Models.Security;
|
|
|
using NetUV.Core.Requests;
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
@@ -30,6 +31,7 @@ using OASystem.API.OAMethodLib.KiMiApi;
|
|
|
using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
|
|
|
using OASystem.Domain.AesEncryption;
|
|
|
using OASystem.Domain.Attributes;
|
|
|
+using OASystem.Domain.Common;
|
|
|
using OASystem.Domain.Dtos.CRM;
|
|
|
using OASystem.Domain.Dtos.FileDto;
|
|
|
using OASystem.Domain.Dtos.Financial;
|
|
|
@@ -10920,6 +10922,10 @@ FROM
|
|
|
var exp = Expressionable.Create<Grp_CreditCardPayment>();
|
|
|
exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
|
|
|
|
|
|
+ // 费用类型为机票时,排除 金额、币种为0 的数据
|
|
|
+ exp.AndIF(_dto.Label == 85, it => it.PayMoney > 0.00M && it.PaymentCurrency > 0);
|
|
|
+
|
|
|
+
|
|
|
if (auditStatus == approvedStatus) exp.And(it => approvedAuditIds.Contains(it.IsAuditGM));
|
|
|
else if (auditStatus != allStatus) exp.And(it => it.IsAuditGM == auditStatus);
|
|
|
|
|
|
@@ -10963,8 +10969,9 @@ FROM
|
|
|
|
|
|
/*
|
|
|
* 85 机票预定
|
|
|
+ * 清除人数等于0的信息
|
|
|
*/
|
|
|
- var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
|
|
|
+ var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.ClientNum != 0).ToListAsync();
|
|
|
|
|
|
/*
|
|
|
* 98 其他款项
|
|
|
@@ -11045,6 +11052,19 @@ FROM
|
|
|
*/
|
|
|
foreach (var entity in entityList)
|
|
|
{
|
|
|
+ // 处理机票退票,当前为正整数 应减掉退票费用,标注退票
|
|
|
+ bool isRefundProcessed = false;
|
|
|
+ if (_dto.Label == 85)
|
|
|
+ {
|
|
|
+ var jpResult = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
|
|
|
+ if (jpResult != null && jpResult.RecordType == 1)
|
|
|
+ {
|
|
|
+ entity.PayMoney = -Math.Abs(entity.PayMoney);
|
|
|
+ entity.PayThenMoney = -Math.Abs(entity.PayThenMoney);
|
|
|
+ isRefundProcessed = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var _detail = new Grp_CreditCardPaymentDetailView
|
|
|
{
|
|
|
Id = entity.Id,
|
|
|
@@ -11104,6 +11124,7 @@ FROM
|
|
|
CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//if (_dto.Label == 79)
|
|
|
//{
|
|
|
// string original = string.Empty;
|
|
|
@@ -11592,7 +11613,7 @@ FROM
|
|
|
_detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
|
|
|
|
|
|
// 处理 退票 其他 等费用类型显示在 航班号后面
|
|
|
- var cabinType = initDatas.Where(x => x.Id == jpRes.CType).Select(x => x.Name).FirstOrDefault();
|
|
|
+ var cabinType = initDatas.Where(x => x.Id == jpRes.CType).Select(x => x.Name).FirstOrDefault() ?? "未设置";
|
|
|
var filterTypeNames = new List<string>() {
|
|
|
"退票",
|
|
|
"行程单打印费",
|
|
|
@@ -11605,16 +11626,18 @@ FROM
|
|
|
}
|
|
|
|
|
|
// 2026 版 费用名称 处理
|
|
|
- if (jpRes.CreateTime >= Convert.ToDateTime("2026-06-01 00:00:00"))
|
|
|
+ if (jpRes.CreateTime >= GlobalConfig.AirTicketIntegrationDateTime)
|
|
|
{
|
|
|
var flights = FlightParser.ParseFlights(jpRes.FlightsDescription);
|
|
|
var flightNumbers = flights.Select(x => x.FlightNumber).ToList();
|
|
|
var flightCitys = flights.Select(x => @$"{x.DepartureAirport}/{x.ArrivalAirport}").ToList();
|
|
|
|
|
|
- List<int> numbers = jpRes.ClientName
|
|
|
- .Split(',')
|
|
|
- .Select(int.Parse)
|
|
|
- .ToList();
|
|
|
+ List<int> numbers = !string.IsNullOrEmpty(jpRes.ClientName)
|
|
|
+ ? jpRes.ClientName
|
|
|
+ .Split(',')
|
|
|
+ .Select(int.Parse)
|
|
|
+ .ToList()
|
|
|
+ : new List<int>();
|
|
|
|
|
|
var clientInfos = await _sqlSugar.Queryable<Crm_DeleClient>()
|
|
|
.Where(x => numbers.Contains(x.Id))
|
|
|
@@ -11626,9 +11649,11 @@ FROM
|
|
|
{
|
|
|
if (item.AdditionalServices.Any())
|
|
|
{
|
|
|
- var clientInfo = clientInfos.FirstOrDefault(x => x.Id == item.ClientId);
|
|
|
string name = string.Empty;
|
|
|
- if (clientInfo != null)
|
|
|
+
|
|
|
+ var clientInfo = clientInfos.FirstOrDefault(x => x.Id == item.ClientId);
|
|
|
+ if (item.ClientId == -1) name = "行程单";
|
|
|
+ else if (clientInfo != null)
|
|
|
{
|
|
|
name = $"{AesEncryptionHelper.Decrypt(clientInfo.FirstName)}{AesEncryptionHelper.Decrypt(clientInfo.LastName)}";
|
|
|
}
|
|
|
@@ -11639,7 +11664,7 @@ FROM
|
|
|
return $"{typeName}:{x.Amount:#0.00} ";
|
|
|
}).ToList();
|
|
|
|
|
|
- var label = $"<br/>{name}:{string.Join(";", additionalServiceLabels)}";
|
|
|
+ var label = $"<br/>{name}:{string.Join("、", additionalServiceLabels)}";
|
|
|
additionalServices.Append(label);
|
|
|
}
|
|
|
}
|
|
|
@@ -11758,6 +11783,7 @@ FROM
|
|
|
decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
|
|
|
decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
|
|
|
decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
|
|
|
+
|
|
|
if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
|
|
|
{
|
|
|
auditedFeeOriginal = entity.PayMoney;
|
|
|
@@ -11769,6 +11795,9 @@ FROM
|
|
|
unAuditFeeOriginal = OriginalCurrPay;
|
|
|
OriginalCurrPay = 0.00M;
|
|
|
}
|
|
|
+
|
|
|
+ if (isRefundProcessed) unAuditFeeOriginal = entity.PayMoney;
|
|
|
+
|
|
|
/*
|
|
|
* 费用总计
|
|
|
*/
|
|
|
@@ -13546,55 +13575,51 @@ FROM
|
|
|
|
|
|
/// <summary>
|
|
|
/// 机票费用录入 - 2026版
|
|
|
- /// 导出报表
|
|
|
+ /// 导出
|
|
|
/// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
[HttpPost("/api/Groups/airTicket/file/derive")]
|
|
|
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> AirTicketCostDerive(AirTicketCostDeriveDto dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var result = await _airTicketResRep.DeriveAsync(dto);
|
|
|
if (result.Code != 200)
|
|
|
- {
|
|
|
return Ok(JsonView(StatusCodes.Status400BadRequest, result.Msg, ""));
|
|
|
- }
|
|
|
-
|
|
|
- var airInfoList = result.Data.airInfoList;
|
|
|
|
|
|
- if (!airInfoList.Any())
|
|
|
- {
|
|
|
+ var airInfoList = result.Data?.airInfoList;
|
|
|
+ if (airInfoList == null || !airInfoList.Any())
|
|
|
return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
|
|
|
- }
|
|
|
|
|
|
- string diCode = result.Data?.TourCode ?? "XXX";
|
|
|
- string diName = result.Data?.TeamName ?? "XXX";
|
|
|
+ airInfoList = airInfoList.OrderBy(x => x.FlightsCode).ThenBy(x => x.FlightsDescription).ToList();
|
|
|
|
|
|
+ string diName = result.Data.TeamName ?? "XXX";
|
|
|
+ string diCode = result.Data.TourCode ?? "XXX";
|
|
|
+ string userName = result.Data.Opeator ?? "XXX";
|
|
|
+
|
|
|
+ // 加载模板
|
|
|
+ string templatePath = Path.Combine(AppSettingsHelper.Get("ExcelBasePath"), "Template", "机票预订费用报表模板.xlsx");
|
|
|
+ var workbook = new Workbook(templatePath);
|
|
|
var designer = new WorkbookDesigner
|
|
|
{
|
|
|
Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
|
|
|
};
|
|
|
- decimal countCost = 0;
|
|
|
- foreach (var item in airInfoList)
|
|
|
- {
|
|
|
- item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
|
|
|
- item.Price = System.Decimal.Round(item.Price, 2);
|
|
|
- countCost += Convert.ToDecimal(item.Price);
|
|
|
- }
|
|
|
+ decimal countCost = airInfoList.Sum(x => x.Price);
|
|
|
designer.SetDataSource("Export", airInfoList);
|
|
|
designer.SetDataSource("ExportDiCode", diCode);
|
|
|
designer.SetDataSource("ExportDiName", diName);
|
|
|
- designer.SetDataSource("ExportOpUserName", result.Data.Opeator);
|
|
|
-
|
|
|
- designer.SetDataSource("ExportCountCost", countCost + "(" + airInfoList[0].CurrencyStr);
|
|
|
+ designer.SetDataSource("ExportOpUserName", userName);
|
|
|
+ designer.SetDataSource("ExportCountCost", $"{countCost:#0.00}");
|
|
|
designer.Process();
|
|
|
+
|
|
|
+ // ========== 合并相同值的单元格 ==========
|
|
|
+ MergeSameValuesInColumn(designer.Workbook.Worksheets[0], 0, 5);
|
|
|
+ MergeSameValuesInColumn(designer.Workbook.Worksheets[0], 1, 5);
|
|
|
+ MergeSameValuesInColumn(designer.Workbook.Worksheets[0], 2, 5);
|
|
|
+
|
|
|
string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
|
|
|
designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
return Ok(JsonView(true, "成功", url = rst));
|
|
|
-
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -13602,577 +13627,542 @@ FROM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #region 合并相同值的列
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 合并工作表中指定列中相邻的相同值单元格
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="worksheet">要操作的工作表对象</param>
|
|
|
+ /// <param name="columnIndex">需要合并的列的索引(从0开始计数,0表示第一列)</param>
|
|
|
+ /// <param name="startRow">开始合并的起始行索引(从0开始计数,默认值1表示从第二行开始,跳过表头)</param>
|
|
|
+ private void MergeSameValuesInColumn(Worksheet worksheet, int columnIndex, int startRow = 1)
|
|
|
+ {
|
|
|
+ Cells cells = worksheet.Cells;
|
|
|
+
|
|
|
+ // 使用 GetLastDataRow 方法获取列中有数据的最后一行索引
|
|
|
+ int lastRow = cells.GetLastDataRow(columnIndex);
|
|
|
+
|
|
|
+ if (startRow > lastRow) return;
|
|
|
+
|
|
|
+ int mergeStartRow = startRow;
|
|
|
+ string currentValue = cells[startRow, columnIndex].StringValue;
|
|
|
+
|
|
|
+ for (int row = startRow + 1; row <= lastRow + 1; row++)
|
|
|
+ {
|
|
|
+ string cellValue = (row <= lastRow) ? cells[row, columnIndex].StringValue : null;
|
|
|
+
|
|
|
+ if ((row > lastRow) || cellValue != currentValue)
|
|
|
+ {
|
|
|
+ int mergeRows = row - mergeStartRow;
|
|
|
+ if (mergeRows > 1)
|
|
|
+ {
|
|
|
+ cells.Merge(mergeStartRow, columnIndex, mergeRows, 1);
|
|
|
+
|
|
|
+ // 可选:设置合并后单元格居中对齐
|
|
|
+ Aspose.Cells.Style style = cells[mergeStartRow, columnIndex].GetStyle();
|
|
|
+ style.HorizontalAlignment = TextAlignmentType.Center;
|
|
|
+ style.VerticalAlignment = TextAlignmentType.Center;
|
|
|
+ cells[mergeStartRow, columnIndex].SetStyle(style);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (row <= lastRow)
|
|
|
+ {
|
|
|
+ mergeStartRow = row;
|
|
|
+ currentValue = cellValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
/// <summary>
|
|
|
+ /// 机票费用录入 - 2026版
|
|
|
/// 行程单导出
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [HttpPost("/api/Groups/airTicket/file/itinerary")]
|
|
|
+ [HttpPost("/api/Groups/airTicket/file/tripList")]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> AirTicketCostItinerary(ItineraryAirTicketResDto dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
|
|
|
- if (groupData.Code != 0)
|
|
|
+ var result = await _airTicketResRep.TripListAsync(dto);
|
|
|
+ if (result.Code != 200)
|
|
|
{
|
|
|
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
|
|
|
+ return Ok(JsonView(StatusCodes.Status400BadRequest, result.Msg, ""));
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ List<AirTicketReservationsView> _AirTicketReservations = result.Data;
|
|
|
+ var airCompanyList = await _sqlSugar.Queryable<Res_AirCompany>().Where(x => x.IsDel == 0).Select(x => new { x.ShortCode, x.CnName,x.EnName }).ToListAsync();
|
|
|
+ var threeCodeList = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).Select(x => new { x.Three, x.AirPort,x.AirPort_En }).ToListAsync();
|
|
|
+
|
|
|
+ if (dto.Language == "CN")
|
|
|
{
|
|
|
- List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
|
|
|
- if (dto.Language == "CN")
|
|
|
- {
|
|
|
- var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
|
|
|
- var builder = new DocumentBuilder(doc);
|
|
|
- int tableIndex = 0;//表格索引
|
|
|
- //得到文档中的第一个表格
|
|
|
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
+ var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
|
|
|
+ var builder = new DocumentBuilder(doc);
|
|
|
+ int tableIndex = 0;//表格索引
|
|
|
+ //得到文档中的第一个表格
|
|
|
+ Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
|
|
|
- foreach (var item in _AirTicketReservations)
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
+ {
|
|
|
+ #region 处理固定数据
|
|
|
+ string[] flightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (flightsCode.Length > 0)
|
|
|
{
|
|
|
- #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))
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = airCompanyList.FirstOrDefault(a => a.ShortCode == flightsCode[0].Substring(0, 2))?.CnName ?? "--";
|
|
|
+ }
|
|
|
+
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = !string.IsNullOrEmpty(item.ClientName) ? item.ClientName : "--";
|
|
|
+ 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 循环数据处理
|
|
|
+ var airs = new List<AirInfo>();
|
|
|
+ for (int i = 0; i < item.FlightInfoList.Count; i++)
|
|
|
+ {
|
|
|
+ var currAirInfo = item.FlightInfoList[i];
|
|
|
+ var air = new AirInfo();
|
|
|
+ air.Destination = currAirInfo.DepartureAirport + "/" + currAirInfo.ArrivalAirport;
|
|
|
+ air.Flight = currAirInfo.FlightNumber;
|
|
|
+ air.SeatingClass = item.CTypeName;
|
|
|
+ air.FlightDate = currAirInfo.DepartureDate.ToString("MM/dd");
|
|
|
+ air.DepartureTime = currAirInfo.DepartureTime;
|
|
|
+ air.LandingTime = currAirInfo.ArrivalTime;
|
|
|
+ air.ValidityPeriod = "--";
|
|
|
+ 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++)
|
|
|
{
|
|
|
- name += clientName + ",";
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
}
|
|
|
}
|
|
|
- if (!string.IsNullOrWhiteSpace(name))
|
|
|
+ PropertyInfo[] properties = airs[i].GetType().GetProperties();
|
|
|
+ int index = 0;
|
|
|
+ foreach (PropertyInfo property in properties)
|
|
|
{
|
|
|
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
|
|
|
+ string value = property.GetValue(airs[i]).ToString();
|
|
|
+ Cell ishcel0 = table.Rows[row].Cells[index];
|
|
|
+ var p = new Paragraph(doc);
|
|
|
+ string s = value;
|
|
|
+ p.AppendChild(new Run(doc, s));
|
|
|
+ p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
|
|
|
+ ishcel0.AppendChild(p);
|
|
|
+ ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
|
|
|
+ index++;
|
|
|
}
|
|
|
- else
|
|
|
+ row++;
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ var 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++)
|
|
|
{
|
|
|
- table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.RemoveAt(13);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ rownewsIndex++;
|
|
|
}
|
|
|
- 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 = "--";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ table.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ cloneTable.Rows.RemoveAt(12);
|
|
|
+ }
|
|
|
+ if (_AirTicketReservations.Count != 0)
|
|
|
+ {
|
|
|
+ string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = airCompanyList.FirstOrDefault(a => a.ShortCode == FlightsCode[0].Substring(0, 2))?.CnName ?? "--";
|
|
|
+ }
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = !string.IsNullOrEmpty(_AirTicketReservations[0].ClientName) ? _AirTicketReservations[0].ClientName : "--";
|
|
|
+ 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 循环数据处理
|
|
|
- var 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++)
|
|
|
- {
|
|
|
- var 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)
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
|
|
|
+ var builder = new DocumentBuilder(doc);
|
|
|
+ int tableIndex = 0;//表格索引
|
|
|
+ //得到文档中的第一个表格
|
|
|
+ Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
+
|
|
|
+ var texts = new List<string>();
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
+ {
|
|
|
+ string[] FlightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ var _AirCompany = airCompanyList.FirstOrDefault(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(_AirCompany.CnName))
|
|
|
{
|
|
|
- starCity = star_Three.AirPort;
|
|
|
+ transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
|
|
|
}
|
|
|
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
- string EndCity = "";
|
|
|
- if (End_Three != null)
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey("--"))
|
|
|
{
|
|
|
- EndCity = End_Three.AirPort;
|
|
|
+ transDic.Add("--", "--");
|
|
|
}
|
|
|
- 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 (!texts.Contains(item.ClientName))
|
|
|
+ {
|
|
|
+ texts.Add(item.ClientName);
|
|
|
+ }
|
|
|
+ var 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++)
|
|
|
+ {
|
|
|
+ var air = new AirInfo();
|
|
|
+ string[] tempstr = DayArray[i]
|
|
|
+ .Replace("\r\n", string.Empty)
|
|
|
+ .Replace("\\r\\n", string.Empty)
|
|
|
+ .TrimStart().TrimEnd()
|
|
|
+ .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+
|
|
|
+ var star_Three = threeCodeList.FirstOrDefault(a => a.Three == tempstr[2].Substring(0, 3));
|
|
|
+ if (star_Three != null)
|
|
|
{
|
|
|
- if (airs.Count > 2)
|
|
|
+ if (!transDic.ContainsKey(star_Three.AirPort))
|
|
|
{
|
|
|
- for (int j = 0; j < airs.Count - 2; j++)
|
|
|
- {
|
|
|
- var CopyRow = table.Rows[12].Clone(true);
|
|
|
- table.Rows.Add(CopyRow);
|
|
|
- }
|
|
|
+ transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
|
|
|
}
|
|
|
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
|
|
|
- int index = 0;
|
|
|
- foreach (PropertyInfo property in properties)
|
|
|
+ }
|
|
|
+ var End_Three = threeCodeList.FirstOrDefault(a => a.Three == tempstr[2].Substring(3, 3));
|
|
|
+
|
|
|
+ if (End_Three != null)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(End_Three.AirPort))
|
|
|
{
|
|
|
- string value = property.GetValue(airs[i]).ToString();
|
|
|
- Cell ishcel0 = table.Rows[row].Cells[index];
|
|
|
- var p = new Paragraph(doc);
|
|
|
- string s = value;
|
|
|
- p.AppendChild(new Run(doc, s));
|
|
|
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
|
|
|
- ishcel0.AppendChild(p);
|
|
|
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
|
|
|
- index++;
|
|
|
+ transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
|
|
|
}
|
|
|
- row++;
|
|
|
|
|
|
}
|
|
|
- #endregion
|
|
|
-
|
|
|
- var lastParagraph = new Paragraph(doc);
|
|
|
- //第一个表格末尾加段落
|
|
|
- table.ParentNode.InsertAfter(lastParagraph, table);
|
|
|
- //复制第一个表格
|
|
|
- Table cloneTable = (Table)table.Clone(true);
|
|
|
- //在文档末尾段落后面加入复制的表格
|
|
|
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
|
|
|
+ if (!texts.Contains(item.CTypeName))
|
|
|
+ {
|
|
|
+ texts.Add(item.CTypeName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
|
|
|
+ if (transData.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (TranslateResult item in transData)
|
|
|
+ {
|
|
|
+ if (!transDic.ContainsKey(item.Query))
|
|
|
+ {
|
|
|
|
|
|
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
|
|
|
+ transDic.Add(item.Query, item.Translation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in _AirTicketReservations)
|
|
|
+ {
|
|
|
+ #region 处理固定数据
|
|
|
+ string[] FlightsCode = item.FlightsCode.Split('/');
|
|
|
+ if (FlightsCode.Length != 0)
|
|
|
+ {
|
|
|
+ var _AirCompany = airCompanyList.FirstOrDefault(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
|
|
|
+ if (_AirCompany != null)
|
|
|
{
|
|
|
- int rownewsIndex = 13;
|
|
|
- for (int i = 0; i < 2; i++)
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
{
|
|
|
- var CopyRow = table.Rows[12].Clone(true);
|
|
|
- table.Rows.RemoveAt(13);
|
|
|
- table.Rows.Add(CopyRow);
|
|
|
- rownewsIndex++;
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
}
|
|
|
+
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = str;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- table.Rows.RemoveAt(12);
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
}
|
|
|
- cloneTable.Rows.RemoveAt(12);
|
|
|
}
|
|
|
- if (_AirTicketReservations.Count != 0)
|
|
|
+ table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
|
|
|
+ table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
|
|
|
+ string names = item.ClientName;
|
|
|
+ if (!string.IsNullOrWhiteSpace(names))
|
|
|
{
|
|
|
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
|
|
|
- if (FlightsCode.Length != 0)
|
|
|
+ string str = "--";
|
|
|
+ string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult))
|
|
|
{
|
|
|
- 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 = "--";
|
|
|
- }
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
}
|
|
|
- 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 += 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 = "--";
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- 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));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
|
|
|
- var builder = new DocumentBuilder(doc);
|
|
|
- int tableIndex = 0;//表格索引
|
|
|
- //得到文档中的第一个表格
|
|
|
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
|
|
|
-
|
|
|
- var texts = new List<string>();
|
|
|
- foreach (var item in _AirTicketReservations)
|
|
|
+ table.Range.Bookmarks["ClientName"].Text = str;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- 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);
|
|
|
- }
|
|
|
+ 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 = "--";
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
+ #endregion
|
|
|
+ #region 循环数据处理
|
|
|
+ var 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++)
|
|
|
+ {
|
|
|
+ var air = new AirInfo();
|
|
|
+ string[] tempstr = DayArray[i]
|
|
|
+ .Replace("\r\n", string.Empty)
|
|
|
+ .Replace("\\r\\n", string.Empty)
|
|
|
+ .TrimStart().TrimEnd()
|
|
|
+ .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+
|
|
|
+ var star_Three = threeCodeList.FirstOrDefault(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))
|
|
|
{
|
|
|
- if (!transDic.ContainsKey("--"))
|
|
|
- {
|
|
|
- transDic.Add("--", "--");
|
|
|
- }
|
|
|
-
|
|
|
+ str2 = translateResult2;
|
|
|
+ str2 = _airTicketResRep.Processing(str2);
|
|
|
}
|
|
|
+ starCity = str2;
|
|
|
}
|
|
|
- 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);
|
|
|
- }
|
|
|
- var 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++)
|
|
|
+ var End_Three = threeCodeList.FirstOrDefault(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
+ string EndCity = "";
|
|
|
+ if (End_Three != null)
|
|
|
{
|
|
|
- var 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)
|
|
|
+ string str1 = "--";
|
|
|
+ string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
|
|
|
+ if (!string.IsNullOrEmpty(translateResult1))
|
|
|
{
|
|
|
- if (!transDic.ContainsKey(star_Three.AirPort))
|
|
|
- {
|
|
|
- transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
|
|
|
- }
|
|
|
+ str1 = translateResult1;
|
|
|
+ str1 = _airTicketResRep.Processing(str1);
|
|
|
}
|
|
|
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
|
|
|
-
|
|
|
- if (End_Three != null)
|
|
|
+ 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++)
|
|
|
{
|
|
|
- if (!transDic.ContainsKey(End_Three.AirPort))
|
|
|
- {
|
|
|
- transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (!texts.Contains(item.CTypeName))
|
|
|
- {
|
|
|
- texts.Add(item.CTypeName);
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
|
|
|
- if (transData.Count > 0)
|
|
|
- {
|
|
|
- foreach (TranslateResult item in transData)
|
|
|
+ PropertyInfo[] properties = airs[i].GetType().GetProperties();
|
|
|
+ int index = 0;
|
|
|
+ foreach (PropertyInfo property in properties)
|
|
|
{
|
|
|
- if (!transDic.ContainsKey(item.Query))
|
|
|
- {
|
|
|
-
|
|
|
- transDic.Add(item.Query, item.Translation);
|
|
|
- }
|
|
|
+ string value = property.GetValue(airs[i]).ToString();
|
|
|
+ Cell ishcel0 = table.Rows[row].Cells[index];
|
|
|
+ var p = new Paragraph(doc);
|
|
|
+ string s = value;
|
|
|
+ p.AppendChild(new Run(doc, s));
|
|
|
+ p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
|
|
|
+ ishcel0.AppendChild(p);
|
|
|
+ ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
|
|
|
+ //ishcel0.CellFormat.VerticalAlignment=
|
|
|
+ index++;
|
|
|
}
|
|
|
+ row++;
|
|
|
+
|
|
|
}
|
|
|
- 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);
|
|
|
- }
|
|
|
+ #endregion
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
+ var lastParagraph = new Paragraph(doc);
|
|
|
+ //第一个表格末尾加段落
|
|
|
+ table.ParentNode.InsertAfter(lastParagraph, table);
|
|
|
+ //复制第一个表格
|
|
|
+ Table cloneTable = (Table)table.Clone(true);
|
|
|
+ //在文档末尾段落后面加入复制的表格
|
|
|
+ table.ParentNode.InsertAfter(cloneTable, lastParagraph);
|
|
|
|
|
|
- table.Range.Bookmarks["ClientName"].Text = str;
|
|
|
- }
|
|
|
- else
|
|
|
+ if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
|
|
|
+ {
|
|
|
+ int rownewsIndex = 13;
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
{
|
|
|
- table.Range.Bookmarks["ClientName"].Text = "--";
|
|
|
+ var CopyRow = table.Rows[12].Clone(true);
|
|
|
+ table.Rows.RemoveAt(13);
|
|
|
+ table.Rows.Add(CopyRow);
|
|
|
+ rownewsIndex++;
|
|
|
}
|
|
|
- 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 循环数据处理
|
|
|
- var 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++)
|
|
|
+ }
|
|
|
+ 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)
|
|
|
{
|
|
|
- var 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;
|
|
|
+ string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).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];
|
|
|
- var p = new Paragraph(doc);
|
|
|
- string s = value;
|
|
|
- p.AppendChild(new Run(doc, s));
|
|
|
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
|
|
|
- ishcel0.AppendChild(p);
|
|
|
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
|
|
|
- //ishcel0.CellFormat.VerticalAlignment=
|
|
|
- index++;
|
|
|
- }
|
|
|
- row++;
|
|
|
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- var 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++;
|
|
|
- }
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = str;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- table.Rows.RemoveAt(12);
|
|
|
+ table.Range.Bookmarks["AirlineCompany"].Text = "--";
|
|
|
}
|
|
|
- cloneTable.Rows.RemoveAt(12);
|
|
|
}
|
|
|
- if (_AirTicketReservations.Count != 0)
|
|
|
+ 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)
|
|
|
{
|
|
|
- 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))
|
|
|
{
|
|
|
- names += clientName + ",";
|
|
|
+ str = translateResult;
|
|
|
+ str = _airTicketResRep.Processing(str);
|
|
|
}
|
|
|
- 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 = "--";
|
|
|
+ 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);
|
|
|
+ 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));
|
|
|
- }
|
|
|
+ return Ok(JsonView(true, "成功!", rst));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
|
|
|
- throw;
|
|
|
+ return Ok(JsonView(StatusCodes.Status400BadRequest, $"程序错误!Error:{ex.Message}", ""));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|