接口完善

parent 775708eb
...@@ -45,13 +45,25 @@ public ApiResponse List() ...@@ -45,13 +45,25 @@ public ApiResponse List()
[HttpPost] [HttpPost]
public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request) public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request)
{ {
var count = request.Where(t => t.SecondId > 0).Select(t => t.SecondId).Distinct().Count(); var allotCount = request.Where(t => t.AllotId > 0).Select(t => t.AllotId).Distinct().Count();
if (count == 0 || request.Any(t => t.SecondId == 0)) 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错误"); 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); var repetition = request.GroupBy(t => new { t.RowNumber, t.ItemName }).Where(t => t.Count() > 1);
if (repetition.Any()) 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); var result = secondAllotService.SaveValue(request);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
...@@ -63,8 +75,25 @@ public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request) ...@@ -63,8 +75,25 @@ public ApiResponse SaveValue([FromBody]List<ag_fixatitem> request)
/// <returns></returns> /// <returns></returns>
[Route("api/second/savecompute")] [Route("api/second/savecompute")]
[HttpPost] [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); return new ApiResponse(ResponseType.OK);
} }
......
...@@ -727,7 +727,7 @@ ...@@ -727,7 +727,7 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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>
二次绩效分配结果保存 二次绩效分配结果保存
</summary> </summary>
......
...@@ -274,6 +274,11 @@ ...@@ -274,6 +274,11 @@
绩效ID 绩效ID
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_compute.SecondId">
<summary>
二次绩效ID
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.Department"> <member name="P:Performance.EntityModels.ag_compute.Department">
<summary> <summary>
科室 科室
...@@ -644,6 +649,11 @@ ...@@ -644,6 +649,11 @@
科室实发金额 科室实发金额
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.Status">
<summary>
状态 1 未提交 2 提交
</summary>
</member>
<member name="T:Performance.EntityModels.ag_temp"> <member name="T:Performance.EntityModels.ag_temp">
<summary> <summary>
二次绩效模板 二次绩效模板
......
...@@ -7,35 +7,40 @@ ...@@ -7,35 +7,40 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels namespace Performance.EntityModels
{ {
/// <summary> /// <summary>
/// 二次绩效结果表 /// 二次绩效结果表
/// </summary> /// </summary>
[Table("ag_compute")] [Table("ag_compute")]
public class ag_compute public class ag_compute
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Key] [Key]
public int Id { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 绩效ID /// 绩效ID
/// </summary> /// </summary>
public Nullable<int> AllotId { get; set; } public Nullable<int> AllotId { get; set; }
/// <summary>
/// 二次绩效ID
/// </summary>
public Nullable<int> SecondId { get; set; }
/// <summary> /// <summary>
/// 科室 /// 科室
/// </summary> /// </summary>
public string Department { get; set; } public string Department { get; set; }
/// <summary> /// <summary>
/// 人员名称 /// 人员名称
/// </summary> /// </summary>
public string PersonName { get; set; } public string PersonName { get; set; }
/// <summary> /// <summary>
/// 实发金额 /// 实发金额
/// </summary> /// </summary>
......
...@@ -50,5 +50,10 @@ public class ag_secondallot ...@@ -50,5 +50,10 @@ public class ag_secondallot
/// 科室实发金额 /// 科室实发金额
/// </summary> /// </summary>
public Nullable<decimal> RealGiveFee { get; set; } public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 状态 1 未提交 2 提交
/// </summary>
public Nullable<int> Status { get; set; }
} }
} }
...@@ -25,6 +25,7 @@ public class SecondAllotService : IAutoInjection ...@@ -25,6 +25,7 @@ public class SecondAllotService : IAutoInjection
private readonly PerforAgtempitemRepository perforAgtempitemRepository; private readonly PerforAgtempitemRepository perforAgtempitemRepository;
private readonly PerforAgfixatitemRepository perforAgfixatitemRepository; private readonly PerforAgfixatitemRepository perforAgfixatitemRepository;
private readonly PerforAgusetempRepository perforAgusetempRepository; private readonly PerforAgusetempRepository perforAgusetempRepository;
private readonly PerforAgcomputeRepository perforAgcomputeRepository;
public SecondAllotService(IOptions<Application> application, public SecondAllotService(IOptions<Application> application,
PerforUserRepository perforUserRepository, PerforUserRepository perforUserRepository,
...@@ -35,9 +36,10 @@ public class SecondAllotService : IAutoInjection ...@@ -35,9 +36,10 @@ public class SecondAllotService : IAutoInjection
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforAgworkloadRepository perforAgworkloadRepository, PerforAgworkloadRepository perforAgworkloadRepository,
PerforAgtempRepository perforAgtempRepository, PerforAgtempRepository perforAgtempRepository,
PerforAgtempitemRepository perforAgtempitemRepository, PerforAgtempitemRepository perforAgtempitemRepository,
PerforAgfixatitemRepository perforAgfixatitemRepository, PerforAgfixatitemRepository perforAgfixatitemRepository,
PerforAgusetempRepository perforAgusetempRepository) PerforAgusetempRepository perforAgusetempRepository,
PerforAgcomputeRepository perforAgcomputeRepository)
{ {
this.application = application.Value; this.application = application.Value;
this.perforUserRepository = perforUserRepository; this.perforUserRepository = perforUserRepository;
...@@ -51,6 +53,7 @@ public class SecondAllotService : IAutoInjection ...@@ -51,6 +53,7 @@ public class SecondAllotService : IAutoInjection
this.perforAgtempitemRepository = perforAgtempitemRepository; this.perforAgtempitemRepository = perforAgtempitemRepository;
this.perforAgfixatitemRepository = perforAgfixatitemRepository; this.perforAgfixatitemRepository = perforAgfixatitemRepository;
this.perforAgusetempRepository = perforAgusetempRepository; this.perforAgusetempRepository = perforAgusetempRepository;
this.perforAgcomputeRepository = perforAgcomputeRepository;
} }
/// <summary> /// <summary>
...@@ -166,9 +169,17 @@ public List<ag_workload> GetWorkloadList(WorkloadRequest request) ...@@ -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); 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) public bool SaveValue(List<ag_fixatitem> request)
{ {
var secondId = request.First().SecondId; 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); var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request) foreach (var item in request)
{ {
...@@ -191,6 +202,37 @@ public bool SaveValue(List<ag_fixatitem> request) ...@@ -191,6 +202,37 @@ public bool SaveValue(List<ag_fixatitem> request)
} }
/// <summary> /// <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> /// </summary>
/// <param name="request"></param> /// <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