Commit c8156bab by 李承祥

二次绩效选择模板时补充数据

parent ea9cb43a
...@@ -168,7 +168,6 @@ public bool UseTemp(UseTempRequest request) ...@@ -168,7 +168,6 @@ public bool UseTemp(UseTempRequest request)
{ {
entity.UseTempId = request.TempId; entity.UseTempId = request.TempId;
result = perforAgusetempRepository.Update(entity); result = perforAgusetempRepository.Update(entity);
//删除多余的数据
if (result) if (result)
{ {
//获取固定模板列头 //获取固定模板列头
...@@ -184,20 +183,55 @@ public bool UseTemp(UseTempRequest request) ...@@ -184,20 +183,55 @@ public bool UseTemp(UseTempRequest request)
headItems.AddRange(workDtos); headItems.AddRange(workDtos);
} }
List<ag_fixatitem> list = new List<ag_fixatitem>(); List<ag_fixatitem> list = new List<ag_fixatitem>();
var addList = new List<ag_fixatitem>();
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var secondList = Mapper.Map<List<SecondListResponse>>(perforAgsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value)));
secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
var secondId = secondList.Where(s => s.IsArchive == 0)?.Select(s => s.Id); //获取未归档的二次绩效
if (secondId == null || secondId.Count() <= 0)
return result;
//获取数据 //获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId); var fixatList = perforAgfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value));
foreach (var item in headItems) foreach (var item in headItems)
{ {
list.AddRange(fixatList.Where(t => t.ItemName == item.FiledName && t.Type == item.Type)); //符合条件的数据(未归档)
var exist = fixatList.Where(t => t.ItemName == item.FiledName && t.Type == item.Type);
if (exist != null && exist.Count() > 0)
list.AddRange(exist);
else
{
secondList.ForEach(t =>
{
if (t.IsArchive == 0)
{
addList.Add(new ag_fixatitem
{
ItemName = item.FiledName,
RowNumber = -1,
Type = item.Type,
SourceType = item.SourceType,
Sort = item.Sort,
FactorValue = item.FactorValue,
UnitType = t.UnitType,
AllotId = t.AllotId,
SecondId = t.Id
});
}
});
}
} }
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
{ {
var delList = fixatList.Except(list); var delList = fixatList.Except(list);
perforAgfixatitemRepository.RemoveRange(delList.ToArray()); perforAgfixatitemRepository.RemoveRange(delList.ToArray());
}
if (addList != null && addList.Count > 0)
perforAgfixatitemRepository.AddRange(addList.ToArray());
}
} }
} }
return result; return result;
......
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