接口完善

parent 775708eb
......@@ -45,13 +45,25 @@ public ApiResponse List()
[HttpPost]
public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request)
{
var count = request.Where(t => t.SecondId > 0).Select(t => t.SecondId).Distinct().Count();
if (count == 0 || request.Any(t => t.SecondId == 0))
var allotCount = request.Where(t => t.AllotId > 0).Select(t => t.AllotId).Distinct().Count();
if (allotCount != 1 || request.Any(t => t.AllotId == 0))
throw new PerformanceException("一次绩效ID错误");
var secondCount = request.Where(t => t.SecondId > 0).Select(t => t.SecondId).Distinct().Count();
if (secondCount != 1 || request.Any(t => t.SecondId == 0))
throw new PerformanceException("二次绩效ID错误");
var typeCount = request.Where(t => t.Type > 0).Select(t => t.Type).Distinct().Count();
if (typeCount != 1 || request.Any(t => t.Type == 0))
throw new PerformanceException("二次绩效项位置错误");
var unitTypeCount = request.Where(t => !string.IsNullOrEmpty(t.UnitType)).Select(t => t.UnitType).Distinct().Count();
if (unitTypeCount != 1 || request.Any(t => string.IsNullOrEmpty(t.UnitType)))
throw new PerformanceException("科室类型错误");
var repetition = request.GroupBy(t => new { t.RowNumber, t.ItemName }).Where(t => t.Count() > 1);
if (repetition.Any())
throw new PerformanceException(string.Join(";", repetition.Select(t => $"行{t.Key.RowNumber}{t.Key.ItemName}重复录入")));
throw new PerformanceException(string.Join(";", repetition.Select(t => $"行{t.Key.RowNumber}{t.Key.ItemName}重复录入")));
var result = secondAllotService.SaveValue(request);
return new ApiResponse(ResponseType.OK);
......@@ -63,8 +75,25 @@ public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request)
/// <returns></returns>
[Route("api/second/savecompute")]
[HttpPost]
public ApiResponse SaveCompute()
public ApiResponse SaveCompute([FromBody]List<ag_compute> request)
{
var allotCount = request.Where(t => t.AllotId > 0).Select(t => t.AllotId).Distinct().Count();
if (allotCount != 1 || request.Any(t => t.AllotId == 0))
throw new PerformanceException("一次绩效ID错误");
var secondCount = request.Where(t => t.SecondId > 0).Select(t => t.SecondId).Distinct().Count();
if (secondCount != 1 || request.Any(t => t.SecondId == 0))
throw new PerformanceException("二次绩效ID错误");
var departmentCount = request.Where(t => !string.IsNullOrEmpty(t.Department)).Select(t => t.Department).Distinct().Count();
if (departmentCount != 1 || request.Any(t => string.IsNullOrEmpty(t.Department)))
throw new PerformanceException("科室名称错误");
var personNameCount = request.Where(t => !string.IsNullOrEmpty(t.PersonName)).Select(t => t.PersonName).Distinct().Count();
if (personNameCount != 1 || request.Any(t => string.IsNullOrEmpty(t.PersonName)))
throw new PerformanceException("人员名称错误");
var result = secondAllotService.SaveCompute(request);
return new ApiResponse(ResponseType.OK);
}
......
......@@ -727,7 +727,7 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.SaveCompute">
<member name="M:Performance.Api.Controllers.SecondAllotController.SaveCompute(System.Collections.Generic.List{Performance.EntityModels.ag_compute})">
<summary>
二次绩效分配结果保存
</summary>
......
......@@ -274,6 +274,11 @@
绩效ID
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.SecondId">
<summary>
二次绩效ID
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.Department">
<summary>
科室
......@@ -644,6 +649,11 @@
科室实发金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Status">
<summary>
状态 1 未提交 2 提交
</summary>
</member>
<member name="T:Performance.EntityModels.ag_temp">
<summary>
二次绩效模板
......
......@@ -7,35 +7,40 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
/// 二次绩效结果表
/// </summary>
[Table("ag_compute")]
public class ag_compute
public class ag_compute
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
public int Id { get; set; }
/// <summary>
/// 绩效ID
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 二次绩效ID
/// </summary>
public Nullable<int> SecondId { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 人员名称
/// </summary>
public string PersonName { get; set; }
/// <summary>
/// 实发金额
/// </summary>
......
......@@ -50,5 +50,10 @@ public class ag_secondallot
/// 科室实发金额
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 状态 1 未提交 2 提交
/// </summary>
public Nullable<int> Status { get; set; }
}
}
......@@ -25,6 +25,7 @@ public class SecondAllotService : IAutoInjection
private readonly PerforAgtempitemRepository perforAgtempitemRepository;
private readonly PerforAgfixatitemRepository perforAgfixatitemRepository;
private readonly PerforAgusetempRepository perforAgusetempRepository;
private readonly PerforAgcomputeRepository perforAgcomputeRepository;
public SecondAllotService(IOptions<Application> application,
PerforUserRepository perforUserRepository,
......@@ -35,9 +36,10 @@ public class SecondAllotService : IAutoInjection
PerforUserroleRepository userroleRepository,
PerforAgworkloadRepository perforAgworkloadRepository,
PerforAgtempRepository perforAgtempRepository,
PerforAgtempitemRepository perforAgtempitemRepository,
PerforAgfixatitemRepository perforAgfixatitemRepository,
PerforAgusetempRepository perforAgusetempRepository)
PerforAgtempitemRepository perforAgtempitemRepository,
PerforAgfixatitemRepository perforAgfixatitemRepository,
PerforAgusetempRepository perforAgusetempRepository,
PerforAgcomputeRepository perforAgcomputeRepository)
{
this.application = application.Value;
this.perforUserRepository = perforUserRepository;
......@@ -51,6 +53,7 @@ public class SecondAllotService : IAutoInjection
this.perforAgtempitemRepository = perforAgtempitemRepository;
this.perforAgfixatitemRepository = perforAgfixatitemRepository;
this.perforAgusetempRepository = perforAgusetempRepository;
this.perforAgcomputeRepository = perforAgcomputeRepository;
}
/// <summary>
......@@ -166,9 +169,17 @@ public List<ag_workload> GetWorkloadList(WorkloadRequest request)
return perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.Department);
}
/// <summary>
/// 二次绩效项录入保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool SaveValue(List<ag_fixatitem> request)
{
var secondId = request.First().SecondId;
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null)
throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request)
{
......@@ -191,6 +202,37 @@ public bool SaveValue(List<ag_fixatitem> request)
}
/// <summary>
/// 二次绩效分配结果保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool SaveCompute(List<ag_compute> request)
{
var secondId = request.First().SecondId;
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null)
throw new PerformanceException("二次绩效ID不存在");
if (second.Status == 2)
throw new PerformanceException("二次绩效已提交,无法重复提交");
var compute = perforAgcomputeRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request)
{
if (compute != null && compute.Any(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName))
{
var cellItem = compute.First(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName);
cellItem.RealGiveFee = item.RealGiveFee;
perforAgcomputeRepository.Update(cellItem);
}
else
{
perforAgcomputeRepository.Add(item);
}
}
return true;
}
/// <summary>
/// 新增
/// </summary>
/// <param name="request"></param>
......
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