|
@@ -1,7 +1,11 @@
|
|
|
using Aspose.Cells;
|
|
|
+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 OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.Dtos.Groups;
|
|
|
using OASystem.Domain.Entities.Business;
|
|
@@ -26,15 +30,17 @@ namespace OASystem.API.Controllers
|
|
|
private readonly DelegationInfoRepository _groupRepository;
|
|
|
private readonly TaskAssignmentRepository _taskAssignmentRep;
|
|
|
private readonly AirTicketResRepository _airTicketResRep;
|
|
|
+ private readonly SqlSugarClient _sqlSugar;
|
|
|
private string url;
|
|
|
private string path;
|
|
|
- public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository, TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep)
|
|
|
+ public GroupsController(IMapper mapper,SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository, TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_grpScheduleRep = grpScheduleRep;
|
|
|
_groupRepository = groupRepository;
|
|
|
_taskAssignmentRep = taskAssignmentRep;
|
|
|
_airTicketResRep = airTicketResRep;
|
|
|
+ _sqlSugar = sqlSugar;
|
|
|
url = AppSettingsHelper.Get("ExcelBaseUrl");
|
|
|
path = AppSettingsHelper.Get("ExcelBasePath");
|
|
|
if (!System.IO.Directory.Exists(path))
|
|
@@ -773,7 +779,11 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 根据id查询费用录入信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
|
|
@@ -793,6 +803,11 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 机票费用录入操作(Status:1.新增,2.修改)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
|
|
@@ -812,7 +827,11 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 机票费用录入,删除
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
|
|
@@ -832,12 +851,12 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 导出机票录入报表
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [HttpPost]
|
|
|
+ /// <summary>
|
|
|
+ /// 导出机票录入报表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
|
|
|
{
|
|
@@ -862,6 +881,14 @@ namespace OASystem.API.Controllers
|
|
|
decimal countCost = 0;
|
|
|
foreach (var item in AirTicketReservations)
|
|
|
{
|
|
|
+ if (item.BankType == "其他")
|
|
|
+ {
|
|
|
+ item.BankNo = "--";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
|
|
|
+ }
|
|
|
item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
|
|
|
item.Price = System.Decimal.Round(item.Price, 2);
|
|
|
countCost += Convert.ToDecimal(item.Price);
|
|
@@ -870,13 +897,13 @@ namespace OASystem.API.Controllers
|
|
|
designer.SetDataSource("ExportDiCode", diCode);
|
|
|
designer.SetDataSource("ExportDiName", diName);
|
|
|
designer.SetDataSource("ExportOpUserName", _Users.CnName);
|
|
|
-
|
|
|
+
|
|
|
designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
|
|
|
designer.Process();
|
|
|
string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
|
|
|
designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
- return Ok(JsonView(true, "成功",url=rst));
|
|
|
+ return Ok(JsonView(true, "成功", url = rst));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -891,6 +918,104 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> ItineraryAirTicketRes(AirTicketResDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
|
|
|
+ if (groupData.Code != 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, groupData.Msg));
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ 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++)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+
|
|
|
+ }
|
|
|
+ //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(false, "程序错误!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|