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 @@ ...@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System; using System;
...@@ -33,6 +34,62 @@ ReportGlobalService reportGlobalService ...@@ -33,6 +34,62 @@ ReportGlobalService reportGlobalService
} }
/// <summary> /// <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> /// </summary>
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
......
...@@ -401,11 +401,11 @@ public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request) ...@@ -401,11 +401,11 @@ public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
[HttpPost] [HttpPost]
public ApiResponse OtherList([FromBody] AgOtherRequest request) public ApiResponse OtherList([FromBody] AgOtherRequest request)
{ {
var result = secondAllotService.OtherList(request.SecondId, claimService.GetUserId()); //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 = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
var obj = new var obj = new
{ {
header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(s => s.RealAmount) ?? 0), header = secondAllotService.OtherListHeader(request.SecondId, realAmount),
body = result, body = result,
}; };
return new ApiResponse(ResponseType.OK, obj); return new ApiResponse(ResponseType.OK, obj);
...@@ -423,13 +423,19 @@ public ApiResponse OtherSave([FromBody] AgOtherRequest request) ...@@ -423,13 +423,19 @@ public ApiResponse OtherSave([FromBody] AgOtherRequest request)
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
//[Route("api/second/other/save/{secondId}")] /// <summary>
//[HttpPost] /// 二次绩效其他绩效保存(new)
//public ApiResponse OtherSave(int secondId, [FromBody] SaveCollectData request) /// </summary>
//{ /// <param name="secondId"></param>
// secondAllotService.OtherSave(secondId, request); /// <param name="request"></param>
// return new ApiResponse(ResponseType.OK); /// <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 二次绩效其他绩效 #endregion 二次绩效其他绩效
......
...@@ -214,18 +214,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest ...@@ -214,18 +214,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
else else
{ {
var http = new RestSharpHelper(); var http = new RestSharpHelper();
string endpoint = "extract/extract"; var extractUrl = http.SetUrl(url.HttpPost, "extract/extract");
var extractUrl = http.SetUrl(url.HttpPost, endpoint);
var obj = new var obj = new ExtractRequest
{ {
allotId = request.AllotId, AllotId = request.AllotId,
hospitalId = request.HospitalId, HospitalId = request.HospitalId,
email = email, Email = email,
userId = claim.GetUserId() UserId = claim.GetUserId()
}; };
string json = JsonHelper.Serialize(obj); string json = JsonHelper.Serialize(obj);
logger.LogInformation("提取绩效数据参数:" + json);
var parameter = JsonHelper.Deserialize<Dictionary<string, object>>(json); var parameter = JsonHelper.Deserialize<Dictionary<string, object>>(json);
var restRequest = string.IsNullOrEmpty(filePath) ? http.CreatePostRequest(json) : http.CreateFileRequest(new string[] { filePath }, parameter); var restRequest = string.IsNullOrEmpty(filePath) ? http.CreatePostRequest(json) : http.CreateFileRequest(new string[] { filePath }, parameter);
Task.Run(() => http.GetResponse(extractUrl, restRequest)); Task.Run(() => http.GetResponse(extractUrl, restRequest));
...@@ -290,12 +290,7 @@ public IActionResult DownFile([FromQuery] AllotRequest request) ...@@ -290,12 +290,7 @@ public IActionResult DownFile([FromQuery] AllotRequest request)
[AllowAnonymous] [AllowAnonymous]
public ApiResponse SaveFile() public ApiResponse SaveFile()
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); string json = JsonHelper.Serialize(Request.Form.ToDictionary());
foreach (var key in Request.Form.Keys)
{
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
var request = JsonHelper.Deserialize<ExtractRequest>(json); var request = JsonHelper.Deserialize<ExtractRequest>(json);
if (Request.Form.Files == null || !Request.Form.Files.Any()) if (Request.Form.Files == null || !Request.Form.Files.Any())
......
...@@ -1094,6 +1094,34 @@ ...@@ -1094,6 +1094,34 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </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)"> <member name="M:Performance.Api.Controllers.ReportGlobalController.Import(System.Int32,Microsoft.AspNetCore.Http.IFormCollection)">
<summary> <summary>
上传人员绩效文件 上传人员绩效文件
...@@ -1252,6 +1280,14 @@ ...@@ -1252,6 +1280,14 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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)"> <member name="M:Performance.Api.Controllers.SecondAllotController.SecondPrint(System.Int32)">
<summary> <summary>
二次绩效结果打印 二次绩效结果打印
......
...@@ -14,8 +14,8 @@ public class SecondEmpRequest ...@@ -14,8 +14,8 @@ public class SecondEmpRequest
public string EmployeeName { get; set; } public string EmployeeName { get; set; }
public string JobNumber { get; set; } public string JobNumber { get; set; }
} }
public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest> public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
{ {
public SecondEmpRequestValidator() public SecondEmpRequestValidator()
......
...@@ -44,16 +44,11 @@ public class ExtractController : Controller ...@@ -44,16 +44,11 @@ public class ExtractController : Controller
[HttpPost] [HttpPost]
public void ExtractData() public void ExtractData()
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); string json = JsonHelper.Serialize(Request.Form.ToDictionary());
foreach (var key in Request.Form.Keys)
{
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
logger.LogInformation("提取绩效数据请求参数:" + json); logger.LogInformation("提取绩效数据请求参数:" + json);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
if (request == null || request.AllotId == 0 || request.HospitalId == 0) if (request == null || request.AllotId == 0 || request.HospitalId == 0)
return; return;
...@@ -109,8 +104,7 @@ private string SaveFileAsTemplate(IFormFile file, int hospitalId) ...@@ -109,8 +104,7 @@ private string SaveFileAsTemplate(IFormFile file, int hospitalId)
private void ImportFileAsAllotExtractFile(int allotId, int hospitalId, string filePath) private void ImportFileAsAllotExtractFile(int allotId, int hospitalId, string filePath)
{ {
var http = new RestSharpHelper(); var http = new RestSharpHelper();
string endpoint = "template/savefile"; var importUrl = http.SetUrl(options.ImportFile, "template/savefile");
var importUrl = http.SetUrl(options.ImportFile, endpoint);
var obj = new { allotId, hospitalId }; var obj = new { allotId, hospitalId };
......
...@@ -32,12 +32,124 @@ PerforHisimportdataRepository hisimportdataRepository ...@@ -32,12 +32,124 @@ PerforHisimportdataRepository hisimportdataRepository
this.hisimportdataRepository = hisimportdataRepository; this.hisimportdataRepository = hisimportdataRepository;
} }
#region Report_Global
public List<report_global> GetReportGlobals(int hospitalId) 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; 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 #region ImportFile && SaveData
public void ImportAllotData(int hospitalId, string filePath) public void ImportAllotData(int hospitalId, string filePath)
......
...@@ -1700,14 +1700,20 @@ public void OtherSave(int secondId, SaveCollectData collectData) ...@@ -1700,14 +1700,20 @@ public void OtherSave(int secondId, SaveCollectData collectData)
} }
if (parameters == null || !parameters.Any()) return; 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) foreach (var item in collectData.Data)
{ {
var list = item.ToList(); var list = item.ToList();
var itemList = list.Select(t => $"\"{parameters[list.IndexOf(t)]}\":\"{t}\""); Dictionary<string, object> dict = new Dictionary<string, object>();
josn.Add($"{{{string.Join(",", itemList)}}}"); 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(); data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList();
if (data == null || !data.Any()) return; 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