Commit b86daa53 by GhostUI

提交代码

parent 797fa862
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.Dtos.Finance
{
public class FinanceDto
{
//public List<dc_base_finance_fee> Finance { get; set; }
public List<columnsObj> Col { get; set; } = new List<columnsObj>();
public string Data { get; set; }
}
public class columnsObj
{
public string title { get; set; }
public string key { get; set; }
public bool show { get; set; } = true;
public string width { get; set; } = "120";
}
}
......@@ -5,6 +5,7 @@ using Bailun.DC.Models.Common;
using Bailun.DC.Models.Common.Page;
using Bailun.DC.Models.Dtos.Finance;
using Dapper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -16,10 +17,11 @@ namespace Bailun.DC.Services.WebApiService
{
public partial class FinanceService
{
public async Task<CommonApiResponseDto<List<dc_base_finance_fee>>> GetCashFlowStatement(GetCashFlowStatementInput input)
public CommonApiResponseDto<FinanceDto> GetCashFlowStatement(GetCashFlowStatementInput input)
{
try
{
var dtos = new FinanceDto();
var sql = $@"select * from dc_base_finance_fee s1
left JOIN dc_base_finance_company s2
ON s1.company_name = s2.company_name
......@@ -33,23 +35,110 @@ and s2.company_type = @CorporateEntity";
para.Add("PaymentTimeEnd", input.PaymentTimeEnd.Date);
para.Add("CorporateEntity", input.CorporateEntity);
var data = SimpleCRUD.Query<dc_base_finance_fee>(sql, para, GlobalConfig.ConnectionString).ToList();
foreach (var item in data)
{
if (item.cost_form == 2)
{
item.amount = -(item.amount);
item.amount_rmb = -(item.amount_rmb);
}
//借支单待还余额
if (item.cost_form == 3)
{
if (item.is_lend.HasValue && item.is_lend.Value == 2 && ((item.lend_balance ?? 0) > 0)) //归还金额
{
item.amount = -(item.amount);
item.amount_rmb = -(item.amount_rmb);
}
}
}
if (data.Count > 0)
{
var url = ConfigHelper.AppSetting("cwUrl");
url += $"?BeginRepayTime={input.PaymentTimeStart.ToString("yyyy-MM-dd")}&EndRepayTime={input.PaymentTimeEnd.ToString("yyyy-MM-dd")}";
var listInterest = new FinanceReportServices().ListInterestExpense(url);//手续费
var listHandleFee = new FinanceReportServices().ListFinanceHandleFee(input.PaymentTimeStart, input.PaymentTimeEnd, null, "");//利息支出
var Col = data.GroupBy(a => a.company_name).Select(p => p.Key).OrderBy(a => a).ToList();
var listValue = new List<Tuple<string, List<decimal>>>();
for (var i = 0; i < Col.Count; i++)
{
//主体下所有费用单
var feedata = data.Where(x => x.company_name == Col[i]).ToList();
foreach (var item in feedata)
{
var obj = listValue.Where(a => a.Item1 == item.type_name).FirstOrDefault();
if (obj == null)
{
var listItems = new List<decimal>();
while (listItems.Count < Col.Count)//所有主体都添加上
{
listItems.Add(0.00M);
}
listItems[i] = item.amount_rmb ?? 0;//当前主体赋值
listValue.Add(new Tuple<string, List<decimal>>(item.type_name, listItems));
}
else
{
obj.Item2[i] += item.amount_rmb ?? 0;
}
}
}
dtos.Col.Add(new columnsObj
{
key = "key",
title = "费用类型"
});
for (int j = 0; j < Col.Count; j++)
{
var keyInfo = new columnsObj
{
key = "key" + j,
title = Col[j]
};
dtos.Col.Add(keyInfo);
}
var jsonStr = "[";
for (int i = 0; i < listValue.Count; i++)
{
jsonStr += "{";
jsonStr += "\"key\":\"" + listValue[i].Item1 + "\",";
for (int j = 1; j < listValue[i].Item2.Count; j++)
{
jsonStr += "\"" + dtos.Col[j].key + "\":\"" + listValue[i].Item2[j] + "\",";
}
jsonStr = jsonStr.Trim(',');
jsonStr += "},";
}
jsonStr = jsonStr.Trim(',');
jsonStr += "]";
//if (listInterest.Count > 0)
//{
//}
//if (listHandleFee.Count > 0)
//{
var url = ConfigHelper.AppSetting("cwUrl");
return new CommonApiResponseDto<List<dc_base_finance_fee>>
//}
dtos.Data = jsonStr;
}
return new CommonApiResponseDto<FinanceDto>
{
Data = data
Data = dtos
};
}
catch (Exception e)
{
return new CommonApiResponseDto<List<dc_base_finance_fee>> { IsSuccess = false, Message = e.Message };
return new CommonApiResponseDto<FinanceDto> { IsSuccess = false, Message = e.Message };
}
}
private async Task<List<Models.Api.mInterestExpense>> GetMInterestExpense(string url)
private List<Models.Api.mInterestExpense> GetMInterestExpense(string url)
{
using (var http = new HttpClient())
{
var result = await http.GetStringAsync(url);
var result = http.GetStringAsync(url).GetAwaiter().GetResult();
var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Api.mInterestExpense>>(result);
return obj;
};
......
......@@ -1374,7 +1374,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <param name="PayName"></param>
/// <param name="ismanager">是否管理成本</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
//[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
[BrowseLog("Bailun_data", "访问【百伦数据中心】->【财务报表】->【管理成本报表】->【查询】页面", 0)]
public JsonResult AdministrativeCostJson(int t, DateTime start,DateTime end,int? paycompanyid,int? ismanager)
......
......@@ -40,7 +40,7 @@ namespace Bailun.DC.WebApi.Controllers
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("getCashFlowStatement")]
public async Task<CommonApiResponseDto<List<dc_base_finance_fee>>> GetCashFlowStatement(GetCashFlowStatementInput input)
=> await new FinanceService().GetCashFlowStatement(input);
public CommonApiResponseDto<FinanceDto> GetCashFlowStatement(GetCashFlowStatementInput input)
=> new FinanceService().GetCashFlowStatement(input);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment