Commit a02ec5e0 by 李承祥

二次绩效带出上次绩效添加的绩效信息

parent 18c76996
......@@ -2121,6 +2121,9 @@
<member name="P:Performance.DtoModels.SecondListResponse.IsArchive">
<summary> 是否归档 </summary>
</member>
<member name="P:Performance.DtoModels.HeadItem.IsBring">
<summary> 1 带出历史数据 2不带出 </summary>
</member>
<member name="P:Performance.DtoModels.SecondTempResponse.TempName">
<summary>
模板名称
......
......@@ -459,7 +459,7 @@
二次绩效固定项
</summary>
</member>
<member name="P:Performance.EntityModels.ag_fixatitem.Id">
<member name="P:Performance.EntityModels.ag_fixatitem.ID">
<summary>
</summary>
......@@ -714,6 +714,11 @@
1 自动带出 2 计算得出
</summary>
</member>
<member name="P:Performance.EntityModels.ag_tempitem.IsBring">
<summary>
1 带出历史数据 2不带出
</summary>
</member>
<member name="T:Performance.EntityModels.ag_usetemp">
<summary>
......
......@@ -27,6 +27,9 @@ public UseTempRequestValidator()
RuleSet("Use", () =>
{
RuleFor(x => x.TempId).NotNull().GreaterThan(0);
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
RuleFor(x => x.Department).NotNull().NotEmpty();
RuleFor(x => x.UnitType).NotNull().NotEmpty();
});
RuleSet("Refresh", () =>
......
......@@ -153,12 +153,9 @@ public List<SecondTempResponse> GetTemp(int hospitalid)
/// <returns></returns>
public bool UseTemp(UseTempRequest request)
{
var temp = perforAgtempRepository.GetEntity(t => t.Id == request.TempId);
if (temp == null)
throw new PerformanceException("参数tempId 无效");
var result = false;
var entity = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
var entity = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType);
if (entity == null)
{
entity = Mapper.Map<ag_usetemp>(request);
......@@ -184,35 +181,36 @@ public bool UseTemp(UseTempRequest request)
if (secondId == null || secondId.Count() <= 0)
return result;
//获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value));
foreach (var item in headItems)
foreach (var second in secondList)
{
//符合条件的数据(未归档)
var exist = fixatList.Where(t => t.ItemName == item.FiledName && t.Type == item.Type);
if (exist != null && exist.Count() > 0)
list.AddRange(exist);
else
foreach (var head in headItems)
{
secondList.ForEach(t =>
if (second.IsArchive == 0)
{
if (t.IsArchive == 0)
var exist = fixatList?.Where(t => t.ItemName == head.FiledName && t.Type == head.Type && t.SecondId == second.Id);
if (exist != null && exist.Count() > 0)
list.AddRange(exist);
else
{
var configs = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>();
addList.Add(new ag_fixatitem
{
ItemName = item.FiledName,
ItemName = head.FiledName,
RowNumber = -1,
Type = item.Type,
SourceType = item.SourceType,
Sort = item.Sort,
FactorValue = item.FactorValue,
UnitType = t.UnitType,
AllotId = t.AllotId,
SecondId = t.Id
Type = head.Type,
SourceType = head.SourceType,
Sort = head.Sort,
FactorValue = head.FactorValue,
UnitType = second.UnitType,
AllotId = second.AllotId,
SecondId = second.Id,
ItemValue = head.FiledName == "绩效合计(考核后)" ? second.RealGiveFee?.ToString()
: head.FiledName == "发放月份" ? $"{second.Year}{second.Month}月"
: configs.FirstOrDefault(t => t.TypeName == head.FiledName)?.Value.ToString()
});
}
});
}
}
}
if (list != null && list.Count > 0)
......@@ -430,11 +428,12 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
var headItems = GetHeadItems(usetemp.UseTempId.Value, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() };
//获取数据
//获取已录入数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue);
if (request.IsArchive == 1)
if (request.IsArchive == 1) //归档
{
if (fixatList == null || fixatList.Count == 0)
#region 已归档数据,根据数据获取
if (fixatList == null || fixatList.Where(t => t.RowNumber != -1).Count() == 0)
throw new PerformanceException("绩效归档时,尚未添加数据。");
else
{
......@@ -450,11 +449,11 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
}).Where(t => t.FiledId != "无FiledId").ToList();
result.HeadItems = headItems;
}
#endregion
}
if (fixatList != null && fixatList.Count > 0)
//未归档
if (fixatList != null && fixatList.Where(t => t.RowNumber != -1).Count() > 0)
{
//补充数据
var rows = fixatList.Select(t => t.RowNumber.Value).Distinct();
foreach (var row in rows)
{
......@@ -462,20 +461,11 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
result.BodyItems.AddRange(GetBodyItems(header, 2, fixatitems: fixatList, row: row));
}
}
else
else if (fixatList == null || (fixatList != null && fixatList.Where(t => t.RowNumber != -1).Count() == 0))
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
var config = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>();
#region 补充顶部数据
config.Add(new cof_again { TypeName = "绩效合计(考核后)", Value = second.RealGiveFee });
result.BodyItems.AddRange(GetBodyItems(headItems.Where(t => t.Type == 1).ToList(), 1, configs: config));
result.BodyItems.FirstOrDefault(t => t.FiledName == "发放月份").Value = $"{second.Year}{second.Month}月";
#endregion
#region 补充需要带出的数据
headItems = headItems.Where(t => t.IsBring == 1).ToList();
if (headItems != null && headItems.Count > 0)
#region 补充历史绩效需要带出的数据
var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
if (bringhead != null && bringhead.Count > 0)
{
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value)).OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
......@@ -483,19 +473,30 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
if (index != 0)
fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue);
fixatList = fixatList.Where(t => headItems.Select(h => h.FiledName).Contains(t.ItemName)).ToList();
fixatList = fixatList?.Where(t => bringhead.Select(h => h.FiledName).Contains(t.ItemName)).ToList();
if (fixatList != null && fixatList.Count > 0)
{
var rows = fixatList.Select(t => t.RowNumber.Value).Distinct();
foreach (var row in rows)
{
var header = row == -1 ? headItems.Where(t => t.Type == 1).ToList() : headItems.Where(t => t.Type != 1).ToList();
var header = row == -1 ? bringhead.Where(t => t.Type == 1).ToList() : bringhead.Where(t => t.Type != 1).ToList();
result.BodyItems.AddRange(GetBodyItems(header, 2, fixatitems: fixatList, row: row));
}
}
}
#endregion
}
if (fixatList == null || (fixatList != null && fixatList.Where(t => t.RowNumber == -1).Count() == 0))
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
var config = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>();
#region 补充顶部数据
config.Add(new cof_again { TypeName = "绩效合计(考核后)", Value = second.RealGiveFee });
result.BodyItems.AddRange(GetBodyItems(headItems.Where(t => t.Type == 1).ToList(), 1, configs: config));
result.BodyItems.FirstOrDefault(t => t.FiledName == "发放月份").Value = $"{second.Year}{second.Month}月";
#endregion
}
return new SecondResponse
{
HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(),
......
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