Commit 911392b9 by ruyun.zhang@suvalue.com

Merge remote-tracking branch 'origin/feature/dongfang' into feature/dongfang

parents af06d961 9dbcb36e
...@@ -26,60 +26,60 @@ public ConfigController(ConfigService configService, AllotService allotService) ...@@ -26,60 +26,60 @@ public ConfigController(ConfigService configService, AllotService allotService)
_allotService = allotService; _allotService = allotService;
} }
#region director //#region director
/// <summary> ///// <summary>
/// 获取规模/效率绩效配置列表 ///// 获取规模/效率绩效配置列表
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("directorlist")] //[Route("directorlist")]
[HttpPost] //[HttpPost]
public ApiResponse<List<DirectorResponse>> GetDireList([CustomizeValidator(RuleSet = "Select"), FromBody]DirectorRequest request) //public ApiResponse<List<DirectorResponse>> GetDireList([CustomizeValidator(RuleSet = "Select"), FromBody]DirectorRequest request)
{ //{
var list = _configService.GetDireList(request.AllotID); // var list = _configService.GetDireList(request.AllotID);
return new ApiResponse<List<DirectorResponse>>(ResponseType.OK, "ok", list); // return new ApiResponse<List<DirectorResponse>>(ResponseType.OK, "ok", list);
} //}
/// <summary> ///// <summary>
/// 新增规模/效率绩效配置 ///// 新增规模/效率绩效配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("direinsert")] //[Route("direinsert")]
[HttpPost] //[HttpPost]
public ApiResponse<DirectorResponse> DireInsert([CustomizeValidator(RuleSet = "Insert"), FromBody]DirectorRequest request) //public ApiResponse<DirectorResponse> DireInsert([CustomizeValidator(RuleSet = "Insert"), FromBody]DirectorRequest request)
{ //{
var director = _configService.DireInsert(request); // var director = _configService.DireInsert(request);
return new ApiResponse<DirectorResponse>(ResponseType.OK, director); // return new ApiResponse<DirectorResponse>(ResponseType.OK, director);
} //}
/// <summary> ///// <summary>
/// 更新规模/效率绩效配置 ///// 更新规模/效率绩效配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("direupdate")] //[Route("direupdate")]
[HttpPost] //[HttpPost]
public ApiResponse<DirectorResponse> DireUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]DirectorRequest request) //public ApiResponse<DirectorResponse> DireUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]DirectorRequest request)
{ //{
var director = _configService.DireUpdate(request); // var director = _configService.DireUpdate(request);
return new ApiResponse<DirectorResponse>(ResponseType.OK, director); // return new ApiResponse<DirectorResponse>(ResponseType.OK, director);
} //}
/// <summary> ///// <summary>
/// 删除规模/效率绩效配置 ///// 删除规模/效率绩效配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("diredelete")] //[Route("diredelete")]
[HttpPost] //[HttpPost]
public ApiResponse DireDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]DirectorRequest request) //public ApiResponse DireDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]DirectorRequest request)
{ //{
if (!_configService.DireDelete(request)) // if (!_configService.DireDelete(request))
return new ApiResponse(ResponseType.Fail); // return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} //}
#endregion //#endregion
#region drugprop #region drugprop
/// <summary> /// <summary>
...@@ -191,115 +191,115 @@ public ApiResponse DrugtypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -191,115 +191,115 @@ public ApiResponse DrugtypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
} }
#endregion #endregion
#region income //#region income
/// <summary> ///// <summary>
/// 获取ICU有效收入配置列表 ///// 获取ICU有效收入配置列表
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("incomelist")] //[Route("incomelist")]
[HttpPost] //[HttpPost]
public ApiResponse<List<IncomeResponse>> GetIncomeList([CustomizeValidator(RuleSet = "Select"), FromBody]IncomeRequest request) //public ApiResponse<List<IncomeResponse>> GetIncomeList([CustomizeValidator(RuleSet = "Select"), FromBody]IncomeRequest request)
{ //{
var list = _configService.GetIncomeList(request.AllotID); // var list = _configService.GetIncomeList(request.AllotID);
return new ApiResponse<List<IncomeResponse>>(ResponseType.OK, "ok", list); // return new ApiResponse<List<IncomeResponse>>(ResponseType.OK, "ok", list);
} //}
/// <summary> ///// <summary>
/// 新增ICU有效收入配置 ///// 新增ICU有效收入配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("incomeinsert")] //[Route("incomeinsert")]
[HttpPost] //[HttpPost]
public ApiResponse<IncomeResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody]IncomeRequest request) //public ApiResponse<IncomeResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody]IncomeRequest request)
{ //{
var income = _configService.IncomeInsert(request); // var income = _configService.IncomeInsert(request);
return new ApiResponse<IncomeResponse>(ResponseType.OK, income); // return new ApiResponse<IncomeResponse>(ResponseType.OK, income);
} //}
/// <summary> ///// <summary>
/// 修改ICU有效收入配置 ///// 修改ICU有效收入配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("incomeupdate")] //[Route("incomeupdate")]
[HttpPost] //[HttpPost]
public ApiResponse<IncomeResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody]IncomeRequest request) //public ApiResponse<IncomeResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody]IncomeRequest request)
{ //{
var income = _configService.IncomeUpdate(request); // var income = _configService.IncomeUpdate(request);
return new ApiResponse<IncomeResponse>(ResponseType.OK, income); // return new ApiResponse<IncomeResponse>(ResponseType.OK, income);
} //}
/// <summary> ///// <summary>
/// 删除ICU有效收入配置 ///// 删除ICU有效收入配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("incomedelete")] //[Route("incomedelete")]
[HttpPost] //[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]IncomeRequest request) //public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]IncomeRequest request)
{ //{
if (!_configService.IncomeDelete(request)) // if (!_configService.IncomeDelete(request))
return new ApiResponse(ResponseType.Fail); // return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} //}
#endregion //#endregion
#region workyear //#region workyear
/// <summary> ///// <summary>
/// 获取年资系数配置列表 ///// 获取年资系数配置列表
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("workyearlist")] //[Route("workyearlist")]
[HttpPost] //[HttpPost]
public ApiResponse<List<WorkyearResponse>> GetWorkList([CustomizeValidator(RuleSet = "Select"), FromBody]WorkyearRequest request) //public ApiResponse<List<WorkyearResponse>> GetWorkList([CustomizeValidator(RuleSet = "Select"), FromBody]WorkyearRequest request)
{ //{
var list = _configService.GetWorkList(request.AllotID); // var list = _configService.GetWorkList(request.AllotID);
return new ApiResponse<List<WorkyearResponse>>(ResponseType.OK, "ok", list); // return new ApiResponse<List<WorkyearResponse>>(ResponseType.OK, "ok", list);
} //}
/// <summary> ///// <summary>
/// 新增年资系数配置 ///// 新增年资系数配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("workinsert")] //[Route("workinsert")]
[HttpPost] //[HttpPost]
public ApiResponse<WorkyearResponse> WorkyearInsert([CustomizeValidator(RuleSet = "Insert"), FromBody]WorkyearRequest request) //public ApiResponse<WorkyearResponse> WorkyearInsert([CustomizeValidator(RuleSet = "Insert"), FromBody]WorkyearRequest request)
{ //{
var workyear = _configService.WorkInsert(request); // var workyear = _configService.WorkInsert(request);
return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear); // return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear);
} //}
/// <summary> ///// <summary>
/// 修改年资系数配置 ///// 修改年资系数配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("workupdate")] //[Route("workupdate")]
[HttpPost] //[HttpPost]
public ApiResponse<WorkyearResponse> WorkyearUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]WorkyearRequest request) //public ApiResponse<WorkyearResponse> WorkyearUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]WorkyearRequest request)
{ //{
var workyear = _configService.WorkUpdate(request); // var workyear = _configService.WorkUpdate(request);
return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear); // return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear);
} //}
/// <summary> ///// <summary>
/// 删除年资系数配置 ///// 删除年资系数配置
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("workdelete")] //[Route("workdelete")]
[HttpPost] //[HttpPost]
public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]WorkyearRequest request) //public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]WorkyearRequest request)
{ //{
if (!_configService.WorkDelete(request)) // if (!_configService.WorkDelete(request))
return new ApiResponse(ResponseType.Fail); // return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} //}
#endregion //#endregion
#region cofagain #region cofagain
/// <summary> /// <summary>
......
...@@ -249,34 +249,6 @@ ...@@ -249,34 +249,6 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDireList(Performance.DtoModels.DirectorRequest)">
<summary>
获取规模/效率绩效配置列表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.DireInsert(Performance.DtoModels.DirectorRequest)">
<summary>
新增规模/效率绩效配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.DireUpdate(Performance.DtoModels.DirectorRequest)">
<summary>
更新规模/效率绩效配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.DireDelete(Performance.DtoModels.DirectorRequest)">
<summary>
删除规模/效率绩效配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugList(Performance.DtoModels.DrugpropRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.GetDrugList(Performance.DtoModels.DrugpropRequest)">
<summary> <summary>
获取 药占比配置信息列表 获取 药占比配置信息列表
...@@ -333,62 +305,6 @@ ...@@ -333,62 +305,6 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetIncomeList(Performance.DtoModels.IncomeRequest)">
<summary>
获取ICU有效收入配置列表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.Insert(Performance.DtoModels.IncomeRequest)">
<summary>
新增ICU有效收入配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.Update(Performance.DtoModels.IncomeRequest)">
<summary>
修改ICU有效收入配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.Delete(Performance.DtoModels.IncomeRequest)">
<summary>
删除ICU有效收入配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetWorkList(Performance.DtoModels.WorkyearRequest)">
<summary>
获取年资系数配置列表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.WorkyearInsert(Performance.DtoModels.WorkyearRequest)">
<summary>
新增年资系数配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.WorkyearUpdate(Performance.DtoModels.WorkyearRequest)">
<summary>
修改年资系数配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.WorkyearDelete(Performance.DtoModels.WorkyearRequest)">
<summary>
删除年资系数配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetAgainList(Performance.DtoModels.CofAgainRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.GetAgainList(Performance.DtoModels.CofAgainRequest)">
<summary> <summary>
获取二次绩效配置列表 获取二次绩效配置列表
......
...@@ -191,6 +191,7 @@ public AutoMapperConfigs() ...@@ -191,6 +191,7 @@ public AutoMapperConfigs()
CreateMap<ag_fixatitem, BodyItem>() CreateMap<ag_fixatitem, BodyItem>()
.ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName)) .ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName))
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue)); .ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue));
CreateMap<HeadItem, BodyItem>().ReverseMap();
CreateMap<ag_temp, SecondTempResponse>(); CreateMap<ag_temp, SecondTempResponse>();
CreateMap<ag_secondallot, SecondListResponse>().ReverseMap(); CreateMap<ag_secondallot, SecondListResponse>().ReverseMap();
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Performance.Infrastructure
{
public static class CommonHelper
{
public static IEnumerable<T> ToDistinct<T>(this IEnumerable<T> source)
{
return source.Distinct(new TCompare<T>());
}
public static IEnumerable<T> ToDistinct<T, C>(this IEnumerable<T> source, Func<T, C> field)
{
return source.Distinct(new TCompare<T, C>(field));
}
public class TCompare<T> : IEqualityComparer<T>
{
public bool Equals(T x, T y)
{
try
{
bool result = true;
PropertyInfo[] propertyInfos = typeof(T).GetProperties();
foreach (var propertyInfo in propertyInfos) //可设置i的起始值或判断i的值,来跳过不需要比较的字段
{
result = propertyInfo.GetValue(x, null)?.ToString()
== propertyInfo.GetValue(y, null)?.ToString();
if (!result) break;
}
return result;
}
catch
{
return false;
}
}
public int GetHashCode(T obj)
{
return 1;
}
}
public class TCompare<T, C> : IEqualityComparer<T>
{
private readonly Func<T, C> field;
public TCompare(Func<T, C> field)
{
this.field = field;
}
public bool Equals(T x, T y)
{
return EqualityComparer<C>.Default.Equals(field(x), field(y));
}
public int GetHashCode(T obj)
{
return EqualityComparer<C>.Default.GetHashCode(field(obj));
}
}
}
}
...@@ -34,5 +34,21 @@ public int ImportData(int allotId) ...@@ -34,5 +34,21 @@ public int ImportData(int allotId)
select distinct allotid,year,month,hospitalid,sourcetype,department,typename,cellvalue from view_report_original_income where allotid=@allotId;"; select distinct allotid,year,month,hospitalid,sourcetype,department,typename,cellvalue from view_report_original_income where allotid=@allotId;";
return Execute(sql, new { allotId }); return Execute(sql, new { allotId });
} }
/// <summary>
///
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public int SupplyData(int allotId)
{
string sql = @"
insert into cof_drugtype(charge,allotid) select distinct id.typename charge,
@allotId allotid from im_data id
inner join per_sheet ps on id.sheetid = ps.id
where id.allotid = @allotId and ps.sheettype = 3 and ifnull(id.typename, '') != ''
and id.typename not in (select charge from cof_drugtype where allotid = @allotId);";
return Execute(sql, new { allotId });
}
} }
} }
...@@ -228,6 +228,7 @@ internal int ImportData(int allotId) ...@@ -228,6 +228,7 @@ internal int ImportData(int allotId)
{ {
try try
{ {
var flag = perforPerallotRepository.SupplyData(allotId);
return perforPerallotRepository.ImportData(allotId); return perforPerallotRepository.ImportData(allotId);
} }
catch { } catch { }
......
...@@ -63,6 +63,7 @@ public class SecondAllotService : IAutoInjection ...@@ -63,6 +63,7 @@ public class SecondAllotService : IAutoInjection
this.perforCofagainRepository = perforCofagainRepository; this.perforCofagainRepository = perforCofagainRepository;
this.perforAgothersourceRepository = perforAgothersourceRepository; this.perforAgothersourceRepository = perforAgothersourceRepository;
} }
#region 二次绩效列表与数据保存 #region 二次绩效列表与数据保存
/// <summary> /// <summary>
/// 获取二次绩效列表 /// 获取二次绩效列表
...@@ -131,13 +132,122 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -131,13 +132,122 @@ public List<SecondListResponse> GetSecondList(int userId)
return list; return list;
} }
#region 二次绩效详情
///// <summary>
///// 二次绩效详情
///// </summary>
///// <returns></returns>
//public SecondResponse GetSecondDetail(UseTempRequest request)
//{
// var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
// if (usetemp == null)
// throw new PerformanceException("当前科室暂未配置绩效模板");
// var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
// //获取固定模板列 + 工作量列
// 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 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过
// {
// #region 已归档数据,根据数据获取 列
// if (fixatList == null || fixatList.Where(t => t.RowNumber != -1).Count() == 0)
// throw new PerformanceException("提交时未添加数据。");
// else
// {
// var existHead = fixatList.Select(t => new { FiledName = t.ItemName, Sort = t.Sort.Value, SourceType = t.SourceType.Value, Type = t.Type.Value, FactorValue = t.FactorValue.Value }).Distinct().ToList();
// headItems = existHead.Select(t => new HeadItem
// {
// FiledId = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.FiledId ?? "无FiledId",
// FiledName = t.FiledName,
// Sort = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.Sort ?? 0,
// SourceType = t.SourceType,
// Type = t.Type,
// FactorValue = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.FactorValue ?? 0
// }).ToList();
// result.HeadItems = headItems;
// }
// #endregion
// }
// //未归档
// 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)
// {
// var header = row == -1 ? headItems.Where(t => t.Type == 1).ToList() : headItems.Where(t => t.Type != 1).ToList();
// result.BodyItems.AddRange(GetBodyItems(header, 2, fixatitems: fixatList, row: row));
// }
// }
// else if (fixatList == null || (fixatList != null && fixatList.Where(t => t.RowNumber != -1).Count() == 0))
// {
// #region 补充历史绩效需要带出的数据
// var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
// if (bringhead != null && bringhead.Count > 0)
// {
// var allotIds = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID);
// var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value)
// && t.Department == request.Department && t.UnitType == request.UnitType)
// .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
// var index = secondIdList.IndexOf(request.SecondId);
// if (index != 0)
// fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue);
// 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 ? 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 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(),
// BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(),
// };
//}
///// <summary>
///// 二次绩效详情
///// </summary>
///// <returns></returns>
//public List<ag_othersource> GetSecondDetail(int secondid)
//{
// var others = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondid);
// return others;
//}
#endregion
#region 二次绩效详情-使用中
/// <summary> /// <summary>
/// 二次绩效详情 /// 二次绩效详情
/// </summary> /// </summary>
/// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public SecondResponse GetSecondDetail(UseTempRequest request) public SecondResponse GetSecondDetail(UseTempRequest request)
{ {
var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType); //获取科室二次绩效费用分配使用的模板
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
...@@ -145,93 +255,152 @@ public SecondResponse GetSecondDetail(UseTempRequest request) ...@@ -145,93 +255,152 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
var headItems = GetHeadItems(usetemp.UseTempId.Value, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType); var headItems = GetHeadItems(usetemp.UseTempId.Value, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() }; var result = new SecondResponse();
//获取已录入数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue); var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue);
if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过 //归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems
if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1))
{ {
#region 已归档数据,根据数据获取
if (fixatList == null || fixatList.Where(t => t.RowNumber != -1).Count() == 0) if (fixatList == null || fixatList.Where(t => t.RowNumber != -1).Count() == 0)
throw new PerformanceException("提交时未添加数据。"); throw new PerformanceException("提交时未添加数据。");
else
{ result = SubmittedData(fixatList, headItems);
var existHead = fixatList.Select(t => new { FiledName = t.ItemName, Sort = t.Sort.Value, SourceType = t.SourceType.Value, Type = t.Type.Value, FactorValue = t.FactorValue.Value }).Distinct().ToList();
headItems = existHead.Select(t => new HeadItem
{
FiledId = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.FiledId ?? "无FiledId",
FiledName = t.FiledName,
Sort = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.Sort ?? 0,
SourceType = t.SourceType,
Type = t.Type,
FactorValue = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.FactorValue ?? 0
}).ToList();
result.HeadItems = headItems;
}
#endregion
} }
//未归档 else
if (fixatList != null && fixatList.Where(t => t.RowNumber != -1).Count() > 0)
{ {
var rows = fixatList.Select(t => t.RowNumber.Value).Distinct(); result = new SecondResponse { HeadItems = headItems };
foreach (var row in rows) //判断是否有数据
//有数据 带出历史数据
if (fixatList != null && fixatList.Any())
{ {
var header = row == -1 ? headItems.Where(t => t.Type == 1).ToList() : headItems.Where(t => t.Type != 1).ToList(); result.BodyItems = GetBodyItems(fixatList, headItems);
result.BodyItems.AddRange(GetBodyItems(header, 2, fixatitems: fixatList, row: row)); if (fixatList.Where(t => t.RowNumber != -1) == null || !fixatList.Where(t => t.RowNumber != -1).Any())
result.BodyItems.AddRange(GetBringItems(request, headItems)); //更换模板时,会自动保存顶部数据
} }
} else
else if (fixatList == null || (fixatList != null && fixatList.Where(t => t.RowNumber != -1).Count() == 0))
{
#region 补充历史绩效需要带出的数据
var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
if (bringhead != null && bringhead.Count > 0)
{ {
var allotIds = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID); //无数据 根据IsBring带出历史二次绩效中需要带出的数据
var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value) result.BodyItems = GetBringItems(request, headItems);
&& t.Department == request.Department && t.UnitType == request.UnitType) result.BodyItems.AddRange(Mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1)));
.OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
var index = secondIdList.IndexOf(request.SecondId);
if (index != 0)
fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue);
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 ? 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 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 }); FillData(second, result.BodyItems);
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 return new SecondResponse
{ {
HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(), HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(),
BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(), BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(),
}; ;
}
/// <summary>
/// 根据已保存的数据返回
/// </summary>
/// <param name="fixatitems">已保存的数据</param>
/// <param name="headItems">列的名称、系数等值</param>
/// <returns></returns>
private SecondResponse SubmittedData(List<ag_fixatitem> fixatitems, List<HeadItem> headItems)
{
var header = fixatitems.Select(t => new { t.ItemName, t.Type, t.Sort }).ToDistinct().ToList();
var result = new SecondResponse
{
HeadItems = header.Select(t => new HeadItem
{
FiledId = headItems.FirstOrDefault(h => h.FiledName == t.ItemName && h.Type == t.Type)?.FiledId ?? t.ItemName + t.Type,
FiledName = t.ItemName,
Sort = t.Sort.Value,
Type = t.Type.Value,
FactorValue = headItems.FirstOrDefault(h => h.FiledName == t.ItemName && h.Type == t.Type)?.FactorValue ?? 0
}).ToList()
}; };
result.BodyItems = GetBodyItems(fixatitems, headItems);
return result;
} }
///// <summary> /// <summary>
///// 二次绩效详情 /// 获取历史数据
///// </summary> /// </summary>
///// <returns></returns> /// <param name="fixatitems"></param>
//public List<ag_othersource> GetSecondDetail(int secondid) /// <param name="headItems"></param>
//{ /// <returns></returns>
// var others = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondid); private List<BodyItem> GetBodyItems(List<ag_fixatitem> fixatitems, List<HeadItem> headItems)
// return others; {
//} var bodyItems = new List<BodyItem>();
if (fixatitems != null && fixatitems.Any())
{
bodyItems = fixatitems.Select(t => new BodyItem
{
RowNumber = t.RowNumber.Value,
FiledId = headItems.FirstOrDefault(h => h.FiledName == t.ItemName && h.Type == t.Type)?.FiledId ?? t.ItemName + t.Type,
FiledName = t.ItemName,
SourceType = t.SourceType.Value,
Type = t.Type.Value,
Value = t.ItemValue
}).ToList();
}
return bodyItems;
}
/// <summary>
/// 补充须带出的历史数据,如姓名、职称等
/// </summary>
/// <param name="request"></param>
/// <param name="headItems"></param>
/// <returns></returns>
private List<BodyItem> GetBringItems(UseTempRequest request, List<HeadItem> headItems)
{
var bodyItems = new List<BodyItem>();
var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
if (bringhead != null && bringhead.Count > 0)
{
var allotIds = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID);
var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value)
&& t.Department == request.Department && t.UnitType == request.UnitType)
.OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
var index = secondIdList.IndexOf(request.SecondId);
var fixatList = new List<ag_fixatitem>();
if (index != 0)
fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1)
&& t.RowNumber.HasValue && t.RowNumber != -1 && bringhead.Select(s => s.FiledName).Contains(t.ItemName));
if (fixatList != null && fixatList.Any())
bodyItems = GetBodyItems(fixatList, headItems);
}
return bodyItems;
}
/// <summary>
/// 补充二次绩效配置数据
/// </summary>
/// <param name="second"></param>
/// <param name="bodyItems"></param>
private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
{
if (bodyItems == null || !bodyItems.Any()) return;
var keyValue = new Dictionary<string, string>
{
{"发放月份", $"{second.Year}{second.Month.ToString().PadLeft(2, '0')}月"},
{"绩效合计(考核后)", second.RealGiveFee.ToString()},
};
var config = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId);
if (config != null && config.Any())
config.ForEach(t =>
{
keyValue.Add(t.TypeName, t.Value.ToString());
});
foreach (var item in keyValue)
{
var header = bodyItems.FirstOrDefault(t => t.FiledName == item.Key);
if (header != null && string.IsNullOrEmpty(header.Value))
bodyItems.FirstOrDefault(t => t.FiledName == item.Key).Value = item.Value;
}
}
#endregion
/// <summary> /// <summary>
/// 二次绩效项录入保存 /// 二次绩效项录入保存
/// </summary> /// </summary>
...@@ -404,7 +573,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -404,7 +573,7 @@ public bool UseTemp(UseTempRequest request)
AllotId = second.AllotId, AllotId = second.AllotId,
SecondId = second.Id, SecondId = second.Id,
ItemValue = head.FiledName == "绩效合计(考核后)" ? second.RealGiveFee?.ToString() ItemValue = head.FiledName == "绩效合计(考核后)" ? second.RealGiveFee?.ToString()
: head.FiledName == "发放月份" ? $"{second.Year}{second.Month}月" : head.FiledName == "发放月份" ? $"{second.Year}{second.Month.ToString().PadLeft(2, '0')}月"
: configs.FirstOrDefault(t => t.TypeName == head.FiledName)?.Value.ToString() : configs.FirstOrDefault(t => t.TypeName == head.FiledName)?.Value.ToString()
}); });
} }
......
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