ソースを参照

添加引用,修改汇率逻辑,动态生成文档

在 `GroupsController.cs` 文件中,添加了 `MySqlX.XDevAPI.Relational`、`NPOI.HSSF.UserModel`、`NPOI.SS.Formula.Functions` 和 `TencentCloud.Ocr.V20181119.Models` 的引用。
修改了货币汇率计算逻辑,针对“日元”货币,增加了特定的汇率调整。
修改了文档模板的加载方式,改为动态生成文档,并添加了新的文档内容插入逻辑。
添加了 `InvertedListFileDownloadSetRow` 和 `InvertedListFileDownloadSetBorders` 方法,用于设置表格行和边框。
修改了生成的文件名,增加了 GUID 以确保唯一性。
添加了页脚插入图片的功能。
修改了部分注释,将“会务倒退表”改为“会务倒推表”。
添加了 `FMGJ_Log.png` 图片文件。
修改了 `GeneralMethod.cs` 文件中的注释,将“验证数字字符串”改为“验证日期字符串”。
修改了 `InvertedListView.cs` 文件中的注释,将“送机 是否选中”改为“报批资料准备 是否选中”。
LEIYI 3 ヶ月 前
コミット
8ab2e09b3e

+ 230 - 34
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4,7 +4,9 @@ using Aspose.Words.Drawing;
 using Aspose.Words.Tables;
 using DiffMatchPatch;
 using Microsoft.AspNetCore.SignalR;
+using MySqlX.XDevAPI.Relational;
 using NPOI.HSSF.UserModel;
+using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using NPOI.SS.Util;
 using NPOI.XSSF.UserModel;
@@ -37,6 +39,7 @@ using System.Data;
 using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
+using TencentCloud.Ocr.V20181119.Models;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
 using Bookmark = Aspose.Words.Bookmark;
@@ -5393,7 +5396,9 @@ FROM
                     if (rateInfo != null)
                     {
                         decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
-                        rate1 *= 1.035M;
+
+                        if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
+                        else rate1 *= 1.035M;
 
                         item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
                     }
@@ -7582,7 +7587,9 @@ FROM
                     if (rateInfo != null)
                     {
                         decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
-                        rate1 *= 1.035M;
+
+                        if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
+                        else rate1 *= 1.035M;
 
                         item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
                     }
@@ -19179,65 +19186,254 @@ ORDER by  gctggrc.id DESC
             string teamName = "";
             if (info != null) teamName = info.TeamName;
 
-            //载入模板
-            Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
-            DocumentBuilder builder = new DocumentBuilder(doc);
+
+            var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
+            var doc = new Document();
+            var builder = new DocumentBuilder(doc);
+
+            #region old insert
+            ////载入模板
+            //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
+            //Document doc = new Document(tempPath);
+            //DocumentBuilder builder = new DocumentBuilder(doc);
 
             //利用键值对存放数据
-            Dictionary<string, string> dic = new Dictionary<string, string>();
-            dic.Add("TeamName", teamName);
+            //Dictionary<string, string> dic = new Dictionary<string, string>();
+            //dic.Add("TeamName", teamName);
+            //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
 
-            dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
+            //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
+            //dic.Add("BPRemark", info1.ApprovalDataRemark);
 
-            dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
-            dic.Add("BPRemark", info1.ApprovalDataRemark);
+            //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
+            //dic.Add("SQRemark", info1.ApprovalRemark);
 
-            dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
-            dic.Add("SQRemark", info1.ApprovalRemark);
+            //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
+            //dic.Add("CPJRemark", info1.IssueApprovalRemark);
 
-            dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
-            dic.Add("CPJRemark", info1.IssueApprovalRemark);
+            ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
+            ////dic.Add("HZRemark", info1.ApplyPassportRemark);
 
-            //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
-            //dic.Add("HZRemark", info1.ApplyPassportRemark);
+            //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
+            //dic.Add("QZRemark", info1.VisaInformationRemark);
 
-            dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
-            dic.Add("QZRemark", info1.VisaInformationRemark);
+            //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
+            //dic.Add("SQQZRemark", info1.SendVisaRemark);
 
-            dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
-            dic.Add("SQQZRemark", info1.SendVisaRemark);
+            //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
+            //dic.Add("CQRemark", info1.IssueVisaRemark);
 
-            dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
-            dic.Add("CQRemark", info1.IssueVisaRemark);
+            //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
+            //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
 
-            dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
-            dic.Add("XQHRemark", info1.PreTripMeetingRemark);
+            //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
+            //dic.Add("SJRemark", info1.AirportdDropOffRemark);
+            //#region 填充word模板书签内容
+            //foreach (var key in dic.Keys)
+            //{
+            //    builder.MoveToBookmark(key);
+            //    builder.Write(dic[key]);
+            //}
+            //#endregion
+            #endregion
 
-            dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
-            dic.Add("SJRemark", info1.AirportdDropOffRemark);
+            #region New Insert
 
-            #region 填充word模板书签内容
-            foreach (var key in dic.Keys)
+            string titleFont = $"仿宋",
+                   contentFont = $"仿宋";
+
+            var fontColor = Color.FromArgb(64, 64, 64);
+            //设置标题 团组名称
+            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
+            builder.Font.Name = titleFont;
+            builder.Font.Color = fontColor;
+            builder.Font.Size = 12;
+            builder.Font.Bold = true;
+            builder.Writeln(teamName);
+            //设置副标题 团组出访时间
+            builder.Font.Size = 12;
+            builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
+            builder.Writeln();
+
+            var backgroundColor = Color.FromArgb(199, 199, 199);
+
+            var table = builder.StartTable();
+
+            builder.InsertCell();
+            builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
+            builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
+            builder.CellFormat.Borders.LineWidth = 1;
+            builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
+            
+            table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
+            builder.RowFormat.Height = 40;
+            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; 
+            builder.Font.Name = contentFont;
+            builder.Font.Size = 12;
+            builder.Font.Bold = true;
+            builder.Font.Color = fontColor;
+            builder.Write("时间");
+
+            builder.InsertCell();
+            table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
+            builder.Write("流程");
+
+            builder.InsertCell();
+            table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
+            builder.Write("说明");
+            builder.EndRow();
+
+            //报批资料准备
+            if (info1.IsSelectedAirportd)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
+            }
+            //报批/提供送签资料
+            if (info1.IsSelectedApprovalData)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
+            }
+            //出批件护照办理
+            if (info1.IsSelectedIssueApproval)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
+            }
+            //签证资料准备
+            if (info1.IsSelectedVisaInfo)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
+            }
+            //送签
+            if (info1.IsSelectedSendVisa)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
+            }
+            //出签
+            if (info1.IsSelectedIssueVisa)
             {
-                builder.MoveToBookmark(key);
-                builder.Write(dic[key]);
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
             }
+
+            //机票
+            if (info1.IsSelectedAirTicket)
+            {
+                if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
+
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
+            }
+            //酒店
+            if (info1.IsSelectedHotel)
+            {
+                if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
+            }
+
+            //开行前会
+            if (info1.IsSelectedPreTripMeeting)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
+            }
+            //送机
+            if (info1.IsSelectedAirportdDropOff)
+            {
+                InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
+            }
+
+
+            builder.EndTable();
+
+            //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
+            //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
+            for (int i = 0; i < table.Rows.Count; i++)
+            {
+                var row = table.Rows[i];
+                //设置宽度
+                row.Cells[0].CellFormat.Width = 20.00;
+                row.Cells[1].CellFormat.Width = 30.00;
+                row.Cells[2].CellFormat.Width = 50.00;
+                if (i != 0)
+                {
+                    //边框设置
+                    InvertedListFileDownloadSetBorders(row.Cells, 0);
+                    InvertedListFileDownloadSetBorders(row.Cells, 1);
+                    InvertedListFileDownloadSetBorders(row.Cells, 2);
+                }
+            }
+
+            #region 页脚插入图片
+
+            // 创建页脚
+            Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
+            doc.FirstSection.HeadersFooters.Add(footer);
+
+            Paragraph para = new Paragraph(doc);
+            para.ParagraphFormat.Alignment = ParagraphAlignment.Right; 
+            footer.AppendChild(para);
+
+            builder.MoveTo(para);
+
+            string imagePath = "./Images/FMGJ_Log.png"; 
+            builder.InsertImage(imagePath);
+
+            #endregion
+
             #endregion
 
+
             var fileDir = AppSettingsHelper.Get("WordBasePath");
-            string fileName = $"{teamName}团出行准备流程表.doc";
+            string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
             string filePath = fileDir + $@"InvertedList/{fileName}";
             doc.Save(filePath);
             string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
             return Ok(JsonView(true, "操作成功!", Url));
         }
 
+        private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
+        {
+            var fontColor = Color.FromArgb(64, 64, 64);
+
+            builder.InsertCell();
+            builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
+            builder.RowFormat.Height = 40;
+            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
+            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
+            builder.Font.Name = fontName;
+            builder.Font.Size = 8;
+            builder.Font.Bold = true;
+            builder.Font.Color = fontColor;
+            builder.Write(dateTime);
+
+            builder.InsertCell();
+            builder.Font.Size = 9;
+            builder.Font.Bold = true;
+            builder.Font.Color = fontColor;
+            builder.Write(content);
+
+            builder.InsertCell();
+            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
+            builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; 
+            builder.Font.Size = 9;
+            builder.Font.Bold = false;
+            builder.Font.Color = fontColor;
+            builder.Write(reamrk);
+            builder.EndRow();
+        }
+
+        private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
+        {
+            cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
+            cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
+            cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
+            cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
+            //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
+            //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
+        }
 
         #endregion
 
-        #region 会务倒退表
+        #region 会务倒
         /// <summary>
-        /// 会务倒退表
+        /// 会务倒
         /// Init
         /// </summary>
         /// <returns></returns>
@@ -19252,7 +19448,7 @@ ORDER by  gctggrc.id DESC
         }
 
         /// <summary>
-        /// 会务倒退
+        /// 会务倒
         /// ExcelDownload
         /// </summary>
         /// <param name="dto"></param>

BIN
OASystem/OASystem.Api/Images/FMGJ_Log.png


+ 1 - 1
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1653,7 +1653,7 @@ namespace OASystem.API.OAMethodLib
         #region 日期 格式转换 
 
         /// <summary>
-        /// 验证数字字符串
+        /// 验证日期字符串
         /// </summary>
         /// <param name="str"></param>
         /// <returns></returns>

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/InvertedListView.cs

@@ -231,7 +231,7 @@ namespace OASystem.Domain.ViewModels.Groups
         #region 每项是否选中   false   true
 
         /// <summary>
-        /// 送机 是否选中
+        /// 报批资料准备 是否选中
         /// </summary>
         public bool IsSelectedAirportd { get; set; } = true;