|
@@ -16,6 +16,14 @@ using OASystem.Infrastructure.Repositories.Groups;
|
|
|
using SqlSugar;
|
|
|
using StackExchange.Redis;
|
|
|
using System.Data;
|
|
|
+using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
|
|
|
+using System.Web;
|
|
|
+using Aspose.Words;
|
|
|
+using NPOI.HSSF.Util;
|
|
|
+using OASystem.Domain.Entities.Customer;
|
|
|
+using System.IO.Compression;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using System.Net.Http;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -29,6 +37,7 @@ namespace OASystem.API.Controllers
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IConfiguration _config;
|
|
|
private readonly SqlSugarClient _sqlSugar;
|
|
|
+ private readonly HttpClient _httpClient;
|
|
|
private readonly SetDataTypeRepository _setDataTypeRep;
|
|
|
private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
|
|
|
private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
|
|
@@ -41,7 +50,7 @@ namespace OASystem.API.Controllers
|
|
|
/// </summary>
|
|
|
public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
|
|
|
TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
|
|
|
- PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep)
|
|
|
+ PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_config = configuration;
|
|
@@ -52,6 +61,7 @@ namespace OASystem.API.Controllers
|
|
|
_ForForeignReceivablesRep = ForForeignReceivablesRep;
|
|
|
_proceedsReceivedRep = proceedsReceivedRep;
|
|
|
_paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
|
|
|
+ _httpClient = httpClient;
|
|
|
}
|
|
|
|
|
|
#region 日付申请
|
|
@@ -656,7 +666,6 @@ namespace OASystem.API.Controllers
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return Ok(JsonView(false, ex.Message));
|
|
|
- throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -682,7 +691,6 @@ namespace OASystem.API.Controllers
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return Ok(JsonView(false, ex.Message));
|
|
|
- throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -738,7 +746,426 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 已收账单
|
|
|
+ /// File Downloasd
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostReceivablesFeilDownload(ForeignReceivablesFeilDownloadDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (dto.DiId < 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请传入有效DiId参数!"));
|
|
|
+ }
|
|
|
+ if (dto.FileType < 1 || dto.FileType > 3)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川) 2 生成收款单(北京) 3 汇款账单"));
|
|
|
+ }
|
|
|
+
|
|
|
+ var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
|
|
|
+ if (_DelegationInfo == null)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无团组信息!!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.FileType == 1 || dto.FileType == 2)
|
|
|
+ {
|
|
|
+ var _ForeignReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
|
|
|
+ if (_ForeignReceivables.Count < 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无收款信息!!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ string tempName = "";
|
|
|
+ if (dto.FileType == 1) tempName = $"收款账单(四川)模板.docx";
|
|
|
+ else if (dto.FileType == 2) tempName = $"收款账单(北京)模板.docx";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/{tempName}";
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ #region 替换Word模板书签内容
|
|
|
+
|
|
|
+ //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
|
|
|
+ //付款方
|
|
|
+ if (doc.Range.Bookmarks["To"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["To"];
|
|
|
+ mark.Text = _ForeignReceivables[0].To == null ? "" : _ForeignReceivables[0].To.ToString();
|
|
|
+ }
|
|
|
+ //付款方电话
|
|
|
+ if (doc.Range.Bookmarks["ToTel"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["ToTel"];
|
|
|
+ mark.Text = _ForeignReceivables[0].ToTel == null ? "" : _ForeignReceivables[0].ToTel.ToString();
|
|
|
+ }
|
|
|
+ //导出时间
|
|
|
+ if (doc.Range.Bookmarks["Date"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["Date"];
|
|
|
+ mark.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ //注
|
|
|
+ if (doc.Range.Bookmarks["Attention"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["Attention"];
|
|
|
+ mark.Text = _ForeignReceivables[0].Attention == null ? "" : _ForeignReceivables[0].Attention.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //团队名称
|
|
|
+ if (doc.Range.Bookmarks["Team"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["Team"];
|
|
|
+ mark.Text = _DelegationInfo.VisitCountry == null ? "" : _DelegationInfo.VisitCountry.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //付款日期
|
|
|
+ if (doc.Range.Bookmarks["PayDate"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["PayDate"];
|
|
|
+ mark.Text = _ForeignReceivables[0].PayDate == null ? "" : Convert.ToDateTime(_ForeignReceivables[0].PayDate).ToString("yyyy年MM月dd日");
|
|
|
+ }
|
|
|
+
|
|
|
+ decimal sumPrice = 0;
|
|
|
+ //各项费用
|
|
|
+ if (doc.Range.Bookmarks["PayItemContent"] != null)
|
|
|
+ {
|
|
|
+ string items = "";
|
|
|
+ foreach (var fr in _ForeignReceivables)
|
|
|
+ {
|
|
|
+ items += fr.PriceName + " " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
|
|
|
+ sumPrice += fr.ItemSumPrice;
|
|
|
+ }
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["PayItemContent"];
|
|
|
+ mark.Text = items;
|
|
|
+ }
|
|
|
+ //合计
|
|
|
+ if (doc.Range.Bookmarks["Total"] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks["Total"];
|
|
|
+ mark.Text = sumPrice.ToString("#0.00");
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //文件名
|
|
|
+ string strFileName = _DelegationInfo.TeamName + "-收款账单.docx";
|
|
|
+
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + "ForeignReceivables/File/" + strFileName);
|
|
|
+ string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/ForeignReceivables/File/" + strFileName;
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "成功", new { Url = url }));
|
|
|
+ }
|
|
|
+ else if (dto.FileType == 3) //汇款通知
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "该团组未填写出入境费用;"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据源
|
|
|
+ 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 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,
|
|
|
+ AirType = tcl.ShippingSpaceTypeId
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+ if (DeleClientList.Count<1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无团组成员,请先填写团组成员!!!"));
|
|
|
+ }
|
|
|
+ var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
|
|
|
+ var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
|
|
|
+
|
|
|
+
|
|
|
+ Dictionary<string, string> bookmarkArr = null;
|
|
|
+
|
|
|
+ string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/汇款通知.docx";
|
|
|
+ //载入模板
|
|
|
+ Document doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = null;
|
|
|
+
|
|
|
+
|
|
|
+ List<string> filesToZip = new List<string>();
|
|
|
+
|
|
|
+ foreach (var ClientItem in _GroupClient) //遍历单位
|
|
|
+ {
|
|
|
+ doc = new Document(tempPath);
|
|
|
+ builder = new DocumentBuilder(doc);
|
|
|
+ Paragraph paragraph = new Paragraph(doc);
|
|
|
+
|
|
|
+ bookmarkArr = new Dictionary<string, string>();
|
|
|
+ bookmarkArr.Add("titleClientUnit", ClientItem.Key); //title单位
|
|
|
+ bookmarkArr.Add("ClientUnit", ClientItem.Key); //单位
|
|
|
+ bookmarkArr.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));//出发日期
|
|
|
+ bookmarkArr.Add("name", string.Join(",", ClientItem.Select(x => x.Name).ToArray()).TrimEnd(','));//全部人员信息
|
|
|
+ bookmarkArr.Add("VisitCountry", _DelegationInfo.VisitCountry);//出访国家
|
|
|
+ bookmarkArr.Add("dayTime", DateTime.Now.ToString("yyyy年MM月dd日"));//今天日期
|
|
|
+
|
|
|
+ var ClientItemList = ClientItem.ToList();
|
|
|
+ string UsersTop = string.Empty;//word中人员以及金额
|
|
|
+ decimal WordAllPrice = 0.00M;
|
|
|
+
|
|
|
+ //int[] infoColumn = new int[5] {dac1.Select(x=>x.Place.Length).ToList().Max(),2, dac1.Select(x => x.Cost.Length).Max() + dac1.Select(x => x.Currency.Length).Max(),
|
|
|
+ // 6, 3 + dac1.Where(x=>!string.IsNullOrWhiteSpace(x.Place)).Select(x=>(Convert.ToDecimal(x.SubTotal) / Convert.ToDecimal(x.Cost)).ToString().Length).Max() };
|
|
|
+
|
|
|
+ //遍历人员
|
|
|
+ for (int i = 0; i < ClientItemList.Count(); i++)
|
|
|
+ {
|
|
|
+ Dictionary<string, string> TeableBookmarkArr = new Dictionary<string, string>();
|
|
|
+ var client = ClientItemList[i]; //每个人员
|
|
|
+ var firstName = ClientItemList[i].Name;
|
|
|
+
|
|
|
+ //计算费用总和
|
|
|
+ decimal airPrice = client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW;
|
|
|
+ decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
|
|
|
+ dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
|
|
|
+ _EnterExitCosts.Service;
|
|
|
+ WordAllPrice += AllPrice;
|
|
|
+
|
|
|
+ UsersTop += firstName + "出访费用为¥" + AllPrice.ToString("#0.00") + "元、";
|
|
|
+
|
|
|
+ TeableBookmarkArr.Add("jp",(client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW).ToString("#0.00") + " 元"); //机票金额
|
|
|
+ TeableBookmarkArr.Add("cs", _EnterExitCosts.CityTranffic.ToString("#0.00") + " 元"); //城市交通费用
|
|
|
+ TeableBookmarkArr.Add("zs", dac1.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //住宿费
|
|
|
+ string zsinfo = string.Empty;
|
|
|
+ string hsinfo = string.Empty;
|
|
|
+ string gzinfo = string.Empty;
|
|
|
+ List<string> placeArr = new List<string>();
|
|
|
+
|
|
|
+ Aspose.Words.Tables.Table FirstTable = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
|
|
|
+ Aspose.Words.Tables.Table ChildTable = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 0, true);
|
|
|
+ Aspose.Words.Tables.Table ChildTable1 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 1, true);
|
|
|
+ Aspose.Words.Tables.Table ChildTable2 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 2, true);
|
|
|
+
|
|
|
+ int rowIndex = 0;
|
|
|
+ foreach (var item in dac1)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (placeArr.Contains(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ placeArr.Add(item.Place);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ if (rowIndex > ChildTable.Rows.Count - 1)
|
|
|
+ {
|
|
|
+ var chitableRow = ChildTable.LastRow.Clone(true);
|
|
|
+ ChildTable.AppendChild(chitableRow);
|
|
|
+ }
|
|
|
+ int days = dac1.FindAll(x => x.Place == item.Place).Count();
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 0, item.Place);
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 1, days + "晚");
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 2, item.Cost + item.Currency + "/晚");
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
|
|
|
+ rowIndex++;
|
|
|
+ zsinfo += item.Place + " " + days + "晚 " + item.Cost + item.Currency + "/晚" + " 汇率" + (item.SubTotal /item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ placeArr.Clear();
|
|
|
+ rowIndex = 0;
|
|
|
+ foreach (var item in dac2)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (placeArr.Contains(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ placeArr.Add(item.Place);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ if (rowIndex > ChildTable1.Rows.Count - 1)
|
|
|
+ {
|
|
|
+ var chitableRow = ChildTable1.LastRow.Clone(true);
|
|
|
+ ChildTable1.AppendChild(chitableRow);
|
|
|
+ }
|
|
|
+ int days = dac2.FindAll(x => x.Place == item.Place).Count();
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 0, item.Place);
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 1, days + "天");
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 4, "CNY" +item.SubTotal * days);
|
|
|
+ rowIndex++;
|
|
|
+ hsinfo += item.Place + " " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" +item.SubTotal * days + "\r\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ placeArr.Clear();
|
|
|
+ rowIndex = 0;
|
|
|
+ foreach (var item in dac3)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (placeArr.Contains(item.Place))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ placeArr.Add(item.Place);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.Place))
|
|
|
+ {
|
|
|
+ if (rowIndex > ChildTable2.Rows.Count - 1)
|
|
|
+ {
|
|
|
+ var chitableRow = ChildTable2.LastRow.Clone(true);
|
|
|
+ ChildTable2.AppendChild(chitableRow);
|
|
|
+ }
|
|
|
+ int days = dac3.FindAll(x => x.Place == item.Place).Count();
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 0, item.Place);
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 1, days + "天");
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
|
|
|
+ rowIndex++;
|
|
|
+ gzinfo += item.Place + " " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ placeArr.Clear();
|
|
|
+ TeableBookmarkArr.Add("zsinfo", zsinfo); //住宿费详情
|
|
|
+ TeableBookmarkArr.Add("hs", dac2.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //伙食费
|
|
|
+ TeableBookmarkArr.Add("hsinfo", hsinfo); //伙食费详情
|
|
|
+ TeableBookmarkArr.Add("gz", dac3.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //公杂费
|
|
|
+ TeableBookmarkArr.Add("gzinfo", gzinfo); //公杂费详情
|
|
|
+ TeableBookmarkArr.Add("qt", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00") + " 元");//其他费用
|
|
|
+ TeableBookmarkArr.Add("qtinfo", $"(签证费{_EnterExitCosts.Visa.ToString("#0.00")}元、保险{_EnterExitCosts.Safe.ToString("#0.00")}元等费用)");//其他费用第二列
|
|
|
+ TeableBookmarkArr.Add("fw", _EnterExitCosts.Service.ToString("#0.00") + "元/人");//服务费
|
|
|
+ TeableBookmarkArr.Add("AllPrice", AllPrice.ToString("#0.00") + "元/人");//表格合计费用
|
|
|
+ string airStr = client.AirType == 460 ? "经济舱" : client.AirType == 458 ? "公务舱" : "";
|
|
|
+ TeableBookmarkArr.Add("title", $"费用清单-{airStr}({firstName})");
|
|
|
+ foreach (var book in TeableBookmarkArr.Keys)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (doc.Range.Bookmarks[book] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks[book];
|
|
|
+ mark.Text = TeableBookmarkArr[book];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (i != ClientItemList.Count - 1)
|
|
|
+ {
|
|
|
+ builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
|
|
|
+ Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
|
|
|
+ table.ParentNode.InsertAfter(paragraph, table);
|
|
|
+ var CloneTable = (Aspose.Words.Tables.Table)table.Clone(true);
|
|
|
+ table.ParentNode.InsertAfter(CloneTable, paragraph);
|
|
|
+ }
|
|
|
+
|
|
|
+ TeableBookmarkArr.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
|
|
|
+ bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
|
|
|
+ bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用 付辰同志出访费用为¥73,604.8元
|
|
|
|
|
|
+ foreach (var book in bookmarkArr.Keys)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (doc.Range.Bookmarks[book] != null)
|
|
|
+ {
|
|
|
+ Bookmark mark = doc.Range.Bookmarks[book];
|
|
|
+ mark.Text = bookmarkArr[book];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //MemoryStream outSteam = new MemoryStream();
|
|
|
+ string filsPath = $"ForeignReceivables/File/{ClientItem.Key}.docx";
|
|
|
+ doc.Save(AppSettingsHelper.Get("WordBasePath") + filsPath);
|
|
|
+ filesToZip.Add(filsPath);
|
|
|
+ //streams.Add(ClientItem.Key + ".docx", outSteam.ToArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ //文件名
|
|
|
+ string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
|
|
|
+ string zipPath = $"ForeignReceivables/File/{_DelegationInfo.TeamName}-收款账单{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (var zip = ZipFile.Open(zipPath, ZipArchiveMode.Create))
|
|
|
+ {
|
|
|
+ foreach (var file in filesToZip)
|
|
|
+ {
|
|
|
+ zip.CreateEntryFromFile(file, Path.GetFileName(file));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, ex.Message));
|
|
|
+ }
|
|
|
+
|
|
|
+ string url = AppSettingsHelper.Get("WordBasePath") + $"{zipPath}";
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "成功", new { Url = url }));
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(false, "操作失败!"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, ex.Message));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
|
|
|
+ {
|
|
|
+ //获取table中的某个单元格,从0开始
|
|
|
+ Aspose.Words.Tables.Cell lshCell = table.Rows[rows].Cells[cells];
|
|
|
+ //将单元格中的第一个段落移除
|
|
|
+ lshCell.FirstParagraph.Remove();
|
|
|
+ //新建一个段落
|
|
|
+ Paragraph p = new Paragraph(doc);
|
|
|
+ var r = new Run(doc, val);
|
|
|
+ r.Font.Size = 8;
|
|
|
+ //把设置的值赋给之前新建的段落
|
|
|
+ p.AppendChild(r);
|
|
|
+
|
|
|
+ //将此段落加到单元格内
|
|
|
+ lshCell.AppendChild(p);
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 已收款项
|