二次分配科室改名带出问题修复

parent 7eece475
......@@ -295,8 +295,11 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
}
else
{
var allWorkloadTypes = _agworkloadtypeRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department) ?? new List<ag_workload_type>();
var workloadTypes = allWorkloadTypes.Where(t => UnitTypeUtil.Is(t.UnitType, second.UnitType)) ?? new List<ag_workload_type>();
var temp = _agworkloadtypeRepository.GetEntities(t => t.HospitalId == allot.HospitalId) ?? new List<ag_workload_type>();
var workloadTypes = temp.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.Department == second.Department) ?? new List<ag_workload_type>();
if (workloadTypes.Count() == 0)
workloadTypes = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.NewUnitType) && w.Department == second.NewAccountingUnit)?.ToList() ?? new List<ag_workload_type>();
foreach (var item in workloadTypes.OrderBy(t => t.Id))
{
maps.Add(new SecondColumnDictionary($"{item.TypeName}占比", $"Workload_Ratio_{item.Id}", true, 1, "Top", isNumber: true));
......@@ -384,8 +387,10 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D
else
{
var bodyDynamic = _agworkloadsourceRepository.GetEntities(t => loadEmployees.Select(w => w.Id).Contains(t.BodyId));
var allworkload = _agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department) ?? new List<ag_workload>();
var workloads = allworkload.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType)) ?? new List<ag_workload>();
var temp = _agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId) ?? new List<ag_workload>();
var workloads = temp.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.Department == second.Department) ?? new List<ag_workload>();
if (workloads.Count() == 0)
workloads = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.NewUnitType) && w.Department == second.NewAccountingUnit)?.ToList() ?? new List<ag_workload>();
/* isSave 为True时,没必要查询数据 */
var secondWorkload = isSave && overrideMode != EmployeeSource.Workload
......@@ -453,8 +458,8 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D
if (Enum.TryParse(typeof(UnitType), second.UnitType, true, out object unittype))
{
// 优先取 业务中层实际人均绩效 否则 取 科室人均
var tempEmpolyee = _imemployeeclinicRepository.GetEntities(w => w.AllotID == allot.ID && w.AccountingUnit == second.Department);
var empolyee = tempEmpolyee.FirstOrDefault(w => UnitTypeUtil.Is(w.UnitType, second.UnitType));
var tempEmpolyee = _imemployeeclinicRepository.GetEntities(w => w.AllotID == allot.ID);
var empolyee = tempEmpolyee.FirstOrDefault(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.AccountingUnit == second.Department);
var rescompute = _resaccountRepository.GetEntity(w => w.AllotID == allot.ID && w.AccountingUnit == second.Department && w.UnitType == (int)unittype);
var avg = (empolyee != null && empolyee.FitPeopleValue.HasValue) ? empolyee.FitPeopleValue : rescompute?.Avg ?? 0;
refAvg = avg ?? 0;
......@@ -495,8 +500,10 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D
else
{
List<decimal> ratios = new List<decimal>();
var tempWorkloadTypes = _agworkloadtypeRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department) ?? new List<ag_workload_type>();
var workloadTypes = tempWorkloadTypes.Where(t => UnitTypeUtil.Is(t.UnitType, second.UnitType));
var temp = _agworkloadtypeRepository.GetEntities(t => t.HospitalId == allot.HospitalId) ?? new List<ag_workload_type>();
var workloadTypes = temp.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.Department == second.Department) ?? new List<ag_workload_type>();
if (workloadTypes.Count() == 0)
workloadTypes = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.NewUnitType) && w.Department == second.NewAccountingUnit)?.ToList() ?? new List<ag_workload_type>();
// 前二次绩效
if (headDynamic.Count == 0 && prevSecondAllot != null)
......@@ -791,8 +798,11 @@ private List<string> LoadEmployees_OfficeExcel(ag_secondallot second)
}
else
{
var tempWorkloads = _agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department) ?? new List<ag_workload>();
var workloads = tempWorkloads.Where(t => UnitTypeUtil.Is(t.UnitType, second.UnitType)) ?? new List<ag_workload>();
var temp = _agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId) ?? new List<ag_workload>();
var workloads = temp.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.Department == second.Department) ?? new List<ag_workload>();
if (workloads.Count() == 0)
workloads = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.NewUnitType) && w.Department == second.NewAccountingUnit)?.ToList() ?? new List<ag_workload>();
var loads = workloads
.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort)
.Select(t => new TitleValue<string, decimal?> { Title = t.ItemId, Value = t.ItemName, State = t.FactorValue })
......@@ -1654,33 +1664,12 @@ public object RedistributionEmployee(SecondEmployeeDto request)
if (employees != null)
{
Func<per_employee, decimal?> getDistPerformance = (emp) => 0;
//// 不计算模板时,带出工作量绩效(一次分配中的应发绩效)
//if (request.ComputeMode == (int)ComputeMode.NotCalculate)
//{
// if (UnitTypeUtil.IsOffice(second.UnitType))
// {
// // 填报模板带出 行政工勤 绩效
// var distPerformance = _rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId && employees.Select(s => s.PersonnelNumber).Contains(t.JobNumber));
// getDistPerformance = (emp) =>
// {
// if (second.Department == emp.AccountingUnit)
// return distPerformance?.Where(w => w.JobNumber?.Trim() == emp.PersonnelNumber?.Trim())?.Sum(w => w.GiveFee) ?? 0;
// return 0;
// };
// }
//}
var secondWorkload = GetSecondWorkloadByValue(second.AllotId.Value, second.UnitType, second.Department);
var monthDays = DateTime.DaysInMonth(allot.Year, allot.Month);
foreach (var employee in employees)
{
Dictionary<string, object> item = new Dictionary<string, object>();
//// 不计算模板时,带出工作量绩效(一次分配中的应发绩效)
//if (request.ComputeMode == (int)ComputeMode.NotCalculate)
//{
// item.Add(nameof(ag_bodysource.WorkPerformance), getDistPerformance(employee));
//}
item.Add(nameof(per_employee.UnitType), employee.UnitType);
item.Add(nameof(ag_bodysource.SecondId), request.SecondId);
item.Add(nameof(ag_bodysource.Department), second.Department);
......
using AutoMapper;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPOI.XSSF.UserModel;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
......@@ -90,10 +92,12 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId,
var prevSecondAllot = GetPreviousSecondAllot(hospitalId, secondAllot);
int tempId = (int)Temp.other;
var temp = agusetempRepository.GetEntities(w => w.HospitalId == hospitalId && w.Department == secondAllot.Department);
var userTemp = temp.FirstOrDefault(w => UnitTypeUtil.IsEqualsUnitType(w.UnitType, secondAllot.UnitType));
if (userTemp != null) tempId = userTemp.UseTempId ?? (int)Temp.other;
var temp = agusetempRepository.GetEntities(w => w.HospitalId == hospitalId);
var userTemp = temp.FirstOrDefault(w => UnitTypeUtil.Is(w.UnitType, secondAllot.UnitType) && w.Department == secondAllot.Department);
if (userTemp == null)
userTemp = temp?.FirstOrDefault(w => UnitTypeUtil.Is(w.UnitType, secondAllot.NewUnitType) && w.Department == secondAllot.NewAccountingUnit);
if (userTemp != null) tempId = userTemp.UseTempId ?? (int)Temp.other;
if (new int[] { 2, 3 }.Contains(secondAllot.Status ?? 1)) //纪录被提交后,根据提交时的模板获取对应的数据
tempId = (secondAllot.UseTempId ?? 0) == 0 ? (int)Temp.other : secondAllot.UseTempId.Value;
......@@ -134,8 +138,10 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se
var fixedHeaders = agtempitemRepository.GetEntities(w => w.TempId == tempId);
// 用户自定义的工作量、单项奖励
var temp = agworkloadRepository.GetEntities(w => w.HospitalId == hospitalId && w.Department == secondAllot.Department);
var configHeaders = temp.Where(w => UnitTypeUtil.IsEqualsUnitType(w.UnitType, secondAllot.UnitType));
var temp = agworkloadRepository.GetEntities(w => w.HospitalId == hospitalId);
var configHeaders = temp.Where(w => UnitTypeUtil.Is(w.UnitType, secondAllot.UnitType) && w.Department == secondAllot.Department);
if (configHeaders.Count() == 0)
configHeaders = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, secondAllot.NewUnitType) && w.Department == secondAllot.NewAccountingUnit)?.ToList() ?? new List<ag_workload>();
if (SecondAllotService.defaultValues != null && SecondAllotService.defaultValues.Any())
configHeaders = configHeaders?.Where(w => !SecondAllotService.defaultValues.Select(t => t.Item1).Contains(w.ItemName)).ToList();
......@@ -599,8 +605,12 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
var headerItems = new List<HeadItem>();
var unit = secondAllot.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : secondAllot.UnitType;
var temp = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == secondAllot.Department);
var deptHeader = temp.Where(w => UnitTypeUtil.IsEqualsUnitType(w.UnitType, unit));
var temp = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospitalId);
var deptHeader = temp.Where(w => UnitTypeUtil.Is(w.UnitType, unit) && w.Department == secondAllot.Department) ?? new List<ag_workload_type>();
if (deptHeader.Count() == 0)
deptHeader = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, secondAllot.NewUnitType) && w.Department == secondAllot.NewAccountingUnit) ?? new List<ag_workload_type>();
if (deptHeader != null && deptHeader.Any())
{
int sortindex = 1;
......@@ -947,7 +957,7 @@ public ag_secondallot GetPreviousSecondAllot(int hospitalId, ag_secondallot seco
if (index == 0) return null;
var prevAllot = allotList[index - 1];
var temp = agsecondallotRepository.GetEntities(w => w.AllotId == prevAllot.ID && (w.Department == secondAllot.Department || w.Department == secondAllot.NewAccountingUnit));
var temp = agsecondallotRepository.GetEntities(w => w.AllotId == prevAllot.ID);
var prevSecondAllot = temp.FirstOrDefault(w =>
(UnitTypeUtil.IsEqualsUnitType(w.UnitType, secondAllot.UnitType) && w.Department == secondAllot.Department)
......
......@@ -587,8 +587,10 @@ public void SaveSecondAllotBodyData(int hospitalId, ag_secondallot second, dynam
}
if (body == null || !((IEnumerable<dynamic>)body).Any()) return;
var temp = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == second.Department);
var workloads = temp?.Where(w => UnitTypeUtil.IsEqualsUnitType(w.UnitType, second.UnitType))?.ToList() ?? new List<ag_workload>();
var temp = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId);
var workloads = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.UnitType) && w.Department == second.Department)?.ToList() ?? new List<ag_workload>();
if (workloads.Count() == 0)
workloads = temp?.Where(w => UnitTypeUtil.Is(w.UnitType, second.NewUnitType) && w.Department == second.NewAccountingUnit)?.ToList() ?? new List<ag_workload>();
string[] prefix = new string[] { "WorkloadScore_", "AssessmentScore_", "WorkPerformance_", $"{AgWorkloadType.SingleAwards}_", $"{AgWorkloadType.Workload}_", $"{AgWorkloadType.PreAccountingReward}_" };
List<ag_workload_source> workloadSources = new List<ag_workload_source>();
......
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