|
@@ -1,14 +1,20 @@
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
+using Aspose.Cells;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.API.OAMethodLib.File;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos.Financial;
|
|
|
+using OASystem.Domain.Dtos.Groups;
|
|
|
+using OASystem.Domain.Entities.Financial;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
+using OASystem.Domain.ViewModels.SmallFun;
|
|
|
using OASystem.Infrastructure.Repositories.Financial;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+using SqlSugar;
|
|
|
+using StackExchange.Redis;
|
|
|
using System.Data;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
@@ -34,8 +40,8 @@ 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)
|
|
|
+ TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
|
|
|
+ PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_config = configuration;
|
|
@@ -70,7 +76,7 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(data));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取日付申请 基础数据源 - 转账表识
|
|
|
/// </summary>
|
|
@@ -114,7 +120,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
return Ok(JsonView(data));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 日付申请 Single Search By Id
|
|
|
/// </summary>
|
|
@@ -133,7 +139,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
return Ok(JsonView(result.Data));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 日付申请 添加
|
|
|
/// </summary>
|
|
@@ -247,28 +253,28 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
//if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
|
|
|
//{
|
|
|
-
|
|
|
+
|
|
|
// //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
|
|
|
// // pairs, datas);
|
|
|
//}
|
|
|
//else //日付常规模板
|
|
|
//{
|
|
|
- pairs.Clear();
|
|
|
- pairs.Add("Opertor", userName);
|
|
|
- pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
- pairs.Add("FAuditStatus", feeData.FAuditDesc);
|
|
|
- pairs.Add("MAuditStatus", feeData.MAuditDesc);
|
|
|
- pairs.Add("SumPrice", feeData.SumPrice);
|
|
|
-
|
|
|
- DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
|
|
|
- datas.Clear();
|
|
|
- datas.Add(data);
|
|
|
- string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
|
|
|
- string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
|
|
|
-
|
|
|
- return Ok(JsonView(true, msg));
|
|
|
+ pairs.Clear();
|
|
|
+ pairs.Add("Opertor", userName);
|
|
|
+ pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ pairs.Add("FAuditStatus", feeData.FAuditDesc);
|
|
|
+ pairs.Add("MAuditStatus", feeData.MAuditDesc);
|
|
|
+ pairs.Add("SumPrice", feeData.SumPrice);
|
|
|
+
|
|
|
+ DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
|
|
|
+ datas.Clear();
|
|
|
+ datas.Add(data);
|
|
|
+ string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
|
|
|
+ string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
|
|
|
+
|
|
|
+ return Ok(JsonView(true, msg));
|
|
|
//}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -276,7 +282,7 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
return Ok(JsonView(true));
|
|
|
}
|
|
|
#endregion
|
|
@@ -291,7 +297,7 @@ namespace OASystem.API.Controllers
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
|
|
|
{
|
|
|
- var data = await GroupCommission.GetCommissionPageList(dto);
|
|
|
+ var data = await GroupCommission.GetCommissionPageList(dto);
|
|
|
|
|
|
return Ok(JsonView(data.Data));
|
|
|
}
|
|
@@ -754,7 +760,7 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(false, "参数不能为空!"));
|
|
|
}
|
|
|
|
|
|
- Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId );
|
|
|
+ Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
|
|
|
dynamic data = null;
|
|
|
if (dto.PortType == 1)
|
|
|
{
|
|
@@ -762,9 +768,9 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
return Ok(JsonView(false, ffrData.Msg));
|
|
|
}
|
|
|
- data= ffrData.Data;
|
|
|
+ data = ffrData.Data;
|
|
|
}
|
|
|
- else if(dto.PortType == 2)
|
|
|
+ else if (dto.PortType == 2)
|
|
|
{
|
|
|
if (ffrData.Code != 0)
|
|
|
{
|
|
@@ -785,7 +791,7 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
return Ok(JsonView(false, "请选择正确的端口号!"));
|
|
|
}
|
|
|
- return Ok(JsonView(true,"操作成功!", data));
|
|
|
+ return Ok(JsonView(true, "操作成功!", data));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -895,11 +901,11 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
|
|
|
-
|
|
|
+ if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
|
|
|
+
|
|
|
if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
|
|
|
-
|
|
|
- if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
|
|
|
+
|
|
|
+ if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
|
|
|
|
|
|
#region 页面功能权限处理
|
|
|
PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
|
|
@@ -1100,5 +1106,203 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 应收报表
|
|
|
+
|
|
|
+ ///// <summary>
|
|
|
+ ///// 应收报表
|
|
|
+ ///// 查询 根据日期范围
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="dto"></param>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //[HttpPost]
|
|
|
+ //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ //public async Task<IActionResult> ExcelSyntheticalReceivable(PostSyntheticalReceivableByDateRangeDto dto)
|
|
|
+ //{
|
|
|
+ //}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 应收报表
|
|
|
+ /// 查询 根据日期范围
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ string sqlWhere = " Where di.IsDel=0 ";
|
|
|
+
|
|
|
+ #region 验证
|
|
|
+ if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "日期参数至少填写一个!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(dto.beginDt))
|
|
|
+ {
|
|
|
+ if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sqlWhere += string.Format(@" And di.VisitDate >= '{0}' ", dto.beginDt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(dto.endDt))
|
|
|
+ {
|
|
|
+ if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sqlWhere += string.Format(@" And di.VisitDate <= '{0}' ", dto.endDt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ string sql = string.Format(@" select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from Fin_ForeignReceivables fr join Grp_DelegationInfo di on fr.DIID = di.id {0} ", sqlWhere);
|
|
|
+
|
|
|
+ List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
|
|
|
+
|
|
|
+ decimal sumAll_fr = 0M;
|
|
|
+ decimal sumAll_pr = 0M;
|
|
|
+ decimal sumAll_balance = 0M;
|
|
|
+
|
|
|
+ if (list_rst.Count > 0)
|
|
|
+ {
|
|
|
+ int rowNumber = 1;
|
|
|
+ foreach (var item_rst in list_rst)
|
|
|
+ {
|
|
|
+ item_rst.No = rowNumber;
|
|
|
+ rowNumber++;
|
|
|
+
|
|
|
+ int diId = item_rst.diid;
|
|
|
+ decimal sum_fr = 0M;
|
|
|
+ decimal sum_pr = 0M;
|
|
|
+ string str_client = string.Empty;
|
|
|
+ decimal sum_other = 0M;
|
|
|
+ decimal balance = 0M;
|
|
|
+ string str_schedule = string.Empty;
|
|
|
+
|
|
|
+ //1.
|
|
|
+ string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
|
|
|
+ List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
|
|
|
+ sum_fr = list_fr.Sum(s => s.ItemSumPrice);
|
|
|
+
|
|
|
+ //2.
|
|
|
+ string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
|
|
|
+ List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
|
|
|
+ foreach (var item_pr in list_pr)
|
|
|
+ {
|
|
|
+ sum_pr += item_pr.Price;
|
|
|
+ str_client += string.Format(@"{0};", item_pr.Client);
|
|
|
+ str_schedule += string.Format(@"{0};", item_pr.Remark);
|
|
|
+ }
|
|
|
+ if (str_schedule.Length > 0)
|
|
|
+ {
|
|
|
+ str_schedule = str_schedule.TrimEnd(';');
|
|
|
+ }
|
|
|
+ if (str_client.Length > 0)
|
|
|
+ {
|
|
|
+ str_client = str_client.TrimEnd(';');
|
|
|
+ }
|
|
|
+
|
|
|
+ //3.
|
|
|
+ string sql_other = string.Format(@" Select * From Fin_OtherPrice where diid = {0} and isdel = 0 and RefundType = 1 and PayType=1 ", diId);
|
|
|
+ List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
|
|
|
+ sum_other = list_other.Sum(s => s.Price);
|
|
|
+
|
|
|
+ item_rst.frPrice = sum_fr.ToString("#0.00");
|
|
|
+ item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
|
|
|
+ item_rst.balPrice = (sum_fr - (sum_pr - sum_other)).ToString("#0.00");
|
|
|
+ item_rst.clientUnit = str_client;
|
|
|
+ item_rst.schedule = str_schedule;
|
|
|
+
|
|
|
+ sumAll_fr += sum_fr;
|
|
|
+ sumAll_pr += (sum_pr - sum_other);
|
|
|
+ sumAll_balance += (sum_fr - (sum_pr - sum_other));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
|
|
|
+ result.total_fr = sumAll_fr.ToString("#0.00");
|
|
|
+ result.total_pr = sumAll_pr.ToString("#0.00");
|
|
|
+ result.total_balance = sumAll_balance.ToString("#0.00");
|
|
|
+ result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
|
|
|
+
|
|
|
+ if (dto.requestType == 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, "请求成功", result, list_rst.Count));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //----------------------------
|
|
|
+ List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
|
|
|
+ WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
+ designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
|
|
|
+
|
|
|
+ int excNo = 1;
|
|
|
+ foreach (var item in list_rst)
|
|
|
+ {
|
|
|
+ Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
|
|
|
+ exc.No = excNo.ToString();
|
|
|
+ excNo++;
|
|
|
+ exc.TeamName = item.teamName;
|
|
|
+ exc.ClientUnit = item.clientUnit;
|
|
|
+ exc.VisitDate = item.visitDate;
|
|
|
+ exc.Accounts = item.frPrice;
|
|
|
+ exc.Received = item.prPrice;
|
|
|
+ exc.Balance = item.balPrice;
|
|
|
+ exc.Collection = item.schedule;
|
|
|
+ DateTime time = Convert.ToDateTime(item.visitDate);
|
|
|
+ TimeSpan ts = DateTime.Now - time;
|
|
|
+ float SY = float.Parse(item.balPrice);
|
|
|
+ if (ts.Days >= 365 && SY > 0)
|
|
|
+ {
|
|
|
+ exc.Sign = "需收款";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ exc.Sign = "";
|
|
|
+ }
|
|
|
+ list_Ex.Add(exc);
|
|
|
+ }
|
|
|
+
|
|
|
+ var dt = CommonFun.GetDataTableFromIList(list_Ex);
|
|
|
+ dt.TableName = "Excel_SyntheticalReceivableByDateRange";
|
|
|
+ if (dt != null)
|
|
|
+ {
|
|
|
+ designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
|
|
|
+
|
|
|
+ //数据源
|
|
|
+ designer.SetDataSource(dt);
|
|
|
+
|
|
|
+
|
|
|
+ //根据数据源处理生成报表内容
|
|
|
+ designer.Process();
|
|
|
+
|
|
|
+ string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
+ string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
+ return Ok(JsonView(true, "成功", new { url = rst }));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "获取成功", "", list_rst.Count));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|