Commit f0136a39 by lcx

report_global增删的接口完善

parent bb46a3e8
......@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using System;
......@@ -33,6 +34,62 @@ ReportGlobalService reportGlobalService
}
/// <summary>
/// 获取报表配置信息
/// </summary>
/// <param name="hospitalId"></param>
/// <returns></returns>
[HttpGet]
public ApiResponse GetAllReportGlobal([FromRoute] int hospitalId)
{
//reportGlobalService.CopyPreviousGlobalData(new per_allot
//{
// ID = 101,
// HospitalId = 13,
// Year = 2020,
// Month = 8
//});
var result = reportGlobalService.GetReportGlobals(hospitalId);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 添加报表配置
/// </summary>
/// <param name="global"></param>
/// <returns></returns>
[HttpPost]
public ApiResponse CreateReportGlobal([FromBody] report_global global)
{
var result = reportGlobalService.CreateReportGlobal(global);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 修改报表配置
/// </summary>
/// <param name="global"></param>
/// <returns></returns>
[HttpPost("update")]
public ApiResponse UpdateReportGlobal([FromBody] report_global global)
{
var result = reportGlobalService.UpdateReportGlobal(global);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 删除报表配置
/// </summary>
/// <param name="globalId"></param>
/// <returns></returns>
[HttpPost("{globalId}")]
public ApiResponse DeleteReportGlobal([FromRoute] int globalId)
{
var result = reportGlobalService.DeleteReportGlobal(globalId);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 上传人员绩效文件
/// </summary>
/// <param name="hospitalId"></param>
......
......@@ -1094,6 +1094,34 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.GetAllReportGlobal(System.Int32)">
<summary>
获取报表配置信息
</summary>
<param name="hospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.CreateReportGlobal(Performance.EntityModels.report_global)">
<summary>
添加报表配置
</summary>
<param name="global"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.UpdateReportGlobal(Performance.EntityModels.report_global)">
<summary>
修改报表配置
</summary>
<param name="global"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.DeleteReportGlobal(System.Int32)">
<summary>
删除报表配置
</summary>
<param name="globalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.Import(System.Int32,Microsoft.AspNetCore.Http.IFormCollection)">
<summary>
上传人员绩效文件
......
......@@ -3856,17 +3856,17 @@
类别
</summary>
</member>
<member name="P:Performance.EntityModels.report_global.Type">
<member name="P:Performance.EntityModels.report_global.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_global.InputName">
<member name="P:Performance.EntityModels.report_global.Month">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_global.InputType">
<member name="P:Performance.EntityModels.report_global.Value">
<summary>
</summary>
......
......@@ -32,12 +32,124 @@ PerforHisimportdataRepository hisimportdataRepository
this.hisimportdataRepository = hisimportdataRepository;
}
#region Report_Global
public List<report_global> GetReportGlobals(int hospitalId)
{
var globals = reportglobalRepository.GetEntities(t => t.HospitalID == hospitalId);
var globals = reportglobalRepository.GetEntities(t => t.HospitalID == hospitalId)
?.OrderBy(t => t.Category).ThenBy(t => t.Year).ThenBy(t => t.Month).ToList();
return globals;
}
public bool CreateReportGlobal(report_global global)
{
return reportglobalRepository.Add(global);
}
public bool UpdateReportGlobal(report_global global)
{
var entity = reportglobalRepository.GetEntity(t => t.Id == global.Id);
entity.Year = global.Year;
entity.Month = global.Month;
entity.Category = global.Category;
entity.Value = global.Value;
return reportglobalRepository.Update(entity);
}
public bool DeleteReportGlobal(int globalId)
{
var entity = reportglobalRepository.GetEntity(t => t.Id == globalId);
return reportglobalRepository.Remove(entity);
}
#endregion Report_Global
#region Copy Previous Report Data
public void CopyPreviousGlobalData(per_allot allot)
{
var globals = reportglobalRepository.GetEntities(t => t.HospitalID == allot.HospitalId);
if (globals == null || !globals.Any()) return;
var onlyYears = globals.Where(t => t.Year.HasValue && !t.Month.HasValue);
if (onlyYears != null && onlyYears.Any())
{
var year = onlyYears.Where(t => t.Year < allot.Year)?.Max(t => t.Year);
if (year.HasValue)
{
var current = onlyYears.Where(t => t.Year == allot.Year)?.ToList() ?? new List<report_global>();
var previous = onlyYears.Where(t => t.Year == year)?.ToList() ?? new List<report_global>();
var newdata = previous.Where(t => !current.Select(s => s.Category).Contains(t.Category))?.ToList();
if (newdata != null && newdata.Any())
{
newdata = newdata.Select(t => new report_global
{
HospitalID = allot.HospitalId,
Year = allot.Year,
Category = t.Category,
Value = t.Value
}).ToList();
reportglobalRepository.AddRange(newdata.ToArray());
}
}
}
var yearAndMonth = globals.Where(t => t.Year.HasValue && t.Month.HasValue);
if (yearAndMonth != null && yearAndMonth.Any())
{
var month = yearAndMonth.Where(t => t.Year == allot.Year && t.Month < allot.Month)?.Max(t => t.Month);
if (allot.Month == 1 || !month.HasValue)
{
var year = yearAndMonth.Where(t => t.Year < allot.Year)?.Max(t => t.Year);
month = yearAndMonth.Where(t => t.Year == year)?.Max(t => t.Month);
if (year.HasValue && month.HasValue)
{
var current = yearAndMonth.Where(t => t.Year == allot.Year && t.Month == allot.Month)?.ToList() ?? new List<report_global>();
var previous = yearAndMonth.Where(t => t.Year == year && t.Month == month)?.ToList() ?? new List<report_global>();
var newdata = previous.Where(t => !current.Select(s => s.Category).Contains(t.Category))?.ToList();
if (newdata != null && newdata.Any())
{
newdata = newdata.Select(t => new report_global
{
HospitalID = allot.HospitalId,
Year = allot.Year,
Month = allot.Month,
Category = t.Category,
Value = t.Value
}).ToList();
reportglobalRepository.AddRange(newdata.ToArray());
}
}
}
else
{
if (month.HasValue)
{
var current = yearAndMonth.Where(t => t.Year == allot.Year && t.Month == allot.Month)?.ToList() ?? new List<report_global>();
var previous = yearAndMonth.Where(t => t.Year == allot.Year && t.Month == month)?.ToList() ?? new List<report_global>();
var newdata = previous.Where(t => !current.Select(s => s.Category).Contains(t.Category))?.ToList();
if (newdata != null && newdata.Any())
{
newdata = newdata.Select(t => new report_global
{
HospitalID = allot.HospitalId,
Year = allot.Year,
Month = allot.Month,
Category = t.Category,
Value = t.Value
}).ToList();
reportglobalRepository.AddRange(newdata.ToArray());
}
}
}
}
}
#endregion Copy Previous Report Data
#region ImportFile && SaveData
public void ImportAllotData(int hospitalId, string filePath)
......
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