|
@@ -1589,10 +1589,7 @@ namespace OASystem.API.Controllers
|
|
|
data = ffrData.Data;
|
|
|
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- return Ok(JsonView(false, "请选择正确的端口号!"));
|
|
|
- }
|
|
|
+ else return Ok(JsonView(false, "请选择正确的端口号!"));
|
|
|
return Ok(JsonView(true, "操作成功!", data));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -1711,6 +1708,119 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 已收款项
|
|
|
+ /// 会计团组费用excel下载
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> GroupAccFeeExcelDownload(GroupAccFeeExcelDto dto)
|
|
|
+ {
|
|
|
+ //用户权限验证:只有财务部门的同事才能下载
|
|
|
+ var userInfo = await _sqlSugar.Queryable<Sys_Users>()
|
|
|
+ .LeftJoin<Sys_Department>((x, y) => x.DepId == y.Id)
|
|
|
+ .Where((x, y) => x.Id == dto.UserId && x.IsDel == 0 && y.DepName.Contains("财务"))
|
|
|
+ .FirstAsync();
|
|
|
+ if (userInfo == null) return Ok(JsonView(false, "只有财务部同事可下载!"));
|
|
|
+
|
|
|
+ //团组信息验证
|
|
|
+ var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
|
|
|
+ if (groupInfo == null) return Ok(JsonView(false, "团组信息不存在或已删除,不可下载!"));
|
|
|
+
|
|
|
+ //已收款项信息验证
|
|
|
+ var proceedInfos = await _sqlSugar.Queryable<Fin_ProceedsReceived>()
|
|
|
+ .Where(x => x.Diid == dto.GroupId && x.IsDel == 0)
|
|
|
+ .Select(x => new GroupAccFeeExcelView() {
|
|
|
+ OrgName = x.Client,
|
|
|
+ VisitorNum = 1, //假设每条记录代表一个访客
|
|
|
+ ActualAR = 0.00M,
|
|
|
+ PaidDate = x.SectionTime,
|
|
|
+ PaidAmount = x.Price,
|
|
|
+ Remark = x.Remark,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+ if (!proceedInfos.Any()) return Ok(JsonView(false, "已收款项信息不存在或已删除,不可下载!"));
|
|
|
+
|
|
|
+ var costInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>()
|
|
|
+ .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
|
|
|
+ .FirstAsync();
|
|
|
+
|
|
|
+ var rateInfos = CommonFun.GetCurrencyChinaToList(costInfo.CurrencyRemark);
|
|
|
+
|
|
|
+ var hotelCostInfos = await _sqlSugar.Queryable<Grp_DayAndCost>()
|
|
|
+ .LeftJoin<Sys_SetData>((x, y) => x.Currency == y.Id)
|
|
|
+ .Where((x, y) => x.DiId == dto.GroupId && x.Type == 1 && x.IsDel == 0)
|
|
|
+ .Select((x, y) => new { x.Place, x.Cost, x.Currency, y.Name,CurrencyName = y.Remark, Rate = x.SubTotal / x.Cost, x.SubTotal })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ decimal visaFee = costInfo?.Visa ?? 0.00M, //签证费
|
|
|
+ IntercityFare = costInfo?.CityTranffic ?? 0.00M, //城市区间交通费
|
|
|
+ hotelFee = hotelCostInfos.Sum(x => x.Cost), //住宿费
|
|
|
+ hotelCNYEquivalent = hotelCostInfos.Sum(x => x.SubTotal), //住宿费CNY折算价
|
|
|
+ hotelRate = rateInfos.FirstOrDefault(x => x.CurrencyCode.Equals(hotelCostInfos.FirstOrDefault().Name))?.Rate ?? 0.00M; //住宿费汇率
|
|
|
+ string hotelCurrency = hotelCostInfos.FirstOrDefault()?.CurrencyName ?? "-"; //住宿费币种
|
|
|
+
|
|
|
+ var costInfosNew = new List<GroupAccFeeExcelView>() {
|
|
|
+ new (){ CostName = "酒店",CostAmt = hotelFee,CostCurrency = hotelCurrency, CostRate = hotelRate, CNYEquivalent = hotelCNYEquivalent},
|
|
|
+ new (){ CostName = "市区间交通",CostAmt = IntercityFare,CostCurrency = "人民币" },
|
|
|
+ new (){ CostName = "签证",CostAmt = visaFee,CostCurrency = "人民币" },
|
|
|
+ };
|
|
|
+
|
|
|
+ if (proceedInfos == null || proceedInfos.Count < 1) proceedInfos = costInfosNew;
|
|
|
+ int replaceCount = Math.Min(proceedInfos.Count, costInfosNew.Count);
|
|
|
+ // 替换元素
|
|
|
+ for (int i = 0; i < replaceCount; i++)
|
|
|
+ {
|
|
|
+ var newInfo = costInfosNew[i];
|
|
|
+ proceedInfos[i].CostName = newInfo.CostName;
|
|
|
+
|
|
|
+ if (newInfo.CostAmt != null && newInfo.CostAmt > 0.00M) proceedInfos[i].CostAmt = newInfo.CostAmt;
|
|
|
+ if (newInfo.CostRate != null && newInfo.CostRate > 0.00M) proceedInfos[i].CostRate = newInfo.CostRate;
|
|
|
+ if (newInfo.CNYEquivalent != null && newInfo.CNYEquivalent > 0.00M) proceedInfos[i].CNYEquivalent = newInfo.CNYEquivalent;
|
|
|
+
|
|
|
+ proceedInfos[i].CostCurrency = newInfo.CostCurrency;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加剩余元素
|
|
|
+ if (costInfosNew.Count > proceedInfos.Count) proceedInfos.AddRange(costInfosNew.Skip(proceedInfos.Count));
|
|
|
+
|
|
|
+ int index = 1;
|
|
|
+ proceedInfos.ForEach( x=> {
|
|
|
+ x.Index = index;
|
|
|
+ index++;
|
|
|
+ });
|
|
|
+
|
|
|
+ string url = string.Empty;
|
|
|
+ #region 生成Excel文件
|
|
|
+
|
|
|
+ var designer = new WorkbookDesigner
|
|
|
+ {
|
|
|
+ Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/GroupAccFeeTemp.xlsx")
|
|
|
+ };
|
|
|
+ designer.SetDataSource("DataView", proceedInfos);
|
|
|
+
|
|
|
+ //根据数据源处理生成报表内容
|
|
|
+ designer.Process();
|
|
|
+
|
|
|
+ //设置sum函数
|
|
|
+ int cellIndex = proceedInfos.Count + 3;
|
|
|
+ int cellFormulaIndex = cellIndex - 1;
|
|
|
+ var calcFormula = $"=SUM(F3:F{cellFormulaIndex})";
|
|
|
+ designer.Workbook.Worksheets[0].Cells[$"F{cellIndex}"].Formula = calcFormula;
|
|
|
+
|
|
|
+ //计算sum函数
|
|
|
+ designer.Workbook.Worksheets[0].CalculateFormula(new CalculationOptions() { IgnoreError = true }, true);
|
|
|
+
|
|
|
+ string fileName = $"AmountReceived/{groupInfo.TeamName}_会计团组费用{Guid.NewGuid().ToString()}.xlsx";
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
+ url = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
+ #endregion
|
|
|
+ return Ok(JsonView(true,"操作成功!",url));
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 收款退还与其他款项 --> 收款退还
|