Преглед на файлове

机票行程单的导出

wangh преди 1 година
родител
ревизия
62d693a713

+ 136 - 11
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -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
     }
 }

+ 6 - 1
OASystem/OASystem.Api/appsettings.json

@@ -107,6 +107,11 @@
   "ExcelBasePath": "C:/Server/File/OA2023/Office/Excel/",
   "ExcelFtpPath": "Office/Excel/",
   "OfficeBaseUrl": "http://132.232.92.186:24/",
-  "OfficeTempBasePath": "C:/Server/File/OA2023/Office/"
+  "OfficeTempBasePath": "C:/Server/File/OA2023/Office/",
+
+  "WordBaseUrl": "http://132.232.92.186:24/",
+  "WordBasePath": "C:/Server/File/OA2023/Office/Word/",
+  "WordFtpPath": "Office/Word/"
+
 
 }

+ 117 - 0
OASystem/OASystem.Domain/ViewModels/Groups/AirTicketReservationsView.cs

@@ -106,6 +106,10 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public string BankNo { get; set; }
         /// <summary>
+        /// 卡类型
+        /// </summary>
+        public string BankType { get; set; }
+        /// <summary>
         /// 支付时间
         /// </summary>
         public DateTime CreateTime { get; set; }
@@ -122,4 +126,117 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public string CurrencyStr { get; set; }
     }
+
+    /// <summary>
+    /// 导出行程单数据
+    /// </summary>
+    public class Itinerary
+    {
+        /// <summary>
+        /// 航空公司记录编码
+        /// </summary>
+        public string AirlineRecordCode { get; set; } = "--";
+        /// <summary>
+        /// 订座记录编码
+        /// </summary>
+        public string ReservationRecordCode{ get; set; } = "--";
+        /// <summary>
+        /// 旅客姓名
+        /// </summary>
+        public string ClientName{ get; set; } = "--";
+        /// <summary>
+        /// 票号
+        /// </summary>
+        public string TicketNumber{ get; set; } = "--";
+        /// <summary>
+        /// 身份识别代码
+        /// </summary>
+        public string IdentificationCode{ get; set; } = "--";
+        /// <summary>
+        /// 联票
+        /// </summary>
+        public string JointTicket{ get; set; } = "--";
+        /// <summary>
+        /// 出票航空公司
+        /// </summary>
+        public string AirlineCompany{ get; set; } = "--";
+        /// <summary>
+        /// 出票时间
+        /// </summary>
+        public string TimeIssue{ get; set; } = "--";
+        /// <summary>
+        /// 代理人
+        /// </summary>
+        public string DrawingAgent{ get; set; } = "--";
+        /// <summary>
+        /// 航协代码
+        /// </summary>
+        public string NavigationCode{ get; set; } = "--";
+        /// <summary>
+        /// 代理人地址
+        /// </summary>
+        public string AgentsAddress{ get; set; } = "--";
+        /// <summary>
+        /// 代理人电话
+        /// </summary>
+        public string AgentPhone{ get; set; } = "--";
+        /// <summary>
+        /// 代理人传真
+        /// </summary>
+        public string AgentFacsimile{ get; set; } = "--";
+        /// <summary>
+        /// 航班数据
+        /// </summary>
+        public List<AirInfo> AirInfo { get;set; } = new List<AirInfo>();
+    }
+    /// <summary>
+    /// 航班信息
+    /// </summary>
+    public class AirInfo
+    {
+        /// <summary>
+        /// 始发地/到达地
+        /// </summary>
+        public string Destination { get; set; }
+        /// <summary>
+        /// 航班号
+        /// </summary>
+        public string Flight { get; set; }
+        /// <summary>
+        /// 座位等级
+        /// </summary>
+        public string SeatingClass { get; set; }
+        /// <summary>
+        /// 日期
+        /// </summary>
+        public string FlightDate { get; set; }
+        /// <summary>
+        /// 起飞时间
+        /// </summary>
+        public string DepartureTime { get; set; }
+        /// <summary>
+        /// 到达时间
+        /// </summary>
+        public string LandingTime { get; set; }
+        /// <summary>
+        /// 有效期
+        /// </summary>
+        public string ValidityPeriod { get; set; }
+        /// <summary>
+        /// 客票状态
+        /// </summary>
+        public string TicketStatus { get; set; }
+        /// <summary>
+        /// 行李
+        /// </summary>
+        public string Luggage { get; set; }
+        /// <summary>
+        /// 起飞航站楼
+        /// </summary>
+        public string DepartureTerminal { get; set; }
+        /// <summary>
+        /// 到达航站楼
+        /// </summary>
+        public string LandingTerminal { get; set; }
+    }
 }

+ 1 - 0
OASystem/OASystem.Infrastructure/OASystem.Infrastructure.csproj

@@ -14,6 +14,7 @@
     <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
+    <PackageReference Include="NPOI" Version="2.6.0" />
     <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
     <PackageReference Include="SqlSugarCore" Version="5.1.3.32" />
     <PackageReference Include="StackExchange.Redis" Version="2.6.96" />

+ 34 - 1
OASystem/OASystem.Infrastructure/Repositories/Resource/AirTicketResRepository.cs

@@ -1,5 +1,8 @@
 using AutoMapper;
+
 using MySqlX.XDevAPI.Relational;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.UserDto;
@@ -20,6 +23,9 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Web;
 using System.Xml.Linq;
+using System.Net;
+using NPOI.XWPF.UserModel;
+using NPOI.OpenXmlFormats.Wordprocessing;
 
 namespace OASystem.Infrastructure.Repositories.Resource
 {
@@ -627,7 +633,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 string sql = string.Format(@"select d.TourCode,d.TeamName,a.FlightsCity,a.FlightsCode,a.FlightsDescription,(select Name from Sys_SetData where Id=a.cType) as 'CTypeName',a.ClientName,a.ClientNum,
                                 a.PrePrice,a.Price,(select Name from Sys_SetData where Id=c.PayDId) as 'PayType', case when 
                                 c.OrbitalPrivateTransfer=0 then '公转' when c.OrbitalPrivateTransfer=1 then '私转' end as OrbitalPrivateTransfer,c.BankNo,c.CreateTime,
-                                c.Payee,a.PriceDescription,(select Name from Sys_SetData where Id=a.Currency) as 'CurrencyStr'
+                                c.Payee,a.PriceDescription,(select Name from Sys_SetData where Id=a.Currency) as 'CurrencyStr',(select Name from Sys_SetData where Id=c.CTDId) as BankType
                                 from Grp_AirTicketReservations a,Grp_CreditCardPayment c ,Grp_DelegationInfo d where  a.id=c.CId and d.Id=a.DIId  and a.isdel=0
                                 and a.DIId={0} Order By a.CreateTime desc", dto.DiId, 0);
                 List<AirTicketReservationsPayView>  _AirTicketReservations = _sqlSugar.SqlQueryable<AirTicketReservationsPayView>(sql).ToList();
@@ -647,5 +653,32 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 return result = new Result() { Code = -2, Msg = "未知错误" };
             }
         }
+
+        public async Task<Result> ItineraryAirTicketRes(AirTicketResDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                string sql = string.Format(@"select a.*,c.IsAuditGM,(select Name from Sys_SetData where Id=a.cType) as 'CTypeName',(select Name from 
+                                                Sys_SetData where Id=a.PreCurrency) as 'PreCurrencyStr',(select Name from Sys_SetData where Id=a.Currency)
+                                                as 'CurrencyStr' from Grp_AirTicketReservations a,Grp_CreditCardPayment c where  a.id=c.CId  and a.isdel={1}
+                                                and a.DIId={0} Order By a.CreateTime desc", dto.DiId, 0);
+                List<AirTicketReservationsView> _AirTicketReservations = _sqlSugar.SqlQueryable<AirTicketReservationsView>(sql).ToList();
+                if (_AirTicketReservations.Count==0)
+                {
+                    return result = new Result() { Code = -1, Msg = "暂无数据", Data = null };
+                }
+                else
+                {
+                    return result = new Result() { Code = 0, Msg = "查询成功", Data = _AirTicketReservations };
+                }
+            }
+            catch (Exception)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+        }
+       
     }
 }