Commit 434b9a9a by lcx

添加接口

parent 8e927fdb
......@@ -218,5 +218,18 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R
var list = reportService.MenuReport(request);
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
/// 绩效汇报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("table")]
[HttpPost]
public ApiResponse Table([FromBody] ConditionRequest request)
{
var list = reportService.Table(request);
return new ApiResponse(ResponseType.OK, "", list);
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ConditionRequest
{
public int[] Year { get; set; }
public int[] Month { get; set; }
public string[] AccountingUnit { get; set; }
public string[] UnitType { get; set; }
}
public class TableData
{
public List<Header> Headers { get; set; }
public string Data { get; set; }
}
public class Header
{
public string Date { get; set; }
public string AccountingUnit { get; set; }
public string UnitType { get; set; }
public string Field { get; set; }
}
public class QueryData
{
public int HospitalId { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public string AccountingUnit { get; set; }
public string UnitType { get; set; }
public string SourceType { get; set; }
public string Category { get; set; }
public string ItemName { get; set; }
public Nullable<decimal> Value { get; set; }
}
}
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.DtoModels.Request;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -402,5 +404,45 @@ public void ExecProc(string execsql, object param)
logger.LogError($"执行存储过程时发生异常,sql:{execsql};参数:{JsonHelper.Serialize(param)};异常:{ex.Message};");
}
}
public TableData Table(ConditionRequest request)
{
TableData tableData = new TableData();
try
{
var condition = request.Year.Join(request.Month, t => true, t => true, (t1, t2) => new { t1, t2 });
var data = perforReportRepository.DapperQuery<QueryData>("", new { });
if (data == null || !data.Any()) return tableData;
var groupData = data.GroupBy(t => new { t.SourceType, t.Category, t.ItemName });
var type = data.Select(t => new { SourceType = t.SourceType.NoBlank(), Category = t.Category.NoBlank(), ItemName = t.ItemName.NoBlank() }).Distinct();
var groupType = type.GroupBy(t => t.SourceType).Select(t => new
{
Type = t.Key,
Count = t.Count()
}).OrderBy(t => t.Type).ThenBy(t => t.Count);
// 含有子集
foreach (var item in groupType.Where(t => t.Count > 1))
{
}
// 不包含子集含有子集
foreach (var item in groupType.Where(t => t.Count == 1))
{
}
}
catch (Exception)
{
}
return tableData;
}
}
}
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