Commit 317a3cc9 by lcx

Merge branch 'v2020calculate' into v2020collect

# Conflicts:
#	performance/Performance.Api/wwwroot/Performance.Api.xml
#	performance/Performance.Api/wwwroot/Performance.DtoModels.xml
#	performance/Performance.Infrastructure/Helper/JsonHelper.cs
#	performance/Performance.Services/PerExcelService/ExcelReadConfig.cs
parents e218731d 9c7c862b
......@@ -44,6 +44,19 @@ public class AccountController : Controller
/// <summary>
/// 登录
/// </summary>
/// <remarks>
/// Sample request:
///
/// POST /Todo
/// {
/// "logintype": 2,
/// "account": "admin",
/// "password": "1111",
/// "appname": "string",
/// "device": "web"
/// }
///
/// </remarks>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
......@@ -110,7 +123,7 @@ public ApiResponse SelfInfo()
user.Role = _roleService.GetUserRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole };
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user);
}
......@@ -179,7 +192,7 @@ public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"),
{
var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole };
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUserRole(userId);
var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
......
......@@ -116,49 +116,49 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 查看科室绩效
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("departmentdetail")]
[HttpPost]
public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{
var userId = claimService.GetUserId();
var roles = roleService.GetUserRole(userId);
var department = claimService.GetUserClaim(JwtClaimTypes.Department);
///// <summary>
///// 查看科室绩效
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("departmentdetail")]
//[HttpPost]
//public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{
// var userId = claimService.GetUserId();
// var roles = roleService.GetUserRole(userId);
// var department = claimService.GetUserClaim(JwtClaimTypes.Department);
var again = againAllotService.GetAgainallot(request.AgainAllotID);
if (again == null)
return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效");
if (roles.First().Type == application.DirectorRole)
{
var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1);
return new ApiResponse(ResponseType.OK, detail);
}
else if (roles.First().Type == application.NurseRole)
{
var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2);
return new ApiResponse(ResponseType.OK, detail);
}
return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别");
}
// var again = againAllotService.GetAgainallot(request.AgainAllotID);
// if (again == null)
// return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效");
// if (roles.First().Type == application.DirectorRole)
// {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1);
// return new ApiResponse(ResponseType.OK, detail);
// }
// else if (roles.First().Type == application.NurseRole)
// {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2);
// return new ApiResponse(ResponseType.OK, detail);
// }
// return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别");
//}
/// <summary>
/// 生成绩效
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("generate")]
[HttpPost]
public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{
var userId = claimService.GetUserId();
var department = claimService.GetUserClaim(JwtClaimTypes.Department);
var result = againAllotService.Generate(request, userId, department);
return new ApiResponse(ResponseType.OK);
}
///// <summary>
///// 生成绩效
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("generate")]
//[HttpPost]
//public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{
// var userId = claimService.GetUserId();
// var department = claimService.GetUserClaim(JwtClaimTypes.Department);
// var result = againAllotService.Generate(request, userId, department);
// return new ApiResponse(ResponseType.OK);
//}
/// <summary>
/// 查看绩效详情
......
......@@ -9,6 +9,7 @@
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.AllotCompute;
using System;
using System.Collections.Generic;
using System.IO;
......@@ -24,6 +25,7 @@ namespace Performance.Api.Controllers
public class AllotController : Controller
{
private AllotService _allotService;
private readonly ResultComputeService resultComputeService;
private HospitalService _hospitalService;
private ConfigService _configService;
private IHostingEnvironment _evn;
......@@ -32,11 +34,13 @@ public class AllotController : Controller
private readonly LogManageService logManageService;
public AllotController(AllotService allotService,
ResultComputeService resultComputeService,
HospitalService hospitalService, ConfigService configService,
ILogger<AllotController> logger, IHostingEnvironment evn,
ClaimService claim, LogManageService logManageService)
{
_allotService = allotService;
this.resultComputeService = resultComputeService;
_hospitalService = hospitalService;
_logger = logger;
_evn = evn;
......@@ -265,6 +269,8 @@ public ApiResponse Issued([FromBody] AllotRequest request)
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
// 科室下发
resultComputeService.GenerateSecondAllot(allot);
return new ApiResponse(ResponseType.OK);
}
......@@ -282,5 +288,82 @@ public ApiResponse UpdateAllotShowFormula([FromBody] AllotRequest request)
var result = _allotService.UpdateAllotShowFormula(request.ID);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 获取
/// </summary>
/// <returns></returns>
[Route("reserved")]
[HttpPost]
public ApiResponse Reserved([FromBody] ReservedRequest request)
{
if (request.HospitalId < 1)
return new ApiResponse(ResponseType.ParameterError, "绩效信息无效");
var userid = _claim.GetUserId();
var reserveds = _allotService.GetReserved(request.HospitalId, request.Year, userid);
#region 格式转换
var result = reserveds?.Select(w => new
{
w.HospitalId,
w.Year,
w.UnitType,
w.AccountingUnit,
w.EmployeeName,
w.JobNumber,
JanReseFee = w.JanFee * w.JanRatio,
JanGiveFee = w.JanFee * (1 - w.JanRatio),
FebReseFee = w.FebFee * w.FebRatio,
FebGiveFee = w.FebFee * (1 - w.FebRatio),
MarReseFee = w.MarFee * w.MarRatio,
MarGiveFee = w.MarFee * (1 - w.MarRatio),
AprReseFee = w.AprFee * w.AprRatio,
AprGiveFee = w.AprFee * (1 - w.AprRatio),
MayReseFee = w.MayFee * w.MayRatio,
MayGiveFee = w.MayFee * (1 - w.MayRatio),
JunReseFee = w.JunFee * w.JunRatio,
JunGiveFee = w.JunFee * (1 - w.JunRatio),
JulReseFee = w.JulFee * w.JulRatio,
JulGiveFee = w.JulFee * (1 - w.JulRatio),
AugReseFee = w.AugFee * w.AugRatio,
AugGiveFee = w.AugFee * (1 - w.AugRatio),
SepReseFee = w.SepFee * w.SepRatio,
SepGiveFee = w.SepFee * (1 - w.SepRatio),
OctReseFee = w.OctFee * w.OctRatio,
OctGiveFee = w.OctFee * (1 - w.OctRatio),
NovReseFee = w.NovFee * w.NovRatio,
NovGiveFee = w.NovFee * (1 - w.NovRatio),
DecReseFee = w.DecFee * w.DecRatio,
DecGiveFee = w.DecFee * (1 - w.DecRatio),
TotalReseFee = (w.JanFee * w.JanRatio ?? 0) + (w.FebFee * w.FebRatio ?? 0) + (w.MarFee * w.MarRatio ?? 0)
+ (w.AprFee * w.AprRatio ?? 0) + (w.MayFee * w.MayRatio ?? 0) + (w.JunFee * w.JunRatio ?? 0)
+ (w.JulFee * w.JulRatio ?? 0) + (w.AugFee * w.AugRatio ?? 0) + (w.SepFee * w.SepRatio ?? 0)
+ (w.OctFee * w.OctRatio ?? 0) + (w.NovFee * w.NovRatio ?? 0) + (w.DecFee * w.DecRatio ?? 0),
TotalGiveFee = (w.JanFee * (1 - w.JanRatio) ?? 0) + (w.FebFee * (1 - w.FebRatio) ?? 0) + (w.MarFee * (1 - w.MarRatio) ?? 0)
+ (w.AprFee * (1 - w.AprRatio) ?? 0) + (w.MayFee * (1 - w.MayRatio) ?? 0) + (w.JunFee * (1 - w.JunRatio) ?? 0)
+ (w.JulFee * (1 - w.JulRatio) ?? 0) + (w.AugFee * (1 - w.AugRatio) ?? 0) + (w.SepFee * (1 - w.SepRatio) ?? 0)
+ (w.OctFee * (1 - w.OctRatio) ?? 0) + (w.NovFee * (1 - w.NovRatio) ?? 0) + (w.DecFee * (1 - w.DecRatio) ?? 0),
});
#endregion
return new ApiResponse(ResponseType.OK, result);
}
}
}
......@@ -30,7 +30,7 @@ public BudgetController(ClaimService claim, BudgetService budgetService)
/// <returns></returns>
[HttpPost]
[Route("query")]
public ApiResponse<List<BudgetResponse>> Query([FromBody]BudgetRequest request)
public ApiResponse<List<BudgetResponse>> Query([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<BudgetResponse>>(ResponseType.ParameterError, "参数无效");
......@@ -47,7 +47,7 @@ public ApiResponse<List<BudgetResponse>> Query([FromBody]BudgetRequest request)
/// <returns></returns>
[HttpPost]
[Route("save/{mainYear}")]
public ApiResponse Save(int mainYear, [FromBody]List<BudgetResponse> request)
public ApiResponse Save(int mainYear, [FromBody] List<BudgetResponse> request)
{
var userId = claim.GetUserId();
var result = false;
......@@ -65,7 +65,7 @@ public ApiResponse Save(int mainYear, [FromBody]List<BudgetResponse> request)
/// <returns></returns>
[HttpPost]
[Route("modify")]
public ApiResponse Modify([FromBody]List<BudgetResponse> request)
public ApiResponse Modify([FromBody] List<BudgetResponse> request)
{
//var result = budgetService.ModifyBudgetData(request);
//return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败");
......@@ -79,7 +79,7 @@ public ApiResponse Modify([FromBody]List<BudgetResponse> request)
/// <returns></returns>
[HttpPost]
[Route("result/query")]
public ApiResponse<List<per_budget_result>> Result([FromBody]BudgetRequest request)
public ApiResponse<List<per_budget_result>> Result([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<per_budget_result>>(ResponseType.ParameterError, "参数无效");
......@@ -95,7 +95,7 @@ public ApiResponse<List<per_budget_result>> Result([FromBody]BudgetRequest reque
/// <returns></returns>
[HttpPost]
[Route("result/ratio")]
public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody]BudgetRequest request)
public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<BudgetRatioResponse>>(ResponseType.ParameterError, "参数无效");
......@@ -111,7 +111,7 @@ public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody]BudgetRequest requ
/// <returns></returns>
[HttpPost]
[Route("result/save")]
public ApiResponse ResultSave([FromBody]List<per_budget_result> request)
public ApiResponse ResultSave([FromBody] List<per_budget_result> request)
{
var userId = claim.GetUserId();
var result = budgetService.SaveBudgetRatio(request, userId);
......@@ -143,5 +143,26 @@ public ApiResponse CancelResult(int id)
var result = budgetService.CancelResult(id);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
/// <summary>
/// 统计指定月份绩效信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("result/collect")]
public ApiResponse Collect([FromBody] BudgetCollectRequest request)
{
var result = budgetService.Collect(request.HospitalId, request.Year, request.Month);
return new ApiResponse(ResponseType.OK, new
{
result.Year,
result.Month,
result.MedicalIncome,
result.TheNewPerformance,
result.MedicineProportion,
result.MaterialCosts,
});
}
}
}
\ No newline at end of file
......@@ -162,6 +162,10 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
request.AccountID = accountId;
}
}
else if (request.AccountID != 0 && request.UnitType == (int)UnitType.特殊核算组)
{
second = _computeService.GetSecondByAccountId(request.AccountID);
}
if (second != null && second.UnitType == UnitType.特殊核算组.ToString())
{
......@@ -188,11 +192,56 @@ public ApiResponse AllCompute([FromBody] ComputerRequest request)
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var isShowManage = _computeService.IsShowManage(request.AllotId);
var list = isShowManage == 1 ? _computeService.AllCompute(request.AllotId) : _computeService.AllManageCompute(request.AllotId);
//var list = isShowManage == 1
// ? _computeService.AllCompute(request.AllotId)
// : _computeService.AllManageCompute(request.AllotId);
var list = _computeService.AllCompute(request.AllotId, isShowManage);
return new ApiResponse(ResponseType.OK, "ok", list);
}
/// <summary>
/// 获取全院绩效平均
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("allavg")]
[HttpPost]
public ApiResponse AllComputeAvg([FromBody] ComputerRequest request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var isShowManage = _computeService.IsShowManage(request.AllotId);
var list = _computeService.AllCompute(request.AllotId, isShowManage);
List<res_baiscnorm> avgs = new List<res_baiscnorm>();
var gc = list.Where(w => w.UnitType != UnitType.行政高层.ToString());
avgs.Add(new res_baiscnorm
{
PositionName = "不含行政高层人均绩效",
TotelNumber = gc.Select(w => new { w.JobNumber, w.EmployeeName }).Distinct().Count(),
TotelValue = Math.Round(gc.Sum(s => s.RealGiveFee) ?? 0),
AvgValue = gc.Select(p => new { p.JobNumber, p.EmployeeName }).Distinct().Count() == 0
? 0 : Math.Round(gc.Sum(s => s.RealGiveFee) / gc.Select(p => new { p.JobNumber, p.EmployeeName }).Distinct().Count() ?? 0)
});
avgs.AddRange(
list.GroupBy(w => w.UnitType).Select(w => new res_baiscnorm
{
PositionName = $"{w.Key}人均绩效",
TotelNumber = w.Count(),
TotelValue = Math.Round(w.Sum(s => s.RealGiveFee) ?? 0),
AvgValue = gc.Select(p => new { p.JobNumber, p.EmployeeName }).Distinct().Count() == 0
? 0 : Math.Round(gc.Sum(s => s.RealGiveFee) / gc.Select(p => new { p.JobNumber, p.EmployeeName }).Distinct().Count() ?? 0)
}));
return new ApiResponse(ResponseType.OK, "ok", avgs.Select(w => new { w.PositionName, w.TotelNumber, w.TotelValue, w.AvgValue }));
}
/// <summary>
/// 获取全院管理绩效列表
/// </summary>
/// <param name="request"></param>
......@@ -204,7 +253,7 @@ public ApiResponse AllManageCompute([FromBody] ComputerRequest request)
var allot = _allotService.GetAllot(request.AllotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.AllManageCompute(request.AllotId);
var list = _computeService.AllCompute(request.AllotId, 1);
return new ApiResponse(ResponseType.OK, "ok", list);
}
......
......@@ -320,6 +320,19 @@ public ApiResponse DeleteApr([FromBody] per_apr_amount request)
}
/// <summary>
/// 医院其他绩效审核;驳回、成功
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("apr/audit")]
public ApiResponse AuditResult([FromBody] AprAmountAuditRequest request)
{
var userid = claim.GetUserId();
var result = employeeService.ConfirmAudit(userid, request);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
/// <summary>
/// 上传人员绩效文件
/// </summary>
/// <param name="form"></param>
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
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;
namespace Performance.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class HistoryController : ControllerBase
{
private readonly HistoryService historyService;
private readonly ClaimService claim;
private readonly IHostingEnvironment evn;
public HistoryController(
HistoryService historyService,
ClaimService claim,
IHostingEnvironment evn)
{
this.historyService = historyService;
this.claim = claim;
this.evn = evn;
}
/// <summary>
/// 上传历史绩效数据
/// </summary>
/// <param name="form"></param>
/// <returns></returns>
[Route("import")]
[HttpPost]
public ApiResponse Import([FromForm] IFormCollection form)
{
var hospitalid = form.ToDictionary().GetValue("hospitalid", 0);
if (hospitalid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "hospitalid无效");
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var name = $"History_{FileHelper.GetFileNameNoExtension(file.FileName)}{DateTime.Now:yyyyMMddHHmmssfff}";
var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(evn.ContentRootPath, "Files", hospitalid.ToString());
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}上传失败");
}
historyService.ImportHistoryData(hospitalid, path);
return new ApiResponse(ResponseType.OK);
}
}
}
......@@ -145,13 +145,13 @@ public ApiResponse DeleteDeptDic([FromBody] DeptdicResponse request)
/// 系统/标准科室字典
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="type">1系统科室 2标准科室 3核算单元</param>
/// <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
/// <returns></returns>
[Route("deptdic/{hospitalId}/dict/{type}")]
[HttpPost]
public ApiResponse DeptDics(int hospitalId, int type)
{
if (!new int[] { 1, 2, 3 }.Contains(type))
if (!new int[] { 1, 2, 3, 4, 5 }.Contains(type))
return new ApiResponse(ResponseType.ParameterError, "参数错误!");
var result = personService.DeptDics(hospitalId, type);
......@@ -169,5 +169,17 @@ public ApiResponse DeptWorkloadDetail([CustomizeValidator(RuleSet = "Select"), F
var data = personService.DeptWorkloadDetail(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, data);
}
/// <summary>
/// 门诊开单收入详情
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("dept/incomedetail")]
public ApiResponse DeptIncomeDetail([CustomizeValidator(RuleSet = "Select"), FromBody] WorkDetailRequest request)
{
var data = personService.DeptIncomeDetail(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, data);
}
}
}
......@@ -37,7 +37,7 @@ public ApiResponse Rank([FromBody] HospitalIdRequest request)
{
var allots = allotService.GetAllotList(request.HospitalId);
int[] states = new int[] { 6, 8 };
int[] states = new int[] { 6, 8, 10 };
var result = allots?.Where(w => states.Contains(w.States))
.Select(w => new { w.Year, w.Month })
.OrderByDescending(w => w.Year)
......
......@@ -4,6 +4,7 @@
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Services;
using Performance.Services.AllotCompute;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -19,12 +20,16 @@ public class SecondAllotController : ControllerBase
{
private readonly ClaimService claimService;
private readonly SecondAllotService secondAllotService;
private readonly ResultComputeService resultComputeService;
public SecondAllotController(ClaimService claimService,
SecondAllotService secondAllotService)
public SecondAllotController(
ClaimService claimService,
SecondAllotService secondAllotService,
ResultComputeService resultComputeService)
{
this.claimService = claimService;
this.secondAllotService = secondAllotService;
this.resultComputeService = resultComputeService;
}
#region 二次绩效列表、录入数据展示,保存数据
......@@ -131,6 +136,30 @@ public ApiResponse SecondDetail([CustomizeValidator(RuleSet = "Refresh"), FromBo
//}
#endregion
/// <summary>
/// 二次绩效录入页面自动补全
/// </summary>
/// <returns></returns>
[Route("api/second/autocomplete")]
[HttpPost]
public ApiResponse AutoComplete([FromBody] SecondEmpRequest request)
{
var result = secondAllotService.AutoComplete(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 二次绩效录入页面其他模板自动补全
/// </summary>
/// <returns></returns>
[Route("api/second/other/autocomplete")]
[HttpPost]
public ApiResponse OtherAutoComplete([FromBody] SecondEmpRequest request)
{
var result = secondAllotService.OtherAutoComplete(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, result);
}
#region 模板使用
/// <summary>
/// 选择二次绩效模板
......@@ -302,8 +331,7 @@ public ApiResponse SubmitAudit(SubmitAuditRequest request)
[Route("/api/second/audit/list")]
public ApiResponse<List<ag_secondallot>> AuditList([FromBody] AllotDeptRequest request)
{
var userid = claimService.GetUserId();
var list = secondAllotService.AuditList(userid, request.AllotId);
var list = secondAllotService.AuditList(request.AllotId);
return new ApiResponse<List<ag_secondallot>>(ResponseType.OK, "审核列表", list);
}
......@@ -317,6 +345,36 @@ public ApiResponse AuditResult([FromBody] SecondAuditRequest request)
{
var userid = claimService.GetUserId();
var result = secondAllotService.ConfirmAudit(userid, request);
if (request.IsPass == 1)
{
resultComputeService.SaveSecondReserved(request.SecondId);
}
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
/// <summary>
/// 护理部二次绩效审核列表
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("/api/second/audit/nursingdept/list")]
public ApiResponse<List<ag_secondallot>> NursingDeptlist([FromBody] AllotDeptRequest request)
{
var list = secondAllotService.NursingDeptlist(request.AllotId);
return new ApiResponse<List<ag_secondallot>>(ResponseType.OK, "审核列表", list);
}
/// <summary>
/// 护理部二次绩效审核结果;驳回、成功
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("/api/second/audit/nursingdept/result")]
public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
{
var userid = claimService.GetUserId();
var result = secondAllotService.NursingDeptAudit(userid, request);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
#endregion
......
......@@ -25,6 +25,7 @@ public class TemplateController : Controller
{
private readonly TemplateService templateService;
private readonly DFExtractService extractService;
private readonly ExtractIncomeService extractIncomeService;
private HospitalService hospitalService;
private IHostingEnvironment env;
private ClaimService claim;
......@@ -37,6 +38,7 @@ public class TemplateController : Controller
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
DFExtractService extractService,
ExtractIncomeService extractIncomeService,
IHostingEnvironment env,
ClaimService claim,
IOptions<Application> options,
......@@ -47,6 +49,7 @@ public class TemplateController : Controller
{
this.templateService = templateService;
this.extractService = extractService;
this.extractIncomeService = extractIncomeService;
this.hospitalService = hospitalService;
this.env = env;
this.claim = claim;
......@@ -81,6 +84,9 @@ public IActionResult DownFile(int type = 1)
case 4:
path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xls");
break;
case 5:
path = Path.Combine(env.ContentRootPath, "Template", "工作量数据导入模板.xls");
break;
}
var memoryStream = new MemoryStream();
......@@ -407,5 +413,24 @@ public ApiResponse Schedule([FromBody] log_dbug request)
var ratio = allotService.AllotLog(allot, 3)?.Max(t => ConvertHelper.TryDecimal(t.Message)) ?? 0;
return new ApiResponse(ResponseType.OK, new { ratio });
}
[Route("extract/income/{allotId}")]
[AllowAnonymous]
[HttpGet]
public IActionResult ExtractIncome(int allotId)
{
string filepath = extractIncomeService.Execture(allotId);
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
string fileExt = Path.GetExtension(filepath);
var provider = new FileExtensionContentTypeProvider();
var memi = provider.Mappings[fileExt];
return File(memoryStream, memi, Path.GetFileName(filepath));
}
}
}
\ No newline at end of file
......@@ -63,10 +63,8 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
else
{
var executedContext = await next();
if (executedContext.Exception != null)
throw executedContext.Exception;
if (executedContext.Result is ObjectResult)
if (executedContext.Exception == null && executedContext.Result is ObjectResult)
{
_logger.LogInformation("响应结果" + JsonHelper.Serialize(executedContext.Result));
var objectResult = (ObjectResult)executedContext.Result;
......
......@@ -81,7 +81,7 @@ public void ConfigureServices(IServiceCollection services)
json.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include;
json.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
json.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
json.SerializerSettings.Culture = new CultureInfo("it-IT");
json.SerializerSettings.Culture = new CultureInfo("zh-CN");
json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
})
//model验证
......
......@@ -14,7 +14,7 @@
},
"Application": {
//登录过期时间
"ExpirationMinutes": "120",
"ExpirationMinutes": "1200",
//验证码过期
"SmsCodeMinutes": "5",
//护士长二次绩效管理员
......
......@@ -36,6 +36,8 @@
"DirectorRole": "4",
//特殊科室二次绩效管理员
"SpecialRole": "9",
//行政科室二次绩效管理员
"OfficeRole": "10",
//邮件指定接收人
"Receiver": [ "chengxiang.li@suvalue.com", "486035085@qq.com" ],
// 抽取结果Excel文件保存地址
......
......@@ -214,6 +214,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.res_compute">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.res_reserved">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.res_specialunit">
<summary> </summary>
</member>
......@@ -365,6 +368,21 @@
人员名称
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.PerforSumFee">
<summary>
可分配绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.OthePerfor">
<summary>
医院其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.NightWorkPerfor">
<summary>
实发绩效工资金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_compute.RealGiveFee">
<summary>
实发金额
......@@ -760,6 +778,16 @@
实发绩效工资金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_othersource.ReservedRatio">
<summary>
预留比例
</summary>
</member>
<member name="P:Performance.EntityModels.ag_othersource.ReservedAmount">
<summary>
预留金额
</summary>
</member>
<member name="T:Performance.EntityModels.ag_secondallot">
<summary>
二次绩效列表
......@@ -835,6 +863,26 @@
备注
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptStatus">
<summary>
护理部审核状态 1 未提交 2 等待审核 3 审核通过 4 驳回
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptAuditTime">
<summary>
护理部审核时间
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptAuditUser">
<summary>
护理部审核人
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptRemark">
<summary>
护理部备注
</summary>
</member>
<member name="T:Performance.EntityModels.ag_temp">
<summary>
二次绩效模板
......@@ -1805,6 +1853,11 @@
ExTypeId
</summary>
</member>
<member name="P:Performance.EntityModels.ex_script.ConfigId">
<summary>
配置Id
</summary>
</member>
<member name="P:Performance.EntityModels.ex_script.IsEnable">
<summary>
是否可用 1 可用 2 不可用
......@@ -2050,79 +2103,29 @@
保底绩效系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseHeadNumber">
<summary>
护士长人数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseNumber">
<summary>
护士人数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseBasicFactor">
<summary>
护理基础系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseSlopeFactor">
<summary>
倾斜系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseScale">
<summary>
规模绩效系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseEffic">
<summary>
效率绩效系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseGrant">
<summary>
发放系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseOtherPerfor1">
<summary>
其他绩效1
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseOtherPerfor2">
<summary>
其他绩效2
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseExtra">
<summary>
医院奖罚
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseScoringAverage">
<member name="P:Performance.EntityModels.im_accountbasic.UpdateDate">
<summary>
考核对分率
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseAdjustFactor">
<member name="P:Performance.EntityModels.im_accountbasic.UpdateUser">
<summary>
调节系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.WorkSlopeFactor">
<member name="P:Performance.EntityModels.im_accountbasic.AssessBeforeOtherFee">
<summary>
工作量倾斜系数
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.UpdateDate">
<member name="P:Performance.EntityModels.im_accountbasic.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.UpdateUser">
<member name="P:Performance.EntityModels.im_accountbasic.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.im_data">
......@@ -2335,6 +2338,11 @@
其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee.NightWorkPerfor">
<summary>
夜班费
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee.Punishment">
<summary>
医院奖罚
......@@ -2360,6 +2368,21 @@
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.im_employee_clinic">
<summary>
......@@ -2420,6 +2443,11 @@
基础绩效系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.FitPeopleValue">
<summary>
实际人均绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.PostCoefficient">
<summary>
岗位系数
......@@ -2445,6 +2473,11 @@
管理绩效发放系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.OtherManagePerfor">
<summary>
其他管理绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.ScoreAverageRate">
<summary>
考核得分率
......@@ -2495,6 +2528,21 @@
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_clinic.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.im_employee_logistics">
<summary>
......@@ -2595,6 +2643,21 @@
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_logistics.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_logistics.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.im_employee_logistics.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.im_header">
<summary>
......@@ -3030,6 +3093,36 @@
金额
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.TypeInDepartment">
<summary>
录入科室
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.Status">
<summary>
状态 1 未提交 2 等待审核 3 审核通过 4 驳回
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.AuditTime">
<summary>
审核时间
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.AuditUser">
<summary>
审核人
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.CreateDate">
<summary>
......@@ -3510,6 +3603,16 @@
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.HospitalId">
<summary>
医院Id
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.AllotId">
<summary>
绩效Id
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.AccountingUnit">
<summary>
核算单元
......@@ -3585,19 +3688,14 @@
年龄
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.Remark">
<member name="P:Performance.EntityModels.per_employee.ReservedRatio">
<summary>
备注
预留比例
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.HospitalId">
<summary>
医院Id
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.AllotId">
<member name="P:Performance.EntityModels.per_employee.Remark">
<summary>
绩效Id
备注
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.CreateTime">
......@@ -3680,6 +3778,156 @@
数据来源 1 excel 导入 2 计算
</summary>
</member>
<member name="T:Performance.EntityModels.report_original_persontime">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.AllotID">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.Month">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.HospitalID">
<summary>
医院ID
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.SourceType">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.AccountingUnit">
<summary>
科室核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_persontime.PersonTime">
<summary>
人次
</summary>
</member>
<member name="T:Performance.EntityModels.report_original_stays">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.AllotID">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.Month">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.HospitalID">
<summary>
医院ID
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.SourceType">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.AccountingUnit">
<summary>
科室核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_stays.Stays">
<summary>
住院时长
</summary>
</member>
<member name="T:Performance.EntityModels.report_original_surgery">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.AllotID">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.Month">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.HospitalID">
<summary>
医院ID
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.SourceType">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.AccountingUnit">
<summary>
科室核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.report_original_surgery.PersonTime">
<summary>
人次
</summary>
</member>
<member name="T:Performance.EntityModels.report_original_workload">
<summary>
......@@ -4145,6 +4393,26 @@
实发绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_account.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_account.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_account.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_account.AssessLaterPerforTotal">
<summary>
考核后绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_account.Remark">
<summary>
备注
......@@ -4450,6 +4718,16 @@
绩效基数核算参考对象
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.FitPeopleValue">
<summary>
绩效基础核算参考值
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.FitPeopleRatio">
<summary>
绩效基数核算参考对象取值比例(如临床科室护士*95%)
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.EmployeeName">
<summary>
人员姓名
......@@ -4525,6 +4803,11 @@
其他绩效(来自人员名单)
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.NightWorkPerfor">
<summary>
夜班费
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.GiveFee">
<summary>
应发绩效(需计算)
......@@ -4580,6 +4863,11 @@
科主任/护士长人数
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.OtherManagePerfor">
<summary>
其他管理绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.MedicalNumber">
<summary>
核算单元人员数量
......@@ -4590,6 +4878,176 @@
效率绩效人数
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_compute.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.res_reserved">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.HospitalId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.Year">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.EmployeeName">
<summary>
人员姓名
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JobNumber">
<summary>
工号
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JanFee">
<summary>
一月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JanRatio">
<summary>
一月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.FebFee">
<summary>
二月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.FebRatio">
<summary>
二月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.MarFee">
<summary>
三月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.MarRatio">
<summary>
三月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.AprFee">
<summary>
四月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.AprRatio">
<summary>
四月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.MayFee">
<summary>
五月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.MayRatio">
<summary>
五月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JunFee">
<summary>
六月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JunRatio">
<summary>
六月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JulFee">
<summary>
七月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.JulRatio">
<summary>
七月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.AugFee">
<summary>
八月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.AugRatio">
<summary>
八月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.SepFee">
<summary>
九月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.SepRatio">
<summary>
九月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.OctFee">
<summary>
十月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.OctRatio">
<summary>
十月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.NovFee">
<summary>
十一月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.NovRatio">
<summary>
十一月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.DecFee">
<summary>
十二月
</summary>
</member>
<member name="P:Performance.EntityModels.res_reserved.DecRatio">
<summary>
十二月
</summary>
</member>
<member name="T:Performance.EntityModels.res_specialunit">
<summary>
......@@ -4640,6 +5098,11 @@
量化指标绩效分值
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.QuantitativeFee">
<summary>
量化指标绩效金额
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.ScoringAverage">
<summary>
考核得分率
......@@ -4690,6 +5153,26 @@
业绩总绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.PerforTotal">
<summary>
考核前绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.AssessBeforeOtherFee">
<summary>
考核前其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.AssessLaterOtherFee">
<summary>
考核后其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.res_specialunit.AdjustLaterOtherFee">
<summary>
调节后其他绩效
</summary>
</member>
<member name="T:Performance.EntityModels.sys_extract">
<summary>
医院数据提取脚本
......@@ -4800,6 +5283,16 @@
是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenCMIPercent">
<summary>
是否开启科室CMI占比 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenNursingDeptAudit">
<summary>
是否开启护理部审核 1 启用 2 禁用
</summary>
</member>
<member name="T:Performance.EntityModels.sys_hospitalconfig">
<summary>
......
......@@ -31,6 +31,10 @@ public class Application
/// </summary>
public int SpecialRole { get; set; }
/// <summary>
/// 行政科室二次绩效管理员
/// </summary>
public int OfficeRole { get; set; }
/// <summary>
/// 邮件指定接收人
/// </summary>
public string[] Receiver { get; set; }
......
......@@ -70,7 +70,7 @@ public AutoMapperConfigs()
CreateMap<PerData, im_data>()
.ForMember(dest => dest.IsFactor, opt => opt.MapFrom(src => src.IsFactor ? 1 : 2))
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().FirstOrDefault(t => t.Name == src.UnitType).Value));
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().FirstOrDefault(t => t.Name == src.UnitType.Replace("行政工勤", "行政后勤")).Value));
CreateMap<im_header, PerHeader>()
.ForMember(dest => dest.IsMerge, opt => opt.MapFrom(src => src.IsMerge == 1 ? true : false));
......@@ -108,7 +108,7 @@ public AutoMapperConfigs()
//CreateMap<PerDataAccountBaisc, im_accountbasic>();
//CreateMap<im_accountbasic, PerDataAccountBaisc>();
CreateMap<PerDataAccountBaisc, im_accountbasic>()
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType).Value))
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType.Replace("行政工勤", "行政后勤")).Value))
.ForMember(dest => dest.DoctorAccountingUnit, opt => opt.MapFrom(src => src.AccountingUnit))
//.ForMember(dest => dest.Department, opt => opt.MapFrom(src => src.Department))
.ForMember(dest => dest.DoctorDirectorNumber, opt => opt.MapFrom(src => src.ManagerNumber))
......@@ -116,7 +116,7 @@ public AutoMapperConfigs()
.ForMember(dest => dest.DoctorBasicFactor, opt => opt.MapFrom(src => src.BasicFactor))
//.ForMember(dest => dest.DoctorSlopeFactor, opt => opt.MapFrom(src => src.SlopeFactor))
.ForMember(dest => dest.DoctorOtherPerfor1, opt => opt.MapFrom(src => src.OtherPerfor1))
.ForMember(dest => dest.DoctorOtherPerfor2, opt => opt.MapFrom(src => src.OtherPerfor2))
//.ForMember(dest => dest.DoctorOtherPerfor2, opt => opt.MapFrom(src => src.OtherPerfor2))
//.ForMember(dest => dest.DoctorExtra, opt => opt.MapFrom(src => src.Extra))
.ForMember(dest => dest.DoctorScoringAverage, opt => opt.MapFrom(src => src.ScoringAverage))
.ForMember(dest => dest.DoctorAdjustFactor, opt => opt.MapFrom(src => src.AdjustFactor))
......@@ -150,7 +150,7 @@ public AutoMapperConfigs()
CreateMap<res_account, PerDataAccountBaisc>()
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => src.UnitType.HasValue ? ((UnitType)src.UnitType).ToString() : ""));
CreateMap<PerDataAccountBaisc, res_account>()
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => string.IsNullOrEmpty(src.UnitType) ? -1 : EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType).Value));
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => string.IsNullOrEmpty(src.UnitType) ? -1 : EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType.Replace("行政工勤", "行政后勤")).Value));
//CreateMap<PerDataAccountBaisc, res_accountnurse>();
//CreateMap<res_accountdoctor, ComputeSource>();
......@@ -229,6 +229,21 @@ public AutoMapperConfigs()
CreateMap<res_compute, SecondPerforResponse>()
.ReverseMap();
CreateMap<HistoryData, report_original_persontime>()
.ForMember(dest => dest.PersonTime, opt => opt.MapFrom(src => src.ResultData))
.ReverseMap();
CreateMap<HistoryData, report_original_stays>()
.ForMember(dest => dest.Stays, opt => opt.MapFrom(src => src.ResultData))
.ReverseMap();
CreateMap<HistoryData, report_original_surgery>()
.ForMember(dest => dest.PersonTime, opt => opt.MapFrom(src => src.ResultData))
.ReverseMap();
}
public void xx()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class HistoryData
{
/// <summary>
/// 年
/// </summary>
public int Year { get; set; }
/// <summary>
/// 月
/// </summary>
public int Month { get; set; }
/// <summary>
/// 医院ID
/// </summary>
public int HospitalID { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 科室核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 结果值
/// </summary>
public Nullable<decimal> ResultData { get; set; }
public string SheetName { get; set; }
}
}
......@@ -42,6 +42,11 @@ public class ComputeEmployee
public Nullable<decimal> BasicNorm { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string DoctorName { get; set; }
......@@ -77,11 +82,26 @@ public class ComputeEmployee
//public Nullable<DateTime> WorkTime { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 出勤率
/// </summary>
public Nullable<decimal> Attendance { get; set; }
......@@ -135,5 +155,10 @@ public class ComputeEmployee
/// 管理绩效发放系数
/// </summary>
public Nullable<decimal> Management { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
}
}
......@@ -21,12 +21,22 @@ public class ComputeResult
public string FitPeople { get; set; }
/// <summary>
/// 绩效基础核算参考值
/// </summary>
public Nullable<decimal> FitPeopleValue { get; set; }
/// <summary>
/// 绩效基数核算参考对象取值比例(如临床科室护士*95%)
/// </summary>
public Nullable<decimal> FitPeopleRatio { get; set; }
/// <summary>
/// 人员姓名
/// </summary>
public string EmployeeName { get; set; }
/// <summary>
/// 绩效合计(来自科室经济测算表)
/// 绩效合计 考核前(来自科室经济测算表)
/// </summary>
public Nullable<decimal> PerforTotal { get; set; }
......@@ -66,16 +76,31 @@ public class ComputeResult
public Nullable<decimal> ShouldGiveFee { get; set; }
/// <summary>
/// 绩效合计(需计算)
/// 绩效合计 考核前(需计算)
/// </summary>
public Nullable<decimal> PerforSumFee { get; set; }
/// <summary>
/// 考核对分率(来自人员名单)
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 出勤率(来自人员名单)
/// </summary>
public Nullable<decimal> Attendance { get; set; }
......@@ -86,12 +111,17 @@ public class ComputeResult
public Nullable<decimal> Punishment { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 其他绩效(来自人员名单)
/// </summary>
public Nullable<decimal> OtherPerfor { get; set; }
/// <summary>
/// 应发绩效(需计算)
/// 应发绩效 考核前(需计算)
/// </summary>
public Nullable<decimal> GiveFee { get; set; }
......@@ -158,5 +188,10 @@ public class ComputeResult
/// 效率绩效人数
/// </summary>
public Nullable<decimal> PermanentStaff { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
}
}
......@@ -37,8 +37,8 @@ public enum UnitType
行政高层 = 10,
[Description("行政中层")]
行政中层 = 11,
[Description("行政勤")]
行政 = 12,
[Description("行政勤")]
行政 = 12,
}
public enum SheetType
......@@ -94,7 +94,7 @@ public enum SheetType
/// <summary> 特殊临床科室医护绩效测算基础 </summary>
[Description("特殊临床科室医护绩效测算基础")]
AccountBasicSpecial = 16,
/// <summary> 科室绩效医院奖罚 </summary>
[Description("科室绩效医院奖罚")]
AccountExtra = 17,
......@@ -114,6 +114,23 @@ public enum SheetType
/// <summary> 行政后勤 </summary>
[Description("行政后勤")]
LogisticsEmployee = 21,
/// <summary> 科室材料考核 </summary>
[Description("科室考核")]
AccountScoreAverage = 25,
/// <summary> 科室调节后其他绩效 </summary>
[Description("科室调节后其他绩效")]
AccountAdjustLaterOtherFee = 26,
/// <summary> 业务中层行政中高层调节后其他绩效 </summary>
[Description("业务中层行政中高层调节后其他绩效")]
PersonAdjustLaterOtherFee = 27,
/// <summary> 其他工作量(不参与核算) </summary>
[Description("其他工作量")]
OtherWorkload = 28,
}
/// <summary>
......
......@@ -64,9 +64,14 @@ public class PerDataAccountBaisc : IPerData
public decimal OtherPerfor1 { get; set; }
/// <summary>
/// 其他绩效2
/// 考核前其他绩效
/// </summary>
public decimal OtherPerfor2 { get; set; }
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
///// <summary>
///// 其他绩效2
///// </summary>
//public decimal OtherPerfor2 { get; set; }
/// <summary>
/// 药占比奖罚
......@@ -89,11 +94,21 @@ public class PerDataAccountBaisc : IPerData
public decimal ScoringAverage { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节系数
/// </summary>
public decimal AdjustFactor { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 规模绩效系数
/// </summary>
public decimal Scale { get; set; }
......@@ -153,11 +168,16 @@ public class PerDataAccountBaisc : IPerData
public Nullable<decimal> WorkloadFee { get; set; }
/// <summary>
/// 绩效合计
/// 绩效合计 考核前
/// </summary>
public Nullable<decimal> PerforTotal { get; set; }
/// <summary>
/// 绩效合计 考核后
/// </summary>
public Nullable<decimal> AssessLaterPerforTotal { get; set; }
/// <summary>
/// 人均绩效
/// </summary>
public Nullable<decimal> Avg { get; set; }
......
......@@ -37,6 +37,11 @@ public class PerDataClinicEmployee : IPerData
public string JobTitle { get; set; }
/// <summary>
/// 实际人均绩效
/// </summary>
public Nullable<decimal> FitPeopleValue { get; set; }
/// <summary>
/// 基础绩效系数
/// </summary>
public Nullable<decimal> Basics { get; set; }
......@@ -72,11 +77,21 @@ public class PerDataClinicEmployee : IPerData
//public Nullable<DateTime> WorkTime { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 出勤率
/// </summary>
public Nullable<decimal> Attendance { get; set; }
......@@ -84,12 +99,17 @@ public class PerDataClinicEmployee : IPerData
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtheManagementPerfor { get; set; }
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 其他绩效
/// </summary>
public Nullable<decimal> OthePerfor { get; set; }
///// <summary>
///// 其他绩效
///// 夜班费
///// </summary>
//public Nullable<decimal> OthePerfor { get; set; }
//public Nullable<decimal> NightWorkPerfor { get; set; }
///// <summary>
///// 医院奖罚
......@@ -102,6 +122,11 @@ public class PerDataClinicEmployee : IPerData
public Nullable<decimal> Adjust { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 行号
/// </summary>
public int RowNumber { get; set; }
......
......@@ -62,11 +62,26 @@ public class PerDataEmployee : IPerData
//public Nullable<DateTime> WorkTime { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 出勤率
/// </summary>
public Nullable<decimal> Attendance { get; set; }
......@@ -91,6 +106,11 @@ public class PerDataEmployee : IPerData
/// </summary>
public Nullable<decimal> Adjust { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
///// <summary>
///// 发放系数
///// </summary>
......
......@@ -34,7 +34,7 @@ public class PerDataLogisticsEmployee : IPerData
/// <summary>
/// 人员工号
/// </summary>
public string JobNumber { get; set; }
public string PersonnelNumber { get; set; }
/// <summary>
/// 姓名
......@@ -62,6 +62,11 @@ public class PerDataLogisticsEmployee : IPerData
public Nullable<decimal> OthePerfor { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 行号
/// </summary>
public int RowNumber { get; set; }
......
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class AprAmountAuditRequest
{
/// <summary> 二次绩效Id </summary>
public int[] Id { get; set; }
/// <summary> 审核结果 1、审核通过 2、驳回 </summary>
public int IsPass { get; set; }
/// <summary> 备注 </summary>
public string Remark { get; set; }
}
public class AprAmountAuditRequestValidator : AbstractValidator<AprAmountAuditRequest>
{
public AprAmountAuditRequestValidator()
{
RuleFor(x => x.IsPass).NotNull().NotEmpty().InclusiveBetween(1, 2);
}
}
}
......@@ -10,4 +10,8 @@ public class BudgetRequest
public int Year { get; set; }
}
public class BudgetCollectRequest : BudgetRequest
{
public int Month { get; set; }
}
}
......@@ -29,6 +29,11 @@ public class DeptDetailRequest
/// 汇总ID
/// </summary>
public int AccountID { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public int UnitType { get; set; }
}
public class DetailRequestValidator : AbstractValidator<DeptDetailRequest>
{
......
......@@ -55,6 +55,10 @@ public class HospitalRequest
/// 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
/// </summary>
public Nullable<int> IsShowManage { get; set; }
/// <summary>
/// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary>
public Nullable<int> IsOpenCMIPercent { get; set; }
}
public class HospitalRequestValidator : AbstractValidator<HospitalRequest>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ReservedRequest
{
public int HospitalId { get; set; }
public int Year { get; set; }
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class SecondEmpRequest
{
public int TempId { get; set; }
public int SecondId { get; set; }
public string EmployeeName { get; set; }
public string JobNumber { get; set; }
}
public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
{
public SecondEmpRequestValidator()
{
RuleFor(x => x.TempId).NotNull().GreaterThan(0);
RuleFor(x => x.SecondId).NotNull().GreaterThan(0);
}
}
}
......@@ -79,7 +79,7 @@ public UserRequestValidator()
action();
RuleFor(x => x.ID).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.States).InclusiveBetween(1, 2);
RuleFor(x => x.Password).Length(4, 20);
//RuleFor(x => x.Password).Length(4, 20);
RuleFor(x => x.Role).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.HosIDArray).NotNull().NotEmpty().Must(f => f.Length > 0);
});
......
......@@ -8,6 +8,7 @@ namespace Performance.DtoModels
public class WorkDetailRequest
{
public int AllotId { get; set; }
public int SecondId { get; set; }
public string AccountingUnit { get; set; }
}
......@@ -19,6 +20,7 @@ public WorkDetailRequestValidator()
RuleSet("Select", () =>
{
RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.SecondId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AccountingUnit).NotNull().NotEmpty();
});
}
......
......@@ -6,11 +6,24 @@ namespace Performance.DtoModels
{
public class ComputeResponse
{
public ComputeResponse() { }
public ComputeResponse(string source, string accountingUnit, string employeeName, string jobNumber, string jobTitle)
{
Source = source;
AccountingUnit = accountingUnit;
EmployeeName = employeeName;
JobNumber = jobNumber;
JobTitle = jobTitle;
}
/// <summary>
/// 来源
/// </summary>
public string Source { get; set; }
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
......@@ -32,8 +45,43 @@ public class ComputeResponse
public string JobTitle { get; set; }
/// <summary>
/// 业绩绩效
/// </summary>
public Nullable<decimal> PerforSumFee { get; set; }
/// <summary>
/// 管理绩效
/// </summary>
public Nullable<decimal> PerforManagementFee { get; set; }
/// <summary>
/// 应发小计
/// </summary>
public Nullable<decimal> ShouldGiveFee { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public Nullable<decimal> OthePerfor { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 实发绩效
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 预留比例
/// </summary>
public Nullable<decimal> ReservedRatio { get; set; }
/// <summary>
/// 预留比例金额
/// </summary>
public Nullable<decimal> ReservedRatioFee { get; set; }
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
/// <summary>
/// 查看科室绩效详情
/// </summary>
public class DeptIncomeResponse
{
public string Department { get; set; }
public string DoctorName { get; set; }
public string PersonnelNumber { get; set; }
public string Category { get; set; }
public decimal Fee { get; set; }
}
}
......@@ -147,5 +147,18 @@ public class DeptResponse
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -15,6 +15,8 @@ public class DeptdicResponse
public Deptdic InpatDoctorAccounting { get; set; }
public Deptdic InpatNurseAccounting { get; set; }
public Deptdic InpatTechnicAccounting { get; set; }
public Deptdic LogisticsAccounting { get; set; }
public Deptdic SpecialAccounting { get; set; }
public DateTime? CreateTime { get; set; }
}
......
......@@ -19,5 +19,13 @@ public class HospitalResponse
public int IsOpenIncome { get; set; }
public int IsOpenDirector { get; set; }
public int IsShowManage { get; set; }
/// <summary>
/// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary>
public int IsOpenCMIPercent { get; set; }
/// <summary>
/// 是否开启护理部审核 1 启用 2 禁用
/// </summary>
public int IsOpenNursingDeptAudit { get; set; }
}
}
......@@ -30,6 +30,8 @@ public class ResComputeResponse
/// 绩效基数核算参考对象
/// </summary>
public string FitPeople { get; set; }
public string FitPeopleValue { get; set; }
public string FitPeopleRatio { get; set; }
/// <summary>
/// 人员姓名
......@@ -72,6 +74,11 @@ public class ResComputeResponse
public Nullable<decimal> Scale { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 岗位系数
/// </summary>
public Nullable<decimal> PostCoefficient { get; set; }
......@@ -165,5 +172,30 @@ public class ResComputeResponse
/// 效率绩效人数
/// </summary>
public Nullable<decimal> PermanentStaff { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public Nullable<decimal> OtherPerformance { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -150,7 +150,10 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<rep_report> rep_report { get; set; }
/// <summary> 条件表 </summary>
public virtual DbSet<rep_selection> rep_selection { get; set; }
/// <summary> 科室核算结果 </summary>
public virtual DbSet<report_original_surgery> report_original_surgery { get; set; }
public virtual DbSet<report_original_stays> report_original_stays { get; set; }
public virtual DbSet<report_original_persontime> report_original_persontime { get; set; }
/// <summary> 科室核算结果 </summary>
public virtual DbSet<res_account> res_account { get; set; }
/// <summary> 医生科室核算结果 </summary>
public virtual DbSet<res_accountdoctor> res_accountdoctor { get; set; }
......@@ -161,6 +164,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> </summary>
public virtual DbSet<res_compute> res_compute { get; set; }
/// <summary> </summary>
public virtual DbSet<res_reserved> res_reserved { get; set; }
/// <summary> </summary>
public virtual DbSet<res_specialunit> res_specialunit { get; set; }
/// <summary> 医院数据提取脚本 </summary>
public virtual DbSet<sys_extract> sys_extract { get; set; }
......
......@@ -7,50 +7,66 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
/// 二次绩效结果表
/// </summary>
[Table("ag_compute")]
public class ag_compute
public class ag_compute
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
public int Id { get; set; }
/// <summary>
/// 绩效ID
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 二次绩效ID
/// </summary>
public Nullable<int> SecondId { get; set; }
public string UnitType { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 职称
/// </summary>
public string WorkPost { get; set; }
/// <summary>
/// 工号
/// </summary>
public string JobNumber { get; set; }
/// <summary>
/// 人员名称
/// </summary>
public string PersonName { get; set; }
/// <summary>
/// 可分配绩效
/// </summary>
public Nullable<decimal> PerforSumFee { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public Nullable<decimal> OthePerfor { get; set; }
/// <summary>
/// 实发绩效工资金额
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 实发金额
/// </summary>
......
......@@ -80,5 +80,15 @@ public class ag_othersource
/// 实发绩效工资金额
/// </summary>
public Nullable<decimal> RealAmount { get; set; }
/// <summary>
/// 预留比例
/// </summary>
public Nullable<decimal> ReservedRatio { get; set; }
/// <summary>
/// 预留金额
/// </summary>
public Nullable<decimal> ReservedAmount { get; set; }
}
}
......@@ -85,5 +85,25 @@ public class ag_secondallot
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 护理部审核状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary>
public Nullable<int> NursingDeptStatus { get; set; }
/// <summary>
/// 护理部审核时间
/// </summary>
public Nullable<DateTime> NursingDeptAuditTime { get; set; }
/// <summary>
/// 护理部审核人
/// </summary>
public Nullable<int> NursingDeptAuditUser { get; set; }
/// <summary>
/// 护理部备注
/// </summary>
public string NursingDeptRemark { get; set; }
}
}
......@@ -7,35 +7,40 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("ex_script")]
public class ex_script
public class ex_script
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
public int Id { get; set; }
/// <summary>
/// 执行sql
/// </summary>
public string ExecScript { get; set; }
/// <summary>
/// 数据库类型1、Sql Server 2、Orcale
/// </summary>
public int DatabaseType { get; set; }
/// <summary>
/// ExTypeId
/// </summary>
public int TypeId { get; set; }
/// <summary>
/// 配置Id
/// </summary>
public int ConfigId { get; set; }
/// <summary>
/// 是否可用 1 可用 2 不可用
/// </summary>
......
......@@ -141,70 +141,70 @@ public class im_accountbasic
/// </summary>
public Nullable<decimal> MinimumFactor { get; set; }
/// <summary>
/// 护士长人数
/// </summary>
public Nullable<decimal> NurseHeadNumber { get; set; }
///// <summary>
///// 护士长人数
///// </summary>
//public Nullable<decimal> NurseHeadNumber { get; set; }
/// <summary>
/// 护士人数
/// </summary>
public Nullable<decimal> NurseNumber { get; set; }
///// <summary>
///// 护士人数
///// </summary>
//public Nullable<decimal> NurseNumber { get; set; }
/// <summary>
/// 护理基础系数
/// </summary>
public Nullable<decimal> NurseBasicFactor { get; set; }
///// <summary>
///// 护理基础系数
///// </summary>
//public Nullable<decimal> NurseBasicFactor { get; set; }
/// <summary>
/// 倾斜系数
/// </summary>
public Nullable<decimal> NurseSlopeFactor { get; set; }
///// <summary>
///// 倾斜系数
///// </summary>
//public Nullable<decimal> NurseSlopeFactor { get; set; }
/// <summary>
/// 规模绩效系数
/// </summary>
public Nullable<decimal> NurseScale { get; set; }
///// <summary>
///// 规模绩效系数
///// </summary>
//public Nullable<decimal> NurseScale { get; set; }
/// <summary>
/// 效率绩效系数
/// </summary>
public Nullable<decimal> NurseEffic { get; set; }
///// <summary>
///// 效率绩效系数
///// </summary>
//public Nullable<decimal> NurseEffic { get; set; }
/// <summary>
/// 发放系数
/// </summary>
public Nullable<decimal> NurseGrant { get; set; }
///// <summary>
///// 发放系数
///// </summary>
//public Nullable<decimal> NurseGrant { get; set; }
/// <summary>
/// 其他绩效1
/// </summary>
public Nullable<decimal> NurseOtherPerfor1 { get; set; }
///// <summary>
///// 其他绩效1
///// </summary>
//public Nullable<decimal> NurseOtherPerfor1 { get; set; }
/// <summary>
/// 其他绩效2
/// </summary>
public Nullable<decimal> NurseOtherPerfor2 { get; set; }
///// <summary>
///// 其他绩效2
///// </summary>
//public Nullable<decimal> NurseOtherPerfor2 { get; set; }
/// <summary>
/// 医院奖罚
/// </summary>
public Nullable<decimal> NurseExtra { get; set; }
///// <summary>
///// 医院奖罚
///// </summary>
//public Nullable<decimal> NurseExtra { get; set; }
/// <summary>
/// 考核对分率
/// </summary>
public Nullable<decimal> NurseScoringAverage { get; set; }
///// <summary>
///// 考核对分率
///// </summary>
//public Nullable<decimal> NurseScoringAverage { get; set; }
/// <summary>
/// 调节系数
/// </summary>
public Nullable<decimal> NurseAdjustFactor { get; set; }
///// <summary>
///// 调节系数
///// </summary>
//public Nullable<decimal> NurseAdjustFactor { get; set; }
/// <summary>
/// 工作量倾斜系数
/// </summary>
public Nullable<decimal> WorkSlopeFactor { get; set; }
///// <summary>
///// 工作量倾斜系数
///// </summary>
//public Nullable<decimal> WorkSlopeFactor { get; set; }
/// <summary>
///
......@@ -215,5 +215,18 @@ public class im_accountbasic
///
/// </summary>
public Nullable<int> UpdateUser { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -115,6 +115,11 @@ public class im_employee
/// 其他绩效
/// </summary>
public Nullable<decimal> OtherPerfor { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 医院奖罚
......@@ -140,5 +145,17 @@ public class im_employee
///
/// </summary>
public Nullable<int> UpdateUser { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -72,6 +72,11 @@ public class im_employee_clinic
public Nullable<decimal> Basics { get; set; }
/// <summary>
/// 实际人均绩效
/// </summary>
public Nullable<decimal> FitPeopleValue { get; set; }
/// <summary>
/// 岗位系数
/// </summary>
public Nullable<decimal> PostCoefficient { get; set; }
......@@ -97,6 +102,11 @@ public class im_employee_clinic
public Nullable<decimal> Management { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
......@@ -145,5 +155,17 @@ public class im_employee_clinic
///
/// </summary>
public Nullable<int> UpdateUser { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -140,5 +140,18 @@ public class im_employee_logistics
///
/// </summary>
public Nullable<int> UpdateUser { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -45,7 +45,37 @@ public class per_apr_amount
/// 金额
/// </summary>
public Nullable<decimal> Amount { get; set; }
/// <summary>
/// 录入科室
/// </summary>
public string TypeInDepartment { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary>
public int Status { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public Nullable<DateTime> AuditTime { get; set; }
/// <summary>
/// 审核人
/// </summary>
public Nullable<int> AuditUser { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
///
/// </summary>
......
......@@ -22,6 +22,16 @@ public class per_employee
public int Id { get; set; }
/// <summary>
/// 医院Id
/// </summary>
public Nullable<int> HospitalId { get; set; }
/// <summary>
/// 绩效Id
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
......@@ -97,19 +107,14 @@ public class per_employee
public Nullable<int> Age { get; set; }
/// <summary>
/// 备注
/// 预留比例
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 医院Id
/// </summary>
public Nullable<int> HospitalId { get; set; }
public Nullable<decimal> ReservedRatio { get; set; }
/// <summary>
/// 绩效Id
/// 备注
/// </summary>
public Nullable<int> AllotId { get; set; }
public string Remark { get; set; }
/// <summary>
///
......
//-----------------------------------------------------------------------
// <copyright file=" report_original_workload.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("report_original_persontime")]
public class report_original_persontime
{
/// <summary>
///
/// </summary>
[Key]
public int Id { 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>
/// 医院ID
/// </summary>
public int HospitalID { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 科室核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 人次
/// </summary>
public Nullable<int> PersonTime { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" report_original_workload.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("report_original_stays")]
public class report_original_stays
{
/// <summary>
///
/// </summary>
[Key]
public int Id { 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>
/// 医院ID
/// </summary>
public int HospitalID { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 科室核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 住院时长
/// </summary>
public Nullable<decimal> Stays { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" report_original_workload.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("report_original_surgery")]
public class report_original_surgery
{
/// <summary>
///
/// </summary>
[Key]
public int Id { 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>
/// 医院ID
/// </summary>
public int HospitalID { get; set; }
/// <summary>
///
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 科室核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 人次
/// </summary>
public Nullable<int> PersonTime { get; set; }
}
}
......@@ -7,7 +7,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
///
......
......@@ -160,7 +160,24 @@ public class res_account
/// 实发绩效
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
/// <summary>
/// 考核后绩效
/// </summary>
public Nullable<decimal> AssessLaterPerforTotal { get; set; }
/// <summary>
/// 备注
/// </summary>
......
......@@ -7,25 +7,25 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("res_compute")]
public class res_compute
public class res_compute
{
/// <summary>
///
/// </summary>
[Key]
public int ID { get; set; }
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// sheet页id
/// </summary>
......@@ -40,155 +40,188 @@ public class res_compute
/// 核算单元类型(医技科室、临床科室等)
/// </summary>
public string AccountType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 绩效基数核算参考对象
/// </summary>
public string FitPeople { get; set; }
/// <summary>
/// 绩效基础核算参考值
/// </summary>
public Nullable<decimal> FitPeopleValue { get; set; }
/// <summary>
/// 绩效基数核算参考对象取值比例(如临床科室护士*95%)
/// </summary>
public Nullable<decimal> FitPeopleRatio { get; set; }
/// <summary>
/// 人员姓名
/// </summary>
public string EmployeeName { get; set; }
/// <summary>
/// 职称
/// </summary>
public string JobTitle { get; set; }
/// <summary>
/// 工号
/// </summary>
public string JobNumber { get; set; }
/// <summary>
/// 绩效合计(来自科室经济测算表)
/// </summary>
public Nullable<decimal> PerforTotal { get; set; }
/// <summary>
/// 核算单元医生数量(来自科室经济测算表)
/// </summary>
public Nullable<decimal> Number { get; set; }
/// <summary>
/// 人均绩效(来自科室经济测算表)
/// </summary>
public Nullable<decimal> Avg { get; set; }
/// <summary>
/// 效率绩效(需计算)
/// </summary>
public Nullable<decimal> Efficiency { get; set; }
/// <summary>
/// 规模绩效(需计算)
/// </summary>
public Nullable<decimal> Scale { get; set; }
/// <summary>
/// 岗位系数
/// </summary>
public Nullable<decimal> PostCoefficient { get; set; }
/// <summary>
/// 发放系数(来自人员名单)
/// </summary>
public Nullable<decimal> Grant { get; set; }
/// <summary>
/// 应发管理绩效(需计算,科主任护士长独有)
/// </summary>
public Nullable<decimal> ShouldGiveFee { get; set; }
/// <summary>
/// 绩效合计(需计算)
/// </summary>
public Nullable<decimal> PerforSumFee { get; set; }
/// <summary>
/// 考核对分率(来自人员名单)
/// </summary>
public Nullable<decimal> ScoreAverageRate { get; set; }
/// <summary>
/// 医院奖罚(来自人员名单)
/// </summary>
public Nullable<decimal> Punishment { get; set; }
/// <summary>
/// 其他绩效(来自人员名单)
/// </summary>
public Nullable<decimal> OtherPerfor { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightWorkPerfor { get; set; }
/// <summary>
/// 应发绩效(需计算)
/// </summary>
public Nullable<decimal> GiveFee { get; set; }
/// <summary>
/// 出勤率(来自人员名单)
/// </summary>
public Nullable<decimal> Attendance { get; set; }
/// <summary>
/// 参加工作时间(来自人员名单)
/// </summary>
public Nullable<DateTime> WorkTime { get; set; }
/// <summary>
/// 绩效基础金额(计算)
/// </summary>
public Nullable<decimal> BaiscNormValue { get; set; }
/// <summary>
/// 年资系数(来自人员名单)
/// </summary>
public Nullable<decimal> WorkYear { get; set; }
/// <summary>
/// 调节系数
/// </summary>
public Nullable<decimal> Adjust { get; set; }
/// <summary>
/// 工作量绩效
/// </summary>
public Nullable<decimal> Workload { get; set; }
/// <summary>
/// 实发绩效
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 变更日志
/// </summary>
public string ChangeLog { get; set; }
/// <summary>
///
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 科主任/护士长人数
/// </summary>
public Nullable<decimal> ManagerNumber { get; set; }
/// <summary>
/// 其他管理绩效
/// </summary>
public Nullable<decimal> OtherManagePerfor { get; set; }
/// <summary>
/// 核算单元人员数量
/// </summary>
public Nullable<decimal> MedicalNumber { get; set; }
/// <summary>
/// 效率绩效人数
/// </summary>
public Nullable<decimal> PermanentStaff { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" res_reserved.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("res_reserved")]
public class res_reserved
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int HospitalId { get; set; }
/// <summary>
///
/// </summary>
public int Year { get; set; }
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 人员姓名
/// </summary>
public string EmployeeName { get; set; }
/// <summary>
/// 工号
/// </summary>
public string JobNumber { get; set; }
/// <summary>
/// 一月
/// </summary>
public Nullable<decimal> JanFee { get; set; }
/// <summary>
/// 一月
/// </summary>
public Nullable<decimal> JanRatio { get; set; }
/// <summary>
/// 二月
/// </summary>
public Nullable<decimal> FebFee { get; set; }
/// <summary>
/// 二月
/// </summary>
public Nullable<decimal> FebRatio { get; set; }
/// <summary>
/// 三月
/// </summary>
public Nullable<decimal> MarFee { get; set; }
/// <summary>
/// 三月
/// </summary>
public Nullable<decimal> MarRatio { get; set; }
/// <summary>
/// 四月
/// </summary>
public Nullable<decimal> AprFee { get; set; }
/// <summary>
/// 四月
/// </summary>
public Nullable<decimal> AprRatio { get; set; }
/// <summary>
/// 五月
/// </summary>
public Nullable<decimal> MayFee { get; set; }
/// <summary>
/// 五月
/// </summary>
public Nullable<decimal> MayRatio { get; set; }
/// <summary>
/// 六月
/// </summary>
public Nullable<decimal> JunFee { get; set; }
/// <summary>
/// 六月
/// </summary>
public Nullable<decimal> JunRatio { get; set; }
/// <summary>
/// 七月
/// </summary>
public Nullable<decimal> JulFee { get; set; }
/// <summary>
/// 七月
/// </summary>
public Nullable<decimal> JulRatio { get; set; }
/// <summary>
/// 八月
/// </summary>
public Nullable<decimal> AugFee { get; set; }
/// <summary>
/// 八月
/// </summary>
public Nullable<decimal> AugRatio { get; set; }
/// <summary>
/// 九月
/// </summary>
public Nullable<decimal> SepFee { get; set; }
/// <summary>
/// 九月
/// </summary>
public Nullable<decimal> SepRatio { get; set; }
/// <summary>
/// 十月
/// </summary>
public Nullable<decimal> OctFee { get; set; }
/// <summary>
/// 十月
/// </summary>
public Nullable<decimal> OctRatio { get; set; }
/// <summary>
/// 十一月
/// </summary>
public Nullable<decimal> NovFee { get; set; }
/// <summary>
/// 十一月
/// </summary>
public Nullable<decimal> NovRatio { get; set; }
/// <summary>
/// 十二月
/// </summary>
public Nullable<decimal> DecFee { get; set; }
/// <summary>
/// 十二月
/// </summary>
public Nullable<decimal> DecRatio { get; set; }
}
}
......@@ -62,6 +62,11 @@ public class res_specialunit
public Nullable<decimal> QuantitativeIndicatorsValue { get; set; }
/// <summary>
/// 量化指标绩效金额
/// </summary>
public Nullable<decimal> QuantitativeFee { get; set; }
/// <summary>
/// 考核得分率
/// </summary>
public Nullable<decimal> ScoringAverage { get; set; }
......@@ -110,5 +115,21 @@ public class res_specialunit
/// 业绩总绩效
/// </summary>
public Nullable<decimal> ResultsTotalFee { get; set; }
/// <summary>
/// 考核前绩效
/// </summary>
public Nullable<decimal> PerforTotal { get; set; }
/// <summary>
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
}
}
......@@ -85,5 +85,15 @@ public class sys_hospital
/// 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
/// </summary>
public Nullable<int> IsShowManage { get; set; }
/// <summary>
/// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary>
public Nullable<int> IsOpenCMIPercent { get; set; }
/// <summary>
/// 是否开启护理部审核 1 启用 2 禁用
/// </summary>
public Nullable<int> IsOpenNursingDeptAudit { get; set; }
}
}
......@@ -35,6 +35,10 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param) where T : class,
{
return context.Database.GetDbConnection().Query<T>(sql, param);
}
public T DapperQueryFirstOrDefault<T>(string sql, object param)
{
return context.Database.GetDbConnection().QueryFirstOrDefault<T>(sql, param);
}
public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeout = null)
{
......@@ -80,6 +84,14 @@ public bool RemoveRange(params TEntity[] entities)
context.Set<TEntity>().RemoveRange(entities);
return context.SaveChanges() > 0;
}
public bool RemoveRange(Expression<Func<TEntity, bool>> exp)
{
var query = CompileQuery(exp);
var entities = query == null || query.Count() == 0 ? null : query.ToList();
if (entities != null)
context.Set<TEntity>().RemoveRange(entities);
return context.SaveChanges() > 0;
}
public bool Update(TEntity entity)
{
......
......@@ -158,15 +158,54 @@ public void ImportWorkloadData(per_allot allot, object parameters)
/// 查询工作量数据
/// </summary>
/// <param name="allotid"></param>
public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string[] unittype)
public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string unittype, int hospitalid)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = "select t1.* from report_original_workload t1 join per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber where t1.allotid = @allotid and t1.accountingunit = @accountingunit and t1.accountingunit = @accountingunit and t2.unittype in @unittype order by fee desc,convert(t1.doctorname using gbk);";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittype }, commandTimeout: 60 * 60);
string clear = @"SELECT t3.AccountingUnit as Department,t1.DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t2.allotid = @allotid
AND t3.unittype = @unittype
AND t3.accountingunit = @accountingunit
AND t1.Source LIKE CONCAT('%',@unittype,'工作量%')
AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
{
throw ex;
}
}
}
/// <summary>
/// 查询门诊收入数据
/// </summary>
/// <param name="allotid"></param>
public IEnumerable<ex_result> QueryIncomeData(int allotid, string accountingunit, string unittype, int hospitalid)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = @"SELECT t3.AccountingUnit as Department,t1.DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t2.allotid = @allotid
AND t3.unittype = @unittype
AND t3.accountingunit = @accountingunit
AND t1.Source like '%门诊开单%'
AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
{
......
//-----------------------------------------------------------------------
// <copyright file=" ag_header.cs">
// * FileName: ag_header.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// report_original_persontime Repository
/// </summary>
public partial class PerforReportoriginalpersontimeRepository : PerforRepository<report_original_persontime>
{
public PerforReportoriginalpersontimeRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_header.cs">
// * FileName: ag_header.cs
// </copyright>
//-----------------------------------------------------------------------
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// report_original_stays Repository
/// </summary>
public partial class PerforReportoriginalstaysRepository : PerforRepository<report_original_stays>
{
public PerforReportoriginalstaysRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_header.cs">
// * FileName: ag_header.cs
// </copyright>
//-----------------------------------------------------------------------
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// report_original_surgery Repository
/// </summary>
public partial class PerforReportoriginalsurgeryRepository : PerforRepository<report_original_surgery>
{
public PerforReportoriginalsurgeryRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" cof_guarantee.cs">
// * FileName: cof_guarantee.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// cof_guarantee Repository
/// </summary>
public partial class PerforresreservedRepository : PerforRepository<res_reserved>
{
public PerforresreservedRepository(PerformanceDbContext context) : base(context)
{
}
}
}
......@@ -82,7 +82,8 @@ private List<PerAgainData> SlideRowRead(ISheet sheet, PerHeader header, int r, I
for (int c = 0; c < header.Children.Count(); c++)
{
var athead = header.Children.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
var factorValue = ConvertHelper.To<decimal?>(sheet.GetRow(FactorRow).GetCell(athead.PointCell)?.ToString());
......
......@@ -64,170 +64,170 @@ public class AgainAllotService : IAutoInjection
this.configService = configService;
}
/// <summary>
/// 生成二次绩效
/// </summary>
/// <param name="request"></param>
public bool Generate(AgainAllotRequest request, int userId, string department)
{
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在");
var roles = roleService.GetRole(userId);
perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
//清理二次绩效无用数据
configService.ClearAgain(againAllot.ID);
try
{
#region 基础信息
//获取基础配置信息
var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
decimal? basicnumber = 0m;
//获取科室实发绩效
if (roles != null)
{
var role = roles.FirstOrDefault();
if (role != null)
{
if (application.NurseRole == role.Type)
basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
else if (application.DirectorRole == role.Type)
basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
}
}
#endregion
#region 计算
//读取二次计算excel数据
var perAgainExcel = againService.ReadData(againAllot);
//护士长或科主任出勤
var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
//计算职称出勤系数、年资出勤系数
foreach (var item in perAgainExcel.AgainEmployee)
{
item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
}
//计算 科室系数人均
var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
//二次分配科室概览
PerAgainSituation situation = new PerAgainSituation
{
NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
DepartmentTotal = basicnumber,
BossPerfor = departmentFactorAvg * bossAttendance / days,
Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
Attendance = days,
DepartmentFactorAvg = departmentFactorAvg
};
//业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
situation.JobPerfor = situation.AllotPerfor * jobfactor;
situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
//业绩二次分配科室动态数据:工作量得分
foreach (var rowNumber in rowList)
{
var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
decimal? sumValue = 0m;
foreach (var atRow in atRowList)
sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
sumValue = sumValue * againEmployee?.YearFactor;
var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
if (head == null)
{
perAgainExcel.Header.MergeCell++;
var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
perAgainExcel.Header.Children.Add(head);
}
perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
}
//业绩二次分配科室动态数据:绩效工资
foreach (var rowNumber in rowList)
{
var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue;
var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue);
var perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
if (head == null)
{
perAgainExcel.Header.MergeCell++;
var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
perAgainExcel.Header.Children.Add(head);
}
perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
}
//业绩二次分配科室:应发绩效、实发绩效
string[] jobArray = new string[] { "护士长", "科主任" };
foreach (var employee in perAgainExcel.AgainEmployee)
{
if (jobArray.Contains(employee.JobTitle))
{
employee.GiveFee = situation.BossPerfor;
employee.RealGiveFee = situation.BossPerfor;
}
else
{
employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor);
var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue;
employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
}
}
#endregion
#region 保存
var againsituation = Mapper.Map<ag_againsituation>(situation);
againsituation.AllotID = againAllot.AllotID;
againsituation.AgainAllotID = againAllot.ID;
perforAgagainsituationRepository.Add(againsituation);
var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgemployeeRepository.AddRange(employeeList.ToArray());
var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header);
pHeader.AllotID = againAllot.AllotID;
pHeader.AgainAllotID = againAllot.ID;
var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgheaderRepository.Add(pHeader);
perforAgheaderRepository.AddRange(cHeaderList.ToArray());
var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgdataRepository.AddRange(dataList.ToArray());
#endregion
}
catch (Exception ex)
{
perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
}
perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
return true;
//return SheetFormat(perAgainExcel, situation);
}
///// <summary>
///// 生成二次绩效
///// </summary>
///// <param name="request"></param>
//public bool Generate(AgainAllotRequest request, int userId, string department)
//{
// var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
// if (againAllot == null || againAllot.ID == 0)
// throw new PerformanceException("绩效二次分配不存在");
// var roles = roleService.GetRole(userId);
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
// //清理二次绩效无用数据
// configService.ClearAgain(againAllot.ID);
// try
// {
// #region 基础信息
// //获取基础配置信息
// var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
// var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
// var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
// var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
// decimal? basicnumber = 0m;
// //获取科室实发绩效
// if (roles != null)
// {
// var role = roles.FirstOrDefault();
// if (role != null)
// {
// if (application.NurseRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// else if (application.DirectorRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// }
// }
// #endregion
// #region 计算
// //读取二次计算excel数据
// var perAgainExcel = againService.ReadData(againAllot);
// //护士长或科主任出勤
// var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
// //计算职称出勤系数、年资出勤系数
// foreach (var item in perAgainExcel.AgainEmployee)
// {
// item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
// item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
// }
// //计算 科室系数人均
// var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
// //二次分配科室概览
// PerAgainSituation situation = new PerAgainSituation
// {
// NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
// DepartmentTotal = basicnumber,
// BossPerfor = departmentFactorAvg * bossAttendance / days,
// Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
// Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
// AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
// Attendance = days,
// DepartmentFactorAvg = departmentFactorAvg
// };
// //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
// situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
// situation.JobPerfor = situation.AllotPerfor * jobfactor;
// situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
// var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
// //业绩二次分配科室动态数据:工作量得分
// foreach (var rowNumber in rowList)
// {
// var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
// var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
// decimal? sumValue = 0m;
// foreach (var atRow in atRowList)
// sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
// sumValue = sumValue * againEmployee?.YearFactor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
// if (head == null)
// {
// perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head);
// }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
// }
// //业绩二次分配科室动态数据:绩效工资
// foreach (var rowNumber in rowList)
// {
// var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue;
// var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue);
// var perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
// if (head == null)
// {
// perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head);
// }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
// }
// //业绩二次分配科室:应发绩效、实发绩效
// string[] jobArray = new string[] { "护士长", "科主任" };
// foreach (var employee in perAgainExcel.AgainEmployee)
// {
// if (jobArray.Contains(employee.JobTitle))
// {
// employee.GiveFee = situation.BossPerfor;
// employee.RealGiveFee = situation.BossPerfor;
// }
// else
// {
// employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor);
// var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue;
// employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
// employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
// }
// }
// #endregion
// #region 保存
// var againsituation = Mapper.Map<ag_againsituation>(situation);
// againsituation.AllotID = againAllot.AllotID;
// againsituation.AgainAllotID = againAllot.ID;
// perforAgagainsituationRepository.Add(againsituation);
// var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgemployeeRepository.AddRange(employeeList.ToArray());
// var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header);
// pHeader.AllotID = againAllot.AllotID;
// pHeader.AgainAllotID = againAllot.ID;
// var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgheaderRepository.Add(pHeader);
// perforAgheaderRepository.AddRange(cHeaderList.ToArray());
// var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgdataRepository.AddRange(dataList.ToArray());
// #endregion
// }
// catch (Exception ex)
// {
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
// }
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
// return true;
// //return SheetFormat(perAgainExcel, situation);
//}
/// <summary>
/// 绩效详情表格转换
......
......@@ -207,7 +207,7 @@ private int SaveClinicEmployee(PerSheet sheet, int allotId)
var imdata = Mapper.Map<im_employee_clinic>(data);
imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId;
//imdata.OtherPerfor = data.OthePerfor;
imdata.OtherPerfor = data.OthePerfor;
addList.Add(imdata);
}
perforImemployeeclinicRepository.AddRange(addList.ToArray());
......
......@@ -30,6 +30,8 @@ public class ProcessComputService : IAutoInjection
private readonly PerforRescomputeRepository perforRescomputeRepository;
private readonly LogManageService logManageService;
private readonly GuaranteeService guaranteeService;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerallotRepository perallotRepository;
public ProcessComputService(PerforCofincomeRepository perforCofincomeRepository,
PerforCofdrugpropRepository perforCofdrugpropRepository,
......@@ -44,7 +46,9 @@ public class ProcessComputService : IAutoInjection
PerforCofcmiRepository perforCofcmiRepository,
PerforRescomputeRepository perforRescomputeRepository,
LogManageService logManageService,
GuaranteeService guaranteeService)
GuaranteeService guaranteeService,
PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository)
{
this.perforCofincomeRepository = perforCofincomeRepository;
this.perforCofdrugpropRepository = perforCofdrugpropRepository;
......@@ -60,6 +64,8 @@ public class ProcessComputService : IAutoInjection
this.perforRescomputeRepository = perforRescomputeRepository;
this.logManageService = logManageService;
this.guaranteeService = guaranteeService;
this.hospitalRepository = hospitalRepository;
this.perallotRepository = perallotRepository;
}
///// <summary>
......@@ -177,6 +183,11 @@ public void Save(List<PerSheet> perSheets, int allotId)
/// </summary>
public (List<PerSheet> Sheets, List<PerSheet> MergeSheets) MergeCompute(PerExcel excel, int allotid)
{
var allot = perallotRepository.GetEntity(t => t.ID == allotid);
if (allot == null) throw new ArgumentNullException(nameof(per_allot));
var hospital = hospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
if (hospital == null) throw new ArgumentNullException(nameof(sys_hospital));
List<PerSheet> perSheet = new List<PerSheet>();
//合并科室收入、支出
......@@ -209,7 +220,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
//var onceWorkload1 = workloadCompute.OnceCompute(workload1, confs);
//医生组 二次计算
logManageService.WriteMsg("正在生成绩效", "医生组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1, confs, cmis, conitem, true);
var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1, hospital, confs, cmis, conitem, true);
twiceWorkloadResult1.Sheet.SheetType = SheetType.ComputeDoctorWorkload;
perSheet.Add(twiceWorkloadResult1.Sheet);
......@@ -220,7 +231,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
//var onceWorkload2 = workloadCompute.OnceCompute(workload2);
//护理组 二次计算
logManageService.WriteMsg("正在生成绩效", "护理组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2, confs, cmis, conitem);
var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2, hospital, confs, cmis, conitem);
twiceWorkloadResult2.Sheet.SheetType = SheetType.ComputeNurseWorkload;
perSheet.Add(twiceWorkloadResult2.Sheet);
......@@ -249,7 +260,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
/// <param name="perSheet"></param>
/// <returns></returns>
public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, IEnumerable<AccountUnitTotal> extras,
IEnumerable<AccountUnitTotal> drugExtras, IEnumerable<AccountUnitTotal> materialsExtras)
IEnumerable<AccountUnitTotal> drugExtras, IEnumerable<AccountUnitTotal> materialsExtras, IEnumerable<AccountUnitTotal> accountScoreAverages)
{
var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t);
var economicData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeEconomic)?.PerData?.Select(t => (PerData)t);
......@@ -276,6 +287,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
var extra = extras?.FirstOrDefault(w => w.UnitType == unitType.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var drugExtra = drugExtras?.FirstOrDefault(w => w.UnitType == unitType.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var materialsExtra = materialsExtras?.FirstOrDefault(w => w.UnitType == unitType.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == unitType.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var econDoctor = economicData.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
......@@ -288,16 +300,21 @@ public void Save(List<PerSheet> perSheets, int allotId)
workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit);
dept.MedicineFactor = workDoctor?.MedicineFactor;
dept.ScoringAverage = dept.ScoringAverage == 0m ? 0 : dept.ScoringAverage;
//dept.ScoringAverage = scoreAverage.HasValue ? scoreAverage ?? 0 : dept.ScoringAverage;
dept.ScoringAverage = dept.ScoringAverage;
dept.AdjustFactor = dept.AdjustFactor == 0m ? 1 : dept.AdjustFactor;
dept.Income = econDoctor?.CellValue ?? 0;
dept.WorkloadFee = workDoctor?.CellValue ?? 0;
dept.AssessBeforeOtherFee = dept?.AssessBeforeOtherFee ?? 0;
dept.AssessLaterOtherFee = dept?.AssessLaterOtherFee ?? 0;
dept.AdjustLaterOtherFee = dept?.AdjustLaterOtherFee ?? 0;
dept.Extra = (extra ?? 0);
dept.MedicineExtra = (drugExtra ?? 0);
dept.MaterialsExtra = (materialsExtra ?? 0);
dept.PerforFee = dept.Income * dept.BasicFactor;
dept.PerforTotal = Math.Round((dept.PerforFee + dept.WorkloadFee + dept.OtherPerfor1) ?? 0);
dept.RealGiveFee = Math.Round(((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.OtherPerfor2 + (extra ?? 0)) * dept.AdjustFactor) ?? 0);
dept.PerforTotal = Math.Round((dept.PerforFee + dept.WorkloadFee + dept.OtherPerfor1 + dept.AssessBeforeOtherFee) ?? 0);
dept.AssessLaterPerforTotal = Math.Round((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.Extra + dept.AssessLaterOtherFee) ?? 0);
dept.RealGiveFee = Math.Round((dept.AssessLaterPerforTotal * dept.AdjustFactor + dept.AdjustLaterOtherFee) ?? 0);
dept.Avg = dept.ManagerNumber + dept.Number == 0 ? 0 : dept.PerforTotal / (dept.ManagerNumber + dept.Number);
}
......@@ -354,8 +371,8 @@ public void ComputeOffice(per_allot allot, PerExcel excel, IEnumerable<AccountUn
dept.MedicineExtra = 0;// (drugExtra ?? 0);
dept.MaterialsExtra = 0;//(materialsExtra ?? 0);
dept.PerforFee = empolyees.Sum(w => w.PerforTotal ?? 0);
dept.PerforTotal = Math.Round((dept.PerforFee + (dept?.OtherPerfor1 ?? 0)) ?? 0);
dept.RealGiveFee = Math.Round(((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.OtherPerfor2 + (extra ?? 0)) * dept.AdjustFactor) ?? 0);
dept.PerforTotal = Math.Round(empolyees.Sum(w => w.GiveFee ?? 0));
dept.RealGiveFee = Math.Round(((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.Extra) * dept.AdjustFactor) ?? 0);
//dept.Avg = dept.ManagerNumber + dept.Number == 0 ? 0 : dept.PerforTotal / (dept.ManagerNumber + dept.Number);
dept.Avg = dept.Number == 0 ? 0 : dept.PerforTotal / dept.Number;
......@@ -386,10 +403,14 @@ public IEnumerable<AccountUnitTotal> GetAccountExtra(PerExcel excel, SheetType s
assessList = (isTotal)
? assessList?.Where(w => w.IsTotal == 1)
: assessList?.Where(w => w.IsTotal != 1);
return assessList
?.GroupBy(t => new { t.UnitType, t.AccountingUnit })
?.Select(t => new AccountUnitTotal { UnitType = t.Key.UnitType, AccountingUnit = t.Key.AccountingUnit, TotelValue = t.Sum(g => g.CellValue) });
return assessList?.Select(t => new EmpolyeeTotal
{
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
JobNumber = t.JobNumber,
EmployeeName = t.EmployeeName,
TotelValue = t.CellValue
});
}
/// <summary>
......@@ -402,24 +423,36 @@ public IEnumerable<EmpolyeeTotal> GetEmployeeExtra(PerExcel excel)
.FirstOrDefault(t => t.SheetType == SheetType.PersonExtra)
?.PerData
?.Select(t => (PerData)t)
?.Where(w => w.IsTotal != 1);
?.Where(w => w.IsTotal == 1);
return assessList?.Select(t => new EmpolyeeTotal
{
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
JobNumber = t.JobNumber,
EmployeeName = t.EmployeeName,
TotelValue = t.CellValue
});
}
/// <summary>
/// 获取科室考核得分率
/// </summary>
/// <param name="excel"></param>
public IEnumerable<AccountUnitTotal> GetAccountScoreAverage(PerExcel excel, SheetType sheetType, bool isTotal = false)
{
var assessList = excel.PerSheet
.FirstOrDefault(t => t.SheetType == sheetType)
?.PerData
?.Select(t => (PerData)t);
assessList = (isTotal)
? assessList?.Where(w => w.IsTotal == 1)
: assessList?.Where(w => w.IsTotal != 1);
return assessList
?.GroupBy(t => new
{
t.UnitType,
t.AccountingUnit,
t.JobNumber,
t.EmployeeName,
})
?.Select(t => new EmpolyeeTotal
{
UnitType = t.Key.UnitType,
AccountingUnit = t.Key.AccountingUnit,
JobNumber = t.Key.JobNumber,
EmployeeName = t.Key.EmployeeName,
TotelValue = t.Sum(g => g.CellValue)
});
?.GroupBy(t => new { t.UnitType, t.AccountingUnit })
?.Select(t => new AccountUnitTotal { UnitType = t.Key.UnitType, AccountingUnit = t.Key.AccountingUnit, TotelValue = t.Sum(g => g.CellValue) });
}
......@@ -586,6 +619,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
var allData = datalist.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
var cofList = perforCofdrugpropRepository.GetEntities(t => t.AllotID == allotid);
if (cofList == null || !cofList.Any()) return cofs;
var unitList = (drugData?.Select(t => t.AccountingUnit) ?? new List<string>()).Union(allData.Select(t => t.AccountingUnit));
......
......@@ -18,11 +18,17 @@ public class ResultComputeService : IAutoInjection
private readonly BaiscNormService baiscNormService;
private readonly ComputeDirector computeDirector;
private readonly BudgetService budgetService;
private readonly PerforPeremployeeRepository perforPeremployeeRepository;
private readonly PerforPerallotRepository perforPerallotRepository;
private readonly PerforAgcomputeRepository perforAgcomputeRepository;
private readonly PerforAgsecondallotRepository perforAgsecondallotRepository;
private readonly PerforresreservedRepository perforresreservedRepository;
private readonly PerforImemployeeRepository perforImEmployeeRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository;
private readonly PerforResbaiscnormRepository perforResbaiscnormRepository;
private readonly PerforResspecialunitRepository perforResspecialunitRepository;
private readonly PerforImaccountbasicRepository perforImaccountbasicRepository;
private readonly PerforResaccountRepository perforResaccountRepository;
private readonly LogManageService logManageService;
private readonly PerforImemployeeclinicRepository perforImemployeeclinicRepository;
private readonly PerforImemployeelogisticsRepository perforImemployeelogisticsRepository;
......@@ -33,8 +39,14 @@ public class ResultComputeService : IAutoInjection
PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforResspecialunitRepository perforResspecialunitRepository,
PerforImaccountbasicRepository perforImaccountbasicRepository,
PerforResaccountRepository perforResaccountRepository,
BaiscNormService baiscNormService, ComputeDirector computeDirector,
LogManageService logManageService, BudgetService budgetService,
PerforPeremployeeRepository perforPeremployeeRepository,
PerforPerallotRepository perforPerallotRepository,
PerforAgcomputeRepository perforAgcomputeRepository,
PerforAgsecondallotRepository perforAgsecondallotRepository,
PerforresreservedRepository perforresreservedRepository,
PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository)
{
......@@ -45,8 +57,14 @@ public class ResultComputeService : IAutoInjection
this.perforResbaiscnormRepository = perforResbaiscnormRepository;
this.perforResspecialunitRepository = perforResspecialunitRepository;
this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.perforResaccountRepository = perforResaccountRepository;
this.logManageService = logManageService;
this.budgetService = budgetService;
this.perforPeremployeeRepository = perforPeremployeeRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforAgcomputeRepository = perforAgcomputeRepository;
this.perforAgsecondallotRepository = perforAgsecondallotRepository;
this.perforresreservedRepository = perforresreservedRepository;
this.perforImemployeeclinicRepository = perforImemployeeclinicRepository;
this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository;
}
......@@ -106,7 +124,7 @@ public class ResultComputeService : IAutoInjection
/// <param name="allot"></param>
public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<PerSheet> sheetLast, List<res_baiscnorm> baiscnormList,
IEnumerable<AccountUnitTotal> accountExtras, IEnumerable<AccountUnitTotal> drugExtras, IEnumerable<AccountUnitTotal> materialsExtras,
IEnumerable<EmpolyeeTotal> employeeExtra)
IEnumerable<EmpolyeeTotal> employeeExtra, IEnumerable<AccountUnitTotal> accountScoreAverages)
{
var isBudget = budgetService.GetAdjustAndGrant(allot, out decimal adjust, out decimal grant);
var typeList = EnumHelper.GetItems<PerforType>();
......@@ -115,7 +133,7 @@ public class ResultComputeService : IAutoInjection
if (specialUnit == null || specialUnit.PerData.Count == 0)
return;
var dataList = xxx(specialUnit, allot, baiscnormList, typeList);
var dataList = CalculateSpecialUnit(specialUnit, allot, baiscnormList, typeList);
//取出科室
var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t);
......@@ -141,19 +159,30 @@ public class ResultComputeService : IAutoInjection
decimal? headcount = null;
if (typeList.Any(o => o.Description == t.QuantitativeIndicators))
headcount = group.Number;
if (!string.IsNullOrEmpty(t.QuantitativeIndicators) && t.QuantitativeIndicators.LastIndexOf("人均绩效") > -1)
headcount = group.Number;
if (!headcount.HasValue || headcount == 0)
headcount = 1;
return t.Quantity * t.QuantitativeIndicatorsValue * headcount;
});
var groupAdjust = isBudget ? adjust : (dept?.AdjustFactor ?? 0);
foreach (var item in accountDataList)
{
//科室奖罚汇总结果
var extra = accountExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var drugExtra = drugExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var materialsExtra = materialsExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept.AccountingUnit)?.TotelValue;
var extra = accountExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
var drugExtra = drugExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
var materialsExtra = materialsExtras?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
decimal? headcount = null;
if (typeList.Any(o => o.Description == item.QuantitativeIndicators))
headcount = group.Number;
if (!string.IsNullOrEmpty(item.QuantitativeIndicators) && item.QuantitativeIndicators.LastIndexOf("人均绩效") > -1)
headcount = group.Number;
if (!headcount.HasValue || headcount == 0)
headcount = 1;
//var xxx = item.Quantity * item.QuantitativeIndicatorsValue * headcount;
var res = new res_specialunit
{
......@@ -164,16 +193,22 @@ public class ResultComputeService : IAutoInjection
QuantitativeIndicators = item.QuantitativeIndicators,
Quantity = item.Quantity,
QuantitativeIndicatorsValue = item.QuantitativeIndicatorsValue,
ScoringAverage = dept?.ScoringAverage,
//OtherPerfor = dept?.OtherPerfor,
QuantitativeFee = item.Quantity * item.QuantitativeIndicatorsValue * headcount,
//ScoringAverage = scoreAverage.HasValue ? scoreAverage : dept?.ScoringAverage,
ScoringAverage = dept?.ScoringAverage ?? 0,
OtherPerfor = dept?.OtherPerfor1,
Punishment = (extra ?? 0),
MedicineExtra = (drugExtra ?? 0),
MaterialsExtra = (materialsExtra ?? 0),
Adjust = (groupAdjust == 0) ? 1 : groupAdjust,
};
Adjust = isBudget ? adjust : (dept?.AdjustFactor ?? 1),
res.GiveFee = Math.Round((sumValue + (extra ?? 0)) ?? 0);
res.RealGiveFee = Math.Round(res.GiveFee * (res.ScoringAverage ?? 0) * (groupAdjust == 0 ? 1 : groupAdjust) ?? 0);
AssessBeforeOtherFee = dept?.AssessBeforeOtherFee ?? 0,
AssessLaterOtherFee = dept?.AssessLaterOtherFee ?? 0,
AdjustLaterOtherFee = dept?.AdjustLaterOtherFee ?? 0,
};
res.PerforTotal = (sumValue ?? 0) + res.AssessBeforeOtherFee;
res.GiveFee = Math.Round(res.PerforTotal + res.AssessLaterOtherFee ?? 0);
res.RealGiveFee = Math.Round(res.GiveFee * res.ScoringAverage * res.Adjust + res.Punishment + res.AdjustLaterOtherFee ?? 0);
res.Avg = Math.Round((group.Number != 0 ? res.GiveFee / group.Number : null) ?? 0);
res.ResultsTotalFee = Math.Round(sumValue ?? 0);
......@@ -204,14 +239,18 @@ public class ResultComputeService : IAutoInjection
JobTitle = empolyee.JobTitle,
ScoreAverageRate = empolyee.ScoreAverageRate,
//Punishment = empolyee.Punishment,
Punishment = extra ?? 0,
//OtherPerfor = empolyee.OtherPerfor,
OtherManagePerfor = empolyee.OtherManagePerfor,
Number = group.Number,
PerforTotal = sumValue,
Avg = group.Number == 0 ? 0 : (sumValue / group.Number),
Adjust = empolyeeAdjust,
Grant = isBudget ? grant : empolyee.Management
Adjust = empolyeeAdjust ?? 1m,
Grant = isBudget ? grant : empolyee.Management,
Attendance = empolyee.Attendance ?? 0,
AssessBeforeOtherFee = empolyee?.AssessBeforeOtherFee ?? 0,
AssessLaterOtherFee = empolyee?.AssessLaterOtherFee ?? 0,
AdjustLaterOtherFee = empolyee?.AdjustLaterOtherFee ?? 0,
};
compute.Efficiency = compute.Avg * (empolyee.Efficiency ?? 1);
......@@ -219,13 +258,13 @@ public class ResultComputeService : IAutoInjection
//应发管理绩效
compute.ShouldGiveFee = Math.Round((compute.Efficiency + compute.Scale) * compute.Grant ?? 0);
//绩效合计
compute.PerforSumFee = Math.Round(compute.Avg + compute.ShouldGiveFee ?? 0);
compute.PerforSumFee = Math.Round(compute.Avg + compute.ShouldGiveFee + compute.AssessBeforeOtherFee ?? 0);
//应发绩效
//compute.GiveFee = compute.PerforSumFee;
compute.GiveFee = Math.Round(compute.PerforSumFee * compute.ScoreAverageRate * (compute.Attendance ?? 0) + (extra ?? 0) ?? 0);
compute.GiveFee = Math.Round(compute.PerforSumFee * compute.ScoreAverageRate * compute.Attendance + compute.Punishment + compute.AssessLaterOtherFee ?? 0);
//实发绩效
//compute.RealGiveFee = (compute.GiveFee * compute.ScoreAverageRate + (compute.Punishment ?? 0) + (compute.OtherPerfor ?? 0)) * (compute.Adjust ?? 1m);
compute.RealGiveFee = Math.Round(compute.GiveFee * (compute.Adjust ?? 1m) ?? 0);
compute.RealGiveFee = Math.Round(compute.GiveFee * compute.Adjust + compute.AdjustLaterOtherFee ?? 0);
// 参考基数专用绩效合计
compute.BaiscNormPerforTotal = compute.PerforSumFee;
......@@ -238,7 +277,7 @@ public class ResultComputeService : IAutoInjection
perforResspecialunitRepository.AddRange(resDataList.ToArray());
}
private IEnumerable<PerDataSpecialUnit> xxx(PerSheet specialUnit, per_allot allot, List<res_baiscnorm> baiscnormList, List<EnumItem> typeList)
private IEnumerable<PerDataSpecialUnit> CalculateSpecialUnit(PerSheet specialUnit, per_allot allot, List<res_baiscnorm> baiscnormList, List<EnumItem> typeList)
{
var dataList = specialUnit.PerData.Select(t => (PerDataSpecialUnit)t);
var specialEmployee = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID);
......@@ -274,5 +313,260 @@ private IEnumerable<PerDataSpecialUnit> xxx(PerSheet specialUnit, per_allot allo
}
return dataList;
}
#region 预留金额
/// <summary>
/// 二次绩效审核通过后修改绩效预留金额
/// </summary>
/// <param name="secondId"></param>
public void SaveSecondReserved(int secondId)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null)
throw new PerformanceException("参数信息无效");
var allot = perforPerallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("参数信息无效");
var again = perforAgcomputeRepository.GetEntities(t => t.AllotId == allot.ID);
if (again != null && again.Any())
{
var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allot.ID);
var group = again.GroupBy(t => new { t.Department, t.JobNumber, t.PersonName })
.Select(t => new ComputeResponse
{
UnitType = second.UnitType,
AccountingUnit = t.Key.Department,
JobNumber = t.Key.JobNumber,
EmployeeName = t.Key.PersonName,
RealGiveFee = t.Sum(g => g.RealGiveFee)
});
AddOrUpdate(allot, empDic, group);
}
}
/// <summary>
/// 绩效生成完成后修改绩效预留金额
/// </summary>
/// <param name="allot"></param>
public void SaveReserved(per_allot allot)
{
var mTypes = new[] { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
var resComputes = perforRescomputeRepository.GetEntities(t => t.AllotID == allot.ID && mTypes.Contains(t.AccountType))?.OrderByDescending(t => t.AccountingUnit);
if (resComputes != null && resComputes.Any())
{
var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allot.ID);
var group = resComputes.GroupBy(t => new { t.UnitType, t.AccountingUnit, t.EmployeeName, t.JobNumber })
.Select(t => new ComputeResponse
{
UnitType = t.Key.UnitType,
AccountingUnit = t.Key.AccountingUnit,
EmployeeName = t.Key.EmployeeName,
JobNumber = t.Key.JobNumber,
RealGiveFee = t.Sum(g => g.RealGiveFee)
});
AddOrUpdate(allot, empDic, group);
}
}
private void AddOrUpdate(per_allot allot, List<per_employee> empDic, IEnumerable<ComputeResponse> group)
{
var reserveds = perforresreservedRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.Year == allot.Year);
List<res_reserved> updates = new List<res_reserved>(), inserts = new List<res_reserved>();
foreach (var item in group)
{
var ratio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
var reserved = reserveds?.FirstOrDefault(w => w.AccountingUnit == item.AccountingUnit && w.JobNumber == item.JobNumber);
if (reserved == null)
{
reserved = new res_reserved
{
UnitType = item.UnitType,
HospitalId = allot.HospitalId,
Year = allot.Year,
AccountingUnit = item.AccountingUnit,
JobNumber = item.JobNumber,
EmployeeName = item.EmployeeName,
};
inserts.Add(reserved);
}
else
updates.Add(reserved);
ChangeRealGiveFee(reserved, allot, item.RealGiveFee ?? 0, ratio);
}
perforresreservedRepository.AddRange(inserts.ToArray());
perforresreservedRepository.UpdateRange(updates.ToArray());
}
/// <summary>
/// 修改绩效金额
/// </summary>
/// <param name="reserved"></param>
/// <param name="allot"></param>
/// <param name="realGiveFee"></param>
/// <param name="ratio"></param>
private void ChangeRealGiveFee(res_reserved reserved, per_allot allot, decimal realGiveFee, decimal ratio)
{
if (allot.Month == 1)
{
reserved.JanFee = realGiveFee;
reserved.JanRatio = ratio;
}
else if (allot.Month == 2)
{
reserved.FebFee = realGiveFee;
reserved.FebRatio = ratio;
}
else if (allot.Month == 3)
{
reserved.MarFee = realGiveFee;
reserved.MarRatio = ratio;
}
else if (allot.Month == 4)
{
reserved.AprFee = realGiveFee;
reserved.AprRatio = ratio;
}
else if (allot.Month == 5)
{
reserved.MayFee = realGiveFee;
reserved.MayRatio = ratio;
}
else if (allot.Month == 6)
{
reserved.JunFee = realGiveFee;
reserved.JunRatio = ratio;
}
else if (allot.Month == 7)
{
reserved.JulFee = realGiveFee;
reserved.JulRatio = ratio;
}
else if (allot.Month == 8)
{
reserved.AugFee = realGiveFee;
reserved.AugRatio = ratio;
}
else if (allot.Month == 9)
{
reserved.SepFee = realGiveFee;
reserved.SepRatio = ratio;
}
else if (allot.Month == 10)
{
reserved.OctFee = realGiveFee;
reserved.OctRatio = ratio;
}
else if (allot.Month == 11)
{
reserved.NovFee = realGiveFee;
reserved.NovRatio = ratio;
}
else if (allot.Month == 12)
{
reserved.DecFee = realGiveFee;
reserved.DecRatio = ratio;
}
}
#endregion
/// <summary>
/// 创建科室二次分配
/// </summary>
/// <param name="allot"></param>
public void GenerateSecondAllot(per_allot allot)
{
List<ag_secondallot> tempSecond = new List<ag_secondallot>();
List<ag_secondallot> insSecond = new List<ag_secondallot>();
List<ag_secondallot> updSecond = new List<ag_secondallot>();
var types = new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 };
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
var specialList = perforResspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
if (accountUnit != null)
{
foreach (var item in accountUnit)
{
if (!tempSecond.Any(f => f.UnitType == ((UnitType)item.UnitType).ToString() && f.Department == item.AccountingUnit))
{
tempSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = ((UnitType)item.UnitType).ToString(),
Department = item.AccountingUnit,
RealGiveFee = item.RealGiveFee,
});
}
}
}
if (specialList != null)
{
foreach (var item in specialList.Select(w => new { w.AccountingUnit, w.RealGiveFee }).Distinct())
{
if (!tempSecond.Any(f => f.UnitType == UnitType.特殊核算组.ToString() && f.Department == item.AccountingUnit))
{
tempSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = UnitType.特殊核算组.ToString(),
Department = item.AccountingUnit,
RealGiveFee = item.RealGiveFee,
});
}
}
}
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
foreach (var item in tempSecond)
{
var second = secondList?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
if (second == null)
{
insSecond.Add(new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = item.UnitType,
Department = item.Department,
RealGiveFee = item.RealGiveFee,
Status = 1,
NursingDeptStatus = 1,
});
}
else
{
if (Math.Round((second.RealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m && second.Status > 1)
{
second.Status = 4;
second.Remark = "科室绩效结果发生变更,需要重新提交";
second.NursingDeptStatus = 4;
second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
}
second.RealGiveFee = item.RealGiveFee;
updSecond.Add(second);
}
}
if (insSecond.Any())
perforAgsecondallotRepository.AddRange(insSecond.ToArray());
if (updSecond.Any())
perforAgsecondallotRepository.UpdateRange(updSecond.ToArray());
}
}
}
......@@ -25,6 +25,7 @@ public class AllotService : IAutoInjection
private ProcessComputService processComputService;
private ResultComputeService resultComputeService;
private PerforLogdbugRepository logdbug;
private readonly PerforresreservedRepository perforresreservedRepository;
private ConfigService configService;
private IHostingEnvironment _evn;
private ILogger<AllotService> _logger;
......@@ -36,6 +37,8 @@ public class AllotService : IAutoInjection
private readonly PerforHospitalRepository perforHospitalRepository;
private readonly PerforResbaiscnormRepository perforResbaiscnormRepository;
private PerforHospitalconfigRepository perforHospitalconfigRepository;
private readonly RoleService roleService;
private readonly UserService userService;
private PerforCofdirectorRepository perforCofdirectorRepository;
//private readonly IHubContext<AllotLogHub> hubContext;
......@@ -51,6 +54,7 @@ public class AllotService : IAutoInjection
ResultComputeService resultComputeService,
ConfigService configService,
PerforLogdbugRepository logdbug,
PerforresreservedRepository perforresreservedRepository,
IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService,
IOptions<Application> options,
......@@ -60,6 +64,8 @@ public class AllotService : IAutoInjection
PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository,
//IHubContext<AllotLogHub> hubContext
RoleService roleService,
UserService userService,
LogManageService logManageService,
ReportService reportService,
PerforCofdirectorRepository perforCofdirectorRepository,
......@@ -78,10 +84,13 @@ public class AllotService : IAutoInjection
this.options = options;
this.configService = configService;
this.logdbug = logdbug;
this.perforresreservedRepository = perforresreservedRepository;
this.perforLogcheckRepository = perforLogcheckRepository;
this.perforHospitalRepository = perforHospitalRepository;
this.perforResbaiscnormRepository = perforResbaiscnormRepository;
this.perforHospitalconfigRepository = perforHospitalconfigRepository;
this.roleService = roleService;
this.userService = userService;
//this.hubContext = hubContext;
this.logManageService = logManageService;
this.reportService = reportService;
......@@ -343,13 +352,16 @@ public void Generate(per_allot allot, string mail)
// 科室奖罚汇总
logManageService.WriteMsg("正在生成绩效", "科室奖罚汇总", 1, allot.ID, "ReceiveMessage", true);
var accountExtras = processComputService.GetAccountExtra(excel, SheetType.AccountExtra);
var accountExtras = processComputService.GetAccountExtra(excel, SheetType.AccountExtra, true);
// 科室药占比考核
logManageService.WriteMsg("正在生成绩效", "科室药占比考核", 1, allot.ID, "ReceiveMessage", true);
var drugExtras = processComputService.GetAccountExtra(excel, SheetType.AccountDrugAssess, true);
// 科室材料占比考核
logManageService.WriteMsg("正在生成绩效", "科室材料占比考核", 1, allot.ID, "ReceiveMessage", true);
var materialsExtras = processComputService.GetAccountExtra(excel, SheetType.AccountMaterialsAssess, true);
// 科室考核得分率
logManageService.WriteMsg("正在生成绩效", "科室考核得分率", 1, allot.ID, "ReceiveMessage", true);
var accountScoreAverages = processComputService.GetAccountScoreAverage(excel, SheetType.AccountScoreAverage, true);
////科室药占比考核
//logManageService.WriteMsg("正在生成绩效", "科室奖罚汇总", 1, allot.ID, "ReceiveMessage", true);
......@@ -361,7 +373,7 @@ public void Generate(per_allot allot, string mail)
//重新计算科室业绩(含所有提供保底金额)
logManageService.WriteMsg("正在生成绩效", "计算科室业绩分", 1, allot.ID, "ReceiveMessage", true);
var sheetLast = processComputService.Compute(excel, mergeSheets, accountExtras, drugExtras, materialsExtras);
var sheetLast = processComputService.Compute(excel, mergeSheets, accountExtras, drugExtras, materialsExtras, accountScoreAverages);
//保存计算过程数据
logManageService.WriteMsg("正在生成绩效", "保存科室业绩结果及计算过程中产生的数据", 1, allot.ID, "ReceiveMessage", true);
......@@ -380,13 +392,17 @@ public void Generate(per_allot allot, string mail)
// 计算特殊科室
logManageService.WriteMsg("正在生成绩效", "计算最终特殊科室绩效数据", 1, allot.ID, "ReceiveMessage", true);
resultComputeService.SpecialUnitCompute(excel, allot, sheetLast, baiscnormList, accountExtras, drugExtras, materialsExtras, employeeExtra);
resultComputeService.SpecialUnitCompute(excel, allot, sheetLast, baiscnormList, accountExtras, drugExtras, materialsExtras, employeeExtra, accountScoreAverages);
logManageService.WriteMsg("正在生成绩效", "保存最终特殊科室绩效数据", 1, allot.ID, "ReceiveMessage", true);
//保存 绩效人均参考标准
logManageService.WriteMsg("正在生成绩效", "保存绩效人均参考标准", 1, allot.ID, "ReceiveMessage", true);
perforResbaiscnormRepository.AddRange(baiscnormList.ToArray());
// 保存预留绩效
logManageService.WriteMsg("正在生成绩效", "保存预留绩效金额", 1, allot.ID, "ReceiveMessage", true);
resultComputeService.SaveReserved(allot);
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID);
......@@ -395,8 +411,8 @@ public void Generate(per_allot allot, string mail)
var flag = reportService.UpdateData(allot);
logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true);
//发送邮件
logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true);
////发送邮件
//logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true);
//SendEmail(allot, mail, 1, time);
//logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功");
logManageService.WriteMsg("绩效生成结束", "绩效生成成功", 5, allot.ID, "ReceiveMessage", true);
......@@ -511,5 +527,34 @@ public List<log_dbug> AllotLog(per_allot allot, int type)
list = list.OrderBy(t => t.CreateTime).ToList();
return list;
}
public List<res_reserved> GetReserved(int hospitalId, int year, int userid)
{
var user = userService.GetUser(userid);
if (user == null)
throw new PerformanceException("用户信息错误");
var role = roleService.GetUserRole(userid)?.FirstOrDefault()?.Type;
if (!role.HasValue)
throw new PerformanceException("用户信息错误");
var roleTypes = new[] { options.Value.NurseRole, options.Value.DirectorRole, options.Value.SpecialRole, options.Value.OfficeRole };
var reserveds = perforresreservedRepository.GetEntities(w => w.HospitalId == hospitalId && w.Year == year);
if (reserveds != null && reserveds.Any())
{
if (role.Value == options.Value.NurseRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(UnitType.护理组.ToString()) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.DirectorRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && (w.UnitType.Contains(UnitType.医生组.ToString()) || w.UnitType.Contains(UnitType.医技组.ToString())) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.SpecialRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(UnitType.特殊核算组.ToString()) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.OfficeRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && (w.UnitType.Contains(UnitType.行政中层.ToString()) || w.UnitType.Contains(UnitType.行政后勤.ToString())) && w.AccountingUnit == user.Department)?.ToList();
}
return reserveds;
}
}
}
......@@ -329,5 +329,61 @@ public bool GetAdjustAndGrant(per_allot allot, out decimal adjust, out decimal g
grant = result.Grant.Value / 100;
return true;
}
/// <summary>
/// 统计指定月份绩效信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public per_budget_result Collect(int hospitalid, int year, int month)
{
return new per_budget_result
{
Year = year,
Month = month,
MedicalIncome = GetMedicalIncome(hospitalid, year, month),
TheNewPerformance = GetTheNewPerformance(hospitalid, year, month),
MedicineProportion = GetMedicineProportion(hospitalid, year, month),
MaterialCosts = GetMaterialCosts(hospitalid, year, month),
};
}
///绩效总金额
private decimal GetTheNewPerformance(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(fee),0) as fee from (
select realgivefee as fee from res_compute t1
join per_allot t2 on t1.allotid=t2.id
where hospitalid=@hospitalid and year=@year and month=@month and accounttype in ('护士长','科主任','行政中层','行政高层')
union all
select AssessLaterPerforTotal as fee from res_account t1
join per_allot t2 on t1.allotid=t2.id
where hospitalid=@hospitalid and year=@year and month=@month
) tab";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///医疗收入
private decimal GetMedicalIncome(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee from report_original_income t1 where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///药品收入
private decimal GetMedicineProportion(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '药费'
where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///材料支出
private decimal GetMaterialCosts(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '材料费'
where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
}
}
......@@ -29,6 +29,7 @@ public class ComputeService : IAutoInjection
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerapramountRepository perapramountRepository;
private readonly PerforCofcmiRepository cofcmiRepository;
private readonly PerforPeremployeeRepository perforPeremployeeRepository;
private readonly PerforCofworkitemRepository cofworkitemRepository;
public ComputeService(PerforResaccountRepository perforResaccountRepository,
......@@ -46,6 +47,7 @@ public class ComputeService : IAutoInjection
PerforHospitalRepository hospitalRepository,
PerforPerapramountRepository perapramountRepository,
PerforCofcmiRepository cofcmiRepository,
PerforPeremployeeRepository perforPeremployeeRepository,
PerforCofworkitemRepository cofworkitemRepository)
{
this.perforResaccountRepository = perforResaccountRepository;
......@@ -63,6 +65,7 @@ public class ComputeService : IAutoInjection
this.hospitalRepository = hospitalRepository;
this.perapramountRepository = perapramountRepository;
this.cofcmiRepository = cofcmiRepository;
this.perforPeremployeeRepository = perforPeremployeeRepository;
this.cofworkitemRepository = cofworkitemRepository;
}
......@@ -104,6 +107,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
};
var isShowManage = IsShowManage(allotId);
var apramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
if (pairs.Keys.Any(t => t == type))
{
......@@ -164,21 +168,25 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
var computes = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && pairs[type].Contains(t.UnitType));
if (computes == null || !computes.Any()) return new List<ResComputeResponse>();
data = Mapper.Map<List<ResComputeResponse>>(computes);
data.ForEach(t =>
{
t.WorkTime = string.IsNullOrEmpty(t.WorkTime) ? null : Convert.ToDateTime(t.WorkTime).ToString("yyyy-MM-dd");
//t.WorkTime = string.IsNullOrEmpty(t.WorkTime) ? null : Convert.ToDateTime(t.WorkTime).ToString("yyyy-MM-dd");
if (isShowManage == 2)
{
t.PerforSumFee = t.ShouldGiveFee;
var employee = employees.FirstOrDefault(e => e.DoctorName == t.EmployeeName && e.AccountingUnit == t.AccountingUnit && pairs[type].Contains(e.UnitType));
var scoreAverageRate = t.ScoreAverageRate ?? employee.ScoreAverageRate ?? 0;
var attendance = t.Attendance ?? employee.Attendance ?? 0;
t.GiveFee = t.ShouldGiveFee * scoreAverageRate * attendance + t.OtherPerfor;
t.GiveFee = t.ShouldGiveFee * scoreAverageRate * attendance + (t.OtherPerfor ?? 0);
t.RealGiveFee = t.GiveFee * (t.Adjust ?? 1m);
t.BaiscNormValue = t.RealGiveFee;
}
var aprAmount = apramounts?.Where(w => !(string.IsNullOrEmpty(w.DoctorName) && string.IsNullOrEmpty(w.PersonnelNumber)) && w.DoctorName?.Trim() == t.EmployeeName?.Trim() && w.PersonnelNumber?.Trim() == t.JobNumber?.Trim());
t.OtherPerformance = aprAmount?.Sum(w => w.Amount);
});
return data.Distinct().OrderByDescending(t => t.AccountingUnit).ToList();
}
......@@ -190,7 +198,12 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
data = Mapper.Map<List<ResComputeResponse>>(compute);
data = data.OrderByDescending(t => t.RealGiveFee).ThenBy(t => t.FitPeople).ThenBy(t => t.AccountingUnit).ToList();
data.ForEach(t => t.WorkTime = string.IsNullOrEmpty(t.WorkTime) ? null : Convert.ToDateTime(t.WorkTime).ToString("yyyy-MM-dd"));
data.ForEach(t =>
{
//t.WorkTime = string.IsNullOrEmpty(t.WorkTime) ? null : Convert.ToDateTime(t.WorkTime).ToString("yyyy-MM-dd");
var aprAmount = apramounts?.Where(w => !(string.IsNullOrEmpty(w.DoctorName) && string.IsNullOrEmpty(w.PersonnelNumber)) && w.DoctorName?.Trim() == t.EmployeeName?.Trim() && w.PersonnelNumber?.Trim() == t.JobNumber?.Trim());
t.OtherPerformance = aprAmount?.Sum(w => w.Amount);
});
return data.Distinct().OrderByDescending(t => t.AccountingUnit).ToList();
}
}
......@@ -259,7 +272,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId)
/// <returns></returns>
public List<DeptResponse> GetOfficePerformance(int allotId)
{
var unitType = new List<int> { (int)UnitType.行政中层, (int)UnitType.行政工 };
var unitType = new List<int> { (int)UnitType.行政 };
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId)
?.OrderBy(t => t.UnitType)
......@@ -409,90 +422,197 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
return null;
}
#region 绩效发放列表
/// <summary>
/// 返回绩效发放列表
/// </summary>
/// <param name="allotId">绩效ID</param>
/// <param name="isShowManage"> 仅显示管理绩效 isShowManage == 1 </param>
/// <returns></returns>
public List<ComputeResponse> AllCompute(int allotId)
public List<ComputeResponse> AllCompute(int allotId, int isShowManage)
{
var list = new List<ComputeResponse>();
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId)?.OrderByDescending(t => t.AccountingUnit);
list = Mapper.Map<List<ComputeResponse>>(allot);
list?.ForEach(t => t.Source = "一次绩效");
var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId);
if (again != null && again.Any())
// 获取一次次绩效结果
var list = GetAllotPerformance(allotId, isShowManage);
// 获取二次绩效结果
var seconds = GetSecondPerformance(allotId);
if (seconds != null)
list?.AddRange(seconds);
// 补充医院其他绩效
var result = AddAprAmount(allotId, list);
// 预留比例
if (result != null)
{
var group = again.GroupBy(t => new { t.Department, t.WorkPost, t.JobNumber, t.PersonName })
.Select(t => new
{
department = t.Key.Department,
jobtitle = t.Key.WorkPost,
jobnumber = t.Key.JobNumber,
name = t.Key.PersonName,
fee = t.Sum(g => g.RealGiveFee)
});
list.AddRange(group.Select(t => new ComputeResponse
var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
foreach (var item in result)
{
Source = "二次绩效",
AccountingUnit = t.department,
JobNumber = t.jobnumber,
JobTitle = t.jobtitle,
EmployeeName = t.name,
RealGiveFee = t.fee
}).OrderByDescending(t => t.AccountingUnit));
item.PerforSumFee = Math.Round(item.PerforSumFee ?? 0, 0, MidpointRounding.AwayFromZero);
item.PerforManagementFee = Math.Round(item.PerforManagementFee ?? 0, 0, MidpointRounding.AwayFromZero);
item.OthePerfor = Math.Round(item.OthePerfor ?? 0, 0, MidpointRounding.AwayFromZero);
item.NightWorkPerfor = Math.Round(item.NightWorkPerfor ?? 0, 0, MidpointRounding.AwayFromZero);
item.ShouldGiveFee = Math.Round((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0) + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 0, MidpointRounding.AwayFromZero);
item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
item.ReservedRatioFee = Math.Round(((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0)) * item.ReservedRatio ?? 0, 0, MidpointRounding.AwayFromZero);
item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 0, MidpointRounding.AwayFromZero);
}
}
return AddAprAmount(allotId, list);
return result?.OrderByDescending(t => t.AccountingUnit).ToList();
}
/// <summary>
/// 返回绩效发放列表
/// 科主任护士长返回管理绩效
/// 获取一次次绩效结果
/// </summary>
/// <param name="allotId">绩效ID</param>
/// <param name="allotId"></param>
/// <returns></returns>
public List<ComputeResponse> AllManageCompute(int allotId)
private List<ComputeResponse> GetAllotPerformance(int allotId, int isShowManage)
{
var list = new List<ComputeResponse>();
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId)?.OrderByDescending(t => t.AccountingUnit);
if (allot != null && allot.Any(t => t.AllotID == allotId))
var mTypes = new[] { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
var types1 = new List<string> { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString() };
var types2 = new List<string> { AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
// 业务中层人员信息
var empolyeeList = _perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allotId);
// 一次绩效 获取特定人员绩效结果
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && mTypes.Contains(t.AccountType))?.OrderByDescending(t => t.AccountingUnit);
//var apramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
return allot?.Select(t =>
{
var types = new List<string> { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString() };
list = allot.Select(t => new ComputeResponse
{
Source = "一次绩效",
AccountingUnit = t.AccountingUnit,
EmployeeName = t.EmployeeName,
JobNumber = t.JobNumber,
JobTitle = t.JobTitle,
RealGiveFee = types.Contains(t.AccountType) ? t.ShouldGiveFee : t.RealGiveFee
}).ToList();
}
var comp = new ComputeResponse("一次绩效", t.AccountingUnit, t.EmployeeName, t.JobNumber, t.JobTitle);
comp.UnitType = t.AccountType;
if (types1.Contains(t.AccountType))
comp.PerforManagementFee = (t.ShouldGiveFee ?? 0) + (t.OtherPerfor ?? 0) + (t.Punishment ?? 0);
else
comp.PerforManagementFee = t.RealGiveFee;
// 行政中层 行政高层 补充 夜班费
if (types2.Contains(t.AccountType))
comp.NightWorkPerfor = t.NightWorkPerfor;
// 获取科主任系数,解决共用科主任重复计算人均问题
var basics = empolyeeList?.FirstOrDefault(w => w.AccountingUnit == t.AccountingUnit && w.DoctorName == t.EmployeeName && w.PersonnelNumber == t.JobNumber)?.Basics;
// 仅显示管理绩效
if (isShowManage == 2)
comp.PerforSumFee = 0;
else
comp.PerforSumFee = basics.HasValue ? t.Avg * basics : t.Avg;
return comp;
}).ToList();
}
/// <summary>
/// 获取二次绩效结果
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
private List<ComputeResponse> GetSecondPerformance(int allotId)
{
var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId);
if (again != null && again.Any())
{
var group = again.GroupBy(t => new { t.Department, t.WorkPost, t.JobNumber, t.PersonName })
.Select(t => new
var group = again
.GroupBy(t => new { t.UnitType, t.Department, t.WorkPost, t.JobNumber, t.PersonName })
.Select(t =>
{
department = t.Key.Department,
jobtitle = t.Key.WorkPost,
jobnumber = t.Key.JobNumber,
name = t.Key.PersonName,
fee = t.Sum(g => g.RealGiveFee)
var comp = new ComputeResponse("二次绩效", t.Key.Department, t.Key.PersonName, t.Key.JobNumber, t.Key.WorkPost);
comp.UnitType = t.Key.UnitType;
comp.PerforSumFee = t.Sum(g => g.PerforSumFee);
comp.NightWorkPerfor = t.Sum(g => g.NightWorkPerfor);
return comp;
});
list.AddRange(group.Select(t => new ComputeResponse
{
Source = "二次绩效",
AccountingUnit = t.department,
JobNumber = t.jobnumber,
JobTitle = t.jobtitle,
EmployeeName = t.name,
RealGiveFee = t.fee
}).OrderByDescending(t => t.AccountingUnit));
return group?.ToList();
}
return null;
}
/// <summary>
/// 添加额外绩效金额(基础绩效、其他绩效等)
/// </summary>
/// <param name="allotId"></param>
/// <param name="computes"></param>
private List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> computes)
{
if (computes == null || !computes.Any())
return computes;
var list = perapramountRepository.GetEntities(t => t.AllotId == allotId);
if (list == null || !list.Any())
return computes;
foreach (var emp in computes)
{
var apramount = list.Where(t => t.AccountingUnit == emp.AccountingUnit && !string.IsNullOrEmpty(t.PersonnelNumber) && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
emp.OthePerfor = apramount?.Sum(w => w.Amount);
}
return AddAprAmount(allotId, list);
return computes;
}
///// <summary>
///// 返回绩效发放列表
///// 科主任护士长返回管理绩效
///// </summary>
///// <param name="allotId">绩效ID</param>
///// <returns></returns>
//public List<ComputeResponse> AllManageCompute(int allotId)
//{
// var list = new List<ComputeResponse>();
// var mTypes = new[] { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
// var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && mTypes.Contains(t.AccountType))?.OrderByDescending(t => t.AccountingUnit);
// if (allot != null && allot.Any(t => t.AllotID == allotId))
// {
// var types = new List<string> { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString() };
// list = allot.Select(t => new ComputeResponse
// {
// Source = "一次绩效",
// AccountingUnit = t.AccountingUnit,
// EmployeeName = t.EmployeeName,
// JobNumber = t.JobNumber,
// JobTitle = t.JobTitle,
// RealGiveFee = types.Contains(t.AccountType) ? t.ShouldGiveFee : t.RealGiveFee
// }).ToList();
// }
// var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId);
// if (again != null && again.Any())
// {
// var group = again.GroupBy(t => new { t.Department, t.WorkPost, t.JobNumber, t.PersonName })
// .Select(t => new
// {
// department = t.Key.Department,
// jobtitle = t.Key.WorkPost,
// jobnumber = t.Key.JobNumber,
// name = t.Key.PersonName,
// fee = t.Sum(g => g.RealGiveFee)
// });
// list.AddRange(group.Select(t => new ComputeResponse
// {
// Source = "二次绩效",
// AccountingUnit = t.department,
// JobNumber = t.jobnumber,
// JobTitle = t.jobtitle,
// EmployeeName = t.name,
// RealGiveFee = t.fee
// }).OrderByDescending(t => t.AccountingUnit));
// }
// var result = AddAprAmount(allotId, list);
// if (result != null)
// {
// var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
// foreach (var item in result)
// {
// var temp = item.RealGiveFee ?? 0;
// item.ReservedRatio = empDic?.FirstOrDefault(w => w.DoctorName == item.EmployeeName && w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
// item.ReservedRatioFee = temp * item.ReservedRatio;
// item.RealGiveFee = temp - item.ReservedRatioFee;
// }
// }
// return result;
//}
#endregion
public res_compute GetComputeSingle(int computeid)
{
return _perforRescomputeRepository.GetEntity(t => t.ID == computeid);
......@@ -587,12 +707,13 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
int groupbasis = 1;
string single = "";
var sheetType = new List<int> {
(int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload,
(int)SheetType.AccountExtra, (int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess
(int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.AccountExtra,
(int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess, (int)SheetType.AccountScoreAverage,
(int)SheetType.AccountAdjustLaterOtherFee
};
foreach (var stype in sheetType)
{
if (type == 3 && stype == (int)SheetType.Workload) type = 1;
//if (type == 3 && stype == (int)SheetType.Workload) type = 1;
foreach (var sheet in persheet.Where(t => t.SheetType == stype))
{
if (single != "" && sheet.SheetName.Substring(0, 3) != single)
......@@ -600,14 +721,19 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
single = sheet.SheetName.Substring(0, 3);
var sheetName = reg.Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
var sheetData = basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == type).ToList();
//var nType = (stype == (int)SheetType.Workload) ? 1 : type;
var sheetData = basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == type && t.IsTotal != 1).ToList();
if (sheetData == null || !sheetData.Any()) continue;
var headerData = headers?.Where(t => t.SheetID == sheet.ID);
var sheettype = 1; //特殊核算科室 4
var amount = 0m;
if (sheet.SheetType == (int)SheetType.Expend)
if (sheet.SheetType == (int)SheetType.Income || sheet.SheetType == (int)SheetType.OtherIncome)
{
amount = sheetData?.Sum(t => t.IsFactor == 1 ? t.CellValue * (t.FactorValue ?? 0) : t.CellValue) ?? 0;
}
else if (sheet.SheetType == (int)SheetType.Expend)
{
sheettype = 2;
amount = economic.FirstOrDefault(t => t.ItemName.Contains(sheetName) && t.UnitType == type)?.ItemValue ?? 0m;
......@@ -620,17 +746,28 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
else if (sheet.SheetType == (int)SheetType.AccountExtra)
{
sheettype = 5;
amount = sheetData.Sum(t => t.CellValue ?? 0m);
amount = doctor?.Extra ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountDrugAssess)
{
sheettype = 6;
amount = sheetData.Sum(t => t.CellValue ?? 0m);
amount = doctor?.MedicineExtra ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountMaterialsAssess)
{
sheettype = 7;
amount = sheetData.Sum(t => t.CellValue ?? 0m);
amount = doctor?.MaterialsExtra ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountScoreAverage)
{
sheettype = 8;
//amount = Math.Round(doctor?.ScoringAverage ?? 0, 4);
amount = Math.Round(basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == type && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0, 4);
}
else if (sheet.SheetType == (int)SheetType.AccountAdjustLaterOtherFee)
{
sheettype = 9;
amount = Math.Round(basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == type && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0, 0);
}
var item = new DetailDtos
......@@ -647,7 +784,6 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
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())
......@@ -769,7 +905,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details
ItemName = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1) is null ? data.First().ItemName :
data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1).ItemName?.Replace("执行", "开单/执行"),
IncomeType = data.First().IncomeType,
Amount = data.First().Amount,
Amount = data.Sum(w => w.Amount),
GroupBasis = groupbasis,
Items = items
});
......@@ -793,16 +929,18 @@ public DeptDataDetails SpecialDeptDetail(ag_secondallot second)
UnitType = second.UnitType,
AccountingUnit = second.Department,
//Department = second.Department,
ScoringAverage = special.First().ScoringAverage.Value,
OtherPerfor1 = special.First().OtherPerfor.Value,
AdjustFactor = special.First().Adjust.Value,
Avg = special.First().Avg,
RealGiveFee = special.First().RealGiveFee,
Number = special.First().Number.Value,
PerforFee = special.First().GiveFee,
PerforTotal = special.First().ResultsTotalFee,
Income = special.First().ResultsTotalFee,
//Extra = special.First().Punishment.Value,
ScoringAverage = special.FirstOrDefault()?.ScoringAverage ?? 0,
OtherPerfor1 = special.FirstOrDefault()?.OtherPerfor ?? 0,
AdjustFactor = special.FirstOrDefault()?.Adjust ?? 0,
Avg = special.FirstOrDefault()?.Avg,
RealGiveFee = special.FirstOrDefault()?.RealGiveFee,
Number = special.FirstOrDefault()?.Number ?? 0,
PerforFee = special.FirstOrDefault()?.GiveFee,
PerforTotal = special.FirstOrDefault()?.ResultsTotalFee,
Income = special.FirstOrDefault()?.ResultsTotalFee,
Extra = special.FirstOrDefault()?.Punishment ?? 0,
MedicineExtra = special.FirstOrDefault()?.MedicineExtra ?? 0,
MaterialsExtra = special.FirstOrDefault()?.MaterialsExtra ?? 0,
},
Detail = new List<DetailDtos>(),
};
......@@ -821,13 +959,126 @@ public DeptDataDetails SpecialDeptDetail(ag_secondallot second)
ItemName = item.QuantitativeIndicators,
CellValue = item.Quantity,
Factor = item.QuantitativeIndicatorsValue,
ItemValue = Math.Round(item.Quantity * item.QuantitativeIndicatorsValue ?? 0, 2)
ItemValue = Math.Round(item.QuantitativeFee ?? 0, 2)
});
}
deptDetails.Detail.Add(detail);
var persheet = _perforPerSheetRepository.GetEntities(t => t.AllotID == second.AllotId);
var headers = _perforImheaderRepository.GetEntities(t => t.AllotID == second.AllotId);
var basicData = _perforImDataRepository.GetEntities(t => t.AllotID == second.AllotId && t.AccountingUnit == second.Department);
var sheetType = new List<int>
{
(int)SheetType.AccountExtra, (int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess,
(int)SheetType.AccountScoreAverage, (int)SheetType.AccountAdjustLaterOtherFee
};
Regex reg = new Regex("[0-9]*");
int groupBasis = 0;
foreach (var stype in sheetType)
{
foreach (var sheet in persheet.Where(t => t.SheetType == stype))
{
groupBasis++;
var sheetName = reg.Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
var sheetData = basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)UnitType.特殊核算组 && t.IsTotal != 1).ToList();
if (sheetData == null || !sheetData.Any()) continue;
var headerData = headers?.Where(t => t.SheetID == sheet.ID);
var sheettype = 1; //特殊核算科室 4
var amount = 0m;
if (sheet.SheetType == (int)SheetType.AccountExtra)
{
sheettype = 5;
amount = special.FirstOrDefault()?.Punishment ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountDrugAssess)
{
sheettype = 6;
amount = special.FirstOrDefault()?.MedicineExtra ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountMaterialsAssess)
{
sheettype = 7;
amount = special.FirstOrDefault()?.MaterialsExtra ?? 0;
}
else if (sheet.SheetType == (int)SheetType.AccountScoreAverage)
{
sheettype = 8;
//amount = Math.Round(special.FirstOrDefault()?.ScoringAverage ?? 0, 4);
amount = Math.Round(basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)UnitType.特殊核算组 && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0, 4);
}
else if (sheet.SheetType == (int)SheetType.AccountAdjustLaterOtherFee)
{
sheettype = 9;
amount = Math.Round(basicData.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)UnitType.特殊核算组 && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0, 0);
}
var item = new DetailDtos
{
ItemName = sheetName,
IncomeType = sheettype,
Amount = amount,
GroupBasis = groupBasis,
};
var items = sheetData?.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())
{
items = items.GroupBy(t => t.ItemName).Select(t =>
new DetailModule
{
ItemName = t.Key,
CellValue = t.Sum(group => group.CellValue),
Factor = t.FirstOrDefault().Factor,
ItemValue = t.Sum(group => group.ItemValue),
}
).ToList();
}
if (headerData != null && headerData.Any())
{
items = items
?.OrderBy(t => (headerData.FirstOrDefault(h => h.CellValue == t.ItemName)?.PointCell) ?? 100)
?.ThenBy(t => t.ItemName).ToList();
}
item.Items = items;
deptDetails.Detail.Add(item);
}
}
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)
{
......@@ -836,7 +1087,7 @@ public ag_secondallot GetAccountId(int secondId, out int accountId)
if (second != null)
{
var unitType = EnumHelper.GetItems<UnitType>().FirstOrDefault(t => t.Name == second.UnitType);
var account = perforResaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.UnitType == unitType.Value && t.Department == second.Department);
var account = perforResaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.UnitType == unitType.Value && t.AccountingUnit == second.Department);
if (account == null && second.UnitType != UnitType.特殊核算组.ToString())
throw new PerformanceException("科室信息错误");
accountId = account?.ID ?? 0;
......@@ -844,51 +1095,17 @@ public ag_secondallot GetAccountId(int secondId, out int accountId)
return second;
}
/// <summary>
/// 添加额外绩效金额(基础绩效、其他绩效等)
/// </summary>
/// <param name="allotId"></param>
/// <param name="computes"></param>
private List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> computes)
public ag_secondallot GetSecondByAccountId(int accountId)
{
if (computes == null || !computes.Any())
return computes;
var list = perapramountRepository.GetEntities(t => t.AllotId == allotId);
if (list == null || !list.Any())
return computes;
var source = new string[] { "一次绩效", "二次绩效" };
foreach (var item in list.Where(t => t.Amount.HasValue))
var special = _perforResspecialunitRepository.GetEntity(t => t.ID == accountId);
if (special == null)
throw new PerformanceException("科室信息错误");
return new ag_secondallot
{
var flag = false;
foreach (var s in source)
{
if (flag) continue;
var emp = computes.FirstOrDefault(t => t.Source == s && t.JobNumber == item.PersonnelNumber && t.EmployeeName == item.DoctorName);
if (emp != null)
{
emp.RealGiveFee += item.Amount;
flag = true;
continue;
}
emp = computes.FirstOrDefault(t => t.Source == s && t.JobNumber == item.PersonnelNumber);
if (emp != null)
{
emp.RealGiveFee += item.Amount;
flag = true;
continue;
}
emp = computes.FirstOrDefault(t => t.Source == s && t.EmployeeName == item.DoctorName);
if (emp != null)
{
emp.RealGiveFee += item.Amount;
flag = true;
continue;
}
}
}
return computes;
AllotId = special.AllotID,
Department = special.AccountingUnit,
UnitType = UnitType.特殊核算组.ToString()
};
}
}
}
}
\ No newline at end of file
......@@ -670,10 +670,11 @@ public void Copy(per_allot allot)
if (orgDurgprop == null || orgDurgprop.Count == 0)
{
var durgprop = _drugpropRepository.GetEntities(t => t.AllotID == allotId) ?? _drugpropRepository.GetEntities(t => t.AllotID == -1);
var newDurgprops = durgprop.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
if (hospital != null && hospital?.IsOpenDrugprop == 2)
newDurgprops = new List<cof_drugprop> { new cof_drugprop { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
_drugpropRepository.AddRange(newDurgprops.ToArray());
var newDurgprops = durgprop?.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
//if (hospital != null && hospital?.IsOpenDrugprop == 2)
// newDurgprops = new List<cof_drugprop> { new cof_drugprop { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
if (durgprop != null && durgprop.Any())
_drugpropRepository.AddRange(newDurgprops.ToArray());
}
logger.LogInformation($"workItem");
......@@ -791,6 +792,7 @@ private void CopyAprData(int prevAllotId, int allotId)
{
var data = list.Select(t => new per_apr_amount
{
Status = 2,
AllotId = allotId,
PersonnelNumber = t.PersonnelNumber,
DoctorName = t.DoctorName,
......
......@@ -203,15 +203,20 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s
ratio += 15m / incomemodules.Count();
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 20 ? 20 : ratio);
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取模块“{module.ModuleName}”的数据");
foreach (var config in configs)
var items = scripts.Where(t => t.TypeId == module.TypeId);
if (items != null && items.Any())
{
var item = scripts.FirstOrDefault(t => t.TypeId == module.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
var querydata = QueryData(config, allot, item.ExecScript, module.ModuleName);
if (querydata != null && querydata.Any())
foreach (var item in items)
{
perforExresultRepository.AddRange(querydata.ToArray());
data.AddRange(querydata);
var config = configs.FirstOrDefault(t => t.Id == item.ConfigId);
if (config == null) continue;
var querydata = QueryData(config, allot, item.ExecScript, module.ModuleName);
if (querydata != null && querydata.Any())
{
perforExresultRepository.AddRange(querydata.ToArray());
data.AddRange(querydata);
}
}
}
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"模块“{module.ModuleName}”的数据已完成提取");
......@@ -249,21 +254,25 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 50 ? 50 : ratio);
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取项目“{exitem.ItemName}”的数据");
var module = modules.FirstOrDefault(t => t.Id == exitem.ModuleId);
foreach (var config in configs)
var scritems = scripts.Where(t => t.TypeId == exitem.TypeId);
if (scritems != null && scritems.Any())
{
var item = scripts.FirstOrDefault(t => t.TypeId == exitem.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
var result = QueryData(config, allot, item.ExecScript, module.ModuleName);
if (result != null && result.Any())
foreach (var item in scritems)
{
result.ForEach(t =>
var config = configs.FirstOrDefault(t => t.Id == item.ConfigId);
if (config == null) continue;
var result = QueryData(config, allot, item.ExecScript, module.ModuleName);
if (result != null && result.Any())
{
t.Category = exitem.ItemName;
});
result.ForEach(t =>
{
t.Category = exitem.ItemName;
});
perforExresultRepository.AddRange(result.ToArray());
data.AddRange(result);
perforExresultRepository.AddRange(result.ToArray());
data.AddRange(result);
}
}
}
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"项目“{exitem.ItemName}”的数据已完成提取");
......@@ -299,18 +308,22 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
ratio += 10m / specials.Where(t => t.TypeId > 0).Count();
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 60 ? 60 : ratio);
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取特殊核算项“{special.Target}”的数据");
foreach (var config in configs)
var scritems = scripts.Where(t => t.TypeId == special.TypeId);
if (scritems != null && scritems.Any())
{
var item = scripts.FirstOrDefault(t => t.TypeId == special.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
var result = QueryData(config, allot, item.ExecScript, specialname);
result.ForEach(t =>
foreach (var item in scritems)
{
t.Category = special.Target;
t.Department = special.Department;
});
data.AddRange(result);
var config = configs.FirstOrDefault(t => t.Id == item.ConfigId);
if (config == null) continue;
var result = QueryData(config, allot, item.ExecScript, specialname);
result.ForEach(t =>
{
t.Category = special.Target;
t.Department = special.Department;
});
data.AddRange(result);
}
}
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"特殊核算项“{special.Target}”的数据已完成提取");
}
......@@ -411,13 +424,14 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
WriteExpend(sheet, sheetRead, modules, items, data);
break;
case SheetType.Workload:
case SheetType.OtherWorkload:
WriteWorkload(sheet, sheetRead, modules, items, data);
break;
//case SheetType.AccountBasic:
// WriteAccountBasic(sheet, sheetRead);
// break;
case SheetType.SpecialUnit:
WriteSpecialUnit(sheet, sheetRead, specials, data);
WriteSpecialUnit(sheet, sheetRead, specials, data, sheetRead.Point.DataFirstRowNum.Value);
break;
}
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入");
......@@ -506,6 +520,7 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
WriteExpend(sheet, sheetRead, modules, items, extracts, false);
break;
case SheetType.Workload:
case SheetType.OtherWorkload:
ClearData(sheet, 3, 3);
WriteWorkload(sheet, sheetRead, modules, items, extracts, false);
break;
......@@ -513,8 +528,11 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
// WriteAccountBasic(sheet, sheetRead, false);
// break;
case SheetType.SpecialUnit:
ClearData(sheet, 2, 0);
WriteSpecialUnit(sheet, sheetRead, specials, extracts, lastAllot, false);
ClearData(sheet, 2, 3, endCellNum: 4);
SupplySpecialUnit(sheet, sheetRead, specials, extracts, lastAllot, false);
break;
case SheetType.AccountExtra:
ClearData(sheet, 2, 3);
break;
}
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入");
......@@ -571,8 +589,8 @@ private List<ex_result> QueryData(sys_hospitalconfig config, per_allot allot, st
CreateTime = CreateTime,
}).ToList();
}
return data;
}
return data;
}
/// <summary>
......@@ -599,6 +617,7 @@ private List<ex_result> QueryData(sys_hospitalconfig config, per_allot allot, st
/// <param name="configs"></param>
private void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
{
logger.LogDebug($"从HIS抽取报表数据");
Dictionary<string, object> pairs = new Dictionary<string, object>
{
{ "@allotid", allot.ID },
......@@ -609,14 +628,19 @@ private void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
var imports = repimportconfigRepository.GetEntities(w => w.ScriptType == 1);
if (imports == null || !imports.Any()) return;
logger.LogDebug($"imports {JsonHelper.Serialize(imports)}");
foreach (var import in imports)
{
var conf = configs.FirstOrDefault(w => w.HospitalId == allot.HospitalId && w.Id == import.ConfigId);
if (conf != null)
{
logger.LogDebug($"conf {JsonHelper.Serialize(conf)}");
var timeRanges = import.TimeRange.SplitRemoveEmpty(",");
if (timeRanges == null || !timeRanges.Any()) continue;
logger.LogDebug($" timeRanges {JsonHelper.Serialize(timeRanges)}");
foreach (var item in timeRanges)
{
if (item == "1")
......@@ -636,9 +660,21 @@ private void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
}
try
{
logger.LogDebug($" pairs {JsonHelper.Serialize(pairs)}");
DatabaseType type = (DatabaseType)conf.DataBaseType;
var connection = ConnectionBuilder.Create(type, conf.DbSource, conf.DbName, conf.DbUser, conf.DbPassword);
foreach (var key in pairs.Keys)
{
import.ImportScript = import.ImportScript.Replace(key, pairs[key].ToString());
}
logger.LogDebug($"执行导入报表SQL:{import.TableName} -- {import.ImportScript}");
logger.LogDebug($"执行导入报表SQL参数:{import.TableName} -- {JsonHelper.Serialize(pairs)}");
var data = connection.Query(import.ImportScript, new DynamicParameters(pairs), commandTimeout: 60 * 60);
logger.LogDebug($"执行导入报表SQL查询完成 -- {data.Count()}");
perforPerallotRepository.ImportData(import, pairs, data);
}
catch (Exception ex)
......@@ -772,6 +808,7 @@ private void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook workbook
}
int sheetIndex = 0;
int newSheetCount = 0;
foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.Income)?.OrderBy(t => t.ModuleName))
{
var sheet = workbook.GetSheet(module.ModuleName);
......@@ -789,13 +826,36 @@ private void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook workbook
logger.LogInformation($"newSheet: {newSheet.SheetName}");
workbook.SetSheetOrder(newSheet.SheetName, sheetIndex);
workbook.SetSheetName(sheetIndex, module.ModuleName);
sheetIndex++; newSheetCount++;
}
}
}
sheetIndex = 0;
foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.OtherWorkload)?.OrderBy(t => t.ModuleName))
{
var sheet = workbook.GetSheet(module.ModuleName);
if (sheet == null)
{
logger.LogInformation($"CreateNotExistSheet: {module.ModuleName}");
string key = "工作量";
if (module.ModuleName.Contains(key))
{
var item = pairs.Where(t => t.Key.StartsWith("3.")).OrderByDescending(t => t.Key).First();
if (sheetIndex == 0)
sheetIndex = item.Value + newSheetCount + 1;
var copysheet = workbook.GetSheet(item.Key);
var newSheet = copysheet.CopySheet(item.Key + Guid.NewGuid().ToString("N"), true);
logger.LogInformation($"newSheet: {newSheet.SheetName}");
workbook.SetSheetOrder(newSheet.SheetName, sheetIndex);
workbook.SetSheetName(sheetIndex, module.ModuleName);
sheetIndex++;
}
}
}
}
private void ClearData(ISheet sheet, int beginRowNum, int beginCellNum, bool isIncome = false)
private void ClearData(ISheet sheet, int beginRowNum, int beginCellNum, bool isIncome = false, int? endCellNum = null)
{
if (sheet == null)
return;
......@@ -805,8 +865,9 @@ private void ClearData(ISheet sheet, int beginRowNum, int beginCellNum, bool isI
var row = sheet.GetRow(i);
if (row != null)
{
int lastCellNum = endCellNum ?? row.LastCellNum;
//跳过核算单元和科室
for (int j = beginCellNum; j < row.LastCellNum; j++)
for (int j = beginCellNum; j < lastCellNum; j++)
{
var cell = row.GetCell(j);
if (cell != null && (cell.CellType != CellType.Formula || isIncome))
......@@ -1250,7 +1311,7 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_mo
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_special> specials, List<NewExtractDto> data, per_allot lastAllot = null, bool IsWriteHead = true)
private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_special> specials, List<NewExtractDto> data, int beginRowIndex, per_allot lastAllot = null, bool IsWriteHead = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var dictionary = new Dictionary<string, Func<ex_special, List<im_specialunit>, object>>
......@@ -1270,14 +1331,11 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
if (lastAllot != null)
allotDataList = perforImspecialunitRepository.GetEntities(t => t.AllotID == lastAllot.ID);
//取消合并单元格
int mergedCount = sheet.NumMergedRegions;
for (int i = mergedCount - 1; i >= 0; i--)
{
var temp = sheet.GetMergedRegion(i);
if (temp.FirstRow > sheetRead.Point.HeaderFirstRowNum)
sheet.RemoveMergedRegion(i);
}
////取消合并单元格
//foreach (var merge in sheet.MergedRegions)
//{
// sheet.RemoveMergedRegion(sheet.MergedRegions.IndexOf(merge));
//}
var modDataGroup = speaialList.GroupBy(t => new { t.Department }).Select(group => new
{
......@@ -1285,8 +1343,8 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
Count = group.Count()
})?.OrderBy(t => t.Department);
int mergedBegin = sheetRead.Point.DataFirstRowNum.Value;
int mergedEnd = sheetRead.Point.DataFirstRowNum.Value;
int mergedBegin = beginRowIndex;
int mergedEnd = beginRowIndex;
var extractdata = data.Where(t => t.SheetName == specialname).ToList();
logger.LogInformation($"data有{extractdata?.Count ?? 0}个.");
......@@ -1297,7 +1355,7 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
var headIndex = sheetRead.Point.HeaderFirstRowNum;
var cellList = sheet.GetRow(headIndex.Value).Cells;
var rowIndex = sheetRead.Point.DataFirstRowNum.Value + i;
var rowIndex = beginRowIndex + i;
var importRow = sheet.CreateRow(rowIndex);
int cellIndex = 0;
......@@ -1340,6 +1398,201 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void SupplySpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_special> specials, List<NewExtractDto> data, per_allot lastAllot = null, bool IsWriteHead = true)
{
try
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var dictionary = new Dictionary<string, Func<ex_special, List<im_specialunit>, object>>
{
{ "科室", (special,lastallot) => special.Department?.Trim() },
{ "人数", (special,lastallot) => lastallot.Where(t=>special.Department == t.Department).Max(t=>t.Number) },
{ "量化指标", (special,lastallot) => special.Target?.Trim()},
{ "量化指标绩效分值",(special,lastallot) => special.TargetFactor },
{ "调节系数", (special,lastallot) => special.AdjustFactor },
};
List<im_specialunit> allotDataList = new List<im_specialunit>();
if (lastAllot != null)
allotDataList = perforImspecialunitRepository.GetEntities(t => t.AllotID == lastAllot.ID);
var speaialList = specials?.OrderBy(t => t.Department).ToList();
logger.LogInformation($"item有{speaialList?.Count ?? 0}个.");
if (speaialList == null || !speaialList.Any()) return;
var headIndex = sheetRead.Point.HeaderFirstRowNum;
var cellList = sheet.GetRow(headIndex.Value).Cells;
var headerDict = new Dictionary<string, int>();
cellList.ForEach(t =>
{
t.SetCellType(CellType.String);
if (!headerDict.ContainsKey(t.StringCellValue))
headerDict.Add(t.StringCellValue, cellList.IndexOf(t));
});
if (!headerDict.ContainsKey("科室") || !headerDict.ContainsKey("量化指标") || !headerDict.ContainsKey("数量")) return;
var extractdata = data.Where(t => t.SheetName == specialname).ToList();
var merges = mergefunc.Invoke(sheet, sheetRead.Point.DataFirstRowNum);
if (merges == null || !merges.Any()) return;
merges = merges.OrderBy(t => t.FirstRow).ToList();
int startRowIndex = sheetRead.Point.DataFirstRowNum ?? 2;
int lastrownumber = startRowIndex;
foreach (var merge in merges)
{
var deptSpecials = speaialList.Where(t => t.Department == merge.Value)?.ToList();
if (deptSpecials == null) continue;
for (int i = merge.FirstRow; i < merge.LastRow + 1; i++)
{
var row = GetOrCreate(sheet, i);
string target = NopiSevice.GetValue(GetOrCreate(row, headerDict["量化指标"]))?.Trim();
var config = deptSpecials.FirstOrDefault(t => t.Target == target);
if (config != null)
{
var numcell = GetOrCreate(row, headerDict["数量"]);
var value = extractdata?.FirstOrDefault(t => t.Department == merge.Value && t.Category == target)?.Value;
OutToExcelCell(numcell, value);
deptSpecials.RemoveAll(t => t.Department == merge.Value && t.Target == target);
continue;
}
}
if (deptSpecials != null && deptSpecials.Any())
{
foreach (var spec in deptSpecials)
{
sheet.ShiftRows(merge.LastRow + 1, sheet.LastRowNum, 1, true, false);
var shiftrow = sheet.CreateRow(merge.LastRow + 1);
WriteSpecialCellValue(dictionary, shiftrow, cellList, spec, allotDataList, extractdata);
var thanmerges = merges.Where(t => t.FirstRow > merge.LastRow)?.ToList();
if (thanmerges != null && thanmerges.Any())
{
thanmerges.ForEach(t =>
{
t.FirstRow += 1;
t.LastRow += 1;
});
}
merge.LastRow += 1;
}
}
speaialList.RemoveAll(t => t.Department == merge.Value);
}
//if (speaialList != null && speaialList.Any())
//{
// var index = sheet.LastRowNum + 1;
// foreach (var item in speaialList)
// {
// var newrow = sheet.CreateRow(index);
// newrow.CreateCell(0).SetCellValue("");
// index++;
// }
//}
//取消合并单元格
int mergedCount = sheet.NumMergedRegions;
for (int i = mergedCount - 1; i >= 0; i--)
{
var temp = sheet.GetMergedRegion(i);
if (temp.FirstRow > sheetRead.Point.HeaderFirstRowNum)
sheet.RemoveMergedRegion(i);
}
foreach (var merge in merges.Where(t => t.FirstColumn == 0))
{
if (merge.LastRow > merge.FirstRow)
{
CellRangeAddress region = new CellRangeAddress(merge.FirstRow, merge.LastRow, headerDict["科室"], headerDict["科室"]);
sheet.AddMergedRegion(region);
sheet.AddMergedRegion(new CellRangeAddress(merge.FirstRow, merge.LastRow, headerDict["人数"], headerDict["人数"]));
}
}
WriteSpecialUnit(sheet, sheetRead, speaialList, data, sheet.LastRowNum + 1, lastAllot, false);
}
catch (Exception ex)
{
logger.LogError("补充特殊科室数据发生异常" + ex.ToString());
}
}
private void WriteSpecialCellValue(Dictionary<string, Func<ex_special, List<im_specialunit>, object>> dictionary, IRow row, List<ICell> cellList, ex_special special, List<im_specialunit> allotDataList, List<NewExtractDto> extractdata)
{
foreach (var cell in cellList)
{
object value = null;
if (dictionary.ContainsKey(cell.StringCellValue))
{
var item = dictionary.First(t => t.Key == cell.StringCellValue);
value = item.Value.Invoke(special, allotDataList) ?? "";
}
if (cell.StringCellValue == "数量" && special?.TypeId > 0)
{
value = extractdata?.FirstOrDefault(t => t.Category == special.Target)?.Value;
}
var newCell = row.CreateCell(cellList.IndexOf(cell));
OutToExcelCell(newCell, value);
if (dictionary.ContainsKey(cell.StringCellValue) || (cell.StringCellValue == "数量" && !string.IsNullOrEmpty(value?.ToString())))
newCell.CellStyle = style;
}
}
private readonly Func<ISheet, int?, List<CellRangeAddressAndValue>> mergefunc = (sheet, beginrow) =>
{
var merges = new List<CellRangeAddressAndValue>();
//合并
int regionsCount = sheet.NumMergedRegions;
for (int i = 0; i < regionsCount; i++)
{
CellRangeAddress range = sheet.GetMergedRegion(i);
if (range != null)
{
var merge = new CellRangeAddressAndValue(range);
string value = "";
var firstrow = sheet.GetRow(range.FirstRow);
if (firstrow != null && firstrow.GetCell(range.FirstColumn) is ICell firstcell && firstcell != null)
{
firstcell.SetCellType(CellType.String);
value = firstcell.StringCellValue?.Trim();
}
merge.Value = value;
merges.Add(merge);
}
}
//非合并
int index = beginrow ?? merges.Min(t => t.FirstRow);
for (int i = index; i < sheet.LastRowNum + 1; i++)
{
if (merges.Count > 0 && !merges.Any(t => i >= t.FirstRow && i <= t.LastRow))
{
string value = "";
var firstrow = sheet.GetRow(i);
if (firstrow != null && firstrow.GetCell(merges.First().FirstColumn) is ICell firstcell && firstcell != null)
{
firstcell.SetCellType(CellType.String);
value = firstcell.StringCellValue?.Trim();
}
merges.Add(new CellRangeAddressAndValue(i, i, merges.First().FirstColumn, merges.First().LastColumn, value, false));
}
}
return merges;
};
#region 写入数据
/// <summary>
/// 写入列头
......@@ -1417,6 +1670,7 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewE
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value);
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 1;
int lastrownumber = rowIndex;
if (!isNewTemp && !isIncom)
{
#region 给历史模板已有科室补充数据
......@@ -1453,6 +1707,7 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewE
}
}
allExtract.RemoveAll(t => t.Department == department);
if (i > lastrownumber) lastrownumber = i;
}
}
#endregion
......@@ -1461,7 +1716,7 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewE
if (allExtract == null || !allExtract.Any()) return;
#region 补充新的科室及数据
var lastrowIndex = (isNewTemp || isIncom) ? rowIndex : sheet.LastRowNum + 1;
var lastrowIndex = (isNewTemp || isIncom) ? rowIndex : lastrownumber + 1;
foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct())
{
var row = GetOrCreate(sheet, lastrowIndex);
......@@ -1583,6 +1838,8 @@ private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewEx
{
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 0);
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2;
int lastrownumber = rowIndex;
if (!isNewTemp)
{
#region 给历史模板已有科室补充数据
......@@ -1613,6 +1870,7 @@ private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewEx
}
}
allExtract.RemoveAll(t => t.Department == department);
if (i > lastrownumber) lastrownumber = i;
}
}
#endregion
......@@ -1623,10 +1881,10 @@ private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewEx
//var unit = sheet.SheetName.IndexOf("医生") > -1 ? new int[] { (int)UnitType.医生组, (int)UnitType.医技组 } : new int[] { (int)UnitType.护理组 };
#region 补充新的科室及数据
var lastrowIndex = isNewTemp ? rowIndex : sheet.LastRowNum + 1;
var lastrowIndex = isNewTemp ? rowIndex : lastrownumber + 1;
foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct())
{
var row = sheet.CreateRow(lastrowIndex);
var row = GetOrCreate(sheet, lastrowIndex);
for (int i = head.FirstCellNum + 1; i < head.LastCellNum; i++)
{
var headName = head.GetCell(i).StringCellValue;
......@@ -1835,4 +2093,52 @@ public class NewExtractDto : ExtractDto
public string InpatTechnicAccounting { get; set; }
public new decimal? Value { get; set; }
}
public class CellRangeAddressAndValue
{
public CellRangeAddressAndValue()
: this(default, default, default, default, default)
{
}
public CellRangeAddressAndValue(CellRangeAddress address)
: this(address.FirstRow, address.LastRow, address.FirstColumn, address.LastColumn)
{
}
public CellRangeAddressAndValue(int firstRow, int lastRow, int firstCol, int lastCol)
: this(firstRow, lastRow, firstCol, lastCol, default)
{
}
public CellRangeAddressAndValue(int firstRow, int lastRow, int firstCol, int lastCol, string value, bool isMerge = true)
{
if (lastRow < firstRow || lastCol < firstCol)
{
throw new ArgumentException("lastRow < firstRow || lastCol < firstCol");
}
FirstRow = firstRow;
LastRow = lastRow;
FirstColumn = firstCol;
LastColumn = lastCol;
Value = value;
IsMerge = isMerge;
}
public int FirstRow { get; set; }
public int LastRow { get; set; }
public int FirstColumn { get; set; }
public int LastColumn { get; set; }
public string Value { get; set; }
public bool IsMerge { get; set; }
}
}
......@@ -388,10 +388,10 @@ public bool InsertApr(per_apr_amount request, int userId)
if (request == null)
return false;
var data = perapramountRepository.GetEntity(t => t.PersonnelNumber == request.PersonnelNumber && t.AllotId == request.AllotId);
if (data != null)
throw new PerformanceException("人员工号已存在");
//var data = perapramountRepository.GetEntity(t => t.PersonnelNumber == request.PersonnelNumber && t.AllotId == request.AllotId);
//if (data != null)
// throw new PerformanceException("人员工号已存在");
request.Status = 2;
request.CreateDate = DateTime.Now;
request.CreateUser = userId;
return perapramountRepository.Add(request);
......@@ -406,9 +406,12 @@ public bool UpdateApr(per_apr_amount request)
if (data == null)
throw new PerformanceException("修改数据无效");
data.Status = 2;
data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName;
data.PerforType = request.PerforType;
data.TypeInDepartment = request.TypeInDepartment;
data.AccountingUnit = request.AccountingUnit;
data.Amount = request.Amount;
return perapramountRepository.Update(data);
......@@ -423,6 +426,29 @@ public bool DeleteApr(int id)
return true;
}
/// <summary>
/// 审核医院其他绩效
/// </summary>
/// <param name="userid"></param>
/// <param name="request"></param>
/// <returns></returns>
public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
{
if (request.Id.Length == 0)
throw new PerformanceException("审核信息无效,请确认");
var apramounts = perapramountRepository.GetEntities(t => request.Id.Contains(t.Id));
foreach (var item in apramounts)
{
item.Status = (request.IsPass == 1) ? 3 : 4;
item.AuditUser = userid;
item.AuditTime = DateTime.Now;
item.Remark = request.Remark;
}
return perapramountRepository.UpdateRange(apramounts.ToArray());
}
public void ImpoerAprEmployees(int allotid, string path, int userid)
{
var data = perapramountRepository.GetEntities(t => t.AllotId == allotid);
......@@ -459,7 +485,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
Dictionary<string, int> dict = new Dictionary<string, int>
{
{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 },
{ "录入科室", -1 },{ "核算单元", -1 },{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 },
};
List<string> errorHeaders = new List<string>();
......@@ -483,10 +509,13 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entity = new per_apr_amount
{
PersonnelNumber = row.GetCell(dict["人员工号"])?.ToString(),
DoctorName = row.GetCell(dict["姓名"])?.ToString(),
PerforType = row.GetCell(dict["绩效类型"])?.ToString(),
Amount = (decimal)(row.GetCell(dict["金额"])?.NumericCellValue ?? 0),
Status = 2,
PersonnelNumber = row.GetCell(dict["人员工号"]).GetValue(),
DoctorName = row.GetCell(dict["姓名"]).GetValue(),
PerforType = row.GetCell(dict["绩效类型"]).GetValue(),
Amount = ConvertHelper.To<decimal>(row.GetCell(dict["金额"]).GetValue(), 0),
TypeInDepartment = row.GetCell(dict["录入科室"]).GetValue(),
AccountingUnit = row.GetCell(dict["核算单元"]).GetValue(),
AllotId = allotid,
CreateDate = createtime,
CreateUser = userid,
......
......@@ -100,33 +100,49 @@ private void DefaultModules(int hospitalId)
public ex_module AddModule(ModModuleRequest request)
{
if (request.SheetType != (int)SheetType.Income)
if (!new int[] { (int)SheetType.Income, (int)SheetType.OtherWorkload }.Contains(request.SheetType.Value))
throw new PerformanceException("模块类型错误,只支持收入模板配置");
string[] array = new string[] { "开单收入", "执行收入" };
if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
throw new PerformanceException("模块名称规则错误");
//if (!Regex.IsMatch(request.ModuleName, @"^[\u4e00-\u9fa5]+$"))
// throw new PerformanceException("模块名称规则错误,请使用全中文命名");
string addname = "";
if (request.SheetType == (int)SheetType.Income)
{
string[] array = new string[] { "开单收入", "执行收入" };
if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
throw new PerformanceException("模块名称规则错误");
//if (!Regex.IsMatch(request.ModuleName, @"^[\u4e00-\u9fa5]+$"))
// throw new PerformanceException("模块名称规则错误,请使用全中文命名");
var incomeList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
var incomeList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
if (incomeList.Any(t => Regex.Replace(t.ModuleName, @"\d", "").Replace(".", "").Replace(" ", "") == request.ModuleName))
throw new PerformanceException("绩效模板已存在!");
if (incomeList.Any(t => Regex.Replace(t.ModuleName, @"\d", "").Replace(".", "").Replace(" ", "") == request.ModuleName))
throw new PerformanceException("绩效模板已存在!");
string addname = "";
var moduleList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.ModuleName.IndexOf("1.") != -1);
string name = request.ModuleName.Replace("开单收入", "").Replace("执行收入", "");
var exist = moduleList.Where(t => t.ModuleName.Contains(name));
if (exist != null && exist.Any())
{
string modulename = exist.OrderByDescending(t => t.ModuleName).First().ModuleName;
int[] sort = Array.ConvertAll(modulename.Split(' ')[0].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries), t => ConvertHelper.TryInt(t));
sort[2] += 1;
addname = string.Join(".", sort) + " " + request.ModuleName;
var moduleList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.ModuleName.IndexOf("1.") != -1);
string name = request.ModuleName.Replace("开单收入", "").Replace("执行收入", "");
var exist = moduleList.Where(t => t.ModuleName.Contains(name));
if (exist != null && exist.Any())
{
string modulename = exist.OrderByDescending(t => t.ModuleName).First().ModuleName;
int[] sort = Array.ConvertAll(modulename.Split(' ')[0].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries), t => ConvertHelper.TryInt(t));
sort[2] += 1;
addname = string.Join(".", sort) + " " + request.ModuleName;
}
else
{
string modulename = moduleList.OrderByDescending(t => t.ModuleName).First().ModuleName;
int[] sort = Array.ConvertAll(modulename.Split(' ')[0].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries), t => ConvertHelper.TryInt(t));
sort[1] += 1;
addname = $"{sort[0]}.{sort[1]}.1 " + request.ModuleName;
}
}
else
else if (request.SheetType == (int)SheetType.OtherWorkload)
{
var incomeList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.OtherWorkload);
if (incomeList.Any(t => Regex.Replace(t.ModuleName, @"\d", "").Replace(".", "").Replace(" ", "") == request.ModuleName))
throw new PerformanceException("绩效模板已存在!");
var moduleList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.ModuleName.IndexOf("3.") != -1);
string modulename = moduleList.OrderByDescending(t => t.ModuleName).First().ModuleName;
int[] sort = Array.ConvertAll(modulename.Split(' ')[0].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries), t => ConvertHelper.TryInt(t));
sort[1] += 1;
......@@ -488,7 +504,7 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType)
public List<TitleValue> FeeType()
{
var titlevalue = new List<TitleValue>();
var type = EnumHelper.GetItems<SheetType>().Where(t => new List<int> { (int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.SpecialUnit }.Contains(t.Value));
var type = EnumHelper.GetItems<SheetType>().Where(t => new List<int> { (int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.SpecialUnit, (int)SheetType.OtherWorkload }.Contains(t.Value));
if (type != null && type.Any())
{
titlevalue = type.Select(t => new TitleValue
......
using Dapper;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services
{
public class ExtractIncomeService : IAutoInjection
{
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
private readonly PerforExscriptRepository exscriptRepository;
private readonly ILogger logger;
public ExtractIncomeService(
PerforPerallotRepository perallotRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
PerforExscriptRepository exscriptRepository,
ILogger<ExtractIncomeService> logger
)
{
this.perallotRepository = perallotRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
this.logger = logger;
}
public string Execture(int allotId)
{
try
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("选取的绩效无效!");
var pairs = GetIncomeData(allot);
string filepath = CreateExcel(allot.HospitalId, pairs);
if (string.IsNullOrEmpty(filepath) || !FileHelper.IsExistFile(filepath))
throw new PerformanceException("抽取文件错误");
logger.LogInformation("医生收入文件: " + filepath);
return filepath;
}
catch (PerformanceException ex)
{
throw ex;
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
throw new PerformanceException("抽取数据过程中发生异常!");
}
}
private Dictionary<string, List<IncomeDataDto>> GetIncomeData(per_allot allot)
{
var configs = hospitalconfigRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (configs == null || !configs.Any()) throw new PerformanceException("未添加医院提取配置");
var types = extypeRepository.GetEntities(t => t.Source == 100);
if (types == null || !types.Any()) throw new PerformanceException("未配置数据提取内容");
Dictionary<string, List<IncomeDataDto>> pairs = new Dictionary<string, List<IncomeDataDto>>();
foreach (var item in types)
{
pairs.Add(item.EName, new List<IncomeDataDto>());
var scripts = exscriptRepository.GetEntities(t => t.TypeId == item.Id);
if (scripts == null || !scripts.Any()) continue;
foreach (var script in scripts)
{
var config = configs.FirstOrDefault(t => t.Id == script.ConfigId);
if (config == null) continue;
var data = QueryData(config, allot, script.ExecScript);
if (data != null && data.Any())
pairs[item.EName].AddRange(data);
}
}
return pairs;
}
private IEnumerable<IncomeDataDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql)
{
try
{
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
{
foreach (var item in parameters)
{
execsql = Regex.Replace(execsql, item.Key, item.Value, RegexOptions.IgnoreCase);
}
logger.LogInformation("获取医生收入sql: " + execsql + "\n配置:" + JsonHelper.Serialize(config));
var result = connection.Query<IncomeDataDto>(execsql, commandTimeout: 20000);
return result;
}
}
catch (Exception ex)
{
logger.LogError("获取医生收入时发生异常: " + ex.ToString());
}
return new List<IncomeDataDto>();
}
private string CreateExcel(int hospitalId, Dictionary<string, List<IncomeDataDto>> dataDict)
{
if (dataDict == null || !dataDict.Any(t => t.Value != null && t.Value.Any())) throw new PerformanceException("未查询到数据!");
IWorkbook workbook = new XSSFWorkbook();
ICellStyle cellStyle = getCellStyle.Invoke(workbook);
foreach (var dict in dataDict.Where(t => t.Value != null && t.Value.Any()))
{
ISheet sheet = workbook.CreateSheet(dict.Key);
var columns = memberDict.Keys.ToList();
var categories = dict.Value.Select(s => s.Category).Distinct().OrderBy(t => t);
columns.AddRange(categories);
CreateHeader(sheet, cellStyle, columns);
int rowIndex = sheet.LastRowNum + 1;
var groupData = dict.Value.GroupBy(t => new { t.EmpCode, t.EmpName, t.DeptName, t.ExecDeptName });
foreach (var data in groupData)
{
IRow row = sheet.CreateRow(rowIndex);
int index = 0;
foreach (var field in columns)
{
ICell cell = row.CreateCell(index);
if (memberDict.ContainsKey(field))
OutToExcelCell(cell, memberDict[field]?.Invoke(data.Key));
else
{
var value = data.FirstOrDefault(t => t.Category == field)?.Fee;
if (value.HasValue)
OutToExcelCell(cell, value.Value);
}
cell.CellStyle = cellStyle;
index++;
}
rowIndex++;
}
}
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "income");
if (!FileHelper.IsExistDirectory(path))
FileHelper.CreateDirectory(path);
string filepath = Path.Combine(path, $"医生收入{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx");
using (FileStream fs = new FileStream(filepath, FileMode.Create))
{
workbook.Write(fs);
}
if (workbook != null) workbook.Close();
return filepath;
}
private void CreateHeader(ISheet sheet, ICellStyle cellStyle, List<string> columns)
{
IRow row = sheet.CreateRow(0);
if (row == null) return;
int index = 0;
foreach (var col in columns)
{
ICell cell = row.CreateCell(index);
cell.SetCellValue(col);
cell.CellStyle = cellStyle;
index++;
}
sheet.CreateFreezePane(memberDict.Count, 1); //首行冻结
}
private Dictionary<string, string> GetParameters(per_allot allot)
{
DateTime beginTime = new DateTime(allot.Year, allot.Month, 1);
Dictionary<string, string> pairs = new Dictionary<string, string>
{
{ "@beginTime", $"'{beginTime.ToString("yyyy-MM-dd")}'" },
{ "@endTime", $"'{beginTime.AddMonths(1).ToString("yyyy-MM-dd")}'"},
};
return pairs;
}
public void OutToExcelCell(ICell cell, object obj)
{
if (obj == null)
{
cell.SetCellValue("");
return;
}
string value = obj.ToString();
try
{
var type = obj.GetType();
switch (type.ToString())
{
case "System.String"://字符串类型
cell.SetCellValue(value);
break;
case "System.DateTime"://日期类型
DateTime dateV;
DateTime.TryParse(value, out dateV);
cell.SetCellValue(dateV.ToString("yyyy/M/d"));
break;
case "System.Boolean"://布尔型
bool boolV = false;
bool.TryParse(value, out boolV);
cell.SetCellValue(boolV);
break;
case "System.Int16"://整型
case "System.Int32":
case "System.Int64":
case "System.Byte":
int intV = 0;
int.TryParse(value, out intV);
cell.SetCellValue(intV);
break;
case "System.Decimal"://浮点型
case "System.Double":
double doubV = 0;
double.TryParse(value, out doubV);
cell.SetCellValue(doubV);
break;
case "System.DBNull"://空值处理
cell.SetCellValue("");
break;
default:
cell.SetCellValue("");
break;
}
}
catch
{
cell.SetCellValue(value);
}
}
private readonly Dictionary<string, Func<dynamic, object>> memberDict = new Dictionary<string, Func<dynamic, object>>
{
{ "医生工号", (t) => t.EmpCode },
{ "医生姓名", (t) => t.EmpName },
{ "开单科室", (t) => t.DeptName },
{ "执行科室", (t) => t.ExecDeptName },
//{ "费用类型", (t) => t.Category },
//{ "费用", (t) => t.Fee }
};
private readonly Func<IWorkbook, ICellStyle> getCellStyle = (workbook) =>
{
IFont font = workbook.CreateFont();
font.FontHeightInPoints = 12;
font.FontName = "微软雅黑";
ICellStyle cellStyle = workbook.CreateCellStyle();
cellStyle.Alignment = HorizontalAlignment.Center;//设置水平居中
cellStyle.VerticalAlignment = VerticalAlignment.Center;//设置垂直居中
cellStyle.SetFont(font);
return cellStyle;
};
}
public class IncomeDataDto
{
/// <summary>
/// 医生工号
/// </summary>
public string EmpCode { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string EmpName { get; set; }
/// <summary>
/// 开单科室
/// </summary>
public string DeptName { get; set; }
/// <summary>
/// 执行科室
/// </summary>
public string ExecDeptName { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string Category { get; set; }
/// <summary>
/// 费用
/// </summary>
public decimal Fee { get; set; }
}
}
using Microsoft.Extensions.Logging;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Performance.Services
{
public class HistoryService : IAutoInjection
{
private readonly ILogger<EmployeeService> logger;
private readonly PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository;
private readonly PerforReportoriginalstaysRepository reportoriginalstaysRepository;
private readonly PerforReportoriginalpersontimeRepository reportoriginalpersontimeRepository;
public HistoryService(
ILogger<EmployeeService> logger,
PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository,
PerforReportoriginalstaysRepository reportoriginalstaysRepository,
PerforReportoriginalpersontimeRepository reportoriginalpersontimeRepository)
{
this.logger = logger;
this.reportoriginalsurgeryRepository = reportoriginalsurgeryRepository;
this.reportoriginalstaysRepository = reportoriginalstaysRepository;
this.reportoriginalpersontimeRepository = reportoriginalpersontimeRepository;
}
public void ImportHistoryData(int hospitalid, string path)
{
try
{
var entities = ReadExcelData(hospitalid, path);
var @data1 = entities.Where(w => w.SheetName == "工作量");
if (@data1.Any())
{
var years = @data1.Select(s => s.Year).Distinct().ToList();
var months = @data1.Select(s => s.Month).Distinct().ToList();
reportoriginalpersontimeRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_persontime>>(@data1);
reportoriginalpersontimeRepository.AddRange(@data.ToArray());
}
var @data2 = entities.Where(w => w.SheetName == "手术量");
if (@data2.Any())
{
var years = @data2.Select(s => s.Year).Distinct().ToList();
var months = @data2.Select(s => s.Month).Distinct().ToList();
reportoriginalsurgeryRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_surgery>>(@data2);
reportoriginalsurgeryRepository.AddRange(@data.ToArray());
}
var @data3 = entities.Where(w => w.SheetName == "住院天数");
if (@data3.Any())
{
var years = @data3.Select(s => s.Year).Distinct().ToList();
var months = @data3.Select(s => s.Month).Distinct().ToList();
reportoriginalstaysRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_stays>>(@data3);
reportoriginalstaysRepository.AddRange(@data.ToArray());
}
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
}
}
private List<HistoryData> ReadExcelData(int hospitalid, string path)
{
var entities = new List<HistoryData>();
var config = new[]
{
new { sheetName = "工作量", columnNames = new string[] { "年份", "月份", "来源", "核算单元", "科室", "数量" } },
new { sheetName = "手术量", columnNames = new string[] { "年份", "月份", "来源", "核算单元", "科室", "数量" } },
new { sheetName = "住院天数", columnNames = new string[] { "年份", "月份", "来源", "核算单元", "科室", "数量" } },
};
IWorkbook workbook = null;
var version = FileHelper.GetExtension(path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
{
workbook = (version == ExcelVersion.xlsx)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
if (workbook == null) return entities;
foreach (var cfg in config)
{
var sheet = workbook.GetSheet(cfg.sheetName);
if (sheet == null) continue;
var firstRow = sheet.GetRow(0);
List<(string, int)> excelheader = new List<(string, int)>();
for (int cellindex = 0; cellindex < firstRow.LastCellNum + 1; cellindex++)
{
var cell = firstRow.GetCell(cellindex);
if (cell == null) continue;
if (!string.IsNullOrEmpty(cell.ToString()))
excelheader.Add((cell.ToString(), cellindex));
}
if (excelheader == null || !excelheader.Any())
throw new PerformanceException("上传excel内容错误");
Dictionary<string, int> dict = new Dictionary<string, int>();
cfg.columnNames.ToList().ForEach(w => dict.Add(w, -1));
List<string> errorHeaders = new List<string>();
foreach (var key in dict.Keys.ToList())
{
if (!excelheader.Select(t => t.Item1).Contains(key)) errorHeaders.Add(key);
else dict[key] = excelheader.First(t => t.Item1 == key).Item2;
}
if (errorHeaders != null && errorHeaders.Any())
throw new PerformanceException($"excel缺少列{string.Join(", ", errorHeaders)}");
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
{
var row = sheet.GetRow(rowindex);
if (row == null) continue;
var entity = new HistoryData
{
SheetName = cfg.sheetName,
HospitalID = hospitalid,
Year = ConvertHelper.To<int>(row.GetCell(dict["年份"]).GetValue()),
Month = ConvertHelper.To<int>(row.GetCell(dict["月份"]).GetValue()),
SourceType = row.GetCell(dict["来源"]).GetValue(),
AccountingUnit = row.GetCell(dict["核算单元"]).GetValue(),
Department = row.GetCell(dict["科室"]).GetValue(),
ResultData = ConvertHelper.To<decimal>(row.GetCell(dict["数量"]).GetValue()),
};
entities.Add(entity);
}
}
return entities;
}
}
}
......@@ -133,6 +133,7 @@ public HospitalResponse Update(HospitalRequest request)
//hospital.IsOpenDirector = request.IsOpenDirector;
hospital.IsOpenDrugprop = request.IsOpenDrugprop;
hospital.IsShowManage = request.IsShowManage;
hospital.IsOpenCMIPercent = request.IsOpenCMIPercent;
//hospital.IsOpenIncome = request.IsOpenIncome;
if (!_hospitalRepository.Update(hospital))
......
......@@ -183,7 +183,7 @@ private bool EditAccountBasic(int userId, OriginalRequest request)
{ "核算单元人员数量", nameof(im_accountbasic.DoctorNumber) },
{ "预算比例", nameof(im_accountbasic.DoctorBasicFactor) },
//{ "倾斜系数", nameof(im_accountbasic.DoctorSlopeFactor) },
{ "工作量倾斜系数", nameof(im_accountbasic.WorkSlopeFactor) },
//{ "工作量倾斜系数", nameof(im_accountbasic.WorkSlopeFactor) },
{ "保底绩效参考标准", nameof(im_accountbasic.MinimumReference) },
{ "保底绩效系数", nameof(im_accountbasic.MinimumFactor) },
{ "其他绩效1", nameof(im_accountbasic.DoctorOtherPerfor1) },
......
......@@ -358,7 +358,10 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<PerS
var basicRule = basicRuleList.FirstOrDefault(t => t.UnitType == (UnitType)resAccount.UnitType);
if (basicRule == null) continue;
var avg = (resAccount.ManagerNumber + resAccount.Number) == 0 ? 0 : resAccount.PerforTotal / (resAccount.ManagerNumber + resAccount.Number);
// 优先取 实际人均绩效
var avg = (empolyee.FitPeopleValue.HasValue && empolyee.FitPeopleValue > 0)
? empolyee.FitPeopleValue
: (resAccount.ManagerNumber + resAccount.Number) == 0 ? 0 : resAccount.PerforTotal / (resAccount.ManagerNumber + resAccount.Number);
var effAvg = empolyee.PermanentStaff == 0 ? 0 : resAccount.PerforTotal / empolyee.PermanentStaff;
//var efficiency = avg * (empolyee.Efficiency ?? 1);
......@@ -371,24 +374,29 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<PerS
AccountType = basicRule.AccountUnitType.ToString(),
EmployeeName = empolyee.DoctorName,
FitPeople = empolyee.FitPeople,
FitPeopleRatio = empolyee.FitPeopleRatio,
FitPeopleValue = empolyee.FitPeopleValue,
JobTitle = empolyee.JobTitle,
JobNumber = empolyee.JobNumber,
ScoreAverageRate = empolyee.ScoreAverageRate,
//OtherPerfor = empolyee.OtherPerfor,
AssessBeforeOtherFee = empolyee.AssessBeforeOtherFee ?? 0,
ScoreAverageRate = empolyee.ScoreAverageRate ?? 0,
AssessLaterOtherFee = empolyee.AssessLaterOtherFee ?? 0,
AdjustLaterOtherFee = empolyee.AdjustLaterOtherFee ?? 0,
OtherPerfor = empolyee.OtherPerfor ?? 0,
OtherManagePerfor = empolyee.OtherManagePerfor ?? 0,
Number = resAccount.ManagerNumber + resAccount.Number,
PerforTotal = resAccount.PerforTotal,
Avg = avg,
Efficiency = effAvg * (empolyee.Efficiency ?? 1),
Scale = resAccount.PerforTotal * (empolyee.Scale ?? 1),
Adjust = isBudget ? adjust : empolyee.Adjust,
Efficiency = effAvg * (empolyee.Efficiency ?? 0),
Scale = resAccount.PerforTotal * (empolyee.Scale ?? 0),
Adjust = (isBudget ? adjust : empolyee.Adjust) ?? 1m,
Remark = empolyees.Count() > 1 ? "特殊科室主任,共用核算单元" : "",
Grant = isBudget ? grant : empolyee.Management,
Grant = (isBudget ? grant : empolyee.Management) ?? 0,
ManagerNumber = resAccount.ManagerNumber,
MedicalNumber = resAccount.Number,
PermanentStaff = empolyee.PermanentStaff,
Attendance = empolyee.Attendance
Attendance = empolyee.Attendance ?? 0,
};
var extra = employeeExtra?.Where(w => !string.IsNullOrEmpty(w.AccountingUnit) && !string.IsNullOrEmpty(w.UnitType)
......@@ -398,15 +406,15 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<PerS
compute.Punishment = extra ?? 0;
//应发管理绩效
compute.ShouldGiveFee = Math.Round((compute.Efficiency + compute.Scale) * (compute.Grant ?? 0) ?? 0);
compute.ShouldGiveFee = Math.Round((compute.Efficiency + compute.Scale + compute.OtherManagePerfor) * compute.Grant ?? 0);
//绩效合计
compute.PerforSumFee = Math.Round((compute.Avg * (empolyee.Basics ?? 0)) + compute.ShouldGiveFee ?? 0);
compute.PerforSumFee = Math.Round((compute.Avg * (empolyee.Basics ?? 0)) + compute.ShouldGiveFee + compute.AssessBeforeOtherFee ?? 0);
//应发绩效
//compute.GiveFee = compute.PerforSumFee;
compute.GiveFee = Math.Round(compute.PerforSumFee * compute.ScoreAverageRate * (compute.Attendance ?? 0) + (extra ?? 0) ?? 0);
compute.GiveFee = Math.Round(compute.PerforSumFee * compute.ScoreAverageRate * compute.Attendance + compute.Punishment + compute.OtherPerfor + compute.AssessLaterOtherFee ?? 0);
//实发绩效
//compute.RealGiveFee = (compute.GiveFee * compute.ScoreAverageRate * (compute.Attendance ?? 0) + (compute.Punishment ?? 0) + (compute.OtherPerfor ?? 0)) * (compute.Adjust ?? 1m);
compute.RealGiveFee = Math.Round(compute.GiveFee * (compute.Adjust ?? 1m) ?? 0);
compute.RealGiveFee = Math.Round(compute.GiveFee * compute.Adjust + compute.AdjustLaterOtherFee ?? 0);
// 参考基数专用绩效合计
compute.BaiscNormPerforTotal = compute.PerforSumFee;
......@@ -447,52 +455,69 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot
{
// 奖罚汇总
var extra = employeeExtra?.Where(w => !string.IsNullOrEmpty(w.AccountingUnit) && !string.IsNullOrEmpty(w.UnitType) && (!string.IsNullOrEmpty(w.EmployeeName) || !string.IsNullOrEmpty(w.JobNumber)))
.FirstOrDefault(w => w.AccountingUnit == item.AccountingUnit && w.UnitType == item.UnitType && w.JobNumber == item.JobNumber && w.EmployeeName == item.DoctorName)
.FirstOrDefault(w => w.AccountingUnit == item.AccountingUnit && w.UnitType == item.AccountType && w.JobNumber == item.JobNumber && w.EmployeeName == item.DoctorName)
?.TotelValue;
var itemAdjust = isBudget ? adjust : item.Adjust;
var compute = new ComputeResult
{
AccountType = item.AccountType,
AccountingUnit = item.AccountingUnit,
EmployeeName = item.DoctorName,
FitPeople = item.FitPeople,
FitPeopleRatio = item.FitPeopleRatio ?? 0,
FitPeopleValue = item.FitPeopleValue ?? 0,
Grant = isBudget ? grant : (item.Management ?? 1),
//WorkTime = item.WorkTime,
PostCoefficient = item.PostCoefficient,
Attendance = item.Attendance,
ScoreAverageRate = item.ScoreAverageRate,
PostCoefficient = item.PostCoefficient ?? 0,
Attendance = item.Attendance ?? 0,
ScoreAverageRate = item.ScoreAverageRate ?? 0,
Punishment = extra ?? 0,
OtherPerfor = item.OtherPerfor,
OtherPerfor = item.OtherPerfor ?? 0,
JobTitle = item.JobTitle,
JobNumber = item.JobNumber,
Adjust = itemAdjust,
Adjust = (isBudget ? adjust : item.Adjust) ?? 1m,
//Workload = item.Workload
AssessBeforeOtherFee = item?.AssessBeforeOtherFee ?? 0,
AssessLaterOtherFee = item?.AssessLaterOtherFee ?? 0,
AdjustLaterOtherFee = item?.AdjustLaterOtherFee ?? 0,
};
decimal? baiscnorm = 1;
var perforTypeItem = perforTypeArray.FirstOrDefault(t => t.Description == item.FitPeople);
if (perforTypeItem != null)
decimal? baiscnorm = compute?.FitPeopleValue ?? 0;
if (baiscnorm == 0)
{
var perforType = (PerforType)perforTypeItem.Value;
baiscnorm = item.FitPeopleValue ?? baiscNormService.GetBaiscNorm(baiscnormList, perforType);
var perforTypeItem = perforTypeArray.FirstOrDefault(t => t.Description == item.FitPeople);
if (perforTypeItem != null)
{
var perforType = (PerforType)perforTypeItem.Value;
baiscnorm = item.FitPeopleValue ?? baiscNormService.GetBaiscNorm(baiscnormList, perforType);
compute.FitPeopleValue = baiscnorm;
}
}
// 行政高层 行政中层 夜班费
if (AccountUnitType.行政高层.ToString() == involve || AccountUnitType.行政中层.ToString() == involve)
compute.NightWorkPerfor = item.NightWorkPerfor;
//添加参数计算
compute.BaiscNormValue = baiscnorm * (item.FitPeopleRatio ?? 0);
//绩效合计
compute.PerforTotal = compute.BaiscNormValue * compute.PostCoefficient * compute.Attendance;
// 行政高层 行政中层 考核前其他绩效
if (AccountUnitType.行政高层.ToString() == involve || AccountUnitType.行政中层.ToString() == involve)
compute.PerforTotal = compute.PerforTotal + compute.AssessBeforeOtherFee;
//应发绩效
compute.GiveFee = compute.BaiscNormValue * compute.PostCoefficient * compute.Attendance + compute.Punishment;
// 行政中高层 不需要其他绩效 行政工勤 不需要考核得分率 区分开计算
if (AccountUnitType.行政工勤.ToString() == involve)
compute.GiveFee = Math.Round(compute.GiveFee + (compute.OtherPerfor ?? 0) ?? 0);
compute.GiveFee = Math.Round(compute.GiveFee + compute.OtherPerfor ?? 0);
else
compute.GiveFee = Math.Round((compute.GiveFee * compute.ScoreAverageRate) ?? 0);
compute.GiveFee = Math.Round((compute.GiveFee * compute.ScoreAverageRate + compute.AssessLaterOtherFee) ?? 0);
//实发绩效
compute.RealGiveFee = Math.Round((compute.GiveFee * (itemAdjust ?? 1)) ?? 0);
compute.RealGiveFee = Math.Round((compute.GiveFee * compute.Adjust + compute.AdjustLaterOtherFee) ?? 0);
computeList.Add(compute);
}
}
......
......@@ -19,9 +19,13 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataEmployee.FitPeopleRatio), "绩效基数核算系数", true),
new ColumnInfo(nameof(PerDataEmployee.AccountType), "人员分类"),
new ColumnInfo(nameof(PerDataEmployee.PostCoefficient), "岗位系数", true),
new ColumnInfo(nameof(PerDataEmployee.NightWorkPerfor), "夜班费"),
new ColumnInfo(nameof(PerDataEmployee.AssessBeforeOtherFee), "考核前其他绩效", true),
new ColumnInfo(nameof(PerDataEmployee.ScoreAverageRate), "考核得分率", true),
new ColumnInfo(nameof(PerDataEmployee.AssessLaterOtherFee), "考核后其他绩效", true),
new ColumnInfo(nameof(PerDataEmployee.Attendance), "出勤率", true),
new ColumnInfo(nameof(PerDataEmployee.Adjust), "调节系数", true),
new ColumnInfo(nameof(PerDataEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
};
......@@ -34,14 +38,20 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataClinicEmployee.DoctorName), "医生姓名"),
new ColumnInfo(nameof(PerDataClinicEmployee.JobTitle), "职务分类"),
new ColumnInfo(nameof(PerDataClinicEmployee.Basics), "基础绩效系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.FitPeopleValue), "实际人均绩效", true),
new ColumnInfo(nameof(PerDataClinicEmployee.PermanentStaff), "效率绩效人数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.Efficiency), "效率绩效系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.Scale), "规模绩效系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.Management), "管理绩效发放系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.AssessBeforeOtherFee), "考核前其他绩效", true),
new ColumnInfo(nameof(PerDataClinicEmployee.ScoreAverageRate), "考核得分率", true),
new ColumnInfo(nameof(PerDataClinicEmployee.AssessLaterOtherFee), "考核后其他绩效", true),
new ColumnInfo(nameof(PerDataClinicEmployee.Attendance), "出勤率", true),
new ColumnInfo(nameof(PerDataClinicEmployee.OtheManagementPerfor), "其他管理绩效"),
new ColumnInfo(nameof(PerDataClinicEmployee.OtherManagePerfor), "其他管理绩效"),
new ColumnInfo(nameof(PerDataClinicEmployee.OthePerfor), "其他绩效"),
//new ColumnInfo(nameof(PerDataClinicEmployee.NightWorkPerfor), "夜班费"),
new ColumnInfo(nameof(PerDataClinicEmployee.Adjust), "调节系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
};
......@@ -52,12 +62,13 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataLogisticsEmployee.FitPeople), "绩效基数核算参考对象"),
new ColumnInfo(nameof(PerDataLogisticsEmployee.FitPeopleValue), "绩效基础核算参考值", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.FitPeopleRatio), "绩效基数核算系数", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.JobNumber), "人员工号"),
new ColumnInfo(nameof(PerDataLogisticsEmployee.PersonnelNumber), "人员工号"),
new ColumnInfo(nameof(PerDataLogisticsEmployee.DoctorName), "人员姓名"),
new ColumnInfo(nameof(PerDataLogisticsEmployee.JobTitle), "职务分类"),
new ColumnInfo(nameof(PerDataLogisticsEmployee.PostCoefficient), "岗位系数", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.Attendance), "出勤率", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.OthePerfor), "其他绩效", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
};
public static ColumnInfo[] AccountBaisc { get; set; } = new ColumnInfo[]
......@@ -68,8 +79,11 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataAccountBaisc.Number), "核算单元人员数量", true),
new ColumnInfo(nameof(PerDataAccountBaisc.BasicFactor), "预算比例", true),
new ColumnInfo(nameof(PerDataAccountBaisc.OtherPerfor1), "其他绩效1", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AssessBeforeOtherFee), "考核前其他绩效", true),
new ColumnInfo(nameof(PerDataAccountBaisc.ScoringAverage), "考核得分率", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AssessLaterOtherFee), "考核后其他绩效", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AdjustFactor), "调节系数", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AdjustLaterOtherFee), "调节后其他绩效", true),
};
}
......
......@@ -12,53 +12,53 @@ namespace Performance.Services
{
public static class NopiSevice
{
public static string GetCellStringValue(ICell cell)
{
if (cell != null)
{
try
{
switch (cell.CellType)
{
case CellType.Numeric:
return cell.NumericCellValue.ToString().Replace("0", "");
case CellType.String:
return cell.StringCellValue.ToString().Replace("0", "");
case CellType.Formula:
cell.SetCellType(CellType.String);
return cell.StringCellValue.ToString().Replace("0", "");
}
}
catch (Exception ex)
{
//throw ex;
}
}
return null;
}
public static decimal? GetCellValue(ICell cell)
{
if (cell != null)
{
try
{
switch (cell.CellType)
{
case CellType.Numeric:
return ConvertHelper.To<decimal?>(cell.NumericCellValue);
case CellType.String:
return ConvertHelper.To<decimal?>(cell.StringCellValue);
case CellType.Formula:
return ConvertHelper.To<decimal?>(cell.NumericCellValue);
}
}
catch (Exception ex)
{
//throw ex;
}
}
return null;
}
//public static string GetCellStringValue(ICell cell)
//{
// if (cell != null)
// {
// try
// {
// switch (cell.CellType)
// {
// case CellType.Numeric:
// return cell.NumericCellValue.ToString().Replace("0", "");
// case CellType.String:
// return cell.StringCellValue.ToString().Replace("0", "");
// case CellType.Formula:
// cell.SetCellType(CellType.String);
// return cell.StringCellValue.ToString().Replace("0", "");
// }
// }
// catch (Exception ex)
// {
// //throw ex;
// }
// }
// return null;
//}
//public static decimal? GetCellValue(ICell cell)
//{
// if (cell != null)
// {
// try
// {
// switch (cell.CellType)
// {
// case CellType.Numeric:
// return ConvertHelper.To<decimal?>(cell.NumericCellValue);
// case CellType.String:
// return ConvertHelper.To<decimal?>(cell.StringCellValue);
// case CellType.Formula:
// return ConvertHelper.To<decimal?>(cell.NumericCellValue);
// }
// }
// catch (Exception ex)
// {
// //throw ex;
// }
// }
// return null;
//}
public static string GetValue(this ICell cell)
{
......@@ -73,7 +73,8 @@ public static string GetValue(this ICell cell)
case CellType.String:
return cell?.StringCellValue.ToString();
case CellType.Formula:
return cell?.NumericCellValue.ToString();
cell?.SetCellType(CellType.String);
return cell?.StringCellValue.ToString();
case CellType.Boolean:
return cell?.BooleanCellValue.ToString();
case CellType.Unknown:
......@@ -97,25 +98,25 @@ public static bool TryGetPoint(List<PerHeader> headers, string title, out int po
return x.HasValue;
}
public static DateTime? GetCellDatetimeValue(ICell cell)
{
if (cell != null)
{
if (cell.CellType == CellType.Numeric)
{
if (HSSFDateUtil.IsCellDateFormatted(cell))
{
return cell.DateCellValue;
}
}
else if (cell.CellType == CellType.String)
{
var reg = @"(19|20)\d{2}(-|/)[01]?\d(-|/)[0123]?\d( [012]?\d\:\d{2}\:\d{2})?";
if (!string.IsNullOrEmpty(cell.StringCellValue) && Regex.Match(cell.StringCellValue.Trim(), reg).ToString() == cell.StringCellValue.Trim())
return ConvertHelper.To<DateTime>(cell.StringCellValue);
}
}
return null;
}
//public static DateTime? GetCellDatetimeValue(ICell cell)
//{
// if (cell != null)
// {
// if (cell.CellType == CellType.Numeric)
// {
// if (HSSFDateUtil.IsCellDateFormatted(cell))
// {
// return cell.DateCellValue;
// }
// }
// else if (cell.CellType == CellType.String)
// {
// var reg = @"(19|20)\d{2}(-|/)[01]?\d(-|/)[0123]?\d( [012]?\d\:\d{2}\:\d{2})?";
// if (!string.IsNullOrEmpty(cell.StringCellValue) && Regex.Match(cell.StringCellValue.Trim(), reg).ToString() == cell.StringCellValue.Trim())
// return ConvertHelper.To<DateTime>(cell.StringCellValue);
// }
// }
// return null;
//}
}
}
......@@ -72,8 +72,18 @@ public static IPerSheetDataRead GetDataRead(SheetType sheetType, bool isnew = fa
dataread = new PerSheetDataReadAccountExtra();
//dataread = new PerSheetDataReadAccountMaterialsAssess(); // 科室材料考核
break;
case SheetType.AccountScoreAverage:
dataread = new PerSheetDataReadAccountExtra();
break;
case SheetType.AccountAdjustLaterOtherFee:
//dataread = new PerSheetDataReadPersonExtra(); // 科室调节后其他绩效
dataread = new PerSheetDataReadAccountExtra();
break;
case SheetType.PersonAdjustLaterOtherFee:
dataread = new PerSheetDataReadPersonExtra(); // 业务中层行政中高层调节后其他绩效
break;
}
return dataread;
}
}
}
}
\ No newline at end of file
......@@ -104,6 +104,12 @@ public SheetType GetSheetType(string sheetName)
return SheetType.AccountDrugAssess;
else if (sheetName.StartsWith("5.4"))
return SheetType.AccountMaterialsAssess;
else if (sheetName.StartsWith("6.1"))
return SheetType.AccountScoreAverage;
else if (sheetName.StartsWith("6.2"))
return SheetType.AccountAdjustLaterOtherFee;
else if (sheetName.StartsWith("6.3"))
return SheetType.PersonAdjustLaterOtherFee;
return SheetType.Unidentifiable;
}
}
......
......@@ -99,7 +99,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
/// </summary>
/// <param name="sheet"></param>
/// <returns></returns>
public (PerSheet Sheet, List<PerData> PerData) TwiceCompute(PerSheet sheet, List<CofDrugProp> confs = null, List<cof_cmi> cmis = null, List<cof_workitem> workitems = null, bool isDoctor = false)
public (PerSheet Sheet, List<PerData> PerData) TwiceCompute(PerSheet sheet, sys_hospital hospital, List<CofDrugProp> confs = null, List<cof_cmi> cmis = null, List<cof_workitem> workitems = null, bool isDoctor = false)
{
//获取最大列坐标位置
int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1;
......@@ -115,7 +115,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
{
var ds = group.Select(t =>
{
var (cellvalue, factor) = ComputValue(group, confs, cmis, workitems, isDoctor);
var (cellvalue, factor) = ComputValue(group, hospital, confs, cmis, workitems, isDoctor);
var dto = new PerData
{
......@@ -140,7 +140,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
return (sheet, perDataList);
}
private (decimal?, decimal?) ComputValue(IGrouping<object, PerData> group, List<CofDrugProp> confs = null, List<cof_cmi> cmis = null, List<cof_workitem> workitems = null, bool isDoctor = false)
private (decimal?, decimal?) ComputValue(IGrouping<object, PerData> group, sys_hospital hospital, List<CofDrugProp> confs = null, List<cof_cmi> cmis = null, List<cof_workitem> workitems = null, bool isDoctor = false)
{
var unittype = isDoctor ? new List<int> { (int)UnitType.医生组, (int)UnitType.医技组, (int)UnitType.专家组, (int)UnitType.其他医生组, (int)UnitType.其他医技组, (int)UnitType.特殊核算组 } : new List<int> { (int)UnitType.护理组, (int)UnitType.其他护理组 };
......@@ -149,8 +149,8 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
return (group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue), null);
else
{
var factor = confs?.FirstOrDefault(t => t.AccoutingUnit == group.First().AccountingUnit)?.Factor ?? 1;
var cmifactor = cmis?.FirstOrDefault(t => t.AccountingUnit == group.First().AccountingUnit && unittype.Contains(t.UnitType))?.Value ?? 1;
var factor = hospital.IsOpenDrugprop == 2 ? 1 : (confs?.FirstOrDefault(t => t.AccoutingUnit == group.First().AccountingUnit)?.Factor ?? 1);
var cmifactor = hospital.IsOpenCMIPercent == 2 ? 1 : (cmis?.FirstOrDefault(t => t.AccountingUnit == group.First().AccountingUnit && unittype.Contains(t.UnitType))?.Value ?? 1);
//需要乘系数的项
var fgroup = group.Where(t => workitems.Select(s => s.Item).Contains(t.TypeName));
//需要乘系数的项
......@@ -171,7 +171,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
value += ngroup.Sum(s =>
{
var cellvalue = s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue;
if (workitems.Any(w => w.Type == 2) && workitems.Where(w => w.Type == 2).Select(q => q.Item).Contains(s.TypeName))
if (workitems.Any(w => w.Type == 1) && workitems.Where(w => w.Type == 1).Select(q => q.Item).Contains(s.TypeName))
{
cellvalue = cmifactor * cellvalue;
}
......
......@@ -49,7 +49,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
......@@ -57,8 +58,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{
RowNumber = r,
SignID = athead.SignID,
UnitType = NopiSevice.GetCellStringValue(row.GetCell(unit.UnitTypeNum.Value)),
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
UnitType = row.GetCell(unit.UnitTypeNum.Value).GetValue(),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
......@@ -68,11 +69,11 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (Point.TotalCellNum.HasValue && athead.PointCell == Point.TotalCellNum)
data.IsTotal = 1;
if (unit.DeptCellNum.HasValue)
data.Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value));
data.Department = row.GetCell(unit.DeptCellNum.Value).GetValue();
if (unit.EmpNameCellNum.HasValue)
data.EmployeeName = NopiSevice.GetCellStringValue(row.GetCell(unit.EmpNameCellNum.Value));
data.EmployeeName = row.GetCell(unit.EmpNameCellNum.Value).GetValue();
if (unit.JobCellNum.HasValue)
data.JobNumber = NopiSevice.GetCellStringValue(row.GetCell(unit.JobCellNum.Value));
data.JobNumber = row.GetCell(unit.JobCellNum.Value).GetValue();
if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department))
......
......@@ -68,20 +68,21 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue),
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()),
IsFactor = true,
};
dataList.Add(data);
......
......@@ -45,7 +45,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
......@@ -53,7 +54,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
//Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
TypeName = athead?.CellValue,
CellValue = cellValue,
......
......@@ -70,7 +70,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
continue;
if (!string.IsNullOrEmpty(athead?.CellValue) && athead.CellValue.Contains("备注"))
continue;
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
......@@ -78,8 +79,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
......
......@@ -66,15 +66,16 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
......
......@@ -66,15 +66,16 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
......
......@@ -48,7 +48,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
......@@ -56,8 +57,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{
RowNumber = r,
SignID = athead.SignID,
UnitType = NopiSevice.GetCellStringValue(row.GetCell(unit.UnitTypeNum.Value)),
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
UnitType = row.GetCell(unit.UnitTypeNum.Value).GetValue(),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
......@@ -67,11 +68,11 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (Point.TotalCellNum.HasValue && athead.PointCell == Point.TotalCellNum)
data.IsTotal = 1;
if (unit.DeptCellNum.HasValue)
data.Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value));
data.Department = row.GetCell(unit.DeptCellNum.Value).GetValue();
if (unit.EmpNameCellNum.HasValue)
data.EmployeeName = NopiSevice.GetCellStringValue(row.GetCell(unit.EmpNameCellNum.Value));
data.EmployeeName = row.GetCell(unit.EmpNameCellNum.Value).GetValue();
if (unit.JobCellNum.HasValue)
data.JobNumber = NopiSevice.GetCellStringValue(row.GetCell(unit.JobCellNum.Value));
data.JobNumber = row.GetCell(unit.JobCellNum.Value).GetValue();
if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department))
......
......@@ -46,7 +46,8 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
for (int c = 0; c < vhead.Count(); c++)
{
var athead = vhead.ElementAt(c);
var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
......@@ -54,13 +55,13 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{
RowNumber = r,
SignID = athead.SignID,
AccountingUnit = NopiSevice.GetCellStringValue(row.GetCell(unit.AccountingUnitCellNum.Value)),
Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue,
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType,
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue),
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()),
IsFactor = true,
};
if (sheet.SheetName.Contains("医生组"))
......
......@@ -24,6 +24,7 @@ public class PersonService : IAutoInjection
private readonly PerforUserRepository perforUserRepository;
private readonly PerforUserroleRepository perforUserroleRepository;
private readonly PerforRoleRepository perforRoleRepository;
private readonly PerforAgsecondallotRepository agsecondallotRepository;
private readonly Application application;
private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{
......@@ -33,6 +34,8 @@ public class PersonService : IAutoInjection
{ nameof(DeptdicResponse.InpatDoctorAccounting), (UnitType.医生组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatNurseAccounting), (UnitType.护理组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatTechnicAccounting), (UnitType.医技组.ToString(), "住院") },
{ nameof(DeptdicResponse.LogisticsAccounting), (UnitType.行政后勤.ToString(), null) },
{ nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) },
};
public PersonService(ILogger<PersonService> logger,
......@@ -42,6 +45,7 @@ public class PersonService : IAutoInjection
PerforUserRepository perforUserRepository,
PerforUserroleRepository perforUserroleRepository,
PerforRoleRepository perforRoleRepository,
PerforAgsecondallotRepository agsecondallotRepository,
IOptions<Application> application)
{
this.logger = logger;
......@@ -51,6 +55,7 @@ public class PersonService : IAutoInjection
this.perforUserRepository = perforUserRepository;
this.perforUserroleRepository = perforUserroleRepository;
this.perforRoleRepository = perforRoleRepository;
this.agsecondallotRepository = agsecondallotRepository;
this.application = application.Value;
}
......@@ -102,6 +107,7 @@ public void CreateAllotPersons(int hospitalId, int allotId, int prevAllotId = -1
Remark = t.Remark,
HospitalId = t.HospitalId,
AllotId = allotId,
ReservedRatio = t.ReservedRatio,
CreateTime = DateTime.Now,
}).ToList();
SaveAllotPersons(data);
......@@ -133,6 +139,16 @@ private void SaveAllotPersons(List<per_employee> employees)
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public List<per_employee> GetPerEmployee(int allotId)
{
return peremployeeRepository.GetEntities(t => t.AllotId == allotId)?.OrderBy(t => t.Id).ToList();
}
/// <summary>
/// 获取所有员工记录
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public List<per_employee> GetPersons(int allotId, int userId)
{
var (dept, unittype) = GetDeptByUser(userId);
......@@ -277,12 +293,14 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
HospitalId = hospitalId,
HISDeptName = t.Key.HISDeptName,
Department = t.Key.Department,
OutDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.医生组.ToString() && group.Source == "门诊")),
OutNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.护理组.ToString() && group.Source == "门诊")),
OutTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.医技组.ToString() && group.Source == "门诊")),
InpatDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.医生组.ToString() && group.Source == "住院")),
InpatNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.护理组.ToString() && group.Source == "住院")),
InpatTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.UnitType == UnitType.医技组.ToString() && group.Source == "住院")),
OutDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "门诊")),
OutNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "门诊")),
OutTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "门诊")),
InpatDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "住院")),
InpatNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "住院")),
InpatTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "住院")),
LogisticsAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.行政后勤.ToString())),
SpecialAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.特殊核算组.ToString())),
CreateTime = t.Max(group => group.CreateTime)
});
......@@ -301,9 +319,10 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.医技组.ToString() } },
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new string[]{ UnitType.护理组.ToString() } },
{ application.SpecialRole, new string[]{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string[]{ UnitType.行政后勤.ToString() } },
};
if (dict.Keys.Contains(role.Type.Value))
......@@ -454,7 +473,15 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
}
else if (type == 3)
{
result = deptdics.Select(t => t.AccountingUnit).Distinct().ToList();
result = deptdics.Where(t => !new string[] { UnitType.行政后勤.ToString(), UnitType.特殊核算组.ToString() }.Contains(t.UnitType)).Select(t => t.AccountingUnit).Distinct().ToList();
}
else if (type == 4)
{
result = deptdics.Where(t => t.UnitType == UnitType.行政后勤.ToString()).Select(t => t.AccountingUnit).Distinct().ToList();
}
else if (type == 5)
{
result = deptdics.Where(t => t.UnitType == UnitType.特殊核算组.ToString()).Select(t => t.AccountingUnit).Distinct().ToList();
}
return result.Select(t => new TitleValue { Title = t, Value = t }).ToList();
}
......@@ -466,18 +493,58 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{
var (dept, unittype) = GetDeptByUser(userId);
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, unittype);
var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId);
if (second == null)
return null;
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, second.UnitType, allot.HospitalId);
if (data != null && data.Any())
{
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }).Select(t => new
{
t.Key.Department,
t.Key.DoctorName,
t.Key.PersonnelNumber,
t.Key.Category,
Fee = t.Sum(group => group.Fee ?? 0)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
.Select(t => new DeptIncomeResponse
{
Department = t.Key.Department,
DoctorName = t.Key.DoctorName,
PersonnelNumber = t.Key.PersonnelNumber,
Category = t.Key.Category,
Fee = t.Sum(group => group.Fee ?? 0)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
}
return new string[] { };
}
/// <summary>
/// 科室工作量数据详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId)
{
var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId);
if (second == null)
return null;
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var data = perallotRepository.QueryIncomeData(request.AllotId, request.AccountingUnit, second.UnitType, allot.HospitalId);
if (data != null && data.Any())
{
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
.Select(t => new DeptIncomeResponse
{
Department = t.Key.Department,
DoctorName = t.Key.DoctorName,
PersonnelNumber = t.Key.PersonnelNumber,
Category = t.Key.Category,
Fee = t.Sum(group => group.Fee ?? 0)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
}
return new string[] { };
......
......@@ -358,7 +358,8 @@ private bool IsMedical(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (role.Type == application.DirectorRole || role.Type == application.NurseRole)
var roleTypes = new[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (role.Type.HasValue && roleTypes.Contains(role.Type.Value))
return true;
else
return false;
......
......@@ -17,6 +17,7 @@ namespace Performance.Services
public class SecondAllotService : IAutoInjection
{
private readonly Application application;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforUserRepository perforUserRepository;
private readonly PerforUserhospitalRepository perforUserhospitalRepository;
private readonly PerforPerallotRepository perforPerallotRepository;
......@@ -33,12 +34,14 @@ public class SecondAllotService : IAutoInjection
private readonly PerforAgothersourceRepository perforAgothersourceRepository;
private readonly PerforAgworkloadtypeRepository perforAgworkloadtypeRepository;
private readonly PerforRoleRepository roleRepository;
private readonly PerforPerapramountRepository perapramountRepository;
private readonly PerforResspecialunitRepository resspecialunitRepository;
private readonly PersonService personService;
private readonly PerforRescomputeRepository rescomputeRepository;
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(IOptions<Application> application,
PerforHospitalRepository hospitalRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository,
......@@ -55,11 +58,13 @@ public class SecondAllotService : IAutoInjection
PerforAgothersourceRepository perforAgothersourceRepository,
PerforAgworkloadtypeRepository perforAgworkloadtypeRepository,
PerforRoleRepository roleRepository,
PerforPerapramountRepository perapramountRepository,
PerforResspecialunitRepository resspecialunitRepository,
PersonService personService,
PerforRescomputeRepository rescomputeRepository)
{
this.application = application.Value;
this.hospitalRepository = hospitalRepository;
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
......@@ -76,6 +81,7 @@ public class SecondAllotService : IAutoInjection
this.perforAgothersourceRepository = perforAgothersourceRepository;
this.perforAgworkloadtypeRepository = perforAgworkloadtypeRepository;
this.roleRepository = roleRepository;
this.perapramountRepository = perapramountRepository;
this.resspecialunitRepository = resspecialunitRepository;
this.personService = personService;
this.rescomputeRepository = rescomputeRepository;
......@@ -100,7 +106,7 @@ public List<SecondListResponse> GetSecondList(int userId)
throw new NotImplementedException("人员未选择医院");
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8 }.Contains(t.States));
if (allotList == null || allotList.Count == 0)
throw new NotImplementedException("该医院未生成绩效");
return new List<SecondListResponse>();
var allotListId = allotList.Select(t => t.ID).ToList();
Expression<Func<ag_secondallot, bool>> exp = t => allotListId.Contains(t.AllotId.Value) && t.Department == user.Department;
......@@ -110,56 +116,10 @@ public List<SecondListResponse> GetSecondList(int userId)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (role.Type == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (role.Type == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = perforAgsecondallotRepository.GetEntities(exp);
//各科室绩效分配结果
var accountList = perforResaccountRepository.GetEntities(t => allotListId.Contains(t.AllotID.Value) && t.Department == user.Department);
//取得未生成二次绩效的绩效id
var exceptListId = secondList == null ? allotListId : allotListId.Except(secondList.Select(t => t.AllotId.Value));
var specialList = resspecialunitRepository.GetEntities(t => allotListId.Contains(t.AllotID.Value) && t.Department == user.Department);
#region 初始化二次绩效
List<ag_secondallot> newSecond = new List<ag_secondallot>();
foreach (var item in exceptListId)
{
var allot = allotList.FirstOrDefault(t => t.ID == item);
if (allot == null) continue;
res_account account = null;
res_specialunit special = null;
if (role.Type == application.DirectorRole)
account = accountList?.FirstOrDefault(t => t.AllotID == item && (t.UnitType == (int)UnitType.医生组 || t.UnitType == (int)UnitType.医技组));
else if (role.Type == application.NurseRole)
account = accountList?.FirstOrDefault(t => t.AllotID == item && t.UnitType == (int)UnitType.护理组);
else if (role.Type == application.SpecialRole)
special = specialList?.FirstOrDefault(t => t.AllotID == item);
if (account == null && special == null) continue;
var second = new ag_secondallot
{
AllotId = item,
Year = allot.Year,
Month = allot.Month,
Department = user.Department,
UnitType = role.Type == application.SpecialRole ? UnitType.特殊核算组.ToString() : ((UnitType)account.UnitType).ToString(),
RealGiveFee = role.Type == application.SpecialRole ? special.RealGiveFee : account.RealGiveFee,
Status = 1
};
newSecond.Add(second);
}
#endregion
if (newSecond.Count > 0)
{
perforAgsecondallotRepository.AddRange(newSecond.ToArray());
if (secondList == null)
secondList = newSecond;
else
secondList.AddRange(newSecond);
}
var list = Mapper.Map<List<SecondListResponse>>(secondList);
list?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
return list;
......@@ -271,6 +231,36 @@ public List<SecondListResponse> GetSecondList(int userId)
#endregion
/// <summary>
/// 二次绩效分配录入人员自动补全信息
/// </summary>
/// <param name="request"></param>
/// <param name="userId"></param>
/// <returns></returns>
public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板");
//获取固定模板列 + 工作量列
var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var employees = personService.GetPerEmployee(second.AllotId.Value);
var bodyItems = GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType, request.EmployeeName, request.JobNumber);
return bodyItems;
}
#region 二次绩效详情-使用中
/// <summary>
/// 二次绩效详情
......@@ -295,7 +285,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
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 && !string.IsNullOrEmpty(t.ItemName));
//归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems
if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1))
{
......@@ -303,6 +293,8 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
throw new PerformanceException("提交时未添加数据。");
result = SubmittedData(fixatList, headItems);
// 补充 医院其他绩效
SupplementOtherPerfor(result, second.AllotId ?? -99);
}
else
{
......@@ -312,14 +304,21 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
if (fixatList != null && fixatList.Any())
{
result.BodyItems = GetBodyItems(fixatList, headItems);
// 补充 医院其他绩效
SupplementOtherPerfor(result, second.AllotId ?? -99);
if (fixatList.Where(t => t.RowNumber != -1) == null || !fixatList.Where(t => t.RowNumber != -1).Any())
result.BodyItems.AddRange(GetEmployees(second.AllotId.Value, userId, headItems)); //更换模板时,会自动保存顶部数据
{
//更换模板时,会自动保存顶部数据
var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems.AddRange(GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType));
}
}
else
{
//无数据 根据IsBring带出历史二次绩效中需要带出的数据
//result.BodyItems = GetBringItems(request, headItems);
result.BodyItems = GetEmployees(second.AllotId.Value, userId, headItems);
var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems = GetEmployees(employees, second.AllotId.Value, userId, headItems, second.UnitType);
var bodys = Mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1));
if (bodys != null && bodys.Any())
......@@ -339,19 +338,62 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(),
};
}
/// <summary>
/// 补充 医院其他绩效
/// </summary>
/// <param name="result"></param>
private void SupplementOtherPerfor(SecondResponse result, int allotId)
{
if (result?.BodyItems != null && result.BodyItems.Any())
{
var second = perforAgsecondallotRepository.GetEntity(t => t.AllotId == allotId);
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
foreach (var rownum in result.BodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct())
{
var rowData = result.BodyItems.Where(w => w.RowNumber == rownum);
var personnelNumber = rowData.FirstOrDefault(w => w.FiledId == "PersonnelNumber")?.Value;
var fullName = rowData.FirstOrDefault(w => w.FiledId == "FullName")?.Value;
var amount = perapramounts
?.Where(w => w.AccountingUnit?.Trim() == second.Department?.Trim() && w.DoctorName?.Trim() == fullName?.Trim() && w.PersonnelNumber?.Trim() == personnelNumber?.Trim())
?.Sum(w => w.Amount);
var otherPerfor = rowData.FirstOrDefault(w => w.FiledId == "OtherPerformance");
if (otherPerfor != null)
otherPerfor.Value = amount?.ToString();
}
}
}
private List<BodyItem> GetEmployees(int allotId, int userId, List<HeadItem> heads)
private List<BodyItem> GetEmployees(List<per_employee> employees, int allotId, int userId, List<HeadItem> heads, string unittype, string empName = "", string jobNumber = "")
{
var list = new List<BodyItem>();
var employees = personService.GetPersons(allotId, userId);
if (employees == null || !employees.Any()) return list;
//var employees = personService.GetPersons(allotId, userId);
if (employees == null || !employees.Any(t => t.UnitType == unittype)) return list;
if (string.IsNullOrEmpty(empName) && string.IsNullOrEmpty(jobNumber))
employees = employees.Where(t => t.UnitType == unittype).ToList();
if (!string.IsNullOrEmpty(empName))
employees = employees?.Where(w => w.DoctorName?.Trim() == empName?.Trim()).ToList();
if (!string.IsNullOrEmpty(jobNumber))
employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Contains(jobNumber.Trim())).ToList();
var second = perforAgsecondallotRepository.GetEntity(t => t.AllotId == allotId);
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
Func<per_employee, decimal?> getAprAmount = (t) => perapramounts
?.Where(w => w.AccountingUnit?.Trim() == second.Department?.Trim() && w.DoctorName?.Trim() == t.DoctorName?.Trim() && w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.Amount);
Dictionary<(string, string), Func<per_employee, object>> dict = new Dictionary<(string, string), Func<per_employee, object>>
{
{ ("人员工号", "PersonnelNumber"), (t) => t.PersonnelNumber },
{ ("姓名", "FullName"), (t) => t.DoctorName },
{ ("岗位", "Post"), (t) => !string.IsNullOrEmpty(t.Duty) && (t.Duty.IndexOf("主任") > -1 || t.Duty.IndexOf("护士长") > -1) ? "主任" : "其他" },
{ ("出勤", "ActualAttendance"), (t) => t.AttendanceDay },
{ ("预留比例", "ReservedRatio"), (t) => t.ReservedRatio },
{ ("医院其他绩效","OtherPerformance"), (t) => getAprAmount(t)},
};
int rowNumber = 1;
......@@ -490,7 +532,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
foreach (var item in keyValue)
{
var header = bodyItems.FirstOrDefault(t => t.FiledName == item.Key);
if (header != null && (string.IsNullOrEmpty(header.Value) || header.Value == "0"))
if (header != null && (string.IsNullOrEmpty(header.Value) /*|| header.Value == "0"*/))
bodyItems.FirstOrDefault(t => t.FiledName == item.Key).Value = item.Value;
}
}
......@@ -610,13 +652,11 @@ public bool SaveValue(List<ag_fixatitem> request)
List<ag_fixatitem> update = new List<ag_fixatitem>(), insert = new List<ag_fixatitem>();
if (fixatitems != null && fixatitems.Any())
{
foreach (var item in request)
foreach (var item in request.Where(w => !string.IsNullOrEmpty(w.ItemName)))
{
if (fixatitems.Any(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName))
var cellItem = fixatitems.FirstOrDefault(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName);
if (cellItem != null)
{
var cellItem = fixatitems.FirstOrDefault(t => t.RowNumber == item.RowNumber && t.ItemName == item.ItemName);
if (cellItem == null)
continue;
cellItem.ItemValue = item.ItemValue;
cellItem.Sort = item.Sort;
cellItem.SourceType = item.SourceType;
......@@ -727,11 +767,18 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department;
if (role.Type == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (role.Type == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var useTemp = perforAgusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps);
......@@ -815,6 +862,7 @@ public bool UseTemp(UseTempRequest request)
: configs.FirstOrDefault(t => t.TypeName == head.FiledName)?.Value.ToString()
});
}
}
}
}
......@@ -1059,6 +1107,10 @@ public bool DeleteWorkType(WorkloadRequest request)
return (UnitType.医生组.ToString(), user.Department);
else if (role.Type == application.NurseRole)
return (UnitType.护理组.ToString(), user.Department);
if (role.Type == application.SpecialRole)
return (UnitType.特殊核算组.ToString(), user.Department);
if (role.Type == application.OfficeRole)
return (UnitType.行政后勤.ToString(), user.Department);
else
return ("", user.Department);
}
......@@ -1070,22 +1122,67 @@ public bool DeleteWorkType(WorkloadRequest request)
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
public List<ag_secondallot> AuditList(int userId, int allotId)
public List<ag_secondallot> AuditList(int allotId)
{
//var hospital = perforUserhospitalRepository.GetEntities(t => t.UserID == userId);
//var allotList = perforPerallotRepository.GetEntities(t => hospital.Select(h => h.HospitalID).Contains(t.HospitalId));
//if (allotList != null && allotList.Count > 0)
//{
// var allotIds = allotList.Select(t => t.ID);
// return perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value) && t.Status == 2);
//}
//return null;
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month && t.Status == 2);
return secondList;
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && !new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 }.Contains(t.UnitType.Value));
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit);
}
private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accountUnit, List<res_specialunit> specialunit)
{
List<res_account> temps = new List<res_account>();
if (accountUnit != null)
accountUnit.ForEach(w => temps.Add(new res_account { UnitType = w.UnitType, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee }));
if (specialunit != null)
specialunit.ForEach(w =>
{
if (!temps.Any(t => t.UnitType == (int)UnitType.特殊核算组 && t.AccountingUnit == w.AccountingUnit))
temps.Add(new res_account { UnitType = (int)UnitType.特殊核算组, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee });
});
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
var result = temps.Select(t =>
{
var second = secondList?.FirstOrDefault(f => f.UnitType == ((UnitType)t.UnitType).ToString() && f.Department == t.AccountingUnit);
if (second != null) return second;
return new ag_secondallot
{
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = ((UnitType)t.UnitType).ToString(),
Department = t.AccountingUnit,
RealGiveFee = t.RealGiveFee,
Status = 1,
};
});
var enums = EnumHelper.GetItems<UnitType>();
return result.OrderBy(t => t.Status == 4 ? 2 : t.Status)
.ThenBy(t => enums.FirstOrDefault(f => f.Name == t.UnitType)?.Value)
.ThenBy(t => t.Department)
.ToList();
}
/// <summary>
/// 护理部二次绩效考核列表
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
public List<ag_secondallot> NursingDeptlist(int allotId)
{
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 };
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value));
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit);
}
/// <summary>
......@@ -1103,11 +1200,17 @@ public bool AuditSubmit(ag_secondallot second, int userId)
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department;
if (role.Type == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (role.Type == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var temp = perforAgusetempRepository.GetEntity(exp);
if (temp == null)
......@@ -1126,9 +1229,10 @@ public bool AuditSubmit(ag_secondallot second, int userId)
}
second.UseTempId = temp.UseTempId;
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
second.Remark = "已提交审核,等待审核中";
//second.Remark = "已提交审核,等待审核中";
return perforAgsecondallotRepository.Update(second);
}
......@@ -1142,8 +1246,8 @@ public bool AuditSubmit(ag_secondallot second, int userId)
public bool ConfirmAudit(int userId, SecondAuditRequest request)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second.Status != 2)
throw new PerformanceException("该绩效未提交至审核,请确认");
//if (second.Status != 2)
// throw new PerformanceException("该绩效未提交至审核,请确认");
if (request.IsPass == 1)
{
......@@ -1158,19 +1262,30 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
second.AuditUser = userId;
second.AuditTime = DateTime.Now;
second.Remark = request.Remark;
if (string.IsNullOrEmpty(second.Remark))
{
second.Remark = request.IsPass == 1 ? "审核通过" : "驳回";
}
//if (string.IsNullOrEmpty(second.Remark))
//{
// second.Remark = request.IsPass == 1 ? "审核通过" : "驳回";
//}
var result = perforAgsecondallotRepository.Update(second);
// 无论驳回还是通过,都需要清空该科室历史数据
var histories = perforAgcomputeRepository.GetEntities(w => w.SecondId == request.SecondId);
if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray());
#region 添加至二次绩效汇总
if (result && request.IsPass == 1)
{
var histories = perforAgcomputeRepository.GetEntities(w => w.SecondId == request.SecondId);
if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray());
// 护理部审核
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) return true;
var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
if (hospital == null) return true;
if (hospital.IsOpenNursingDeptAudit == 1 && second.NursingDeptStatus != 3)
return true;
var computes = new List<ag_compute>();
if (second.SubmitType == 1)
......@@ -1187,10 +1302,14 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
{
AllotId = second.AllotId,
SecondId = second.Id,
UnitType = second.UnitType,
Department = second.Department,
JobNumber = items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "人员工号")?.ItemValue,
WorkPost = items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "岗位")?.ItemValue,
PersonName = items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "姓名")?.ItemValue,
PerforSumFee = ConvertHelper.TryDecimal(items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "可分配绩效")?.ItemValue, 0),
OthePerfor = ConvertHelper.TryDecimal(items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "医院其他绩效")?.ItemValue, 0),
NightWorkPerfor = ConvertHelper.TryDecimal(items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "夜班工作量绩效")?.ItemValue, 0),
RealGiveFee = ConvertHelper.TryDecimal(items.FirstOrDefault(t => t.RowNumber == item && t.ItemName == "实发绩效工资金额")?.ItemValue, 0),
});
}
......@@ -1208,22 +1327,54 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
{
AllotId = second.AllotId,
SecondId = second.Id,
UnitType = second.UnitType,
Department = second.Department,
WorkPost = item.WorkPost,
JobNumber = item.WorkNumber,
PersonName = item.Name,
PerforSumFee = item.DistPerformance,
OthePerfor = item.OtherPerformance,
NightWorkPerfor = item.NightWorkPerformance,
RealGiveFee = item.RealAmount,
});
}
}
}
perforAgcomputeRepository.AddRange(computes.ToArray());
}
#endregion
return result;
}
/// <summary>
/// 护理部审核
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="secondId">二次绩效ID</param>
/// <param name="ispass">1、审核通过 2、驳回</param>
/// <returns></returns>
public bool NursingDeptAudit(int userId, SecondAuditRequest request)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("二次分配绩效无效");
if (request.IsPass == 1)
{
second.NursingDeptStatus = 3;
second.NursingDeptRemark = $"{request.Remark}";
}
else
{
second.UseTempId = null;
second.NursingDeptStatus = 4;
second.NursingDeptRemark = $"{request.Remark}";
}
second.NursingDeptAuditUser = userId;
second.NursingDeptAuditTime = DateTime.Now;
return perforAgsecondallotRepository.Update(second);
}
#endregion
#region common
......@@ -1250,6 +1401,13 @@ public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == tempId);
var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
var temp = perforAgtempRepository.GetEntity(w => w.Id == tempId);
// 其他来源不考虑工作量
if (temp?.Id == 6)
return headItems;
//获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
if (workItem != null && workItem.Count > 0)
......@@ -1300,27 +1458,116 @@ public List<BodyItem> GetBodyItems(List<HeadItem> headItems, int source, List<co
#region 二次绩效其他来源
public List<ag_othersource> OtherList(int secondId, int userId)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("二次绩效信息无效!");
var employees = personService.GetPersons(second.AllotId.Value, userId);
if (employees == null || !employees.Any(t => t.UnitType == second.UnitType)) return new List<ag_othersource>();
employees = employees.Where(t => t.UnitType == second.UnitType).ToList();
List<ag_othersource> result = null;
var otherSecondList = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (otherSecondList != null && otherSecondList.Any())
{
return otherSecondList.OrderBy(t => t.Id).ToList();
result = otherSecondList.OrderBy(t => t.Id).ToList();
}
else
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("二次绩效信息无效!");
result = employees.Select(t => new ag_othersource
{
SecondId = secondId,
WorkNumber = t.PersonnelNumber,
Name = t.DoctorName,
Department = t.Department,
WorkPost = t.JobTitle,
}).ToList();
}
var isSupplementTitlePerformance = otherSecondList == null || !otherSecondList.Any();
SupplementSecondDetail(second, employees, result, isSupplementTitlePerformance);
var employees = personService.GetPersons(second.AllotId.Value, userId);
if (employees == null || !employees.Any()) return new List<ag_othersource>();
return result;
}
/// <summary>
/// 二次绩效录入页面其他模板自动补全
/// </summary>
/// <param name="secondId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板");
return employees.Select(t => new ag_othersource
//获取固定模板列 + 工作量列
var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var employees = personService.GetPerEmployee(second.AllotId.Value);
if (employees == null) return new List<ag_othersource>();
if (!string.IsNullOrEmpty(request.EmployeeName))
employees = employees?.Where(w => w.DoctorName?.Trim() == request.EmployeeName?.Trim()).ToList();
if (!string.IsNullOrEmpty(request.JobNumber))
employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Contains(request.JobNumber.Trim())).ToList();
List<ag_othersource> result = employees
.Select(t => new ag_othersource
{
SecondId = secondId,
SecondId = request.SecondId,
WorkNumber = t.PersonnelNumber,
Name = t.DoctorName,
Department = t.Department,
WorkPost = t.JobTitle
WorkPost = t.JobTitle,
}).ToList();
SupplementSecondDetail(second, employees, result);
return result;
}
/// <summary>
/// 补充二次分配 人员明细
/// </summary>
/// <param name="second"></param>
/// <param name="employees"></param>
/// <param name="result"></param>
/// <param name="isTitlePerformance">是否补全职称绩效</param>
private void SupplementSecondDetail(ag_secondallot second, List<per_employee> employees, List<ag_othersource> result, bool isTitlePerformance = true)
{
// 补充医院其他绩效 及 预留比例
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId);
Func<per_employee, decimal?> getAprAmount = (t) => perapramounts
?.Where(w => w.AccountingUnit?.Trim() == second.Department?.Trim() && w.DoctorName?.Trim() == t.DoctorName?.Trim() && w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.Amount);
var distPerformance = rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId && employees.Select(s => s.DoctorName).Contains(t.EmployeeName));
Func<per_employee, decimal?> getDistPerformance = (t) => 0;
if (second.UnitType == UnitType.行政后勤.ToString())
getDistPerformance = (t) => distPerformance
?.Where(w => w.AccountingUnit?.Trim() == second.Department?.Trim() && w.EmployeeName?.Trim() == t.DoctorName?.Trim() && w.JobNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.GiveFee);
foreach (var item in result)
{
var empl = employees.FirstOrDefault(w => w.PersonnelNumber?.Trim() == item.WorkNumber?.Trim() && w.DoctorName?.Trim() == item.Name?.Trim());
if (empl != null)
{
item.ReservedRatio = empl.ReservedRatio;
item.OtherPerformance = getAprAmount(empl);
if (isTitlePerformance)
item.TitlePerformance = getDistPerformance(empl);
}
}
}
......@@ -1443,6 +1690,7 @@ public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId)
{
{ application.DirectorRole, AccountUnitType.科主任.ToString() },
{ application.NurseRole, AccountUnitType.护士长.ToString() },
{ application.OfficeRole, AccountUnitType.行政中层.ToString() },
};
if (!dict.Keys.Contains(role.Type.Value)) return new List<SecondPerforResponse>();
......
......@@ -27,6 +27,8 @@ public class UserService : IAutoInjection
private PerforPerallotRepository _perforPerallotRepository;
private PerforImaccountbasicRepository _imaccountbasicRepository;
private PerforImspecialunitRepository _imspecialunitRepository;
private PerforResaccountRepository _resaccountRepository;
private PerforPerallotRepository _perallotRepository;
private PerforPerdeptdicRepository _perdeptdicRepository;
public UserService(IOptions<Application> application,
PerforSmsRepository smsRepository,
......@@ -39,6 +41,8 @@ public class UserService : IAutoInjection
PerforPerallotRepository perforPerallotRepository,
PerforImaccountbasicRepository imaccountbasicRepository,
PerforImspecialunitRepository imspecialunitRepository,
PerforResaccountRepository resaccountRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perdeptdicRepository)
{
this.application = application.Value;
......@@ -52,6 +56,8 @@ public class UserService : IAutoInjection
this._perforPerallotRepository = perforPerallotRepository;
this._imaccountbasicRepository = imaccountbasicRepository;
this._imspecialunitRepository = imspecialunitRepository;
this._resaccountRepository = resaccountRepository;
this._perallotRepository = perallotRepository;
this._perdeptdicRepository = perdeptdicRepository;
}
......@@ -148,16 +154,17 @@ public ApiResponse Delete(int iD)
/// <param name="request"></param>
public UserResponse Insert(UserRequest request, int userid)
{
var isAgainAdmin = new int[] { application.DirectorRole, application.NurseRole }.Contains(request.Role);
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
throw new PerformanceException("登录名重复");
if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1))
throw new PerformanceException("手机号重复");
if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("请选择科室");
if (isAgainAdmin && request.HosIDArray.Length > 1)
//if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1))
// throw new PerformanceException("手机号重复");
//if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
// throw new PerformanceException("请选择科室");
if (request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request);
......@@ -224,9 +231,9 @@ public UserResponse Update(UserRequest request, bool isAgainAdmin)
if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("登录名重复");
vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("手机号重复");
//vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1);
//if (null != vlist && vlist.Count() > 0)
// throw new PerformanceException("手机号重复");
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
......@@ -326,7 +333,7 @@ public List<sys_role> RoleList(int userId)
List<sys_role> result = new List<sys_role>() { role };
GetChildrenRole(roles, role.ID, result);
return result?.Distinct().ToList();
return result?.OrderBy(w => w.Sort)?.Distinct().ToList();
}
/// <summary>
......@@ -362,7 +369,24 @@ public List<TitleValue> Department(int hospitalId)
var list = _perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
if (list == null || !list.Any()) return new List<TitleValue>();
var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t);
var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t).ToList();
//// 补充行政科室
//var states = new int[] { (int)AllotStates.Archive, (int)AllotStates.GenerateAccomplish };
//var allots = _perallotRepository.GetEntities(w => w.HospitalId == hospitalId && states.Contains(w.States));
//if (allots != null && allots.Any())
//{
// var allot = allots.OrderByDescending(w => w.Year).ThenByDescending(w => w.Month).FirstOrDefault();
// if (allot != null)
// {
// var types = new int[] { (int)UnitType.行政中层, (int)UnitType.行政后勤 };
// var accounts = _resaccountRepository.GetEntities(w => w.AllotID == allot.ID && w.UnitType.HasValue && types.Contains(w.UnitType.Value));
// if (accounts != null && accounts.Any())
// {
// result.AddRange(accounts.Select(w => w.AccountingUnit));
// }
// }
//}
return result?.Select(t => new TitleValue { Title = t, Value = t }).ToList();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment