Commit aea7d36f by 纪旭 韦

no message

parent 2dbc74f7
......@@ -395,14 +395,16 @@ public ApiResponse GetWholeHospitalGrantSummary([FromBody] HospitalGrantSummary
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_dept", bdate, edate.AddMonths(1));
var datas = _computeService.GetAllComputeViewByDateAndTotal("view_allot_sign_dept", bdate, edate.AddMonths(1),request.GroupBy,request.SumBy);
if (null == datas)
throw new PerformanceException("当前绩效记录不存在");
var selectdata = request.GroupBy.Union(request.SumBy);
var data = datas.GroupBy(t => new { t.UnitName });
return new ApiResponse(ResponseType.OK, "ok", data);
var list = new QueryComputeByDateGetTotal
{
Data = datas.ToList(),
TotalData = _computeService.SumDatas(datas),
};
return new ApiResponse(ResponseType.OK, "ok", list);
}
......
......@@ -82,4 +82,8 @@ public class QueryComputeByDateGetPage
public int PageSize { get; set; }
public int TotalCount { get; set; }
}
}
public class QueryComputeByDateGetTotal
{
public List<dynamic> Data { get; set; }
public Dictionary<string, decimal> TotalData { get; set; }}
}
......@@ -397,6 +397,7 @@ public List<dynamic> QueryCompute(int allotId, string viewName)
return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
}
public List<dynamic> QueryComputeByDate(string viewName, DateTime beginTime, DateTime endTime)
{
var sql = $@"SELECT * FROM {viewName}
......@@ -405,6 +406,26 @@ public List<dynamic> QueryComputeByDate(string viewName, DateTime beginTime, Dat
return DapperQuery<dynamic>(sql, new { beginTime = beginTime.ToString("yyyy-MM-dd"), endTime = endTime.ToString("yyyy-MM-dd") }).ToList();
}
public List<dynamic> QueryComputeByDateAndTotal(string viewName, DateTime beginTime, DateTime endTime,List<string> groupBy, List<string> sumBy)
{
string Groupby = "";
string Sumby = "";
foreach (var item in groupBy)
{
Groupby += $@"{item},";
}
foreach (var item in sumBy)
{
Sumby += $@"Sum({item}) {item},";
}
Groupby = Groupby.Substring(0,Groupby.Length - 1);
Sumby = Sumby.Substring(0,Sumby.Length - 1);
var sql = $@"SELECT {Groupby},{Sumby} FROM {viewName} where STR_TO_DATE(concat(Year,'-',Month,'-01'),'%Y-%m-%d') >= @beginTime
and STR_TO_DATE(concat(Year,'-',Month,'-01'),'%Y-%m-%d') < @endTime Group By {Groupby}";
return DapperQuery<dynamic>(sql, new { beginTime = beginTime.ToString("yyyy-MM-dd"), endTime = endTime.ToString("yyyy-MM-dd") }).ToList();
}
public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
{
......
......@@ -2069,10 +2069,14 @@ public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewN
{
return reportRepository.QueryCompute(AllotId, viewName);
}
public List<dynamic> GetAllComputeViewByDate(string viewName, DateTime beginTime, DateTime endTime)
{
return reportRepository.QueryComputeByDate(viewName, beginTime, endTime);
}
public List<dynamic> GetAllComputeViewByDateAndTotal(string viewName, DateTime beginTime, DateTime endTime,List<string> groupBy,List<string> sumBy)
{
return reportRepository.QueryComputeByDateAndTotal(viewName, beginTime, endTime,groupBy,sumBy);
}
/// <summary>
///
......
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