Przeglądaj źródła

EnterExitCostMobileOpSingleStep3To6 --> FeeType 更更改为 “ 3 住宿费;4 伙食费;5 公杂费;6 培训费”

LEIYI 3 miesięcy temu
rodzic
commit
d616aee8b1

+ 9 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -8122,22 +8122,26 @@ FROM
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
         {
-            var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
+            var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
             int subId = dto.SubId, feeType = dto.FeeType;
 
             if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
             if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
             if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
 
-            if (!feeTypeIds.Contains(feeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
+            if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
            
             var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
             subInfo.Id = subId;
             subInfo.DiId = dto.DiId;
-            subInfo.Type = feeType;
+
+            if (feeType == 3) subInfo.Type = 1;
+            else if (feeType == 4) subInfo.Type = 1;
+            else if (feeType == 5) subInfo.Type = 1;
+            else if (feeType == 6) subInfo.Type = 1;
+
             subInfo.CreateUserId = dto.CurrUserId;
 
-            
             //子表op
             if (subId < 1)
             {
@@ -8160,7 +8164,7 @@ FROM
                 if (subUpd < 1) return Ok(JsonView(false));
             }
            
-            var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
+            var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
 
             //消息通知
             var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;

+ 143 - 0
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -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 报表/折线图统计

+ 1 - 1
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDto.cs

@@ -697,7 +697,7 @@ namespace OASystem.Domain.Dtos.Groups
 
         /// <summary>
         /// 费用类型
-        /// 1 住宿费;2 伙食费;3 公杂费;4 培训费
+        /// 3 住宿费;4 伙食费;5 公杂费;6 培训费
         /// </summary>
         public int FeeType { get; set; }