Commit b89c5212 by lcx

Merge branch '单元格修改' into 读取excel抽取

parents 52dcc918 92f7f024
...@@ -49,8 +49,8 @@ public ApiResponse List() ...@@ -49,8 +49,8 @@ public ApiResponse List()
[HttpPost] [HttpPost]
public ApiResponse SaveValue(int secondid, [FromBody] List<ag_fixatitem> request) public ApiResponse SaveValue(int secondid, [FromBody] List<ag_fixatitem> request)
{ {
if (secondid != 0 && (request == null || request.Count == 0)) //if (secondid != 0 && (request == null || request.Count == 0))
secondAllotService.DelValue(secondid, request); // secondAllotService.DelValue(secondid, request);
var allotCount = request.Where(t => t.AllotId > 0).Select(t => t.AllotId).Distinct().Count(); var allotCount = request.Where(t => t.AllotId > 0).Select(t => t.AllotId).Distinct().Count();
if (allotCount != 1 || request.Any(t => t.AllotId == 0)) if (allotCount != 1 || request.Any(t => t.AllotId == 0))
......
...@@ -308,7 +308,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request) ...@@ -308,7 +308,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
//检验 二次绩效配置 数据是否 有值,无则补充带出 //检验 二次绩效配置 数据是否 有值,无则补充带出
FillData(second, result.BodyItems); FillData(second, result.BodyItems);
SupplyHeaderByWorkItem(request, result, second); SupplyHeaderByWorkItem(request, result, second, fixatList?.Where(t => t.RowNumber == -1));
return new SecondResponse return new SecondResponse
{ {
...@@ -436,18 +436,13 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems) ...@@ -436,18 +436,13 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <param name="result"></param> /// <param name="result"></param>
private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse result, ag_secondallot second) private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse result, ag_secondallot second, IEnumerable<ag_fixatitem> fixatitems)
{ {
var workitem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department //var workitem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && !EnumHelper.GetItems<AgWorkloadType>().Select(type => type.Value).Contains(t.WorkTypeId)); //&& t.UnitType == request.UnitType && t.WorkTypeId != (int)AgWorkloadType.SingleAwards);
if (workitem == null || !workitem.Any(t => t.Id > 0)) //if (workitem == null || !workitem.Any(t => t.Id > 0))
return; // return;
var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType;
var deptHeader = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit);
if (deptHeader == null || !deptHeader.Any())
return;
//不包含工作量绩效 //不包含工作量绩效
if (!result.HeadItems.Select(t => t.FiledId).Contains("PerformanceShareTheWorkload")) if (!result.HeadItems.Select(t => t.FiledId).Contains("PerformanceShareTheWorkload"))
...@@ -476,22 +471,27 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -476,22 +471,27 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
var headerItems = new List<HeadItem>(); var headerItems = new List<HeadItem>();
int sortindex = 1; var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType;
foreach (var item in deptHeader) var deptHeader = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit);
if (deptHeader != null && deptHeader.Any())
{ {
if (item.HospitalId == 0) continue; int sortindex = 1;
foreach (var item in deptHeader)
for (int i = 0; i < headers.Length; i++)
{ {
var headItem = (HeadItem)headers[i].Clone(); if (item.HospitalId == 0) continue;
headItem.FiledName = (i % 2 == 0) ? item.TypeName : item.TypeName.Replace("占比", "金额");
if (i % 2 != 0 && !headItem.FiledName.EndsWith("金额")) for (int i = 0; i < headers.Length; i++)
headItem.FiledName += "金额"; {
headItem.FiledId += item.Id; var headItem = (HeadItem)headers[i].Clone();
headItem.Sort = maxSortValue + sortindex; headItem.FiledName = (i % 2 == 0) ? item.TypeName : item.TypeName.Replace("占比", "金额");
headItem.WorkType = item.Id; if (i % 2 != 0 && !headItem.FiledName.EndsWith("金额"))
headerItems.Add(headItem); headItem.FiledName += "金额";
sortindex++; headItem.FiledId += item.Id;
headItem.Sort = maxSortValue + sortindex;
headItem.WorkType = item.Id;
headerItems.Add(headItem);
sortindex++;
}
} }
} }
var defauleHeader = new List<ag_workload_type> var defauleHeader = new List<ag_workload_type>
...@@ -521,6 +521,8 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -521,6 +521,8 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
result.HeadItems.Add(item); result.HeadItems.Add(item);
var body = Mapper.Map<BodyItem>(item); var body = Mapper.Map<BodyItem>(item);
body.RowNumber = rownumber; body.RowNumber = rownumber;
if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName))
body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue;
result.BodyItems.Add(body); result.BodyItems.Add(body);
} }
} }
...@@ -538,51 +540,82 @@ public bool SaveValue(List<ag_fixatitem> request) ...@@ -538,51 +540,82 @@ public bool SaveValue(List<ag_fixatitem> request)
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) if (second == null)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId); var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request) var result = DelValue(fixatitems, request);
List<ag_fixatitem> update = new List<ag_fixatitem>(), insert = new List<ag_fixatitem>();
if (fixatitems != null && fixatitems.Any())
{ {
if (fixatitems != null && fixatitems.Any(t => t.SecondId == secondId && t.RowNumber == item.RowNumber && t.ItemName == item.ItemName)) foreach (var item in request)
{ {
var cellItem = fixatitems.First(t => t.SecondId == secondId && t.RowNumber == item.RowNumber && t.ItemName == item.ItemName); if (fixatitems.Any(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName))
cellItem.ItemValue = item.ItemValue; {
cellItem.Sort = item.Sort; var cellItem = fixatitems.FirstOrDefault(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName);
cellItem.SourceType = item.SourceType; if (cellItem == null)
cellItem.Type = item.Type; continue;
cellItem.UnitType = item.UnitType; cellItem.ItemValue = item.ItemValue;
cellItem.SpecialAttr = item.SpecialAttr; cellItem.Sort = item.Sort;
perforAgfixatitemRepository.Update(cellItem); cellItem.SourceType = item.SourceType;
} cellItem.Type = item.Type;
else cellItem.UnitType = item.UnitType;
{ cellItem.SpecialAttr = item.SpecialAttr;
perforAgfixatitemRepository.Add(item); update.Add(cellItem);
}
else
{
insert.Add(item);
}
} }
} }
return DelValue(second.Id, request); else
insert = request;
result = perforAgfixatitemRepository.UpdateRange(update.ToArray());
result = perforAgfixatitemRepository.AddRange(insert.ToArray());
return result;
} }
/// <summary> /// <summary>
/// 删除未保存的历史数据 /// 删除未保存的历史数据
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="fixatlist">数据库中查询到的值</param>
/// <param name="fixatitems"></param> /// <param name="fixatitems">需要保存的数据</param>
/// <returns></returns> /// <returns></returns>
public bool DelValue(int secondId, List<ag_fixatitem> fixatitems) public bool DelValue(List<ag_fixatitem> fixatlist, List<ag_fixatitem> fixatitems)
{ {
if (secondId == 0) var result = true;
throw new PerformanceException("二次绩效Id无效"); // 提交数据为空时,删除所有数据
var fixatlist = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
if (fixatitems == null || fixatitems.Count == 0) if (fixatitems == null || fixatitems.Count == 0)
{ {
return perforAgfixatitemRepository.RemoveRange(fixatlist.ToArray()); if (fixatlist != null && fixatlist.Any())
result = perforAgfixatitemRepository.RemoveRange(fixatlist.ToArray());
return result;
} }
var saveRows = fixatitems.Select(t => t.RowNumber).Distinct(); if (fixatlist != null && fixatlist.Any())
var delRows = fixatlist.Select(t => t.RowNumber).Distinct().Except(saveRows); {
if (delRows != null && delRows.Count() > 0) var groupData = fixatlist.GroupBy(t => new { t.RowNumber, t.ItemName }).Select(t => new
return perforAgfixatitemRepository.RemoveRange(fixatlist.Where(t => delRows.Contains(t.RowNumber)).ToArray()); {
t.Key.RowNumber,
t.Key.ItemName,
Count = t.Count(),
Id = t.Max(group => group.ID)
});
// 删除重复数据
if (groupData.Any(t => t.Count > 1))
{
var delData = fixatlist.Where(t => !groupData.Select(w => w.Id).Contains(t.ID));
int flag = fixatlist.RemoveAll(t => !groupData.Select(w => w.Id).Contains(t.ID));
result = perforAgfixatitemRepository.RemoveRange(delData.ToArray());
}
return true; // 删除行号不存在的数据
var saveRows = fixatitems.Select(t => t.RowNumber).Distinct();
var delRows = fixatlist.Select(t => t.RowNumber).Distinct().Except(saveRows);
if (delRows != null && delRows.Count() > 0)
result = perforAgfixatitemRepository.RemoveRange(fixatlist.Where(t => delRows.Contains(t.RowNumber)).ToArray());
}
return result;
} }
/// <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