Commit 8d04651f by lcx

Merge branch 'v2020morge' into v2020morge-graphql

# Conflicts:
#	performance/Performance.Api/Controllers/SecondAllotController.cs
#	performance/Performance.Api/wwwroot/Performance.EntityModels.xml
#	performance/Performance.EntityModels/Context/PerformanceDbContext.cs
parents 6dcaa653 e940a7c2
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.Infrastructure;
using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
......@@ -10,10 +17,51 @@ namespace Performance.Api.Controllers
[Route("api/{hospitalId}/report/global")]
public class ReportGlobalController : Controller
{
//private readonly
private readonly IHostingEnvironment env;
private readonly AllotService allotService;
private readonly ReportGlobalService reportGlobalService;
public ReportGlobalController()
public ReportGlobalController(
IHostingEnvironment env,
AllotService allotService,
ReportGlobalService reportGlobalService
)
{
this.env = env;
this.allotService = allotService;
this.reportGlobalService = reportGlobalService;
}
/// <summary>
/// 上传人员绩效文件
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="form"></param>
/// <returns></returns>
[Route("import")]
[HttpPost]
public ApiResponse Import(int hospitalId, [FromForm] IFormCollection form)
{
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", $"ImportDataFiles");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
}
reportGlobalService.ImportAllotData(hospitalId, path);
return new ApiResponse(ResponseType.OK);
}
}
}
......@@ -456,7 +456,6 @@ public ApiResponse DeptComputeDetail(int allotId)
var userId = claimService.GetUserId();
//var data = secondAllotService.DeptComputeDetail(userId, allotId, out int isShowManage);
var data = secondAllotService.DeptComputeDetailList(userId, allotId, out int isShowManage);
return new ApiResponse(ResponseType.OK, new { isShowManage, data });
}
}
......
......@@ -1094,6 +1094,14 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.Import(System.Int32,Microsoft.AspNetCore.Http.IFormCollection)">
<summary>
上传人员绩效文件
</summary>
<param name="hospitalId"></param>
<param name="form"></param>
<returns></returns>
</member>
<member name="T:Performance.Api.Controllers.SecondAllotController">
<summary>
二次绩效
......
......@@ -936,7 +936,7 @@
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.AccountingUnit">
<summary>
核算单元
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.EmployeeName">
......@@ -1044,6 +1044,11 @@
应发管理绩效
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.OtherManagePerfor">
<summary>
其他管理绩效
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.Income">
<summary>
科室业绩
......
......@@ -24,7 +24,7 @@ public class PerDataAccountBaisc : IPerData
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
......@@ -158,6 +158,11 @@ public class PerDataAccountBaisc : IPerData
/// </summary>
public decimal ShouldGiveFee { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public decimal OtherManagePerfor { get; set; }
///// <summary>
///// 保底绩效参考标准
///// </summary>
......@@ -172,8 +177,8 @@ public class PerDataAccountBaisc : IPerData
///// 工作量倾斜系数
///// </summary>
//public Nullable<decimal> WorkSlopeFactor { get; set; }
#endregion
#endregion EXCEL读取
#region 由计算得出
......@@ -227,6 +232,6 @@ public class PerDataAccountBaisc : IPerData
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
#endregion
#endregion 由计算得出
}
}
......@@ -135,6 +135,10 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<his_script> his_script { get; set; }
/// <summary> </summary>
public virtual DbSet<his_importdata> his_importdata { get; set; }
/// <summary> </summary>
public virtual DbSet<hos_personfee> hos_personfee { get; set; }
/// <summary> 科室核算导入信息 </summary>
......
//-----------------------------------------------------------------------
// <copyright file=" his_importdata.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("his_importdata")]
public class his_importdata
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
/// 医院ID
/// </summary>
public int HospitalId { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 年
/// </summary>
public int Year { get; set; }
/// <summary>
/// 月
/// </summary>
public int Month { get; set; }
/// <summary>
/// 科室核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string PersonnelName { get; set; }
/// <summary>
/// 人员工号
/// </summary>
public string PersonnelNumber { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 一级分类
/// </summary>
public string Category { get; set; }
/// <summary>
/// 原始分类
/// </summary>
public string Original { get; set; }
/// <summary>
/// 二级分类
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 值
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" his_importdata.cs">
// * FileName: his_importdata.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// his_importdata Repository
/// </summary>
public partial class PerforHisimportdataRepository : PerforRepository<his_importdata>
{
public PerforHisimportdataRepository(PerformanceDbContext context) : base(context)
{
}
}
}
......@@ -6,6 +6,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services
......@@ -901,15 +903,20 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
private List<DetailModule> CommonDetailItems(List<im_data> basicData, List<im_header> headers, per_sheet sheet, UnitType type)
{
var items = basicData
.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal != 1)
?.Select(t => new DetailModule
{
ItemName = t.TypeName,
CellValue = t.CellValue,
Factor = sheet.SheetType == (int)SheetType.Workload ? t.FactorValue : t.FactorValue * 100,
ItemValue = t.IsFactor == 1 ? (t.CellValue * (t.FactorValue ?? 0)) : t.CellValue,
}).ToList();
Expression<Func<im_data, bool>> exp = (t) => t.SheetID == sheet.ID && t.IsTotal != 1;
if (sheet.SheetType == (int)SheetType.Workload && new int[] { (int)UnitType.医技组, (int)UnitType.其他医技组 }.Contains((int)type))
exp = exp.And(t => new int[] { (int)UnitType.医生组, (int)UnitType.医技组, (int)UnitType.其他医技组 }.Contains(t.UnitType.Value));
else
exp = exp.And(t => t.UnitType == (int)type);
var items = basicData.Where(exp.Compile())?.Select(t => new DetailModule
{
ItemName = t.TypeName,
CellValue = t.CellValue,
Factor = sheet.SheetType == (int)SheetType.Workload ? t.FactorValue : t.FactorValue * 100,
ItemValue = t.IsFactor == 1 ? (t.CellValue * (t.FactorValue ?? 0)) : t.CellValue,
}).ToList();
if (items != null && items.Any())
{
......@@ -1252,35 +1259,43 @@ public DeptDataDetails GetDoctorDetail(int computeId)
//var allot = perforPerallotRepository.GetEntity(t => t.ID == resCompute.AllotID);
//if (allot == null) return new DeptDataDetails();
var employee = _perforImemployeeclinicRepository.GetEntity(t => t.AllotID == resCompute.AllotID && t.AccountingUnit == resCompute.AccountingUnit && t.UnitType == resCompute.UnitType && t.DoctorName == resCompute.EmployeeName);
var employee = _perforImemployeeclinicRepository.GetEntity(t => t.AllotID == resCompute.AllotID && t.AccountingUnit == resCompute.AccountingUnit && t.UnitType == resCompute.UnitType && t.PersonnelNumber == resCompute.JobNumber);
DeptDataDetails doctorDetails = new DeptDataDetails
{
ShowFormula = 0,
Pandect = new PerDataAccountBaisc
{
BasicFactor = employee?.Basics ?? 0, //基础绩效系数
Effic = employee.Efficiency ?? 0, //效率绩效系数
Scale = employee.Scale ?? 0, //规模绩效系数
Management = employee.Management,//管理绩效发放系数
AdjustFactor = employee?.Adjust ?? 1, //调节系数
AdjustLaterOtherFee = employee.AdjustLaterOtherFee, //调节后其他绩效
AccountingUnit = resCompute.AccountingUnit,
EmployeeName = resCompute.EmployeeName,
PerforTotal = resCompute.PerforTotal, //科室考核前绩效
Number = resCompute.Number ?? 0, //核算人数
AvgPerfor = (resCompute.Number ?? 0) == 0 ? 0 : resCompute.PerforTotal / resCompute.Number, //人均绩效
BasicFactor = employee?.Basics ?? 0, //基础绩效系数
Attendance = resCompute.Attendance, //出勤率
Attendance = resCompute.Attendance ?? 1, //出勤率
Avg = resCompute.Avg, //实际人均
PermanentStaff = resCompute.PermanentStaff ?? 0, //效率绩效人数
Effic = employee.Efficiency ?? 0, //效率绩效系数
EfficPerfor = resCompute.Efficiency ?? 0, //效率绩效
Scale = employee.Scale ?? 0, //规模绩效系数
ScalePerfor = resCompute.Scale ?? 0, //规模绩效
Management = employee.Management,//管理绩效发放系数
Extra = resCompute.Punishment ?? 0, //医院奖罚
OtherManagePerfor = resCompute.OtherManagePerfor ?? 0, //其他管理绩效
ShouldGiveFee = resCompute.ShouldGiveFee ?? 0, //考核前管理绩效
ScoringAverage = resCompute.ScoreAverageRate ?? 1, //考核得分率
AssessLaterManagementFee = Math.Round(resCompute.ShouldGiveFee * resCompute.ScoreAverageRate * resCompute.Attendance + resCompute.Punishment ?? 0), //考核后管理绩效
AdjustFactor = employee?.Adjust ?? 1, //调节系数
AdjustLaterOtherFee = employee.AdjustLaterOtherFee, //调节后其他绩效
RealGiveFee = resCompute.RealGiveFee //绩效合计
},
Detail = new List<DetailDtos>()
};
var isShowManage = IsShowManage(resCompute.AllotID.Value);
// 开启 显示管理绩效
if (isShowManage == 2)
doctorDetails.Pandect.RealGiveFee = doctorDetails.Pandect.AssessLaterManagementFee;
var sheets = _perforPerSheetRepository.GetEntities(t => t.AllotID == resCompute.AllotID && new int[] { (int)SheetType.PersonExtra, (int)SheetType.PersonAdjustLaterOtherFee }.Contains(t.SheetType.Value));
if (sheets == null || !sheets.Any()) return doctorDetails;
......@@ -1312,4 +1327,4 @@ public DeptDataDetails GetDoctorDetail(int computeId)
return doctorDetails;
}
}
}
\ No newline at end of file
}
using Performance.EntityModels;
using Microsoft.Extensions.Logging;
using NPOI.SS.UserModel;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Performance.Services
{
public class ReportGlobalService : IAutoInjection
{
private readonly ILogger logger;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforReportglobalRepository reportglobalRepository;
private readonly PerforHisimportdataRepository hisimportdataRepository;
public ReportGlobalService(PerforReportglobalRepository reportglobalRepository)
public ReportGlobalService(
ILogger<ReportGlobalService> logger,
PerforPerallotRepository perallotRepository,
PerforReportglobalRepository reportglobalRepository,
PerforHisimportdataRepository hisimportdataRepository
)
{
this.logger = logger;
this.perallotRepository = perallotRepository;
this.reportglobalRepository = reportglobalRepository;
this.hisimportdataRepository = hisimportdataRepository;
}
public List<report_global> GetReportGlobals(int hospitalId)
......@@ -20,5 +37,119 @@ public List<report_global> GetReportGlobals(int hospitalId)
var globals = reportglobalRepository.GetEntities(t => t.HospitalID == hospitalId);
return globals;
}
#region ImportFile && SaveData
public void ImportAllotData(int hospitalId, string filePath)
{
IWorkbook workbook = null;
try
{
workbook = ExcelHelper.GetWorkbook(filePath);
if (workbook == null) throw new PerformanceException("文件读取失败");
var allots = perallotRepository.GetEntities(t => t.HospitalId == hospitalId);
for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++)
{
var sheet = workbook.GetSheetAt(sheetIndex);
if (sheet == null) continue;
string sheetName = sheet.SheetName.NoBlank();
var columns = GetColumns(sheet, sheetName, out string sourceType);
if (columns == null || !columns.Any(t => !string.IsNullOrEmpty(t.NoBlank()))) continue;
var data = new List<his_importdata>();
for (int rowIndex = 1; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{
var row = sheet.GetRow(rowIndex);
if (row == null) continue;
his_importdata importdata = new his_importdata
{
Year = GetCellValue<int>(row, columns, nameof(his_importdata.Year)),
Month = GetCellValue<int>(row, columns, nameof(his_importdata.Month)),
AccountingUnit = GetCellValue<string>(row, columns, nameof(his_importdata.AccountingUnit)),
Department = GetCellValue<string>(row, columns, nameof(his_importdata.Department)),
PersonnelNumber = GetCellValue<string>(row, columns, nameof(his_importdata.PersonnelNumber)),
PersonnelName = GetCellValue<string>(row, columns, nameof(his_importdata.PersonnelName)),
Original = GetCellValue<string>(row, columns, nameof(his_importdata.Original)),
Value = GetCellValue<decimal>(row, columns, nameof(his_importdata.Value)),
};
data.Add(importdata);
}
if (data == null || !data.Any(t => t.Year != 0 && t.Month != 0)) return;
data.ForEach(t =>
{
t.HospitalId = hospitalId;
t.AllotId = allots?.FirstOrDefault(w => w.Year == t.Year && t.Month == w.Month)?.ID;
t.SourceType = sourceType;
t.Category = sheetName;
});
var years = data.Select(t => t.Year).Distinct();
var months = data.Select(t => t.Month).Distinct();
var historyData = hisimportdataRepository.GetEntities(t => t.HospitalId == hospitalId && years.Contains(t.Year) && months.Contains(t.Month) && t.Category == sheetName);
if (historyData != null && historyData.Any()) hisimportdataRepository.RemoveRange(historyData.ToArray());
hisimportdataRepository.AddRange(data.Where(t => t.Year != 0 && t.Month != 0).ToArray());
}
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
}
}
private List<string> GetColumns(ISheet sheet, string sheetName, out string sourceType)
{
sourceType = "";
foreach (var item in sourceTypes)
{
if (item.Value.Contains(sheetName))
{
sourceType = item.Key;
break;
}
}
if (string.IsNullOrEmpty(sourceType)) return new List<string>(); ;
var columnRow = sheet.GetOrCreate(0);
return columnRow.GetCellValues();
}
private T GetCellValue<T>(IRow row, List<string> columns, string key)
{
var value = hisImportdataDict[key];
if (columns.Contains(value) && row.GetCell(columns.IndexOf(value)) != null)
return row.GetCell(columns.IndexOf(value)).GetCellValue<T>();
return default;
}
private readonly Dictionary<string, string[]> sourceTypes = new Dictionary<string, string[]>
{
{ "收入", new string[] { "门诊收入", "住院收入" } },
{ "医生工作量", new string[] { "门诊人次", "出院人次", "手术概况", "住院天数", "实际开放总床日数" } },
{ "医技工作量", new string[] { "医技工作量" } },
};
private readonly Dictionary<string, string> hisImportdataDict = new Dictionary<string, string>
{
{ nameof(his_importdata.Year), "年份" },
{ nameof(his_importdata.Month), "月份" },
{ nameof(his_importdata.AccountingUnit), "核算单元" },
{ nameof(his_importdata.Department), "科室" },
{ nameof(his_importdata.PersonnelNumber), "工号" },
{ nameof(his_importdata.PersonnelName), "医生姓名" },
{ nameof(his_importdata.Original), "类别" },
{ nameof(his_importdata.Value), "值" },
};
#endregion ImportFile && SaveData
}
}
......@@ -394,7 +394,7 @@ private List<BodyItem> GetEmployees(List<per_employee> employees, ag_secondallot
var list = new List<BodyItem>();
//var employees = personService.GetPersons(allotId, userId);
//if (employees == null || !employees.Any(t => t.UnitType == unittype)) return list;
if (employees == null || !employees.Any()) return list;
var hospital = hospitalRepository.GetEntity(t => t.ID == employees.First().HospitalId);
if (hospital == null) return list;
......
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