|
@@ -1,5 +1,6 @@
|
|
|
using Aspose.Cells;
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
+using NetUV.Core.Handles;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.AesEncryption;
|
|
@@ -1319,6 +1320,148 @@ ORDER BY
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 团组报表
|
|
|
+ /// Excel 下载
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">团组列表请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostGroupStatementExportExcel")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostGroupStatementExportExcel(GroupStatementDetailsDto _dto)
|
|
|
+ {
|
|
|
+ //pageId 38
|
|
|
+ int currUserId = _dto.UserId, pageId = _dto.PageId, diId = _dto.DiId;
|
|
|
+ bool isAudit = _dto.isAudit;
|
|
|
+ #region 参数验证
|
|
|
+ if (currUserId < 1) return Ok(JsonView(false, "员工Id为空"));
|
|
|
+ if (pageId < 1) return Ok(JsonView(false, "页面Id为空"));
|
|
|
+ if (diId < 1) return Ok(JsonView(false, "数据Id为空"));
|
|
|
+
|
|
|
+ #region 页面操作权限验证
|
|
|
+ var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(currUserId, pageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权!"));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).First();
|
|
|
+ if (groupInfo == null) return Ok(JsonView(false, "暂无该条团组信息!"));
|
|
|
+ var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.Id == currUserId).First();
|
|
|
+
|
|
|
+ string groupNo = groupInfo.TourCode,
|
|
|
+ groupName = groupInfo.TeamName.Replace("|", "、"),
|
|
|
+ lister = userInfo?.CnName ?? "-";
|
|
|
+
|
|
|
+ var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>()
|
|
|
+ .Where(it => it.IsDel == 0)
|
|
|
+ .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Sex = x.Sex })
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+
|
|
|
+ //获取模板
|
|
|
+ string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/团组费用统计模板.xls");
|
|
|
+ var designer = new WorkbookDesigner();
|
|
|
+ designer.Workbook = new Workbook(tempPath);
|
|
|
+ // 获取工作簿中的工作表集合
|
|
|
+ var worksheets = designer.Workbook.Worksheets;
|
|
|
+
|
|
|
+ var visaFeeSheet = worksheets["签证费用"];
|
|
|
+ #region 签证费用
|
|
|
+ if (visaFeeSheet != null)
|
|
|
+ {
|
|
|
+ string groupVisaFeeSql = string.Format(@"Select vi.Id As VisaId,vi.DIId As VisaDiId,vi.VisaClient,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
|
|
|
+ ccp.DayRate,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
|
|
|
+ sd3.Name As CardTypeName,ccp.IsPay,u.CnName As Applicant,vi.CreateTime,
|
|
|
+ (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice
|
|
|
+ From Grp_VisaInfo vi
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 80 And vi.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
+ Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where vi.IsDel = 0 {1} And vi.DIId = {0} Order By CreateTime", diId,isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+
|
|
|
+ var groupVisaFeeViews = _sqlSugar.Queryable<Grp_VisaInfo>()
|
|
|
+ .InnerJoin<Grp_CreditCardPayment>((vi, ccp) => ccp.IsDel == 0 && ccp.CTable == 80 && vi.Id == ccp.CId)
|
|
|
+ .LeftJoin<Sys_SetData>((vi, ccp,sd1) => ccp.PaymentCurrency == sd1.Id)
|
|
|
+ .LeftJoin<Sys_SetData>((vi, ccp, sd1, sd2) => ccp.PayDId == sd2.Id)
|
|
|
+ .Where((vi, ccp, sd1) => vi.IsDel == 0 && vi.DIId == diId)
|
|
|
+ .WhereIF(isAudit, (vi, ccp, sd1, sd2) => ccp.IsAuditGM == 1)
|
|
|
+ .Select((vi, ccp, sd1, sd2) => new {
|
|
|
+ //VisaClient = GetVisaClientNames( vi.VisaClient,_clientDatas),
|
|
|
+ vi.VisaClient,
|
|
|
+ ccp.PayMoney,
|
|
|
+ ccp.DayRate,
|
|
|
+ Currency = sd1.Name,
|
|
|
+ ccp.ConsumptionDate,
|
|
|
+ vi.Remark,
|
|
|
+ ccp.Payee,
|
|
|
+ PaymentModes = sd2.Name,
|
|
|
+ CostMark = ccp.OrbitalPrivateTransfer == 0 ? "公转" : "私转",
|
|
|
+ PaymentStatus = ccp.IsPay == 0 ? "未付款" :"已付款"
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var visaCNYTotalCost = groupVisaFeeViews.Sum(x => x.PayMoney * x.DayRate);
|
|
|
+
|
|
|
+ var visaFeeDt = CommonFun.ToDataTableArray(groupVisaFeeViews);
|
|
|
+ visaFeeDt.TableName = $"VisaFeeView";
|
|
|
+ designer.SetDataSource(visaFeeDt);
|
|
|
+ designer.SetDataSource("VisaCNYTotalCost", visaCNYTotalCost.ToString("#0.00"));
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ designer.SetDataSource("GroupNo", groupNo);
|
|
|
+ designer.SetDataSource("GroupName", groupName);
|
|
|
+ designer.SetDataSource("Lister", lister);
|
|
|
+ designer.Process();
|
|
|
+ //文件名
|
|
|
+ string fileName = $"{groupName}[{groupNo}]_团组费用清单{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "GroupStatement/" + fileName);
|
|
|
+ string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/GroupStatement/" + fileName;
|
|
|
+ return Ok(JsonView(true, "成功", url));
|
|
|
+ }
|
|
|
+
|
|
|
+ private string GetVisaClientNames(string nameStr, List<Crm_DeleClient> _clientDatas)
|
|
|
+ {
|
|
|
+ string names = string.Empty;
|
|
|
+
|
|
|
+ string visaClients = nameStr;
|
|
|
+ if (!string.IsNullOrEmpty(visaClients))
|
|
|
+ {
|
|
|
+ var clientIds = new string[] { };
|
|
|
+ if (visaClients.Contains(',')) clientIds = visaClients.Split(',');
|
|
|
+ else clientIds = new string[] { visaClients };
|
|
|
+
|
|
|
+ if (clientIds.Length > 0)
|
|
|
+ {
|
|
|
+ var clientIds1 = new List<int>() { };
|
|
|
+ foreach (var clientIdStr in clientIds)
|
|
|
+ {
|
|
|
+ var isInt = int.TryParse(clientIdStr, out int id);
|
|
|
+ if (isInt) clientIds1.Add(id);
|
|
|
+ }
|
|
|
+ if (clientIds1.Count > 0)
|
|
|
+ {
|
|
|
+ var clients = _clientDatas.Where(it => clientIds1.Contains(it.Id)).ToList();
|
|
|
+
|
|
|
+ foreach (var client in clients)
|
|
|
+ {
|
|
|
+ EncryptionProcessor.DecryptProperties(client);
|
|
|
+ names += $"{client.LastName + client.FirstName},";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else names = visaClients;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (names.Length > 0) names = names.Substring(0, names.Length - 1);
|
|
|
+
|
|
|
+ return names;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 报表/折线图统计
|