二次分配自动补全

parent c447d46c
...@@ -148,6 +148,18 @@ public ApiResponse AutoComplete([FromBody] SecondEmpRequest request) ...@@ -148,6 +148,18 @@ public ApiResponse AutoComplete([FromBody] SecondEmpRequest request)
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
/// <summary>
/// 二次绩效录入页面其他模板自动补全
/// </summary>
/// <returns></returns>
[Route("api/second/other/autocomplete")]
[HttpPost]
public ApiResponse OtherAutoComplete([FromBody] SecondEmpRequest request)
{
var result = secondAllotService.OtherAutoComplete(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, result);
}
#region 模板使用 #region 模板使用
/// <summary> /// <summary>
/// 选择二次绩效模板 /// 选择二次绩效模板
......
...@@ -1051,6 +1051,12 @@ ...@@ -1051,6 +1051,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherAutoComplete(Performance.DtoModels.SecondEmpRequest)">
<summary>
二次绩效录入页面其他模板自动补全
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.Temp(Performance.DtoModels.AllotDeptRequest)"> <member name="M:Performance.Api.Controllers.SecondAllotController.Temp(Performance.DtoModels.AllotDeptRequest)">
<summary> <summary>
选择二次绩效模板 选择二次绩效模板
......
...@@ -9,12 +9,6 @@ public class SecondEmpRequest ...@@ -9,12 +9,6 @@ public class SecondEmpRequest
{ {
public int TempId { get; set; } public int TempId { get; set; }
public int HospitalId { get; set; }
public string Department { get; set; }
public string UnitType { get; set; }
public int SecondId { get; set; } public int SecondId { get; set; }
public string EmployeeName { get; set; } public string EmployeeName { get; set; }
...@@ -27,9 +21,6 @@ public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest> ...@@ -27,9 +21,6 @@ public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
public SecondEmpRequestValidator() public SecondEmpRequestValidator()
{ {
RuleFor(x => x.TempId).NotNull().GreaterThan(0); RuleFor(x => x.TempId).NotNull().GreaterThan(0);
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
RuleFor(x => x.Department).NotNull().NotEmpty();
RuleFor(x => x.UnitType).NotNull().NotEmpty();
RuleFor(x => x.SecondId).NotNull().GreaterThan(0); RuleFor(x => x.SecondId).NotNull().GreaterThan(0);
} }
} }
......
...@@ -136,6 +136,16 @@ private void SaveAllotPersons(List<per_employee> employees) ...@@ -136,6 +136,16 @@ private void SaveAllotPersons(List<per_employee> employees)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
public List<per_employee> GetPerEmployee(int allotId)
{
return peremployeeRepository.GetEntities(t => t.AllotId == allotId)?.OrderBy(t => t.Id).ToList();
}
/// <summary>
/// 获取所有员工记录
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public List<per_employee> GetPersons(int allotId, int userId) public List<per_employee> GetPersons(int allotId, int userId)
{ {
var (dept, unittype) = GetDeptByUser(userId); var (dept, unittype) = GetDeptByUser(userId);
......
...@@ -286,19 +286,24 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -286,19 +286,24 @@ public List<SecondListResponse> GetSecondList(int userId)
/// <returns></returns> /// <returns></returns>
public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId) public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity( var usetemp = perforAgusetempRepository.GetEntity(
t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType); var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var employees = personService.GetPerEmployee(second.AllotId.Value);
if (second == null) var bodyItems = GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType, request.EmployeeName, request.JobNumber);
throw new PerformanceException("当前科室二次分配绩效信息无效");
var bodyItems = GetEmployees(second.AllotId.Value, userId, headItems, second.UnitType, request.EmployeeName, request.JobNumber);
return bodyItems; return bodyItems;
} }
...@@ -351,14 +356,16 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId) ...@@ -351,14 +356,16 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
if (fixatList.Where(t => t.RowNumber != -1) == null || !fixatList.Where(t => t.RowNumber != -1).Any()) if (fixatList.Where(t => t.RowNumber != -1) == null || !fixatList.Where(t => t.RowNumber != -1).Any())
{ {
//更换模板时,会自动保存顶部数据 //更换模板时,会自动保存顶部数据
result.BodyItems.AddRange(GetEmployees(second.AllotId.Value, userId, headItems, second.UnitType)); var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems.AddRange(GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType));
} }
} }
else else
{ {
//无数据 根据IsBring带出历史二次绩效中需要带出的数据 //无数据 根据IsBring带出历史二次绩效中需要带出的数据
//result.BodyItems = GetBringItems(request, headItems); //result.BodyItems = GetBringItems(request, headItems);
result.BodyItems = GetEmployees(second.AllotId.Value, userId, headItems, second.UnitType); var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems = GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType);
var bodys = Mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1)); var bodys = Mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1));
if (bodys != null && bodys.Any()) if (bodys != null && bodys.Any())
...@@ -404,19 +411,20 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId) ...@@ -404,19 +411,20 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId)
} }
} }
private List<BodyItem> GetEmployees(int allotId, int userId, List<HeadItem> heads, string unittype, string empName = "", string jobNumber = "") private List<BodyItem> GetEmployees(List<per_employee> employees, int allotId, int userId, List<HeadItem> heads, string unittype, string empName = "", string jobNumber = "")
{ {
var list = new List<BodyItem>(); var list = new List<BodyItem>();
var employees = personService.GetPersons(allotId, userId); //var employees = personService.GetPersons(allotId, userId);
if (employees == null || !employees.Any(t => t.UnitType == unittype)) return list; if (employees == null || !employees.Any(t => t.UnitType == unittype)) return list;
if (string.IsNullOrEmpty(empName) && string.IsNullOrEmpty(jobNumber))
employees = employees.Where(t => t.UnitType == unittype).ToList(); employees = employees.Where(t => t.UnitType == unittype).ToList();
if (!string.IsNullOrEmpty(empName)) if (!string.IsNullOrEmpty(empName))
employees = employees?.Where(w => w.DoctorName?.Trim() == empName?.Trim()).ToList(); employees = employees?.Where(w => w.DoctorName?.Trim() == empName?.Trim()).ToList();
if (!string.IsNullOrEmpty(jobNumber)) if (!string.IsNullOrEmpty(jobNumber))
employees = employees?.Where(w => w.PersonnelNumber?.Trim() == jobNumber?.Trim()).ToList(); employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Contains(jobNumber.Trim())).ToList();
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
Func<per_employee, decimal?> getAprAmount = (t) => perapramounts Func<per_employee, decimal?> getAprAmount = (t) => perapramounts
...@@ -1432,6 +1440,67 @@ public List<ag_othersource> OtherList(int secondId, int userId) ...@@ -1432,6 +1440,67 @@ public List<ag_othersource> OtherList(int secondId, int userId)
WorkPost = t.JobTitle, WorkPost = t.JobTitle,
}).ToList(); }).ToList();
} }
SupplementSecondDetail(second, employees, result);
return result;
}
/// <summary>
/// 二次绩效录入页面其他模板自动补全
/// </summary>
/// <param name="secondId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板");
//获取固定模板列 + 工作量列
var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var employees = personService.GetPerEmployee(second.AllotId.Value);
if (employees == null) return new List<ag_othersource>();
if (!string.IsNullOrEmpty(request.EmployeeName))
employees = employees?.Where(w => w.DoctorName?.Trim() == request.EmployeeName?.Trim()).ToList();
if (!string.IsNullOrEmpty(request.JobNumber))
employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Contains(request.JobNumber.Trim())).ToList();
List<ag_othersource> result = employees
.Select(t => new ag_othersource
{
SecondId = request.SecondId,
WorkNumber = t.PersonnelNumber,
Name = t.DoctorName,
Department = t.Department,
WorkPost = t.JobTitle,
}).ToList();
SupplementSecondDetail(second, employees, result);
return result;
}
/// <summary>
/// 补充二次分配 人员明细
/// </summary>
/// <param name="second"></param>
/// <param name="employees"></param>
/// <param name="result"></param>
private void SupplementSecondDetail(ag_secondallot second, List<per_employee> employees, List<ag_othersource> result)
{
// 补充医院其他绩效 及 预留比例 // 补充医院其他绩效 及 预留比例
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId);
Func<per_employee, decimal?> getAprAmount = (t) => perapramounts Func<per_employee, decimal?> getAprAmount = (t) => perapramounts
...@@ -1455,8 +1524,6 @@ public List<ag_othersource> OtherList(int secondId, int userId) ...@@ -1455,8 +1524,6 @@ public List<ag_othersource> OtherList(int secondId, int userId)
item.TitlePerformance = getDistPerformance(empl); item.TitlePerformance = getDistPerformance(empl);
} }
} }
return result;
} }
public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount) public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount)
......
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