Commit cf8d50a4 by lcx

Merge branch 'v2020morge' into v2020morge-graphql

# Conflicts:
#	performance/Performance.Api/Controllers/SecondAllotController.cs
#	performance/Performance.EntityModels/Entity/im_accountbasic.cs
#	performance/Performance.Repository/PerforCofdirectorRepository.cs
#	performance/Performance.Services/ExtractExcelService/ExtractHelper/ExtractHelper.cs
parents 26996e64 7ffa0d8c
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "5.0.1",
"commands": [
"dotnet-ef"
]
}
}
}
\ No newline at end of file
using FluentValidation.AspNetCore;
using Hangfire;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
......@@ -7,7 +6,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.AllotCompute;
......@@ -16,7 +14,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
......@@ -27,19 +24,17 @@ namespace Performance.Api.Controllers
public class AllotController : Controller
{
private AllotService _allotService;
private readonly ResultComputeService resultComputeService;
private HospitalService _hospitalService;
private ResultComputeService _resultComputeService;
private ConfigService _configService;
private IHostingEnvironment _evn;
private ILogger<AllotController> _logger;
private ClaimService _claim;
private readonly LogManageService logManageService;
private LogManageService _logManageService;
private IBackgroundTaskQueue _backgroundTaskQueue;
private IServiceScopeFactory _serviceScopeFactory;
public AllotController(AllotService allotService,
ResultComputeService resultComputeService,
HospitalService hospitalService,
ConfigService configService,
ILogger<AllotController> logger,
IHostingEnvironment evn,
......@@ -49,12 +44,11 @@ public class AllotController : Controller
LogManageService logManageService)
{
_allotService = allotService;
this.resultComputeService = resultComputeService;
_hospitalService = hospitalService;
_resultComputeService = resultComputeService;
_logger = logger;
_evn = evn;
_claim = claim;
this.logManageService = logManageService;
_logManageService = logManageService;
_configService = configService;
_backgroundTaskQueue = backgroundTaskQueue;
_serviceScopeFactory = serviceScopeFactory;
......@@ -190,7 +184,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
if (allot.States == (int)AllotStates.Wait)
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
logManageService.WriteMsg("生成绩效准备中", $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!", 1, allot.ID, "ReceiveMessage", true);
_logManageService.WriteMsg("生成绩效准备中", $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!", 1, allot.ID, "ReceiveMessage", true);
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
if (_evn.IsEnvironment("Localhost"))
{
......@@ -211,13 +205,27 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
});
}
logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
_logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
//_allotService.Generate(allot, email);
////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email));
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 重新计算院领导绩效
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("recalculation")]
[HttpPost]
public ApiResponse Recalculation([FromBody] RecalculationRequest request)
{
if (request.Money.HasValue)
_allotService.Recalculation(request.AllotId, request.Money.Value);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 归档绩效记录
/// </summary>
/// <param name="request"></param>
......@@ -296,7 +304,7 @@ public ApiResponse Issued([FromBody] AllotRequest request)
throw new PerformanceException("当前绩效记录不存在");
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
// 科室下发
resultComputeService.GenerateSecondAllot(allot);
_resultComputeService.GenerateSecondAllot(allot);
return new ApiResponse(ResponseType.OK);
}
......
......@@ -194,58 +194,58 @@ public ConfigController(ConfigService configService, AllotService allotService)
#endregion
#region drugprop
/// <summary>
/// 获取 药占比配置信息列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("drugproplist")]
[HttpPost]
public ApiResponse<List<DrugpropResponse>> GetDrugList([CustomizeValidator(RuleSet = "Select"), FromBody] DrugpropRequest request)
{
var list = _configService.GetDrugList(request.AllotID);
return new ApiResponse<List<DrugpropResponse>>(ResponseType.OK, "ok", list);
}
///// <summary>
///// 获取 药占比配置信息列表
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("drugproplist")]
//[HttpPost]
//public ApiResponse<List<DrugpropResponse>> GetDrugList([CustomizeValidator(RuleSet = "Select"), FromBody] DrugpropRequest request)
//{
// var list = _configService.GetDrugList(request.AllotID);
// return new ApiResponse<List<DrugpropResponse>>(ResponseType.OK, "ok", list);
//}
/// <summary>
/// 新增药占比配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("druginsert")]
[HttpPost]
public ApiResponse<DrugpropResponse> DrugInsert([CustomizeValidator(RuleSet = "Insert"), FromBody] DrugpropRequest request)
{
var drugprop = _configService.DrugInsert(request);
return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
}
///// <summary>
///// 新增药占比配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("druginsert")]
//[HttpPost]
//public ApiResponse<DrugpropResponse> DrugInsert([CustomizeValidator(RuleSet = "Insert"), FromBody] DrugpropRequest request)
//{
// var drugprop = _configService.DrugInsert(request);
// return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
//}
/// <summary>
/// 修改药占比配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("drugupdate")]
[HttpPost]
public ApiResponse<DrugpropResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] DrugpropRequest request)
{
var drugprop = _configService.DrugUpdate(request);
return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
}
///// <summary>
///// 修改药占比配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("drugupdate")]
//[HttpPost]
//public ApiResponse<DrugpropResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] DrugpropRequest request)
//{
// var drugprop = _configService.DrugUpdate(request);
// return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
//}
/// <summary>
/// 删除药占比配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("drugdelete")]
[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] DrugpropRequest request)
{
if (!_configService.DrugDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
///// <summary>
///// 删除药占比配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("drugdelete")]
//[HttpPost]
//public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] DrugpropRequest request)
//{
// if (!_configService.DrugDelete(request))
// return new ApiResponse(ResponseType.Fail);
// return new ApiResponse(ResponseType.OK);
//}
#endregion
#region drugtype
......@@ -469,58 +469,58 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
#endregion
#region cmi
/// <summary>
/// 获取 CMI配置信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cmilist")]
[HttpPost]
public ApiResponse GetHosCMIList([FromBody] cof_cmi request)
{
var list = _configService.GetCMIList(request.AllotId);
return new ApiResponse(ResponseType.OK, "ok", list);
}
///// <summary>
///// 获取 CMI配置信息
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("cmilist")]
//[HttpPost]
//public ApiResponse GetHosCMIList([FromBody] cof_cmi request)
//{
// var list = _configService.GetCMIList(request.AllotId);
// return new ApiResponse(ResponseType.OK, "ok", list);
//}
/// <summary>
/// 新增 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cmiinsert")]
[HttpPost]
public ApiResponse HosCMIInsert([FromBody] cof_cmi request)
{
var drugprop = _configService.HosCMIInsert(request);
return new ApiResponse(ResponseType.OK, drugprop);
}
///// <summary>
///// 新增 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("cmiinsert")]
//[HttpPost]
//public ApiResponse HosCMIInsert([FromBody] cof_cmi request)
//{
// var drugprop = _configService.HosCMIInsert(request);
// return new ApiResponse(ResponseType.OK, drugprop);
//}
/// <summary>
/// 修改 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cmiupdate")]
[HttpPost]
public ApiResponse HosCMIUpdate([FromBody] cof_cmi request)
{
var drugprop = _configService.HosCMIUpdate(request);
return new ApiResponse(ResponseType.OK, drugprop);
}
///// <summary>
///// 修改 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("cmiupdate")]
//[HttpPost]
//public ApiResponse HosCMIUpdate([FromBody] cof_cmi request)
//{
// var drugprop = _configService.HosCMIUpdate(request);
// return new ApiResponse(ResponseType.OK, drugprop);
//}
/// <summary>
/// 删除 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cmidelete")]
[HttpPost]
public ApiResponse HosCMIDelete([FromBody] cof_cmi request)
{
if (!_configService.HosCMIDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
///// <summary>
///// 删除 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("cmidelete")]
//[HttpPost]
//public ApiResponse HosCMIDelete([FromBody] cof_cmi request)
//{
// if (!_configService.HosCMIDelete(request))
// return new ApiResponse(ResponseType.Fail);
// return new ApiResponse(ResponseType.OK);
//}
#endregion
/// <summary>
......
......@@ -17,17 +17,18 @@ namespace Performance.Api.Controllers
[ApiController]
public class ExConfigController : Controller
{
private readonly ILogger<ExConfigController> logger;
private ILogger logger;
private WebapiUrl options;
private ExConfigService configService;
private WebapiUrl url;
public ExConfigController(
ILogger<ExConfigController> logger,
ExConfigService configService,
IOptions<WebapiUrl> url)
IOptions<WebapiUrl> options,
ExConfigService configService)
{
this.logger = logger;
this.options = options.Value;
this.configService = configService;
this.url = url.Value;
}
/// <summary>
......@@ -43,7 +44,7 @@ public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody] Mod
if (request.ExecuteType == null || !request.ExecuteType.Any())
return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!");
var list = configService.ExtractScheme(request.HospitalId.Value, request.ExecuteType);
var list = configService.ExtractScheme(request.HospitalId.Value, request.ExecuteType, request.SheetType);
return new ApiResponse(ResponseType.OK, list);
}
......@@ -70,9 +71,24 @@ public ApiResponse FeeSource([FromBody] ModModuleRequest request)
if (request.HospitalId == null || request.HospitalId.Value == 0)
return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
string retJson = HttpHelper.HttpPost(url.HttpPost + "/modextract/source", JsonHelper.Serialize(request), true);
var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
return new ApiResponse(ResponseType.OK, ret.Data);
bool isSingle = false;
configService.QueryHosConfigs(request.ModuleId.Value, ref isSingle, out int sheetType);
ModFeeResponse response;
if (isSingle)
{
response = configService.FeeSource(request);
}
else
{
var http = new RestSharpHelper();
var url = http.SetUrl(options.HttpPost, "/modextract/source");
var req = http.CreatePostRequest(JsonHelper.Serialize(request));
var res = http.GetResponse(url, req);
var ret = http.GetContent<ApiResponse<ModFeeResponse>>(res);
response = ret.Data;
}
return new ApiResponse(ResponseType.OK, response);
}
/// <summary>
......@@ -161,15 +177,29 @@ public ApiResponse AddItem([FromBody] ItemListRequest request)
[HttpPost]
public ApiResponse Items([FromBody] ModItemRequest request)
{
if (!configService.QueryHosConfigs(request.ModuleId.Value, out int sheetType))
bool isSingle = false;
if (!configService.QueryHosConfigs(request.ModuleId.Value, ref isSingle, out int sheetType))
return new ApiResponse(ResponseType.Fail, "当前医院未配置地址");
if (sheetType == (int)SheetType.Income)
{
logger.LogInformation($"绩效收入模板配置项列表 : 请求地址 {url.HttpPost}/modextract/items");
HttpHelper.HttpPost(url.HttpPost + "/modextract/items", JsonHelper.Serialize(request), true);
if (isSingle)
{
configService.AddItems(request.ModuleId.Value);
}
else
{
logger.LogInformation($"绩效收入模板配置项列表 : 请求地址 {options.HttpPost}/modextract/items");
var http = new RestSharpHelper();
var url = http.SetUrl(options.HttpPost, "/modextract/items");
var req = http.CreatePostRequest(JsonHelper.Serialize(request));
var res = http.GetResponse(url, req);
var ret = http.GetContent<ApiResponse>(res);
logger.LogInformation($"绩效收入模板配置项列表在{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss完成请求")}");
}
}
var list = configService.QueryItems(request.ModuleId.Value);
return new ApiResponse(ResponseType.OK, list);
}
......@@ -204,8 +234,8 @@ public ApiResponse DelItem([FromBody] ModItemRequest request)
return new ApiResponse(ResponseType.OK, "删除成功!");
}
#region 特殊科室模板
/// <summary>
/// 特殊科室模板配置项新增
/// </summary>
......@@ -266,7 +296,6 @@ public ApiResponse DelSpecial([FromBody] ModSpecialRequest request)
return new ApiResponse(ResponseType.OK, "删除成功!");
}
/// <summary>
/// 特殊科室人均
/// </summary>
......@@ -278,7 +307,8 @@ public ApiResponse PerforType()
var list = configService.PerforType();
return new ApiResponse(ResponseType.OK, list);
}
#endregion
#endregion 特殊科室模板
/// <summary>
/// 数据配置项
......
......@@ -402,10 +402,10 @@ public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
public ApiResponse OtherList([FromBody] AgOtherRequest request)
{
//var result = secondAllotService.OtherList(request.SecondId, claimService.GetUserId());
var result = secondAllotDetails.GetOtherTempDetails(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource);
var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
var obj = new
{
header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(t => t.RealAmount)),
header = secondAllotService.OtherListHeader(request.SecondId, realAmount ?? 0),
body = result,
};
return new ApiResponse(ResponseType.OK, obj);
......@@ -415,12 +415,12 @@ public ApiResponse OtherList([FromBody] AgOtherRequest request)
/// 二次绩效其他绩效保存
/// </summary>
/// <returns></returns>
[Route("api/second/other/save")]
[Route("api/second/other/save/{secondId}")]
[HttpPost]
public ApiResponse OtherSave([FromBody] AgOtherRequest request)
public ApiResponse OtherSave(int secondId, [FromBody] SaveCollectData request)
{
var result = secondAllotService.OtherSave(request.SecondId, request.Othersources);
return new ApiResponse(ResponseType.OK, result);
secondAllotService.OtherSave(secondId, request);
return new ApiResponse(ResponseType.OK);
}
#endregion 二次绩效其他绩效
......@@ -448,6 +448,7 @@ public ApiResponse DeptComputeDetail(int allotId)
var userId = claimService.GetUserId();
//var data = secondAllotService.DeptComputeDetail(userId, allotId, out int isShowManage);
var data = secondAllotService.DeptComputeDetailList(userId, allotId, out int isShowManage);
return new ApiResponse(ResponseType.OK, new { isShowManage, data });
}
}
......
using FluentValidation.AspNetCore;
using Hangfire;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
......@@ -18,50 +18,52 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api.Controllers
{
[Route("api/[controller]")]
public class TemplateController : Controller
{
private readonly ILogger logger;
private readonly IHostingEnvironment env;
private readonly ClaimService claim;
private readonly WebapiUrl url;
private readonly Application application;
private readonly TemplateService templateService;
private readonly DFExtractService extractService;
private readonly ExtractIncomeService extractIncomeService;
private readonly ExtractService extractEService;
private HospitalService hospitalService;
private IHostingEnvironment env;
private ClaimService claim;
private Application application;
private WebapiUrl url;
private readonly ExConfigService configService;
private readonly HospitalService hospitalService;
private readonly AllotService allotService;
private readonly LogManageService logService;
private readonly ILogger<ExceptionsFilter> logger;
private readonly IServiceScopeFactory serviceScopeFactory;
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
DFExtractService extractService,
ExtractIncomeService extractIncomeService,
ExtractService extractEService,
public TemplateController(
ILogger<ExceptionsFilter> logger,
IHostingEnvironment env,
ClaimService claim,
IOptions<Application> options,
IOptions<WebapiUrl> url,
IOptions<Application> options,
TemplateService templateService,
ExtractIncomeService extractIncomeService,
ExConfigService configService,
HospitalService hospitalService,
AllotService allotService,
LogManageService logService,
ILogger<ExceptionsFilter> logger)
IServiceScopeFactory serviceScopeFactory)
{
this.templateService = templateService;
this.extractService = extractService;
this.extractIncomeService = extractIncomeService;
this.extractEService = extractEService;
this.hospitalService = hospitalService;
this.logger = logger;
this.env = env;
this.claim = claim;
this.application = options.Value;
this.url = url.Value;
this.application = options.Value;
this.templateService = templateService;
this.extractIncomeService = extractIncomeService;
this.configService = configService;
this.hospitalService = hospitalService;
this.allotService = allotService;
this.logService = logService;
this.logger = logger;
this.serviceScopeFactory = serviceScopeFactory;
}
/// <summary>
......@@ -79,15 +81,19 @@ public IActionResult DownFile(int type = 1)
case 1:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xls");
break;
case 2:
path = Path.Combine(env.ContentRootPath, "Template", "医院二次分配绩效模板.xlsx");
break;
case 3:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板(无执行科室).xlsx");
break;
case 4:
path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xls");
break;
case 5:
path = Path.Combine(env.ContentRootPath, "Template", "工作量数据导入模板.xls");
break;
......@@ -157,70 +163,8 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.OK);
}
#region 老版提取
///// <summary>
///// 提取绩效数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("extractdata")]
//[HttpPost]
//public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBody]AllotRequest request)
//{
// try
// {
// var allot = allotService.GetAllot(request.ID);
// if (allot == null)
// return new ApiResponse(ResponseType.Fail, "该绩效无效");
// allot.IsExtracting = allot.IsExtracting ?? 0;
// if (allot.IsExtracting == 1)
// return new ApiResponse(ResponseType.Fail, "正在提取数据,请稍等。");
// var hospital = hospitalService.GetHopital(request.HospitalId.Value);
// if (hospital == null)
// return new ApiResponse(ResponseType.Fail, "医院无效");
// var email = claim.GetUserClaim(JwtClaimTypes.Mail);
// allot.IsExtracting = 1;
// allotService.Update(allot);
// string path = extractService.GetFilepath(hospital.ID, out int type);
// if (!string.IsNullOrEmpty(path) && type != 0)
// {
// //发送请求,返回路径
// string retJson = HttpHelper.HttpClient(url.ImportFirst + $"?type={type}&hospitalId={hospital.ID}&year={allot.Year}&month={allot.Month}", path);
// var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
// if ((int)ret.State != 1)
// return new ApiResponse(ResponseType.Fail, "首次模板地址无效!");
// path = ret.Message;
// }
// string param = JsonHelper.Serialize(new
// {
// id = request.ID,
// hospitalId = hospital.ID,
// mail = email,
// path = path
// });
// HttpHelper.HttpPostNoRequest(url.ExtractData, param, true);
// //extractService.ExtractData(request.ID, user.Mail, hospital);
// //BackgroundJob.Enqueue(() => extractService.ExtractData(request.ID, user.Mail, hospital));
// return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
// }
// catch (Exception ex)
// {
// var allot = allotService.GetAllot(request.ID);
// if (allot != null)
// {
// allot.IsExtracting = 3;
// allotService.Update(allot);
// }
// throw ex;
// }
//}
#endregion
#region 新版提取
/// <summary>
/// 提取绩效数据
/// </summary>
......@@ -237,10 +181,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
try
{
bool isSingle = false;
string message = extractService.Judge(request.AllotId, request.HospitalId, request.UseScheme, ref isSingle, out string filePath);
string message = configService.Judge(request.AllotId, request.HospitalId, request.UseScheme, ref isSingle, out string filePath);
if (!string.IsNullOrEmpty(message))
return new ApiResponse(ResponseType.Fail, message);
//if (!string.IsNullOrEmpty(filePath))
//{
// var data = configService.CheckHasNewDepartmentOrCategory(request.AllotId);
// return new ApiResponse(ResponseType.Fail, data);
//}
//检验科室、费用类型是否需要补充
allot.IsExtracting = allot.IsExtracting ?? 0;
if (allot.IsExtracting == 1)
return new ApiResponse(ResponseType.OK, "正在提取数据,请稍等!", new { IsExtracting = true });
......@@ -250,15 +202,33 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
if (isSingle)
{
string extractFilePath = extractEService.Main(allot.ID, allot.HospitalId, email, "User" + claim.GetUserId(), filePath, true);
Task.Run(() =>
{
using (var scope = serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<ExtractService>();
string extractFilePath = scopedServices.Main(allot.ID, allot.HospitalId, email, "User" + claim.GetUserId(), filePath, isSingle);
}
});
}
else
{
logger.LogInformation("提取绩效数据请求路径:" + url.HttpPost + "/extract/extract");
if (string.IsNullOrEmpty(filePath))
HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={email}&userId={claim.GetUserId()}", "");
else
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={email}&userId={claim.GetUserId()}", filePath, true);
var http = new RestSharpHelper();
string endpoint = "/extract/extract";
var extractUrl = http.SetUrl(url.HttpPost, endpoint);
var obj = new
{
allotId = request.AllotId,
hospitalId = request.HospitalId,
email = email,
userId = claim.GetUserId()
};
string json = JsonHelper.Serialize(obj);
var parameter = JsonHelper.Deserialize<Dictionary<string, object>>(json);
var restRequest = string.IsNullOrEmpty(filePath) ? http.CreatePostRequest(json) : http.CreateFileRequest(new string[] { filePath }, parameter);
Task.Run(() => http.GetResponse(extractUrl, restRequest));
}
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!", new { IsExtracting = false });
......@@ -281,8 +251,8 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
// B 使用配置作为模板
}
#endregion
#endregion 新版提取
/// <summary>
/// 从WebAPI下载文件
......@@ -314,26 +284,31 @@ public IActionResult DownFile([FromQuery] AllotRequest request)
/// <summary>
/// 保存提取文件
/// </summary>
/// <param name="form"></param>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[Route("savefile")]
[HttpPost]
[AllowAnonymous]
public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int hospitalId)
public ApiResponse SaveFile()
{
logger.LogInformation($"保存提取文件请求参数:allotId:{allotId} hospitalId:{hospitalId}");
try
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (var key in Request.Form.Keys)
{
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
if (Request.Form.Files == null || !Request.Form.Files.Any())
{
logger.LogError($"返回文件为空!");
return new ApiResponse(ResponseType.Error, "上传文件无效");
}
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", "autoextract");
logger.LogInformation("保存提取文件请求参数:" + json);
try
{
var file = Request.Form.Files[0];
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{request.HospitalId}", "autoextract");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
......@@ -349,24 +324,22 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
return new ApiResponse(ResponseType.Error, "保存失败");
}
}
var allot = allotService.GetAllot(allotId);
var allot = allotService.GetAllot(request.AllotId);
allot.ExtractPath = path;
allot.IsExtracting = 2;
if (string.IsNullOrEmpty(path) || !FileHelper.IsExistFile(path))
{
logger.LogInformation($"保存提取文件文件未保存成功,保存文件不存在!");
return new ApiResponse(ResponseType.Fail, "上传成功!");
}
if (!allotService.Update(allot))
{
logger.LogInformation($"保存提取文件更新文件路径失败!");
return new ApiResponse(ResponseType.Fail, "上传成功!");
}
return new ApiResponse(ResponseType.OK, "上传成功!");
string success = "上传成功!";
string message = (string.IsNullOrEmpty(path) || !FileHelper.IsExistFile(path))
? "保存提取文件文件未保存成功,保存文件不存在!"
: (!allotService.Update(allot)) ? "保存提取文件更新文件路径失败!" : success;
if (message == success)
return new ApiResponse(ResponseType.OK, message);
else
return new ApiResponse(ResponseType.Fail, message);
}
catch (Exception ex)
{
logger.LogInformation($"保存提取文件异常{ex.ToString()}");
logger.LogError($"保存提取文件保存失败:" + ex.ToString());
return new ApiResponse(ResponseType.Error, ex.Message);
}
......@@ -375,24 +348,20 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
/// <summary>
/// 返回日志
/// </summary>
/// <param name="type">1 进度条 2 信息</param>
/// <param name="tag"></param>
/// <param name="message"></param>
/// <param name="level"></param>
/// <param name="groupName"></param>
/// <param name="request"></param>
[Route("returnlog")]
[HttpPost]
[AllowAnonymous]
public void ReturnLog(int type, string tag, string message, int level, string groupName)
public void ReturnLog([FromBody] SignalrLogRequest request)
{
logger.LogInformation("返回日志:" + JsonHelper.Serialize(new { type, tag, message, level, groupName }));
if (type == 3)
logger.LogInformation("返回日志:" + JsonHelper.Serialize(request));
if (request.Type == 3)
{
logService.Schedule(groupName, ConvertHelper.To<decimal>(message), level);
logService.Schedule(request.GroupName, ConvertHelper.To<decimal>(request.Message), request.Level);
}
else
{
logService.ExtractLog(groupName, tag, message, level);
logService.ExtractLog(request.GroupName, request.Tag, request.Message, request.Level);
}
}
......
......@@ -32,6 +32,7 @@
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<UserSecretsId>e732666b-5531-4cd8-b713-2fe3db31126c</UserSecretsId>
</PropertyGroup>
<ItemGroup>
......
......@@ -8,7 +8,7 @@
},
"AppConnection": {
//"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_performance;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_yubei;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
},
......
......@@ -184,6 +184,13 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.Recalculation(Performance.DtoModels.RecalculationRequest)">
<summary>
重新计算院领导绩效
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.Pigeonhole(Performance.DtoModels.AllotRequest)">
<summary>
归档绩效记录
......@@ -426,34 +433,6 @@
<param name="computeId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugList(Performance.DtoModels.DrugpropRequest)">
<summary>
获取 药占比配置信息列表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.DrugInsert(Performance.DtoModels.DrugpropRequest)">
<summary>
新增药占比配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.Update(Performance.DtoModels.DrugpropRequest)">
<summary>
修改药占比配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.Delete(Performance.DtoModels.DrugpropRequest)">
<summary>
删除药占比配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)">
<summary>
获取 药占比类型信息列表
......@@ -566,34 +545,6 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetHosCMIList(Performance.EntityModels.cof_cmi)">
<summary>
获取 CMI配置信息
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.HosCMIInsert(Performance.EntityModels.cof_cmi)">
<summary>
新增 CMI配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.HosCMIUpdate(Performance.EntityModels.cof_cmi)">
<summary>
修改 CMI配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.HosCMIDelete(Performance.EntityModels.cof_cmi)">
<summary>
删除 CMI配置
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.WorkHeader(Performance.DtoModels.WorkItemRequest)">
<summary>
获取工作量绩效列头
......@@ -1287,7 +1238,7 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherSave(Performance.DtoModels.AgOtherRequest)">
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherSave(System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
二次绩效其他绩效保存
</summary>
......@@ -1359,24 +1310,17 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.SaveFile(Microsoft.AspNetCore.Http.IFormCollection,System.Int32,System.Int32)">
<member name="M:Performance.Api.Controllers.TemplateController.SaveFile">
<summary>
保存提取文件
</summary>
<param name="form"></param>
<param name="allotId"></param>
<param name="hospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(System.Int32,System.String,System.String,System.Int32,System.String)">
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(Performance.DtoModels.SignalrLogRequest)">
<summary>
返回日志
</summary>
<param name="type">1 进度条 2 信息</param>
<param name="tag"></param>
<param name="message"></param>
<param name="level"></param>
<param name="groupName"></param>
<param name="request"></param>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(Performance.EntityModels.log_dbug)">
<summary>
......
......@@ -396,11 +396,6 @@
门诊药占比分值
</summary>
</member>
<member name="P:Performance.DtoModels.CofDrugProp.Prop">
<summary>
占比
</summary>
</member>
<member name="P:Performance.DtoModels.CofDrugProp.Factor">
<summary>
分值
......@@ -804,6 +799,18 @@
<member name="F:Performance.DtoModels.SheetType.PersonPostCoefficient">
<summary> 个人岗位系数 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.WorkloadMedicineProp">
<summary> 药占比系数 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.WorkloadCMI">
<summary> CMI系数 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.WorkloadIncline">
<summary> 工作量倾斜系数 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.Assess">
<summary> 考核 </summary>
</member>
<member name="T:Performance.DtoModels.AccountUnitType">
<summary>
核算单元类型
......@@ -1037,11 +1044,6 @@
应发管理绩效
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.MedicineFactor">
<summary>
药占比系数
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.Income">
<summary>
科室业绩
......@@ -2031,6 +2033,16 @@
邮箱
</summary>
</member>
<member name="P:Performance.DtoModels.ExtractRequest.GroupName">
<summary>
Signalr分组名称
</summary>
</member>
<member name="P:Performance.DtoModels.ExtractRequest.UserId">
<summary>
用户Id
</summary>
</member>
<member name="P:Performance.DtoModels.GuaranteeRequest.Id">
<summary> </summary>
</member>
......@@ -2842,6 +2854,9 @@
<member name="P:Performance.DtoModels.DetailModule.CMIFactor">
<summary> CMI系数 </summary>
</member>
<member name="P:Performance.DtoModels.DetailModule.InclineFactor">
<summary> 工作量倾斜系数 </summary>
</member>
<member name="P:Performance.DtoModels.DetailModule.ItemValue">
<summary> 结算值 </summary>
</member>
......
......@@ -67,18 +67,12 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_check">
<summary> 上传excel文件校验配置 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_cmi">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_depttype">
<summary> 科室类型 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_director">
<summary> 规模绩效、效率绩效计算系数配置 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_drugprop">
<summary> 工作量门诊药占比系数 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_drugtype">
<summary> 药占比费用列头名称 </summary>
</member>
......@@ -1316,36 +1310,6 @@
单元格列头名称
</summary>
</member>
<member name="T:Performance.EntityModels.cof_cmi">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_cmi.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_cmi.AllotId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_cmi.UnitType">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_cmi.AccountingUnit">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_cmi.Value">
<summary>
</summary>
</member>
<member name="T:Performance.EntityModels.cof_depttype">
<summary>
科室类型
......@@ -1406,36 +1370,6 @@
绩效系数
</summary>
</member>
<member name="T:Performance.EntityModels.cof_drugprop">
<summary>
工作量门诊药占比系数
</summary>
</member>
<member name="P:Performance.EntityModels.cof_drugprop.ID">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_drugprop.AllotID">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_drugprop.MaxRange">
<summary>
药占比最大范围(小于)
</summary>
</member>
<member name="P:Performance.EntityModels.cof_drugprop.MinRange">
<summary>
药占比最小范围(大于等于)
</summary>
</member>
<member name="P:Performance.EntityModels.cof_drugprop.Value">
<summary>
药占比对应系数
</summary>
</member>
<member name="T:Performance.EntityModels.cof_drugtype">
<summary>
药占比费用列头名称
......@@ -2136,11 +2070,6 @@
核算单元(护理组)
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.IncludeAvgCalculate">
<summary>
是否带入平均计算 是 否
......@@ -2151,11 +2080,6 @@
定科人数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorDirectorNumber">
<summary>
科主任数量
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorNumber">
<summary>
核算单元医生数量
......@@ -2166,11 +2090,6 @@
医生基础系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorSlopeFactor">
<summary>
倾斜系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorScale">
<summary>
规模绩效系数
......@@ -2206,11 +2125,6 @@
材料占比奖罚
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorExtra">
<summary>
医院奖罚
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.DoctorScoringAverage">
<summary>
考核对分率
......@@ -2231,71 +2145,6 @@
保底绩效系数
</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">
<summary>
考核对分率
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.NurseAdjustFactor">
<summary>
调节系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.WorkSlopeFactor">
<summary>
工作量倾斜系数
</summary>
</member>
<member name="P:Performance.EntityModels.im_accountbasic.UpdateDate">
<summary>
......
......@@ -10,12 +10,12 @@ public class HandsonTable
{
private IEnumerable<collect_permission> _permissions;
private List<Dictionary<string, string>> _data;
public HandsonTable(int sheetType, string[] cols, List<collect_permission> permissions)
{
_permissions = permissions;
_data = new List<Dictionary<string, string>>();
InitColHeaders(sheetType, cols);
InitColumns(permissions);
}
......@@ -40,6 +40,8 @@ public void SetRowData(IEnumerable<HandsonRowData> datas, bool isTypein)
dic[item.Name.ToLower()] = item.Value?.ToString() ?? "";
else if (dic.ContainsKey(item.Name.ToLower()) && _permissions.Any(w => w.HeadName.ToLower() == item.Name.ToLower() && w.AttachLast > 0))
dic[item.Name.ToLower()] = item.Value?.ToString() ?? "";
else if (dic.ContainsKey(item.Name.ToLower()) && _permissions.Any(w => w.HeadName.ToLower() == item.Name.ToLower()))
dic[item.Name.ToLower()] = item.Value?.ToString() ?? "";
}
_data.Add(dic);
}
......@@ -105,20 +107,25 @@ public HandsonColumn(string data, bool readOnly = false, DataFormat format = Dat
case DataFormat.普通格式:
Type = "text";
break;
case DataFormat.小数:
Type = "numeric";
NumericFormat = new NumericFormat { Pattern = "0,00.00" };
break;
case DataFormat.百分比:
Type = "numeric";
NumericFormat = new NumericFormat { Pattern = "0,00.00%" };
break;
}
}
public string Data { get; set; }
public bool ReadOnly { get; set; }
public string Type { get; set; }
public string[] Source { get; set; }
public bool Strict { get; set; } = false;
public NumericFormat NumericFormat { get; set; }
}
......
......@@ -9,11 +9,13 @@ namespace Performance.DtoModels
/// </summary>
public class CofDrugProp
{
public string AccoutingUnit { get; set; }
/// <summary>
/// 占比
/// </summary>
public decimal Prop { get; set; }
public string AccountingUnit { get; set; }
public string UnitType { get; set; }
//public string AccoutingUnit { get; set; }
///// <summary>
///// 占比
///// </summary>
//public decimal Prop { get; set; }
/// <summary>
/// 分值
/// </summary>
......
......@@ -11,32 +11,41 @@ public enum ExcelVersion
xls
}
/// <summary> 核算单元类型 </summary>
public enum UnitType
{
[Description("医生组")]
医生组 = 1,
[Description("护理组")]
护理组 = 2,
[Description("医技组")]
医技组 = 3,
[Description("专家组")]
专家组 = 4,
//[Description("其他")]
//其他 = 5,
[Description("特殊核算组")]
特殊核算组 = 6,
[Description("其他医生组")]
其他医生组 = 7,
[Description("其他护理组")]
其他护理组 = 8,
[Description("其他医技组")]
其他医技组 = 9,
[Description("行政高层")]
行政高层 = 10,
[Description("行政中层")]
行政中层 = 11,
[Description("行政后勤")]
行政后勤 = 12,
}
......@@ -46,27 +55,35 @@ public enum SheetType
/// <summary> 无法识别 </summary>
[Description("无法识别")]
Unidentifiable = 1,
/// <summary> 行政中高层 </summary>
[Description("行政中高层")]
Employee = 2,
/// <summary> 收入 </summary>
[Description("收入")]
Income = 3,
/// <summary> 其他收入 </summary>
[Description("其他收入")]
OtherIncome = 4,
/// <summary> 支出 </summary>
[Description("支出")]
Expend = 5,
/// <summary> 加班 </summary>
[Description("加班")]
Overtime = 6,
/// <summary> 工作量 </summary>
[Description("工作量")]
Workload = 7,
/// <summary> 特殊核算单元 </summary>
[Description("特殊核算单元")]
SpecialUnit = 8,
/// <summary> 临床科室医护绩效测算基础 </summary>
[Description("临床科室医护绩效测算基础")]
AccountBasic = 9,
......@@ -74,15 +91,19 @@ public enum SheetType
/// <summary> 科室经济核算汇总表 </summary>
[Description("科室经济核算汇总表")]
ComputeEconomic = 10,
/// <summary> 医生工作量计算 </summary>
[Description("医生工作量计算")]
ComputeDoctorWorkload = 11,
/// <summary> 护士工作量计算 </summary>
[Description("护士工作量计算")]
ComputeNurseWorkload = 12,
/// <summary> 临床科室医生绩效测算表 </summary>
[Description("临床科室医生绩效测算表")]
ComputeDoctorAccount = 13,
/// <summary> 临床科室护士绩效测算表 </summary>
[Description("临床科室护士绩效测算表")]
ComputeNurseAccount = 14,
......@@ -115,7 +136,6 @@ public enum SheetType
[Description("行政后勤")]
LogisticsEmployee = 21,
/// <summary> 科室考核 </summary>
[Description("科室考核")]
AccountScoreAverage = 25,
......@@ -132,22 +152,41 @@ public enum SheetType
[Description("其他工作量")]
OtherWorkload = 28,
/// <summary> 预算比例 </summary>
[Description("预算比例")]
BudgetRatio = 30,
/// <summary> 科室考核前其他绩效 </summary>
[Description("科室考核前其他绩效")]
AssessBeforeOtherFee = 31,
/// <summary> 其他管理绩效 </summary>
[Description("其他管理绩效")]
PersonOtherManagePerforFee = 32,
/// <summary> 调节后其他管理绩效 </summary>
[Description("调节后其他管理绩效")]
PersonAdjustLaterOtherManagePerforFee = 33,
/// <summary> 个人岗位系数 </summary>
[Description("个人岗位系数")]
PersonPostCoefficient = 34,
/// <summary> 药占比系数 </summary>
[Description("药占比系数")]
WorkloadMedicineProp = 35,
/// <summary> CMI系数 </summary>
[Description("CMI系数")]
WorkloadCMI = 36,
/// <summary> 工作量倾斜系数 </summary>
[Description("工作量倾斜系数")]
WorkloadIncline = 37,
/// <summary> 考核 </summary>
[Description("考核")]
Assess = 38, //该参数作用类似于 其他工作量
}
/// <summary>
......@@ -158,18 +197,23 @@ public enum AccountUnitType
/// <summary> </summary>
[Description("")]
Null = 1,
/// <summary> 临床科室 </summary>
[Description("科主任")]
科主任 = 2,
/// <summary> 临床科室 </summary>
[Description("护士长")]
护士长 = 3,
/// <summary> 行政高层 </summary>
[Description("行政高层")]
行政高层 = 4,
/// <summary> 临床科室 </summary>
[Description("行政中层")]
行政中层 = 5,
/// <summary> 临床科室 </summary>
[Description("行政工勤")]
行政工勤 = 6,
......@@ -179,30 +223,43 @@ public enum PerforType
{
[Description("临床科室主任人均绩效")]
临床主任,
[Description("临床科室副主任人均绩效")]
临床副主任,
[Description("医技科室主任人均绩效")]
医技主任,
[Description("医技科室副主任人均绩效")]
医技副主任,
[Description("护士长人均绩效")]
护士长,
[Description("护士人均绩效")]
护士,
[Description("临床主任护士长平均")]
临床主任护士长平均,
[Description("临床主任医技主任护士长平均")]
临床主任医技主任护士长平均,
[Description("临床医生人均绩效")]
临床医生,
[Description("医技医生人均绩效")]
医技医生,
[Description("行政高层人均绩效")]
行政高层,
[Description("行政中层人均绩效")]
行政中层,
[Description("行政工勤人均绩效")]
行政工勤,
[Description("医生护士平均绩效")]
医生护士平均,
}
......@@ -214,12 +271,16 @@ public enum MinimumType
{
[Description("保底绩效临床医生人均绩效")]
保底临床医生 = 1,
[Description("保底绩效医技医生人均绩效")]
保底医技医生 = 2,
[Description("保底绩效护士人均绩效")]
保底护士 = 3,
[Description("保底绩效行政工勤人均绩效")]
保底工勤 = 4,
[Description("自定义保底绩效")]
自定义保底 = 5,
}
......
......@@ -72,6 +72,6 @@ public class PerData : IPerData
public int PointCell { get; set; }
public string SignID { get; set; }
public decimal? MedicineFactor { get; set; }
//public decimal? MedicineFactor { get; set; }
}
}
......@@ -177,10 +177,10 @@ public class PerDataAccountBaisc : IPerData
#region 由计算得出
/// <summary>
/// 药占比系数
/// </summary>
public Nullable<decimal> MedicineFactor { get; set; }
///// <summary>
///// 药占比系数
///// </summary>
//public Nullable<decimal> MedicineFactor { get; set; }
///// <summary>
///// 保底绩效金额
......
......@@ -27,9 +27,16 @@ public class ExtractRequest
/// </summary>
public string Email { get; set; }
/// <summary>
/// Signalr分组名称
/// </summary>
public string GroupName { get; set; }
}
/// <summary>
/// 用户Id
/// </summary>
public int UserId { get; set; }
}
public class ExtractRequestValidator : AbstractValidator<ExtractRequest>
{
......
namespace Performance.DtoModels
{
public class RecalculationRequest
{
public int AllotId { get; set; }
public decimal? Money { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class SignalrLogRequest
{
public int Type { get; set; }
public string Tag { get; set; }
public string Message { get; set; }
public int Level { get; set; }
public string GroupName { get; set; }
}
}
......@@ -85,6 +85,9 @@ public class DetailModule
/// <summary> CMI系数 </summary>
public decimal? CMIFactor { get; set; }
/// <summary> 工作量倾斜系数 </summary>
public decimal? InclineFactor { get; set; }
/// <summary> 结算值 </summary>
public decimal? ItemValue { get; set; }
}
......
......@@ -74,8 +74,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> 上传excel文件校验配置 </summary>
public virtual DbSet<cof_check> cof_check { get; set; }
/// <summary> </summary>
public virtual DbSet<cof_cmi> cof_cmi { get; set; }
///// <summary> </summary>
//public virtual DbSet<cof_cmi> cof_cmi { get; set; }
/// <summary> 科室类型 </summary>
public virtual DbSet<cof_depttype> cof_depttype { get; set; }
......@@ -83,8 +83,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> 规模绩效、效率绩效计算系数配置 </summary>
public virtual DbSet<cof_director> cof_director { get; set; }
/// <summary> 工作量门诊药占比系数 </summary>
public virtual DbSet<cof_drugprop> cof_drugprop { get; set; }
///// <summary> 工作量门诊药占比系数 </summary>
//public virtual DbSet<cof_drugprop> cof_drugprop { get; set; }
/// <summary> 药占比费用列头名称 </summary>
public virtual DbSet<cof_drugtype> cof_drugtype { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" cof_cmi.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
////-----------------------------------------------------------------------
//// <copyright file=" cof_cmi.cs">
//// * FileName: .cs
//// </copyright>
////-----------------------------------------------------------------------
//using System;
//using System.ComponentModel.DataAnnotations;
//using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("cof_cmi")]
public class cof_cmi
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
//namespace Performance.EntityModels
//{
// /// <summary>
// ///
// /// </summary>
// [Table("cof_cmi")]
// public class cof_cmi
// {
// /// <summary>
// ///
// /// </summary>
// [Key]
// public int Id { get; set; }
/// <summary>
///
/// </summary>
public int AllotId { get; set; }
// /// <summary>
// ///
// /// </summary>
// public int AllotId { get; set; }
/// <summary>
///
/// </summary>
public int UnitType { get; set; }
// /// <summary>
// ///
// /// </summary>
// public int UnitType { get; set; }
/// <summary>
///
/// </summary>
public string AccountingUnit { get; set; }
// /// <summary>
// ///
// /// </summary>
// public string AccountingUnit { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
// /// <summary>
// ///
// /// </summary>
// public Nullable<decimal> Value { get; set; }
// }
//}
//-----------------------------------------------------------------------
// <copyright file=" cof_drugprop.cs">
// * FileName: 工作量门诊药占比系数.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
////-----------------------------------------------------------------------
//// <copyright file=" cof_drugprop.cs">
//// * FileName: 工作量门诊药占比系数.cs
//// </copyright>
////-----------------------------------------------------------------------
//using System;
//using System.ComponentModel.DataAnnotations;
//using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
/// 工作量门诊药占比系数
/// </summary>
[Table("cof_drugprop")]
public class cof_drugprop
{
/// <summary>
///
/// </summary>
[Key]
public int ID { get; set; }
//namespace Performance.EntityModels
//{
// /// <summary>
// /// 工作量门诊药占比系数
// /// </summary>
// [Table("cof_drugprop")]
// public class cof_drugprop
// {
// /// <summary>
// ///
// /// </summary>
// [Key]
// public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
// /// <summary>
// ///
// /// </summary>
// public Nullable<int> AllotID { get; set; }
/// <summary>
/// 药占比最大范围(小于)
/// </summary>
public Nullable<decimal> MaxRange { get; set; }
// /// <summary>
// /// 药占比最大范围(小于)
// /// </summary>
// public Nullable<decimal> MaxRange { get; set; }
/// <summary>
/// 药占比最小范围(大于等于)
/// </summary>
public Nullable<decimal> MinRange { get; set; }
// /// <summary>
// /// 药占比最小范围(大于等于)
// /// </summary>
// public Nullable<decimal> MinRange { get; set; }
/// <summary>
/// 药占比对应系数
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
// /// <summary>
// /// 药占比对应系数
// /// </summary>
// public Nullable<decimal> Value { get; set; }
// }
//}
......@@ -46,10 +46,10 @@ public class im_accountbasic
/// </summary>
public string NurseAccountingUnit { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
///// <summary>
///// 科室
///// </summary>
//public string Department { get; set; }
/// <summary>
/// 是否带入平均计算 是 否
......@@ -61,10 +61,10 @@ public class im_accountbasic
/// </summary>
public Nullable<decimal> PermanentStaff { get; set; }
/// <summary>
/// 科主任数量
/// </summary>
public Nullable<decimal> DoctorDirectorNumber { get; set; }
///// <summary>
///// 科主任数量
///// </summary>
//public Nullable<decimal> DoctorDirectorNumber { get; set; }
/// <summary>
/// 核算单元医生数量
......@@ -76,10 +76,10 @@ public class im_accountbasic
/// </summary>
public Nullable<decimal> DoctorBasicFactor { get; set; }
/// <summary>
/// 倾斜系数
/// </summary>
public Nullable<decimal> DoctorSlopeFactor { get; set; }
///// <summary>
///// 倾斜系数
///// </summary>
//public Nullable<decimal> DoctorSlopeFactor { get; set; }
/// <summary>
/// 规模绩效系数
......@@ -116,9 +116,9 @@ public class im_accountbasic
/// </summary>
public Nullable<decimal> MaterialsExtra { get; set; }
/// <summary>
/// 医院奖罚
/// </summary>
///// <summary>
///// 医院奖罚
///// </summary>
public Nullable<decimal> DoctorExtra { get; set; }
/// <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> NurseNumber { get; set; }
/// <summary>
/// 护理基础系数
/// </summary>
public Nullable<decimal> NurseBasicFactor { get; set; }
/// <summary>
/// 倾斜系数
/// </summary>
public Nullable<decimal> NurseSlopeFactor { get; set; }
/// <summary>
/// 规模绩效系数
/// </summary>
public Nullable<decimal> NurseScale { get; set; }
/// <summary>
/// 效率绩效系数
/// </summary>
public Nullable<decimal> NurseEffic { get; set; }
/// <summary>
/// 发放系数
/// </summary>
public Nullable<decimal> NurseGrant { get; set; }
/// <summary>
/// 其他绩效1
/// </summary>
public Nullable<decimal> NurseOtherPerfor1 { get; set; }
/// <summary>
/// 其他绩效2
/// </summary>
public Nullable<decimal> NurseOtherPerfor2 { get; set; }
/// <summary>
/// 医院奖罚
/// </summary>
public Nullable<decimal> NurseExtra { get; set; }
/// <summary>
/// 考核对分率
/// </summary>
public Nullable<decimal> NurseScoringAverage { get; set; }
/// <summary>
/// 调节系数
/// </summary>
public Nullable<decimal> NurseAdjustFactor { get; set; }
/// <summary>
/// 工作量倾斜系数
/// </summary>
public Nullable<decimal> WorkSlopeFactor { get; set; }
///// <summary>
///// 护士长人数
///// </summary>
//public Nullable<decimal> NurseHeadNumber { get; set; }
///// <summary>
///// 护士人数
///// </summary>
//public Nullable<decimal> NurseNumber { get; set; }
///// <summary>
///// 护理基础系数
///// </summary>
//public Nullable<decimal> NurseBasicFactor { get; set; }
///// <summary>
///// 倾斜系数
///// </summary>
//public Nullable<decimal> NurseSlopeFactor { get; set; }
///// <summary>
///// 规模绩效系数
///// </summary>
//public Nullable<decimal> NurseScale { get; set; }
///// <summary>
///// 效率绩效系数
///// </summary>
//public Nullable<decimal> NurseEffic { get; set; }
///// <summary>
///// 发放系数
///// </summary>
//public Nullable<decimal> NurseGrant { get; set; }
///// <summary>
///// 其他绩效1
///// </summary>
//public Nullable<decimal> NurseOtherPerfor1 { get; set; }
///// <summary>
///// 其他绩效2
///// </summary>
//public Nullable<decimal> NurseOtherPerfor2 { get; set; }
///// <summary>
///// 医院奖罚
///// </summary>
//public Nullable<decimal> NurseExtra { get; set; }
///// <summary>
///// 考核对分率
///// </summary>
//public Nullable<decimal> NurseScoringAverage { get; set; }
///// <summary>
///// 调节系数
///// </summary>
//public Nullable<decimal> NurseAdjustFactor { get; set; }
///// <summary>
///// 工作量倾斜系数
///// </summary>
//public Nullable<decimal> WorkSlopeFactor { get; set; }
/// <summary>
///
......@@ -220,12 +220,10 @@ public class im_accountbasic
/// 考核前其他绩效
/// </summary>
public Nullable<decimal> AssessBeforeOtherFee { get; set; }
/// <summary>
/// 考核后其他绩效
/// </summary>
public Nullable<decimal> AssessLaterOtherFee { get; set; }
/// <summary>
/// 调节后其他绩效
/// </summary>
......
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Extract.Api.Controllers
{
[Route("api/[controller]")]
public class ExtractController : Controller
{
private readonly DFExtractService extractService;
private readonly HospitalService hospitalService;
private readonly ExtractService extractService1;
private readonly WebapiUrl url;
private readonly ILogger<ExtractController> logger;
private readonly IHostingEnvironment evn;
private readonly ILogger logger;
private readonly WebapiUrl options;
private readonly ExtractService extractService1;
public ExtractController(DFExtractService extractService,
HospitalService hospitalService,
ExtractService extractService1,
IOptions<WebapiUrl> url,
public ExtractController(
IHostingEnvironment evn,
ILogger<ExtractController> logger,
IHostingEnvironment evn)
IOptions<WebapiUrl> options,
ExtractService extractService1)
{
this.extractService = extractService;
this.hospitalService = hospitalService;
this.extractService1 = extractService1;
this.url = url.Value;
this.logger = logger;
this.evn = evn;
this.logger = logger;
this.options = options.Value;
this.extractService1 = extractService1;
}
/// <summary>
/// 保存首次文件
/// </summary>
/// <param name="form"></param>
/// <param name="type">1、历史绩效文件 2、首次模板文件</param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[Route("import")]
[HttpPost]
public ApiResponse Import([FromForm] IFormCollection form, int type, int hospitalId, int year, int month)
{
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Error, "上传文件无效");
var dpath = Path.Combine(evn.ContentRootPath, "Files", $"{hospitalId}", "first");
if (type == 1)
dpath = Path.Combine(evn.ContentRootPath, "Files", $"{hospitalId}", $"{year}{month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
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.Error, "保存失败");
}
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
return new ApiResponse(ResponseType.OK, path);
else
return new ApiResponse(ResponseType.Error, "获取首次文件失败!");
}
///// <summary>
///// 提取数据
///// </summary>
///// <param name="request"></param>
//[HttpPost]
//[Route("index")]
//public void Index([FromBody]AllotRequest request)
//{
// var token = Guid.NewGuid().ToString("N");
// logger.LogInformation(token + ",开始提取数据,请求参数:" + JsonHelper.Serialize(request));
// var hospital = hospitalService.GetHopital(request.HospitalId.Value);
// var filepath = extractService.ExtractData(request.ID, request.Mail, hospital, request.Path);
// if (!string.IsNullOrEmpty(filepath) && FileHelper.IsExistFile(filepath))
// {
// int i = 1;
// while (i <= 5)
// {
// string retJson = HttpHelper.HttpClient(url.ImportFile + $"?allotId={request.ID}&hospitalId={hospital.ID}", filepath);
// logger.LogInformation(retJson);
// var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
// if ((int)ret.State == 1)
// break;
// i++;
// }
// }
// logger.LogInformation(token + ",提取结束,请求参数:" + JsonHelper.Serialize(request));
//}
#region 新版提取
/// <summary>
......@@ -117,25 +42,47 @@ public ApiResponse Import([FromForm] IFormCollection form, int type, int hospita
/// <returns></returns>
[Route("extract")]
[HttpPost]
public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email, string userId)
public void ExtractData()
{
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email, userId }));
if (allotId == 0 || hospitalId == 0)
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (var key in Request.Form.Keys)
{
dict.Add(key, Request.Form[key]);
}
string json = JsonHelper.Serialize(dict);
var request = JsonHelper.Deserialize<ExtractRequest>(json);
logger.LogInformation("提取绩效数据请求参数:" + json);
if (request == null || request.AllotId == 0 || request.HospitalId == 0)
return;
var path = string.Empty;
if (Request.Form.Files == null || !Request.Form.Files.Any())
logger.LogInformation($"文件为空,以模板文件进行数据提取!");
else
path = SaveFileAsTemplate(Request.Form.Files[0], request.HospitalId);
#region 保存历史绩效文件
string filePath = extractService1.Main(request.AllotId, request.HospitalId, request.Email, "User" + request.UserId, path);
logger.LogInformation($"抽取的文件地址: {filePath}");
if (form.Files == null || !form.Files.Any() || ((FormFileCollection)form.Files).FirstOrDefault() == null)
logger.LogInformation($"文件为空!");
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
ImportFileAsAllotExtractFile(request.AllotId, request.HospitalId, filePath);
else
logger.LogInformation($"保存提取文件提取文件不存在!");
}
#endregion 新版提取
#region 保存历史绩效文件
private string SaveFileAsTemplate(IFormFile file, int hospitalId)
{
var file = ((FormFileCollection)form.Files)?.FirstOrDefault();
var dpath = Path.Combine(evn.ContentRootPath, "Files", "HospitalAllot", $"{hospitalId}");
FileHelper.CreateDirectory(dpath);
path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
string path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
logger.LogInformation($"保存历史绩效文件保存路径:" + path);
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
......@@ -148,57 +95,45 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
{
logger.LogInformation($"保存历史绩效文件保存失败");
else
return "";
}
}
return path;
}
#endregion 保存历史绩效文件
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
//string filePath = extractService.ExtractData(allotId, email, hospitalId, "User" + userId, path); //抽取
string filePath = extractService1.Main(allotId, hospitalId, email, "User" + userId, path);
logger.LogInformation($"抽取文件地址: {filePath}");
#region 保存文件到网站下
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
private void ImportFileAsAllotExtractFile(int allotId, int hospitalId, string filePath)
{
string http = url.ImportFile + $"/template/savefile?allotId={allotId}&hospitalId={hospitalId}";
logger.LogInformation("请求路径:" + http + ",请求参数" + JsonHelper.Serialize(new
{
allotId,
hospitalId
}));
var http = new RestSharpHelper();
string endpoint = "/template/savefile";
var importUrl = http.SetUrl(options.ImportFile, endpoint);
var obj = new { allotId, hospitalId };
string json = JsonHelper.Serialize(obj);
var parameter = JsonHelper.Deserialize<Dictionary<string, object>>(json);
var request = http.CreateFileRequest(new string[] { filePath }, parameter);
int i = 1;
while (i <= 5)
{
if (i == 5)
logger.LogInformation($"保存文件失败,已尝试执行五次,请联系开发人员!");
else
logger.LogInformation($"正在尝试第{i}次保存!");
//保存文件
var files = new Dictionary<string, string> { { "file", filePath } };
string retJson = HttpHelper.HttpPost(http, files: files);
logger.LogInformation("保存提取文件返回结果:" + JsonHelper.Serialize(retJson));
logger.LogInformation(retJson);
var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
if (ret != null && (int)ret.State == 1)
var response = http.GetResponse(importUrl, request);
var result = http.GetContent<ApiResponse>(response);
if (result != null && (int)result.State == 1)
{
logger.LogInformation("保存提取文件保存成功!");
break;
return;
}
i++;
}
logger.LogInformation($"保存文件失败,已尝试执行五次,请联系开发人员!");
}
else
logger.LogInformation($"保存提取文件提取文件不存在!");
#endregion 保存文件到网站下
}
#endregion 新版提取
}
}
......@@ -16,6 +16,7 @@ public class ModExtractController : Controller
{
private readonly ILogger<ModExtractController> logger;
private ExConfigService service;
public ModExtractController(
ILogger<ModExtractController> logger,
ExConfigService service)
......@@ -24,34 +25,38 @@ public class ModExtractController : Controller
this.service = service;
}
/// <summary>
/// 绩效数据抽取模板
/// </summary>
/// <returns></returns>
[Route("scheme")]
[HttpPost]
public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody]ModModuleRequest request)
{
if (request.HospitalId == null || request.HospitalId.Value == 0)
return new ApiResponse(ResponseType.ParameterError, "HospitalId 不存在,请重新选择!");
if (request.ExecuteType == null || !request.ExecuteType.Any())
return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!");
#region 弃用
var list = service.ExtractScheme(request.HospitalId.Value, request.ExecuteType);
return new ApiResponse(ResponseType.OK, list);
}
///// <summary>
///// 绩效数据抽取模板
///// </summary>
///// <returns></returns>
//[Route("scheme")]
//[HttpPost]
//public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody]ModModuleRequest request)
//{
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 不存在,请重新选择!");
// if (request.ExecuteType == null || !request.ExecuteType.Any())
// return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!");
/// <summary>
/// 费用类型
/// </summary>
/// <returns></returns>
[Route("type")]
[HttpPost]
public ApiResponse FeeType()
{
var list = service.FeeType();
return new ApiResponse(ResponseType.OK, list);
}
// var list = service.ExtractScheme(request.HospitalId.Value, request.ExecuteType);
// return new ApiResponse(ResponseType.OK, list);
//}
///// <summary>
///// 费用类型
///// </summary>
///// <returns></returns>
//[Route("type")]
//[HttpPost]
//public ApiResponse FeeType()
//{
// var list = service.FeeType();
// return new ApiResponse(ResponseType.OK, list);
//}
#endregion 弃用
/// <summary>
/// 绩效考核项费用来源
......@@ -59,7 +64,7 @@ public ApiResponse FeeType()
/// <returns></returns>
[Route("source")]
[HttpPost]
public ApiResponse FeeSource([FromBody]ModModuleRequest request)
public ApiResponse FeeSource([FromBody] ModModuleRequest request)
{
if (request.HospitalId == null || request.HospitalId.Value == 0)
return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
......@@ -75,7 +80,7 @@ public ApiResponse FeeSource([FromBody]ModModuleRequest request)
/// <returns></returns>
[Route("items")]
[HttpPost]
public ApiResponse Items([FromBody]ModItemRequest request)
public ApiResponse Items([FromBody] ModItemRequest request)
{
logger.LogInformation($"绩效收入模板配置项列表:{JsonHelper.Serialize(request)}");
service.AddItems(request.ModuleId.Value);
......
using RestSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Infrastructure
{
public class RestSharpHelper
{
public const string tokenHeader = "Authorization";
public RestClient SetUrl(string baseUrl, string endpoint)
{
var url = Path.Combine(baseUrl, endpoint);
var restClient = new RestClient(url);
return restClient;
}
public RestRequest CreateGetRequest(string tokenHeader = tokenHeader, string token = null, int timeout = -1)
{
var restRequest = new RestRequest(Method.GET);
restRequest.AddHeader(tokenHeader, token);
restRequest.AddHeader("Accept", "application/json");
restRequest.Timeout = timeout;
return restRequest;
}
public RestRequest CreatePostRequest(string payload, string tokenHeader = tokenHeader, string token = null, int timeout = -1)
{
var restRequest = new RestRequest(Method.POST);
restRequest.AddHeader(tokenHeader, token);
restRequest.AddHeader("Accept", "application/json");
restRequest.AddParameter("application/json", payload, ParameterType.RequestBody);
restRequest.Timeout = timeout;
return restRequest;
}
public RestRequest CreateFileRequest(string[] files, Dictionary<string, object> parameter = null, string tokenHeader = tokenHeader, string token = null, int timeout = -1)
{
var restRequest = new RestRequest(Method.POST);
restRequest.AddHeader(tokenHeader, token);
if (files != null && files.Any(t => !string.IsNullOrEmpty(t)))
{
int i = 1;
foreach (var file in files.Where(t => !string.IsNullOrEmpty(t)))
{
restRequest.AddFile(i.ToString(), file);
i++;
}
}
if (parameter != null)
{
foreach (var item in parameter)
{
restRequest.AddParameter(item.Key, item.Value);
}
}
restRequest.Timeout = timeout;
return restRequest;
}
public RestRequest CreatePutRequest(string payload, string tokenHeader = tokenHeader, string token = null, int timeout = -1)
{
var restRequest = new RestRequest(Method.PUT);
restRequest.AddHeader(tokenHeader, token);
restRequest.AddHeader("Accept", "application/json");
restRequest.AddParameter("application/json", payload, ParameterType.RequestBody);
restRequest.Timeout = timeout;
return restRequest;
}
public RestRequest CreateDeleteRequest(string tokenHeader = tokenHeader, string token = null, int timeout = -1)
{
var restRequest = new RestRequest(Method.DELETE);
restRequest.AddHeader(tokenHeader, token);
restRequest.AddHeader("Accept", "application/json");
restRequest.Timeout = timeout;
return restRequest;
}
public IRestResponse GetResponse(RestClient client, RestRequest request)
{
return client.Execute(request);
}
public async Task<IRestResponse> GetResponseAsync(RestClient client, RestRequest request)
{
return await client.ExecuteAsync(request);
}
public DTO GetContent<DTO>(IRestResponse response)
{
var content = response.Content;
DTO dtoObject = JsonHelper.Deserialize<DTO>(content);
return dtoObject;
}
}
}
......@@ -28,6 +28,8 @@ public int DeleteData(int allotId)
"im_employee_logistics",
"im_header",
"im_specialunit",
"log_check",
"per_employee",
"per_sheet",
"res_account",
"res_accountdoctor",
......@@ -35,7 +37,13 @@ public int DeleteData(int allotId)
"res_baiscnorm",
"res_compute",
"res_specialunit",
"log_check",
"report_allot_crowd",
"report_allot_summary",
"report_original_income",
"report_original_persontime",
"report_original_stays",
"report_original_surgery",
"report_original_workload",
};
string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;");
......@@ -68,21 +76,22 @@ public int DeleteAllotData(int allotId)
"im_employee_logistics",
"im_header",
"im_specialunit",
"per_sheet",
"res_account",
"res_accountdoctor",
"res_accountnurse",
"res_baiscnorm",
"res_compute",
"res_specialunit",
"log_check",
"per_employee",
"per_sheet",
"report_allot_crowd",
"report_allot_summary",
"report_original_income",
"report_original_persontime",
"report_original_stays",
"report_original_surgery",
"report_original_workload",
"res_account",
"res_accountdoctor",
"res_accountnurse",
"res_baiscnorm",
"res_compute",
"res_specialunit",
};
string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;");
......@@ -95,13 +104,20 @@ public int DeleteResData(int allotId)
{
List<string> tableArray = new List<string>
{
"log_dbug",
"report_allot_crowd",
"report_allot_summary",
"report_original_income",
"report_original_persontime",
"report_original_stays",
"report_original_surgery",
"report_original_workload",
"res_account",
"res_accountdoctor",
"res_accountnurse",
"res_baiscnorm",
"res_compute",
"res_specialunit",
"log_dbug",
};
string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;");
......
//-----------------------------------------------------------------------
// <copyright file=" cof_cmi.cs">
// * FileName: cof_cmi.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
////-----------------------------------------------------------------------
//// <copyright file=" cof_cmi.cs">
//// * FileName: cof_cmi.cs
//// </copyright>
////-----------------------------------------------------------------------
//using System;
//using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// cof_cmi Repository
/// </summary>
public partial class PerforCofcmiRepository : PerforRepository<cof_cmi>
{
public PerforCofcmiRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//namespace Performance.Repository
//{
// /// <summary>
// /// cof_cmi Repository
// /// </summary>
// public partial class PerforCofcmiRepository : PerforRepository<cof_cmi>
// {
// public PerforCofcmiRepository(PerformanceDbContext context) : base(context)
// {
// }
// }
//}
//-----------------------------------------------------------------------
// <copyright file=" cof_drugprop.cs">
// * FileName: cof_drugprop.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
////-----------------------------------------------------------------------
//// <copyright file=" cof_drugprop.cs">
//// * FileName: cof_drugprop.cs
//// </copyright>
////-----------------------------------------------------------------------
//using System;
//using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// cof_drugprop Repository
/// </summary>
public partial class PerforCofdrugpropRepository : PerforRepository<cof_drugprop>
{
public PerforCofdrugpropRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//namespace Performance.Repository
//{
// /// <summary>
// /// cof_drugprop Repository
// /// </summary>
// public partial class PerforCofdrugpropRepository : PerforRepository<cof_drugprop>
// {
// public PerforCofdrugpropRepository(PerformanceDbContext context) : base(context)
// {
// }
// }
//}
......@@ -18,7 +18,6 @@ public class ProcessComputService : IAutoInjection
{
private readonly BudgetService _budgetService;
private PerforCofincomeRepository perforCofincomeRepository;
private PerforCofdrugpropRepository perforCofdrugpropRepository;
private PerforPersheetRepository perforPerSheetRepository;
private PerforImdataRepository perforImDataRepository;
private PerforImheaderRepository perforImHeaderRepository;
......@@ -27,7 +26,6 @@ public class ProcessComputService : IAutoInjection
private PerforResbaiscnormRepository perforResbaiscnormRepository;
private PerforCofdrugtypeRepository perforCofdrugtypeRepository;
private PerforCofworkitemRepository perforCofworkitemRepository;
private PerforCofcmiRepository perforCofcmiRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository;
private readonly LogManageService logManageService;
private readonly GuaranteeService guaranteeService;
......@@ -37,7 +35,6 @@ public class ProcessComputService : IAutoInjection
public ProcessComputService(
BudgetService budgetService,
PerforCofincomeRepository perforCofincomeRepository,
PerforCofdrugpropRepository perforCofdrugpropRepository,
PerforPersheetRepository perforPerSheetRepository,
PerforImdataRepository perforImDataRepository,
PerforImheaderRepository perforImHeaderRepository,
......@@ -46,7 +43,6 @@ public class ProcessComputService : IAutoInjection
PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforCofdrugtypeRepository perforCofdrugtypeRepository,
PerforCofworkitemRepository perforCofworkitemRepository,
PerforCofcmiRepository perforCofcmiRepository,
PerforRescomputeRepository perforRescomputeRepository,
LogManageService logManageService,
GuaranteeService guaranteeService,
......@@ -55,7 +51,6 @@ public class ProcessComputService : IAutoInjection
{
_budgetService = budgetService;
this.perforCofincomeRepository = perforCofincomeRepository;
this.perforCofdrugpropRepository = perforCofdrugpropRepository;
this.perforPerSheetRepository = perforPerSheetRepository;
this.perforImDataRepository = perforImDataRepository;
this.perforImHeaderRepository = perforImHeaderRepository;
......@@ -64,7 +59,6 @@ public class ProcessComputService : IAutoInjection
this.perforResbaiscnormRepository = perforResbaiscnormRepository;
this.perforCofdrugtypeRepository = perforCofdrugtypeRepository;
this.perforCofworkitemRepository = perforCofworkitemRepository;
this.perforCofcmiRepository = perforCofcmiRepository;
this.perforRescomputeRepository = perforRescomputeRepository;
this.logManageService = logManageService;
this.guaranteeService = guaranteeService;
......@@ -219,14 +213,17 @@ public void Save(List<PerSheet> perSheets, int allotId)
workload1.SheetName = "医生组工作量绩效测算表";
logManageService.WriteMsg("正在生成绩效", "获取药品费用分割比例", 1, allotid, "ReceiveMessage");
var confs = GetDrugConfig(excel, allotid);
var cmis = perforCofcmiRepository.GetEntities(t => t.AllotId == allotid);
var conitem = perforCofworkitemRepository.GetEntities(t => t.AllotID == allotid);
var medicineProps = GetFactors(excel, SheetType.WorkloadMedicineProp);
var cmis = GetFactors(excel, SheetType.WorkloadCMI);
var inclines = GetFactors(excel, SheetType.WorkloadIncline);
//医生组 一次计算
//var onceWorkload1 = workloadCompute.OnceCompute(workload1, confs);
//医生组 二次计算
logManageService.WriteMsg("正在生成绩效", "医生组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1, hospital, confs, cmis, conitem, true);
var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1, hospital, conitem, medicineProps, cmis, inclines, true);
twiceWorkloadResult1.Sheet.SheetType = SheetType.ComputeDoctorWorkload;
perSheet.Add(twiceWorkloadResult1.Sheet);
......@@ -237,7 +234,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
//var onceWorkload2 = workloadCompute.OnceCompute(workload2);
//护理组 二次计算
logManageService.WriteMsg("正在生成绩效", "护理组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2, hospital, confs, cmis, conitem);
var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2, hospital, conitem, medicineProps, cmis, inclines);
twiceWorkloadResult2.Sheet.SheetType = SheetType.ComputeNurseWorkload;
perSheet.Add(twiceWorkloadResult2.Sheet);
......@@ -305,7 +302,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
if (UnitType.医技组 == unitType && workDoctor == null)
workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit);
dept.MedicineFactor = workDoctor?.MedicineFactor;
//dept.MedicineFactor = workDoctor?.MedicineFactor;
//dept.ScoringAverage = scoreAverage.HasValue ? scoreAverage ?? 0 : dept.ScoringAverage;
dept.ScoringAverage = dept.ScoringAverage;
dept.AdjustFactor = (isBudget ? adjust : dept?.AdjustFactor) ?? 1;
......@@ -619,40 +616,59 @@ public IEnumerable<AccountUnitTotal> GetAccountScoreAverage(PerExcel excel, Shee
/// </summary>
/// <param name="excel"></param>
/// <returns></returns>
private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
private IEnumerable<CofDrugProp> GetFactors(PerExcel excel, SheetType sheetType)
{
//计算药占比
List<CofDrugProp> cofs = new List<CofDrugProp>();
var incomeSheet = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.Income && t.SheetName.Contains("门诊") && t.SheetName.Contains("开单"));
var datalist = incomeSheet.PerData.Select(t => (PerData)t);
var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allotid && t.ChargeType == "药费")?.Select(t => t.Charge).ToList();
var drugData = datalist.Where(t => drugtype.Contains(t.TypeName)).GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
if (drugtype == null)
var perDatas = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.WorkloadMedicineProp)?.PerData.Select(w => (PerData)w);
var factors = perDatas
?.Where(w => w.IsTotal == 1)
.Select(w => new CofDrugProp
{
drugData = null;
//throw new PerformanceException("未配置药占比类型");
AccountingUnit = w.AccountingUnit,
UnitType = w.UnitType,
Factor = w.CellValue ?? 1
});
return factors ?? new List<CofDrugProp>();
}
var allData = datalist.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
///// <summary>
///// 获取药占比分割比例
///// </summary>
///// <param name="excel"></param>
///// <returns></returns>
//private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
//{
// //计算药占比
// List<CofDrugProp> cofs = new List<CofDrugProp>();
var cofList = perforCofdrugpropRepository.GetEntities(t => t.AllotID == allotid);
if (cofList == null || !cofList.Any()) return cofs;
// var incomeSheet = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.Income && t.SheetName.Contains("门诊") && t.SheetName.Contains("开单"));
// var datalist = incomeSheet.PerData.Select(t => (PerData)t);
// var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allotid && t.ChargeType == "药费")?.Select(t => t.Charge).ToList();
var unitList = (drugData?.Select(t => t.AccountingUnit) ?? new List<string>()).Union(allData.Select(t => t.AccountingUnit));
// var drugData = datalist.Where(t => drugtype.Contains(t.TypeName)).GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
// if (drugtype == null)
// {
// drugData = null;
// //throw new PerformanceException("未配置药占比类型");
// }
foreach (var unit in unitList)
{
var dsv = drugData?.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue;
var asv = allData.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue;
// var allData = datalist.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
var prop = asv.HasValue && asv.Value > 0 ? Math.Round((dsv ?? 0) / asv.Value, 2) : 0;
var fvalue = cofList.FirstOrDefault(t => prop > t.MinRange && prop <= t.MaxRange)?.Value ?? 0;
cofs.Add(new CofDrugProp { AccoutingUnit = unit, Factor = fvalue, Prop = prop });
}
return cofs;
}
// 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));
// foreach (var unit in unitList)
// {
// var dsv = drugData?.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue;
// var asv = allData.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue;
// var prop = asv.HasValue && asv.Value > 0 ? Math.Round((dsv ?? 0) / asv.Value, 2) : 0;
// var fvalue = cofList.FirstOrDefault(t => prop > t.MinRange && prop <= t.MaxRange)?.Value ?? 0;
// cofs.Add(new CofDrugProp { AccoutingUnit = unit, Factor = fvalue, Prop = prop });
// }
// return cofs;
//}
#endregion compute
}
......
......@@ -9,6 +9,7 @@
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.AllotCompute;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.IO;
......@@ -32,6 +33,9 @@ public class AllotService : IAutoInjection
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private readonly IOptions<Application> options;
private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository;
private PerforPeragainallotRepository _againallotRepository;
private PerforLogcheckRepository perforLogcheckRepository;
private readonly PerforHospitalRepository perforHospitalRepository;
......@@ -59,6 +63,9 @@ public class AllotService : IAutoInjection
IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService,
IOptions<Application> options,
ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository,
PerforPeragainallotRepository againallotRepository,
PerforLogcheckRepository perforLogcheckRepository,
PerforHospitalRepository perforHospitalRepository,
......@@ -83,6 +90,9 @@ public class AllotService : IAutoInjection
this.resultComputeService = resultComputeService;
this.emailService = emailService;
this.options = options;
_computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository;
this.configService = configService;
this.logdbug = logdbug;
this.perforresreservedRepository = perforresreservedRepository;
......@@ -314,6 +324,8 @@ public void Generate(per_allot allot, string mail)
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID);
// 关闭筛选功能
ExtractHelper.CloseAutoFilter(allot.Path);
// 导出数据
excel = importDataService.ReadDataAndSave(allot);
......@@ -451,6 +463,45 @@ public void Generate(per_allot allot, string mail)
}
/// <summary>
/// 重新计算院领导绩效
/// </summary>
/// <param name="allotId"></param>
/// <param name="money"></param>
public void Recalculation(int allotId, decimal money)
{
var allot = _allotRepository.GetEntity(w => w.ID == allotId);
var empolyeeList = _perforImEmployeeRepository.GetEntities(t => t.AllotID == allotId && t.AccountType == AccountUnitType.行政高层.ToString());
if (empolyeeList == null) return;
var computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList);
computeEmployees.ForEach(w => w.FitPeopleValue = money);
List<res_baiscnorm> baiscnormList = new List<res_baiscnorm>();
var computResult = _computeDirector.Compute(computeEmployees, allot, baiscnormList);
if (computResult == null) return;
baiscnormList = baiscNormService.ComputeOtherAvg(baiscnormList, computResult, empolyeeList);
baiscnormList.ForEach(t => t.AllotID = allot.ID);
var historyRescompute = _perforRescomputeRepository.GetEntities(w => w.AllotID == allotId && w.AccountType == AccountUnitType.行政高层.ToString());
if (historyRescompute != null && historyRescompute.Any())
_perforRescomputeRepository.RemoveRange(historyRescompute.ToArray());
var computes = Mapper.Map<List<res_compute>>(computResult);
computes.ForEach(t => t.AllotID = allot.ID);
_perforRescomputeRepository.AddRange(computes.ToArray());
var names = baiscnormList.Select(b => b.PositionName).ToList();
var historyResbaiscnorm = perforResbaiscnormRepository.GetEntities(w => w.AllotID == allotId && names.Contains(w.PositionName));
if (historyResbaiscnorm != null && historyResbaiscnorm.Any())
perforResbaiscnormRepository.RemoveRange(historyResbaiscnorm.ToArray());
perforResbaiscnormRepository.AddRange(Mapper.Map<res_baiscnorm[]>(baiscnormList));
}
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="allot"></param>
......
......@@ -78,8 +78,13 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI
if (amounts != null && perbudgetamountRepository.AddRange(amounts.ToArray()))
{
var ratios = Mapper.Map<List<per_budget_ratio>>(request.Where(t => t.Type == 2));
var budgetData = request.FirstOrDefault(t => t.Type == 2);
ratios.ForEach(t =>
{
t.HospitalRevenue = budgetData?.HospitalRevenue;
t.MeritPayIncrement = budgetData?.MeritPayIncrement;
t.TheDrugIncomeBudget = budgetData?.TheDrugIncomeBudget;
t.MaterialIncomeBudget = budgetData?.MaterialIncomeBudget;
t.MainYear = mainYear;
t.CreateTime = DateTime.Now;
t.CreateUser = userId;
......@@ -136,19 +141,20 @@ public bool ModifyBudgetData(List<BudgetResponse> request)
foreach (var item in ratios)
{
var data = request.FirstOrDefault(t => t.Type == 2 && t.Id == item.Id);
var budgetData = request.FirstOrDefault(t => t.Type == 2);
if (data == null) continue;
item.HospitalRevenue = data.HospitalRevenue;
item.HospitalRevenue = data.HospitalRevenue == 0 ? budgetData?.HospitalRevenue:data.HospitalRevenue;
item.TotalLaborCost = data.TotalLaborCost;
item.StaffSpendingFixed = data.StaffSpendingFixed;
item.StaffSpendingBonus = data.StaffSpendingBonus;
item.MeritPayIncrement = data.MeritPayIncrement;
item.MeritPayIncrement = data.MeritPayIncrement==0?budgetData?.MeritPayIncrement:data.MeritPayIncrement;
item.TotalMeritPay = data.TotalMeritPay;
item.Amplification = data.Amplification;
item.IncrementCapitaRatio = data.IncrementCapitaRatio;
item.TheDrugIncome = data.TheDrugIncome;
item.TheDrugIncomeBudget = data.TheDrugIncomeBudget;
item.TheDrugIncomeBudget = data.TheDrugIncomeBudget==0?budgetData?.TheDrugIncomeBudget:data.TheDrugIncomeBudget;
item.MaterialIncome = data.MaterialIncome;
item.MaterialIncomeBudget = data.MaterialIncomeBudget;
item.MaterialIncomeBudget = data.MaterialIncomeBudget==0?budgetData?.MaterialIncomeBudget:data.MaterialIncomeBudget;
item.TheCostInTotal = data.TheCostInTotal;
item.DepreOfFixedAssets = data.DepreOfFixedAssets;
item.AmortOfIntangibleAssets = data.AmortOfIntangibleAssets;
......
......@@ -7,9 +7,12 @@
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Google.Protobuf.WellKnownTypes;
using HandsonRowData = Performance.DtoModels.HandsonRowData;
namespace Performance.Services
{
......@@ -26,6 +29,8 @@ public class CollectService : IAutoInjection
private readonly PerforCollectdataRepository perforcollectdataRepository;
private readonly PerforCollectpermissionRepository perforcollectpermissionRepository;
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforImaccountbasicRepository perforImaccountbasicRepository;
private readonly SheetSevice sheetSevice;
private readonly Application options;
public CollectService(
......@@ -40,6 +45,8 @@ public class CollectService : IAutoInjection
PerforCollectdataRepository perforcollectdataRepository,
PerforCollectpermissionRepository perforcollectpermissionRepository,
PerforUserroleRepository userroleRepository,
PerforImaccountbasicRepository perforImaccountbasicRepository,
SheetSevice sheetSevice,
IOptions<Application> options)
{
this.userRepository = userRepository;
......@@ -53,6 +60,8 @@ public class CollectService : IAutoInjection
this.perforcollectdataRepository = perforcollectdataRepository;
this.perforcollectpermissionRepository = perforcollectpermissionRepository;
this.userroleRepository = userroleRepository;
this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.sheetSevice = sheetSevice;
this.options = options.Value;
}
......@@ -220,7 +229,7 @@ private IEnumerable<collect_permission> GetCollectSheetByAllot(int hospitalId, i
var types = new[] { (int)SheetType.Employee, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload,
(int)SheetType.ClinicEmployee, (int)SheetType.AccountExtra, (int)SheetType.PersonExtra, (int)SheetType.LogisticsEmployee,
(int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess, (int)SheetType.AccountScoreAverage,
(int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee };
(int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee,(int)SheetType.AccountBasic };
var sheets = perforPersheetRepository.GetEntities(w => w.AllotID == allot.ID && types.Contains((w.SheetType ?? 0)));
var headers = perforImheaderRepository.GetEntities(w => w.AllotID == allot.ID);
......@@ -296,7 +305,7 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName)
var types = new[] { (int)SheetType.Employee, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload,
(int)SheetType.ClinicEmployee, (int)SheetType.AccountExtra, (int)SheetType.PersonExtra, (int)SheetType.LogisticsEmployee,
(int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess, (int)SheetType.AccountScoreAverage,
(int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee };
(int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee,(int)SheetType.AccountBasic};
var sheet = perforPersheetRepository
.GetEntity(w => w.AllotID == allot.ID && w.SheetName == sheetName && types.Contains((w.SheetType ?? 0)));
......@@ -325,6 +334,8 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName)
config = CollectDataConfig.LogisticsEmployee;
else if (sheet.SheetType == (int)SheetType.PersonExtra)
config = CollectDataConfig.PersonExtra;
else if (sheet.SheetType == (int)SheetType.AccountBasic)
config = CollectDataConfig.AccountBasic;
else
config = CollectDataConfig.Default;
......@@ -354,6 +365,8 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName)
rowDatas = GetClinicEmployee(sheet);
else if (sheet.SheetType == (int)SheetType.LogisticsEmployee)
rowDatas = GetLogisticsEmployee(sheet);
else if (sheet.SheetType == (int)SheetType.AccountBasic)
rowDatas = GetAccountBasic(sheet);
else
rowDatas = GetCommonData(sheet);
}
......@@ -384,12 +397,21 @@ private List<HandsonRowData> GetCommonData(per_sheet sheet)
var units = rowdata.Where(w => w.UnitType.HasValue).Select(w => new { w.UnitType, w.AccountingUnit }).Distinct();
foreach (var item in units)
{
if ((new[] { (int)UnitType.医生组, (int)UnitType.其他医生组 }).Contains(item.UnitType.Value))
if ((new[] {(int) UnitType.医生组, (int) UnitType.其他医生组}).Contains(item.UnitType.Value))
{
setdata.Add(new HandsonCellData("核算单元(医生组)", item.AccountingUnit));
else if ((new[] { (int)UnitType.医技组, (int)UnitType.其他医技组 }).Contains(item.UnitType.Value))
GetUnitClassification(setdata,UnitType.医生组,sheet);
}
else if ((new[] {(int) UnitType.医技组, (int) UnitType.其他医技组}).Contains(item.UnitType.Value))
{
setdata.Add(new HandsonCellData("核算单元(医技组)", item.AccountingUnit));
else if ((new[] { (int)UnitType.护理组, (int)UnitType.其他护理组 }).Contains(item.UnitType.Value))
GetUnitClassification(setdata,UnitType.医技组,sheet);
}
else if ((new[] {(int) UnitType.护理组, (int) UnitType.其他护理组}).Contains(item.UnitType.Value))
{
setdata.Add(new HandsonCellData("核算单元(护理组)", item.AccountingUnit));
GetUnitClassification(setdata,UnitType.护理组,sheet);
}
setdata.Add(new HandsonCellData("核算单元", item.AccountingUnit));
}
if (sheet.SheetType == (int)SheetType.PersonExtra)
......@@ -443,7 +465,64 @@ private HandsonRowData CreateRowData(int row, ColumnInfo[] columns, SortedDictio
var setdata = from cfg in columns
join d in dic.Keys on cfg.Field.ToUpper() equals d.ToUpper()
select new HandsonCellData(cfg.Description, dic[d]);
return new HandsonRowData(row, setdata);
var xx = new HandsonRowData(row, setdata);
return xx;
}
private List<HandsonRowData> GetAccountBasic(per_sheet sheet)
{
//var accounts = sheetSevice.SheetExport(sheet.ID);
var result = new List<HandsonRowData>();
var groupAccount = perforImdataRepository.GetEntities(t => t.SheetID == sheet.ID); //.OrderBy(c=>c.RowNumber).GroupBy(c => c.RowNumber);
if (groupAccount != null && groupAccount.Any())
{
foreach (var rowNumber in groupAccount.Select(t=>t.RowNumber).Distinct())
{
var numberData = groupAccount.Where(t => t.RowNumber == rowNumber);
var accountUnit = new HandsonCellData("核算单元",numberData.First().AccountingUnit);
var data = numberData?.Select(t => new HandsonCellData(t.TypeName, t.CellValue)).ToList();
data.Add(accountUnit);
switch (numberData.First().UnitType)
{
case (int)UnitType.医技组:
var unitType = new HandsonCellData("核算单元类型", UnitType.医技组);
data.Add(unitType);
break;
case (int)UnitType.医生组:
unitType = new HandsonCellData("核算单元类型", UnitType.医生组);
data.Add(unitType);
break;
case (int)UnitType.护理组:
unitType = new HandsonCellData("核算单元类型", UnitType.护理组);
data.Add(unitType);
break;
case (int)UnitType.特殊核算组:
unitType = new HandsonCellData("核算单元类型", UnitType.特殊核算组);
data.Add(unitType);
break;
}
var rowData = new HandsonRowData(rowNumber.Value,data);
result.Add(rowData);
}
//var temps = accounts.Row.Select(item => new { row = item.Rownumber, dic = JsonHelper.Deserialize(item) });
//return new List<HandsonRowData>(temps.Select(temp => CreateRowData(temp.row, ExcelReadConfig.AccountBaisc, temp.dic)));
}
return result;
}
private void GetUnitClassification(List<HandsonCellData> setdata,UnitType unitType,per_sheet sheet)
{
if (sheet.SheetType == (int)SheetType.AccountExtra)
setdata.Add(new HandsonCellData("核算组别", unitType));
else if (sheet.SheetType == (int)SheetType.PersonExtra)
setdata.Add(new HandsonCellData("核算单元分类", unitType));
else if (sheet.SheetType == (int)SheetType.BudgetRatio)
setdata.Add(new HandsonCellData("核算单元类型", unitType));
}
#endregion 加载采集内容
......@@ -579,6 +658,15 @@ public class CollectDataConfig
{ nameof(collect_data.EmployeeName), "医生姓名" },
};
public static Dictionary<string, string> AccountBasic { get; } = new Dictionary<string, string>
{
{ nameof(collect_data.UnitType), "核算单元分类" },
{ nameof(collect_data.AccountingUnitDoctor), "核算单元" },
{ nameof(collect_data.Department), "核算单元" },
{ nameof(collect_data.JobNumber), "人员工号" },
{ nameof(collect_data.EmployeeName), "医生姓名" },
};
public static Dictionary<string, string> Default { get; } = new Dictionary<string, string>
{
{ nameof(collect_data.UnitType), "核算单元分类" },
......
using AutoMapper;
using NPOI.SS.Formula.Functions;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -7,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services
......@@ -28,7 +26,6 @@ public class ComputeService : IAutoInjection
private readonly PerforPerallotRepository perforPerallotRepository;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerapramountRepository perapramountRepository;
private readonly PerforCofcmiRepository cofcmiRepository;
private readonly PerforPeremployeeRepository perforPeremployeeRepository;
private readonly PerforCofworkitemRepository cofworkitemRepository;
......@@ -46,7 +43,6 @@ public class ComputeService : IAutoInjection
PerforPerallotRepository perforPerallotRepository,
PerforHospitalRepository hospitalRepository,
PerforPerapramountRepository perapramountRepository,
PerforCofcmiRepository cofcmiRepository,
PerforPeremployeeRepository perforPeremployeeRepository,
PerforCofworkitemRepository cofworkitemRepository)
{
......@@ -64,7 +60,6 @@ public class ComputeService : IAutoInjection
this.perforPerallotRepository = perforPerallotRepository;
this.hospitalRepository = hospitalRepository;
this.perapramountRepository = perapramountRepository;
this.cofcmiRepository = cofcmiRepository;
this.perforPeremployeeRepository = perforPeremployeeRepository;
this.cofworkitemRepository = cofworkitemRepository;
}
......@@ -763,7 +758,7 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
{
(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, (int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee
(int)SheetType.AccountAdjustLaterOtherFee, (int)SheetType.BudgetRatio, (int)SheetType.AssessBeforeOtherFee,
};
int groupbasis = 1; string single = "";
......@@ -791,15 +786,20 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
continue;
var workitems = cofworkitemRepository.GetEntities(t => t.AllotID == account.AllotID);
var allotCmi = cofcmiRepository.GetEntity(t => t.AllotId == account.AllotID && t.UnitType == account.UnitType && t.AccountingUnit == account.AccountingUnit);
//var allotCmi = cofcmiRepository.GetEntity(t => t.AllotId == account.AllotID && t.UnitType == account.UnitType && t.AccountingUnit == account.AccountingUnit);
var medicineFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadMedicineProp);
var cmiFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadCMI);
var inclineFactor = GetFactors(persheet, basicData, type, SheetType.WorkloadIncline);
foreach (var dto in items)
{
if (workitems != null && workitems.Any(a => a.Type == 1 && a.Item == dto.ItemName))
dto.MediFactor = account.MedicineFactor;
if (workitems != null && workitems.Any(a => a.Type == 2 && a.Item == dto.ItemName) && allotCmi != null)
dto.CMIFactor = allotCmi.Value;
dto.ItemValue = dto.ItemValue * (dto.MediFactor ?? 1) * (dto.CMIFactor ?? 1);
if (workitems != null && workitems.Any(a => a.Type == 1 && a.Item == dto.ItemName) && medicineFactor != null)
dto.MediFactor = medicineFactor;
if (workitems != null && workitems.Any(a => a.Type == 2 && a.Item == dto.ItemName) && cmiFactor != null)
dto.CMIFactor = cmiFactor;
if (workitems != null && workitems.Any(a => a.Type == 3 && a.Item == dto.ItemName) && inclineFactor != null)
dto.InclineFactor = inclineFactor;
dto.ItemValue = dto.ItemValue * (dto.MediFactor ?? 1) * (dto.CMIFactor ?? 1) * (dto.InclineFactor ?? 1);
}
}
......@@ -818,6 +818,14 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
//return deptDetails;
}
private decimal? GetFactors(List<per_sheet> persheet, List<im_data> basicData, UnitType type, SheetType sheetType)
{
var sheet = persheet.FirstOrDefault(w => w.SheetType == (int)sheetType);
if (sheet == null)
return null;
return basicData.FirstOrDefault(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal == 1)?.CellValue;
}
private (int sheettype, decimal amount) ClinicDepartmentDetail(List<per_sheet> persheet, res_account account, List<im_data> basicData, per_sheet sheet, UnitType type, string sheetName)
{
var sheettype = 1;
......@@ -879,7 +887,7 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
SheetType[] pairs = new SheetType[]
{
SheetType.AccountExtra, SheetType.AccountDrugAssess, SheetType.AccountMaterialsAssess, SheetType.AccountScoreAverage, SheetType.AccountAdjustLaterOtherFee,
SheetType.AssessBeforeOtherFee, SheetType.BudgetRatio
SheetType.AssessBeforeOtherFee, SheetType.BudgetRatio,
};
if (pairs.Contains((SheetType)sheet.SheetType))
{
......@@ -993,6 +1001,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details
Factor = t.Factor,
MediFactor = t.MediFactor,
CMIFactor = t.CMIFactor,
InclineFactor = t.InclineFactor,
}).ToList();
}
}
......
......@@ -16,7 +16,7 @@ public class ConfigService : IAutoInjection
{
#region
private PerforCofdirectorRepository _directorRepository;
private PerforCofdrugpropRepository _drugpropRepository;
//private PerforCofdrugpropRepository _drugpropRepository;
private PerforCofworkitemRepository _workitemRepository;
private PerforCofagainRepository _againRepository;
private PerforCofdrugtypeRepository _drugtypeRepository;
......@@ -26,13 +26,13 @@ public class ConfigService : IAutoInjection
private PerforImheaderRepository perforImheaderRepository;
private PerforCofdepttypeRepository perforCofdepttypeRepository;
private PerforPerapramountRepository perapramountRepository;
private PerforCofcmiRepository perforCofcmiRepository;
//private PerforCofcmiRepository perforCofcmiRepository;
private PersonService personService;
private LogManageService logManageService;
private ILogger<ConfigService> logger;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
PerforCofdrugpropRepository cofdrugpropRepository,
//PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofagainRepository againRepository,
PerforCofdrugtypeRepository drugtypeRepository,
PerforPerallotRepository perforPerAllotRepository,
......@@ -42,13 +42,13 @@ public class ConfigService : IAutoInjection
PerforImheaderRepository perforImheaderRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforPerapramountRepository perapramountRepository,
PerforCofcmiRepository perforCofcmiRepository,
//PerforCofcmiRepository perforCofcmiRepository,
PersonService personService,
LogManageService logManageService,
ILogger<ConfigService> logger)
{
this._directorRepository = cofdirectorRepository;
this._drugpropRepository = cofdrugpropRepository;
//this._drugpropRepository = cofdrugpropRepository;
this._workitemRepository = workitemRepository;
this._againRepository = againRepository;
this._drugtypeRepository = drugtypeRepository;
......@@ -58,7 +58,7 @@ public class ConfigService : IAutoInjection
this.perforImheaderRepository = perforImheaderRepository;
this.perforCofdepttypeRepository = perforCofdepttypeRepository;
this.perapramountRepository = perapramountRepository;
this.perforCofcmiRepository = perforCofcmiRepository;
//this.perforCofcmiRepository = perforCofcmiRepository;
this.personService = personService;
this.logManageService = logManageService;
this.logger = logger;
......@@ -249,62 +249,62 @@ public class ConfigService : IAutoInjection
#region cof_drugprop 药占比系数配置
/// <summary>
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<DrugpropResponse> GetDrugList(int allotId)
{
var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
return Mapper.Map<List<DrugpropResponse>>(list);
}
///// <summary>
///// 获取cof_drugprop列表
///// </summary>
///// <returns></returns>
//public List<DrugpropResponse> GetDrugList(int allotId)
//{
// var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
// return Mapper.Map<List<DrugpropResponse>>(list);
//}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DrugpropResponse DrugInsert(DrugpropRequest request)
{
var drugprop = Mapper.Map<cof_drugprop>(request);
if (!_drugpropRepository.Add(drugprop))
throw new PerformanceException("保存失败");
return Mapper.Map<DrugpropResponse>(drugprop);
}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugInsert(DrugpropRequest request)
//{
// var drugprop = Mapper.Map<cof_drugprop>(request);
// if (!_drugpropRepository.Add(drugprop))
// throw new PerformanceException("保存失败");
// return Mapper.Map<DrugpropResponse>(drugprop);
//}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DrugpropResponse DrugUpdate(DrugpropRequest request)
{
var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
if (null == drugprop)
throw new PerformanceException($"ID不存在 :{request.ID}");
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugUpdate(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
drugprop.MaxRange = request.MaxRange;
drugprop.MinRange = request.MinRange;
drugprop.Value = request.Value;
// drugprop.MaxRange = request.MaxRange;
// drugprop.MinRange = request.MinRange;
// drugprop.Value = request.Value;
if (!_drugpropRepository.Update(drugprop))
throw new PerformanceException("保存失败");
return Mapper.Map<DrugpropResponse>(drugprop);
}
// if (!_drugpropRepository.Update(drugprop))
// throw new PerformanceException("保存失败");
// return Mapper.Map<DrugpropResponse>(drugprop);
//}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool DrugDelete(DrugpropRequest request)
{
var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
if (null == drugprop)
throw new PerformanceException($"ID不存在 :{request.ID}");
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool DrugDelete(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
return _drugpropRepository.Remove(drugprop);
}
// return _drugpropRepository.Remove(drugprop);
//}
#endregion
......@@ -381,7 +381,10 @@ public bool DrugtypeDelete(DrugpropRequest request)
/// <returns></returns>
public List<cof_workitem> GetWorkItems(int allotId, int type)
{
var list = _workitemRepository.GetEntities(t => t.AllotID == allotId && t.Type == type);
var list = (type > 0)
? _workitemRepository.GetEntities(t => t.AllotID == allotId && t.Type == type)
: _workitemRepository.GetEntities(t => t.AllotID == allotId);
return Mapper.Map<List<cof_workitem>>(list);
}
......@@ -410,6 +413,7 @@ public cof_workitem WorkItemUpdate(WorkItemRequest request)
throw new PerformanceException($"ID不存在 :{request.ID}");
workyear.Item = request.Item;
workyear.Type = request.Type;
if (!_workitemRepository.Update(workyear))
throw new PerformanceException("保存失败");
......@@ -499,61 +503,61 @@ public bool DepttypeDelete(DrugpropRequest request)
#region cof_cmi cmi
/// <summary>
/// 获取 CMI配置
/// </summary>
/// <returns></returns>
public List<cof_cmi> GetCMIList(int allotId)
{
var list = perforCofcmiRepository.GetEntities(t => t.AllotId == allotId);
return list;
}
///// <summary>
///// 获取 CMI配置
///// </summary>
///// <returns></returns>
//public List<cof_cmi> GetCMIList(int allotId)
//{
// var list = perforCofcmiRepository.GetEntities(t => t.AllotId == allotId);
// return list;
//}
/// <summary>
/// 添加 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_cmi HosCMIInsert(cof_cmi request)
{
if (!perforCofcmiRepository.Add(request))
throw new PerformanceException("保存失败");
return request;
}
///// <summary>
///// 添加 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public cof_cmi HosCMIInsert(cof_cmi request)
//{
// if (!perforCofcmiRepository.Add(request))
// throw new PerformanceException("保存失败");
// return request;
//}
/// <summary>
/// 更新 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_cmi HosCMIUpdate(cof_cmi request)
{
var entity = perforCofcmiRepository.GetEntity(t => t.Id == request.Id);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.Id}");
///// <summary>
///// 更新 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public cof_cmi HosCMIUpdate(cof_cmi request)
//{
// var entity = perforCofcmiRepository.GetEntity(t => t.Id == request.Id);
// if (null == entity)
// throw new PerformanceException($"ID不存在 :{request.Id}");
entity.UnitType = request.UnitType;
entity.AccountingUnit = request.AccountingUnit;
entity.Value = request.Value;
// entity.UnitType = request.UnitType;
// entity.AccountingUnit = request.AccountingUnit;
// entity.Value = request.Value;
if (!perforCofcmiRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
// if (!perforCofcmiRepository.Update(entity))
// throw new PerformanceException("保存失败");
// return entity;
//}
/// <summary>
/// 删除 CMI配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool HosCMIDelete(cof_cmi request)
{
var entity = perforCofcmiRepository.GetEntity(t => t.Id == request.Id);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.Id}");
///// <summary>
///// 删除 CMI配置
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool HosCMIDelete(cof_cmi request)
//{
// var entity = perforCofcmiRepository.GetEntity(t => t.Id == request.Id);
// if (null == entity)
// throw new PerformanceException($"ID不存在 :{request.Id}");
return perforCofcmiRepository.Remove(entity);
}
// return perforCofcmiRepository.Remove(entity);
//}
#endregion
......@@ -642,7 +646,7 @@ public void Copy(per_allot allot)
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
CopyCMIData(allotId, allot.ID);
//CopyCMIData(allotId, allot.ID);
#region 弃用
......@@ -678,17 +682,17 @@ public void Copy(per_allot allot)
#endregion
logger.LogInformation($"orgDurgprop");
var orgDurgprop = _drugpropRepository.GetEntities(t => t.AllotID == allot.ID);
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 } };
if (durgprop != null && durgprop.Any())
_drugpropRepository.AddRange(newDurgprops.ToArray());
}
//logger.LogInformation($"orgDurgprop");
//var orgDurgprop = _drugpropRepository.GetEntities(t => t.AllotID == allot.ID);
//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 } };
// if (durgprop != null && durgprop.Any())
// _drugpropRepository.AddRange(newDurgprops.ToArray());
//}
logger.LogInformation($"workItem");
var workItem = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
......@@ -697,7 +701,7 @@ public void Copy(per_allot allot)
workItem = _workitemRepository.GetEntities(t => t.AllotID == allotId);
if (workItem != null && workItem.Count > 0)
{
var newWorkItem = workItem.Select(t => new cof_workitem { AllotID = allot.ID, Item = t.Item });
var newWorkItem = workItem.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItem.ToArray());
}
}
......@@ -830,35 +834,35 @@ private void CopyAprData(int prevAllotId, int allotId)
}
}
/// <summary>
/// CMI值
/// </summary>
/// <param name="prevAllotId"></param>
/// <param name="allotId"></param>
private void CopyCMIData(int prevAllotId, int allotId)
{
if (prevAllotId == 0) return;
var list = perforCofcmiRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
if (list.Any(t => t.AllotId == allotId))
{
var prevData = list.Where(t => t.AllotId == prevAllotId);
var existData = list.Where(t => t.AllotId == allotId);
if (existData != null && existData.Any())
list = prevData.Where(t => !existData.Select(w => w.UnitType + w.AccountingUnit).Contains(t.UnitType + t.AccountingUnit)).ToList();
}
if (list.Any())
{
var data = list.Select(t => new cof_cmi
{
AllotId = allotId,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Value = t.Value,
});
perforCofcmiRepository.AddRange(data.ToArray());
}
}
///// <summary>
///// CMI值
///// </summary>
///// <param name="prevAllotId"></param>
///// <param name="allotId"></param>
//private void CopyCMIData(int prevAllotId, int allotId)
//{
// if (prevAllotId == 0) return;
// var list = perforCofcmiRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
// if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
// if (list.Any(t => t.AllotId == allotId))
// {
// var prevData = list.Where(t => t.AllotId == prevAllotId);
// var existData = list.Where(t => t.AllotId == allotId);
// if (existData != null && existData.Any())
// list = prevData.Where(t => !existData.Select(w => w.UnitType + w.AccountingUnit).Contains(t.UnitType + t.AccountingUnit)).ToList();
// }
// if (list.Any())
// {
// var data = list.Select(t => new cof_cmi
// {
// AllotId = allotId,
// UnitType = t.UnitType,
// AccountingUnit = t.AccountingUnit,
// Value = t.Value,
// });
// perforCofcmiRepository.AddRange(data.ToArray());
// }
//}
}
}
......@@ -107,7 +107,7 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId,
SupplyHeaderByWorkItem(hospitalId, result, secondAllot, savedDataList);
result.HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.WorkType).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList();
result.BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList();
result.BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ToList();
return result;
}
......@@ -565,7 +565,58 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
#region 其他模板详情
public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int isArchive, int employeeSource)
public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, OtherTemp.Select(t => t.Value).ToArray(), OtherTemp.Select(t => new collect_permission
{
HeadName = t.Value,
Visible = 1,
Readnoly = new string[] { "可分配绩效", "医院其他绩效", "预留比例", "预留金额", "实发绩效工资金额" }.Contains(t.Value) ? 1 : 0
}).ToList());
string[] workNumbers = new string[] { };
var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource, ref workNumbers);
if (result.Columns != null && result.Columns.Any())
{
foreach (var column in result.Columns)
{
if (column.Data == "工号")
{
column.Type = "autocomplete";
column.Source = workNumbers;
column.Strict = true;
}
}
}
realAmount = details?.Sum(t => t.RealAmount);
if (details == null || !details.Any()) return result;
details.ForEach(t =>
{
if (!t.OtherPerformance.HasValue) t.OtherPerformance = 0;
});
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 1;
foreach (var item in details)
{
var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in OtherTemp
join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper()
select new HandsonCellData(conf.Value, fst.Value)).ToList();
cells.Add(new HandsonCellData(nameof(ag_othersource.Id), item.Id));
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
return result;
}
public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int isArchive, int employeeSource, ref string[] workNumbers)
{
var secondAllot = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (secondAllot == null) throw new PerformanceException("二次绩效信息无效!");
......@@ -598,14 +649,15 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
// 如果已经保存>>走保存加载逻辑
if (employeeSource == (int)EmployeeSource.Initial)
{
result = savedDataList.OrderBy(t => t.Id).ToList();
result = savedDataList.OrderBy(t => t.WorkNumber).ToList();
}
// 如果没保存>>走加载im_employee_logistics人员名单逻辑
else
{
var types = new string[] { "行政后勤", "行政工勤" };
var logistics = _imemployeelogisticsRepository.GetEntities(w => w.AllotID == secondAllot.AllotId && types.Contains(w.AccountType) && w.AccountingUnit == secondAllot.Department);
result = (logistics ?? new List<im_employee_logistics>()).Select(w => new ag_othersource
result = (logistics ?? new List<im_employee_logistics>())
.OrderBy(t => Convert.ToInt32(t.PersonnelNumber)).Select(w => new ag_othersource
{
SecondId = secondId,
WorkNumber = w.PersonnelNumber,
......@@ -621,12 +673,12 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
switch (employeeSource)
{
case (int)EmployeeSource.Initial:
result = savedDataList.OrderBy(t => t.Id).ToList();
result = savedDataList.OrderBy(t => t.WorkNumber).ToList();
break;
case (int)EmployeeSource.EmployeeDict:
if (employees == null || !employees.Any()) return new List<ag_othersource>();
result = employees.Select(t => new ag_othersource
result = employees.OrderBy(t => t.PersonnelNumber).Select(t => new ag_othersource
{
SecondId = secondId,
WorkNumber = t.PersonnelNumber,
......@@ -641,7 +693,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
isSupplementTitlePerformance = prevSavedDataList == null || !prevSavedDataList.Any();
if (prevSavedDataList != null && prevSavedDataList.Any())
{
result = prevSavedDataList.OrderBy(t => t.Id)
result = prevSavedDataList.OrderBy(t => t.WorkNumber)
.Select(t => new ag_othersource
{
SecondId = secondId,
......@@ -655,6 +707,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
}
}
var originalEmployees = personService.GetPerEmployee(secondAllot.AllotId.Value);
workNumbers = originalEmployees?.Select(t => t.PersonnelNumber).Distinct().ToArray();
SupplementSecondDetail(secondAllot, originalEmployees, result, isSupplementTitlePerformance);
return result;
......@@ -700,8 +753,27 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
}
}
public static Dictionary<string, string> OtherTemp { get; } = new Dictionary<string, string>
{
{ nameof(ag_othersource.WorkNumber), "工号" },
{ nameof(ag_othersource.Name), "姓名" },
{ nameof(ag_othersource.Department), "科室" },
{ nameof(ag_othersource.WorkPost), "职称" },
{ nameof(ag_othersource.TitlePerformance), "职称绩效" },
{ nameof(ag_othersource.WorkPerformance), "工作量绩效工资" },
{ nameof(ag_othersource.DeptReward), "科室单项奖励" },
{ nameof(ag_othersource.DistPerformance), "可分配绩效" },
{ nameof(ag_othersource.OtherPerformance), "医院其他绩效" },
{ nameof(ag_othersource.NightWorkPerformance), "夜班工作量绩效" },
{ nameof(ag_othersource.ReservedRatio), "预留比例" },
{ nameof(ag_othersource.ReservedAmount), "预留金额" },
{ nameof(ag_othersource.RealAmount), "实发绩效工资金额" },
};
#endregion 其他模板详情
#region Common
/// <summary>
/// 获取上一次的二次绩效
/// </summary>
......@@ -724,6 +796,8 @@ private ag_secondallot GetPreviousSecondAllot(int hospitalId, ag_secondallot sec
var prevSecondAllot = agsecondallotRepository.GetEntity(w => w.AllotId == prevAllot.ID && w.UnitType == secondAllot.UnitType && w.Department == secondAllot.Department);
return prevSecondAllot;
}
#endregion Common
}
/// <summary>
......
......@@ -516,17 +516,15 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var sheet = workbook.GetSheetAt(0);
var firstRow = sheet.GetRow(0);
List<(string, int)> excelheader = new List<(string, int)>();
Dictionary<int, string> excelheader = new Dictionary<int, string>();
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));
var value = firstRow.GetCell(cellindex).GetValue();
if (!string.IsNullOrEmpty(value) && !excelheader.ContainsKey(cellindex))
excelheader.Add(cellindex, value);
}
if (excelheader == null || !excelheader.Any())
if (excelheader == null || excelheader.Count == 0)
throw new PerformanceException("上传excel内容错误");
Dictionary<string, int> dict = new Dictionary<string, int>
......@@ -534,16 +532,12 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
{ "录入科室", -1 },{ "核算单元", -1 },{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -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 (excelheader.Any(w => w.Value == key))
dict[key] = excelheader.First(w => w.Value == key).Key;
}
if (errorHeaders != null && errorHeaders.Any())
throw new PerformanceException($"excel缺少列{string.Join(", ", errorHeaders)}");
var entities = new List<per_apr_amount>();
var createtime = DateTime.Now;
......@@ -555,20 +549,41 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entity = new per_apr_amount
{
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(),
PersonnelNumber = dict["人员工号"] < 0 ? "" : row.GetCell(dict["人员工号"]).GetValue(),
DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(),
PerforType = dict["绩效类型"] < 0 ? "" : row.GetCell(dict["绩效类型"]).GetValue(),
Amount = dict["金额"] < 0 ? 0 : ConvertHelper.To<decimal>(row.GetCell(dict["金额"]).GetValue(), 0),
TypeInDepartment = dict["录入科室"] < 0 ? "" : row.GetCell(dict["录入科室"]).GetValue(),
AccountingUnit = dict["核算单元"] < 0 ? "" : row.GetCell(dict["核算单元"]).GetValue(),
AllotId = allotid,
CreateDate = createtime,
CreateUser = userid,
};
entities.Add(entity);
}
// 补充核算单元
if (entities.Any())
{
if (entities.Any(w => string.IsNullOrEmpty(w.PersonnelNumber) && w.Amount != 0))
throw new PerformanceException("文件中存在“工号”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0))
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
throw new PerformanceException("文件中存在“录入科室”为空的数据");
var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid);
foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && !string.IsNullOrEmpty(w.AccountingUnit)))
{
item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.PersonnelNumber)?.AccountingUnit ?? "";
}
perapramountRepository.AddRange(entities.ToArray());
}
}
catch (PerformanceException ex)
{
throw ex;
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
......
......@@ -4,6 +4,7 @@
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -22,9 +23,13 @@ public class ExConfigService : IAutoInjection
private readonly PerforExitemRepository exitemRepository;
private readonly PerforExspecialRepository exspecialRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforPersheetRepository persheetRepository;
private readonly PerforImdataRepository imdataRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforExtractRepository extractRepository;
private readonly PerforModdicRepository moddicRepository;
private readonly QueryService queryService;
private readonly ILogger logger;
public ExConfigService(PerforExtypeRepository extypeRepository,
......@@ -33,10 +38,15 @@ public class ExConfigService : IAutoInjection
PerforExitemRepository exitemRepository,
PerforExspecialRepository exspecialRepository,
PerforPerallotRepository perallotRepository,
PerforPersheetRepository persheetRepository,
PerforImdataRepository imdataRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforHospitalRepository hospitalRepository,
PerforExtractRepository extractRepository,
PerforModdicRepository moddicRepository,
ILogger<ExConfigService> logger)
QueryService queryService,
ILogger<ExConfigService> logger
)
{
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
......@@ -44,9 +54,13 @@ public class ExConfigService : IAutoInjection
this.exitemRepository = exitemRepository;
this.exspecialRepository = exspecialRepository;
this.perallotRepository = perallotRepository;
this.persheetRepository = persheetRepository;
this.imdataRepository = imdataRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.hospitalRepository = hospitalRepository;
this.extractRepository = extractRepository;
this.moddicRepository = moddicRepository;
this.queryService = queryService;
this.logger = logger;
}
......@@ -328,7 +342,7 @@ public void DelSpecial(int specialId)
#endregion 特殊科室
public bool QueryHosConfigs(int moduleId, out int sheetType)
public bool QueryHosConfigs(int moduleId, ref bool isSingle, out int sheetType)
{
var module = exmoduleRepository.GetEntity(t => t.Id == moduleId);
if (module == null)
......@@ -338,6 +352,11 @@ public bool QueryHosConfigs(int moduleId, out int sheetType)
//if (module.SheetType != (int)SheetType.Income)
// throw new PerformanceException("当前模板不能进行考核项目自动添加");
var hospital = hospitalRepository.GetEntity(t => t.ID == module.HospitalId);
if (hospital == null) throw new PerformanceException("医院信息错误!");
isSingle = hospital.IsSingleProject == 1;
var hospitalConfigs = hospitalconfigRepository.GetEntities(t => t.HospitalId == module.HospitalId);
if (hospitalConfigs != null && hospitalConfigs.Any())
return true;
......@@ -468,12 +487,14 @@ public List<sys_hospitalconfig> GetHospitalconfigs(int hospitalId)
/// 绩效数据抽取模板
/// </summary>
/// <returns></returns>
public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType)
public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType, int? sheetType)
{
var titlevalue = new List<TitleValue>();
Expression<Func<ex_type, bool>> exp = t => new List<int> { 0, hospitalId }.Contains(t.HospitalId);
if (executeType.FirstOrDefault() == 1)
exp = exp.And(t => t.Source == (int)SheetType.Income);
else if (sheetType != null && !new int[] { 0, (int)SheetType.Income }.Contains(sheetType.Value))
exp = exp.And(t => t.Source == sheetType);
else
exp = exp.And(t => t.Source != (int)SheetType.Income);
......@@ -505,7 +526,15 @@ 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, (int)SheetType.OtherWorkload }.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
......@@ -563,5 +592,124 @@ public ModFeeResponse FeeSource(ModModuleRequest request)
return new ModFeeResponse();
}
#region 配置校验
/// <summary>
/// 配置校验
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></param>
public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSingle, out string filePath)
{
string result = null;
filePath = "";
try
{
// 获取绩效信息
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("AllotID错误");
// 获取医院信息
var hospital = hospitalRepository.GetEntity(t => t.ID == hospitalId);
if (hospital == null)
throw new PerformanceException("医院ID错误");
isSingle = (hospital.IsSingleProject ?? 2) == 1;
// 获取医院配置信息
var hospitalConfigList = hospitalconfigRepository.GetEntities(t => t.HospitalId == hospitalId);
if (hospitalConfigList == null || hospitalConfigList.Count == 0)
throw new PerformanceException("当前医院暂不支持HIS数据抽取");
// 获取最近一次绩效
var statesArray = new int[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive };
var allotList = perallotRepository.GetEntities(t => t.HospitalId == hospitalId && statesArray.Contains(t.States));
var allotLast = allotList?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
if (allotLast != null)
filePath = allotLast.Path;
// 获取当前医院模版信息
var modulesList = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId);
if (modulesList == null || modulesList.Count == 0)
throw new PerformanceException("当前医院还未配置模版");
// 获取模板项
var moduleIdList = modulesList.Select(t => t.Id).ToList();
var itemsList = exitemRepository.GetEntities(t => t.ModuleId.HasValue && moduleIdList.Contains(t.ModuleId.Value));
if (itemsList == null || itemsList.Count == 0)
throw new PerformanceException("当前医院还未配置模版项");
// 获取当前模板所有相关抽取SQL语句
var extypeIds = itemsList.Select(t => t.TypeId).Union(modulesList.Select(t => t.TypeId)).Distinct().ToList();
var extractList = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (extractList == null || extractList.Count == 0)
throw new PerformanceException("当前医院配置模板无需抽取");
}
catch (PerformanceException ex)
{
logger.LogError($"提取绩效数据异常 {ex.ToString()}");
result = ex.Message;
}
catch (Exception ex)
{
logger.LogError($"提取绩效数据异常 {ex.ToString()}");
throw new Exception(ex.Message);
}
return result;
}
#endregion 配置校验
#region 检查是否有新增的科室或费用类别
public Dictionary<string, object> CheckHasNewDepartmentOrCategory(int allotId)
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var allotList = perallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId && new int[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive }.Contains(t.States));
var prevAllot = allotList?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
if (prevAllot == null) return null;
var modDics = moddicRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Type == "checksql");
if (modDics == null || !modDics.Any()) return null;
var hospitalconfigs = hospitalconfigRepository.GetEntities(t => modDics.Select(s => s.ConfigId).Distinct().Contains(t.Id));
if (hospitalconfigs == null || !hospitalconfigs.Any()) return null;
var sheets = persheetRepository.GetEntities(t => t.AllotID == prevAllot.ID && t.SheetType == (int)SheetType.Income) ?? new List<per_sheet>();
var importdata = imdataRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value)) ?? new List<im_data>();
Dictionary<string, object> paramtemers = new Dictionary<string, object>();
foreach (var dic in modDics)
{
if (paramtemers.ContainsKey(dic.Remark)) continue;
var config = hospitalconfigs.FirstOrDefault(t => t.Id == dic.ConfigId);
if (config == null) continue;
var data = queryService.QueryData(config, allot, dic.Content);
if (data == null || !data.Any()) continue;
var sheet = sheets.FirstOrDefault(t => t.SheetName.Contains(dic.Remark));
if (sheet == null) continue;
var sheetdata = importdata.Where(t => t.SheetID == sheet.ID)?.ToList() ?? new List<im_data>();
var departments = sheetdata.Select(t => t.Department).Distinct();
var noExistedDepartment = data.Select(t => t.Department).Distinct().Except(departments);
var typenames = sheetdata.Select(t => t.TypeName).Distinct();
var noExistedTypename = data.Select(t => t.Category).Distinct().Except(typenames);
StringBuilder stringBuilder = new StringBuilder();
if (noExistedDepartment != null && noExistedDepartment.Any())
stringBuilder.AppendLine($"新增科室:{string.Join(",", noExistedDepartment)}");
if (noExistedTypename != null && noExistedTypename.Any())
stringBuilder.AppendLine($"新增费用类型:{string.Join(",", noExistedTypename)}");
paramtemers.Add(dic.Remark, stringBuilder.ToString());
}
return paramtemers;
}
#endregion 检查是否有新增的科室或费用类别
}
}
using Dapper;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services.ExtractExcelService
{
public class DictionaryService : IAutoInjection
{
private readonly ILogger<DictionaryService> logger;
private readonly QueryService queryService;
private readonly LogManageService logService;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
private readonly PerforExscriptRepository exscriptRepository;
public DictionaryService(
ILogger<DictionaryService> logger,
QueryService queryService,
LogManageService logService,
PerforPeremployeeRepository peremployeeRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
PerforExscriptRepository exscriptRepository
)
{
this.logger = logger;
this.queryService = queryService;
this.logService = logService;
this.peremployeeRepository = peremployeeRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
}
public void Handler(int hospitalId, per_allot allot, string groupName, bool isSingle)
{
try
{
var configs = hospitalconfigRepository.GetEntities(t => t.HospitalId == hospitalId);
if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息");
var types = extypeRepository.GetEntities(t => t.HospitalId == hospitalId && new int[] { 2 }.Contains(t.Source));
if (types == null || !types.Any()) return;
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取人员信息数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => types.Select(s => s.Id).Contains(t.TypeId) && t.IsEnable == 1);
if (scripts != null && scripts.Any())
{
if (types.Any(t => t.Source == (int)SheetType.Employee)) //人员字典抽取配置
{
var typeIds = types.Where(t => t.Source == (int)SheetType.Employee).Select(t => t.Id);
var script = scripts.FirstOrDefault(t => typeIds.Contains(t.TypeId));
if (script == null) return;
Employee(allot, configs.FirstOrDefault(t => t.Id == script.ConfigId), script.ExecScript);
}
}
}
catch (Exception ex)
{
logger.LogError("获取数据时发生异常");
throw ex;
}
}
private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
{
try
{
if (config == null || string.IsNullOrEmpty(sql)) return;
var data = queryService.QueryData<per_employee>(config, allot, sql);
if (data == null || !data.Any()) return;
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID);
if (employees != null && employees.Any())
{
peremployeeRepository.RemoveRange(employees.ToArray());
}
peremployeeRepository.AddRange(data.ToArray());
}
catch (Exception ex)
{
logger.LogError("获取人员名单时发生异常:" + ex.ToString());
}
}
private void Department()
{
}
}
}
using NPOI.SS.UserModel;
using OfficeOpenXml;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -17,6 +18,7 @@ public static string GetExtractFile(int hospitalId, ref string newFilePath, stri
string originalPath = string.IsNullOrEmpty(allotFilePath)
? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls")
: allotFilePath;
CloseAutoFilter(originalPath);
var (tempPath, filePath) = CopyOriginalFile(hospitalId, originalPath);
newFilePath = filePath;
return tempPath;
......@@ -36,7 +38,7 @@ private static (string TempPath, string FilePath) CopyOriginalFile(int hospitalI
FileHelper.CreateDirectory(dpath);
string tempPath = Path.Combine(dpath, $"Template{DateTime.Now.ToString("yyyyMMddHHmmssfff")}{ext}");
FileHelper.Copy(originalPath, tempPath);
string filePath = Path.Combine(dpath, $"绩效提取数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}{ext}");
string filePath = Path.Combine(dpath, $"绩效提取数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xls");
return (tempPath, filePath);
}
......@@ -66,7 +68,8 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
}
}
foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.OtherWorkload)?.OrderBy(t => t.ModuleName))
foreach (var module in modulesList.Where(t => new int[] { (int)SheetType.OtherWorkload, (int)SheetType.Assess }
.Contains(t.SheetType.Value))?.OrderBy(t => t.ModuleName))
{
var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank());
if (sheet == null)
......@@ -78,6 +81,9 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
var copysheet = workbook.GetSheet(item.Key);
var newSheet = copysheet.CopySheet(module.ModuleName, true);
workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
var point = PerSheetDataFactory.GetDataRead(SheetType.Workload)?.Point;
ClearSheetTemplate(newSheet, point, (SheetType)module.SheetType);
//}
}
}
......@@ -108,5 +114,64 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee
}
}
}
public static void ClearSheetTemplate(ISheet sheet, PerSheetPoint point, SheetType sheetType)
{
if (sheet == null)
return;
for (int i = point.HeaderFirstRowNum.Value; i < sheet.LastRowNum + 1; i++)
{
var row = sheet.GetRow(i);
if (row != null)
{
row.ZeroHeight = false; //取消隐藏行
int dataFirstCellRowNum = point.DataFirstCellNum.Value;
//跳过核算单元和科室
for (int j = dataFirstCellRowNum; j < row.LastCellNum; j++)
{
var cell = row.GetCell(j);
if (cell != null)
{
cell.RemoveCellComment(); //删除批注
row.RemoveCell(cell);
}
}
}
}
if (!new SheetType[] { SheetType.Workload, SheetType.OtherWorkload }.Contains(sheetType))
{
var row = sheet.GetRow(0);
if (row != null) sheet.RemoveRow(row);
sheet.ShiftRows(point.DataFirstRowNum.Value, sheet.LastRowNum + 1, -1);
}
}
public static void CloseAutoFilter(string path)
{
try
{
var fileInfo = new FileInfo(path);
using (ExcelPackage package = new ExcelPackage(fileInfo))
{
ExcelWorkbook workbook = package.Workbook;
if (workbook == null) return;
foreach (var sheet in workbook.Worksheets)
{
if (sheet.AutoFilterAddress != null)
{
sheet.Cells[sheet.AutoFilterAddress.Address].AutoFilter = false;
}
}
package.Save();
}
}
catch (Exception ex)
{
}
}
}
}
......@@ -34,17 +34,18 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
// 去除excel中已存在的列
int headerFirstCellNum = point.DataFirstCellNum.Value;
if (columnHeader.LastCellNum > point.DataFirstCellNum)
if (columnHeader.LastCellNum > point.DataFirstCellNum.Value)
{
for (int index = headerFirstCellNum; index < columnHeader.LastCellNum; index++)
for (int index = point.DataFirstCellNum.Value; index < columnHeader.LastCellNum; index++)
{
var column = columnHeader.GetCell(index).GetDecodeEscapes();
if (string.IsNullOrEmpty(column)) continue;
if (index > headerFirstCellNum) headerFirstCellNum = index;
columns.RemoveAll(t => t.ColumnName.NoBlank() == column);
if (index > headerFirstCellNum)
headerFirstCellNum = index + 1;
}
if (headerFirstCellNum > point.DataFirstCellNum.Value)
headerFirstCellNum += 1;
}
if (columns == null || !columns.Any()) return;
......@@ -53,7 +54,6 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
: style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.系数, CellFormat.百分比);
var columnStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头);
headerFirstCellNum += 1;
// 补充excel中不存在的列
foreach (var item in columns)
{
......@@ -111,7 +111,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++)
for (int rowIndex = point.DataFirstRowNum.Value; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{
var row = sheet.GetRow(rowIndex);
if (row == null) continue;
......@@ -119,6 +119,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex;
var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue;
......@@ -146,8 +148,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
}
data.RemoveAll(t => t.Department == department);
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
}
dataFirstRowNum += 1;
}
private static void WriteSheetDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style,
......@@ -166,7 +168,6 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1;
foreach (string department in departments)
{
var deptData = data.Where(t => t.Department == department);
......@@ -266,7 +267,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++)
for (int rowIndex = point.DataFirstRowNum.Value; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{
var row = sheet.GetRow(rowIndex);
if (row == null) continue;
......@@ -274,6 +275,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex;
var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue;
......@@ -300,8 +303,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
}
data.RemoveAll(t => t.Department == department);
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
}
dataFirstRowNum += 1;
}
private static void WriteCollectDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style,
......@@ -318,7 +321,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1;
foreach (string department in departments)
{
var deptData = data.Where(t => t.Department == department);
......
......@@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Performance.Services.ExtractExcelService
{
......@@ -19,7 +18,7 @@ public class ExtractService : IAutoInjection
private readonly QueryService queryService;
private readonly PersonService personService;
private readonly PerSheetService perSheetService;
private readonly PerforHospitalRepository hospitalRepository;
private readonly DictionaryService dictionaryService;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforCollectdataRepository collectdataRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
......@@ -30,7 +29,7 @@ public class ExtractService : IAutoInjection
QueryService queryService,
PersonService personService,
PerSheetService perSheetService,
PerforHospitalRepository hospitalRepository,
DictionaryService dictionaryService,
PerforPerallotRepository perallotRepository,
PerforCollectdataRepository collectdataRepository,
PerforPeremployeeRepository peremployeeRepository
......@@ -41,7 +40,7 @@ PerforPeremployeeRepository peremployeeRepository
this.queryService = queryService;
this.personService = personService;
this.perSheetService = perSheetService;
this.hospitalRepository = hospitalRepository;
this.dictionaryService = dictionaryService;
this.perallotRepository = perallotRepository;
this.collectdataRepository = collectdataRepository;
this.peremployeeRepository = peremployeeRepository;
......@@ -74,6 +73,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var dict = new Dictionary<ExDataDict, object>();
logService.ReturnTheLog(allotId, groupName, 3, "", 5, 1, isSingle);
dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
var data = queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict);
var standData = StandDataFormat(hospitalId, data);
......@@ -90,6 +90,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
WriteDataToFile(workbook, allotId, dict, standData, groupName, isSingle);
logService.ReturnTheLog(allotId, groupName, 2, "提取完成", $"绩效数据提取成功", 5, isSingle);
workbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateAll(); //实时更新公式的结果
allot.IsExtracting = isSingle ? 2 : 0;
allot.ExtractPath = extractFilePath;
}
......
......@@ -80,7 +80,7 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName
var data = new List<ex_result>();
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取数据");
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (scripts != null && scripts.Any())
......@@ -367,7 +367,7 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo
/// <param name="source"></param>
/// <param name="category"></param>
/// <returns></returns>
private IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql)
public IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql)
{
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
......@@ -386,6 +386,33 @@ private IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot a
}
/// <summary>
/// 查询数据
/// </summary>
/// <param name="config"></param>
/// <param name="allot"></param>
/// <param name="execsql"></param>
/// <param name="source"></param>
/// <param name="category"></param>
/// <returns></returns>
public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, per_allot allot, string execsql)
{
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}");
var result = connection.Query<T>(execsql, commandTimeout: 20000);
logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录");
return result;
}
}
/// <summary>
/// 获取参数
/// </summary>
/// <param name="allot"></param>
......
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Threading.Tasks;
namespace Performance.Services
{
......@@ -102,8 +104,20 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
logdbug.Add(allotId, tag, content, level, type);
if (!isSingle)
{
var http = url.ImportFile + $"/template/returnlog?type={type}&tag={tag}&message={content}&level={level}&groupName={groupName}";
HttpHelper.HttpPost(http);
var http = new RestSharpHelper();
var importUrl = http.SetUrl(url.ImportFile, "/template/returnlog");
var info = new SignalrLogRequest()
{
Type = type,
Tag = tag,
Message = content,
Level = level,
GroupName = groupName
};
string json = JsonHelper.Serialize(info);
var request = http.CreatePostRequest(json);
Task.Run(() => http.GetResponse(importUrl, request));
}
}
catch (Exception ex)
......
......@@ -101,6 +101,16 @@ public static IPerSheetDataRead GetDataRead(SheetType sheetType, bool isnew = fa
case SheetType.PersonPostCoefficient:
dataread = new PerSheetDataReadPersonExtra(); // 个人岗位系数
break;
case SheetType.WorkloadMedicineProp:
dataread = new PerSheetDataReadAccountExtra(); // 药占比系数
break;
case SheetType.WorkloadCMI:
dataread = new PerSheetDataReadAccountExtra(); // CMI系数
break;
case SheetType.WorkloadIncline:
dataread = new PerSheetDataReadAccountExtra(); // 工作量倾斜系数
break;
}
return dataread;
}
......
......@@ -14,14 +14,14 @@ namespace Performance.Services
public class PerSheetService : IAutoInjection
{
private PerHeaderService _perHeader;
private PerforCofdrugpropRepository _perforCofdrugpropRepository;
//private PerforCofdrugpropRepository _perforCofdrugpropRepository;
private PerforCofdrugtypeRepository _perforCofdrugtypeRepository;
public PerSheetService(PerHeaderService perHeader,
PerforCofdrugpropRepository perforCofdrugpropRepository,
//PerforCofdrugpropRepository perforCofdrugpropRepository,
PerforCofdrugtypeRepository perforCofdrugtypeRepository)
{
_perHeader = perHeader;
_perforCofdrugpropRepository = perforCofdrugpropRepository;
//_perforCofdrugpropRepository = perforCofdrugpropRepository;
_perforCofdrugtypeRepository = perforCofdrugtypeRepository;
}
/// <summary>
......@@ -113,6 +113,14 @@ public SheetType GetSheetType(string sheetName)
return SheetType.PersonAdjustLaterOtherManagePerforFee;
else if (sheetName.StartsWith("6.11")) // 个人岗位系数
return SheetType.PersonPostCoefficient;
else if (sheetName.StartsWith("6.12")) // 药占比系数
return SheetType.WorkloadMedicineProp;
else if (sheetName.StartsWith("6.13")) // CMI系数
return SheetType.WorkloadCMI;
else if (sheetName.StartsWith("6.14")) // 工作量倾斜系数
return SheetType.WorkloadIncline;
else if (sheetName.StartsWith("6.1"))
return SheetType.AccountScoreAverage;
else if (sheetName.StartsWith("6.2"))
......
......@@ -84,7 +84,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
var value = group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue);
if (header.CellValue == "门急诊工作量")
{
var factor = confs.FirstOrDefault(t => t.AccoutingUnit == group.Key)?.Factor ?? 0;
var factor = confs.FirstOrDefault(t => t.AccountingUnit == group.Key)?.Factor ?? 0;
value = value * factor;
}
......@@ -99,7 +99,8 @@ 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, sys_hospital hospital, 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,
IEnumerable<cof_workitem> workitems, IEnumerable<CofDrugProp> medicineProps, IEnumerable<CofDrugProp> cmis, IEnumerable<CofDrugProp> inclines, bool isDoctor = false)
{
//获取最大列坐标位置
int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1;
......@@ -115,7 +116,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
{
var ds = group.Select(t =>
{
var (cellvalue, factor) = ComputValue(group, hospital, confs, cmis, workitems, isDoctor);
var cellvalue = ComputValue(group, hospital, workitems, medicineProps, cmis, inclines, isDoctor);
var dto = new PerData
{
......@@ -123,7 +124,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
AccountingUnit = group.Key.AccountingUnit,
//CellValue = group.Sum(s => s.CellValue),
CellValue = cellvalue,
MedicineFactor = factor,
//MedicineFactor = factor,
TypeName = group.Key.UnitType,
RowNumber = group.FirstOrDefault()?.RowNumber ?? 0,
IsTotal = 1,
......@@ -140,45 +141,32 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
return (sheet, perDataList);
}
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)
private decimal? ComputValue(IGrouping<object, PerData> group, sys_hospital hospital,
IEnumerable<cof_workitem> workitems, IEnumerable<CofDrugProp> medicineProps, IEnumerable<CofDrugProp> cmis, IEnumerable<CofDrugProp> inclines, 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.其他护理组 };
var unittype = isDoctor
? new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.专家组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.特殊核算组.ToString() }
: new List<string> { UnitType.护理组.ToString(), UnitType.其他护理组.ToString() };
if ((medicineProps == null && cmis == null && inclines == null) || workitems == null)
return group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue);
if ((confs == null && cmis == null) || workitems == null)
return (group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue), null);
else
{
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));
//需要乘系数的项
var ngroup = group.Where(t => !workitems.Select(s => s.Item).Contains(t.TypeName));
//var value = fgroup.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue) * factor;
//value += ngroup.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue);
var value = fgroup.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))
{
cellvalue = cmifactor * cellvalue;
}
return cellvalue;
});
decimal medicinefactor = medicineProps?.FirstOrDefault(t => t.AccountingUnit == group.First().AccountingUnit && unittype.Contains(t.UnitType))?.Factor ?? 1;
decimal cmifactor = cmis?.FirstOrDefault(t => t.AccountingUnit == group.First().AccountingUnit && unittype.Contains(t.UnitType))?.Factor ?? 1;
decimal inclinefactor = inclines?.FirstOrDefault(t => t.AccountingUnit == group.First().AccountingUnit && unittype.Contains(t.UnitType))?.Factor ?? 1;
value += ngroup.Sum(s =>
var value = group.Sum(s =>
{
var cellvalue = s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue;
if (workitems.Any(w => w.Type == 1) && workitems.Where(w => w.Type == 1).Select(q => q.Item).Contains(s.TypeName))
{
cellvalue = factor * cellvalue;
}
if (workitems.Any(w => w.Type == 3 && w.Item == s.TypeName))
cellvalue = cellvalue * inclinefactor;
if (workitems.Any(w => w.Type == 2 && w.Item == s.TypeName))
cellvalue = cellvalue * cmifactor;
if (workitems.Any(w => w.Type == 1 && w.Item == s.TypeName))
cellvalue = cellvalue * medicinefactor;
return cellvalue;
});
return (value, factor);
}
return value;
}
#endregion
}
......
......@@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.1" />
<PackageReference Include="EPPlus" Version="4.5.3.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
</ItemGroup>
......
......@@ -1688,6 +1688,39 @@ public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request
return perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId);
}
public void OtherSave(int secondId, SaveCollectData collectData)
{
if (collectData.ColHeaders == null || !collectData.ColHeaders.Any()) return;
var parameters = new List<string>();
foreach (var item in collectData.ColHeaders)
{
if (!SecondAllotDetails.OtherTemp.ContainsValue(item)) throw new PerformanceException($"请确认列'{item}'是否正确");
parameters.Add(SecondAllotDetails.OtherTemp.FirstOrDefault(t => t.Value == item).Key);
}
if (parameters == null || !parameters.Any()) return;
List<string> josn = new List<string>();
foreach (var item in collectData.Data)
{
var list = item.ToList();
var itemList = list.Select(t => $"\"{parameters[list.IndexOf(t)]}\":\"{t}\"");
josn.Add($"{{{string.Join(",", itemList)}}}");
}
var data = JsonHelper.Deserialize<List<ag_othersource>>($"[{string.Join(",", josn)}]");
data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList();
if (data == null || !data.Any()) return;
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any())
{
perforAgothersourceRepository.RemoveRange(existEntities.ToArray());
}
data.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(data.ToArray());
}
#endregion 二次绩效其他来源
#region 打印
......
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