Commit a2aef2fd by lcx

新增运营分析接口

parent 7b8c1c74
...@@ -218,5 +218,18 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R ...@@ -218,5 +218,18 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R
var list = reportService.MenuReport(request); var list = reportService.MenuReport(request);
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
/// <summary>
/// 菜单报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("operation")]
[HttpPost]
public ApiResponse Operation([ FromBody] ReportRequest request)
{
var list = reportService.Test(request);
return new ApiResponse(ResponseType.OK, "", list);
}
} }
} }
\ No newline at end of file
...@@ -1449,6 +1449,13 @@ ...@@ -1449,6 +1449,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ReportController.Operation(Performance.DtoModels.ReportRequest)">
<summary>
菜单报表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.GetAllReportGlobal(System.Int32)"> <member name="M:Performance.Api.Controllers.ReportGlobalController.GetAllReportGlobal(System.Int32)">
<summary> <summary>
获取报表配置信息 获取报表配置信息
......
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
......
...@@ -402,5 +402,47 @@ public void ExecProc(string execsql, object param) ...@@ -402,5 +402,47 @@ public void ExecProc(string execsql, object param)
logger.LogError($"执行存储过程时发生异常,sql:{execsql};参数:{JsonHelper.Serialize(param)};异常:{ex.Message};"); logger.LogError($"执行存储过程时发生异常,sql:{execsql};参数:{JsonHelper.Serialize(param)};异常:{ex.Message};");
} }
} }
public List<PerReport> Test(ReportRequest request)
{
string where = "";
if (!string.IsNullOrEmpty(request.Year))
{
where += $" and year in ({request.Year}) ";
}
if (!string.IsNullOrEmpty(request.Month))
{
where += $" and month in ({request.Month}) ";
}
var getDate = $"select distinct year, month from view_test_data where hospitalid = {request.HospitalId} {where}";
var dateList = perforReportRepository.DapperQuery<per_allot>(getDate, new { });
if (dateList == null || !dateList.Any()) return new List<PerReport>();
if (string.IsNullOrEmpty(request.Year))
{
int year = dateList.Max(m => m.Year);
dateList = dateList.Where(t => t.Year == year).ToList();
}
StringBuilder fields = new StringBuilder(string.Empty);
foreach (var date in dateList.OrderBy(t => t.Year).ThenBy(t => t.Month))
{
fields.Append($" sum(case when year = {date.Year} and month = {date.Month} then if(ifnull(value, '')<>'', value, 0) else 0 end) `{date.Year}{date.Month}月`,");
}
string columns = fields.ToString();
if (!string.IsNullOrEmpty(columns) && columns.Length > 1)
columns = "," + columns.Substring(0, columns.Length - 1);
string sql = $"select source, category, itemname {columns} from view_test_data where hospitalid = @hospitalid and year in @year and month in @month group by source, category, itemname;";
var data = perforReportRepository.DapperQuery<object>(sql, new { hospitalId = request.HospitalId, year = dateList.Select(t => t.Year), month = dateList.Select(t => t.Month) })?.ToList();
if (data == null || !data.Any())
return new List<PerReport>();
return new List<PerReport>();
}
} }
} }
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