Commit 62f8a819 by ruyun.zhang@suvalue.com

Merge branch 'hotfix/科室预发修复'

parents 34930cfb 1ee5181d
......@@ -520,141 +520,141 @@ private IEnumerable<PerDataSpecialUnit> CalculateSpecialUnit(PerSheet specialUni
#endregion 预留金额
///// <summary>
///// 创建科室二次分配
///// </summary>
///// <param name="allot"></param>
//public void GenerateSecondAllot(per_allot allot)
//{
// List<ag_secondallot> tempSecond = new List<ag_secondallot>();
// List<ag_secondallot> insSecond = new List<ag_secondallot>();
// List<ag_secondallot> updSecond = new List<ag_secondallot>();
// List<ag_secondallot> delSecond = new List<ag_secondallot>();
// var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政后勤 };
// //// 获取医院是否开启后勤二次分配
// //var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
// //if (hospital?.IsOpenLogisticsSecondAllot != 1)
// // types.Add((int)UnitType.行政后勤);
// var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// // 查询需要进行二次分配的行政后勤科室
// var xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政后勤 && t.NeedSecondAllot == "是");
// if (xzAccountUnit != null && xzAccountUnit.Count > 0)
// (accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
// var specialList = perforResspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
// if (accountUnit != null)
// {
// foreach (var item in accountUnit)
// {
// if (!tempSecond.Any(f => f.UnitType == ((UnitType)item.UnitType).ToString() && f.Department == item.AccountingUnit))
// {
// tempSecond.Add(new ag_secondallot
// {
// AllotId = allot.ID,
// Year = allot.Year,
// Month = allot.Month,
// UnitType = ((UnitType)item.UnitType).ToString(),
// Department = item.AccountingUnit,
// NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
// PreRealGiveFee = item.RealGiveFee,
// });
// }
// }
// }
// if (specialList != null)
// {
// foreach (var item in specialList.Select(w => new { w.AccountingUnit, w.NightShiftWorkPerforFee, w.RealGiveFee }).Distinct())
// {
// if (!tempSecond.Any(f => f.UnitType == UnitType.特殊核算组.ToString() && f.Department == item.AccountingUnit))
// {
// tempSecond.Add(new ag_secondallot
// {
// AllotId = allot.ID,
// Year = allot.Year,
// Month = allot.Month,
// UnitType = UnitType.特殊核算组.ToString(),
// Department = item.AccountingUnit,
// NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
// PreRealGiveFee = item.RealGiveFee,
// });
// }
// }
// }
/// <summary>
/// 创建科室二次分配
/// </summary>
/// <param name="allot"></param>
public void GenerateSecondAllot(per_allot allot)
{
List<ag_secondallot> tempSecond = new List<ag_secondallot>();
List<ag_secondallot> insSecond = new List<ag_secondallot>();
List<ag_secondallot> updSecond = new List<ag_secondallot>();
List<ag_secondallot> delSecond = new List<ag_secondallot>();
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政后勤 };
//// 获取医院是否开启后勤二次分配
//var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
//if (hospital?.IsOpenLogisticsSecondAllot != 1)
// types.Add((int)UnitType.行政后勤);
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// 查询需要进行二次分配的行政后勤科室
var xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政后勤 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
var specialList = perforResspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
if (accountUnit != null)
{
foreach (var item in accountUnit)
{
if (!tempSecond.Any(f => f.UnitType == ((UnitType)item.UnitType).ToString() && f.Department == item.AccountingUnit))
{
tempSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = ((UnitType)item.UnitType).ToString(),
Department = item.AccountingUnit,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
PreRealGiveFee = item.RealGiveFee,
});
}
}
}
if (specialList != null)
{
foreach (var item in specialList.Select(w => new { w.AccountingUnit, w.NightShiftWorkPerforFee, w.RealGiveFee }).Distinct())
{
if (!tempSecond.Any(f => f.UnitType == UnitType.特殊核算组.ToString() && f.Department == item.AccountingUnit))
{
tempSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = UnitType.特殊核算组.ToString(),
Department = item.AccountingUnit,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
PreRealGiveFee = item.RealGiveFee,
});
}
}
}
// var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
// foreach (var item in tempSecond)
// {
// var second = secondList?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
// if (second == null)
// {
// insSecond.Add(new ag_secondallot
// {
// AllotId = allot.ID,
// Year = allot.Year,
// Month = allot.Month,
// UnitType = item.UnitType,
// Department = item.Department,
// PreRealGiveFee = item.PreRealGiveFee,
// NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
// Status = 1,
// NursingDeptStatus = 1,
// });
// }
// else
// {
// /*
// var backResult = Math.Abs((second.PreRealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m
// || Math.Abs((second.NightShiftWorkPerforFee ?? 0) - (item.NightShiftWorkPerforFee ?? 0)) >= 0.5m;
// if (backResult && second.Status > 1)
// {
// second.Status = 4;
// second.Remark = "科室绩效结果发生变更,需要重新提交";
// second.NursingDeptStatus = 4;
// second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
// }
// */
// second.PreRealGiveFee = item.PreRealGiveFee;
// second.NightShiftWorkPerforFee = item.NightShiftWorkPerforFee;
// updSecond.Add(second);
// }
// }
foreach (var item in tempSecond)
{
var second = secondList?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
if (second == null)
{
insSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = item.UnitType,
Department = item.Department,
PreRealGiveFee = item.PreRealGiveFee,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
Status = 1,
NursingDeptStatus = 1,
});
}
else
{
/*
var backResult = Math.Abs((second.PreRealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m
|| Math.Abs((second.NightShiftWorkPerforFee ?? 0) - (item.NightShiftWorkPerforFee ?? 0)) >= 0.5m;
if (backResult && second.Status > 1)
{
second.Status = 4;
second.Remark = "科室绩效结果发生变更,需要重新提交";
second.NursingDeptStatus = 4;
second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
}
*/
second.PreRealGiveFee = item.PreRealGiveFee;
second.NightShiftWorkPerforFee = item.NightShiftWorkPerforFee;
updSecond.Add(second);
}
}
// if (secondList != null && secondList.Any())
// {
// foreach (var item in secondList)
// {
// var second = tempSecond?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
// if (second == null)
// {
// item.PreRealGiveFee = 0;
// delSecond.Add(item);
// }
// }
// }
if (secondList != null && secondList.Any())
{
foreach (var item in secondList)
{
var second = tempSecond?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
if (second == null)
{
item.PreRealGiveFee = 0;
delSecond.Add(item);
}
}
}
// if (insSecond.Any())
// perforAgsecondallotRepository.AddRange(insSecond.ToArray());
if (insSecond.Any())
perforAgsecondallotRepository.AddRange(insSecond.ToArray());
// if (updSecond.Any())
// {
// perforAgsecondallotRepository.UpdateRange(updSecond.ToArray());
// /*
// foreach (var item in updSecond.Where(w => w.Status == 4))
// {
// // 自动驳回,需要清空该科室历史数据
// perforAgsecondallotRepository.DeleteComputeHistory(item.Id);
// }
// */
// }
if (updSecond.Any())
{
perforAgsecondallotRepository.UpdateRange(updSecond.ToArray());
/*
foreach (var item in updSecond.Where(w => w.Status == 4))
{
// 自动驳回,需要清空该科室历史数据
perforAgsecondallotRepository.DeleteComputeHistory(item.Id);
}
*/
}
// if (delSecond.Any())
// perforAgsecondallotRepository.UpdateRange(delSecond.ToArray());
if (delSecond.Any())
perforAgsecondallotRepository.UpdateRange(delSecond.ToArray());
//}
}
/// <summary>
/// 获取所有二次分配记录
......
......@@ -450,8 +450,8 @@ public void Generate(per_allot allot)
//logManageService.WriteMsg("正在生成绩效", "保存预留绩效金额", 1, allot.ID, "ReceiveMessage", true);
//resultComputeService.SaveReserved(allot, allot.HospitalId);
//// 科室下发
//resultComputeService.GenerateSecondAllot(allot);
// 科室创建但不下发
resultComputeService.GenerateSecondAllot(allot);
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID);
......
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