Commit b89c5212 by lcx

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

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