Commit 3a01c5dc by lcx

Merge branch 'v2020morge' into v2020morge-graphql

# Conflicts:
#	performance/Performance.EntityModels/Entity/report_global.cs
parents 8d04651f 38d20192
......@@ -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>
......
......@@ -401,11 +401,11 @@ public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
[HttpPost]
public ApiResponse OtherList([FromBody] AgOtherRequest request)
{
var result = secondAllotService.OtherList(request.SecondId, claimService.GetUserId());
//var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
//var result = secondAllotService.OtherList(request.SecondId, claimService.GetUserId());
var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
var obj = new
{
header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(s => s.RealAmount) ?? 0),
header = secondAllotService.OtherListHeader(request.SecondId, realAmount),
body = result,
};
return new ApiResponse(ResponseType.OK, obj);
......@@ -423,13 +423,19 @@ public ApiResponse OtherSave([FromBody] AgOtherRequest request)
return new ApiResponse(ResponseType.OK, result);
}
//[Route("api/second/other/save/{secondId}")]
//[HttpPost]
//public ApiResponse OtherSave(int secondId, [FromBody] SaveCollectData request)
//{
// secondAllotService.OtherSave(secondId, request);
// return new ApiResponse(ResponseType.OK);
//}
/// <summary>
/// 二次绩效其他绩效保存(new)
/// </summary>
/// <param name="secondId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("api/second/other/save/{secondId}")]
[HttpPost]
public ApiResponse OtherSave(int secondId, [FromBody] SaveCollectData request)
{
secondAllotService.OtherSave(secondId, request);
return new ApiResponse(ResponseType.OK);
}
#endregion 二次绩效其他绩效
......
......@@ -214,18 +214,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
else
{
var http = new RestSharpHelper();
string endpoint = "extract/extract";
var extractUrl = http.SetUrl(url.HttpPost, endpoint);
var extractUrl = http.SetUrl(url.HttpPost, "extract/extract");
var obj = new
var obj = new ExtractRequest
{
allotId = request.AllotId,
hospitalId = request.HospitalId,
email = email,
userId = claim.GetUserId()
AllotId = request.AllotId,
HospitalId = request.HospitalId,
Email = email,
UserId = claim.GetUserId()
};
string json = JsonHelper.Serialize(obj);
logger.LogInformation("提取绩效数据参数:" + json);
var parameter = JsonHelper.Deserialize<Dictionary<string, object>>(json);
var restRequest = string.IsNullOrEmpty(filePath) ? http.CreatePostRequest(json) : http.CreateFileRequest(new string[] { filePath }, parameter);
Task.Run(() => http.GetResponse(extractUrl, restRequest));
......@@ -290,12 +290,7 @@ public IActionResult DownFile([FromQuery] AllotRequest request)
[AllowAnonymous]
public ApiResponse SaveFile()
{
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (var key in Request.Form.Keys)
{
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
string json = JsonHelper.Serialize(Request.Form.ToDictionary());
var request = JsonHelper.Deserialize<ExtractRequest>(json);
if (Request.Form.Files == null || !Request.Form.Files.Any())
......
......@@ -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>
上传人员绩效文件
......@@ -1252,6 +1280,14 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherSave(System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
二次绩效其他绩效保存(new)
</summary>
<param name="secondId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.SecondPrint(System.Int32)">
<summary>
二次绩效结果打印
......
......@@ -14,8 +14,8 @@ public class SecondEmpRequest
public string EmployeeName { get; set; }
public string JobNumber { get; set; }
}
public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
{
public SecondEmpRequestValidator()
......
//-----------------------------------------------------------------------
// <copyright file=" report_global.cs">
// * FileName: .cs
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
///
///
/// </summary>
[Table("report_global")]
public class report_global
public class report_global
{
/// <summary>
///
///
/// </summary>
[Key]
public int Id { get; set; }
public int Id { get; set; }
/// <summary>
/// 医院ID
/// </summary>
public int HospitalID { get; set; }
/// <summary>
/// 类别
/// </summary>
public string Category { get; set; }
/// <summary>
/// 年份
/// </summary>
public Nullable<int> Year { get; set; }
/// <summary>
/// 月份
/// </summary>
public Nullable<int> Month { get; set; }
/// <summary>
/// 值
/// </summary>
......
......@@ -44,16 +44,11 @@ public class ExtractController : Controller
[HttpPost]
public void ExtractData()
{
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (var key in Request.Form.Keys)
{
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
string json = JsonHelper.Serialize(Request.Form.ToDictionary());
logger.LogInformation("提取绩效数据请求参数:" + json);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
if (request == null || request.AllotId == 0 || request.HospitalId == 0)
return;
......@@ -109,8 +104,7 @@ private string SaveFileAsTemplate(IFormFile file, int hospitalId)
private void ImportFileAsAllotExtractFile(int allotId, int hospitalId, string filePath)
{
var http = new RestSharpHelper();
string endpoint = "template/savefile";
var importUrl = http.SetUrl(options.ImportFile, endpoint);
var importUrl = http.SetUrl(options.ImportFile, "template/savefile");
var obj = new { allotId, hospitalId };
......
......@@ -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)
......
......@@ -1700,14 +1700,20 @@ public void OtherSave(int secondId, SaveCollectData collectData)
}
if (parameters == null || !parameters.Any()) return;
List<string> josn = new List<string>();
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
foreach (var item in collectData.Data)
{
var list = item.ToList();
var itemList = list.Select(t => $"\"{parameters[list.IndexOf(t)]}\":\"{t}\"");
josn.Add($"{{{string.Join(",", itemList)}}}");
Dictionary<string, object> dict = new Dictionary<string, object>();
parameters.ForEach(t =>
{
dict.Add(t, list[parameters.IndexOf(t)]);
});
result.Add(dict);
}
var data = JsonHelper.Deserialize<List<ag_othersource>>($"[{string.Join(",", josn)}]");
var json = JsonHelper.Serialize(result);
var data = JsonHelper.Deserialize<List<ag_othersource>>(json);
data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList();
if (data == null || !data.Any()) return;
......
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