Commit 24774025 by lcx

重载功能补充,获取、编辑工作量修改

parent 2f7c8184
...@@ -23,21 +23,18 @@ public class SecondAllotController : ControllerBase ...@@ -23,21 +23,18 @@ public class SecondAllotController : ControllerBase
private readonly SecondAllotService secondAllotService; private readonly SecondAllotService secondAllotService;
private readonly ResultComputeService resultComputeService; private readonly ResultComputeService resultComputeService;
private readonly SecondAllotDetails secondAllotDetails; private readonly SecondAllotDetails secondAllotDetails;
private readonly Services.SecondAllot.SecondAllotService secondAllot;
public SecondAllotController( public SecondAllotController(
ClaimService claimService, ClaimService claimService,
SecondAllotService secondAllotService, SecondAllotService secondAllotService,
ResultComputeService resultComputeService, ResultComputeService resultComputeService,
SecondAllotDetails secondAllotDetails, SecondAllotDetails secondAllotDetails
Services.SecondAllot.SecondAllotService secondAllot
) )
{ {
this.claimService = claimService; this.claimService = claimService;
this.secondAllotService = secondAllotService; this.secondAllotService = secondAllotService;
this.resultComputeService = resultComputeService; this.resultComputeService = resultComputeService;
this.secondAllotDetails = secondAllotDetails; this.secondAllotDetails = secondAllotDetails;
this.secondAllot = secondAllot;
} }
#region 二次绩效列表、录入数据展示,保存数据 #region 二次绩效列表、录入数据展示,保存数据
...@@ -155,7 +152,8 @@ public ApiResponse SecondDetail([CustomizeValidator(RuleSet = "Refresh"), FromBo ...@@ -155,7 +152,8 @@ public ApiResponse SecondDetail([CustomizeValidator(RuleSet = "Refresh"), FromBo
[HttpPost] [HttpPost]
public ApiResponse AutoComplete([FromBody] SecondEmpRequest request) public ApiResponse AutoComplete([FromBody] SecondEmpRequest request)
{ {
var result = secondAllotService.AutoComplete(request, claimService.GetUserId()); //var result = secondAllotService.AutoComplete(request, claimService.GetUserId());
var result = secondAllotService.AutoComplete(request.SecondId, request.JobNumber);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -478,7 +476,7 @@ public ApiResponse DeptComputeDetail(int allotId) ...@@ -478,7 +476,7 @@ public ApiResponse DeptComputeDetail(int allotId)
[HttpPost("api/second/detail/{secondId}/{employeeSource}")] [HttpPost("api/second/detail/{secondId}/{employeeSource}")]
public ApiResponse GetSecondAllotDetail([FromRoute] int secondId, int employeeSource) public ApiResponse GetSecondAllotDetail([FromRoute] int secondId, int employeeSource)
{ {
var detail = secondAllot.GetSecondSavedData(claimService.GetUserId(), secondId, employeeSource); var detail = secondAllotService.GetSecondSavedData(claimService.GetUserId(), secondId, employeeSource);
return new ApiResponse(ResponseType.OK, detail); return new ApiResponse(ResponseType.OK, detail);
} }
...@@ -490,7 +488,7 @@ public ApiResponse GetSecondAllotDetail([FromRoute] int secondId, int employeeSo ...@@ -490,7 +488,7 @@ public ApiResponse GetSecondAllotDetail([FromRoute] int secondId, int employeeSo
[HttpPost("api/second/worktype/{secondId}")] [HttpPost("api/second/worktype/{secondId}")]
public ApiResponse GetWorktypeDict([FromRoute] int secondId) public ApiResponse GetWorktypeDict([FromRoute] int secondId)
{ {
var detail = secondAllot.GetWorkTypeDict(secondId); var detail = secondAllotService.GetWorkTypeDict(secondId);
return new ApiResponse(ResponseType.OK, detail); return new ApiResponse(ResponseType.OK, detail);
} }
...@@ -502,7 +500,7 @@ public ApiResponse GetWorktypeDict([FromRoute] int secondId) ...@@ -502,7 +500,7 @@ public ApiResponse GetWorktypeDict([FromRoute] int secondId)
[HttpPost("api/second/workload/{secondId}")] [HttpPost("api/second/workload/{secondId}")]
public ApiResponse GetWorkloadDict([FromRoute] int secondId) public ApiResponse GetWorkloadDict([FromRoute] int secondId)
{ {
var detail = secondAllot.GetWorkloadDict(secondId); var detail = secondAllotService.GetWorkloadDict(secondId);
return new ApiResponse(ResponseType.OK, detail); return new ApiResponse(ResponseType.OK, detail);
} }
...@@ -516,7 +514,7 @@ public ApiResponse GetWorkloadDict([FromRoute] int secondId) ...@@ -516,7 +514,7 @@ public ApiResponse GetWorkloadDict([FromRoute] int secondId)
[AllowAnonymous] [AllowAnonymous]
public ApiResponse SaveValue([FromRoute] int secondId, [FromBody] dynamic request) public ApiResponse SaveValue([FromRoute] int secondId, [FromBody] dynamic request)
{ {
secondAllot.SaveSecondAllotData(secondId, request); secondAllotService.SaveSecondAllotData(secondId, request);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
} }
......
...@@ -2426,7 +2426,12 @@ ...@@ -2426,7 +2426,12 @@
</member> </member>
<member name="P:Performance.DtoModels.WorkloadRequest.WorkTypeId"> <member name="P:Performance.DtoModels.WorkloadRequest.WorkTypeId">
<summary> <summary>
1、工作量 2、其他 自定义工作量类型Id(不包括默认工作量绩效类型、单项奖励)
</summary>
</member>
<member name="P:Performance.DtoModels.WorkloadRequest.IsSingleAwards">
<summary>
是否是单项奖励
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.WorkyearRequest.MaxRange"> <member name="P:Performance.DtoModels.WorkyearRequest.MaxRange">
...@@ -3439,6 +3444,11 @@ ...@@ -3439,6 +3444,11 @@
8 归档 9 等待生成 10 绩效结果解析成功 8 归档 9 等待生成 10 绩效结果解析成功
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.Detail.Status">
<summary>
状态 1 未提交 2 等待审核 3 审核通过 4 驳回
</summary>
</member>
<member name="P:Performance.DtoModels.SecondListResponse.IsArchive"> <member name="P:Performance.DtoModels.SecondListResponse.IsArchive">
<summary> 是否归档 </summary> <summary> 是否归档 </summary>
</member> </member>
......
...@@ -953,12 +953,12 @@ ...@@ -953,12 +953,12 @@
年资职称绩效 年资职称绩效
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_headsource.PerformanceShareTheWorkload"> <member name="P:Performance.EntityModels.ag_headsource.Workload_Ratio_Default">
<summary> <summary>
工作量绩效占比 工作量绩效占比
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_headsource.PerformanceWorkloadDistributionAmount"> <member name="P:Performance.EntityModels.ag_headsource.Workload_Amount_Default">
<summary> <summary>
工作量分配绩效金额 工作量分配绩效金额
</summary> </summary>
......
...@@ -91,7 +91,7 @@ public enum AgWorkloadType ...@@ -91,7 +91,7 @@ public enum AgWorkloadType
/// <summary> /// <summary>
/// 工作量 /// 工作量
/// </summary> /// </summary>
Workload = 2, Workload = 0,
} }
public enum DataFormat public enum DataFormat
{ {
......
...@@ -20,7 +20,7 @@ public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest> ...@@ -20,7 +20,7 @@ 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.SecondId).NotNull().GreaterThan(0); RuleFor(x => x.SecondId).NotNull().GreaterThan(0);
} }
} }
......
...@@ -43,9 +43,14 @@ public class WorkloadRequest ...@@ -43,9 +43,14 @@ public class WorkloadRequest
public Nullable<decimal> Sort { get; set; } public Nullable<decimal> Sort { get; set; }
/// <summary> /// <summary>
/// 1、工作量 2、其他 /// 自定义工作量类型Id(不包括默认工作量绩效类型、单项奖励)
/// </summary> /// </summary>
public int WorkTypeId { get; set; } public int WorkTypeId { get; set; }
/// <summary>
/// 是否是单项奖励
/// </summary>
public bool IsSingleAwards { get; set; }
} }
public class WorkloadRequestValidator : AbstractValidator<WorkloadRequest> public class WorkloadRequestValidator : AbstractValidator<WorkloadRequest>
{ {
......
...@@ -26,6 +26,9 @@ public class Detail ...@@ -26,6 +26,9 @@ public class Detail
/// </summary> /// </summary>
public int States { get; set; } public int States { get; set; }
/// <summary>
/// 状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary>
public int Status { get; set; } public int Status { get; set; }
public string Department { get; set; } public string Department { get; set; }
......
...@@ -74,12 +74,12 @@ public class ag_headsource ...@@ -74,12 +74,12 @@ public class ag_headsource
/// <summary> /// <summary>
/// 工作量绩效占比 /// 工作量绩效占比
/// </summary> /// </summary>
public Nullable<decimal> PerformanceShareTheWorkload { get; set; } public Nullable<decimal> Workload_Ratio_Default { get; set; }
/// <summary> /// <summary>
/// 工作量分配绩效金额 /// 工作量分配绩效金额
/// </summary> /// </summary>
public Nullable<decimal> PerformanceWorkloadDistributionAmount { get; set; } public Nullable<decimal> Workload_Amount_Default { get; set; }
/// <summary> /// <summary>
/// 满勤天数 /// 满勤天数
......
...@@ -9,57 +9,15 @@ ...@@ -9,57 +9,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Performance.Services.SecondAllot namespace Performance.Services
{ {
public class SecondAllotService : IAutoInjection public partial class SecondAllotService : IAutoInjection
{ {
private readonly ILogger logger;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforAgsecondallotRepository secondallotRepository;
private readonly PerforAgusetempRepository usetempRepository;
private readonly PerforAgworkloadtypeRepository workloadtypeRepository;
private readonly PerforAgworkloadRepository workloadRepository;
private readonly PerforAgheadsourceRepository headsourceRepository;
private readonly PerforAgworktypesourceRepository worktypesourceRepository;
private readonly PerforAgbodysourceRepository bodysourceRepository;
private readonly PerforAgworkloadsourceRepository workloadsourceRepository;
private readonly PerforPerapramountRepository perapramountRepository;
private readonly PersonService personService;
public SecondAllotService(
ILogger<SecondAllotService> logger,
PerforPerallotRepository perallotRepository,
PerforAgsecondallotRepository secondallotRepository,
PerforAgusetempRepository usetempRepository,
PerforAgworkloadtypeRepository workloadtypeRepository,
PerforAgworkloadRepository workloadRepository,
PerforAgheadsourceRepository headsourceRepository,
PerforAgworktypesourceRepository worktypesourceRepository,
PerforAgbodysourceRepository bodysourceRepository,
PerforAgworkloadsourceRepository workloadsourceRepository,
PerforPerapramountRepository perapramountRepositor,
PersonService personService
)
{
this.logger = logger;
this.perallotRepository = perallotRepository;
this.secondallotRepository = secondallotRepository;
this.usetempRepository = usetempRepository;
this.workloadtypeRepository = workloadtypeRepository;
this.workloadRepository = workloadRepository;
this.headsourceRepository = headsourceRepository;
this.worktypesourceRepository = worktypesourceRepository;
this.bodysourceRepository = bodysourceRepository;
this.workloadsourceRepository = workloadsourceRepository;
this.perapramountRepository = perapramountRepositor;
this.personService = personService;
}
#region 二次绩效详情 #region 二次绩效详情
public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int employeeSource) public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int employeeSource)
{ {
var second = secondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("参数SecondId无效!"); if (second == null) throw new PerformanceException("参数SecondId无效!");
var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId); var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
...@@ -77,7 +35,7 @@ public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int empl ...@@ -77,7 +35,7 @@ public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int empl
SecondAllotResponse result = new SecondAllotResponse() { Detail = detail }; SecondAllotResponse result = new SecondAllotResponse() { Detail = detail };
var head = headsourceRepository.GetEntity(t => t.SecondId == secondId) var head = agheadsourceRepository.GetEntity(t => t.SecondId == secondId)
?? new ag_headsource ?? new ag_headsource
{ {
SecondId = secondId, SecondId = secondId,
...@@ -85,7 +43,7 @@ public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int empl ...@@ -85,7 +43,7 @@ public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int empl
PaymentOfTheMonth = $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}月" PaymentOfTheMonth = $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}月"
}; };
JObject jObject = JObject.Parse(JsonConvert.SerializeObject(head)); JObject jObject = JObject.Parse(JsonConvert.SerializeObject(head));
var headDynamic = worktypesourceRepository.GetEntities(t => t.SecondId == secondId); var headDynamic = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId);
if (headDynamic != null && headDynamic.Any()) if (headDynamic != null && headDynamic.Any())
{ {
foreach (var item in headDynamic.OrderBy(t => t.Id)) foreach (var item in headDynamic.OrderBy(t => t.Id))
...@@ -124,7 +82,7 @@ private JArray GetBodyItemsByEmployeeSource(int userId, int employeeSource, ag_s ...@@ -124,7 +82,7 @@ private JArray GetBodyItemsByEmployeeSource(int userId, int employeeSource, ag_s
switch (employeeSource) switch (employeeSource)
{ {
case (int)EmployeeSource.Initial: case (int)EmployeeSource.Initial:
bodysources = bodysourceRepository.GetEntities(t => t.SecondId == second.Id); bodysources = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id);
break; break;
case (int)EmployeeSource.EmployeeDict: case (int)EmployeeSource.EmployeeDict:
...@@ -141,27 +99,7 @@ private JArray GetBodyItemsByEmployeeSource(int userId, int employeeSource, ag_s ...@@ -141,27 +99,7 @@ private JArray GetBodyItemsByEmployeeSource(int userId, int employeeSource, ag_s
} }
SupplementOtherPerfor(second, bodysources, employeeList); SupplementOtherPerfor(second, bodysources, employeeList);
return GetBodyResult(allot.HospitalId, second, bodysources);
JArray jArray = new JArray();
if (bodysources == null || !bodysources.Any())
return jArray;
var bodyDynamic = workloadsourceRepository.GetEntities(t => bodysources.Select(w => w.Id).Contains(t.BodyId));
var workloads = workloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (workloads != null && workloads.Any())
{
foreach (var item in bodysources.OrderBy(t => t.RowNumber).ThenBy(t => t.Id))
{
JObject jObj = JObject.Parse(JsonConvert.SerializeObject(item));
foreach (var workitem in workloads.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort))
{
var value = bodyDynamic?.FirstOrDefault(w => w.BodyId == item.Id && w.WorkloadId == workitem.Id)?.Value;
jObj.Add(new JProperty(workitem.ItemId, value));
}
jArray.Add(jObj);
}
}
return jArray;
} }
/// <summary> /// <summary>
...@@ -182,8 +120,9 @@ public List<ag_bodysource> GetEmployeeFromEmployeeDict(List<per_employee> employ ...@@ -182,8 +120,9 @@ public List<ag_bodysource> GetEmployeeFromEmployeeDict(List<per_employee> employ
{ {
RowNumber = rowNumber, RowNumber = rowNumber,
WorkNumber = employee.PersonnelNumber, WorkNumber = employee.PersonnelNumber,
Department = employee.AccountingUnit,
Name = employee.DoctorName, Name = employee.DoctorName,
Post = (employee.Duty?.IndexOf("主任") > -1 || employee.Duty?.IndexOf("护士长") > -1) ? "科主任/护士长" : "其他", Post = getPost.Invoke(employee),
ActualAttendance = employee.AttendanceDay, ActualAttendance = employee.AttendanceDay,
StaffCoefficient = 1, StaffCoefficient = 1,
JobTitle = employee.JobTitle, JobTitle = employee.JobTitle,
...@@ -203,7 +142,7 @@ public List<ag_bodysource> GetEmployeeFromEmployeeDict(List<per_employee> employ ...@@ -203,7 +142,7 @@ public List<ag_bodysource> GetEmployeeFromEmployeeDict(List<per_employee> employ
/// <returns></returns> /// <returns></returns>
public List<ag_bodysource> GetEmployeeFromPrevData(ag_secondallot prevSecond, List<per_employee> employeeList) public List<ag_bodysource> GetEmployeeFromPrevData(ag_secondallot prevSecond, List<per_employee> employeeList)
{ {
var body = bodysourceRepository.GetEntities(t => t.SecondId == prevSecond.Id); var body = agbodysourceRepository.GetEntities(t => t.SecondId == prevSecond.Id);
if (body == null || !body.Any()) return new List<ag_bodysource>(); if (body == null || !body.Any()) return new List<ag_bodysource>();
foreach (var item in body.Select(t => new ag_bodysource foreach (var item in body.Select(t => new ag_bodysource
...@@ -223,10 +162,13 @@ public List<ag_bodysource> GetEmployeeFromPrevData(ag_secondallot prevSecond, Li ...@@ -223,10 +162,13 @@ public List<ag_bodysource> GetEmployeeFromPrevData(ag_secondallot prevSecond, Li
} }
/// <summary> /// <summary>
/// 补充 医院其他绩效 /// 补充医院其他绩效
/// </summary> /// </summary>
/// <param name="result"></param> /// <param name="secondAllot"></param>
private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysource> bodyItems, List<per_employee> employeeList) /// <param name="bodyItems"></param>
/// <param name="employeeList"></param>
/// <param name="isSupplyOtherEmployees">是否补充字典中该科室不存在,但有其它绩效的人员信息</param>
private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysource> bodyItems, List<per_employee> employeeList, bool isSupplyOtherEmployees = true)
{ {
if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return; if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return;
...@@ -247,7 +189,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc ...@@ -247,7 +189,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc
} }
// 补充字典中该科室不存在,但有其它绩效的人员信息 // 补充字典中该科室不存在,但有其它绩效的人员信息
if (perapramounts != null && perapramounts.Any(t => t.AccountingUnit == secondAllot.Department)) if (isSupplyOtherEmployees && perapramounts != null && perapramounts.Any(t => t.AccountingUnit == secondAllot.Department))
{ {
var groupData = perapramounts.Where(t => t.AccountingUnit == secondAllot.Department).GroupBy(t => t.PersonnelNumber) var groupData = perapramounts.Where(t => t.AccountingUnit == secondAllot.Department).GroupBy(t => t.PersonnelNumber)
.Select(t => new .Select(t => new
...@@ -277,7 +219,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc ...@@ -277,7 +219,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc
{ {
WorkNumber = item.PersonnelNumber, WorkNumber = item.PersonnelNumber,
Name = item.DoctorName, Name = item.DoctorName,
Post = (employee.Duty?.IndexOf("主任") > -1 || employee.Duty?.IndexOf("护士长") > -1) ? "科主任/护士长" : "其他", Post = getPost.Invoke(employee),
ActualAttendance = employee.AttendanceDay, ActualAttendance = employee.AttendanceDay,
StaffCoefficient = 1, StaffCoefficient = 1,
JobTitle = employee.JobTitle, JobTitle = employee.JobTitle,
...@@ -290,6 +232,38 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc ...@@ -290,6 +232,38 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc
} }
/// <summary> /// <summary>
/// 获取body的结果集
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
/// <param name="bodysources"></param>
/// <returns></returns>
private JArray GetBodyResult(int hospitalId, ag_secondallot second, List<ag_bodysource> bodysources)
{
JArray jArray = new JArray();
if (bodysources == null || !bodysources.Any())
return jArray;
var bodyDynamic = agworkloadsourceRepository.GetEntities(t => bodysources.Select(w => w.Id).Contains(t.BodyId));
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType)
?.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort).ToList();
if (workloads != null && workloads.Any())
{
foreach (var item in bodysources.OrderBy(t => t.RowNumber).ThenBy(t => t.Id))
{
JObject jObj = JObject.Parse(JsonConvert.SerializeObject(item)); //使用jsonHelper会自动隐藏空值的项
foreach (var workitem in workloads)
{
var value = bodyDynamic?.FirstOrDefault(w => w.BodyId == item.Id && w.WorkloadId == workitem.Id)?.Value;
jObj.Add(new JProperty(workitem.ItemId, value));
}
jArray.Add(jObj);
}
}
return jArray;
}
/// <summary>
/// 获取当前使用的模板 /// 获取当前使用的模板
/// </summary> /// </summary>
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
...@@ -298,7 +272,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc ...@@ -298,7 +272,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc
private int GetUsingTempId(int hospitalId, ag_secondallot second) private int GetUsingTempId(int hospitalId, ag_secondallot second)
{ {
int usingTempId = (int)Temp.other; int usingTempId = (int)Temp.other;
var usedTemp = usetempRepository.GetEntity(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType); var usedTemp = agusetempRepository.GetEntity(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usedTemp == null) return usingTempId; if (usedTemp == null) return usingTempId;
if (new int[] { 2, 3 }.Contains(second.Status ?? 1)) if (new int[] { 2, 3 }.Contains(second.Status ?? 1))
...@@ -325,17 +299,58 @@ private ag_secondallot GetPreviousSecondAllot(int hospitalId, ag_secondallot sec ...@@ -325,17 +299,58 @@ private ag_secondallot GetPreviousSecondAllot(int hospitalId, ag_secondallot sec
if (index == 0) return null; if (index == 0) return null;
var prevAllot = allotList[index - 1]; var prevAllot = allotList[index - 1];
var prevSecondAllot = secondallotRepository.GetEntity(w => w.AllotId == prevAllot.ID && w.UnitType == secondAllot.UnitType && w.Department == secondAllot.Department); var prevSecondAllot = agsecondallotRepository.GetEntity(w => w.AllotId == prevAllot.ID && w.UnitType == secondAllot.UnitType && w.Department == secondAllot.Department);
return prevSecondAllot; return prevSecondAllot;
} }
/// <summary>
/// 获取岗位
/// </summary>
readonly Func<per_employee, string> getPost = (e) => (e.Duty?.IndexOf("主任") > -1 || e.Duty?.IndexOf("护士长") > -1) ? "科主任/护士长" : "其他";
/// <summary>
/// 二次绩效分配录入人员自动补全信息
/// </summary>
/// <param name="secodId"></param>
/// <param name="workNumber">工号</param>
/// <returns></returns>
public JArray AutoComplete(int secodId, string workNumber)
{
var second = agsecondallotRepository.GetEntity(t => t.Id == secodId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板");
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID && !string.IsNullOrEmpty(t.PersonnelNumber) && t.PersonnelNumber.IndexOf(workNumber) > -1)
?.OrderBy(t => t.PersonnelNumber).ThenByDescending(t => t.DoctorName).ToList();
if (employees == null || !employees.Any()) return new JArray();
var bodysources = new List<ag_bodysource>();
if (employees.Any(t => !string.IsNullOrEmpty(t.DoctorName)))
bodysources = GetEmployeeFromEmployeeDict(employees.Where(t => !string.IsNullOrEmpty(t.DoctorName)).ToList());
else
bodysources = GetEmployeeFromEmployeeDict(employees);
SupplementOtherPerfor(second, bodysources, employees, false);
return GetBodyResult(allot.HospitalId, second, bodysources);
}
#endregion #endregion
#region 动态配置字典 #region 动态配置字典
public dynamic GetWorkTypeDict(int secondId) public dynamic GetWorkTypeDict(int secondId)
{ {
var worktypeSources = worktypesourceRepository.GetEntities(t => t.SecondId == secondId) ?? new List<ag_worktype_source>(); var worktypeSources = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId) ?? new List<ag_worktype_source>();
return worktypeSources.OrderBy(t => t.Id).Select(t => new return worktypeSources.OrderBy(t => t.Id).Select(t => new
{ {
Title = t.FieldId, Title = t.FieldId,
...@@ -345,13 +360,13 @@ public dynamic GetWorkTypeDict(int secondId) ...@@ -345,13 +360,13 @@ public dynamic GetWorkTypeDict(int secondId)
public dynamic GetWorkloadDict(int secondId) public dynamic GetWorkloadDict(int secondId)
{ {
var second = secondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("参数SecondId无效!"); if (second == null) throw new PerformanceException("参数SecondId无效!");
var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId); var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) throw new PerformanceException("绩效记录不存在!"); if (allot == null) throw new PerformanceException("绩效记录不存在!");
var workloads = workloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType) ?? new List<ag_workload>(); var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType) ?? new List<ag_workload>();
return workloads.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort).Select(t => new return workloads.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort).Select(t => new
{ {
Title = t.ItemId, Title = t.ItemId,
...@@ -394,11 +409,11 @@ private void SaveSecondAllotHeadData(int secondId, string json) ...@@ -394,11 +409,11 @@ private void SaveSecondAllotHeadData(int secondId, string json)
if (headsource.Id == 0) if (headsource.Id == 0)
{ {
headsource.SecondId = secondId; headsource.SecondId = secondId;
headsourceRepository.Add(headsource); agheadsourceRepository.Add(headsource);
} }
else else
{ {
headsourceRepository.UpdateByState(headsource); agheadsourceRepository.UpdateByState(headsource);
} }
string[] prefix = new string[] { "Workload_Ratio_", "Workload_Amount_" }; string[] prefix = new string[] { "Workload_Ratio_", "Workload_Amount_" };
...@@ -408,7 +423,7 @@ private void SaveSecondAllotHeadData(int secondId, string json) ...@@ -408,7 +423,7 @@ private void SaveSecondAllotHeadData(int secondId, string json)
return; return;
List<ag_worktype_source> insertData = new List<ag_worktype_source>(); List<ag_worktype_source> insertData = new List<ag_worktype_source>();
var worktypeSources = worktypesourceRepository.GetEntities(t => t.SecondId == secondId); var worktypeSources = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId);
if (worktypeSources == null || !worktypeSources.Any()) if (worktypeSources == null || !worktypeSources.Any())
return; return;
...@@ -420,7 +435,7 @@ private void SaveSecondAllotHeadData(int secondId, string json) ...@@ -420,7 +435,7 @@ private void SaveSecondAllotHeadData(int secondId, string json)
update.Value = ConvertHelper.To<decimal>(dict[key]); update.Value = ConvertHelper.To<decimal>(dict[key]);
} }
} }
worktypesourceRepository.UpdateRange(worktypeSources.ToArray()); agworktypesourceRepository.UpdateRange(worktypeSources.ToArray());
} }
/// <summary> /// <summary>
...@@ -431,14 +446,14 @@ private void SaveSecondAllotHeadData(int secondId, string json) ...@@ -431,14 +446,14 @@ private void SaveSecondAllotHeadData(int secondId, string json)
private void SaveSecondAllotBodyData(int secondId, dynamic body) private void SaveSecondAllotBodyData(int secondId, dynamic body)
{ {
// 允许空行数据提交,删除数据库存数数据 // 允许空行数据提交,删除数据库存数数据
var bodyEntities = bodysourceRepository.GetEntities(t => t.SecondId == secondId); var bodyEntities = agbodysourceRepository.GetEntities(t => t.SecondId == secondId);
if (bodyEntities != null && bodyEntities.Any()) if (bodyEntities != null && bodyEntities.Any())
{ {
var workloadEntities = workloadsourceRepository.GetEntities(t => bodyEntities.Select(w => w.Id).Contains(t.BodyId)); var workloadEntities = agworkloadsourceRepository.GetEntities(t => bodyEntities.Select(w => w.Id).Contains(t.BodyId));
if (workloadEntities != null && workloadEntities.Any()) if (workloadEntities != null && workloadEntities.Any())
workloadsourceRepository.RemoveRange(workloadEntities.ToArray()); agworkloadsourceRepository.RemoveRange(workloadEntities.ToArray());
bodysourceRepository.RemoveRange(bodyEntities.ToArray()); agbodysourceRepository.RemoveRange(bodyEntities.ToArray());
} }
if (body == null || !body.Any()) return; if (body == null || !body.Any()) return;
...@@ -448,7 +463,7 @@ private void SaveSecondAllotBodyData(int secondId, dynamic body) ...@@ -448,7 +463,7 @@ private void SaveSecondAllotBodyData(int secondId, dynamic body)
foreach (var rowitem in body) foreach (var rowitem in body)
{ {
ag_bodysource bodySource = JsonHelper.Deserialize<ag_bodysource>(JsonHelper.Serialize(rowitem)); ag_bodysource bodySource = JsonHelper.Deserialize<ag_bodysource>(JsonHelper.Serialize(rowitem));
var result = bodysourceRepository.Add(bodySource); var result = agbodysourceRepository.Add(bodySource);
if (!result) continue; if (!result) continue;
...@@ -471,7 +486,7 @@ private void SaveSecondAllotBodyData(int secondId, dynamic body) ...@@ -471,7 +486,7 @@ private void SaveSecondAllotBodyData(int secondId, dynamic body)
} }
} }
if (workloadSources != null && workloadSources.Any()) if (workloadSources != null && workloadSources.Any())
workloadsourceRepository.AddRange(workloadSources.ToArray()); agworkloadsourceRepository.AddRange(workloadSources.ToArray());
} }
#endregion #endregion
......
...@@ -15,94 +15,105 @@ ...@@ -15,94 +15,105 @@
namespace Performance.Services namespace Performance.Services
{ {
public class SecondAllotService : IAutoInjection public partial class SecondAllotService : IAutoInjection
{ {
private readonly ILogger logger;
private readonly Application application; private readonly Application application;
private readonly ILogger<SecondAllotService> _logger; private readonly PerforAgsecondallotRepository agsecondallotRepository;
private readonly PerforAgtempRepository agtempRepository;
private readonly PerforAgtempitemRepository agtempitemRepository;
private readonly PerforAgusetempRepository agusetempRepository;
private readonly PerforAgworkloadRepository agworkloadRepository;
private readonly PerforAgworkloadtypeRepository agworkloadtypeRepository;
private readonly PerforAgbodysourceRepository agbodysourceRepository;
private readonly PerforAgheadsourceRepository agheadsourceRepository;
private readonly PerforAgworktypesourceRepository agworktypesourceRepository;
private readonly PerforAgworkloadsourceRepository agworkloadsourceRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforUserRepository userRepository;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforUserRepository perforUserRepository; private readonly PerforUserhospitalRepository userhospitalRepository;
private readonly PerforUserhospitalRepository perforUserhospitalRepository;
private readonly PerforPerallotRepository perforPerallotRepository;
private readonly PerforAgsecondallotRepository perforAgsecondallotRepository;
private readonly PerforResaccountRepository perforResaccountRepository;
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforAgworkloadRepository perforAgworkloadRepository;
private readonly PerforAgtempRepository perforAgtempRepository;
private readonly PerforAgtempitemRepository perforAgtempitemRepository;
private readonly PerforAgfixatitemRepository perforAgfixatitemRepository;
private readonly PerforAgusetempRepository perforAgusetempRepository;
private readonly PerforAgcomputeRepository perforAgcomputeRepository;
private readonly PerforCofagainRepository perforCofagainRepository;
private readonly PerforAgothersourceRepository perforAgothersourceRepository;
private readonly PerforAgworkloadtypeRepository perforAgworkloadtypeRepository;
private readonly PerforRoleRepository roleRepository; private readonly PerforRoleRepository roleRepository;
private readonly PerforPerapramountRepository perapramountRepository; private readonly PerforUserroleRepository userroleRepository;
private readonly PerforImemployeeclinicRepository imemployeeclinicRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforResaccountRepository resaccountRepository;
private readonly PerforRescomputeRepository rescomputeRepository;
private readonly PerforResspecialunitRepository resspecialunitRepository; private readonly PerforResspecialunitRepository resspecialunitRepository;
private readonly PersonService personService; private readonly PerforPerapramountRepository perapramountRepository;
private readonly PerforAgfixatitemRepository agfixatitemRepository;
private readonly PerforAgothersourceRepository agothersourceRepository;
private readonly PerforAgcomputeRepository agcomputeRepository;
private readonly PerforCofagainRepository cofagainRepository;
private readonly ComputeService computeService; private readonly ComputeService computeService;
private readonly PerforRescomputeRepository rescomputeRepository; private readonly PersonService personService;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforImemployeeclinicRepository imemployeeclinicRepository;
private readonly PerforAgworktypesourceRepository worktypesourceRepository;
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>(); private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(IOptions<Application> application, public SecondAllotService(
ILogger<SecondAllotService> logger, ILogger<SecondAllotService> logger,
IOptions<Application> application,
PerforAgsecondallotRepository agsecondallotRepository,
PerforAgtempRepository agtempRepository,
PerforAgtempitemRepository agtempitemRepository,
PerforAgusetempRepository agusetempRepository,
PerforAgworkloadRepository agworkloadRepository,
PerforAgworkloadtypeRepository agworkloadtypeRepository,
PerforAgbodysourceRepository agbodysourceRepository,
PerforAgheadsourceRepository agheadsourceRepository,
PerforAgworktypesourceRepository agworktypesourceRepository,
PerforAgworkloadsourceRepository agworkloadsourceRepository,
PerforPerallotRepository perallotRepository,
PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforUserRepository perforUserRepository, PerforUserhospitalRepository userhospitalRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository,
PerforAgsecondallotRepository perforAgsecondallotRepository,
PerforResaccountRepository perforResaccountRepository,
PerforUserroleRepository userroleRepository,
PerforAgworkloadRepository perforAgworkloadRepository,
PerforAgtempRepository perforAgtempRepository,
PerforAgtempitemRepository perforAgtempitemRepository,
PerforAgfixatitemRepository perforAgfixatitemRepository,
PerforAgusetempRepository perforAgusetempRepository,
PerforAgcomputeRepository perforAgcomputeRepository,
PerforCofagainRepository perforCofagainRepository,
PerforAgothersourceRepository perforAgothersourceRepository,
PerforAgworkloadtypeRepository perforAgworkloadtypeRepository,
PerforRoleRepository roleRepository, PerforRoleRepository roleRepository,
PerforPerapramountRepository perapramountRepository, PerforUserroleRepository userroleRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforResaccountRepository resaccountRepository,
PerforRescomputeRepository rescomputeRepository,
PerforResspecialunitRepository resspecialunitRepository, PerforResspecialunitRepository resspecialunitRepository,
PerforPerapramountRepository perapramountRepository,
PerforAgfixatitemRepository agfixatitemRepository,
PerforAgothersourceRepository agothersourceRepository,
PerforAgcomputeRepository agcomputeRepository,
PerforCofagainRepository cofagainRepository,
PersonService personService, PersonService personService,
ComputeService computeService, ComputeService computeService
PerforRescomputeRepository rescomputeRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository,
PerforAgworktypesourceRepository worktypesourceRepository
) )
{ {
this.logger = logger;
this.application = application.Value; this.application = application.Value;
_logger = logger; this.agsecondallotRepository = agsecondallotRepository;
this.agtempRepository = agtempRepository;
this.agtempitemRepository = agtempitemRepository;
this.agusetempRepository = agusetempRepository;
this.agworkloadRepository = agworkloadRepository;
this.agworkloadtypeRepository = agworkloadtypeRepository;
this.agbodysourceRepository = agbodysourceRepository;
this.agheadsourceRepository = agheadsourceRepository;
this.agworktypesourceRepository = agworktypesourceRepository;
this.agworkloadsourceRepository = agworkloadsourceRepository;
this.perallotRepository = perallotRepository;
this.userRepository = userRepository;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.perforUserRepository = perforUserRepository; this.userhospitalRepository = userhospitalRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforAgsecondallotRepository = perforAgsecondallotRepository;
this.perforResaccountRepository = perforResaccountRepository;
this.userroleRepository = userroleRepository;
this.perforAgworkloadRepository = perforAgworkloadRepository;
this.perforAgtempRepository = perforAgtempRepository;
this.perforAgtempitemRepository = perforAgtempitemRepository;
this.perforAgfixatitemRepository = perforAgfixatitemRepository;
this.perforAgusetempRepository = perforAgusetempRepository;
this.perforAgcomputeRepository = perforAgcomputeRepository;
this.perforCofagainRepository = perforCofagainRepository;
this.perforAgothersourceRepository = perforAgothersourceRepository;
this.perforAgworkloadtypeRepository = perforAgworkloadtypeRepository;
this.roleRepository = roleRepository; this.roleRepository = roleRepository;
this.perapramountRepository = perapramountRepository; this.userroleRepository = userroleRepository;
this.imemployeeclinicRepository = imemployeeclinicRepository;
this.peremployeeRepository = peremployeeRepository;
this.resaccountRepository = resaccountRepository;
this.rescomputeRepository = rescomputeRepository;
this.resspecialunitRepository = resspecialunitRepository; this.resspecialunitRepository = resspecialunitRepository;
this.personService = personService; this.perapramountRepository = perapramountRepository;
this.agfixatitemRepository = agfixatitemRepository;
this.agothersourceRepository = agothersourceRepository;
this.agcomputeRepository = agcomputeRepository;
this.cofagainRepository = cofagainRepository;
this.computeService = computeService; this.computeService = computeService;
this.rescomputeRepository = rescomputeRepository; this.personService = personService;
this.peremployeeRepository = peremployeeRepository;
this.imemployeeclinicRepository = imemployeeclinicRepository;
this.tempitems = perforAgtempitemRepository.GetEntities();
this.worktypesourceRepository = worktypesourceRepository;
} }
#region 二次绩效列表与数据保存 #region 二次绩效列表与数据保存
...@@ -114,15 +125,15 @@ PerforAgworktypesourceRepository worktypesourceRepository ...@@ -114,15 +125,15 @@ PerforAgworktypesourceRepository worktypesourceRepository
/// <returns></returns> /// <returns></returns>
public List<SecondListResponse> GetSecondList(int userId) public List<SecondListResponse> GetSecondList(int userId)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
throw new NotImplementedException("人员ID无效"); throw new NotImplementedException("人员ID无效");
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId); var hospital = userhospitalRepository.GetEntity(t => t.UserID == userId);
if (hospital == null) if (hospital == null)
throw new NotImplementedException("人员未选择医院"); throw new NotImplementedException("人员未选择医院");
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States)); var allotList = perallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States));
if (allotList == null || allotList.Count == 0) if (allotList == null || allotList.Count == 0)
return new List<SecondListResponse>(); return new List<SecondListResponse>();
...@@ -137,7 +148,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -137,7 +148,7 @@ public List<SecondListResponse> GetSecondList(int userId)
else if (role.Type == application.OfficeRole) else if (role.Type == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString()); exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = perforAgsecondallotRepository.GetEntities(exp); var secondList = agsecondallotRepository.GetEntities(exp);
var list = Mapper.Map<List<SecondListResponse>>(secondList); var list = Mapper.Map<List<SecondListResponse>>(secondList);
list?.ForEach(t => list?.ForEach(t =>
{ {
...@@ -150,14 +161,17 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -150,14 +161,17 @@ public List<SecondListResponse> GetSecondList(int userId)
} }
}); });
// 暂时在加载列表时补充信息
if (secondList != null && secondList.Any()) if (secondList != null && secondList.Any())
{ {
var worktypes = perforAgworkloadtypeRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.Department == secondList.First().Department && t.UnitType == secondList.First().UnitType); // 暂时在加载列表时补充信息
var worktypes = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.Department == secondList.First().Department && t.UnitType == secondList.First().UnitType);
if (worktypes != null && worktypes.Any()) if (worktypes != null && worktypes.Any())
{ {
worktypes.ForEach(t => AddWorkTypeDefaultValues(t)); worktypes.ForEach(t => AddWorkTypeDefaultValues(t));
} }
// 补充默认工作量项
CheckDefaultWorkload(hospital.HospitalID ?? 0, secondList.First().Department, secondList.First().UnitType);
} }
return list; return list;
...@@ -181,7 +195,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -181,7 +195,7 @@ public List<SecondListResponse> GetSecondList(int userId)
// var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() }; // var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() };
// //获取已录入数据 // //获取已录入数据
// var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue); // var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue);
// if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过 // if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过
// { // {
// #region 已归档数据,根据数据获取 列 // #region 已归档数据,根据数据获取 列
...@@ -225,7 +239,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -225,7 +239,7 @@ public List<SecondListResponse> GetSecondList(int userId)
// .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList(); // .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
// var index = secondIdList.IndexOf(request.SecondId); // var index = secondIdList.IndexOf(request.SecondId);
// if (index != 0) // if (index != 0)
// fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue); // fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue);
// fixatList = fixatList?.Where(t => bringhead.Select(h => h.FiledName).Contains(t.ItemName)).ToList(); // fixatList = fixatList?.Where(t => bringhead.Select(h => h.FiledName).Contains(t.ItemName)).ToList();
// if (fixatList != null && fixatList.Count > 0) // if (fixatList != null && fixatList.Count > 0)
...@@ -277,15 +291,15 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -277,15 +291,15 @@ 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); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效"); throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效信息无效"); throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity( var usetemp = agusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.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("当前科室暂未配置绩效模板");
...@@ -308,22 +322,22 @@ public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId) ...@@ -308,22 +322,22 @@ public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId)
/// <returns></returns> /// <returns></returns>
public SecondResponse GetSecondDetail(UseTempRequest request, int userId) public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
{ {
var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType); //获取科室二次绩效费用分配使用的模板 && t.Department == request.Department && t.UnitType == request.UnitType); //获取科室二次绩效费用分配使用的模板
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
var temp = perforAgtempRepository.GetEntity(t => t.Id == usetemp.UseTempId); var temp = agtempRepository.GetEntity(t => t.Id == usetemp.UseTempId);
if (temp == null || temp.IsEnable != 1) if (temp == null || temp.IsEnable != 1)
throw new PerformanceException("模板无效,请重新选择"); throw new PerformanceException("模板无效,请重新选择");
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
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 result = new SecondResponse(); var result = new SecondResponse();
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue && !string.IsNullOrEmpty(t.ItemName)); var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue && !string.IsNullOrEmpty(t.ItemName));
//归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems //归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems
if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1))
{ {
...@@ -385,7 +399,7 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId) ...@@ -385,7 +399,7 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId)
{ {
if (result?.BodyItems != null && result.BodyItems.Any()) if (result?.BodyItems != null && result.BodyItems.Any())
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.AllotId == allotId); var second = agsecondallotRepository.GetEntity(t => t.AllotId == allotId);
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3);
foreach (var rownum in result.BodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct()) foreach (var rownum in result.BodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct())
...@@ -527,14 +541,14 @@ private List<BodyItem> GetBringItems(UseTempRequest request, List<HeadItem> head ...@@ -527,14 +541,14 @@ private List<BodyItem> GetBringItems(UseTempRequest request, List<HeadItem> head
var bringhead = headItems.Where(t => t.IsBring == 1).ToList(); var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
if (bringhead != null && bringhead.Count > 0) if (bringhead != null && bringhead.Count > 0)
{ {
var allotIds = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID); var allotIds = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID);
var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value) var secondIdList = agsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value)
&& t.Department == request.Department && t.UnitType == request.UnitType) && t.Department == request.Department && t.UnitType == request.UnitType)
.OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList(); .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
var index = secondIdList.IndexOf(request.SecondId); var index = secondIdList.IndexOf(request.SecondId);
var fixatList = new List<ag_fixatitem>(); var fixatList = new List<ag_fixatitem>();
if (index != 0) if (index != 0)
fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1)
&& t.RowNumber.HasValue && t.RowNumber != -1 && bringhead.Select(s => s.FiledName).Contains(t.ItemName)); && t.RowNumber.HasValue && t.RowNumber != -1 && bringhead.Select(s => s.FiledName).Contains(t.ItemName));
if (fixatList != null && fixatList.Any()) if (fixatList != null && fixatList.Any())
...@@ -552,7 +566,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems) ...@@ -552,7 +566,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
{ {
if (bodyItems == null || !bodyItems.Any()) return; if (bodyItems == null || !bodyItems.Any()) return;
var account = perforResaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.AccountingUnit == second.Department && ((UnitType)t.UnitType).ToString() == second.UnitType); var account = resaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.AccountingUnit == second.Department && ((UnitType)t.UnitType).ToString() == second.UnitType);
var keyValue = new Dictionary<string, string> var keyValue = new Dictionary<string, string>
{ {
...@@ -574,7 +588,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems) ...@@ -574,7 +588,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
{ "职称绩效", "年资职称绩效占比" }, { "职称绩效", "年资职称绩效占比" },
{ "工作量绩效", "工作量绩效占比" }, { "工作量绩效", "工作量绩效占比" },
}; };
var config = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId); var config = cofagainRepository.GetEntities(t => t.AllotID == second.AllotId);
if (config != null && config.Any()) if (config != null && config.Any())
{ {
foreach (var item in config) foreach (var item in config)
...@@ -634,7 +648,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -634,7 +648,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
var headerItems = new List<HeadItem>(); var headerItems = new List<HeadItem>();
var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType; var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType;
var deptHeader = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit); var deptHeader = agworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit);
if (deptHeader != null && deptHeader.Any()) if (deptHeader != null && deptHeader.Any())
{ {
int sortindex = 1; int sortindex = 1;
...@@ -699,11 +713,11 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -699,11 +713,11 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
/// <returns></returns> /// <returns></returns>
public bool SaveValue(List<ag_fixatitem> request, int secondId) public bool SaveValue(List<ag_fixatitem> request, int secondId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) if (second == null)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId); var fixatitems = agfixatitemRepository.GetEntities(t => t.SecondId == secondId);
#region old #region old
...@@ -732,16 +746,16 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId) ...@@ -732,16 +746,16 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId)
//} //}
//else //else
// insert = request; // insert = request;
//result = perforAgfixatitemRepository.UpdateRange(update.ToArray()); //result = agfixatitemRepository.UpdateRange(update.ToArray());
//result = perforAgfixatitemRepository.AddRange(insert.ToArray()); //result = agfixatitemRepository.AddRange(insert.ToArray());
#endregion #endregion
bool result = false; bool result = false;
if (fixatitems != null && fixatitems.Any()) if (fixatitems != null && fixatitems.Any())
result = perforAgfixatitemRepository.RemoveRange(fixatitems.ToArray()); result = agfixatitemRepository.RemoveRange(fixatitems.ToArray());
result = perforAgfixatitemRepository.AddRange(request.ToArray()); result = agfixatitemRepository.AddRange(request.ToArray());
return result; return result;
} }
...@@ -760,9 +774,9 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -760,9 +774,9 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
{ {
if (oldFixatItems != null && oldFixatItems.Any()) if (oldFixatItems != null && oldFixatItems.Any())
{ {
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.ToArray()); result = agfixatitemRepository.RemoveRange(oldFixatItems.ToArray());
_logger.LogError($"删除二次分配录入数据:{oldFixatItems.Count()}"); logger.LogError($"删除二次分配录入数据:{oldFixatItems.Count()}");
_logger.LogError($"删除二次分配录入数据:{JsonHelper.Serialize(oldFixatItems.Select(w => w.ID))}"); logger.LogError($"删除二次分配录入数据:{JsonHelper.Serialize(oldFixatItems.Select(w => w.ID))}");
} }
return result; return result;
} }
...@@ -781,8 +795,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -781,8 +795,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
{ {
var delData = oldFixatItems.Where(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID)); var delData = oldFixatItems.Where(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
int flag = oldFixatItems.RemoveAll(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID)); int flag = oldFixatItems.RemoveAll(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
_logger.LogError($"删除二次分配录入数据:{delData.Count()}"); logger.LogError($"删除二次分配录入数据:{delData.Count()}");
result = perforAgfixatitemRepository.RemoveRange(delData.ToArray()); result = agfixatitemRepository.RemoveRange(delData.ToArray());
} }
// 删除行号不存在的数据 // 删除行号不存在的数据
...@@ -790,8 +804,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -790,8 +804,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
var delRows = oldFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct().Except(saveRows); var delRows = oldFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct().Except(saveRows);
if (delRows != null && delRows.Count() > 0) if (delRows != null && delRows.Count() > 0)
{ {
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.Where(t => delRows.Contains(t.RowNumber)).ToArray()); result = agfixatitemRepository.RemoveRange(oldFixatItems.Where(t => delRows.Contains(t.RowNumber)).ToArray());
_logger.LogError($"删除二次分配录入数据 删除行号不存在的数据:{oldFixatItems.Count()}"); logger.LogError($"删除二次分配录入数据 删除行号不存在的数据:{oldFixatItems.Count()}");
} }
} }
...@@ -806,24 +820,24 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -806,24 +820,24 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
public bool SaveCompute(List<ag_compute> request) public bool SaveCompute(List<ag_compute> request)
{ {
var secondId = request.First().SecondId; var secondId = request.First().SecondId;
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) if (second == null)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
if (second.Status == 2) if (second.Status == 2)
throw new PerformanceException("二次绩效已提交,无法重复提交"); throw new PerformanceException("二次绩效已提交,无法重复提交");
var compute = perforAgcomputeRepository.GetEntities(t => t.SecondId == secondId); var compute = agcomputeRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request) foreach (var item in request)
{ {
if (compute != null && compute.Any(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName)) 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); var cellItem = compute.First(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName);
cellItem.RealGiveFee = item.RealGiveFee; cellItem.RealGiveFee = item.RealGiveFee;
perforAgcomputeRepository.Update(cellItem); agcomputeRepository.Update(cellItem);
} }
else else
{ {
perforAgcomputeRepository.Add(item); agcomputeRepository.Add(item);
} }
} }
return true; return true;
...@@ -840,7 +854,7 @@ public bool SaveCompute(List<ag_compute> request) ...@@ -840,7 +854,7 @@ public bool SaveCompute(List<ag_compute> request)
/// <returns></returns> /// <returns></returns>
public List<SecondTempResponse> GetTemp(int hospitalid, string department, int userId) public List<SecondTempResponse> GetTemp(int hospitalid, string department, int userId)
{ {
var temps = perforAgtempRepository.GetEntities(t => t.IsEnable == 1); var temps = agtempRepository.GetEntities(t => t.IsEnable == 1);
if (temps != null && temps.Any()) if (temps != null && temps.Any())
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
...@@ -858,7 +872,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -858,7 +872,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value)) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var useTemp = perforAgusetempRepository.GetEntity(exp); var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps); var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps);
if (useTemp != null) if (useTemp != null)
secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId); secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId);
...@@ -875,17 +889,17 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -875,17 +889,17 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
public bool UseTemp(UseTempRequest request) public bool UseTemp(UseTempRequest request)
{ {
var result = false; var result = false;
var entity = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId var entity = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType); && t.Department == request.Department && t.UnitType == request.UnitType);
if (entity == null) if (entity == null)
{ {
entity = Mapper.Map<ag_usetemp>(request); entity = Mapper.Map<ag_usetemp>(request);
result = perforAgusetempRepository.Add(entity); result = agusetempRepository.Add(entity);
} }
else else
{ {
entity.UseTempId = request.TempId; entity.UseTempId = request.TempId;
result = perforAgusetempRepository.Update(entity); result = agusetempRepository.Update(entity);
if (result) if (result)
{ {
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
...@@ -894,8 +908,8 @@ public bool UseTemp(UseTempRequest request) ...@@ -894,8 +908,8 @@ public bool UseTemp(UseTempRequest request)
List<ag_fixatitem> list = new List<ag_fixatitem>(); List<ag_fixatitem> list = new List<ag_fixatitem>();
var addList = new List<ag_fixatitem>(); var addList = new List<ag_fixatitem>();
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId); var allotList = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var seconds = perforAgsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value) && new List<int> { 1, 4 }.Contains(t.Status ?? 1)); var seconds = agsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value) && new List<int> { 1, 4 }.Contains(t.Status ?? 1));
var secondList = Mapper.Map<List<SecondListResponse>>(seconds); var secondList = Mapper.Map<List<SecondListResponse>>(seconds);
secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0); secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
...@@ -904,7 +918,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -904,7 +918,7 @@ public bool UseTemp(UseTempRequest request)
if (secondId == null || secondId.Count() <= 0) if (secondId == null || secondId.Count() <= 0)
return result; return result;
var fixatList = perforAgfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value)); var fixatList = agfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value));
#region 获取需要添加的数据 无需操作的数据 #region 获取需要添加的数据 无需操作的数据
...@@ -924,7 +938,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -924,7 +938,7 @@ public bool UseTemp(UseTempRequest request)
list.AddRange(exist); list.AddRange(exist);
else if (head.Type == 1) else if (head.Type == 1)
{ {
var configs = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>(); var configs = cofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>();
addList.Add(new ag_fixatitem addList.Add(new ag_fixatitem
{ {
ItemName = head.FiledName, ItemName = head.FiledName,
...@@ -951,10 +965,10 @@ public bool UseTemp(UseTempRequest request) ...@@ -951,10 +965,10 @@ public bool UseTemp(UseTempRequest request)
//if (list != null && list.Count > 0) //if (list != null && list.Count > 0)
//{ //{
// var delList = fixatList.Except(list); // var delList = fixatList.Except(list);
// perforAgfixatitemRepository.RemoveRange(delList.Where(w => w.SecondId == request.SecondId).ToArray()); // agfixatitemRepository.RemoveRange(delList.Where(w => w.SecondId == request.SecondId).ToArray());
// if (addList != null && addList.Count > 0) // if (addList != null && addList.Count > 0)
// perforAgfixatitemRepository.AddRange(addList.ToArray()); // agfixatitemRepository.AddRange(addList.ToArray());
//} //}
} }
} }
...@@ -967,17 +981,17 @@ public bool UseTemp(UseTempRequest request) ...@@ -967,17 +981,17 @@ public bool UseTemp(UseTempRequest request)
/// <returns></returns> /// <returns></returns>
public void RefreshTemp(UseTempRequest request) public void RefreshTemp(UseTempRequest request)
{ {
var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("参数usetempId 无效"); throw new PerformanceException("参数usetempId 无效");
//获取工作量列头 //获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == usetemp.HospitalId && t.Department == usetemp.Department && t.UnitType == usetemp.UnitType); var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == usetemp.HospitalId && t.Department == usetemp.Department && t.UnitType == usetemp.UnitType);
//获取固定模板列头 //获取固定模板列头
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == usetemp.UseTempId); var tempItem = agtempitemRepository.GetEntities(t => t.TempId == usetemp.UseTempId);
var tempHeader = workItem == null ? tempItem.Select(t => t.FiledName) : tempItem.Select(t => t.FiledName).Union(workItem?.Select(t => t.ItemName)); var tempHeader = workItem == null ? tempItem.Select(t => t.FiledName) : tempItem.Select(t => t.FiledName).Union(workItem?.Select(t => t.ItemName));
//获取数据 //获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId); var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId);
if (fixatList == null || fixatList.Count == 0) if (fixatList == null || fixatList.Count == 0)
throw new PerformanceException("未录入数据"); throw new PerformanceException("未录入数据");
...@@ -987,12 +1001,12 @@ public void RefreshTemp(UseTempRequest request) ...@@ -987,12 +1001,12 @@ public void RefreshTemp(UseTempRequest request)
t.Sort = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.Sort; t.Sort = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.Sort;
t.FactorValue = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.FactorValue; t.FactorValue = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.FactorValue;
}); });
perforAgfixatitemRepository.UpdateRange(fixatList.ToArray()); agfixatitemRepository.UpdateRange(fixatList.ToArray());
//删除 列 不存在的数据 //删除 列 不存在的数据
var header = fixatList.Select(t => t.ItemName).Distinct(); var header = fixatList.Select(t => t.ItemName).Distinct();
var delItems = header.Except(tempHeader); var delItems = header.Except(tempHeader);
if (delItems != null && delItems.Count() > 0) if (delItems != null && delItems.Count() > 0)
perforAgfixatitemRepository.RemoveRange(fixatList.Where(t => delItems.Contains(t.ItemName)).ToArray()); agfixatitemRepository.RemoveRange(fixatList.Where(t => delItems.Contains(t.ItemName)).ToArray());
//添加 新增列 的数据 //添加 新增列 的数据
var addItems = new List<ag_fixatitem>(); var addItems = new List<ag_fixatitem>();
fixatList.Select(t => t.RowNumber).Distinct().ToList().ForEach(t => fixatList.Select(t => t.RowNumber).Distinct().ToList().ForEach(t =>
...@@ -1011,7 +1025,7 @@ public void RefreshTemp(UseTempRequest request) ...@@ -1011,7 +1025,7 @@ public void RefreshTemp(UseTempRequest request)
})); }));
}); });
if (addItems != null && addItems.Count() > 0) if (addItems != null && addItems.Count() > 0)
perforAgfixatitemRepository.AddRange(addItems.ToArray()); agfixatitemRepository.AddRange(addItems.ToArray());
} }
#endregion 模板 #endregion 模板
...@@ -1019,95 +1033,6 @@ public void RefreshTemp(UseTempRequest request) ...@@ -1019,95 +1033,6 @@ public void RefreshTemp(UseTempRequest request)
#region 工作量绩效配置 #region 工作量绩效配置
/// <summary> /// <summary>
/// 获取工作量列表
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public List<ag_workload> GetWorkloadList(WorkloadRequest request)
{
return perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && t.WorkTypeId != (int)AgWorkloadType.SingleAwards);
}
/// <summary>
/// 新增工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkloadAdd(WorkloadRequest request)
{
var workloadList = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复");
ag_workload workload = new ag_workload
{
HospitalId = request.HospitalId,
Department = request.Department,
UnitType = request.UnitType,
FactorValue = request.FactorValue ?? 1,
ItemName = request.ItemName,
Sort = request.Sort ?? 1,
WorkTypeId = request.WorkTypeId,
};
var result = perforAgworkloadRepository.Add(workload);
if (result)
{
string field = request.WorkTypeId == (int)AgWorkloadType.SingleAwards ? AgWorkloadType.SingleAwards.ToString() : AgWorkloadType.Workload.ToString();
workload.ItemId = $"{field}_{workload.WorkTypeId}_{workload.Id}";
perforAgworkloadRepository.Update(workload);
}
return result;
}
/// <summary>
/// 修改工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkloadUpdate(WorkloadRequest request)
{
var workloadList = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.Id != request.Id && t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复");
var workload = workloadList.FirstOrDefault(t => t.Id == request.Id);
workload.HospitalId = request.HospitalId;
workload.Department = request.Department;
workload.UnitType = request.UnitType;
workload.FactorValue = request.FactorValue;
workload.ItemName = request.ItemName;
workload.Sort = request.Sort;
string field = request.WorkTypeId == (int)AgWorkloadType.SingleAwards ? AgWorkloadType.SingleAwards.ToString() : AgWorkloadType.Workload.ToString();
workload.ItemId = $"{field}_{request.WorkTypeId}_{workload.Id}";
workload.WorkTypeId = request.WorkTypeId;
return perforAgworkloadRepository.Update(workload);
}
/// <summary>
/// 删除工作量绩效配置
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool WorkloadDelete(int id)
{
var workload = perforAgworkloadRepository.GetEntity(t => t.Id == id);
return perforAgworkloadRepository.Remove(workload);
}
/// <summary>
/// 获取单行奖励列表
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public List<ag_workload> GetSingleList(WorkloadRequest request)
{
return perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && t.WorkTypeId == (int)AgWorkloadType.SingleAwards);
}
/// <summary>
/// 获取工作量类型列表 /// 获取工作量类型列表
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="secondId"></param>
...@@ -1115,7 +1040,7 @@ public List<ag_workload> GetSingleList(WorkloadRequest request) ...@@ -1115,7 +1040,7 @@ public List<ag_workload> GetSingleList(WorkloadRequest request)
public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId) public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId)
{ {
var (unit, dept) = GetDeptAndUnit(userId); var (unit, dept) = GetDeptAndUnit(userId);
var worktypes = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId.Value == t.HospitalId && t.Department == dept && t.UnitType == unit); var worktypes = agworkloadtypeRepository.GetEntities(t => request.HospitalId.Value == t.HospitalId && t.Department == dept && t.UnitType == unit);
if (worktypes != null && worktypes.Any()) if (worktypes != null && worktypes.Any())
{ {
return worktypes.Select(t => new TitleValue<int> return worktypes.Select(t => new TitleValue<int>
...@@ -1135,16 +1060,16 @@ public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId) ...@@ -1135,16 +1060,16 @@ public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId)
public ag_workload_type SaveWorkType(ag_workload_type request, int userId) public ag_workload_type SaveWorkType(ag_workload_type request, int userId)
{ {
var (unit, dept) = GetDeptAndUnit(userId); var (unit, dept) = GetDeptAndUnit(userId);
var entity = perforAgworkloadtypeRepository.GetEntity(t => request.HospitalId == t.HospitalId && t.Department == dept && t.UnitType == unit && t.TypeName == request.TypeName); var entity = agworkloadtypeRepository.GetEntity(t => request.HospitalId == t.HospitalId && t.Department == dept && t.UnitType == unit && t.TypeName == request.TypeName);
if (entity == null) if (entity == null)
{ {
if (request.Id > 0) if (request.Id > 0)
{ {
entity = perforAgworkloadtypeRepository.GetEntity(t => t.Id == request.Id); entity = agworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
entity.HospitalId = request.HospitalId; entity.HospitalId = request.HospitalId;
entity.TypeName = request.TypeName; entity.TypeName = request.TypeName;
perforAgworkloadtypeRepository.Update(entity); agworkloadtypeRepository.Update(entity);
} }
else else
{ {
...@@ -1155,7 +1080,7 @@ public ag_workload_type SaveWorkType(ag_workload_type request, int userId) ...@@ -1155,7 +1080,7 @@ public ag_workload_type SaveWorkType(ag_workload_type request, int userId)
Department = dept, Department = dept,
UnitType = unit, UnitType = unit,
}; };
perforAgworkloadtypeRepository.Add(entity); agworkloadtypeRepository.Add(entity);
} }
AddWorkTypeDefaultHeadValue(request.HospitalId, entity); AddWorkTypeDefaultHeadValue(request.HospitalId, entity);
AddWorkTypeDefaultValues(entity); AddWorkTypeDefaultValues(entity);
...@@ -1167,85 +1092,62 @@ public ag_workload_type SaveWorkType(ag_workload_type request, int userId) ...@@ -1167,85 +1092,62 @@ public ag_workload_type SaveWorkType(ag_workload_type request, int userId)
return request; return request;
} }
/// <summary>
/// 添加工作量类型默认项工作量得分、考核得分、工作量绩效工资
/// </summary>
/// <param name="type"></param>
private void AddWorkTypeDefaultValues(ag_workload_type type) private void AddWorkTypeDefaultValues(ag_workload_type type)
{ {
List<(string, string, int)> defaultValues = new List<(string, string, int)> var workItems = agworkloadRepository.GetEntities(t => t.WorkTypeId == type.Id);
{
( "工作量得分", "WorkloadScore" , 1 ),
( "考核得分", "AssessmentScore", 2 ),
( "工作量绩效工资", "WorkPerformance", 3 )
};
List<ag_workload> insertData = new List<ag_workload>(); List<(string, string, int)> addItems = new List<(string, string, int)>();
var workItems = perforAgworkloadRepository.GetEntities(t => t.WorkTypeId == type.Id); if (workItems != null && workItems.Any())
if (workItems == null || !workItems.Any(t => defaultValues.Select(q => q.Item1).Contains(t.ItemName)))
{
insertData = defaultValues.Select(t => new ag_workload
{
HospitalId = type.HospitalId,
Department = type.Department,
UnitType = type.UnitType,
ItemId = $"{t.Item2}_{type.Id}",
ItemName = t.Item1,
FactorValue = null,
Sort = 100 + t.Item3,
WorkTypeId = type.Id
}).ToList();
}
else
{ {
foreach (var item in defaultValues) foreach (var item in defaultValues)
{ {
var data = workItems.FirstOrDefault(t => t.ItemName == item.Item1); if (!workItems.Any(t => t.ItemId.StartsWith(item.Item2)))
if (data == null) addItems.Add(item);
{
insertData.Add(new ag_workload
{
HospitalId = type.HospitalId,
Department = type.Department,
UnitType = type.UnitType,
ItemId = $"{item.Item2}_{type.Id}",
ItemName = item.Item1,
FactorValue = null,
Sort = 100 + item.Item3,
WorkTypeId = type.Id
});
}
} }
} }
var result = perforAgworkloadRepository.AddRange(insertData.ToArray());
if (result) if (addItems == null || !addItems.Any()) return;
var insertData = addItems.Select(t => new ag_workload
{ {
insertData.ForEach(t => HospitalId = type.HospitalId,
{ Department = type.Department,
var prefix = defaultValues.FirstOrDefault(w => w.Item1 == t.ItemName).Item2; UnitType = type.UnitType,
if (!string.IsNullOrEmpty(prefix)) ItemId = $"{t.Item2}_{type.Id}",
{ ItemName = t.Item1,
t.ItemId = $"{prefix}_{t.WorkTypeId}_{t.Id}"; FactorValue = null,
} Sort = 100 + t.Item3
}); });
perforAgworkloadRepository.UpdateRange(insertData.ToArray()); agworkloadRepository.AddRange(insertData.ToArray());
}
} }
/// <summary>
/// 添加工作量类型默认配置 - 顶部数据中的占比、金额
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="type"></param>
private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type) private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type)
{ {
List<ag_worktype_source> insertData = new List<ag_worktype_source>(); List<ag_worktype_source> insertData = new List<ag_worktype_source>();
var allots = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId); var allots = perallotRepository.GetEntities(t => t.HospitalId == hospitalId);
if (allots == null || !allots.Any()) return; if (allots == null || !allots.Any()) return;
var seconds = perforAgsecondallotRepository.GetEntities(t => allots.Select(w => w.ID).Contains(t.AllotId.Value) && t.Department == type.Department && t.UnitType == type.UnitType); var seconds = agsecondallotRepository.GetEntities(t => allots.Select(w => w.ID).Contains(t.AllotId.Value) && t.Department == type.Department && t.UnitType == type.UnitType);
if (seconds == null || !seconds.Any()) if (seconds == null || !seconds.Any())
return; return;
var worktypeSources = worktypesourceRepository.GetEntities(t => t.WorkTypeId == type.Id); var worktypeSources = agworktypesourceRepository.GetEntities(t => t.WorkTypeId == type.Id);
if (worktypeSources == null || !worktypeSources.Any()) if (worktypeSources == null || !worktypeSources.Any())
{ {
insertData = seconds.Select(t => new ag_worktype_source insertData = seconds.Select(t => new ag_worktype_source
{ {
WorkTypeId = type.Id, WorkTypeId = type.Id,
SecondId = t.Id, SecondId = t.Id,
FieldId = $"{AgWorkloadType.Workload.ToString()}_Ratio_{type.Id}", FieldId = $"{AgWorkloadType.Workload}_Ratio_{type.Id}",
FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比" FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比"
}).ToList(); }).ToList();
} }
...@@ -1259,7 +1161,7 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type) ...@@ -1259,7 +1161,7 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type)
{ {
WorkTypeId = type.Id, WorkTypeId = type.Id,
SecondId = t, SecondId = t,
FieldId = $"{AgWorkloadType.Workload.ToString()}_Ratio_{type.Id}", FieldId = $"{AgWorkloadType.Workload}_Ratio_{type.Id}",
FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比" FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比"
}).ToList(); }).ToList();
} }
...@@ -1267,7 +1169,7 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type) ...@@ -1267,7 +1169,7 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type)
{ {
t.FieldName = type.TypeName + t.FieldName.Substring(t.FieldName.Length - 2); t.FieldName = type.TypeName + t.FieldName.Substring(t.FieldName.Length - 2);
}); });
worktypesourceRepository.UpdateRange(worktypeSources.ToArray()); agworktypesourceRepository.UpdateRange(worktypeSources.ToArray());
} }
var amounts = insertData.Select(t => new ag_worktype_source var amounts = insertData.Select(t => new ag_worktype_source
{ {
...@@ -1277,40 +1179,183 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type) ...@@ -1277,40 +1179,183 @@ private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type)
FieldName = t.FieldName.Substring(0, t.FieldName.Length - 2) + "金额" FieldName = t.FieldName.Substring(0, t.FieldName.Length - 2) + "金额"
}).ToList(); }).ToList();
insertData.AddRange(amounts); insertData.AddRange(amounts);
var result = worktypesourceRepository.AddRange(insertData.OrderBy(t => t.SecondId).ThenBy(t => t.FieldName).ToArray()); agworktypesourceRepository.AddRange(insertData.OrderBy(t => t.SecondId).ThenBy(t => t.FieldName).ToArray());
if (result) }
/// <summary>
/// 检查默认工作量项是否已添加,添加默认的工作量得分、考核得分、工作量绩效工资
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="department"></param>
/// <param name="unitType"></param>
private void CheckDefaultWorkload(int hospitalId, string department, string unitType)
{
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
List<(string, string, int)> addItems = new List<(string, string, int)>();
if (workloads != null && workloads.Any())
{ {
insertData.ForEach(t => t.FieldId = t.FieldId + "_" + t.Id); foreach (var item in defaultValues)
worktypesourceRepository.UpdateRange(insertData.ToArray()); {
if (!workloads.Any(t => t.ItemId == item.Item2 + "_Default"))
addItems.Add(item);
}
} }
if (addItems == null || !addItems.Any()) return;
var insertData = addItems.Select(t => new ag_workload
{
HospitalId = hospitalId,
Department = department,
UnitType = unitType,
ItemId = t.Item2 + "_Default",
ItemName = t.Item1,
FactorValue = null,
Sort = 100 + t.Item3
});
agworkloadRepository.AddRange(insertData.ToArray());
} }
private readonly List<(string, string, int)> defaultValues = new List<(string, string, int)>
{
( "工作量得分", "WorkloadScore" , 1 ),
( "考核得分", "AssessmentScore", 2 ),
( "工作量绩效工资", "WorkPerformance", 3 )
};
/// <summary> /// <summary>
/// 获取工作量类型列表 /// 删除工作量类型
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="secondId"></param>
/// <returns></returns> /// <returns></returns>
public bool DeleteWorkType(WorkloadRequest request) public bool DeleteWorkType(WorkloadRequest request)
{ {
var entity = perforAgworkloadtypeRepository.GetEntity(t => t.Id == request.Id); var entity = agworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
if (entity != null) if (entity != null)
{ {
var items = perforAgworkloadRepository.GetEntities(t => t.WorkTypeId == request.Id); var items = agworkloadRepository.GetEntities(t => t.WorkTypeId == request.Id);
if (items != null && items.Any()) if (items != null && items.Any())
perforAgworkloadRepository.RemoveRange(items.ToArray()); agworkloadRepository.RemoveRange(items.ToArray());
var sources = worktypesourceRepository.GetEntities(t => t.WorkTypeId == request.Id); var sources = agworktypesourceRepository.GetEntities(t => t.WorkTypeId == request.Id);
if (sources != null && sources.Any()) if (sources != null && sources.Any())
worktypesourceRepository.RemoveRange(sources.ToArray()); agworktypesourceRepository.RemoveRange(sources.ToArray());
return perforAgworkloadtypeRepository.Remove(entity); return agworkloadtypeRepository.Remove(entity);
} }
else else
return false; return false;
} }
/// <summary>
/// 获取工作量列表
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public List<ag_workload> GetWorkloadList(WorkloadRequest request)
{
return agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && t.ItemId.StartsWith($"{AgWorkloadType.Workload}_"));
}
/// <summary>
/// 新增工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkloadAdd(WorkloadRequest request)
{
var workloadList = agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复");
ag_workload workload = new ag_workload
{
HospitalId = request.HospitalId,
Department = request.Department,
UnitType = request.UnitType,
FactorValue = request.FactorValue ?? 1,
ItemName = request.ItemName,
Sort = request.Sort ?? 1,
WorkTypeId = request.WorkTypeId,
};
var result = agworkloadRepository.Add(workload);
if (result)
{
workload.ItemId = getWorkloadItemId.Invoke(request.IsSingleAwards, request.WorkTypeId, workload.Id);
agworkloadRepository.Update(workload);
}
return result;
}
/// <summary>
/// 修改工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkloadUpdate(WorkloadRequest request)
{
var workloadList = agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.Id != request.Id && t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复");
var workload = workloadList.FirstOrDefault(t => t.Id == request.Id);
workload.HospitalId = request.HospitalId;
workload.Department = request.Department;
workload.UnitType = request.UnitType;
workload.FactorValue = request.FactorValue;
workload.ItemName = request.ItemName;
workload.Sort = request.Sort;
workload.ItemId = getWorkloadItemId.Invoke(request.IsSingleAwards, request.WorkTypeId, workload.Id); ;
workload.WorkTypeId = request.WorkTypeId;
return agworkloadRepository.Update(workload);
}
/// <summary>
/// 获取工作量绩效配置的ItemId
/// </summary>
readonly Func<bool, int, int, string> getWorkloadItemId = (isSingleAwards, workTypeId, workloadId) =>
{
/**
* 单项奖励 - SingleAwards_WorkloadId
* 默认工作量类型WorkTypeId=0 - Workload_Default_WorkloadId
* 自定义工作量类型WorkTypeId>0 - Workload_WorkTypeId_WorkloadId
*/
if (isSingleAwards)
return $"{AgWorkloadType.SingleAwards}_{workloadId}";
else
{
return workTypeId == (int)AgWorkloadType.Workload ? $"{AgWorkloadType.Workload}_Default_{workloadId}"
: $"{AgWorkloadType.Workload}_{workTypeId}_{workloadId}";
}
};
/// <summary>
/// 删除工作量绩效配置
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool WorkloadDelete(int id)
{
var workload = agworkloadRepository.GetEntity(t => t.Id == id);
return agworkloadRepository.Remove(workload);
}
/// <summary>
/// 获取单行奖励列表
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public List<ag_workload> GetSingleList(WorkloadRequest request)
{
return agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && t.ItemId.StartsWith(AgWorkloadType.SingleAwards.ToString()));
}
public (string, string) GetDeptAndUnit(int userId) public (string, string) GetDeptAndUnit(int userId)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
...@@ -1337,11 +1382,11 @@ public bool DeleteWorkType(WorkloadRequest request) ...@@ -1337,11 +1382,11 @@ public bool DeleteWorkType(WorkloadRequest request)
/// <returns></returns> /// <returns></returns>
public List<ag_secondallot> AuditList(int allotId) public List<ag_secondallot> AuditList(int allotId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) if (allot == null)
throw new PerformanceException("所选绩效不存在!"); throw new PerformanceException("所选绩效不存在!");
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && !new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 }.Contains(t.UnitType.Value)); var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allotId && !new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 }.Contains(t.UnitType.Value));
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID); var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit); return SecondList(allot, accountUnit, specialunit);
...@@ -1359,7 +1404,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou ...@@ -1359,7 +1404,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou
temps.Add(new res_account { UnitType = (int)UnitType.特殊核算组, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee }); temps.Add(new res_account { UnitType = (int)UnitType.特殊核算组, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee });
}); });
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month); var secondList = agsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
var result = temps.Select(t => var result = temps.Select(t =>
{ {
var second = secondList?.FirstOrDefault(f => f.UnitType == ((UnitType)t.UnitType).ToString() && f.Department == t.AccountingUnit); var second = secondList?.FirstOrDefault(f => f.UnitType == ((UnitType)t.UnitType).ToString() && f.Department == t.AccountingUnit);
...@@ -1389,11 +1434,11 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou ...@@ -1389,11 +1434,11 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou
/// <returns></returns> /// <returns></returns>
public List<ag_secondallot> NursingDeptlist(int allotId) public List<ag_secondallot> NursingDeptlist(int allotId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) if (allot == null)
throw new PerformanceException("所选绩效不存在!"); throw new PerformanceException("所选绩效不存在!");
var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 }; var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 };
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value)); var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value));
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID); var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit); return SecondList(allot, accountUnit, specialunit);
} }
...@@ -1406,7 +1451,7 @@ public List<ag_secondallot> NursingDeptlist(int allotId) ...@@ -1406,7 +1451,7 @@ public List<ag_secondallot> NursingDeptlist(int allotId)
/// <returns></returns> /// <returns></returns>
public bool AuditSubmit(ag_secondallot second, int userId) public bool AuditSubmit(ag_secondallot second, int userId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == second.AllotId); var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("二次绩效无效!"); throw new PerformanceException("二次绩效无效!");
...@@ -1425,7 +1470,7 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1425,7 +1470,7 @@ public bool AuditSubmit(ag_secondallot second, int userId)
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value)) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var temp = perforAgusetempRepository.GetEntity(exp); var temp = agusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!"); throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!");
...@@ -1440,7 +1485,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1440,7 +1485,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
if (temp.UseTempId == 6) if (temp.UseTempId == 6)
{ {
var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == second.Id); var data = agothersourceRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
...@@ -1450,7 +1495,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1450,7 +1495,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
} }
else else
{ {
var data = perforAgfixatitemRepository.GetEntities(t => t.SecondId == second.Id); var data = agfixatitemRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
...@@ -1465,7 +1510,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1465,7 +1510,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
second.SubmitType = temp.UseTempId == 6 ? 2 : 1; second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now; second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中"; //second.Remark = "已提交审核,等待审核中";
return perforAgsecondallotRepository.Update(second); return agsecondallotRepository.Update(second);
} }
/// <summary> /// <summary>
...@@ -1477,7 +1522,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1477,7 +1522,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
/// <returns></returns> /// <returns></returns>
public bool ConfirmAudit(int userId, SecondAuditRequest request) public bool ConfirmAudit(int userId, SecondAuditRequest request)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
//if (second.Status != 2) //if (second.Status != 2)
// throw new PerformanceException("该绩效未提交至审核,请确认"); // throw new PerformanceException("该绩效未提交至审核,请确认");
...@@ -1498,19 +1543,19 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1498,19 +1543,19 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
//{ //{
// second.Remark = request.IsPass == 1 ? "审核通过" : "驳回"; // second.Remark = request.IsPass == 1 ? "审核通过" : "驳回";
//} //}
var result = perforAgsecondallotRepository.Update(second); var result = agsecondallotRepository.Update(second);
// 无论驳回还是通过,都需要清空该科室历史数据 // 无论驳回还是通过,都需要清空该科室历史数据
var histories = perforAgcomputeRepository.GetEntities(w => w.SecondId == request.SecondId); var histories = agcomputeRepository.GetEntities(w => w.SecondId == request.SecondId);
if (histories != null && histories.Any()) if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray()); agcomputeRepository.RemoveRange(histories.ToArray());
#region 添加至二次绩效汇总 #region 添加至二次绩效汇总
if (result && request.IsPass == 1) if (result && request.IsPass == 1)
{ {
// 护理部审核 // 护理部审核
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) return true; if (allot == null) return true;
var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId); var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
...@@ -1522,7 +1567,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1522,7 +1567,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
var computes = new List<ag_compute>(); var computes = new List<ag_compute>();
if (second.SubmitType == 1) if (second.SubmitType == 1)
{ {
var items = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId); var items = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId);
if (items != null && items.Any()) if (items != null && items.Any())
{ {
var rowNumbers = items.Select(t => t.RowNumber).Where(t => t >= 0)?.Distinct(); var rowNumbers = items.Select(t => t.RowNumber).Where(t => t >= 0)?.Distinct();
...@@ -1552,7 +1597,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1552,7 +1597,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
} }
else if (second.SubmitType == 2) else if (second.SubmitType == 2)
{ {
var others = perforAgothersourceRepository.GetEntities(t => t.SecondId == request.SecondId); var others = agothersourceRepository.GetEntities(t => t.SecondId == request.SecondId);
if (others != null && others.Any()) if (others != null && others.Any())
{ {
foreach (var item in others) foreach (var item in others)
...@@ -1574,7 +1619,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1574,7 +1619,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
} }
} }
} }
perforAgcomputeRepository.AddRange(computes.ToArray()); agcomputeRepository.AddRange(computes.ToArray());
} }
#endregion 添加至二次绩效汇总 #endregion 添加至二次绩效汇总
...@@ -1591,7 +1636,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1591,7 +1636,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
/// <returns></returns> /// <returns></returns>
public bool NursingDeptAudit(int userId, SecondAuditRequest request) public bool NursingDeptAudit(int userId, SecondAuditRequest request)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("二次分配绩效无效"); throw new PerformanceException("二次分配绩效无效");
if (request.IsPass == 1) if (request.IsPass == 1)
...@@ -1608,7 +1653,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request) ...@@ -1608,7 +1653,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request)
second.NursingDeptAuditUser = userId; second.NursingDeptAuditUser = userId;
second.NursingDeptAuditTime = DateTime.Now; second.NursingDeptAuditTime = DateTime.Now;
return perforAgsecondallotRepository.Update(second); return agsecondallotRepository.Update(second);
} }
#endregion 二次绩效考核 #endregion 二次绩效考核
...@@ -1622,7 +1667,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request) ...@@ -1622,7 +1667,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request)
/// <returns></returns> /// <returns></returns>
public ag_secondallot GetSecondallot(int secondId) public ag_secondallot GetSecondallot(int secondId)
{ {
return perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); return agsecondallotRepository.GetEntity(t => t.Id == secondId);
} }
/// <summary> /// <summary>
...@@ -1635,18 +1680,18 @@ public ag_secondallot GetSecondallot(int secondId) ...@@ -1635,18 +1680,18 @@ public ag_secondallot GetSecondallot(int secondId)
/// <returns></returns> /// <returns></returns>
public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department, string unitType) public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department, string unitType)
{ {
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == tempId); var tempItem = agtempitemRepository.GetEntities(t => t.TempId == tempId);
var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>(); var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
var temp = perforAgtempRepository.GetEntity(w => w.Id == tempId); var temp = agtempRepository.GetEntity(w => w.Id == tempId);
// 其他来源不考虑工作量 // 其他来源不考虑工作量
if (temp?.Id == 6) if (temp?.Id == 6)
return headItems; return headItems;
//获取工作量列头 //获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType); var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
if (workItem != null && workItem.Count > 0) if (workItem != null && workItem.Count > 0)
{ {
var workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards)); var workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards));
...@@ -1697,14 +1742,14 @@ public List<BodyItem> GetBodyItems(List<HeadItem> headItems, int source, List<co ...@@ -1697,14 +1742,14 @@ public List<BodyItem> GetBodyItems(List<HeadItem> headItems, int source, List<co
public List<ag_othersource> OtherList(int secondId, int userId) public List<ag_othersource> OtherList(int secondId, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("二次绩效信息无效!"); if (second == null) throw new PerformanceException("二次绩效信息无效!");
var employees = personService.GetPersons(second.AllotId.Value, userId); var employees = personService.GetPersons(second.AllotId.Value, userId);
employees = employees?.Where(t => t.UnitType == second.UnitType).ToList(); employees = employees?.Where(t => t.UnitType == second.UnitType).ToList();
List<ag_othersource> result = null; List<ag_othersource> result = null;
var otherSecondList = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var otherSecondList = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (otherSecondList != null && otherSecondList.Any()) if (otherSecondList != null && otherSecondList.Any())
{ {
result = otherSecondList.OrderBy(t => t.Id).ToList(); result = otherSecondList.OrderBy(t => t.Id).ToList();
...@@ -1736,15 +1781,15 @@ public List<ag_othersource> OtherList(int secondId, int userId) ...@@ -1736,15 +1781,15 @@ public List<ag_othersource> OtherList(int secondId, int userId)
/// <returns></returns> /// <returns></returns>
public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId) public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效"); throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效信息无效"); throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity( var usetemp = agusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.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("当前科室暂未配置绩效模板");
...@@ -1815,7 +1860,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -1815,7 +1860,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount) public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) return new Dictionary<string, string>(); if (second == null) return new Dictionary<string, string>();
var keyValue = new Dictionary<string, string> var keyValue = new Dictionary<string, string>
...@@ -1830,7 +1875,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -1830,7 +1875,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request) public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request)
{ {
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var existEntities = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any()) if (existEntities != null && existEntities.Any())
{ {
foreach (var item in request.Where(t => t.Id != 0)) foreach (var item in request.Where(t => t.Id != 0))
...@@ -1850,20 +1895,20 @@ public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request ...@@ -1850,20 +1895,20 @@ public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request
existEntities.First(t => t.Id == item.Id).IndividualReward = item.IndividualReward; existEntities.First(t => t.Id == item.Id).IndividualReward = item.IndividualReward;
existEntities.First(t => t.Id == item.Id).AllocationOfKeySpecialty = item.AllocationOfKeySpecialty; existEntities.First(t => t.Id == item.Id).AllocationOfKeySpecialty = item.AllocationOfKeySpecialty;
} }
perforAgothersourceRepository.UpdateRange(existEntities.ToArray()); agothersourceRepository.UpdateRange(existEntities.ToArray());
var delIds = existEntities.Select(t => t.Id).Except(request.Select(t => t.Id)); var delIds = existEntities.Select(t => t.Id).Except(request.Select(t => t.Id));
if (delIds != null) if (delIds != null)
perforAgothersourceRepository.RemoveRange(existEntities.Where(t => delIds.Contains(t.Id)).ToArray()); agothersourceRepository.RemoveRange(existEntities.Where(t => delIds.Contains(t.Id)).ToArray());
} }
var addEntities = request.Where(t => t.Id == 0).ToList(); var addEntities = request.Where(t => t.Id == 0).ToList();
if (addEntities != null && addEntities.Any()) if (addEntities != null && addEntities.Any())
{ {
addEntities.ForEach(t => t.SecondId = secondId); addEntities.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(addEntities.ToArray()); agothersourceRepository.AddRange(addEntities.ToArray());
} }
return perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); return agothersourceRepository.GetEntities(t => t.SecondId == secondId);
} }
public void OtherSave(int secondId, SaveCollectData collectData) public void OtherSave(int secondId, SaveCollectData collectData)
...@@ -1895,14 +1940,14 @@ public void OtherSave(int secondId, SaveCollectData collectData) ...@@ -1895,14 +1940,14 @@ public void OtherSave(int secondId, SaveCollectData collectData)
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;
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var existEntities = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any()) if (existEntities != null && existEntities.Any())
{ {
perforAgothersourceRepository.RemoveRange(existEntities.ToArray()); agothersourceRepository.RemoveRange(existEntities.ToArray());
} }
data.ForEach(t => t.SecondId = secondId); data.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(data.ToArray()); agothersourceRepository.AddRange(data.ToArray());
} }
#endregion 二次绩效其他来源 #endregion 二次绩效其他来源
...@@ -1911,10 +1956,10 @@ public void OtherSave(int secondId, SaveCollectData collectData) ...@@ -1911,10 +1956,10 @@ public void OtherSave(int secondId, SaveCollectData collectData)
public List<SecPrintResponse> Print(int secondId) public List<SecPrintResponse> Print(int secondId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) return new List<SecPrintResponse>(); if (second == null) return new List<SecPrintResponse>();
//var computes = perforAgcomputeRepository.GetEntities(t => t.SecondId == secondId); //var computes = agcomputeRepository.GetEntities(t => t.SecondId == secondId);
//if (computes == null || !computes.Any()) //if (computes == null || !computes.Any())
// return new List<SecPrintResponse>(); // return new List<SecPrintResponse>();
...@@ -1922,7 +1967,7 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1922,7 +1967,7 @@ public List<SecPrintResponse> Print(int secondId)
if (isOtherTemp) if (isOtherTemp)
{ {
var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var data = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (data == null || !data.Any()) return new List<SecPrintResponse>(); if (data == null || !data.Any()) return new List<SecPrintResponse>();
var result = Mapper.Map<List<SecPrintResponse>>(data); var result = Mapper.Map<List<SecPrintResponse>>(data);
...@@ -1931,7 +1976,7 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1931,7 +1976,7 @@ public List<SecPrintResponse> Print(int secondId)
else else
{ {
var itemname = new List<string> { "人员工号", "姓名", "职称", "职称绩效", "工作量绩效工资", "单项奖励小计", "可分配绩效", "医院其他绩效", "夜班工作量绩效" }; var itemname = new List<string> { "人员工号", "姓名", "职称", "职称绩效", "工作量绩效工资", "单项奖励小计", "可分配绩效", "医院其他绩效", "夜班工作量绩效" };
var fixaitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId && itemname.Contains(t.ItemName)); var fixaitems = agfixatitemRepository.GetEntities(t => t.SecondId == secondId && itemname.Contains(t.ItemName));
if (fixaitems == null || !fixaitems.Any(t => t.RowNumber.HasValue && t.RowNumber != -1)) return new List<SecPrintResponse>(); if (fixaitems == null || !fixaitems.Any(t => t.RowNumber.HasValue && t.RowNumber != -1)) return new List<SecPrintResponse>();
...@@ -1965,11 +2010,11 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1965,11 +2010,11 @@ public List<SecPrintResponse> Print(int secondId)
public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out int isShowManage) public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out int isShowManage)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
throw new NotImplementedException("人员ID无效"); throw new NotImplementedException("人员ID无效");
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId); isShowManage = computeService.IsShowManage(allotId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
...@@ -2015,12 +2060,12 @@ public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out ...@@ -2015,12 +2060,12 @@ public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out
public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage) public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
throw new NotImplementedException("人员ID无效"); throw new NotImplementedException("人员ID无效");
var deptDatas = new List<DeptDataDetails>(); var deptDatas = new List<DeptDataDetails>();
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId); isShowManage = computeService.IsShowManage(allotId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
......
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