Commit 3f959877 by ruyun.zhang

科室详情修改为统一格式

parent 77cc2895
......@@ -9,6 +9,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Claims;
namespace Performance.Api.Controllers
{
......@@ -173,7 +174,7 @@ public ApiResponse<List<DeptResponse>> GetAdminPerformance([FromBody] ComputerRe
/// <returns></returns>
[Route("unite/deptdetail")]
[HttpPost]
public ApiResponse UniteDeptDetail([FromBody] DeptDetailRequest request)
public ApiResponse UniteDeptDetail([FromBody] UniteDeptDetailRequest request)
{
/*
......@@ -220,10 +221,14 @@ public ApiResponse UniteDeptDetail([FromBody] DeptDetailRequest request)
]
*/
throw new NotImplementedException();
if (!Enum.TryParse(request.UnitType, ignoreCase: true, out UnitType unitType))
return new ApiResponse(ResponseType.ParameterError, "核算组别错误");
var userid = _claim.GetUserId();
var response = _computeService.UniteDeptDetail(request.AllotId, unitType, request.AccountingUnit, userid);
return new ApiResponse(ResponseType.OK, response);
}
#region 20230531 即将弃用,由新接口替代
/// <summary>
/// 科室绩效详情
/// </summary>
......@@ -269,7 +274,8 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
var response = _computeService.DeptDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response);
}
}
}
#endregion
/// <summary>
/// 获取全院绩效列表
......
......@@ -1045,7 +1045,7 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.UniteDeptDetail(Performance.DtoModels.DeptDetailRequest)">
<member name="M:Performance.Api.Controllers.ComputeController.UniteDeptDetail(Performance.DtoModels.UniteDeptDetailRequest)">
<summary>
科室绩效详情
</summary>
......
......@@ -157,7 +157,10 @@
<summary> 小数 </summary>
</member>
<member name="F:Performance.DtoModels.DataFormat.小数1">
<summary> 小数 </summary>
<summary> 小数1位 </summary>
</member>
<member name="F:Performance.DtoModels.DataFormat.小数2">
<summary> 小数2位 </summary>
</member>
<member name="F:Performance.DtoModels.DataFormat.整数">
<summary> 整数 </summary>
......@@ -2822,6 +2825,21 @@
提交类型 1 模板提交 2 其他提交
</summary>
</member>
<member name="T:Performance.DtoModels.UniteDeptDetailRequest">
<summary>
查看科室绩效详情
</summary>
</member>
<member name="P:Performance.DtoModels.UniteDeptDetailRequest.AllotId">
<summary>
绩效id
</summary>
</member>
<member name="P:Performance.DtoModels.UniteDeptDetailRequest.UnitType">
<summary>
核算单元类型
</summary>
</member>
<member name="P:Performance.DtoModels.UserListRequest.Role">
<summary>
角色
......@@ -5464,6 +5482,9 @@
</summary>
</member>
<member name="P:Performance.DtoModels.UniteDeptDetailResponse.ShowFormula">
<summary> 0 不显示 1 显示 </summary>
</member>
<member name="P:Performance.DtoModels.UserIdentity.IsAgainAdmin">
<summary>
是否是二次绩效管理 是为true 否则为false
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Performance.DtoModels
......@@ -67,8 +68,10 @@ public enum DataFormat
普通格式,
/// <summary> 小数 </summary>
小数,
/// <summary> 小数 </summary>
/// <summary> 小数1位 </summary>
小数1,
/// <summary> 小数2位 </summary>
小数2,
/// <summary> 整数 </summary>
整数,
/// <summary> 货币 </summary>
......@@ -187,4 +190,31 @@ public enum FromSource
录入 = 1,
}
}
public class UniteDept
{
public enum Type
{
左侧下拉 = 1,
右侧收缩 = 2,
}
public enum Title
{
[Description("整数")] 业绩分值 = 2100,
[Description("百分比")] 预算比例 = 2110,
[Description("整数")] 业绩绩效 = 2120,
[Description("整数")] 工作量绩效 = 2130,
[Description("整数")] 考核前其他绩效 = 2140,
[Description("整数")] 考核前绩效 = 2150,
[Description("百分比")] 考核得分率 = 2160,
[Description("整数")] 药占比奖罚 = 2170,
[Description("整数")] 材料占比奖罚 = 2180,
[Description("整数")] 医院奖罚 = 2190,
[Description("整数")] 考核后绩效 = 2200,
[Description("整数")] 考核后其他绩效 = 2210,
[Description("百分比")] 调节系数 = 2220,
[Description("整数")] 调节后其他绩效 = 2230,
[Description("整数")] 实发绩效 = 2240,
}
}
}
using FluentValidation;
namespace Performance.DtoModels
{
/// <summary>
/// 查看科室绩效详情
/// </summary>
public class UniteDeptDetailRequest
{
/// <summary>
/// 绩效id
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string UnitType { get; set; }
public string AccountingUnit { get; set; }
}
}
using System.Collections.Generic;
namespace Performance.DtoModels
{
public class UniteDeptDetailResponse
{
public string UnitType { get; set; }
public string AccountingUnit { get; set; }
/// <summary> 0 不显示 1 显示 </summary>
public int ShowFormula { get; set; }
public List<DeptDetailItem> DetailItems { get; set; }
}
public class DeptDetailItem
{
//public DeptDetailItem(int type, string title, decimal total, string remark, int sort)
// : this(type, title, total, remark, sort, new List<Dictionary<string, object>>())
//{
//}
//public DeptDetailItem(int type, string title, decimal total, string remark, int sort, List<Dictionary<string, object>> items)
//{
// Type = type;
// Title = title;
// Total = total;
// Remark = remark;
// Sort = sort;
// Items = items;
//}
public int Type { get; set; }
public string Title { get; set; }
public decimal Total { get; set; }
public string TotalFormat { get; set; }
public string Remark { get; set; }
public int Sort { get; set; }
public bool Display { get; set; } = true;
public List<Dictionary<string, object>> Items { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Masuit.Tools;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
namespace Performance.Services
{
public partial class ComputeService : IAutoInjection
{
/// <summary>
/// 查询科室详情,返回统一格式
/// </summary>
/// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, string accountingUnit, int userId)
{
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("绩效月信息错误");
var account = perforResaccountRepository.GetEntity(t => t.UnitType == (int)unitType && t.AccountingUnit == accountingUnit);
account ??= new res_account
{
UnitType = (int)unitType,
AccountingUnit = accountingUnit,
Number = 0,
BasicFactor = 0,
Extra = 0,
AssessBeforeOtherFee = 0,
MedicineExtra = 0,
MaterialsExtra = 0,
ScoringAverage = 0,
AssessLaterOtherFee = 0,
AdjustFactor = 0,
AdjustLaterOtherFee = 0,
RealGiveFee = 0,
};
var ignore = new string[] { "合计", "汇总", "总计" };
var persheet = _perforPerSheetRepository.GetEntities(t => t.AllotID == account.AllotID) ?? new List<per_sheet>();
var headers = _perforImheaderRepository.GetEntities(t => t.AllotID == account.AllotID) ?? new List<im_header>();
var basicData = _perforImDataRepository.GetEntities(t => t.AllotID == account.AllotID && t.AccountingUnit == account.AccountingUnit) ?? new List<im_data>();
var response = new UniteDeptDetailResponse { UnitType = unitType.ToString(), AccountingUnit = accountingUnit, DetailItems = new List<DeptDetailItem>() };
// 行政工勤
if (UnitTypeUtil.IsOffice(response.UnitType))
{
#region 补全行政工勤人员明细
{
var items = new List<Dictionary<string, object>>();
var computes = _perforRescomputeRepository.GetEntities(t => t.AllotID == account.AllotID && t.AccountType == AccountUnitType.行政工勤.ToString() && t.AccountingUnit == account.AccountingUnit) ?? new List<res_compute>();
foreach (var item in computes)
{
items.Add(new Dictionary<string, object>
{
{ "工号", item.JobNumber },
{ "姓名", item.EmployeeName },
{ "系数", ValueFormating(item.PostCoefficient,"") },
{ "出勤", ValueFormating(item.Attendance, DataFormat.百分比.ToString()) },
{ "其他绩效", ValueFormating(item.OtherPerfor,"") },
{ "绩效合计", ValueFormating(item.PerforTotal,DataFormat.小数2.ToString()) },
});
}
var detail = new DeptDetailItem { Title = "业绩绩效", Type = (int)UniteDept.Type.左侧下拉, Total = account.PerforTotal ?? 0, Items = items };
response.DetailItems.Add(detail);
}
#endregion
#region 补全6.11个人岗位系数
{
var items = new List<Dictionary<string, object>>();
var postSheet = persheet.FirstOrDefault(t => t.SheetType == (int)SheetType.PersonPostCoefficient);
if (postSheet != null)
{
var postDatas = basicData?.Where(w => w.SheetID == postSheet.ID && w.AccountingUnit == account?.AccountingUnit);
foreach (var post in postDatas?.GroupBy(w => new { w.JobNumber }))
{
var row = new Dictionary<string, object>
{
{ "工号", post.Key.JobNumber },
{ "姓名", post.FirstOrDefault()?.EmployeeName },
};
foreach (var item in post.Where(w => w.IsTotal != 1))
{
var val = item.IsFactor == 1 ? (item.CellValue * (item.FactorValue ?? 0)) : item.CellValue;
row.AddOrUpdate(item.TypeName, ValueFormating(val, ""), ValueFormating(val, ""));
}
var amount = post.FirstOrDefault(w => w.IsTotal == 1)?.CellValue ?? 0;
row.AddOrUpdate("合计", ValueFormating(amount, ""), ValueFormating(amount, ""));
}
var detail = new DeptDetailItem { Title = "岗位系数", Type = (int)UniteDept.Type.左侧下拉, Total = 0, Items = items };
response.DetailItems.Add(detail);
}
}
#endregion
#region 特殊处理
var total = response.DetailItems.FirstOrDefault(w => w.Title == UniteDept.Title.业绩绩效.ToString() && w.Type == (int)UniteDept.Type.左侧下拉)?.Total ?? 0;
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩分值.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = total });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.工作量绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.考核前绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = total });
#endregion
}
else if (UnitTypeUtil.Is(response.UnitType, UnitType.特殊核算组.ToString()))
{
var special = _perforResspecialunitRepository.GetEntities(t => t.AllotID == allotId && t.Department == accountingUnit);
if (special?.Any() != true) return response;
#region 补全特殊核算组量化指标明细
{
var items = new List<Dictionary<string, object>>();
foreach (var item in special)
{
items.Add(new Dictionary<string, object>
{
{ "量化指标", item.QuantitativeIndicators },
{ "数量", ValueFormating(item.Quantity, "") },
{ "量化指标绩效分值", ValueFormating(item.QuantitativeIndicatorsValue, "") },
{ "工作量绩效", ValueFormating(item.QuantitativeFee, DataFormat.小数2.ToString()) },
});
}
var detail = new DeptDetailItem { Title = "工作量绩效", Type = (int)UniteDept.Type.左侧下拉, Total = special.First().ResultsTotalFee ?? 0, Items = items };
response.DetailItems.Add(detail);
}
#endregion
#region 特殊处理
var total = response.DetailItems.FirstOrDefault(w => w.Title == UniteDept.Title.工作量绩效.ToString() && w.Type == (int)UniteDept.Type.左侧下拉)?.Total ?? 0;
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩分值.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.工作量绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.WorkloadFee ?? 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.考核前绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = special.First().PerforTotal ?? 0 });
#endregion
}
else
{
#region 补全临床科室收入明细
{
var leftSheetTypes = new List<int> { (int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, };
foreach (var sheetType in leftSheetTypes)
{
foreach (var sheet in persheet.Where(t => t.SheetType == sheetType).OrderBy(w => w.SheetName))
{
var type = TypeConversion(account.UnitType);
var sheetName = BeautifulName(sheet.SheetName);
var items = new List<Dictionary<string, object>>();
var postDatas = basicData.Where(t => t.SheetID == sheet.ID && t.IsTotal != 1 && t.UnitType == (int)type);
foreach (var post in postDatas.GroupBy(t => new { t.TypeName }))
{
if (ignore.Contains(post.Key.TypeName)) continue;
var lhfz = post.Sum(group => group.CellValue);
var hsfz = post.Sum(group => group.IsFactor == 1 ? (group.CellValue * (group.FactorValue ?? 0)) : group.CellValue);
var row = new Dictionary<string, object>
{
{ "量化指标", post.Key.TypeName },
{ "量化分值", ValueFormating(lhfz, "") },
{ "核算比例", ValueFormating(post.FirstOrDefault().FactorValue, DataFormat.百分比.ToString()) },
{ "核算分值", ValueFormating(hsfz, "") },
};
items.Add(row);
}
#region 添加合计
{
var lhfz = postDatas.Sum(w => w.CellValue);
var hsfz = postDatas.Sum(w => w.IsFactor == 1 ? (w.CellValue * (w.FactorValue ?? 0)) : w.CellValue);
items.Add(new Dictionary<string, object>
{
{ "量化指标", "原始分值合计"},
{ "量化分值", ValueFormating(lhfz, "") },
{ "核算比例", "核算分值合计"},
{ "核算分值", ValueFormating(hsfz, "") },
});
}
#endregion
var amount = basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal != 1)?.Sum(t => t.IsFactor == 1 ? t.CellValue * (t.FactorValue ?? 0) : t.CellValue) ?? 0;
var detail = new DeptDetailItem { Title = sheetName, Type = (int)UniteDept.Type.左侧下拉, Total = amount, Items = items };
response.DetailItems.Add(detail);
}
}
}
#endregion
#region 补全临床科室工作量明细
{
foreach (var sheet in persheet.Where(t => t.SheetType == (int)SheetType.Workload))
{
if ((sheet.SheetName.Contains("医生") && account.UnitType == (int)UnitType.护理组) || (sheet.SheetName.Contains("护理") && account.UnitType != (int)UnitType.护理组))
continue;
string sheetName = BeautifulName(sheet.SheetName);
var type = TypeConversion(account.UnitType);
var workitems = cofworkitemRepository.GetEntities(t => t.AllotID == account.AllotID);
var medicineFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadMedicineProp);
var cmiFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadCMI);
var inclineFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadIncline);
var items = new List<Dictionary<string, object>>();
var postDatas = basicData.Where(t => t.SheetID == sheet.ID && t.IsTotal != 1 && t.UnitType == (int)type);
foreach (var post in postDatas.GroupBy(t => new { t.TypeName }))
{
if (ignore.Contains(post.Key.TypeName)) continue;
var row = new Dictionary<string, object>();
row.Add("项目", post.Key.TypeName);
row.Add("数量", ValueFormating(post.Sum(group => group.CellValue), ""));
row.Add("系数", ValueFormating(post.FirstOrDefault().FactorValue, ""));
if (workitems != null && workitems.Any(a => a.Type == 1 && a.Item == post.Key.TypeName) && medicineFactor != null)
row.Add("药占比系数", ValueFormating(medicineFactor, ""));
if (workitems != null && workitems.Any(a => a.Type == 2 && a.Item == post.Key.TypeName) && cmiFactor != null)
row.Add("CMI系数", ValueFormating(cmiFactor, ""));
if (workitems != null && workitems.Any(a => a.Type == 3 && a.Item == post.Key.TypeName) && inclineFactor != null)
row.Add("工作量倾斜", ValueFormating(inclineFactor, ""));
var itemValue = post.Sum(group => group.IsFactor == 1 ? (group.CellValue * (group.FactorValue ?? 0)) : group.CellValue);
itemValue = itemValue * (medicineFactor ?? 1) * (cmiFactor ?? 1) * (inclineFactor ?? 1);
row.Add("金额", ValueFormating(itemValue, ""));
items.Add(row);
}
items.Add(new Dictionary<string, object>
{
{ "项目", "核算分值合计"},
{ "金额", postDatas.Sum(w => w.IsFactor == 1 ? (w.CellValue * (w.FactorValue ?? 0)) : w.CellValue) },
});
var amount = basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal != 1)?.Sum(t => t.IsFactor == 1 ? t.CellValue * (t.FactorValue ?? 0) : t.CellValue) ?? 0;
var detail = new DeptDetailItem { Title = sheetName, Type = (int)UniteDept.Type.左侧下拉, Total = amount, Items = items };
response.DetailItems.Add(detail);
}
}
#endregion
#region 特殊处理
string remark = "";
if (allot.ShowFormula == 1)
{
var sr = string.Join(" + ", persheet.Where(t => t.SheetType == (int)SheetType.Income).Select(w => BeautifulName(w.SheetName)));
var ewsr = string.Join(" + ", persheet.Where(t => t.SheetType == (int)SheetType.OtherIncome).Select(w => BeautifulName(w.SheetName)));
var zc = string.Join(" - ", persheet.Where(t => t.SheetType == (int)SheetType.Expend).Select(w => BeautifulName(w.SheetName)));
remark = $"{sr} + {ewsr} - {zc}";
}
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩分值.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.Income ?? 0, Remark = remark });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.业绩绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.PerforFee ?? 0, Remark = allot.ShowFormula == 1 ? "业绩分值 * 预算比例" : "" });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.工作量绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.WorkloadFee ?? 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.考核前绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.PerforTotal ?? 0, Remark = allot.ShowFormula == 1 ? "业绩绩效 + 工作量绩效 + 考核前其他绩效" : "" });
#endregion
}
// 只显示合计没有详情
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.考核后绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.AssessLaterPerforTotal ?? 0, Remark = allot.ShowFormula == 1 ? "考核前绩效 × 考核得分率 + 药占比奖罚 + 材料占比奖罚 + 医院奖罚 + 考核后其他绩效" : "" });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.考核后其他绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.AssessLaterOtherFee ?? 0 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.调节系数.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.AdjustFactor ?? 1 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.实发绩效.ToString(), Type = (int)UniteDept.Type.右侧收缩, Total = account.RealGiveFee ?? 0, Remark = allot.ShowFormula == 1 ? "考核后绩效 × 调节系数 + 调节后其他绩效" : "" });
// 显示详情
#region 补全公共附属表明细
{
var rightSheetTypeMaps = new[]
{
new { Name = nameof(PerDataAccountBaisc.BasicFactor) , Title = UniteDept.Title.预算比例.ToString(), SheetType = SheetType.BudgetRatio},
new { Name = nameof(PerDataAccountBaisc.Extra), Title = UniteDept.Title.医院奖罚.ToString(), SheetType = SheetType.AccountExtra },
new { Name = nameof(PerDataAccountBaisc.AssessBeforeOtherFee), Title = UniteDept.Title.考核前其他绩效.ToString(), SheetType = SheetType.AssessBeforeOtherFee },
new { Name = nameof(PerDataAccountBaisc.MedicineExtra), Title = UniteDept.Title.药占比奖罚.ToString(), SheetType = SheetType.AccountDrugAssess },
new { Name = nameof(PerDataAccountBaisc.MaterialsExtra), Title = UniteDept.Title.材料占比奖罚.ToString(), SheetType = SheetType.AccountMaterialsAssess },
new { Name = nameof(PerDataAccountBaisc.ScoringAverage), Title = UniteDept.Title.考核得分率.ToString(), SheetType = SheetType.AccountScoreAverage },
new { Name = nameof(PerDataAccountBaisc.AdjustLaterOtherFee), Title = UniteDept.Title.调节后其他绩效.ToString(), SheetType = SheetType.AccountAdjustLaterOtherFee },
};
foreach (var map in rightSheetTypeMaps)
{
foreach (var sheet in persheet.Where(t => t.SheetType == (int)map.SheetType))
{
var type = TypeConversion(account.UnitType);
var sheetName = new Regex("[0-9]*").Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
sheetName = sheetName != "科室考核" ? sheetName.Replace("科室绩效", "").Replace("科室", "") : sheetName;
var items = new List<Dictionary<string, object>>();
var postDatas = basicData.Where(t => t.SheetID == sheet.ID && t.IsTotal != 1 && t.UnitType == (int)type);
foreach (var post in postDatas.GroupBy(t => new { t.TypeName }))
{
if (ignore.Contains(post.Key.TypeName)) continue;
var fz = post.Sum(group => group.IsFactor == 1 ? (group.CellValue * (group.FactorValue ?? 0)) : group.CellValue);
var row = new Dictionary<string, object>
{
{ "指标", post.Key.TypeName },
{ "分值", ValueFormating(fz, "") }
};
items.Add(row);
}
var amount = basicData?.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0;
var detail = new DeptDetailItem { Title = map.Title, Type = (int)UniteDept.Type.右侧收缩, Total = amount, Items = items };
response.DetailItems.Add(detail);
}
}
}
#endregion
// Display = 0 全部可见 Display = 1 管理员可见,科室需要下发后才能看到
var detailConfig = new[]
{
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.业绩分值 },
new { Display = 1, Format = DataFormat.百分比, Title = UniteDept.Title.预算比例 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.业绩绩效 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.工作量绩效 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.考核前其他绩效 },
new { Display = 0, Format = DataFormat.整数, Title = UniteDept.Title.考核前绩效 },
new { Display = 1, Format = DataFormat.百分比, Title = UniteDept.Title.考核得分率 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.药占比奖罚 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.材料占比奖罚 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.医院奖罚 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.考核后绩效 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.考核后其他绩效 },
new { Display = 0, Format = DataFormat.百分比, Title = UniteDept.Title.调节系数 },
new { Display = 0, Format = DataFormat.整数, Title = UniteDept.Title.调节后其他绩效 },
new { Display = 1, Format = DataFormat.整数, Title = UniteDept.Title.实发绩效 },
};
//当角色对应时过滤
var userInfo = _userRepository.GetUser(userId);
foreach (var detail in response.DetailItems)
{
detail.Display = true;
var cfg = detailConfig.FirstOrDefault(w => w.Title.ToString() == detail.Title);
// 部分左右侧显示全部格式化
detail.TotalFormat = ValueFormating(detail.Total, cfg?.Format.ToString());
// 只对右侧设置排序
detail.Sort = detail.Type == (int)UniteDept.Type.左侧下拉 || cfg == null ? detail.Sort : (int)cfg.Title;
// 只对科室查看时右侧并且未下发隐藏内容
if (userInfo.IsSecondAdmin && detail.Type == (int)UniteDept.Type.右侧收缩 && cfg?.Display == 1 && allot.States != (int)AllotStates.绩效下发 && allot.States != (int)AllotStates.归档)
{
detail.Display = false;
}
}
response.DetailItems = response.DetailItems.OrderBy(w => w.Type).ThenBy(w => w.Sort).ToList();
return response;
}
private string ValueFormating(decimal? value, string format)
{
var total = value ?? 0;
if (total == 0)
{
return string.Format("{0:0.####}", total);
}
else if (Math.Abs(total) < 1.5m)
{
return string.Format("{0:0.####}", total);
}
else
{
if (format == DataFormat.整数.ToString())
{
return Math.Round(total, 0, MidpointRounding.AwayFromZero).ToString();
}
else if (format == DataFormat.小数2.ToString())
{
total = Math.Round(total, 2, MidpointRounding.AwayFromZero);
return string.Format("{0:0.####}", total);
}
else if (format == DataFormat.百分比.ToString())
{
return string.Format("{0:P}", total);
}
return string.Format("{0:0.####}", total);
}
}
private string BeautifulName(string sheetName)
{
sheetName = new Regex("[0-9]*").Replace(sheetName, "", 5).Replace(".", "").Replace(" ", "");
sheetName = sheetName != "科室考核" ? sheetName.Replace("科室绩效", "").Replace("科室", "") : sheetName;
return sheetName;
}
}
}
using AutoMapper;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using AutoMapper;
using Performance.DtoModels;
using Performance.DtoModels.Request;
using Performance.DtoModels.Response;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
namespace Performance.Services
{
public class ComputeService : IAutoInjection
public partial class ComputeService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly PerforUserRepository _userRepository;
private readonly PerforResaccountRepository perforResaccountRepository;
private readonly PerforPersheetRepository _perforPerSheetRepository;
private readonly PerforImdataRepository _perforImDataRepository;
......@@ -42,6 +41,7 @@ public class ComputeService : IAutoInjection
public ComputeService(
IMapper mapper,
PerforUserRepository userRepository,
PerforResaccountRepository perforResaccountRepository,
PerforPersheetRepository perforPerSheetRepository,
PerforImdataRepository perforImDataRepository,
......@@ -65,6 +65,7 @@ public class ComputeService : IAutoInjection
PerforReportRepository reportRepository)
{
_mapper = mapper;
_userRepository = userRepository;
this.perforResaccountRepository = perforResaccountRepository;
this._perforPerSheetRepository = perforPerSheetRepository;
this._perforImDataRepository = perforImDataRepository;
......@@ -1202,6 +1203,24 @@ public List<res_baiscnorm> GetBaiscnorm(int allotId)
return perforResbaiscnormRepository.GetEntities(t => t.AllotID == allotId)?.OrderBy(t => t.PositionName).ToList();
}
private decimal? GetFactors(List<per_sheet> persheet, List<im_data> basicData, UnitType type, SheetType sheetType)
{
var sheet = persheet.FirstOrDefault(w => w.SheetType == (int)sheetType);
return basicData.FirstOrDefault(t => t.SheetID == sheet?.ID && t.UnitType == (int)type && t.IsTotal == 1)?.CellValue;
}
private UnitType TypeConversion(int? unitType)
{
UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type))
type = UnitType.医生组;
else if (type == UnitType.其他护理组)
type = UnitType.护理组;
return type;
}
#region 20230531 即将弃用,由新接口替代
/// <summary>
/// 返回科室详情
/// </summary>
......@@ -1310,11 +1329,6 @@ public DeptDataDetails DeptDetail(int accountId)
return deptDetails;
}
private decimal? GetFactors(List<per_sheet> persheet, List<im_data> basicData, UnitType type, SheetType sheetType)
{
var sheet = persheet.FirstOrDefault(w => w.SheetType == (int)sheetType);
return basicData.FirstOrDefault(t => t.SheetID == sheet?.ID && t.UnitType == (int)type && t.IsTotal == 1)?.CellValue;
}
private (int sheettype, decimal amount) ClinicDepartmentDetail(List<per_sheet> persheet, res_account account, List<im_data> basicData, per_sheet sheet, UnitType type, string sheetName)
{
......@@ -1433,103 +1447,6 @@ private List<DetailModule> CommonDetailItems(List<im_data> basicData, List<im_he
return items;
}
private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details, string key)
{
if (details == null) return new DeptDataDetails<DetailModuleExtend>();
var result = new DeptDataDetails<DetailModuleExtend>()
{
ShowFormula = details.ShowFormula,
Pandect = details.Pandect,
Detail = new List<DetailDtos<DetailModuleExtend>>(),
};
if (details.Detail == null) return result;
foreach (var groupbasis in details.Detail.Select(t => t.GroupBasis).Distinct())
{
var items = new List<DetailModuleExtend>();
var data = details.Detail.Where(t => t.GroupBasis == groupbasis).ToList();
if (data.Count() > 1)
{
var depts = new List<string>();
data.ForEach(t =>
{
depts.AddRange(t.Items.Select(o => o.ItemName));
});
var billing = data.FirstOrDefault(t => t.ItemName.IndexOf(key) > -1);
var execute = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1);
foreach (var dept in depts.Distinct().OrderBy(t => t))
{
var item1 = billing?.Items.FirstOrDefault(t => t.ItemName == dept);
var item2 = execute?.Items.FirstOrDefault(t => t.ItemName == dept);
items.Add(new DetailModuleExtend
{
ItemName = dept,
ItemValue = item1?.ItemValue,
ItemValue2 = item2?.ItemValue,
CellValue = item1?.CellValue,
CellValue2 = item2?.CellValue,
Factor = item1?.Factor,
Factor2 = item2?.Factor,
});
}
}
else
{
if (data.FirstOrDefault().ItemName.IndexOf("执行") > -1)
{
items = data.First().Items.Select(t => new DetailModuleExtend
{
ItemName = t.ItemName,
ItemValue2 = t.ItemValue,
CellValue2 = t.CellValue,
Factor2 = t.Factor,
}).ToList();
}
else
{
items = data.First().Items.Select(t => new DetailModuleExtend
{
ItemName = t.ItemName,
ItemValue = t.ItemValue,
CellValue = t.CellValue,
Factor = t.Factor,
MediFactor = t.MediFactor,
CMIFactor = t.CMIFactor,
InclineFactor = t.InclineFactor,
}).ToList();
}
}
result.Detail.Add(new DetailDtos<DetailModuleExtend>
{
ItemName = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1) is null ? data.First().ItemName :
data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1).ItemName?.Replace("执行", $"{key}/执行"),
IncomeType = data.First()?.IncomeType ?? 0,
OriginalType = data.First()?.OriginalType ?? 0,
Amount = data.Sum(w => w.Amount),
GroupBasis = groupbasis,
Items = items
});
}
return result;
}
private UnitType TypeConversion(int? unitType)
{
UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type))
type = UnitType.医生组;
else if (type == UnitType.其他护理组)
type = UnitType.护理组;
return type;
}
public DeptDataDetails DeptOfficeDetail(int accountId)
{
var account = perforResaccountRepository.GetEntity(t => t.ID == accountId);
......@@ -1732,25 +1649,6 @@ public DeptDataDetails SpecialDeptDetail(ag_secondallot second)
return deptDetails;
}
//private List<DetailModule> GetExtraDetail(int allotId, int unitType, string accountingUnit)
//{
// var result = new List<DetailModule>();
// var sheetId = _perforPerSheetRepository.GetEntity(t => t.AllotID == allotId && t.SheetType == (int)SheetType.AccountExtra)?.ID;
// if (!sheetId.HasValue) return result;
// var data = _perforImDataRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId && t.UnitType == unitType
// && t.AccountingUnit == accountingUnit && t.IsTotal != 1);
// if (data == null || !data.Any()) return result;
// result = data.Select(t => new DetailModule
// {
// ItemName = t.TypeName,
// CellValue = t.CellValue,
// ItemValue = t.CellValue,
// }).ToList();
// return result;
//}
public ag_secondallot GetAccountId(int secondId, out int accountId)
{
......@@ -1778,7 +1676,8 @@ public ag_secondallot GetSecondByAccountId(int accountId)
Department = special.AccountingUnit,
UnitType = UnitType.特殊核算组.ToString()
};
}
}
#endregion
public DeptDataDetails GetDoctorDetail(int computeId)
{
......
using System;
using System.Collections.Generic;
using System.Text;
using Performance.DtoModels;
namespace Performance.Services
{
......
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