初稿

parent 1bd3618d
using Microsoft.Extensions.Hosting; //using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; //using Microsoft.Extensions.Logging;
using Performance.Services.Queues; //using Performance.Services.Queues;
using System; //using System;
using System.Threading; //using System.Threading;
using System.Threading.Tasks; //using System.Threading.Tasks;
namespace Performance.Api //namespace Performance.Api
{ //{
public class QueuedHostedService : BackgroundService // public class QueuedHostedService : BackgroundService
{ // {
private readonly ILogger<QueuedHostedService> _logger; // private readonly ILogger<QueuedHostedService> _logger;
public QueuedHostedService( // public QueuedHostedService(
IBackgroundTaskQueue taskQueue, // IBackgroundTaskQueue taskQueue,
ILogger<QueuedHostedService> logger) // ILogger<QueuedHostedService> logger)
{ // {
TaskQueue = taskQueue; // TaskQueue = taskQueue;
_logger = logger; // _logger = logger;
} // }
public IBackgroundTaskQueue TaskQueue { get; } // public IBackgroundTaskQueue TaskQueue { get; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) // protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{ // {
_logger.LogInformation( // _logger.LogInformation(
$"Queued Hosted Service is running.{Environment.NewLine} {Environment.NewLine}Tap W to add a work item to the background queue.{Environment.NewLine}"); // $"Queued Hosted Service is running.{Environment.NewLine} {Environment.NewLine}Tap W to add a work item to the background queue.{Environment.NewLine}");
await BackgroundProcessing(stoppingToken); // await BackgroundProcessing(stoppingToken);
} // }
private async Task BackgroundProcessing(CancellationToken stoppingToken) // private async Task BackgroundProcessing(CancellationToken stoppingToken)
{ // {
while (!stoppingToken.IsCancellationRequested) // while (!stoppingToken.IsCancellationRequested)
{ // {
var workItem = // var workItem =
await TaskQueue.DequeueAsync(stoppingToken); // await TaskQueue.DequeueAsync(stoppingToken);
try // try
{ // {
await workItem(stoppingToken); // await workItem(stoppingToken);
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
_logger.LogError(ex, // _logger.LogError(ex,
"Error occurred executing {WorkItem}.", nameof(workItem)); // "Error occurred executing {WorkItem}.", nameof(workItem));
} // }
} // }
} // }
public override async Task StopAsync(CancellationToken stoppingToken) // public override async Task StopAsync(CancellationToken stoppingToken)
{ // {
_logger.LogInformation("Queued Hosted Service is stopping."); // _logger.LogInformation("Queued Hosted Service is stopping.");
await base.StopAsync(stoppingToken); // await base.StopAsync(stoppingToken);
} // }
} // }
} //}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
using System; using System;
namespace Performance.Api.Configurations namespace Performance.Api.Configurations
...@@ -23,6 +23,7 @@ public static void AddDatabaseConfiguration(this IServiceCollection services) ...@@ -23,6 +23,7 @@ public static void AddDatabaseConfiguration(this IServiceCollection services)
optionBuilder => optionBuilder =>
{ {
optionBuilder.EnableStringComparisonTranslations(true); optionBuilder.EnableStringComparisonTranslations(true);
optionBuilder.EnableRetryOnFailure();
}); });
}, ServiceLifetime.Transient); }, ServiceLifetime.Transient);
} }
......
...@@ -46,8 +46,8 @@ public static void AddDependencyInjectionConfiguration(this IServiceCollection s ...@@ -46,8 +46,8 @@ public static void AddDependencyInjectionConfiguration(this IServiceCollection s
#endregion redis #endregion redis
services.AddHostedService<QueuedHostedService>(); //services.AddHostedService<QueuedHostedService>();
services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>(); //services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>();
services.AddSingleton<IHubNotificationQueue, HubNotificationQueue>(); services.AddSingleton<IHubNotificationQueue, HubNotificationQueue>();
services services
......
...@@ -34,8 +34,9 @@ public class AllotController : Controller ...@@ -34,8 +34,9 @@ public class AllotController : Controller
private ILogger<AllotController> _logger; private ILogger<AllotController> _logger;
private ClaimService _claim; private ClaimService _claim;
private LogManageService _logManageService; private LogManageService _logManageService;
private readonly TaskService _taskService;
private readonly CostTransferService costTransferService; private readonly CostTransferService costTransferService;
private IBackgroundTaskQueue _backgroundTaskQueue; //private IBackgroundTaskQueue _backgroundTaskQueue;
private IServiceScopeFactory _serviceScopeFactory; private IServiceScopeFactory _serviceScopeFactory;
public AllotController(AllotService allotService, public AllotController(AllotService allotService,
...@@ -43,10 +44,11 @@ public class AllotController : Controller ...@@ -43,10 +44,11 @@ public class AllotController : Controller
ConfigService configService, ConfigService configService,
ILogger<AllotController> logger, ILogger<AllotController> logger,
IWebHostEnvironment evn, IWebHostEnvironment evn,
IBackgroundTaskQueue backgroundTaskQueue, //IBackgroundTaskQueue backgroundTaskQueue,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
ClaimService claim, ClaimService claim,
LogManageService logManageService, LogManageService logManageService,
TaskService taskService,
CostTransferService costTransferService) CostTransferService costTransferService)
{ {
_allotService = allotService; _allotService = allotService;
...@@ -55,9 +57,10 @@ public class AllotController : Controller ...@@ -55,9 +57,10 @@ public class AllotController : Controller
_evn = evn; _evn = evn;
_claim = claim; _claim = claim;
_logManageService = logManageService; _logManageService = logManageService;
_taskService = taskService;
this.costTransferService = costTransferService; this.costTransferService = costTransferService;
_configService = configService; _configService = configService;
_backgroundTaskQueue = backgroundTaskQueue; //_backgroundTaskQueue = backgroundTaskQueue;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
} }
...@@ -252,28 +255,47 @@ public ApiResponse GenerateAsync([CustomizeValidator(RuleSet = "Delete"), FromBo ...@@ -252,28 +255,47 @@ public ApiResponse GenerateAsync([CustomizeValidator(RuleSet = "Delete"), FromBo
var allot = _allotService.GetAllot(request.ID); var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path)) if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件"); throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
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);
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
//if (_evn.IsEnvironment("Localhost")) //if (_evn.IsEnvironment("Localhost"))
//{ //{
// var tasks = _taskService.GetTasks(-1);
// var status = new int[] { (int)Background.Status.等待, (int)Background.Status.执行中 };
// if (tasks.Any(w => w.Argument == allot.ID.ToString() && w.JobType == (int)Background.JobType.生成测算表 && status.Contains(w.Status)))
// return new ApiResponse(ResponseType.OK, "当前绩效正在生成中,请等待生成完成后重新生成");
// 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);
// _allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
// _allotService.Generate(allot); // _allotService.Generate(allot);
//} //}
//else //else
//{ //{
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.Generate(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
//_publishEndpoint.Publish(allot).Wait(); var tasks = _taskService.GetTasks(-1);
var status = new int[] { (int)Background.Status.等待, (int)Background.Status.执行中 };
if (tasks.Any(w => w.Argument == allot.ID.ToString() && w.JobType == (int)Background.JobType.生成测算表 && status.Contains(w.Status)))
return new ApiResponse(ResponseType.OK, "当前绩效正在生成中,请等待生成完成后重新生成");
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);
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
//_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
//{
// using (var scope = _serviceScopeFactory.CreateScope())
// {
// var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
// scopedServices.Generate(allot);
// await Task.Delay(TimeSpan.FromSeconds(5), token);
// }
//});
_taskService.Add(Background.JobType.生成测算表, allot.ID.ToString());
//} //}
_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");
...@@ -297,15 +319,16 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -297,15 +319,16 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB
if (null == allot || !states.Contains(allot.States)) if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。"); throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => //_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{ //{
using (var scope = _serviceScopeFactory.CreateScope()) // using (var scope = _serviceScopeFactory.CreateScope())
{ // {
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>(); // var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.GenerateReport(allot); // scopedServices.GenerateReport(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token); // await Task.Delay(TimeSpan.FromSeconds(5), token);
} // }
}); //});
_taskService.Add(Background.JobType.生成报表, allot.ID.ToString());
return new ApiResponse(ResponseType.OK, "统计报表数据任务开始"); return new ApiResponse(ResponseType.OK, "统计报表数据任务开始");
} }
......
...@@ -18,24 +18,27 @@ public class ModExtractController : Controller ...@@ -18,24 +18,27 @@ public class ModExtractController : Controller
{ {
private readonly ClaimService _claim; private readonly ClaimService _claim;
private readonly AllotService _allotService; private readonly AllotService _allotService;
private readonly TaskService _taskService;
private readonly CustomExtractService _extractService; private readonly CustomExtractService _extractService;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IBackgroundTaskQueue _backgroundTaskQueue; //private readonly IBackgroundTaskQueue _backgroundTaskQueue;
private readonly IHubNotificationQueue _notificationQueue; private readonly IHubNotificationQueue _notificationQueue;
public ModExtractController( public ModExtractController(
ClaimService claim, ClaimService claim,
AllotService allotService, AllotService allotService,
TaskService taskService,
CustomExtractService extractService, CustomExtractService extractService,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
IBackgroundTaskQueue backgroundTaskQueue, //IBackgroundTaskQueue backgroundTaskQueue,
IHubNotificationQueue notificationQueue) IHubNotificationQueue notificationQueue)
{ {
_claim = claim; _claim = claim;
_allotService = allotService; _allotService = allotService;
_taskService = taskService;
_extractService = extractService; _extractService = extractService;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_backgroundTaskQueue = backgroundTaskQueue; //_backgroundTaskQueue = backgroundTaskQueue;
_notificationQueue = notificationQueue; _notificationQueue = notificationQueue;
} }
...@@ -46,27 +49,30 @@ public ApiResponse CustomExtract(int allotId) ...@@ -46,27 +49,30 @@ public ApiResponse CustomExtract(int allotId)
if (!_extractService.CheckConfigScript(userId, allotId)) if (!_extractService.CheckConfigScript(userId, allotId))
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。"); return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => //_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{ //{
using (var scope = _serviceScopeFactory.CreateScope()) // using (var scope = _serviceScopeFactory.CreateScope())
{ // {
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>(); // var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>(); // var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>(); // var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
// if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
// {
// scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
// scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
// }
// else
// {
// scopedQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
// }
// await Task.Delay(TimeSpan.FromSeconds(5), token);
// }
//});
if (scopedServices.ExtractData(userId, allotId, out string resultFilePath)) _taskService.Add(Background.JobType.自定义抽取, JsonHelper.Serialize(new { UserId = userId, AllotId = allotId }));
{
scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
}
else
{
scopedQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
}
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
_notificationQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取任务开始执行"))); _notificationQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取任务开始执行")));
......
...@@ -37,6 +37,7 @@ public class TemplateController : Controller ...@@ -37,6 +37,7 @@ public class TemplateController : Controller
private readonly HospitalService hospitalService; private readonly HospitalService hospitalService;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly LogManageService logService; private readonly LogManageService logService;
private readonly TaskService _taskService;
private readonly IServiceScopeFactory serviceScopeFactory; private readonly IServiceScopeFactory serviceScopeFactory;
private readonly ExtractService extractService; private readonly ExtractService extractService;
...@@ -52,6 +53,7 @@ public class TemplateController : Controller ...@@ -52,6 +53,7 @@ public class TemplateController : Controller
HospitalService hospitalService, HospitalService hospitalService,
AllotService allotService, AllotService allotService,
LogManageService logService, LogManageService logService,
TaskService taskService,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
ExtractService extractService) ExtractService extractService)
{ {
...@@ -66,6 +68,7 @@ public class TemplateController : Controller ...@@ -66,6 +68,7 @@ public class TemplateController : Controller
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.allotService = allotService; this.allotService = allotService;
this.logService = logService; this.logService = logService;
_taskService = taskService;
this.serviceScopeFactory = serviceScopeFactory; this.serviceScopeFactory = serviceScopeFactory;
this.extractService = extractService; this.extractService = extractService;
} }
...@@ -209,76 +212,27 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest ...@@ -209,76 +212,27 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
if (allot == null) if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误"); return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
// 判断是那种抽取 // 判断是那种抽取
try
{
bool isSingle = false;
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)) bool isSingle = false;
//{ string message = configService.Judge(request.AllotId, request.HospitalId, request.UseScheme, ref isSingle, out string filePath);
// var data = configService.CheckHasNewDepartmentOrCategory(request.AllotId); if (!string.IsNullOrEmpty(message))
// return new ApiResponse(ResponseType.Fail, data); 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 && allot.ExtractTime.HasValue && DateTime.Now.AddHours(-3) < allot.ExtractTime)
return new ApiResponse(ResponseType.OK, "正在提取数据,请稍等!", new { IsExtracting = true }); if (allot.IsExtracting == 1 && allot.ExtractTime.HasValue && DateTime.Now.AddHours(-3) < allot.ExtractTime)
allot.IsExtracting = 1; return new ApiResponse(ResponseType.OK, "正在提取数据,请稍等!", new { IsExtracting = true });
allot.ExtractTime = DateTime.Now;
allotService.Update(allot);
// string email = claim.GetUserClaim(JwtClaimTypes.Mail);
string email = "";
if (isSingle) _taskService.Add(Background.JobType.提取数据, JsonHelper.Serialize(new { request.AllotId, request.HospitalId, request.UseScheme, isSingle, filePath }));
{
logger.LogInformation("同一项目中进行提取");
Task.Run(() => return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们通知您!", new { IsExtracting = false });
{
Thread.Sleep(1000);
using (var scope = serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<ExtractService>();
logger.LogInformation("提取绩效数据参数:" + JsonHelper.Serialize(new { allotId = allot.ID, hospitalId = allot.HospitalId }));
string extractFilePath = scopedServices.Main(allot.ID, allot.HospitalId, email, allot.ID.ToString(), filePath, isSingle);
}
});
}
else
{
var http = new RestSharpHelper();
var extractUrl = http.SetUrl(url.HttpPost, "extract/extract");
var obj = new ExtractRequest
{
AllotId = request.AllotId,
HospitalId = request.HospitalId,
Email = email
};
string json = JsonHelper.Serialize(obj);
logger.LogInformation("提取绩效数据参数:" + json);
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 });
}
catch (Exception ex)
{
if (allot != null)
{
allot.IsExtracting = 3;
allotService.Update(allot);
}
logger.LogError("提取绩效数据:" + ex.ToString());
throw new Exception(ex.Message);
}
// A 使用上传绩效作为模板 // A 使用上传绩效作为模板
// A-1 判断上传绩效是否存在,并执行成功 // A-1 判断上传绩效是否存在,并执行成功
// A-2 医院人员名单、1.0.1 额外收入(写出列头)、2.1 成本支出统计表(写出列头)、4.1 临床科室医护绩效测算表、4.2 特殊核算单元绩效测算表(数量、考核得分率、奖罚、其他) // A-2 医院人员名单、1.0.1 额外收入(写出列头)、2.1 成本支出统计表(写出列头)、4.1 临床科室医护绩效测算表、4.2 特殊核算单元绩效测算表(数量、考核得分率、奖罚、其他)
......
using FluentScheduler; using FluentScheduler;
using System;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using System;
using Microsoft.Extensions.Caching.Memory;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Performance.Repository;
using Performance.DtoModels;
using Performance.Services;
namespace Performance.Api namespace Performance.Api
{ {
...@@ -21,6 +13,7 @@ public JobRegistry(IServiceProvider provider) ...@@ -21,6 +13,7 @@ public JobRegistry(IServiceProvider provider)
Schedule(() => provider.GetService<ExtractGenerateJob>()).ToRunEvery(1).Days().At(23, 00); Schedule(() => provider.GetService<ExtractGenerateJob>()).ToRunEvery(1).Days().At(23, 00);
//Schedule(() => provider.GetService<ClearLoggerJob>()).ToRunNow().AndEvery(60).Seconds(); //Schedule(() => provider.GetService<ClearLoggerJob>()).ToRunNow().AndEvery(60).Seconds();
Schedule(() => provider.GetService<ClearLoggerJob>()).ToRunNow().AndEvery(1).Days().At(3, 00); Schedule(() => provider.GetService<ClearLoggerJob>()).ToRunNow().AndEvery(1).Days().At(3, 00);
Schedule(() => provider.GetService<BackgroundJob>()).ToRunNow().AndEvery(10).Seconds();
} }
} }
} }
...@@ -102,6 +102,7 @@ public void ConfigureServices(IServiceCollection services) ...@@ -102,6 +102,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddTransient<ExtractGenerateJob>(); services.AddTransient<ExtractGenerateJob>();
services.AddTransient<ExtractDataJob>(); services.AddTransient<ExtractDataJob>();
services.AddTransient<ClearLoggerJob>(); services.AddTransient<ClearLoggerJob>();
services.AddTransient<BackgroundJob>();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Debug", "Default": "Information",
"System": "Information", "System": "Information",
"Microsoft": "Information" "Microsoft": "Warning"
} }
}, },
"AppConnection": { "AppConnection": {
"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_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;"
"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"
}, },
"Application": { "Application": {
//登录过期时间 //登录过期时间
......
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Debug", "Default": "Information",
"System": "Information", "System": "Information"
"Microsoft": "Information"
} }
}, },
"AppConnection": { "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=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_screen;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_performance_screen;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"
}, },
"Application": { "Application": {
//登录过期时间 //登录过期时间
......
...@@ -6,22 +6,7 @@ ...@@ -6,22 +6,7 @@
}, },
//连接字符串 //连接字符串
"AppConnection": { "AppConnection": {
"PerformanceConnectionString": "server=116.62.245.55;database=db_performance;uid=suvalue;pwd=suvalue2017;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", "PerformanceConnectionString": "server=116.62.245.55;database=db_performance;uid=suvalue;pwd=suvalue2017;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;"
"HangfireConnectionString": "server=116.62.245.55;database=db_hangfire;uid=suvalue;pwd=suvalue2017;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultdatabase=2"
},
//互亿
"HuyiSmsConfig": {
"Url": "http://106.ihuyi.cn/webservice/sms.php?method=Submit",
"Account": "cf_szjk",
"Password": "123456"
},
//阿里邮箱
"EmailOptions": {
"SmtpServer": "smtpdm.aliyun.com",
"Account": "service@email.suvalue.com",
"Password": "SuValue123456",
"IsEnable": false
}, },
"Application": { "Application": {
//登录过期时间 //登录过期时间
...@@ -51,5 +36,16 @@ ...@@ -51,5 +36,16 @@
"ImportFile": "http://localhost:5001/api/", "ImportFile": "http://localhost:5001/api/",
// 抽取uri // 抽取uri
"HttpPost": "http://localhost:50997/api/" "HttpPost": "http://localhost:50997/api/"
},
"RateLimitingConfig": {
"Endpoints": [
"/api/second/savevalue",
"/api/second/savedata",
"/api/second/other/save",
"/api/second/redistribution/save",
"/api/second/redistribution/submit"
],
"Period": "1", // 单位为秒
"Limit": 1
} }
} }
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}==============================================================${newline}" /> layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}==============================================================${newline}" />
<!-- another file log, only own logs. Uses some ASP.NET core renderers --> <!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="${basedir}/Logs/${shortdate}/${level}.log" <!--<target xsi:type="File" name="ownFile-web" fileName="${basedir}/Logs/${shortdate}/${level}.log"
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}url: ${aspnet-request-url}${newline}action: ${aspnet-mvc-action}${newline}==============================================================${newline}" /> layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}url: ${aspnet-request-url}${newline}action: ${aspnet-mvc-action}${newline}==============================================================${newline}" />-->
<!-- write log to mongodb--> <!-- write log to mongodb-->
<!--<target xsi:type="Mongo" <!--<target xsi:type="Mongo"
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
<logger name="*" minlevel="Trace" writeTo="allfile" /> <logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Skip non-critical Microsoft logs and so log only own logs--> <!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxLevel="Info" final="true" /> <!--<logger name="Microsoft.*" maxLevel="Info" final="true" />-->
<!-- BlackHole without writeTo --> <!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" /> <!--<logger name="*" minlevel="Trace" writeTo="ownFile-web" />-->
<!--Add logs to mongodb--> <!--Add logs to mongodb-->
<!--<logger name="*" minlevel="Trace" writeTo="mongo"/>--> <!--<logger name="*" minlevel="Trace" writeTo="mongo"/>-->
......
...@@ -2165,6 +2165,27 @@ ...@@ -2165,6 +2165,27 @@
<param name="query"></param> <param name="query"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.BackgroundJob.Execute_Allot_Generate(Performance.Services.TaskService,Performance.EntityModels.bg_task)">
<summary>
生成测算表
</summary>
<param name="service"></param>
<param name="task"></param>
</member>
<member name="M:Performance.Api.BackgroundJob.Timeout(Performance.Services.TaskService,System.Collections.Generic.List{Performance.EntityModels.bg_task})">
<summary>
超时关闭
</summary>
<param name="service"></param>
<param name="tasks"></param>
</member>
<member name="M:Performance.Api.BackgroundJob.Repeat(Performance.Services.TaskService,System.Collections.Generic.List{Performance.EntityModels.bg_task})">
<summary>
重复任务仅执行最后异常
</summary>
<param name="service"></param>
<param name="tasks"></param>
</member>
<member name="T:Performance.Api.ClearLoggerJob"> <member name="T:Performance.Api.ClearLoggerJob">
<summary> <summary>
删除历史日志 删除历史日志
......
...@@ -914,11 +914,6 @@ ...@@ -914,11 +914,6 @@
人员工号 人员工号
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.PerData.Annotation">
<summary>
单元格注释
</summary>
</member>
<member name="P:Performance.DtoModels.PerData.Remark"> <member name="P:Performance.DtoModels.PerData.Remark">
<summary> <summary>
单元格备注 单元格备注
......
...@@ -1595,6 +1595,16 @@ ...@@ -1595,6 +1595,16 @@
排序 排序
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.bg_task">
<summary>
考核类别
</summary>
</member>
<member name="P:Performance.EntityModels.bg_task.ID">
<summary>
</summary>
</member>
<member name="T:Performance.EntityModels.cof_accounting"> <member name="T:Performance.EntityModels.cof_accounting">
<summary> <summary>
......
...@@ -135,4 +135,24 @@ public enum Role ...@@ -135,4 +135,24 @@ public enum Role
护理部审核 = 13, 护理部审核 = 13,
绩效查询 = 13, 绩效查询 = 13,
} }
public class Background
{
public enum JobType
{
生成测算表 = 1,
提取数据 = 2,
生成报表 = 3,
自定义抽取 = 4,
}
public enum Status
{
等待 = 1,
执行中 = 2,
完成 = 3,
失败 = 10,
无效 = 88,
超时 = 99,
}
}
} }
...@@ -30,10 +30,10 @@ public class PerData : IPerData ...@@ -30,10 +30,10 @@ public class PerData : IPerData
/// 人员工号 /// 人员工号
/// </summary> /// </summary>
public string JobNumber { get; set; } public string JobNumber { get; set; }
/// <summary> ///// <summary>
/// 单元格注释 ///// 单元格注释
/// </summary> ///// </summary>
public string Annotation { get; set; } //public string Annotation { get; set; }
/// <summary> /// <summary>
/// 单元格备注 /// 单元格备注
/// </summary> /// </summary>
......
...@@ -74,7 +74,7 @@ public object CellValue ...@@ -74,7 +74,7 @@ public object CellValue
{ {
get get
{ {
var value = ConvertHelper.To<decimal?>(cellValue); var value = ConvertHelper.ToDecimalOrNull(cellValue);
if (value.HasValue && value.Value > 0) if (value.HasValue && value.Value > 0)
return Math.Round(value.Value, 2); return Math.Round(value.Value, 2);
return cellValue; return cellValue;
......
...@@ -57,6 +57,7 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -57,6 +57,7 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<as_tempassess> as_tempassess { get; set; } public virtual DbSet<as_tempassess> as_tempassess { get; set; }
/// <summary> 考核列头 </summary> /// <summary> 考核列头 </summary>
public virtual DbSet<as_tempcolumns> as_tempcolumns { get; set; } public virtual DbSet<as_tempcolumns> as_tempcolumns { get; set; }
public virtual DbSet<bg_task> bg_task { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<cof_accounting> cof_accounting { get; set; } public virtual DbSet<cof_accounting> cof_accounting { get; set; }
/// <summary> </summary> /// <summary> </summary>
......
//-----------------------------------------------------------------------
// <copyright file=" bg_task.cs">
// * FileName: bg_task.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
/// 考核类别
/// </summary>
[Table("bg_task")]
public class bg_task
{
/// <summary>
///
/// </summary>
[Key]
public int ID { get; set; }
public string Name { get; set; }
public int JobType { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? BeginTime { get; set; }
public DateTime? EndTime { get; set; }
public int Status { get; set; }
public string Argument { get; set; }
public string Remark { get; set; }
public long ElapsedTime { get; set; }
}
}
...@@ -30,6 +30,23 @@ public static decimal TryDecimal(string inValue, decimal defaultValue = default( ...@@ -30,6 +30,23 @@ public static decimal TryDecimal(string inValue, decimal defaultValue = default(
return ret; return ret;
} }
/// <summary>
/// 转换为128位可空浮点型,并按指定小数位舍入
/// </summary>
/// <param name="input">输入值</param>
/// <param name="digits">小数位数</param>
public static decimal? ToDecimalOrNull(object input)
{
try
{
return decimal.TryParse(input?.ToString(), out decimal tmpvalue) ? tmpvalue : null;
}
catch (Exception ex)
{
throw;
}
}
public static DateTime TryDateTime(string inValue, DateTime defaultValue = default(DateTime)) public static DateTime TryDateTime(string inValue, DateTime defaultValue = default(DateTime))
{ {
DateTime ret = defaultValue; DateTime ret = defaultValue;
...@@ -46,23 +63,28 @@ public static DateTime TryDateTime(string inValue, DateTime defaultValue = defau ...@@ -46,23 +63,28 @@ public static DateTime TryDateTime(string inValue, DateTime defaultValue = defau
/// <returns></returns> /// <returns></returns>
public static T To<T>(object value, T defaultValue = default(T)) public static T To<T>(object value, T defaultValue = default(T))
{ {
try if (value == null)
{ return defaultValue;
var t = typeof(T); if (value is string && string.IsNullOrWhiteSpace(value.ToString()))
//兼容可空类型转换 return defaultValue;
if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null)
{
return default(T);
}
t = Nullable.GetUnderlyingType(t); var t = typeof(T);
} var type = Nullable.GetUnderlyingType(t) ?? t;
return (T)Convert.ChangeType(value, t); var typeName = type.Name.ToLower();
try
{
if (typeName == "string")
return (T)(object)value.ToString();
if (typeName == "guid")
return (T)(object)new Guid(value.ToString());
if (type.IsEnum)
return (T)Enum.Parse(type, value.ToString());
if (value is IConvertible)
return (T)Convert.ChangeType(value, type);
return (T)value;
} }
catch catch (Exception ex)
{ {
return defaultValue; return defaultValue;
} }
......
//-----------------------------------------------------------------------
// <copyright file=" bg_task.cs">
// * FileName: bg_task.cs
// </copyright>
//-----------------------------------------------------------------------
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// bg_task Repository
/// </summary>
public partial class PerforBgtaskRepository : PerforRepository<bg_task>
{
public PerforBgtaskRepository(PerformanceDbContext context) : base(context)
{
}
}
}
...@@ -83,10 +83,10 @@ private List<PerAgainData> SlideRowRead(ISheet sheet, PerHeader header, int r, I ...@@ -83,10 +83,10 @@ private List<PerAgainData> SlideRowRead(ISheet sheet, PerHeader header, int r, I
{ {
var athead = header.Children.ElementAt(c); var athead = header.Children.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
var factorValue = ConvertHelper.To<decimal?>(sheet.GetRow(FactorRow).GetCell(athead.PointCell)?.ToString()); var factorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(FactorRow).GetCell(athead.PointCell)?.ToString());
PerAgainData data = new PerAgainData PerAgainData data = new PerAgainData
{ {
RowNumber = r, RowNumber = r,
...@@ -117,13 +117,13 @@ private static PerAgainEmployee FixatRowRead(List<PerHeader> perHeader, int r, I ...@@ -117,13 +117,13 @@ private static PerAgainEmployee FixatRowRead(List<PerHeader> perHeader, int r, I
RowNumber = r, RowNumber = r,
Name = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "姓名").PointCell)?.ToString(), Name = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "姓名").PointCell)?.ToString(),
JobTitle = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职务").PointCell)?.ToString(), JobTitle = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职务").PointCell)?.ToString(),
JobFactor = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职称系数").PointCell)?.ToString()), JobFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职称系数").PointCell)?.ToString()),
Attendance = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "出勤").PointCell)?.ToString()), Attendance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "出勤").PointCell)?.ToString()),
YearFactor = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "年资").PointCell)?.ToString()), YearFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "年资").PointCell)?.ToString()),
Award = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "重点奖励").PointCell)?.ToString()), Award = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "重点奖励").PointCell)?.ToString()),
Allowance = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "管理津贴").PointCell)?.ToString()), Allowance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "管理津贴").PointCell)?.ToString()),
AlonePerfor = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "单独核算人员绩效").PointCell)?.ToString()), AlonePerfor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "单独核算人员绩效").PointCell)?.ToString()),
NightShift = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "夜班费").PointCell)?.ToString()), NightShift = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "夜班费").PointCell)?.ToString()),
}; };
} }
} }
......
...@@ -325,6 +325,7 @@ public void Generate(per_allot allot) ...@@ -325,6 +325,7 @@ public void Generate(per_allot allot)
{ {
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);
UpdateAllotStates(allot.ID, (int)AllotStates.InCheckData, EnumHelper.GetDescription(AllotStates.InCheckData));
var excel = new PerExcel(); var excel = new PerExcel();
int generate = allot.Generate; int generate = allot.Generate;
if (new int[] { (int)AllotGenerate.OriginalDataEdited, (int)AllotGenerate.PersonnelOffice }.Contains(allot.Generate)) if (new int[] { (int)AllotGenerate.OriginalDataEdited, (int)AllotGenerate.PersonnelOffice }.Contains(allot.Generate))
...@@ -344,7 +345,6 @@ public void Generate(per_allot allot) ...@@ -344,7 +345,6 @@ public void Generate(per_allot allot)
// 导出数据 // 导出数据
excel = importDataService.ReadDataAndSave(allot); excel = importDataService.ReadDataAndSave(allot);
UpdateAllotStates(allot.ID, (int)AllotStates.InCheckData, EnumHelper.GetDescription(AllotStates.InCheckData));
//if (!checkDataService.Check(excel, allot)) //if (!checkDataService.Check(excel, allot))
//{ //{
// UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail)); // UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail));
......
...@@ -2109,13 +2109,13 @@ ...@@ -2109,13 +2109,13 @@
// var value = deptData.FirstOrDefault(t => t.TypeName == headName)?.CellValue ?? "0"; // var value = deptData.FirstOrDefault(t => t.TypeName == headName)?.CellValue ?? "0";
// if (isIncom) // if (isIncom)
// { // {
// var cellvalue = value == "0" ? null : ConvertHelper.To<decimal?>(value); // var cellvalue = value == "0" ? null : ConvertHelper.ToDecimalOrNull(value);
// OutToExcelCell<decimal>(newCell, cellvalue); // OutToExcelCell<decimal>(newCell, cellvalue);
// newCell.CellStyle = style; // newCell.CellStyle = style;
// } // }
// else if (newCell.CellType != CellType.Formula) // else if (newCell.CellType != CellType.Formula)
// { // {
// var cellvalue = value == "0" ? null : ConvertHelper.To<decimal?>(value); // var cellvalue = value == "0" ? null : ConvertHelper.ToDecimalOrNull(value);
// OutToExcelCell<decimal>(newCell, cellvalue); // OutToExcelCell<decimal>(newCell, cellvalue);
// if (header != null && header.Contains(headName)) // if (header != null && header.Contains(headName))
// newCell.CellStyle = style; // newCell.CellStyle = style;
......
...@@ -45,11 +45,11 @@ public static class NopiSevice ...@@ -45,11 +45,11 @@ public static class NopiSevice
// switch (cell.CellType) // switch (cell.CellType)
// { // {
// case CellType.Numeric: // case CellType.Numeric:
// return ConvertHelper.To<decimal?>(cell.NumericCellValue); // return ConvertHelper.ToDecimalOrNull(cell.NumericCellValue);
// case CellType.String: // case CellType.String:
// return ConvertHelper.To<decimal?>(cell.StringCellValue); // return ConvertHelper.ToDecimalOrNull(cell.StringCellValue);
// case CellType.Formula: // case CellType.Formula:
// return ConvertHelper.To<decimal?>(cell.NumericCellValue); // return ConvertHelper.ToDecimalOrNull(cell.NumericCellValue);
// } // }
// } // }
// catch (Exception ex) // catch (Exception ex)
......
...@@ -51,7 +51,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -51,7 +51,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
...@@ -63,7 +63,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -63,7 +63,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(), AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
FactorValue = 1, FactorValue = 1,
IsFactor = true, IsFactor = true,
}; };
......
...@@ -69,7 +69,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -69,7 +69,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
PerData data = new PerData PerData data = new PerData
...@@ -80,9 +80,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -80,9 +80,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(), Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配 UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()),
IsFactor = true, IsFactor = true,
}; };
dataList.Add(data); dataList.Add(data);
...@@ -111,9 +111,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -111,9 +111,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = cellValue, Department = cellValue,
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = (dataList.Select(t => (PerData)t)?.Where(t => t.TypeName == athead.CellValue).Sum(t => t.CellValue) ?? 0) / 2, CellValue = (dataList.Select(t => (PerData)t)?.Where(t => t.TypeName == athead.CellValue).Sum(t => t.CellValue) ?? 0) / 2,
Annotation = technicianRow.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = technicianRow.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = tunit.UnitType, //手动匹配 UnitType = tunit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(tunit.FactorRow.Value).GetCell(athead.PointCell)?.ToString()), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(tunit.FactorRow.Value).GetCell(athead.PointCell)?.ToString()),
IsFactor = true, IsFactor = true,
}; };
dataList.Add(data); dataList.Add(data);
......
...@@ -44,7 +44,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -44,7 +44,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
object @object = row.GetCell(point).GetValue(); object @object = row.GetCell(point).GetValue();
if (item.IsNumber) if (item.IsNumber)
@object = ConvertHelper.To<decimal?>(@object); @object = ConvertHelper.ToDecimalOrNull(@object);
if (dic.Keys.Contains(item.Field)) if (dic.Keys.Contains(item.Field))
dic[item.Field] = @object; dic[item.Field] = @object;
......
...@@ -46,7 +46,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -46,7 +46,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
...@@ -58,7 +58,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -58,7 +58,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
//Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)), //Department = NopiSevice.GetCellStringValue(row.GetCell(unit.DeptCellNum.Value)),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = row.GetCell(0)?.ToString(), UnitType = row.GetCell(0)?.ToString(),
FactorValue = 0, FactorValue = 0,
IsFactor = false, IsFactor = false,
......
...@@ -41,7 +41,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -41,7 +41,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
object @object = row.GetCell(point).GetValue(); object @object = row.GetCell(point).GetValue();
if (item.IsNumber) if (item.IsNumber)
@object = ConvertHelper.To<decimal?>(@object); @object = ConvertHelper.ToDecimalOrNull(@object);
if (dic.Keys.Contains(item.Field)) if (dic.Keys.Contains(item.Field))
dic[item.Field] = @object; dic[item.Field] = @object;
......
...@@ -72,7 +72,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -72,7 +72,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (!string.IsNullOrEmpty(athead?.CellValue) && athead.CellValue.Contains("备注")) if (!string.IsNullOrEmpty(athead?.CellValue) && athead.CellValue.Contains("备注"))
continue; continue;
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
...@@ -84,9 +84,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -84,9 +84,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(), Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配 UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue),
IsFactor = true, IsFactor = true,
}; };
var lastcell = vhead.OrderByDescending(t => t.PointCell).First(); var lastcell = vhead.OrderByDescending(t => t.PointCell).First();
......
...@@ -68,7 +68,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -68,7 +68,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
PerData data = new PerData PerData data = new PerData
...@@ -79,9 +79,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -79,9 +79,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(), Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配 UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue),
IsFactor = true, IsFactor = true,
}; };
if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department)) if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department))
......
...@@ -41,7 +41,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -41,7 +41,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
object @object = row.GetCell(point).GetValue(); object @object = row.GetCell(point).GetValue();
if (item.IsNumber) if (item.IsNumber)
@object = ConvertHelper.To<decimal?>(@object); @object = ConvertHelper.ToDecimalOrNull(@object);
if (dic.Keys.Contains(item.Field)) if (dic.Keys.Contains(item.Field))
dic[item.Field] = @object; dic[item.Field] = @object;
......
...@@ -68,7 +68,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -68,7 +68,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
PerData data = new PerData PerData data = new PerData
...@@ -79,9 +79,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -79,9 +79,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(), Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配 UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.NumericCellValue),
IsFactor = true, IsFactor = true,
}; };
if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department)) if (string.IsNullOrEmpty(data.AccountingUnit) && string.IsNullOrEmpty(data.Department))
......
...@@ -51,7 +51,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -51,7 +51,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
...@@ -63,7 +63,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -63,7 +63,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(), AccountingUnit = row.GetCell(unit.AccountingUnitCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
FactorValue = 1, FactorValue = 1,
IsFactor = true, IsFactor = true,
}; };
......
...@@ -55,13 +55,13 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -55,13 +55,13 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (NopiSevice.TryGetPoint(perHeader, "量化指标", out point)) if (NopiSevice.TryGetPoint(perHeader, "量化指标", out point))
specialUnit.QuantitativeIndicators = row.GetCell(point).GetValue(); specialUnit.QuantitativeIndicators = row.GetCell(point).GetValue();
if (NopiSevice.TryGetPoint(perHeader, "数量", out point)) if (NopiSevice.TryGetPoint(perHeader, "数量", out point))
specialUnit.Quantity = ConvertHelper.To<decimal?>(row.GetCell(point).GetValue()); specialUnit.Quantity = ConvertHelper.ToDecimalOrNull(row.GetCell(point).GetValue());
if (NopiSevice.TryGetPoint(perHeader, "量化指标绩效分值", out point)) if (NopiSevice.TryGetPoint(perHeader, "量化指标绩效分值", out point))
specialUnit.QuantitativeIndicatorsValue = ConvertHelper.To<decimal?>(row.GetCell(point).GetValue()); specialUnit.QuantitativeIndicatorsValue = ConvertHelper.ToDecimalOrNull(row.GetCell(point).GetValue());
if (NopiSevice.TryGetPoint(perHeader, "人数", out point)) if (NopiSevice.TryGetPoint(perHeader, "人数", out point))
specialUnit.Number = ConvertHelper.To<decimal?>(row.GetCell(point).GetValue()); specialUnit.Number = ConvertHelper.ToDecimalOrNull(row.GetCell(point).GetValue());
if (NopiSevice.TryGetPoint(perHeader, "实发绩效", out point)) if (NopiSevice.TryGetPoint(perHeader, "实发绩效", out point))
specialUnit.RealGiveFee = ConvertHelper.To<decimal?>(row.GetCell(point).GetValue()); specialUnit.RealGiveFee = ConvertHelper.ToDecimalOrNull(row.GetCell(point).GetValue());
ICell cell = null; ICell cell = null;
if (NopiSevice.TryGetPoint(perHeader, "科室", out int kspoint)) if (NopiSevice.TryGetPoint(perHeader, "科室", out int kspoint))
...@@ -84,10 +84,10 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -84,10 +84,10 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
specialUnit.AccountingUnit = accountingUnit; specialUnit.AccountingUnit = accountingUnit;
specialUnit.Department = accountingUnit; specialUnit.Department = accountingUnit;
//specialUnit.ScoringAverage = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "考核得分率").PointCell)?.NumericCellValue); //specialUnit.ScoringAverage = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "考核得分率").PointCell)?.NumericCellValue);
//specialUnit.OtherPerfor = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "其他绩效").PointCell)?.NumericCellValue); //specialUnit.OtherPerfor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "其他绩效").PointCell)?.NumericCellValue);
//specialUnit.Punishment = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "医院奖罚").PointCell)?.NumericCellValue); //specialUnit.Punishment = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "医院奖罚").PointCell)?.NumericCellValue);
//specialUnit.Adjust = ConvertHelper.To<decimal?>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "调节系数").PointCell)?.NumericCellValue); //specialUnit.Adjust = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "调节系数").PointCell)?.NumericCellValue);
//} //}
if (!string.IsNullOrEmpty(specialUnit.QuantitativeIndicators) && specialUnit.QuantitativeIndicatorsValue != null) if (!string.IsNullOrEmpty(specialUnit.QuantitativeIndicators) && specialUnit.QuantitativeIndicatorsValue != null)
dataList.Add(specialUnit); dataList.Add(specialUnit);
......
...@@ -48,7 +48,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -48,7 +48,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell).GetValue()); var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) if (!cellValue.HasValue || cellValue.Value == 0)
continue; continue;
...@@ -60,9 +60,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -60,9 +60,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
Department = row.GetCell(unit.DeptCellNum.Value).GetValue(), Department = row.GetCell(unit.DeptCellNum.Value).GetValue(),
TypeName = athead?.CellValue, TypeName = athead?.CellValue,
CellValue = cellValue, CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, //Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, UnitType = unit.UnitType,
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()), FactorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell).GetValue()),
IsFactor = true, IsFactor = true,
}; };
if (sheet.SheetName.Contains("医生组")) if (sheet.SheetName.Contains("医生组"))
......
using System; //using System;
using System.Collections.Concurrent; //using System.Collections.Concurrent;
using System.Threading; //using System.Threading;
using System.Threading.Tasks; //using System.Threading.Tasks;
namespace Performance.Services.Queues //namespace Performance.Services.Queues
{ //{
public interface IBackgroundTaskQueue // public interface IBackgroundTaskQueue
{ // {
void QueueBackgroundWorkItem(Func<CancellationToken, Task> workItem); // void QueueBackgroundWorkItem(Func<CancellationToken, Task> workItem);
Task<Func<CancellationToken, Task>> DequeueAsync(CancellationToken cancellationToken); // Task<Func<CancellationToken, Task>> DequeueAsync(CancellationToken cancellationToken);
} // }
public class BackgroundTaskQueue : IBackgroundTaskQueue // public class BackgroundTaskQueue : IBackgroundTaskQueue
{ // {
private readonly ConcurrentQueue<Func<CancellationToken, Task>> _workItems = new ConcurrentQueue<Func<CancellationToken, Task>>(); // private readonly ConcurrentQueue<Func<CancellationToken, Task>> _workItems = new ConcurrentQueue<Func<CancellationToken, Task>>();
private readonly SemaphoreSlim _signal = new SemaphoreSlim(0); // private readonly SemaphoreSlim _signal = new SemaphoreSlim(0);
public void QueueBackgroundWorkItem(Func<CancellationToken, Task> workItem) // public void QueueBackgroundWorkItem(Func<CancellationToken, Task> workItem)
{ // {
if (workItem == null) // if (workItem == null)
{ // {
throw new ArgumentNullException(nameof(workItem)); // throw new ArgumentNullException(nameof(workItem));
} // }
_workItems.Enqueue(workItem); // _workItems.Enqueue(workItem);
_signal.Release(); // _signal.Release();
} // }
public async Task<Func<CancellationToken, Task>> DequeueAsync(CancellationToken cancellationToken) // public async Task<Func<CancellationToken, Task>> DequeueAsync(CancellationToken cancellationToken)
{ // {
await _signal.WaitAsync(cancellationToken); // await _signal.WaitAsync(cancellationToken);
_workItems.TryDequeue(out var workItem); // _workItems.TryDequeue(out var workItem);
return workItem; // return workItem;
} // }
} // }
} //}
...@@ -574,8 +574,8 @@ private List<ag_bodysource> LoadEmployees_PrevSecondAllot(per_allot allot, ag_se ...@@ -574,8 +574,8 @@ private List<ag_bodysource> LoadEmployees_PrevSecondAllot(per_allot allot, ag_se
new ag_bodysource new ag_bodysource
{ {
WorkNumber = row.FirstOrDefault(w => w.ItemName == "人员工号")?.ItemValue, WorkNumber = row.FirstOrDefault(w => w.ItemName == "人员工号")?.ItemValue,
TitleCoefficient = ConvertHelper.To<decimal?>(row.FirstOrDefault(w => w.ItemName == "职称系数")?.ItemValue), TitleCoefficient = ConvertHelper.ToDecimalOrNull(row.FirstOrDefault(w => w.ItemName == "职称系数")?.ItemValue),
StaffCoefficient = ConvertHelper.To<decimal?>(row.FirstOrDefault(w => w.ItemName == "人员系数")?.ItemValue), StaffCoefficient = ConvertHelper.ToDecimalOrNull(row.FirstOrDefault(w => w.ItemName == "人员系数")?.ItemValue),
}) })
.Distinct().ToList() ?? new List<ag_bodysource>(); .Distinct().ToList() ?? new List<ag_bodysource>();
......
...@@ -537,7 +537,7 @@ public void SaveSecondAllotHeadData(int secondId, string json) ...@@ -537,7 +537,7 @@ public void SaveSecondAllotHeadData(int secondId, string json)
SecondId = secondId, SecondId = secondId,
FieldId = fieldId, FieldId = fieldId,
FieldName = i == 0 ? typeName + "占比" : typeName + "金额", FieldName = i == 0 ? typeName + "占比" : typeName + "金额",
Value = prefix[i].StartsWith(prefix[0]) ? ConvertHelper.To<decimal?>(dict[fieldId.ToLower()]) : null, Value = prefix[i].StartsWith(prefix[0]) ? ConvertHelper.ToDecimalOrNull(dict[fieldId.ToLower()]) : null,
}; };
insertData.Add(source); insertData.Add(source);
......
...@@ -1551,7 +1551,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou ...@@ -1551,7 +1551,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou
}; };
}); });
var enums = EnumHelper.GetItems<UnitType>(); var enums = EnumHelper.GetItems<UnitType>();
return result.Where(w => w.RealGiveFee != 0) return result.Where(w => w.RealGiveFee.HasValue && w.RealGiveFee != 0)
.OrderBy(t => t.Status == 4 ? 2 : t.Status) .OrderBy(t => t.Status == 4 ? 2 : t.Status)
.ThenBy(t => enums.FirstOrDefault(f => f.Name == t.UnitType)?.Value) .ThenBy(t => enums.FirstOrDefault(f => f.Name == t.UnitType)?.Value)
.ThenBy(t => t.Department) .ThenBy(t => t.Department)
...@@ -2190,8 +2190,8 @@ public dynamic Print(int secondId) ...@@ -2190,8 +2190,8 @@ public dynamic Print(int secondId)
foreach (var rownumber in rownumbers) foreach (var rownumber in rownumbers)
{ {
var distperfor = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "可分配绩效")?.ItemValue); var distperfor = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "可分配绩效")?.ItemValue);
var nightworkperfor = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "夜班工作量绩效")?.ItemValue); var nightworkperfor = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "夜班工作量绩效")?.ItemValue);
var sec = new SecPrintResponse var sec = new SecPrintResponse
{ {
JobNumber = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "人员工号")?.ItemValue, JobNumber = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "人员工号")?.ItemValue,
...@@ -2200,11 +2200,11 @@ public dynamic Print(int secondId) ...@@ -2200,11 +2200,11 @@ public dynamic Print(int secondId)
RealAmount = (distperfor ?? 0) + (nightworkperfor ?? 0), RealAmount = (distperfor ?? 0) + (nightworkperfor ?? 0),
}; };
sec.WorkPost = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称")?.ItemValue; sec.WorkPost = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称")?.ItemValue;
sec.TitlePerfor = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称绩效")?.ItemValue); sec.TitlePerfor = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称绩效")?.ItemValue);
sec.WorkPerformance = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "工作量绩效工资")?.ItemValue); sec.WorkPerformance = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "工作量绩效工资")?.ItemValue);
sec.DeptReward = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "单项奖励小计")?.ItemValue); sec.DeptReward = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "单项奖励小计")?.ItemValue);
sec.DistPerformance = distperfor; sec.DistPerformance = distperfor;
sec.OtherPerformance = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "医院其他绩效")?.ItemValue); sec.OtherPerformance = ConvertHelper.ToDecimalOrNull(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "医院其他绩效")?.ItemValue);
sec.NightWorkPerformance = nightworkperfor; sec.NightWorkPerformance = nightworkperfor;
result.Add(sec); result.Add(sec);
} }
......
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Services
{
public class TaskService : IAutoInjection
{
private readonly PerforBgtaskRepository _taskRepository;
public TaskService(
PerforBgtaskRepository taskRepository)
{
_taskRepository = taskRepository;
}
/// <summary>
/// 默认返回 最近10小时的任务
/// </summary>
/// <param name="hours"></param>
/// <returns></returns>
public List<bg_task> GetTasks(int hours = -10)
{
return _taskRepository.GetEntities(w => w.CreateTime > DateTime.Now.AddHours(hours));
}
public bool Add(Background.JobType type, string argument = "")
{
return _taskRepository.Add(new bg_task
{
Name = type.ToString(),
JobType = (int)type,
CreateTime = DateTime.Now,
Argument = argument,
Status = (int)Background.Status.等待,
Remark = $"{type} - {Background.Status.等待}"
});
}
public bool Update(int taskId, Background.Status status, string remark = "", long milliseconds = 0)
{
var task = _taskRepository.GetEntity(w => w.ID == taskId);
if (task == null) return false;
task.Status = (int)status;
if (status == Background.Status.执行中)
task.BeginTime = DateTime.Now;
task.ElapsedTime = milliseconds / 1000;
task.Remark = $"{(Background.JobType)task.JobType} - {status} {remark}";
if (status == Background.Status.完成 || status == Background.Status.失败 || status == Background.Status.超时)
task.EndTime = DateTime.Now;
return _taskRepository.Update(task);
}
}
}
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