Commit 79216817 by lcx

Merge branch 'develop' into feature/绩效汇报表

# Conflicts:
#	performance/Performance.Api/Controllers/ReportController.cs
#	performance/Performance.Api/wwwroot/Performance.Api.xml
#	performance/Performance.Services/ReportService.cs
parents f8184c42 56a8db93
...@@ -219,6 +219,21 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R ...@@ -219,6 +219,21 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
/// 菜单报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("operation")]
[HttpPost]
public ApiResponse Operation([FromBody] ReportRequest request)
{
if (request == null)
return new ApiResponse(ResponseType.Fail, "参数错误!");
var list = reportService.Operation(request);
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary> /// <summary>
/// 绩效汇报表 /// 绩效汇报表
/// </summary> /// </summary>
......
...@@ -575,6 +575,8 @@ public ApiResponse RedistributionLoad([FromBody] SecondLoadDto request) ...@@ -575,6 +575,8 @@ public ApiResponse RedistributionLoad([FromBody] SecondLoadDto request)
overrideMode = (EmployeeSource)request.OverrideMode; overrideMode = (EmployeeSource)request.OverrideMode;
var result = _redistributionService.Load(request.SecondId, (ComputeMode)request.ComputeMode, overrideMode); var result = _redistributionService.Load(request.SecondId, (ComputeMode)request.ComputeMode, overrideMode);
_redistributionService.ClearInvalidValue(result.Body?.Data);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
catch (PerformanceException ex) catch (PerformanceException ex)
...@@ -702,6 +704,7 @@ public ApiResponse RedistributionCompute([FromBody] SecondComputeDto request) ...@@ -702,6 +704,7 @@ public ApiResponse RedistributionCompute([FromBody] SecondComputeDto request)
// 重算部分数据 // 重算部分数据
_redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas); _redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas);
_redistributionService.ClearInvalidValue(cleanDatas);
var dic = _redistributionService.GetTableHeaderDictionary((ComputeMode)request.ComputeMode, allot, second, loads, workloadGroups); var dic = _redistributionService.GetTableHeaderDictionary((ComputeMode)request.ComputeMode, allot, second, loads, workloadGroups);
return new ApiResponse(ResponseType.OK, new { Head = request.Head, Body = cleanDatas, Dic = dic }); return new ApiResponse(ResponseType.OK, new { Head = request.Head, Body = cleanDatas, Dic = dic });
} }
......
...@@ -1455,6 +1455,7 @@ ...@@ -1455,6 +1455,7 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<!-- Badly formed XML comment ignored for member "M:Performance.Api.Controllers.ReportController.Operation(Performance.DtoModels.ReportRequest)" -->
<member name="M:Performance.Api.Controllers.ReportController.TableNormal(Performance.DtoModels.ConditionRequest)"> <member name="M:Performance.Api.Controllers.ReportController.TableNormal(Performance.DtoModels.ConditionRequest)">
<summary> <summary>
绩效汇报表 绩效汇报表
......
...@@ -2394,6 +2394,9 @@ ...@@ -2394,6 +2394,9 @@
<member name="P:Performance.DtoModels.ReportRequest.Month"> <member name="P:Performance.DtoModels.ReportRequest.Month">
<summary></summary> <summary></summary>
</member> </member>
<member name="P:Performance.DtoModels.ReportRequest.AccountingUnit">
<summary> 科室 </summary>
</member>
<member name="P:Performance.DtoModels.SecondAuditRequest.SecondId"> <member name="P:Performance.DtoModels.SecondAuditRequest.SecondId">
<summary> 二次绩效Id </summary> <summary> 二次绩效Id </summary>
</member> </member>
......
...@@ -7312,6 +7312,101 @@ ...@@ -7312,6 +7312,101 @@
医技组系数 医技组系数
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.view_operation_report_result">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.HospitalId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.AccountingUnit">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.SourceType">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.Category">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.ItemName">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.January">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.February">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.March">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.April">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.May">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.June">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.July">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.August">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.September">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.October">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.November">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.view_operation_report_result.December">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.HisData.HisDepartment"> <member name="P:Performance.EntityModels.HisData.HisDepartment">
<summary> <summary>
His科室 His科室
......
...@@ -23,6 +23,9 @@ public class ReportRequest ...@@ -23,6 +23,9 @@ public class ReportRequest
/// <summary> 月 </summary> /// <summary> 月 </summary>
public string Month { get; set; } public string Month { get; set; }
/// <summary> 科室 </summary>
public string[] AccountingUnit { get; set; }
} }
public class ReportRequestValidator : AbstractValidator<ReportRequest> public class ReportRequestValidator : AbstractValidator<ReportRequest>
{ {
......
//-----------------------------------------------------------------------
// <copyright file=" view_operation_report_result.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("view_operation_report_result")]
public class view_operation_report_result
{
/// <summary>
///
/// </summary>
public int HospitalId { get; set; }
/// <summary>
///
/// </summary>
public int Year { get; set; }
/// <summary>
///
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
///
/// </summary>
public string Category { get; set; }
/// <summary>
///
/// </summary>
public string ItemName { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> January { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> February { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> March { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> April { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> May { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> June { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> July { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> August { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> September { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> October { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> November { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> December { get; set; }
}
}
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
......
...@@ -379,7 +379,7 @@ private decimal GetMedicineProportion(int hospitalid, int year, int month) ...@@ -379,7 +379,7 @@ private decimal GetMedicineProportion(int hospitalid, int year, int month)
string sql = @"select ifnull(sum(cellvalue),0) as fee string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1 from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '药费' join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '药费'
where hospitalid=@hospitalid and year=@year and month=@month"; where t1.hospitalid=@hospitalid and t1.year=@year and t1.month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month }); return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
} }
///材料支出 ///材料支出
...@@ -388,7 +388,7 @@ private decimal GetMaterialCosts(int hospitalid, int year, int month) ...@@ -388,7 +388,7 @@ private decimal GetMaterialCosts(int hospitalid, int year, int month)
string sql = @"select ifnull(sum(cellvalue),0) as fee string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1 from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '材料费' join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '材料费'
where hospitalid=@hospitalid and year=@year and month=@month"; where t1.hospitalid=@hospitalid and t1.year=@year and t1.month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month }); return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
} }
} }
......
...@@ -502,7 +502,7 @@ public bool DeleteApr(int id) ...@@ -502,7 +502,7 @@ public bool DeleteApr(int id)
/// <returns></returns> /// <returns></returns>
public bool ConfirmAudit(int userid, AprAmountAuditRequest request) public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
{ {
if (request?.Members == null) if (request?.Members == null || !request.Members.Any())
throw new PerformanceException("审核信息无效,请确认"); throw new PerformanceException("审核信息无效,请确认");
foreach (var item in request.Members) foreach (var item in request.Members)
...@@ -515,8 +515,8 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -515,8 +515,8 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
foreach (var member in request.Members) foreach (var member in request.Members)
{ {
var apramounts = allApramounts?.Where(t => (t.DoctorName ?? "") == member.DoctorName && (t.PersonnelNumber ?? "") == member.PersonnelNumber); var apramounts = allApramounts?.Where(t => (t.DoctorName ?? "") == member.DoctorName && (t.PersonnelNumber ?? "") == member.PersonnelNumber);
if (apramounts == null) if (apramounts == null || !apramounts.Any())
throw new PerformanceException("审核信息无效,请确认"); throw new PerformanceException($"工号为“{member.PersonnelNumber}”的审核信息无效,请确认");
foreach (var item in apramounts) foreach (var item in apramounts)
{ {
...@@ -665,7 +665,7 @@ public List<TitleValue> GetPerforTypeDict(int allotId) ...@@ -665,7 +665,7 @@ public List<TitleValue> GetPerforTypeDict(int allotId)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
public List<Dictionary<string, string>> GetOtherPerStats(int allotId, string department=null) public List<Dictionary<string, string>> GetOtherPerStats(int allotId, string department = null)
{ {
var others = new List<Dictionary<string, string>>(); var others = new List<Dictionary<string, string>>();
var aprAmountList = perapramountRepository.GetFullAmount(w => w.AllotId == allotId && w.Status == 3); var aprAmountList = perapramountRepository.GetFullAmount(w => w.AllotId == allotId && w.Status == 3);
...@@ -894,7 +894,7 @@ public bool DeleteAprHide(int id) ...@@ -894,7 +894,7 @@ public bool DeleteAprHide(int id)
/// <returns></returns> /// <returns></returns>
public bool ConfirmAuditHide(int userid, AprAmountAuditRequest request) public bool ConfirmAuditHide(int userid, AprAmountAuditRequest request)
{ {
if (request?.Members == null) if (request?.Members == null || !request.Members.Any())
throw new PerformanceException("审核信息无效,请确认"); throw new PerformanceException("审核信息无效,请确认");
foreach (var item in request.Members) foreach (var item in request.Members)
...@@ -907,7 +907,7 @@ public bool ConfirmAuditHide(int userid, AprAmountAuditRequest request) ...@@ -907,7 +907,7 @@ public bool ConfirmAuditHide(int userid, AprAmountAuditRequest request)
foreach (var member in request.Members) foreach (var member in request.Members)
{ {
var apramounts = allApramounts?.Where(t => (t.DoctorName ?? "") == member.DoctorName && (t.PersonnelNumber ?? "") == member.PersonnelNumber); var apramounts = allApramounts?.Where(t => (t.DoctorName ?? "") == member.DoctorName && (t.PersonnelNumber ?? "") == member.PersonnelNumber);
if (apramounts == null) if (apramounts == null || !apramounts.Any())
throw new PerformanceException("审核信息无效,请确认"); throw new PerformanceException("审核信息无效,请确认");
foreach (var item in apramounts) foreach (var item in apramounts)
......
...@@ -748,13 +748,14 @@ public bool BathSavePerson(int AllotId, int HospitalId, SaveCollectData request) ...@@ -748,13 +748,14 @@ public bool BathSavePerson(int AllotId, int HospitalId, SaveCollectData request)
return false; return false;
} }
if (persons != null)
if (persons.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim())) delPersonsNum.Add(data.PersonnelNumber);
var any = employees.Any(w => w.Department?.Trim() == data.Department?.Trim() && w.DoctorName?.Trim() == data.DoctorName?.Trim()); var any = employees.Any(w => w.Department?.Trim() == data.Department?.Trim() && w.DoctorName?.Trim() == data.DoctorName?.Trim());
if (!string.IsNullOrEmpty(data.Department?.Trim()) && !string.IsNullOrEmpty(data.AccountingUnit?.Trim()) && !string.IsNullOrEmpty(data.DoctorName?.Trim()) && !any) if (!string.IsNullOrEmpty(data.Department?.Trim()) && !string.IsNullOrEmpty(data.AccountingUnit?.Trim()) && !string.IsNullOrEmpty(data.DoctorName?.Trim()) && !any)
{ {
if (persons != null)
if (persons.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim()))
delPersonsNum.Add(data.PersonnelNumber);
data.HospitalId = HospitalId; data.HospitalId = HospitalId;
data.AllotId = AllotId; data.AllotId = AllotId;
data.DoctorName = data.DoctorName?.Trim(); data.DoctorName = data.DoctorName?.Trim();
...@@ -1135,7 +1136,7 @@ public void SaveQueryRole(int hospitalId, SaveCollectData request) ...@@ -1135,7 +1136,7 @@ public void SaveQueryRole(int hospitalId, SaveCollectData request)
if (hospital.IsOwnerQuery == 1) if (hospital.IsOwnerQuery == 1)
{ {
var isNewRole = !string.IsNullOrEmpty(data.PersonnelNumber?.Trim()) && !string.IsNullOrEmpty(item["Password"]); var isNewRole = !string.IsNullOrEmpty(data.PersonnelNumber?.Trim()) && !string.IsNullOrEmpty(item["Password"]);
var isRepeat = users != null && users.Any(t => t.RealName == data.DoctorName?.Trim() && t.Login == data.PersonnelNumber?.Trim()); var isRepeat = users != null && users.Any(t => t.Login == data.PersonnelNumber?.Trim());
if (isNewRole && !isRepeat) if (isNewRole && !isRepeat)
{ {
newUsers.Add(new[] { $"{data.DoctorName?.Trim()}", $"{data.PersonnelNumber?.Trim()}", $"{item["Password"]}", "", "", "绩效查询", $"{hospital.HosName}", $"{data.AccountingUnit?.Trim()}" }); newUsers.Add(new[] { $"{data.DoctorName?.Trim()}", $"{data.PersonnelNumber?.Trim()}", $"{item["Password"]}", "", "", "绩效查询", $"{hospital.HosName}", $"{data.AccountingUnit?.Trim()}" });
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text.RegularExpressions;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -401,6 +402,30 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute ...@@ -401,6 +402,30 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
} }
/// <summary> /// <summary>
/// 清理 将所有0赋空
/// </summary>
/// <param name="datas"></param>
public void ClearInvalidValue(List<Dictionary<string, object>> datas)
{
if (datas != null)
{
foreach (var row in datas)
{
foreach (var key in row.Keys.ToArray())
{
if (key.StartsWithIgnoreCase("SingleAwards_")
|| key.StartsWithIgnoreCase("Workload_"))
{
var value = row[key]?.ToString() ?? "";
if (value == "0" || Regex.IsMatch(value, "^0.[0]+$"))
row[key] = "";
}
}
}
}
}
/// <summary>
/// 按指定方式加载人员数据 /// 按指定方式加载人员数据
/// </summary> /// </summary>
/// <param name="allot"></param> /// <param name="allot"></param>
...@@ -884,8 +909,8 @@ private void deptRewardCalculate(List<Dictionary<string, object>> rows) ...@@ -884,8 +909,8 @@ private void deptRewardCalculate(List<Dictionary<string, object>> rows)
{ {
foreach (var row in rows) foreach (var row in rows)
{ {
decimal total_deptReward = row.Where(w => w.Key.StartsWithIgnoreCase("SingleAwards_")).Sum(r => GetDecimal2(row, r.Key)); decimal total_deptReward = row.Where(w => w.Key.StartsWithIgnoreCase("SingleAwards_")).Sum(r => GetDecimal(row, r.Key));
row.AddOrUpdate(nameof(ag_bodysource.DeptReward), total_deptReward); row.AddOrUpdate(nameof(ag_bodysource.DeptReward), GetDecimal2(total_deptReward));
} }
} }
/// <summary> /// <summary>
...@@ -960,10 +985,10 @@ private void basisPerformanceCalculate(Dictionary<string, object> head, List<Dic ...@@ -960,10 +985,10 @@ private void basisPerformanceCalculate(Dictionary<string, object> head, List<Dic
var post = row.GetString(nameof(ag_bodysource.Post)); var post = row.GetString(nameof(ag_bodysource.Post));
if (specialPostName.Contains(post)) if (specialPostName.Contains(post))
{ {
var daysFullAttendance = GetDecimal2(head, nameof(ag_headsource.DaysFullAttendance)); var daysFullAttendance = GetDecimal(head, nameof(ag_headsource.DaysFullAttendance));
var departmentsPerCapita = GetDecimal2(head, nameof(ag_headsource.DepartmentsPerCapita)); var departmentsPerCapita = GetDecimal2(head, nameof(ag_headsource.DepartmentsPerCapita));
var staffCoefficient = GetDecimal2(row, nameof(ag_bodysource.StaffCoefficient)); var staffCoefficient = GetDecimal(row, nameof(ag_bodysource.StaffCoefficient));
var actualAttendance = GetDecimal2(row, nameof(ag_bodysource.ActualAttendance)); var actualAttendance = GetDecimal(row, nameof(ag_bodysource.ActualAttendance));
var basisPerformance = daysFullAttendance == 0 ? 0 : departmentsPerCapita * staffCoefficient * actualAttendance / daysFullAttendance; var basisPerformance = daysFullAttendance == 0 ? 0 : departmentsPerCapita * staffCoefficient * actualAttendance / daysFullAttendance;
row.AddOrUpdate(nameof(ag_bodysource.BasisPerformance), basisPerformance); row.AddOrUpdate(nameof(ag_bodysource.BasisPerformance), basisPerformance);
...@@ -988,10 +1013,10 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic ...@@ -988,10 +1013,10 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic
{ {
var post = row.GetString(nameof(ag_bodysource.Post)); var post = row.GetString(nameof(ag_bodysource.Post));
if (!specialPostName.Contains(post)) if (!specialPostName.Contains(post))
total_titleCoefficient += GetDecimal2(row, nameof(ag_bodysource.ActualAttendance)) * GetDecimal2(row, nameof(ag_bodysource.TitleCoefficient)); total_titleCoefficient += GetDecimal(row, nameof(ag_bodysource.ActualAttendance)) * GetDecimal(row, nameof(ag_bodysource.TitleCoefficient));
} }
var seniorityTitlesPerformance = GetDecimal2(head, nameof(ag_headsource.SeniorityTitlesPerformance)); var seniorityTitlesPerformance = GetDecimal(head, nameof(ag_headsource.SeniorityTitlesPerformance));
foreach (var row in rows) foreach (var row in rows)
{ {
var post = row.GetString(nameof(ag_bodysource.Post)); var post = row.GetString(nameof(ag_bodysource.Post));
...@@ -999,8 +1024,8 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic ...@@ -999,8 +1024,8 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic
if (specialPostName.Contains(post)) if (specialPostName.Contains(post))
row.AddOrUpdate(nameof(ag_bodysource.TitleCoefficient), 0m); row.AddOrUpdate(nameof(ag_bodysource.TitleCoefficient), 0m);
// 职称得分 = 当前行实际出勤 * 当前行职称系数 // 职称得分 = 当前行实际出勤 * 当前行职称系数
var titlePerformanceScore = GetDecimal2(row, nameof(ag_bodysource.ActualAttendance)) * GetDecimal2(row, nameof(ag_bodysource.TitleCoefficient)); var titlePerformanceScore = GetDecimal(row, nameof(ag_bodysource.ActualAttendance)) * GetDecimal(row, nameof(ag_bodysource.TitleCoefficient));
row.AddOrUpdate(nameof(ag_bodysource.TitlePerformanceScore), GetDecimal2(titlePerformanceScore)); row.AddOrUpdate(nameof(ag_bodysource.TitlePerformanceScore), titlePerformanceScore);
//个人职称绩效 = ( 当前行实际出勤 * 当前行职称系数 ) / 职称系数总和* 年资职称绩效总和 //个人职称绩效 = ( 当前行实际出勤 * 当前行职称系数 ) / 职称系数总和* 年资职称绩效总和
var titlePerformance = total_titleCoefficient == 0 ? 0 : titlePerformanceScore / total_titleCoefficient * seniorityTitlesPerformance; var titlePerformance = total_titleCoefficient == 0 ? 0 : titlePerformanceScore / total_titleCoefficient * seniorityTitlesPerformance;
row.AddOrUpdate(nameof(ag_bodysource.TitlePerformance), GetDecimal2(titlePerformance)); row.AddOrUpdate(nameof(ag_bodysource.TitlePerformance), GetDecimal2(titlePerformance));
...@@ -1036,14 +1061,14 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic ...@@ -1036,14 +1061,14 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic
break; break;
} }
// 工作量得分 // 工作量得分
row.AddOrUpdate(gp.WorkloadScore, GetDecimal2(workload_score)); row.AddOrUpdate(gp.WorkloadScore, workload_score);
} }
} }
// 工作量每分价格计算 // 工作量每分价格计算
foreach (var gp in workloadGroups) foreach (var gp in workloadGroups)
{ {
// 汇总行内工作量总得分 // 汇总行内工作量总得分
var total_score = rows.Sum(row => GetDecimal2(row, gp.WorkloadScore) * GetDecimal2(row, gp.AssessmentScore)); var total_score = rows.Sum(row => GetDecimal(row, gp.WorkloadScore) * GetDecimal(row, gp.AssessmentScore));
// 计算每分价格 // 计算每分价格
gp.Unit_Price = total_score == 0 ? 0 : head.GetDecimal($"Workload_Amount_{gp.Name}") / total_score; gp.Unit_Price = total_score == 0 ? 0 : head.GetDecimal($"Workload_Amount_{gp.Name}") / total_score;
} }
...@@ -1061,12 +1086,12 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic ...@@ -1061,12 +1086,12 @@ private void titleCoefficientCalculate(Dictionary<string, object> head, List<Dic
row.AddOrUpdate(gp.AssessmentScore, 0m); row.AddOrUpdate(gp.AssessmentScore, 0m);
} }
// 工作量绩效 = 工作量得分 * 每分价格 * 考核得分 // 工作量绩效 = 工作量得分 * 每分价格 * 考核得分
var workload_fee = GetDecimal2(row.GetDecimal(gp.WorkloadScore) * gp.Unit_Price * row.GetDecimal(gp.AssessmentScore)); var workload_fee = row.GetDecimal(gp.WorkloadScore) * gp.Unit_Price * row.GetDecimal(gp.AssessmentScore);
row.AddOrUpdate(gp.WorkPerformance, workload_fee); row.AddOrUpdate(gp.WorkPerformance, GetDecimal2(workload_fee));
workPerformance += workload_fee; workPerformance += workload_fee;
} }
// 行内工作量汇总到一起 // 行内工作量汇总到一起
row.AddOrUpdate(nameof(ag_bodysource.WorkPerformance), workPerformance); row.AddOrUpdate(nameof(ag_bodysource.WorkPerformance), GetDecimal2(workPerformance));
} }
} }
...@@ -1095,7 +1120,7 @@ decimal ComputeMode_3(Dictionary<string, object> row, List<TitleValue<string, de ...@@ -1095,7 +1120,7 @@ decimal ComputeMode_3(Dictionary<string, object> row, List<TitleValue<string, de
// 科主任/护士长 不参与工作量考核 // 科主任/护士长 不参与工作量考核
if (specialPostName.Contains(post)) if (specialPostName.Contains(post))
row.AddOrUpdate(item.ToLower(), 0); row.AddOrUpdate(item.ToLower(), 0);
return GetDecimal2(row.GetDecimal(item.ToLower()) * getFactorValue(loads, item)); return row.GetDecimal(item.ToLower()) * getFactorValue(loads, item);
}); });
return workload_score; return workload_score;
} }
...@@ -1122,7 +1147,7 @@ decimal ComputeMode_2(Dictionary<string, object> row, SecondWorkLoadDto gp, stri ...@@ -1122,7 +1147,7 @@ decimal ComputeMode_2(Dictionary<string, object> row, SecondWorkLoadDto gp, stri
row.AddOrUpdate(gp.Items[i + 1], 0m); row.AddOrUpdate(gp.Items[i + 1], 0m);
} }
var amount = row.GetDecimal(gp.Items[i]) * row.GetDecimal(gp.Items[i + 1]); var amount = row.GetDecimal(gp.Items[i]) * row.GetDecimal(gp.Items[i + 1]);
workload_score += GetDecimal2(amount); workload_score += amount;
} }
} }
return workload_score; return workload_score;
...@@ -1205,6 +1230,13 @@ private void realAmountCalculate(List<Dictionary<string, object>> rows) ...@@ -1205,6 +1230,13 @@ private void realAmountCalculate(List<Dictionary<string, object>> rows)
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
private decimal GetDecimal2(Dictionary<string, object> pairs, string key) => GetDecimal2(pairs.GetDecimal(key)); private decimal GetDecimal2(Dictionary<string, object> pairs, string key) => GetDecimal2(pairs.GetDecimal(key));
/// <summary>
/// 从键值对中获取decimal,默认:0,返回原始值
/// </summary>
/// <param name="pairs"></param>
/// <param name="key"></param>
/// <returns></returns>
private decimal GetDecimal(Dictionary<string, object> pairs, string key) => pairs.GetDecimal(key);
/// <summary> /// <summary>
/// decimal?类型转换decimal 默认:0,保留2位小数 /// decimal?类型转换decimal 默认:0,保留2位小数
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -406,6 +405,186 @@ public void ExecProc(string execsql, object param) ...@@ -406,6 +405,186 @@ public void ExecProc(string execsql, object param)
} }
} }
public SheetExportResponse Operation(ReportRequest request)
{
SheetExportResponse sheet = new SheetExportResponse();
#region data
IEnumerable<int> years = new int[] { };
if (string.IsNullOrEmpty(request.Year))
{
string getYearsSql = "select max(`year`) `year` from view_operation_report_result where hospitalid = @hospitalid;";
years = perforReportRepository.DapperQuery<int?>(getYearsSql, new { hospitalid = request.HospitalId })?.Select(t => t ?? 0);
}
else
{
years = Array.ConvertAll(request.Year.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), t => ConvertHelper.To<int>(t));
}
if (years == null || !years.Any()) return sheet;
string sql = $"select * from view_operation_report_result where hospitalid = @hospitalid and year in @year";
if (request.AccountingUnit != null && request.AccountingUnit.Any())
{
sql += " and accountingunit in @accountingunit";
}
var data = perforReportRepository.DapperQuery<view_operation_report_result>(sql, new { hospitalId = request.HospitalId, year = years, accountingunit = request.AccountingUnit })?.ToList();
#endregion
years = data.Select(t => t.Year).Distinct().OrderByDescending(t => t);
int index = 0;
#region header
var cells = new List<Cell>
{
new Cell{ CellType = "header", CellValue = "经济指标", PointCell = 0, MergeRow = 1, MergeCell = 3 },
};
for (int i = 1; i < 13; i++)
{
cells.Add(new Cell { CellType = "header", CellValue = $"{i}月", PointCell = i + 2, MergeRow = 1, MergeCell = 1 });
}
//foreach (var year in years)
//{
// for (int i = 1; i < 13; i++)
// {
// cells.Add(new Cell { CellType = "header", CellValue = $"{i}月", PointCell = i + 2, MergeRow = 1, MergeCell = 1 });
// }
//}
sheet.Header = new List<Row>
{
new Row(0){ Data = cells }
};
#endregion
if (data == null || !data.Any())
return sheet;
var group = data.GroupBy(t => new { t.SourceType, t.Category, t.ItemName });
data = data.GroupBy(t => new { t.Year, t.SourceType, t.Category, t.ItemName }).Select(t => new view_operation_report_result
{
Year = t.Key.Year,
SourceType = t.Key.SourceType,
Category = t.Key.Category,
ItemName = t.Key.ItemName,
January = t.Sum(g => g.January ?? 0),
February = t.Sum(g => g.February ?? 0),
March = t.Sum(g => g.March ?? 0),
April = t.Sum(g => g.April ?? 0),
May = t.Sum(g => g.May ?? 0),
June = t.Sum(g => g.June ?? 0),
July = t.Sum(g => g.July ?? 0),
August = t.Sum(g => g.August ?? 0),
September = t.Sum(g => g.September ?? 0),
October = t.Sum(g => g.October ?? 0),
November = t.Sum(g => g.November ?? 0),
December = t.Sum(g => g.December ?? 0)
}).ToList();
var sourcetypes = data.Select(t => t.SourceType).Distinct();
#region body
Dictionary<int, Func<view_operation_report_result, object>> dict = new Dictionary<int, Func<view_operation_report_result, object>>
{
{ 1, t => t.January },
{ 2, t => t.February },
{ 3, t => t.March },
{ 4, t => t.April },
{ 5, t => t.May },
{ 6, t => t.June },
{ 7, t => t.July },
{ 8, t => t.August },
{ 9, t => t.September },
{ 10, t => t.October },
{ 11, t => t.November },
{ 12, t => t.December },
};
int rownumber = 0;
int maxPointIndex = 0;
List<Row> rows = new List<Row>();
foreach (var sourcetype in sourcetypes.OrderBy(t => t))
{
int inittype = 0; // 0加载sourcetype、category; 1加载category; 2不加载sourcetype、category
var sourcetypeData = data.Where(t => t.SourceType == sourcetype);
if (sourcetypeData == null || !sourcetypeData.Any()) continue;
foreach (var category in sourcetypeData.Select(t => t.Category).Distinct().OrderBy(t => t))
{
var categoryData = sourcetypeData.Where(t => t.Category == category);
if (categoryData == null || !categoryData.Any()) continue;
foreach (var itemname in categoryData.Select(t => t.ItemName).Distinct().OrderBy(t => t))
{
var itemnameData = categoryData.Where(t => t.ItemName == itemname);
if (itemnameData == null || !itemnameData.Any()) continue;
var rowcells = new List<Cell>();
if (inittype == 0)
{
rowcells = new List<Cell>
{
new Cell { CellType = "body", CellValue = sourcetype, PointCell = 0, MergeRow = sourcetypeData.Count(), MergeCell = 1 },
new Cell { CellType = "body", CellValue = category, PointCell = 1, MergeRow = categoryData.Count(), MergeCell = 1 },
};
}
else if (inittype == 1)
{
rowcells.Add(new Cell { CellType = "body", CellValue = category, PointCell = 0, MergeRow = categoryData.Count(), MergeCell = 1 });
}
int itemnameIndex = inittype == 0 ? 2 : inittype == 1 ? 1 : 0;
rowcells.Add(new Cell { CellType = "body", CellValue = itemname, PointCell = itemnameIndex, MergeRow = itemnameData.Count(), MergeCell = 1 });
index = 0;
foreach (var year in years)
{
var thisdata = itemnameData.FirstOrDefault(t => t.Year == year);
int point = itemnameIndex + 1 + index * 12;
for (int i = 1; i < 13; i++)
{
rowcells.Add(new Cell
{
CellType = "body",
CellValue = thisdata != null ? dict[i].Invoke(thisdata) : null,
PointCell = point,
MergeRow = 1,
MergeCell = 1
});
point++;
}
index++;
}
if (inittype == 0) maxPointIndex = rowcells.Max(t => t.PointCell);
inittype = 2;
rows.Add(new Row(rownumber) { Data = rowcells });
rownumber++;
}
inittype = 1;
}
}
sheet.Row = rows;
#endregion
return sheet;
}
#region normal #region normal
public TableData TableNormal(ConditionRequest request) public TableData TableNormal(ConditionRequest request)
......
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