Commit 6d0fa74c by ruyun.zhang@suvalue.com

Merge branch 'v20201230yubei' into v2020morge-graphql

parents f4c739f7 8aa99249
...@@ -98,8 +98,11 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId, ...@@ -98,8 +98,11 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId,
if (isArchive == 1 || new List<int> { (int)SecondAllotStatus.WaitReview, (int)SecondAllotStatus.PassAudit }.Contains(secondAllot.Status ?? (int)SecondAllotStatus.Uncommitted)) if (isArchive == 1 || new List<int> { (int)SecondAllotStatus.WaitReview, (int)SecondAllotStatus.PassAudit }.Contains(secondAllot.Status ?? (int)SecondAllotStatus.Uncommitted))
employeeSource = (int)EmployeeSource.Initial; employeeSource = (int)EmployeeSource.Initial;
// 历史保存过的数据 // 历史保存过的数据,groupby取最后的一条记录,避免重复数据,在同一rownumber中itemname重复会导致数据丢失
var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == secondAllot.Id); var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == secondAllot.Id);
if (savedDataList != null && savedDataList.Any())
savedDataList = savedDataList.GroupBy(t => new { t.RowNumber, t.ItemName, t.Sort })
.Select(t => t.OrderByDescending(o => o.ID).FirstOrDefault()).ToList();
if (secondAllot.UseTempId != null) tempId = (int)secondAllot.UseTempId; if (secondAllot.UseTempId != null) tempId = (int)secondAllot.UseTempId;
...@@ -221,7 +224,7 @@ public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallo ...@@ -221,7 +224,7 @@ public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallo
case (int)EmployeeSource.EmployeeDict: case (int)EmployeeSource.EmployeeDict:
return GetEmployeeFromEmployeeDict(userId, secondAllot, otherShowColumns); return GetEmployeeFromEmployeeDict(userId, secondAllot, otherShowColumns);
case (int)EmployeeSource.PrevSecondAllot: case int source when source == (int)EmployeeSource.PrevSecondAllot && prevSecondAllot != null:
return GetEmployeeFromPrevData(userId, secondAllot, prevSecondAllot, otherShowColumns); return GetEmployeeFromPrevData(userId, secondAllot, prevSecondAllot, otherShowColumns);
default: default:
...@@ -336,6 +339,10 @@ public List<BodyItem> GetEmployeeFromPrevData(int userId, ag_secondallot secondA ...@@ -336,6 +339,10 @@ public List<BodyItem> GetEmployeeFromPrevData(int userId, ag_secondallot secondA
var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == prevSecondAllot.Id && w.RowNumber.HasValue && w.RowNumber > -1); var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == prevSecondAllot.Id && w.RowNumber.HasValue && w.RowNumber > -1);
if (savedDataList == null || !savedDataList.Any()) return tableFixedDataList; if (savedDataList == null || !savedDataList.Any()) return tableFixedDataList;
// groupby取最后的一条记录,避免重复数据
savedDataList = savedDataList.GroupBy(t => new { t.RowNumber, t.ItemName, t.Sort })
.Select(t => t.OrderByDescending(o => o.ID).FirstOrDefault()).ToList();
var employeeList = personService.GetPersons(secondAllot.AllotId.Value, userId); var employeeList = personService.GetPersons(secondAllot.AllotId.Value, userId);
var employeeColumns = new List<Tuple<string, string>> var employeeColumns = new List<Tuple<string, string>>
{ {
......
...@@ -689,33 +689,45 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId) ...@@ -689,33 +689,45 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId); var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
var result = DelValue(secondId, fixatitems, request);
List<ag_fixatitem> update = new List<ag_fixatitem>(), insert = new List<ag_fixatitem>(); #region old
//var result = DelValue(secondId, fixatitems, request);
//List<ag_fixatitem> update = new List<ag_fixatitem>(), insert = new List<ag_fixatitem>();
//if (fixatitems != null && fixatitems.Any())
//{
// foreach (var item in request.Where(w => !string.IsNullOrEmpty(w.ItemName)))
// {
// var cellItem = fixatitems.FirstOrDefault(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName);
// if (cellItem != null)
// {
// cellItem.ItemValue = item.ItemValue;
// cellItem.Sort = item.Sort;
// cellItem.SourceType = item.SourceType;
// cellItem.Type = item.Type;
// cellItem.UnitType = item.UnitType;
// cellItem.SpecialAttr = item.SpecialAttr;
// update.Add(cellItem);
// }
// else
// {
// insert.Add(item);
// }
// }
//}
//else
// insert = request;
//result = perforAgfixatitemRepository.UpdateRange(update.ToArray());
//result = perforAgfixatitemRepository.AddRange(insert.ToArray());
#endregion
bool result = false;
if (fixatitems != null && fixatitems.Any()) if (fixatitems != null && fixatitems.Any())
{ result = perforAgfixatitemRepository.RemoveRange(fixatitems.ToArray());
foreach (var item in request.Where(w => !string.IsNullOrEmpty(w.ItemName)))
{ result = perforAgfixatitemRepository.AddRange(request.ToArray());
var cellItem = fixatitems.FirstOrDefault(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName);
if (cellItem != null)
{
cellItem.ItemValue = item.ItemValue;
cellItem.Sort = item.Sort;
cellItem.SourceType = item.SourceType;
cellItem.Type = item.Type;
cellItem.UnitType = item.UnitType;
cellItem.SpecialAttr = item.SpecialAttr;
update.Add(cellItem);
}
else
{
insert.Add(item);
}
}
}
else
insert = request;
result = perforAgfixatitemRepository.UpdateRange(update.ToArray());
result = perforAgfixatitemRepository.AddRange(insert.ToArray());
return result; return result;
} }
...@@ -1272,17 +1284,36 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1272,17 +1284,36 @@ public bool AuditSubmit(ag_secondallot second, int userId)
var temp = perforAgusetempRepository.GetEntity(exp); var temp = perforAgusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!"); throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!");
bool method(decimal? submitDataAmount, decimal? realGiveFee)
{
if (!submitDataAmount.HasValue || !realGiveFee.HasValue)
return false;
decimal floatValue = 0.5m;
return submitDataAmount >= (realGiveFee - floatValue) && submitDataAmount <= (realGiveFee + floatValue);
}
if (temp.UseTempId == 6) if (temp.UseTempId == 6)
{ {
var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == second.Id); var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
var total = data.Sum(t => t.RealAmount);
if (!method(total, second.RealGiveFee))
throw new PerformanceException("总金额与考核后金额不一致!");
} }
else else
{ {
var data = perforAgfixatitemRepository.GetEntities(t => t.SecondId == second.Id); var data = perforAgfixatitemRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
var total = data.Where(t => t.ItemName == "实发绩效工资金额" && t.RowNumber > -1).GroupBy(t => t.RowNumber)
.Sum(t => ConvertHelper.To<decimal>(t.OrderByDescending(o => o.ID).FirstOrDefault().ItemValue));
if (!method(total, second.RealGiveFee))
throw new PerformanceException("总金额与考核后金额不一致!");
} }
second.UseTempId = temp.UseTempId; second.UseTempId = temp.UseTempId;
second.Status = 2; second.Status = 2;
......
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