程序虽然抛出异常但是还是执行了后续代码

parent 70bcfefc
...@@ -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