|
|
@@ -1,12 +1,18 @@
|
|
|
|
|
|
+using Aspose.Cells;
|
|
|
+using Aspose.Words;
|
|
|
+using Aspose.Words.Layout;
|
|
|
+using Aspose.Words.Saving;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
using Microsoft.International.Converters.PinYinConverter;
|
|
|
using Microsoft.VisualBasic;
|
|
|
using NPOI.HSSF.Util;
|
|
|
+using OASystem.API.OAMethodLib.File;
|
|
|
using OASystem.API.OAMethodLib.Hub.HubClients;
|
|
|
using OASystem.API.OAMethodLib.Hub.Hubs;
|
|
|
using OASystem.API.OAMethodLib.JuHeAPI;
|
|
|
using OASystem.API.OAMethodLib.SignalR.Hubs;
|
|
|
+using OASystem.Domain.Dtos.Groups;
|
|
|
using OASystem.Domain.Entities.Customer;
|
|
|
using OASystem.Domain.Entities.District;
|
|
|
using OASystem.Domain.Entities.Financial;
|
|
|
@@ -28,6 +34,7 @@ namespace OASystem.API.OAMethodLib
|
|
|
public static class GeneralMethod
|
|
|
{
|
|
|
//团组信息
|
|
|
+ private readonly static SqlSugarClient _sqlSugar = AutofacIocManager.Instance.GetService<SqlSugarClient>();
|
|
|
private readonly static DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
|
|
|
private readonly static TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
|
|
|
private readonly static IJuHeApiService _juHeApi = AutofacIocManager.Instance.GetService<IJuHeApiService>();
|
|
|
@@ -35,6 +42,7 @@ namespace OASystem.API.OAMethodLib
|
|
|
private readonly static TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
|
|
|
private readonly static MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
|
|
|
private readonly static IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
|
|
|
+
|
|
|
private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
|
|
|
#region 员工注册默认添加基础页面
|
|
|
|
|
|
@@ -1483,7 +1491,6 @@ namespace OASystem.API.OAMethodLib
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
#region op行程单,黑屏幕代码
|
|
|
|
|
|
public static string GetCountryStandingTime(int diId)
|
|
|
@@ -2905,7 +2912,1337 @@ namespace OASystem.API.OAMethodLib
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 三公费用明细 文件下载
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取三公费用标准city
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="placeData"></param>
|
|
|
+ /// <param name="nationalTravelFeeId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
|
|
|
+ {
|
|
|
+ string _city = string.Empty;
|
|
|
+
|
|
|
+ if (placeData.Count < 1) return _city;
|
|
|
+
|
|
|
+ var data = placeData.Find(it => it.Id == nationalTravelFeeId);
|
|
|
+ if (data == null) return _city;
|
|
|
+
|
|
|
+ string country = data.Country;
|
|
|
+ string city = data.City;
|
|
|
+ if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
|
|
|
+ else _city = city;
|
|
|
+ return _city;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 三公费用明细 文件下载
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <param name="CTable"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto,string fileFormat = "pdf")
|
|
|
+ {
|
|
|
+ var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
|
|
|
+
|
|
|
+ if (dto.DiId < 1)
|
|
|
+ {
|
|
|
+ _view.Msg = "请传入有效的DiId参数;";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.ExportType < 1)
|
|
|
+ {
|
|
|
+ _view.Msg = MsgTips.Port;
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.SubTypeId < 1)
|
|
|
+ {
|
|
|
+ _view.Msg = @"请传入有效的SubTypeId参数;
|
|
|
+ 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
|
|
|
+ 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
|
|
|
+ 3 团组成员名单 1 团组成员名单";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
|
|
|
+ var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
|
|
|
+ if (_EnterExitCosts == null)
|
|
|
+ {
|
|
|
+ _view.Msg = @"该团组未填写出入境费用;";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据源
|
|
|
+ List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
|
|
|
+ List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
|
|
|
+ List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
|
|
|
+ List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
|
|
|
+
|
|
|
+ var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
|
|
|
+ var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
|
|
|
+ var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
|
|
|
+ .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
|
|
|
+ .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
|
|
|
+ .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
|
|
|
+ .Select((tcl, dc, cc) => new
|
|
|
+ {
|
|
|
+ Name = dc.LastName + dc.FirstName,
|
|
|
+ Sex = dc.Sex,
|
|
|
+ Birthday = dc.BirthDay,
|
|
|
+ Company = cc.CompanyFullName,
|
|
|
+ Job = dc.Job
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+ var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
|
|
|
+ var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
|
|
|
+ var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
|
|
|
+ var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
|
|
|
+
|
|
|
+
|
|
|
+ _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
|
|
|
+
|
|
|
+ if (dto.ExportType == 1) //明细表
|
|
|
+ {
|
|
|
+ if (dto.SubTypeId == 1005) //1005(默认明细表)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!fileFormat.Equals("pdf")) fileFormat = "docx";
|
|
|
+
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
|
|
|
+
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ //利用键值对存放数据
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
|
|
|
+ decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
|
|
|
+ decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
|
|
|
+ decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
|
|
|
+
|
|
|
+ decimal insidePayTotal = _EnterExitCosts.InsidePay;
|
|
|
+
|
|
|
+ string row1_1 = "";
|
|
|
+ if (_EnterExitCosts.Visa > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.Visa;
|
|
|
+ row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
|
|
|
+ if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
|
|
|
+ {
|
|
|
+ row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string row1_2 = "";
|
|
|
+ if (_EnterExitCosts.YiMiao > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.YiMiao;
|
|
|
+ row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
|
|
|
+ }
|
|
|
+ if (_EnterExitCosts.HeSuan > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.HeSuan;
|
|
|
+ row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
|
|
|
+ }
|
|
|
+ if (_EnterExitCosts.Service > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.Service;
|
|
|
+ row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
|
|
|
+ }
|
|
|
+
|
|
|
+ string row1_3 = "";
|
|
|
+ if (_EnterExitCosts.Safe > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.Safe;
|
|
|
+ row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
|
|
|
+ }
|
|
|
+ if (_EnterExitCosts.Ticket > 0)
|
|
|
+ {
|
|
|
+ //insidePayTotal += _EnterExitCosts.Ticket;
|
|
|
+ row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
|
|
|
+ }
|
|
|
+ string row1 = "";
|
|
|
+ if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
|
|
|
+ if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
|
|
|
+ if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
|
|
|
+
|
|
|
+ dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
|
|
|
+ dic.Add("Row1Str", row1);
|
|
|
+
|
|
|
+ dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
|
|
|
+ dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
|
|
|
+ dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
|
|
|
+ dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
|
|
|
+ dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
|
|
|
+ dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
|
|
|
+ dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
|
|
|
+
|
|
|
+ string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
|
|
|
+ dic.Add("SubGZF", miscellaneousFeeTotalStr);
|
|
|
+ //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
|
|
|
+
|
|
|
+ decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
|
|
|
+ decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
|
|
|
+ dic.Add("SubJJC", subJJC.ToString("#0.00"));
|
|
|
+ dic.Add("SubGWC", subGWC.ToString("#0.00"));
|
|
|
+
|
|
|
+ #region 填充word模板书签内容
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 填充word表格内容
|
|
|
+
|
|
|
+ ////获读取指定表格方法二
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+ for (int i = 0; i < dac1.Count; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ Grp_DayAndCost dac = dac1[i];
|
|
|
+ if (dac == null) continue;
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i, 0, 0);
|
|
|
+ builder.Write("第" + dac.Days.ToString() + "晚:");
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i, 1, 0);
|
|
|
+ //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
|
|
|
+ //builder.Write(dac.Place == null ? "" : dac.Place);
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
|
|
|
+
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i, 2, 0);
|
|
|
+ builder.Write("费用标准:");
|
|
|
+
|
|
|
+ string curr = "";
|
|
|
+ var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
|
|
|
+ if (currData != null)
|
|
|
+ {
|
|
|
+ curr = currData.Name;
|
|
|
+ }
|
|
|
+ builder.MoveToCell(0, i, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00") + curr);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i, 4, 0);
|
|
|
+ builder.Write("费用小计:");
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i, 5, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ while (table1.Rows.Count > dac1.Count)
|
|
|
+ {
|
|
|
+ table1.Rows.RemoveAt(dac1.Count);
|
|
|
+ }
|
|
|
+
|
|
|
+ Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
|
|
|
+ for (int i = 0; i < dac2.Count; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ Grp_DayAndCost dac = dac2[i];
|
|
|
+ if (dac == null) continue;
|
|
|
+
|
|
|
+ builder.MoveToCell(1, i, 0, 0);
|
|
|
+ builder.Write("第" + dac.Days.ToString() + "天:");
|
|
|
+
|
|
|
+ builder.MoveToCell(1, i, 1, 0);
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
|
|
|
+
|
|
|
+ builder.MoveToCell(1, i, 2, 0);
|
|
|
+ builder.Write("费用标准:");
|
|
|
+
|
|
|
+ string curr = "";
|
|
|
+ var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
|
|
|
+ if (currData != null)
|
|
|
+ {
|
|
|
+ curr = currData.Name;
|
|
|
+ }
|
|
|
+ builder.MoveToCell(1, i, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00") + curr);
|
|
|
+
|
|
|
+ builder.MoveToCell(1, i, 4, 0);
|
|
|
+ builder.Write("费用小计:");
|
|
|
+
|
|
|
+ builder.MoveToCell(1, i, 5, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ while (table2.Rows.Count > dac2.Count)
|
|
|
+ {
|
|
|
+ table2.Rows.RemoveAt(dac2.Count);
|
|
|
+ }
|
|
|
+
|
|
|
+ Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
|
|
|
+ for (int i = 0; i < dac3.Count; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ Grp_DayAndCost dac = dac3[i];
|
|
|
+ if (dac == null) continue;
|
|
|
+
|
|
|
+ builder.MoveToCell(2, i, 0, 0);
|
|
|
+ builder.Write("第" + dac.Days.ToString() + "天:");
|
|
|
|
|
|
+ builder.MoveToCell(2, i, 1, 0);
|
|
|
+
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
|
|
|
+
|
|
|
+ builder.MoveToCell(2, i, 2, 0);
|
|
|
+ builder.Write("费用标准:");
|
|
|
+
|
|
|
+ string curr = "";
|
|
|
+ var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
|
|
|
+ if (currData != null)
|
|
|
+ {
|
|
|
+ curr = currData.Name;
|
|
|
+ }
|
|
|
+ builder.MoveToCell(2, i, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00") + curr);
|
|
|
+
|
|
|
+ builder.MoveToCell(2, i, 4, 0);
|
|
|
+ builder.Write("费用小计:");
|
|
|
+
|
|
|
+ builder.MoveToCell(2, i, 5, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ while (table3.Rows.Count > dac3.Count)
|
|
|
+ {
|
|
|
+ table3.Rows.RemoveAt(dac3.Count);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //文件名
|
|
|
+ //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
|
|
|
+
|
|
|
+ AsposeHelper.removewatermark_v2180();
|
|
|
+ //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ var saveFormat = Aspose.Words.SaveFormat.Docx;
|
|
|
+
|
|
|
+ if (fileFormat.Equals("pdf")) {
|
|
|
+ //doc.LayoutOptions.IsShowComments = false;
|
|
|
+ doc.LayoutOptions.IsShowHiddenText = false;
|
|
|
+ doc.LayoutOptions.IsShowParagraphMarks = false;
|
|
|
+ doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
|
|
|
+ doc.AcceptAllRevisions();
|
|
|
+
|
|
|
+ Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
|
|
|
+ options.Compliance = PdfCompliance.PdfA1a;
|
|
|
+ options.CreateNoteHyperlinks = true;
|
|
|
+
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
|
|
|
+ //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
|
|
|
+ _view.Data = new { Url = strFileName };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
|
|
|
+ _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
|
|
|
+ {
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
|
|
|
+ {
|
|
|
+ List<string> list = new List<string>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
|
|
|
+ foreach (var item in spilitArr)
|
|
|
+ {
|
|
|
+ var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ var depCode = spDotandEmpty[2].Substring(0, 3);
|
|
|
+ var arrCode = spDotandEmpty[2].Substring(3, 3);
|
|
|
+ string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
|
|
|
+ arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
|
|
|
+
|
|
|
+ list.Add(depName);
|
|
|
+ list.Add(arrName);
|
|
|
+ }
|
|
|
+
|
|
|
+ list = list.Distinct().ToList();
|
|
|
+ dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ dic.Add("ReturnCode", "行程录入不正确!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dic.Add("ReturnCode", "未录入行程!");
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("ReturnCodeAir", dic["ReturnCode"]);
|
|
|
+ dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
|
|
|
+ dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
|
|
|
+
|
|
|
+ if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
|
|
|
+ {
|
|
|
+ TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
|
|
|
+ dic.Add("Day", sp.Days.ToString());
|
|
|
+ }
|
|
|
+ dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
|
|
|
+ dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
|
|
|
+
|
|
|
+ //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
|
|
|
+ //dic.Add("Names", Names);
|
|
|
+
|
|
|
+
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+ decimal dac1totalPrice = 0.00M;
|
|
|
+ int accommodationStartIndex = 6, foodandotherStartIndex = 22;
|
|
|
+ foreach (var dac in dac1)
|
|
|
+ {
|
|
|
+ if (dac.SubTotal == 0.00M)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
|
|
|
+ //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 1, 0);
|
|
|
+
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 2, 0);
|
|
|
+
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
|
|
|
+ builder.Write(currency);//币种
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00"));//标准
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 4, 0);
|
|
|
+ builder.Write("");//人数
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 5, 0);
|
|
|
+ builder.Write("");//天数
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 6, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00"));//小计
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 7, 0);
|
|
|
+
|
|
|
+ decimal rate = 0.00M;
|
|
|
+ rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
|
|
|
+
|
|
|
+ builder.Write(rate.ToString("#0.0000"));//汇率
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 8, 0);
|
|
|
+
|
|
|
+ decimal rbmPrice = dac.SubTotal;
|
|
|
+ builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
|
|
|
+ accommodationStartIndex++;
|
|
|
+ dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
|
|
|
+
|
|
|
+ for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
|
|
|
+ {
|
|
|
+ table1.Rows.RemoveAt(i - 1);
|
|
|
+ foodandotherStartIndex--;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dac2.Count == dac3.Count)//国家 币种 金额
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dac2.Count; i++)
|
|
|
+ {
|
|
|
+ dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
|
|
|
+ dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ decimal dac2totalPrice = 0.00M;
|
|
|
+
|
|
|
+ foreach (var dac in dac2)
|
|
|
+ {
|
|
|
+ if (dac.SubTotal == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
|
|
|
+
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
|
|
|
+ builder.Write(currency);//币种
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00"));//标准
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
|
|
|
+ builder.Write("");//人数
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
|
|
|
+ builder.Write("");//天数
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00"));//小计
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
|
|
|
+
|
|
|
+ decimal rate = 0.00M;
|
|
|
+ rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
|
|
|
+
|
|
|
+ builder.Write(rate.ToString("#0.0000"));//汇率
|
|
|
+
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
|
|
|
+ decimal rbmPrice = dac.SubTotal;
|
|
|
+ builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
|
|
|
+ foodandotherStartIndex++;
|
|
|
+ dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
|
|
|
+
|
|
|
+ for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
|
|
|
+ {
|
|
|
+ table1.Rows.RemoveAt(i - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
|
|
|
+
|
|
|
+ string otherFeeStr = "";
|
|
|
+ if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
|
|
|
+ if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
|
|
|
+ if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
|
|
|
+
|
|
|
+ if (otherFeeStr.Length > 0)
|
|
|
+ {
|
|
|
+ otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
|
|
|
+ otherFeeStr = $"({otherFeeStr})";
|
|
|
+
|
|
|
+ dic.Add("OtherFeeStr", otherFeeStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //总计
|
|
|
+ decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
|
|
|
+
|
|
|
+ //国际旅费
|
|
|
+ string outsideJJ = "";
|
|
|
+ string allPriceJJ = "";
|
|
|
+ if (_EnterExitCosts.SumJJC == 1)
|
|
|
+ {
|
|
|
+ outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
|
|
|
+ allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
|
|
|
+ }
|
|
|
+ string outsideGW = "";
|
|
|
+ string allPriceGW = "";
|
|
|
+ if (_EnterExitCosts.SumGWC == 1)
|
|
|
+ {
|
|
|
+ outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
|
|
|
+ allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
|
|
|
+ {
|
|
|
+ string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
|
|
|
+ dic.Add("InTravelPrice", InTravelPriceStr);
|
|
|
+
|
|
|
+ string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
|
|
|
+ dic.Add("FinalSumPrice", FinalSumPriceStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
|
|
|
+ //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
|
|
|
+ //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
|
|
|
+
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //模板文件名
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
|
|
|
+ {
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
|
|
|
+ //载入模板
|
|
|
+ WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
+ designer.Workbook = new Workbook(tempPath);
|
|
|
+
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
|
|
|
+ {
|
|
|
+ List<string> list = new List<string>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
|
|
|
+ foreach (var item in spilitArr)
|
|
|
+ {
|
|
|
+ var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ var depCode = spDotandEmpty[2].Substring(0, 3);
|
|
|
+ var arrCode = spDotandEmpty[2].Substring(3, 3);
|
|
|
+ string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
|
|
|
+ arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
|
|
|
+
|
|
|
+ list.Add(depName);
|
|
|
+ list.Add(arrName);
|
|
|
+ }
|
|
|
+
|
|
|
+ list = list.Distinct().ToList();
|
|
|
+ dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ dic.Add("ReturnCode", "行程录入不正确!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dic.Add("ReturnCode", "未录入行程!");
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("ReturnCodeAir", dic["ReturnCode"]);
|
|
|
+ dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
|
|
|
+ dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
|
|
|
+
|
|
|
+ if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
|
|
|
+ {
|
|
|
+ TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
|
|
|
+ dic.Add("Day", sp.Days.ToString());
|
|
|
+ }
|
|
|
+ dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
|
|
|
+ dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
|
|
|
+
|
|
|
+ var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
|
|
|
+
|
|
|
+ designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
|
|
|
+ designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
|
|
|
+ designer.SetDataSource("Group", _DelegationInfo.TeamName);
|
|
|
+ designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
|
|
|
+ designer.SetDataSource("Name", Names);
|
|
|
+ designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
|
|
|
+ designer.SetDataSource("Day", dic["Day"] + "天");
|
|
|
+ designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
|
|
|
+ designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
|
|
|
+
|
|
|
+ int startIndex = 10;
|
|
|
+ const int startIndexcopy = 10;
|
|
|
+
|
|
|
+ if (dac2.Count == dac3.Count)//国家 币种 金额
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dac2.Count; i++)
|
|
|
+ {
|
|
|
+ dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
|
|
|
+ dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DataTable dtdac1 = new DataTable();
|
|
|
+ List<string> place = new List<string>();
|
|
|
+ dtdac1.Columns.AddRange(new DataColumn[] {
|
|
|
+ new DataColumn(){ ColumnName = "city"},
|
|
|
+ new DataColumn(){ ColumnName = "curr"},
|
|
|
+ new DataColumn(){ ColumnName = "criterion"},
|
|
|
+ new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
|
|
|
+ new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
|
|
|
+ new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
|
|
|
+ new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
|
|
|
+ new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
|
|
|
+ });
|
|
|
+ DataTable dtdac2 = new DataTable();
|
|
|
+ dtdac2.Columns.AddRange(new DataColumn[] {
|
|
|
+ new DataColumn(){ ColumnName = "city"},
|
|
|
+ new DataColumn(){ ColumnName = "curr"},
|
|
|
+ new DataColumn(){ ColumnName = "criterion"},
|
|
|
+ new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
|
|
|
+ new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
|
|
|
+ new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
|
|
|
+ new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
|
|
|
+ new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
|
|
|
+ });
|
|
|
+ dtdac1.TableName = "tb1";
|
|
|
+ dtdac2.TableName = "tb2";
|
|
|
+ decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
|
|
|
+ foreach (var item in dac1)
|
|
|
+ {
|
|
|
+ item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
|
|
|
+ if (place.Contains(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DataRow row = dtdac1.NewRow();
|
|
|
+
|
|
|
+ row["city"] = item.Place;
|
|
|
+
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
|
|
|
+ decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
|
|
|
+ row["curr"] = currency;
|
|
|
+ row["rate"] = rate.ToString("#0.0000");
|
|
|
+ row["criterion"] = item.Cost.ToString("#0.00");
|
|
|
+ row["number"] = 1;
|
|
|
+ row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
|
|
|
+
|
|
|
+ //row["costRMB"] = rbmPrice;
|
|
|
+
|
|
|
+ dtdac1.Rows.Add(row);
|
|
|
+ place.Add(item.Place);
|
|
|
+ }
|
|
|
+
|
|
|
+ place = new List<string>();
|
|
|
+ foreach (var item in dac2)
|
|
|
+ {
|
|
|
+ item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
|
|
|
+ if (place.Contains(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DataRow row = dtdac2.NewRow();
|
|
|
+ row["city"] = item.Place;
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
|
|
|
+ decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
|
|
|
+ row["curr"] = currency;
|
|
|
+ row["rate"] = rate.ToString("#0.0000");
|
|
|
+ row["criterion"] = item.Cost.ToString("#0.00");
|
|
|
+ row["number"] = 1;
|
|
|
+ row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
|
|
|
+ //row["cost"] = item.SubTotal;
|
|
|
+
|
|
|
+ //row["costRMB"] = rbmPrice;
|
|
|
+
|
|
|
+ dtdac2.Rows.Add(row);
|
|
|
+ place.Add(item.Place);
|
|
|
+ //dac2totalPrice += rbmPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ dac1totalPrice = dac1.Sum(it => it.SubTotal);
|
|
|
+ dac2totalPrice = dac2.Sum(it => it.SubTotal);
|
|
|
+
|
|
|
+ designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
|
|
|
+ designer.SetDataSource("dac2totalPrice", dac2totalPrice);
|
|
|
+ designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
|
|
|
+ designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
|
|
|
+
|
|
|
+
|
|
|
+ string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
|
|
|
+ string cellStr = $" 5.其他费用(";
|
|
|
+ if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
|
|
|
+ if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
|
|
|
+ if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
|
|
|
+ if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
|
|
|
+ if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
|
|
|
+ if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
|
|
|
+ if (cellStr.Length > 8)
|
|
|
+ {
|
|
|
+ cellStr = cellStr.Substring(0, cellStr.Length - 1);
|
|
|
+ }
|
|
|
+ cellStr += ")";
|
|
|
+
|
|
|
+
|
|
|
+ decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
|
|
|
+ decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
|
|
|
+
|
|
|
+ decimal pxFee = dac4.Sum(it => it.Cost);
|
|
|
+ decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
|
|
|
+ string celllastStr1 = "";
|
|
|
+ if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
|
|
|
+ if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
|
|
|
+ if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
|
|
|
+ celllastStr1 += $",国际旅费 元";
|
|
|
+ if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
|
|
|
+
|
|
|
+ string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
|
|
|
+
|
|
|
+ designer.SetDataSource("cell4Str", cell4Str);
|
|
|
+ designer.SetDataSource("cellStr", cellStr);
|
|
|
+ designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
|
|
|
+ designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
|
|
|
+ designer.SetDataSource("celllastStr", celllastStr);
|
|
|
+
|
|
|
+ Workbook wb = designer.Workbook;
|
|
|
+ var sheet = wb.Worksheets[0];
|
|
|
+
|
|
|
+ //绑定datatable数据集
|
|
|
+ designer.SetDataSource(dtdac1);
|
|
|
+ designer.SetDataSource(dtdac2);
|
|
|
+ designer.Process();
|
|
|
+
|
|
|
+ var rowStart = dtdac1.Rows.Count;
|
|
|
+ while (rowStart > 0)
|
|
|
+ {
|
|
|
+ sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
|
|
|
+ sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
|
|
|
+ startIndex++;
|
|
|
+ rowStart--;
|
|
|
+ }
|
|
|
+
|
|
|
+ sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
|
|
|
+ startIndex += 1; //总计行
|
|
|
+
|
|
|
+ rowStart = dtdac2.Rows.Count;
|
|
|
+ while (rowStart > 0)
|
|
|
+ {
|
|
|
+ sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
|
|
|
+ sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
|
|
|
+ startIndex++;
|
|
|
+ rowStart--;
|
|
|
+ }
|
|
|
+
|
|
|
+ sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
|
|
|
+
|
|
|
+ wb.CalculateFormula(true);
|
|
|
+
|
|
|
+ //模板文件名
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
|
|
|
+ {
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ dic.Add("GroupName", _DelegationInfo.TeamName);
|
|
|
+ dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
|
|
|
+
|
|
|
+ string missionLeader = ""; //团负责人默认接团客户名单第一个人
|
|
|
+ string missionLeaderJob = "";//负责人job
|
|
|
+ int groupNumber = 0; //团人数
|
|
|
+ if (DeleClientList.Count > 0)
|
|
|
+ {
|
|
|
+ missionLeader = DeleClientList[0]?.Name ?? "";
|
|
|
+ missionLeaderJob = DeleClientList[0]?.Job ?? "";
|
|
|
+ }
|
|
|
+ dic.Add("MissionLeader", missionLeader); //团负责人
|
|
|
+ dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
|
|
|
+ dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
|
|
|
+
|
|
|
+
|
|
|
+ #region MyRegion
|
|
|
+ //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
|
|
|
+ //{
|
|
|
+ // List<string> list = new List<string>();
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
|
|
|
+ // foreach (var item in spilitArr)
|
|
|
+ // {
|
|
|
+ // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ // var depCode = spDotandEmpty[2].Substring(0, 3);
|
|
|
+ // var arrCode = spDotandEmpty[2].Substring(3, 3);
|
|
|
+ // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
|
|
|
+ // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
|
|
|
+
|
|
|
+ // list.Add(depName);
|
|
|
+ // list.Add(arrName);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // list = list.Distinct().ToList();
|
|
|
+ // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
|
|
|
+ // }
|
|
|
+ // catch (Exception)
|
|
|
+ // {
|
|
|
+ // dic.Add("ReturnCode", "行程录入不正确!");
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // dic.Add("ReturnCode", "未录入行程!");
|
|
|
+ //}
|
|
|
+
|
|
|
+ List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
|
|
|
+ dic.Add("ReturnCode", string.Join("、", countrys));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
|
|
|
+ //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
|
|
|
+ //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
|
|
|
+
|
|
|
+ //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
|
|
|
+ //{
|
|
|
+ // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
|
|
|
+ // dic.Add("Day", sp.Days.ToString());
|
|
|
+
|
|
|
+ //}
|
|
|
+ dic.Add("Day", _DelegationInfo.VisitDays.ToString());
|
|
|
+
|
|
|
+ dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
|
|
|
+ // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
|
|
|
+
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+ //培训人员名单
|
|
|
+ int cultivateRowIndex = 7;
|
|
|
+ foreach (var item in DeleClientList)
|
|
|
+ {
|
|
|
+ builder.MoveToCell(0, cultivateRowIndex, 0, 0);
|
|
|
+ builder.Write(item.Name);
|
|
|
+ builder.MoveToCell(0, cultivateRowIndex, 1, 0);
|
|
|
+ builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
|
|
|
+
|
|
|
+ builder.MoveToCell(0, cultivateRowIndex, 2, 0);
|
|
|
+
|
|
|
+ string birthDay = "";
|
|
|
+ if (item.Birthday != null)
|
|
|
+ {
|
|
|
+ DateTime dt = Convert.ToDateTime(item.Birthday);
|
|
|
+ birthDay = $"{dt.Year}.{dt.Month}";
|
|
|
+ }
|
|
|
+ builder.Write(birthDay);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, cultivateRowIndex, 3, 0);
|
|
|
+ builder.Write(item.Company);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, cultivateRowIndex, 4, 0);
|
|
|
+ builder.Write(item.Job);
|
|
|
+
|
|
|
+ cultivateRowIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ //cultivateRowIndex -= 2;
|
|
|
+ int delRows = 10 + 7 - cultivateRowIndex;
|
|
|
+ if (delRows > 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < delRows; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ table1.Rows.RemoveAt(cultivateRowIndex);
|
|
|
+ //cultivateRowIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
|
|
|
+ dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
|
|
|
+ decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
|
|
|
+ dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
|
|
|
+ decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
|
|
|
+ dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
|
|
|
+ decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
|
|
|
+ dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
|
|
|
+ decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
|
|
|
+ dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
|
|
|
+ //其他费用
|
|
|
+ decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
|
|
|
+ dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
|
|
|
+
|
|
|
+ //其他费用合计
|
|
|
+ decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
|
|
|
+
|
|
|
+ decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
|
|
|
+ decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
|
|
|
+
|
|
|
+ //公务舱合计
|
|
|
+
|
|
|
+ //国际旅费
|
|
|
+
|
|
|
+ string outsideJJ = "";
|
|
|
+ string allPriceJJ = "";
|
|
|
+ if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
|
|
|
+ {
|
|
|
+ dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
|
|
|
+ dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
|
|
|
+ }
|
|
|
+ if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
|
|
|
+ {
|
|
|
+ dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
|
|
|
+ dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
|
|
|
+ {
|
|
|
+ string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
|
|
|
+ dic.Add("AirFeeTotal", airFeeTotalStr);
|
|
|
+ string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
|
|
|
+ dic.Add("FeeTotal", feeTotalStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //模板文件名
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (dto.ExportType == 2) //表格
|
|
|
+ {
|
|
|
+ //利用键值对存放数据
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
|
|
|
+ dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
|
|
|
+
|
|
|
+ TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
|
|
|
+ dic.Add("Day", sp.Days.ToString());
|
|
|
+
|
|
|
+ dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
|
|
|
+
|
|
|
+ if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
|
|
|
+ {
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ dic.Add("TeamName", _DelegationInfo.TeamName);
|
|
|
+ dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
|
|
|
+ //dic.Add("TellPhone", _DelegationInfo.TellPhone);
|
|
|
+
|
|
|
+ string missionLeaderName = "",
|
|
|
+ missionLeaderJob = "";
|
|
|
+
|
|
|
+ if (DeleClientList.Count > 0)
|
|
|
+ {
|
|
|
+ missionLeaderName = DeleClientList[0].Name;
|
|
|
+ missionLeaderJob = DeleClientList[0].Job;
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("MissionLeaderName", missionLeaderName);
|
|
|
+ dic.Add("MissionLeaderJob", missionLeaderJob);
|
|
|
+
|
|
|
+ dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
|
|
|
+ dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
|
|
|
+
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+ int rowCount = 10;//总人数行
|
|
|
+ int startRowIndex = 7; //起始行
|
|
|
+ for (int i = 0; i < DeleClientList.Count; i++)
|
|
|
+ {
|
|
|
+ builder.MoveToCell(0, startRowIndex, 0, 0);
|
|
|
+ builder.Write(DeleClientList[i].Name); //出国人员姓名
|
|
|
+ builder.MoveToCell(0, startRowIndex, 1, 0);
|
|
|
+ string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
|
|
|
+
|
|
|
+ builder.Write(sex);//性别
|
|
|
+ builder.MoveToCell(0, startRowIndex, 2, 0);
|
|
|
+ builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
|
|
|
+ builder.MoveToCell(0, startRowIndex, 3, 0);
|
|
|
+ builder.Write(DeleClientList[i].Company);//工作单位
|
|
|
+ builder.MoveToCell(0, startRowIndex, 4, 0);
|
|
|
+ builder.Write(DeleClientList[i].Job);//职务及级别
|
|
|
+ builder.MoveToCell(0, startRowIndex, 5, 0);
|
|
|
+ builder.Write("");//人员属性
|
|
|
+ builder.MoveToCell(0, startRowIndex, 6, 0);
|
|
|
+ builder.Write("");//上次出国时间
|
|
|
+ startRowIndex++;
|
|
|
+ }
|
|
|
+ int nullRow = rowCount - DeleClientList.Count;//空行
|
|
|
+ for (int i = 0; i < nullRow; i++)
|
|
|
+ {
|
|
|
+ table1.Rows.Remove(table1.Rows[startRowIndex]);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+ //模板文件名
|
|
|
+ string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
|
|
|
+ {
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ dic.Add("GroupClient", _DelegationInfo.ClientUnit);
|
|
|
+
|
|
|
+ var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
|
|
|
+ dic.Add("Names", Names);
|
|
|
+
|
|
|
+ int accommodationRows = 12, foodandotherRows = 12;
|
|
|
+ var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
|
|
|
+ var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
|
|
|
+
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+
|
|
|
+ int accommodationStartIndex = 6;
|
|
|
+ decimal dac1totalPrice = 0.00M;
|
|
|
+ foreach (var dac in dac1)
|
|
|
+ {
|
|
|
+ if (dac.SubTotal == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
|
|
|
+ //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 1, 0);
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 2, 0);
|
|
|
+
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
|
|
|
+ builder.Write(currency);//币种
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00"));//标准
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 4, 0);
|
|
|
+ builder.Write("");//人数
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 5, 0);
|
|
|
+ builder.Write("");//天数
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 6, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00"));//小计
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 7, 0);
|
|
|
+
|
|
|
+ decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
|
|
|
+ builder.Write(rate.ToString("#0.0000"));//汇率
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 8, 0);
|
|
|
+
|
|
|
+ decimal rbmPrice = rate * dac.SubTotal;
|
|
|
+ builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
|
|
|
+ accommodationStartIndex++;
|
|
|
+ dac1totalPrice += rbmPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
|
|
|
+
|
|
|
+
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 1, 0);
|
|
|
+ builder.Write("小计");
|
|
|
+ builder.MoveToCell(0, accommodationStartIndex, 8, 0);
|
|
|
+ builder.Write(dac1totalPrice.ToString("#0.00"));
|
|
|
+
|
|
|
+ accommodationStartIndex++;
|
|
|
+
|
|
|
+
|
|
|
+ int nullRow = accommodationRows - dac1.Count;
|
|
|
+ //删除空行
|
|
|
+ //if (nullRow > 0)
|
|
|
+ //{
|
|
|
+ // int rowIndex = accommodationStartIndex;
|
|
|
+ // for (int i = 0; i < nullRow; i++)
|
|
|
+ // {
|
|
|
+ // Row row = table1.Rows[rowIndex];
|
|
|
+ // row.Remove();
|
|
|
+ // rowIndex++;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (dac2.Count == dac3.Count)//国家 币种 金额
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dac2.Count; i++)
|
|
|
+ {
|
|
|
+ dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
|
|
|
+ dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int foodandotherStartIndex = 19;//
|
|
|
+ decimal dac2totalPrice = 0.00M;
|
|
|
+ foreach (var dac in dac2)
|
|
|
+ {
|
|
|
+ if (dac.SubTotal == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //foodandotherStartIndex = 12;
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
|
|
|
+ builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
|
|
|
+
|
|
|
+ string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
|
|
|
+ builder.Write(currency);//币种
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
|
|
|
+ builder.Write(dac.Cost.ToString("#0.00"));//标准
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
|
|
|
+ builder.Write("");//人数
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
|
|
|
+ builder.Write("");//天数
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
|
|
|
+ builder.Write(dac.SubTotal.ToString("#0.00"));//小计
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
|
|
|
+
|
|
|
+ decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
|
|
|
+ builder.Write(rate.ToString("#0.0000"));//汇率
|
|
|
+ builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
|
|
|
+
|
|
|
+ decimal rbmPrice = rate * dac.SubTotal;
|
|
|
+ builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
|
|
|
+ foodandotherStartIndex++;
|
|
|
+ dac2totalPrice += rbmPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
|
|
|
+ //删除空行
|
|
|
+ if (dac2.Count < foodandotherRows)
|
|
|
+ {
|
|
|
+ //int nullRow = accommodationRows - dac2.Count;
|
|
|
+ //while (table2.Rows.Count > dac2.Count)
|
|
|
+ //{
|
|
|
+ // table2.Rows.RemoveAt(dac2.Count);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
+ dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
|
|
|
+
|
|
|
+ string otherFeeStr = "";
|
|
|
+ if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
|
|
|
+ if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
|
|
|
+ if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
|
|
|
+
|
|
|
+ if (otherFeeStr.Length > 0)
|
|
|
+ {
|
|
|
+ otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
|
|
|
+ otherFeeStr = $"({otherFeeStr})";
|
|
|
+
|
|
|
+ dic.Add("OtherFeeStr", otherFeeStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+ //模板文件名
|
|
|
+ string strFileName = $"省级单位出(境)经费报销单.docx";
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (dto.ExportType == 3)
|
|
|
+ {
|
|
|
+ if (dto.SubTypeId == 1) //团组成员名单
|
|
|
+ {
|
|
|
+ if (DeleClientList.Count < 1)
|
|
|
+ {
|
|
|
+ _view.Msg = "团组成员暂未录入!!!";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ //获取word里所有表格
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+
|
|
|
+ //获取所填表格的序数
|
|
|
+ Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+ var rowStart = tableOne.Rows[0]; //获取第1行
|
|
|
+
|
|
|
+ //循环赋值
|
|
|
+ for (int i = 0; i < DeleClientList.Count; i++)
|
|
|
+ {
|
|
|
+ builder.MoveToCell(0, i + 1, 0, 0);
|
|
|
+ builder.Write(DeleClientList[i].Name);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 1, 0);
|
|
|
+ string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
|
|
|
+ builder.Write(sex);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 2, 0);
|
|
|
+ builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 3, 0);
|
|
|
+ builder.Write(DeleClientList[i].Company);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 4, 0);
|
|
|
+ builder.Write(DeleClientList[i].Job);
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ while (tableOne.Rows.Count > DeleClientList.Count + 1)
|
|
|
+ {
|
|
|
+ tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
|
|
|
+ //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
|
|
|
+ //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
|
|
|
+
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
|
|
|
+
|
|
|
+ _view.Data = new { Url = url };
|
|
|
+ _view.Msg = "成功";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _view.Code = StatusCodes.Status500InternalServerError;
|
|
|
+ _view.Msg = ex.Message;
|
|
|
+
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
}
|
|
|
}
|