Commit 784a5044 by ruyun.zhang@suvalue.com

Merge branch 'hotfix/二次分配保存前重新计算' into release/v22.2.14-Beta-lintao

parents 527ea30b c5955c2a
...@@ -766,6 +766,13 @@ public ApiResponse RedistributionSave([FromBody] SecondComputeDto request) ...@@ -766,6 +766,13 @@ public ApiResponse RedistributionSave([FromBody] SecondComputeDto request)
if (cleanDatas == null || cleanDatas.Count == 0) if (cleanDatas == null || cleanDatas.Count == 0)
throw new PerformanceException("提交参数都是无效数据,请重新填写数据后保存!"); throw new PerformanceException("提交参数都是无效数据,请重新填写数据后保存!");
// 计算提交数据结果
_redistributionService.ResultCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas, loads, workloadGroups);
// 补充医院其他绩效
_redistributionService.SupplementOtherPerfor(second, cleanDatas);
// 重算部分数据
_redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas);
var result = secondAllotService.RedistributionSave(allot, second, request.Head, cleanDatas); var result = secondAllotService.RedistributionSave(allot, second, request.Head, cleanDatas);
return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail, "保存失败"); return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail, "保存失败");
} }
...@@ -823,9 +830,21 @@ public ApiResponse RedistributionSubmit([FromBody] SecondComputeDto request) ...@@ -823,9 +830,21 @@ public ApiResponse RedistributionSubmit([FromBody] SecondComputeDto request)
if (cleanDatas == null || cleanDatas.Count == 0) if (cleanDatas == null || cleanDatas.Count == 0)
throw new PerformanceException("提交参数都是无效数据,请重新填写数据后查看计算结果!"); throw new PerformanceException("提交参数都是无效数据,请重新填写数据后查看计算结果!");
// 计算提交数据结果
_redistributionService.ResultCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas, loads, workloadGroups);
// 补充医院其他绩效
_redistributionService.SupplementOtherPerfor(second, cleanDatas);
// 重算部分数据
_redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas);
var saveResult = secondAllotService.RedistributionSave(allot, second, request.Head, cleanDatas); var saveResult = secondAllotService.RedistributionSave(allot, second, request.Head, cleanDatas);
if (saveResult) if (saveResult)
{ {
var res = _redistributionService.ValidationData(second);
if (!string.IsNullOrEmpty(res))
return new ApiResponse(ResponseType.Fail, $"提交数据中存在无效数据,已经被删除,确认正确后请重新提交;删除工号清单如下:{res}");
var userid = claimService.GetUserId(); var userid = claimService.GetUserId();
var result = secondAllotService.AuditSubmit(second, userid); var result = secondAllotService.AuditSubmit(second, userid);
if (result) if (result)
......
...@@ -1542,5 +1542,20 @@ private IEnumerable<view_second_workload_result> GetSecondWorkloadByValue(int al ...@@ -1542,5 +1542,20 @@ private IEnumerable<view_second_workload_result> GetSecondWorkloadByValue(int al
{ {
return _perallotRepository.GetSecondWorkload(allotid, unittype, accountingunit); return _perallotRepository.GetSecondWorkload(allotid, unittype, accountingunit);
} }
// 验证数据正确性
public string ValidationData(ag_secondallot second)
{
var datas = _agbodysourceRepository.GetEntities(w => w.SecondId == second.Id);
var invalid = datas.Where(w => !w.DistPerformance.HasValue);
string removeEmp = "";
if (invalid != null && invalid.Count() > 0)
{
removeEmp = string.Join(",", invalid.Select(w => w.WorkNumber).ToArray());
_agbodysourceRepository.RemoveRange(invalid.ToArray());
}
return removeEmp;
}
} }
} }
...@@ -1620,6 +1620,15 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1620,6 +1620,15 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
var total = data.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0)); // 其他模板 = 可分配绩效 + 夜班绩效 var total = data.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0)); // 其他模板 = 可分配绩效 + 夜班绩效
if (!VerifySubmissioAmount(total, second.RealGiveFee)) if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}");
logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码");
second.UseTempId = temp.UseTempId;
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
else if (new int[] { 7, 8 }.Contains(temp.UseTempId.Value)) else if (new int[] { 7, 8 }.Contains(temp.UseTempId.Value))
{ {
...@@ -1631,28 +1640,43 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1631,28 +1640,43 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
.Sum(t => t.Sum(item => ConvertHelper.To<decimal>(item.ItemValue))); .Sum(t => t.Sum(item => ConvertHelper.To<decimal>(item.ItemValue)));
if (!VerifySubmissioAmount(total, second.RealGiveFee)) if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}");
logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码");
second.UseTempId = temp.UseTempId;
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
else /*if (new int[] { 9, 10 }.Contains(temp.UseTempId.Value))*/ else /*if (new int[] { 9, 10 }.Contains(temp.UseTempId.Value))*/
{ {
var data = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id); var data = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
else
var nightShiftWorkPerforFee = data.Sum(w => w.NightWorkPerformance ?? 0); {
if (!VerifySubmissioAmount(nightShiftWorkPerforFee, second.NightShiftWorkPerforFee)) var nightShiftWorkPerforFee = data?.Sum(w => w.NightWorkPerformance ?? 0);
throw new PerformanceException($"夜班绩效金额不一致!夜班绩效金额:{second.NightShiftWorkPerforFee ?? 0:0.####},提交金额:{nightShiftWorkPerforFee:0.####}"); var total = data?.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0));
if (!VerifySubmissioAmount(nightShiftWorkPerforFee, second.NightShiftWorkPerforFee))
var total = data.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0)); throw new PerformanceException($"夜班绩效金额不一致!夜班绩效金额:{second.NightShiftWorkPerforFee ?? 0:0.####},提交金额:{nightShiftWorkPerforFee:0.####}");
if (!VerifySubmissioAmount(total, second.RealGiveFee)) else if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee:0.####},提交金额:{total:0.####}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee:0.####},提交金额:{total:0.####}");
else
{
// 这段逻辑是为了监测 验证失败后继续修改状态而特意加入的
second.UseTempId = temp.UseTempId;
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
}
}
} }
second.UseTempId = temp.UseTempId; logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码");
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
/// <summary> /// <summary>
......
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