Commit c5254965 by lcx

Merge branch 'develop' into 手工录入

parents 6e573a49 b3f25e0e
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Api.Configurations
{
public static class AuthenticationConfig
{
public static void AddAuthenticationConfiguration(this IServiceCollection services, IConfiguration configuration)
{
if (services == null) throw new ArgumentNullException(nameof(services));
var signingKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Consts.Secret));
//services.Configure<JwtOptions>(options =>
//{
// options.Issuer = Consts.Issuer;
// options.Audience = Consts.Audience;
// options.SigningCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);
//});
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = Consts.Issuer,
ValidateAudience = true,
ValidAudience = Consts.Audience,
ValidateIssuerSigningKey = true,
IssuerSigningKey = signingKey,
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero,
};
options.Events = new JwtBearerEvents()
{
OnMessageReceived = context =>
{
var accessToken = context.Request.Query["access_token"];
var path = context.HttpContext.Request.Path;
if (!string.IsNullOrEmpty(accessToken) && (path.StartsWithSegments("/performance/allotLogHub")))
{
context.Token = accessToken;
}
return Task.CompletedTask;
}
};
});
}
}
//public class JwtOptions
//{
// /// <summary>
// /// Issuer jwt签发者
// /// </summary>
// public string Issuer { get; set; }
// /// <summary>
// /// Subject jwt所面向的用户
// /// </summary>
// public string Subject { get; set; }
// /// <summary>
// /// Audience 接收jwt的一方
// /// </summary>
// public string Audience { get; set; }
// /// <summary>
// /// Not Before 定义在什么时间之前,该jwt是不可以用的
// /// </summary>
// public DateTime NotBefore => DateTime.Now;
// /// <summary>
// /// Expiration Time jwt的过期时间,必须大于签发时间
// /// </summary>
// public DateTime Expiration => IssuedAt.Add(ValidFor);
// /// <summary>
// /// Issued At jwt的签发时间
// /// </summary>
// public DateTime IssuedAt => DateTime.Now;
// /// <summary>
// /// Set the timespan the token will be valid for (default is 10 min)
// /// </summary>
// public TimeSpan ValidFor { get; set; } = TimeSpan.FromMinutes(120);
// /// <summary>
// /// The signing key to use when generating tokens.
// /// </summary>
// public SigningCredentials SigningCredentials { get; set; }
//}
}
......@@ -10,9 +10,7 @@ public static class AutoMapperConfig
public static void AddAutoMapperConfiguration(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
Mapper.Initialize(cfg => cfg.AddProfile<AutoMapperConfigs>());
services.AddAutoMapper();
services.AddAutoMapper(typeof(AutoMapperConfigs));
}
}
}
......@@ -17,8 +17,14 @@ public static void AddDatabaseConfiguration(this IServiceCollection services)
services.AddDbContext<PerformanceDbContext>(options =>
{
options.UseMySQL(connection.Value.PerformanceConnectionString);
});
options.UseMySql(
connection.Value.PerformanceConnectionString,
ServerVersion.AutoDetect(connection.Value.PerformanceConnectionString),
optionBuilder =>
{
optionBuilder.EnableStringComparisonTranslations(true);
});
}, ServiceLifetime.Transient);
}
}
}
......@@ -55,17 +55,4 @@ public static void AddDependencyInjectionConfiguration(this IServiceCollection s
.AddPerformanceRepoitory();
}
}
#region hangfire 权限
public class HangfireAuthorizationFilter : Hangfire.Dashboard.IDashboardAuthorizationFilter
{
//这里需要配置权限规则
public bool Authorize(Hangfire.Dashboard.DashboardContext context)
{
return true;
}
}
#endregion hangfire 权限
}
using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using System;
using System.Linq;
using System.Reflection;
//using FluentScheduler;
//using Microsoft.Extensions.DependencyInjection;
//using Performance.Services;
//using System;
//using System.Linq;
//using System.Reflection;
namespace Performance.Api.Configurations
{
public static class FluentSchedulerConfig
{
public static void AddFluentSchedulerConfiguration(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
//namespace Performance.Api.Configurations
//{
// public static class FluentSchedulerConfig
// {
// public static void AddFluentSchedulerConfiguration(this IServiceCollection services)
// {
// if (services == null) throw new ArgumentNullException(nameof(services));
ServiceLocator.Instance = services.BuildServiceProvider();
JobManager.Initialize(new JobRegistry());
// ServiceLocator.Instance = services.BuildServiceProvider();
// JobManager.Initialize(new JobRegistry());
////扫描当前程序集中实现了Registry的类
//var registrys = Assembly.GetExecutingAssembly().GetTypes()
// .Where(t => !t.IsInterface && !t.IsSealed && !t.IsAbstract && typeof(Registry).IsAssignableFrom(t))
// .Select(s => s.Assembly.CreateInstance(s.FullName) as Registry)?.ToArray();
// ////扫描当前程序集中实现了Registry的类
// //var registrys = Assembly.GetExecutingAssembly().GetTypes()
// // .Where(t => !t.IsInterface && !t.IsSealed && !t.IsAbstract && typeof(Registry).IsAssignableFrom(t))
// // .Select(s => s.Assembly.CreateInstance(s.FullName) as Registry)?.ToArray();
//// 注册同步服务
//JobManager.Initialize(registrys);
}
}
}
// //// 注册同步服务
// //JobManager.Initialize(registrys);
// }
// }
//}
......@@ -373,7 +373,6 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
/// <summary>
/// 批量新增用户表头
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("GetBatchUserStructrue")]
[HttpPost]
......@@ -387,7 +386,6 @@ public ApiResponse GetBatchUserStructrue()
/// <summary>
/// 批量新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("BatchSaveUser")]
[HttpPost]
......
using FluentValidation.AspNetCore;
using Hangfire;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.ExtractExcelService;
using System;
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
......@@ -34,14 +27,14 @@ public class AgainAllotController : Controller
private ComputeService computeService;
private ClaimService claimService;
private AllotService allotService;
private IHostingEnvironment env;
private IWebHostEnvironment env;
private ConfigService configService;
private Application application;
public AgainAllotController(AgainAllotService againAllotService,
RoleService roleService,
ClaimService claimService,
AllotService allotService,
IHostingEnvironment env,
IWebHostEnvironment env,
ConfigService configService,
ComputeService computeService,
IOptions<Application> options)
......@@ -171,7 +164,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
/// <returns></returns>
[Route("detail")]
[HttpPost]
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request)
{
var result = againAllotService.Detail(request);
return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport });
......
using FluentValidation.AspNetCore;
using MassTransit;
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.Hosting;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.Infrastructure;
......@@ -18,7 +19,6 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
......@@ -30,7 +30,7 @@ public class AllotController : Controller
private AllotService _allotService;
private ResultComputeService _resultComputeService;
private ConfigService _configService;
private IHostingEnvironment _evn;
private IWebHostEnvironment _evn;
private ILogger<AllotController> _logger;
private ClaimService _claim;
private LogManageService _logManageService;
......@@ -42,7 +42,7 @@ public class AllotController : Controller
ResultComputeService resultComputeService,
ConfigService configService,
ILogger<AllotController> logger,
IHostingEnvironment evn,
IWebHostEnvironment evn,
IBackgroundTaskQueue backgroundTaskQueue,
IServiceScopeFactory serviceScopeFactory,
ClaimService claim,
......@@ -247,7 +247,7 @@ public ApiResponse ImportExtraction(int allotId)
/// <returns></returns>
[Route("generate")]
[HttpPost]
public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] AllotRequest request)
public ApiResponse GenerateAsync([CustomizeValidator(RuleSet = "Delete"), FromBody] AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path))
......@@ -257,14 +257,12 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
_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"))
{
_allotService.Generate(allot);
}
else
{
//BackgroundJob.Schedule(() => _allotService.Generate(allot, email), TimeSpan.FromSeconds(1));
//if (_evn.IsEnvironment("Localhost"))
//{
// _allotService.Generate(allot);
//}
//else
//{
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
......@@ -274,7 +272,9 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
}
//_publishEndpoint.Publish(allot).Wait();
//}
_logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
//_allotService.Generate(allot, email);
......@@ -297,15 +297,8 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB
if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.GenerateReport(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
//_publishEndpoint.Publish(allot).Wait();
return new ApiResponse(ResponseType.OK, "统计报表数据任务开始");
}
......@@ -423,7 +416,7 @@ public ApiResponse Issued([FromBody] AllotRequest request)
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
// 科室下发
bool isIssued = false;
var result = _resultComputeService.IssuedPrompt(allot, request, ref isIssued);
......@@ -434,7 +427,7 @@ public ApiResponse Issued([FromBody] AllotRequest request)
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
costTransferService.RejectedApplicat(allot.ID);
}
return new ApiResponse(ResponseType.OK, result);
}
......
......@@ -834,7 +834,6 @@ public ApiResponse LoadTheLastTime([FromBody] CopyRequest request)
/// <summary>
/// 下拉
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("copydropdown")]
public ApiResponse CopyDropDown()
......@@ -846,7 +845,7 @@ public ApiResponse CopyDropDown()
new CopyDrop{Label="收入费用类别",Value="drugTypes"},
new CopyDrop{Label="支出费用类别",Value="drugTypeDisburses"},
new CopyDrop{Label="费用类别系数",Value="drugTypeFactors"},
new CopyDrop{Label="科室类型",Value="deptTypes"},
/* new CopyDrop{Label="科室类型",Value="deptTypes"},*/
new CopyDrop{Label="二次绩效配置",Value="agains"},
new CopyDrop{Label="核算单元及组别",Value="accountings"},
}; ;
......
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.EntityModels;
......@@ -21,12 +20,12 @@ public class EmployeeController : Controller
private EmployeeService employeeService;
private AllotService allotService;
private ClaimService claim;
private IHostingEnvironment evn;
private IWebHostEnvironment evn;
private readonly RoleService roleService;
private readonly UserService userService;
public EmployeeController(EmployeeService employeeService, AllotService allotService,
ClaimService claim, IHostingEnvironment evn, RoleService roleService,
ClaimService claim, IWebHostEnvironment evn, RoleService roleService,
UserService userService)
{
this.employeeService = employeeService;
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.ExtractExcelService;
using System;
using System.IO;
using System.Linq;
namespace Performance.Api.Controllers
{
......@@ -20,11 +17,11 @@ public class HistoryController : ControllerBase
{
private readonly HistoryService historyService;
private readonly ClaimService claim;
private readonly IHostingEnvironment evn;
private readonly IWebHostEnvironment evn;
public HistoryController(
HistoryService historyService,
ClaimService claim,
IHostingEnvironment evn)
IWebHostEnvironment evn)
{
this.historyService = historyService;
this.claim = claim;
......
......@@ -21,22 +21,19 @@ public class ModExtractController : Controller
private readonly CustomExtractService _extractService;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IHubNotificationQueue _notificationQueue;
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
public ModExtractController(
ClaimService claim,
AllotService allotService,
CustomExtractService extractService,
IServiceScopeFactory serviceScopeFactory,
IHubNotificationQueue notificationQueue,
IBackgroundTaskQueue backgroundTaskQueue)
IHubNotificationQueue notificationQueue)
{
_claim = claim;
_allotService = allotService;
_extractService = extractService;
_serviceScopeFactory = serviceScopeFactory;
_notificationQueue = notificationQueue;
_backgroundTaskQueue = backgroundTaskQueue;
}
[HttpPost("custom/{allotId}")]
......@@ -46,27 +43,27 @@ public ApiResponse CustomExtract(int allotId)
if (!_extractService.CheckConfigScript(userId, allotId))
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
//_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
//{
// using (var scope = _serviceScopeFactory.CreateScope())
// {
// var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
// var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
// 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, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
}
// 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, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
// }
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
// await Task.Delay(TimeSpan.FromSeconds(5), token);
// }
//});
_notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
......
......@@ -218,7 +218,7 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R
var list = reportService.MenuReport(request);
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
/// 菜单报表
/// </summary>
/// <param name="request"></param>
......
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.EntityModels;
......@@ -8,10 +7,8 @@
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.Api.Controllers
{
......@@ -19,12 +16,12 @@ namespace Performance.Api.Controllers
[Route("api/{hospitalId}/report/global")]
public class ReportGlobalController : Controller
{
private readonly IHostingEnvironment env;
private readonly IWebHostEnvironment env;
private readonly AllotService allotService;
private readonly ReportGlobalService reportGlobalService;
public ReportGlobalController(
IHostingEnvironment env,
IWebHostEnvironment env,
AllotService allotService,
ReportGlobalService reportGlobalService
)
......
......@@ -2,7 +2,6 @@
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;
......@@ -27,7 +26,7 @@ namespace Performance.Api.Controllers
public class TemplateController : Controller
{
private readonly ILogger logger;
private readonly IHostingEnvironment env;
private readonly IWebHostEnvironment env;
private readonly ClaimService claim;
private readonly WebapiUrl url;
private readonly Application application;
......@@ -41,7 +40,7 @@ public class TemplateController : Controller
public TemplateController(
ILogger<ExceptionsFilter> logger,
IHostingEnvironment env,
IWebHostEnvironment env,
ClaimService claim,
IOptions<WebapiUrl> url,
IOptions<Application> options,
......@@ -296,7 +295,7 @@ public ApiResponse PrejudgeLog([FromRoute] int allotId)
var allot = allotService.GetAllot(allotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
var result=logService.GetLogDbug(allotId);
var result = logService.GetLogDbug(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.Infrastructure;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Api
......@@ -21,9 +16,9 @@ public class ActionsFilter : IAsyncActionFilter
{
private readonly ILogger<ActionsFilter> _logger;
private readonly IMemoryCache _cache;
private readonly IHostingEnvironment _env;
private readonly IWebHostEnvironment _env;
public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnvironment env)
public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IWebHostEnvironment env)
{
this._logger = factory.CreateLogger<ActionsFilter>();
this._cache = cache;
......@@ -38,7 +33,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
var req = new { request.Path, request.Method, context.ActionArguments, Token = authorization.Count > 0 ? authorization.First() : "" };
_logger.LogInformation($"请求内容 {JsonHelper.Serialize(req)}");
//启用body倒带功能
request.EnableRewind();
request.EnableBuffering();
//接口禁用
if (context.Filters.Any(item => item is ApiDisableAttribute))
......
......@@ -37,8 +37,8 @@ public Task OnExceptionAsync(ExceptionContext context)
}
else
{
_logger.LogError($"接口异常:{context.Exception.ToString()}");
var response = new ApiResponse(ResponseType.Error, "接口内部异常", context.Exception.Message);
_logger.LogError($"接口异常:{context.Exception}");
var response = new ApiResponse(ResponseType.Error, "服务器繁忙,请稍后再试...", context.Exception.Message);
context.Result = new ObjectResult(response);
_logger.LogError("接口内部异常" + JsonHelper.Serialize(response));
}
......
using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using Performance.Services.ExtractExcelService;
namespace Performance.Api
{
public class ExtractDataJob : IJob
{
private readonly ExtractJobService extractJobService;
{
public ExtractDataJob()
private readonly ExtractJobService _extractJobService;
public ExtractDataJob(ExtractJobService extractJobService)
{
this.extractJobService = ServiceLocator.Instance.GetService<ExtractJobService>();
_extractJobService = extractJobService;
}
public void Execute()
{
extractJobService.Execute();
_extractJobService.Execute();
}
}
}
using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using Performance.Services.ExtractExcelService;
namespace Performance.Api
{
public class ExtractGenerateJob : IJob
{
private readonly ExtractJobService extractJobService;
private readonly ExtractJobService _extractJobService;
public ExtractGenerateJob()
public ExtractGenerateJob(ExtractJobService extractJobService)
{
this.extractJobService = ServiceLocator.Instance.GetService<ExtractJobService>();
_extractJobService = extractJobService;
}
public void Execute()
{
extractJobService.ExportFile();
_extractJobService.ExportFile();
}
}
}
using FluentScheduler;
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
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
{
public class JobRegistry : Registry
{
public JobRegistry()
public JobRegistry(IServiceProvider provider)
{
//Schedule<ExtractDataJob>().ToRunNow().AndEvery(1).Days().At(23, 0);
//Schedule<ExtractDataJob>().ToRunEvery(1).Days().At(23, 0);
Schedule<ExtractGenerateJob>().ToRunEvery(1).Days().At(23, 00);
Schedule(() => provider.GetService<ExtractGenerateJob>()).ToRunEvery(1).Days().At(23, 00);
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath />
<DocumentationFile>..\Performance.Api\wwwroot\Performance.Api.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath />
<DocumentationFile>..\Performance.Api\wwwroot\Performance.Api.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="aaa\**" />
<Compile Remove="Files\**" />
<Compile Remove="Hubs\**" />
<Content Remove="aaa\**" />
<Content Remove="Files\**" />
<Content Remove="Hubs\**" />
<EmbeddedResource Remove="aaa\**" />
<EmbeddedResource Remove="Files\**" />
<EmbeddedResource Remove="Hubs\**" />
<None Remove="aaa\**" />
<None Remove="Files\**" />
<None Remove="Hubs\**" />
</ItemGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<UserSecretsId>e732666b-5531-4cd8-b713-2fe3db31126c</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<None Remove="Template\~%24医院绩效模板.xlsx" />
</ItemGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<UserSecretsId>e732666b-5531-4cd8-b713-2fe3db31126c</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="FluentScheduler" Version="5.5.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="Hangfire" Version="1.6.22" />
<PackageReference Include="Hangfire.MySql.Core" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="NLog" Version="4.5.11" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Files\**" />
<Content Remove="Files\**" />
<EmbeddedResource Remove="Files\**" />
<None Remove="Files\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.EntityModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.EntityModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="Template\东方医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院人员绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板%28无执行科室%29.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Template\东方医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院人员绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板%28无执行科室%29.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\导入数据模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\导入数据模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
<ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JSONSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project>
......@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishUrl>D:\publish\jx.suvalue.com2</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
......
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
\ No newline at end of file
using FluentValidation;
using FluentScheduler;
using FluentValidation;
using FluentValidation.AspNetCore;
using MassTransit;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Performance.Api.Configurations;
using Performance.Infrastructure;
using Performance.Services;
......@@ -40,19 +45,20 @@ public void ConfigureServices(IServiceCollection services)
#region json & fluentvalidation & filter
services
.AddMvc(option =>
.AddControllers(option =>
{
//筛选器配置
option.Filters.Add<AuthenticationFilter>();
// 控制器访问添加认证
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
option.Filters.Add(new AuthorizeFilter(policy));
option.Filters.Add<ActionsFilter>();
option.Filters.Add<ExceptionsFilter>();
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddJsonOptions(JsonOptions) //json格式配置
.AddNewtonsoftJson(JsonOptions) //json格式配置
.AddFluentValidation(fv =>
{
// model验证,禁用其他以使FluentValidation是唯一执行的验证库
fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
//// model验证,禁用其他以使FluentValidation是唯一执行的验证库
//fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
var assembly = Assembly.Load("Performance.DtoModels");
var types = ReflectionHelper.GetInstances<IValidator>(assembly);
......@@ -64,6 +70,8 @@ public void ConfigureServices(IServiceCollection services)
#endregion json & fluentvalidation & filter
services.AddAuthenticationConfiguration(Configuration);
// dbcontext
services.AddDatabaseConfiguration();
......@@ -88,12 +96,13 @@ public void ConfigureServices(IServiceCollection services)
});
});
// fluentscheduler
services.AddFluentSchedulerConfiguration();
services.AddTransient<ExtractGenerateJob>();
services.AddTransient<ExtractDataJob>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
......@@ -103,19 +112,28 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStatusCodePagesWithReExecute("/error/{0}");
}
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<RequestRateLimitingMiddleware>();
app.UseCors("SignalrCore");
app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/performance/allotLogHub"));
app.UseMvc();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AllotLogHub>("/performance/allotLogHub");
endpoints.MapControllers();
});
app.UseSwaggerSetup(Configuration);
JobManager.Initialize(new JobRegistry(app.ApplicationServices));
}
private void JsonOptions(MvcJsonOptions json)
private void JsonOptions(MvcNewtonsoftJsonOptions json)
{
json.SerializerSettings.Converters.Add(new IsoDateTimeConverterContent() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
......
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Api
{
......
......@@ -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_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_test_srfy;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"
},
......
......@@ -141,14 +141,12 @@
<summary>
批量新增用户表头
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.BatchSaveUser(Performance.DtoModels.UserCollectData)">
<summary>
批量新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="T:Performance.Api.Controllers.AgainAllotController">
......@@ -225,7 +223,7 @@
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.Generate(Performance.DtoModels.AllotRequest)">
<member name="M:Performance.Api.Controllers.AllotController.GenerateAsync(Performance.DtoModels.AllotRequest)">
<summary>
绩效生成
</summary>
......@@ -854,7 +852,6 @@
<summary>
下拉
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.CustomHeads(Performance.DtoModels.CustomPagingRequest)">
......@@ -1623,7 +1620,13 @@
<param name="request"></param>
<returns></returns>
</member>
<!-- Badly formed XML comment ignored for member "M:Performance.Api.Controllers.ReportController.Operation(Performance.DtoModels.ReportRequest)" -->
<member name="M:Performance.Api.Controllers.ReportController.Operation(Performance.DtoModels.ReportRequest)">
<summary>
菜单报表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.TableNormal(Performance.DtoModels.ConditionRequest)">
<summary>
绩效汇报表
......
......@@ -131,7 +131,7 @@
<summary> 绩效库 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.NoData">
<summary> 用户状态 </summary>
<summary> 数据未上传 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.FileUploaded">
<summary> 数据已上传 </summary>
......@@ -3527,21 +3527,11 @@
菜单状态 1 启用 2禁用
</summary>
</member>
<member name="P:Performance.DtoModels.OwnerPerformanceDto.ShouldGiveFee">
<summary>
应发绩效
</summary>
</member>
<member name="P:Performance.DtoModels.OwnerPerformanceDto.ReservedRatio">
<summary>
预留比例
</summary>
</member>
<member name="P:Performance.DtoModels.OwnerPerformanceDto.ReservedRatioFee">
<summary>
预留金额
</summary>
</member>
<member name="P:Performance.DtoModels.OwnerPerformanceDto.RealGiveFee">
<summary>
实发绩效
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>
......@@ -47,7 +47,7 @@ public enum DbSrouceType
public enum AllotStates
{
/// <summary> 用户状态 </summary>
/// <summary> 数据未上传 </summary>
[Description("数据未上传")]
NoData = 0,
/// <summary> 数据已上传 </summary>
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......@@ -12,11 +12,7 @@
<ItemGroup>
<Compile Remove="PerExcel\PerComputeData.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
......
......@@ -12,6 +12,6 @@ public class IssuedPromptResponse : ag_secondallot
/// <summary>
/// 1 删除 2 驳回 3 修改 4 新增
/// </summary>
public new int IssueStatus { get; set; }
public int IssueStatus { get; set; }
}
}
......@@ -8,18 +8,10 @@ public class OwnerPerformanceDto : view_allot_result
{
public IEnumerable<OwnerPerformanceDto> Detail { get; set; }
/// <summary>
/// 应发绩效
/// </summary>
public decimal? ShouldGiveFee { get; set; }
/// <summary>
/// 预留比例
/// </summary>
public decimal? ReservedRatio { get; set; }
/// <summary>
/// 预留金额
/// </summary>
public decimal? ReservedRatioFee { get; set; }
/// <summary>
/// 实发绩效
/// </summary>
public decimal RealGiveFee { get; set; }
......
......@@ -19,7 +19,7 @@ public class UserCollectData
public int HospitalId { get; set; }
public int? CreateUser { get; set; }
public string[] ColHeaders { get; set; }
public new string[][] Data { get; set; }
public string[][] Data { get; set; }
}
public class SaveCustomData
......@@ -27,7 +27,7 @@ public class SaveCustomData
public int AllotId { get; set; }
public string TableName { get; set; }
public string[] ColHeaders { get; set; }
public new string[][] Data { get; set; }
public string[][] Data { get; set; }
}
public class SaveGatherData
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\Performance.Api\wwwroot\Performance.EntityModels.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="T4Template\**" />
<EmbeddedResource Remove="T4Template\**" />
<None Remove="T4Template\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Entity\dis_drugatc.Generated.cs" />
<Compile Remove="Entity\dis_drug_tree.Generated.cs" />
<Compile Remove="Entity\dis_drug_type.Generated.cs" />
<Compile Remove="Entity\dis_drug_useinfo_fee.Generated.cs" />
<Compile Remove="Entity\dis_ip_fee.Generated.cs" />
<Compile Remove="Entity\dis_use_drugs.Generated.cs" />
<Compile Remove="Entity\drug_department_useinfo.Generated.cs" />
<Compile Remove="Entity\drug_dosage.Generated.cs" />
<Compile Remove="Entity\drug_first_use.Generated.cs" />
<Compile Remove="Entity\drug_hosinfo.Generated.cs" />
<Compile Remove="Entity\drug_p_info.Generated.cs" />
<Compile Remove="Entity\drug_p_mi.Generated.cs" />
<Compile Remove="Entity\drug_p_userinfo.Generated.cs" />
<Compile Remove="Entity\drug_som.Generated.cs" />
<Compile Remove="Entity\hos_department_coc.Generated.cs" />
<Compile Remove="Entity\hos_department_fee.Generated.cs" />
<Compile Remove="Entity\hos_disease_person.Generated.cs" />
<Compile Remove="Entity\hos_drugatc.Generated.cs" />
<Compile Remove="Entity\hos_drug_fee.Generated.cs" />
<Compile Remove="Entity\hos_drug_type.Generated.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoContext.tt</DependentUpon>
</Compile>
<Compile Update="T4\AutoEntity.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoEntity.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoContext.cs</LastGenOutput>
</None>
<None Update="T4\AutoEntity.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoEntity.cs</LastGenOutput>
</None>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\Performance.Api\wwwroot\Performance.EntityModels.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.1" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.2.15" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoContext.tt</DependentUpon>
</Compile>
<Compile Update="T4\AutoEntity.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoEntity.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoContext.cs</LastGenOutput>
</None>
<None Update="T4\AutoEntity.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoEntity.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
......@@ -16,13 +16,13 @@ namespace Performance.Extract.Api.Controllers
[Route("api/[controller]")]
public class ExtractController : Controller
{
private readonly IHostingEnvironment evn;
private readonly IWebHostEnvironment evn;
private readonly ILogger logger;
private readonly WebapiUrl options;
private readonly ExtractService extractService1;
public ExtractController(
IHostingEnvironment evn,
IWebHostEnvironment evn,
ILogger<ExtractController> logger,
IOptions<WebapiUrl> options,
ExtractService extractService1)
......
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>3af57781-f816-4c0e-ab66-9b69387e7d35</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Files\**" />
<Content Remove="Files\**" />
<EmbeddedResource Remove="Files\**" />
<None Remove="Files\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.5.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\Performance.Api\Template\医院二次分配绩效模板.xlsx" Link="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Performance.Api\Template\医院绩效模板.xlsx" Link="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Template\东方医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>3af57781-f816-4c0e-ab66-9b69387e7d35</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\Performance.Api\Template\医院二次分配绩效模板.xlsx" Link="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Performance.Api\Template\医院绩效模板.xlsx" Link="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.6.6" />
</ItemGroup>
<ItemGroup>
<None Update="Template\东方医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JSONSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project>
......@@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NLog.Web;
namespace Performance.Extract.Api
{
......@@ -14,11 +15,37 @@ public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
CreateWebHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
throw;
}
finally
{
NLog.LogManager.Shutdown();
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
.ConfigureAppConfiguration((context, config) =>
{
var env = context.HostingEnvironment;
config.AddJsonFile("appsettings.json", true, true);
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true);
})
.UseStartup<Startup>()
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog();
}
}
using AutoMapper;
using CSRedis;
using FluentValidation;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Builder;
......@@ -7,6 +8,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NLog.Extensions.Logging;
......@@ -16,21 +18,16 @@
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Extract.Api
{
public class Startup
{
public Startup(IConfiguration configuration, IHostingEnvironment env)
public Startup(IConfiguration configuration)
{
env.ConfigureNLog("nlog.config");
Configuration = configuration;
}
......@@ -55,13 +52,11 @@ public void ConfigureServices(IServiceCollection services)
#region json & fluentvalidation & filter
services
//筛选器配置
.AddMvc(option =>
.AddControllers(option =>
{
option.Filters.Add<ExceptionsFilter>();
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
//json格式配置
.AddJsonOptions(json =>
.AddNewtonsoftJson(json =>
{
json.SerializerSettings.Converters.Add(new IsoDateTimeConverterContent() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
......@@ -94,15 +89,8 @@ public void ConfigureServices(IServiceCollection services)
.AddPerformanceRepoitory();
#endregion
#region automapper
Mapper.Initialize(cfg => cfg.AddProfile<AutoMapperConfigs>());
services.AddAutoMapper();
#endregion
#region redis
var csredis = new CSRedis.CSRedisClient(connection.Value.RedisConnectionString);
RedisHelper.Initialization(csredis);
#endregion
services.AddAutoMapper(typeof(AutoMapperConfigs));
RedisHelper.Initialization(new CSRedisClient(connection.Value.RedisConnectionString));
#region email
......@@ -118,13 +106,10 @@ public void ConfigureServices(IServiceCollection services)
#endregion
#region //ef配置
services.AddDbContext<PerformanceDbContext>(options =>
{
options.UseMySQL(connection.Value.PerformanceConnectionString);
options.UseMySql(connection.Value.PerformanceConnectionString, ServerVersion.AutoDetect(connection.Value.PerformanceConnectionString));
});
#endregion
services.AddSignalR();
services.AddCors(options =>
{
......@@ -136,20 +121,21 @@ public void ConfigureServices(IServiceCollection services)
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddNLog();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors("SignalrCore");
app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/allotLogHub"));
loggerFactory.CreateLogger<Startup>().LogDebug(env.EnvironmentName);
app.UseMvc();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<AllotLogHub>("/allotLogHub");
});
}
}
}
......@@ -170,7 +170,7 @@ public static bool CreateFile(string filePath, byte[] buffer)
fs.Close();
}
}
catch (Exception ex)
catch (Exception)
{
return false;
}
......
......@@ -60,9 +60,9 @@ public static string HttpPost(string Url, string postDataStr, string encoding =
return retString;
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
......@@ -149,9 +149,9 @@ public static void HttpPostNoRequest(string Url, string postDataStr, bool IsJson
request.GetResponseAsync();
Thread.Sleep(1000);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
......@@ -188,9 +188,9 @@ public static string HttpClient(string url, string file, bool IsAsync = false)
client.UploadFileAsync(new Uri(url), "POST", file);
return "";
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
......@@ -219,9 +219,9 @@ public static string HttpPost(string url, int timeout = -1, Dictionary<string, s
IRestResponse response = client.Execute(request);
return response.Content;
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="RestSharp" Version="106.11.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.1" />
<PackageReference Include="RestSharp" Version="106.13.0" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.2.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="10.3.3" />
<PackageReference Include="EPPlus" Version="4.5.3.2" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.10" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
<PackageReference Include="NPOI" Version="2.5.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.2.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http.abstractions\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Http.Features">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http.features\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Mvc.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.abstractions\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http.abstractions\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Http.Features">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http.features\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Mvc.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.abstractions\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
......@@ -92,7 +92,7 @@ public bool RemoveRange(params TEntity[] entities)
public bool RemoveRange(Expression<Func<TEntity, bool>> exp)
{
var query = CompileQuery(exp);
var query = context.Set<TEntity>().AsQueryable().Where(exp);
var entities = query == null || query.Count() == 0 ? null : query.ToList();
if (entities != null)
context.Set<TEntity>().RemoveRange(entities);
......@@ -142,30 +142,17 @@ public List<TEntity> GetEntities()
public List<TEntity> GetEntities(Expression<Func<TEntity, bool>> exp)
{
var query = CompileQuery(exp);
return query == null || query.Count() == 0 ? null : query.ToList();
return context.Set<TEntity>().AsQueryable().Where(exp).ToList();
}
public List<TEntity> GetEntitiesForPaging(int Page, int pageSize, Expression<Func<TEntity, bool>> exp)
{
return CompileQuery(exp).Skip((Page - 1) * pageSize).Take(pageSize).ToList();
return context.Set<TEntity>().AsQueryable().Where(exp).Skip((Page - 1) * pageSize).Take(pageSize).ToList();
}
public TEntity GetEntity(Expression<Func<TEntity, bool>> exp)
{
return CompileQuerySingle(exp);
}
private IEnumerable<TEntity> CompileQuery(Expression<Func<TEntity, bool>> exp)
{
var func = EF.CompileQuery((DbContext context, Expression<Func<TEntity, bool>> exps) => context.Set<TEntity>().Where(exp));
return func(context, exp);
}
private TEntity CompileQuerySingle(Expression<Func<TEntity, bool>> exp)
{
var func = EF.CompileQuery((DbContext context, Expression<Func<TEntity, bool>> exps) => context.Set<TEntity>().FirstOrDefault(exp));
return func(context, exp);
return context.Set<TEntity>().AsQueryable().FirstOrDefault(exp);
}
#region Bulk
......@@ -204,5 +191,26 @@ public void BulkDelete(IEnumerable<TEntity> entities)
}
#endregion Bulk
public int InsertExecute(IEnumerable<TEntity> data)
{
if (data == null || !data.Any()) return 0;
try
{
string tableName = typeof(TEntity).Name.ToLower();
string database = context.Database.GetDbConnection().Database;
var query = $"select distinct lower(column_name) from information_schema.columns where table_schema = '{database}' and lower(table_name) = '{tableName}' and lower(column_name) <> 'id'";
var columns = DapperQuery<string>(query, new { });
if (columns == null || !columns.Any()) return 0;
var exec = $"insert into {tableName}({string.Join(", ", columns)}) values({string.Join(", ", columns.Select(t => "@" + t))});";
return Execute(exec, data, commandTimeout: 1000 * 60 * 60);
}
catch
{
return 0;
}
}
}
}
using MySql.Data.MySqlClient;
using Microsoft.Data.SqlClient;
using MySql.Data.MySqlClient;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Data;
using System.Data.SqlClient;
namespace Performance.Repository
{
......
......@@ -92,10 +92,10 @@ public bool ImportData(rep_importconfig import, Dictionary<string, object> pairs
transaction.Commit();
}
catch (Exception ex)
catch (Exception)
{
transaction.Rollback();
throw ex;
throw;
}
}
}
......@@ -129,9 +129,9 @@ public void ClearResultData(int allotid)
string clear = "delete from ex_result where allotid = @allotid and isdelete = 1 and createtime < (select min(createtime) from (select distinct createtime from ex_result where allotid = @allotid and isdelete = 1 order by createtime desc limit 4) t);";
connection.Execute(clear, new { allotid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......@@ -159,10 +159,10 @@ public void ImportWorkloadData(per_allot allot, object parameters)
transaction.Commit();
}
catch (Exception ex)
catch (Exception)
{
transaction.Rollback();
throw ex;
throw;
}
}
}
......@@ -187,9 +187,9 @@ FROM view_second_report_workload
ORDER BY doctorname,Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes = unittypes.Union(new string[] { "通用工作量" }), hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......@@ -217,9 +217,9 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittypes, hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......@@ -246,9 +246,9 @@ public IEnumerable<view_second_workload_result> GetSecondWorkload(int allotid, s
GROUP BY TAB1.HospitalId,AllotId,TAB1.UnitType,AccountingUnit,HISDeptName,ItemId,ItemName,FactorValue,DoctorName,PersonnelNumber,Category";
return connection.Query<view_second_workload_result>(query, new { allotid, unittype, accountingunit }, commandTimeout: 60 * 60);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......@@ -275,9 +275,9 @@ public IEnumerable<string> GetSecondWorkloadMaps(int hospitalId)
WHERE IFNULL(Category,'')<>''";
return connection.Query<string>(query, new { hospitalId }, commandTimeout: 60 * 60);
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
}
}
......
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.8.40" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoRepository.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoRepository.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoRepository.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoRepository.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoRepository.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoRepository.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoRepository.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoRepository.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>
......@@ -14,6 +14,7 @@ namespace Performance.Services
public class AgainAllotService : IAutoInjection
{
private Application application;
private readonly IMapper _mapper;
private AgainService againService;
private RoleService roleService;
private ConfigService configService;
......@@ -30,7 +31,10 @@ public class AgainAllotService : IAutoInjection
private PerforAgemployeeRepository perforAgemployeeRepository;
private PerforAgheaderRepository perforAgheaderRepository;
public AgainAllotService(IOptions<Application> options, AgainService againService,
public AgainAllotService(
IOptions<Application> options,
IMapper mapper,
AgainService againService,
RoleService roleService,
PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository,
......@@ -46,6 +50,7 @@ public class AgainAllotService : IAutoInjection
ConfigService configService)
{
this.application = options.Value;
_mapper = mapper;
this.againService = againService;
this.roleService = roleService;
this.perforCofagainRepository = perforCofagainRepository;
......@@ -197,24 +202,24 @@ public class AgainAllotService : IAutoInjection
// #region 保存
// var againsituation = Mapper.Map<ag_againsituation>(situation);
// var againsituation = _mapper.Map<ag_againsituation>(situation);
// againsituation.AllotID = againAllot.AllotID;
// againsituation.AgainAllotID = againAllot.ID;
// perforAgagainsituationRepository.Add(againsituation);
// var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// var employeeList = _mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgemployeeRepository.AddRange(employeeList.ToArray());
// var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header);
// var pHeader = _mapper.Map<ag_header>(perAgainExcel.Header);
// pHeader.AllotID = againAllot.AllotID;
// pHeader.AgainAllotID = againAllot.ID;
// var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// var cHeaderList = _mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgheaderRepository.Add(pHeader);
// perforAgheaderRepository.AddRange(cHeaderList.ToArray());
// var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// var dataList = _mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgdataRepository.AddRange(dataList.ToArray());
......@@ -314,27 +319,27 @@ public class AgainAllotService : IAutoInjection
throw new PerformanceException("绩效二次分配不存在");
var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID);
var againsituation = Mapper.Map<PerAgainSituation>(situation);
var againsituation = _mapper.Map<PerAgainSituation>(situation);
var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var employeeList = Mapper.Map<List<PerAgainEmployee>>(againEmployee);
//var employeeList = _mapper.Map<List<PerAgainEmployee>>(againEmployee);
var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var headerList = Mapper.Map<List<PerHeader>>(header);
//var headerList = _mapper.Map<List<PerHeader>>(header);
var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var dataList = Mapper.Map<List<PerAgainData>>(data);
//var dataList = _mapper.Map<List<PerAgainData>>(data);
var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
var head = Mapper.Map<PerHeader>(pHead);
var cHead = Mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
var head = _mapper.Map<PerHeader>(pHead);
var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
head.Children = cHead;
var perAgainExcel = new PerAgainExcel
{
Header = head,
AgainData = Mapper.Map<List<PerAgainData>>(data),
AgainEmployee = Mapper.Map<List<PerAgainEmployee>>(againEmployee)
AgainData = _mapper.Map<List<PerAgainData>>(data),
AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee)
};
return SheetFormat(perAgainExcel, againsituation);
......@@ -395,7 +400,7 @@ public List<AgainAllotResponse> GetAllotList(int userid)
}
again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
List<AgainAllotResponse> list = Mapper.Map<List<AgainAllotResponse>>(again);
List<AgainAllotResponse> list = _mapper.Map<List<AgainAllotResponse>>(again);
list.ForEach(t =>
{
var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
......
......@@ -16,6 +16,7 @@ namespace Performance.Services.AllotCompute
/// </summary>
public class ProcessComputService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly BudgetService _budgetService;
private PerforCofincomeRepository perforCofincomeRepository;
private PerforPersheetRepository perforPerSheetRepository;
......@@ -33,6 +34,7 @@ public class ProcessComputService : IAutoInjection
private readonly PerforPerallotRepository perallotRepository;
public ProcessComputService(
IMapper mapper,
BudgetService budgetService,
PerforCofincomeRepository perforCofincomeRepository,
PerforPersheetRepository perforPerSheetRepository,
......@@ -49,6 +51,7 @@ public class ProcessComputService : IAutoInjection
PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository)
{
_mapper = mapper;
_budgetService = budgetService;
this.perforCofincomeRepository = perforCofincomeRepository;
this.perforPerSheetRepository = perforPerSheetRepository;
......@@ -101,7 +104,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
List<res_account> addList = new List<res_account>();
foreach (var data in dataList)
{
var imdata = Mapper.Map<res_account>(data);
var imdata = _mapper.Map<res_account>(data);
imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId;
addList.Add(imdata);
......@@ -123,7 +126,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
List<im_header> addHeadList = new List<im_header>();
foreach (var header in sheet.PerHeader)
{
var imheader = Mapper.Map<im_header>(header);
var imheader = _mapper.Map<im_header>(header);
imheader.SheetID = imsheet.ID;
imheader.AllotID = allotId;
perforImHeaderRepository.Add(imheader);
......@@ -131,7 +134,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
{
foreach (var child in header.Children)
{
var imheaderChild = Mapper.Map<im_header>(child);
var imheaderChild = _mapper.Map<im_header>(child);
imheaderChild.SheetID = imsheet.ID;
imheaderChild.ParentID = imheader.ID;
imheaderChild.AllotID = allotId;
......@@ -145,7 +148,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
var dataList = sheet.PerData.Select(t => (PerData)t);
foreach (var data in dataList)
{
var imdata = Mapper.Map<im_data>(data);
var imdata = _mapper.Map<im_data>(data);
imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId;
addDataList.Add(imdata);
......@@ -429,7 +432,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
List<res_account> addList = new List<res_account>();
foreach (var data in perDatas)
{
var imdata = Mapper.Map<res_account>(data);
var imdata = _mapper.Map<res_account>(data);
imdata.AllotID = allot.ID;
addList.Add(imdata);
}
......
......@@ -12,6 +12,7 @@ namespace Performance.Services.AllotCompute
{
public class QueryDataService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly LogManageService logManageService;
private readonly PerforPersheetRepository persheetRepository;
private readonly PerforImemployeeRepository imemployeeRepository;
......@@ -21,7 +22,9 @@ public class QueryDataService : IAutoInjection
private readonly PerforImdataRepository imdataRepository;
private readonly PerforImheaderRepository imheaderRepository;
public QueryDataService(LogManageService logManageService,
public QueryDataService(
IMapper mapper,
LogManageService logManageService,
PerforPersheetRepository persheetRepository,
PerforImemployeeRepository imemployeeRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository,
......@@ -30,6 +33,7 @@ public class QueryDataService : IAutoInjection
PerforImdataRepository imdataRepository,
PerforImheaderRepository imheaderRepository)
{
_mapper = mapper;
this.logManageService = logManageService;
this.persheetRepository = persheetRepository;
this.imemployeeRepository = imemployeeRepository;
......@@ -121,7 +125,7 @@ private PerExcel Query(List<per_sheet> sheets, int allotId)
private void QueryEmployee(int allotId, int sheetId, PerSheet sheet)
{
var data = imemployeeRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId);
var sheetData = Mapper.Map<List<PerDataEmployee>>(data);
var sheetData = _mapper.Map<List<PerDataEmployee>>(data);
if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData);
}
......@@ -129,7 +133,7 @@ private void QueryEmployee(int allotId, int sheetId, PerSheet sheet)
private void QueryClinicEmployee(int allotId, int sheetId, PerSheet sheet)
{
var data = imemployeeclinicRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId);
var sheetData = Mapper.Map<List<PerDataClinicEmployee>>(data);
var sheetData = _mapper.Map<List<PerDataClinicEmployee>>(data);
if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData);
}
......@@ -137,7 +141,7 @@ private void QueryClinicEmployee(int allotId, int sheetId, PerSheet sheet)
private void QueryAccountBasic(int allotId, int sheetId, PerSheet sheet)
{
var data = imaccountbasicRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId);
var sheetData = Mapper.Map<List<PerDataAccountBaisc>>(data);
var sheetData = _mapper.Map<List<PerDataAccountBaisc>>(data);
if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData);
}
......@@ -145,7 +149,7 @@ private void QueryAccountBasic(int allotId, int sheetId, PerSheet sheet)
private void QuerySpecialUnit(int allotId, int sheetId, PerSheet sheet)
{
var data = imspecialunitRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId);
var sheetData = Mapper.Map<List<PerDataSpecialUnit>>(data);
var sheetData = _mapper.Map<List<PerDataSpecialUnit>>(data);
if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData);
}
......@@ -153,7 +157,7 @@ private void QuerySpecialUnit(int allotId, int sheetId, PerSheet sheet)
private void QueryCommon(int allotId, int sheetId, PerSheet sheet)
{
var data = imdataRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId);
var sheetData = Mapper.Map<List<PerData>>(data);
var sheetData = _mapper.Map<List<PerData>>(data);
if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData);
}
......@@ -169,7 +173,7 @@ private List<PerHeader> GetHeaderAndChild(List<im_header> headers, List<im_heade
{
foreach (var header in headers)
{
var perHeader = Mapper.Map<PerHeader>(header);
var perHeader = _mapper.Map<PerHeader>(header);
var children = allheaders.Where(t => t.ParentID == header.ID);
if (children != null && children.Any())
{
......
......@@ -23,6 +23,7 @@ public class ResultComputeService : IAutoInjection
private readonly PerforPerallotRepository perforPerallotRepository;
//private readonly PerforAgcomputeRepository perforAgcomputeRepository;
private readonly PerforAgsecondallotRepository perforAgsecondallotRepository;
private readonly IMapper _mapper;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforImemployeeRepository perforImEmployeeRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository;
......@@ -36,6 +37,7 @@ public class ResultComputeService : IAutoInjection
private readonly ILogger logger;
public ResultComputeService(
IMapper mapper,
PerforHospitalRepository hospitalRepository,
PerforImemployeeRepository perforImEmployeeRepository,
PerforRescomputeRepository perforRescomputeRepository,
......@@ -55,6 +57,7 @@ public class ResultComputeService : IAutoInjection
{
this.baiscNormService = baiscNormService;
this.computeDirector = computeDirector;
_mapper = mapper;
this.hospitalRepository = hospitalRepository;
this.perforImEmployeeRepository = perforImEmployeeRepository;
this.perforRescomputeRepository = perforRescomputeRepository;
......@@ -83,7 +86,7 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet)
var empolyeeList = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID);
var accountbasicList = perforImaccountbasicRepository.GetEntities(t => t.AllotID == allot.ID);
List<ComputeEmployee> computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList);
List<ComputeEmployee> computeEmployees = _mapper.Map<List<ComputeEmployee>>(empolyeeList);
logManageService.WriteMsg("正在生成绩效", "科室主任、护士长 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult = computeDirector.Compute(computeEmployees, accountSheet, allot);
......@@ -93,12 +96,12 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet)
baiscNormService.DocterNurseBaiscnorm(baiscnormList, accountbasicList, accountSheet);
var empolyeeList2 = perforImEmployeeRepository.GetEntities(t => t.AllotID == allot.ID);
var computeEmployees2 = Mapper.Map<List<ComputeEmployee>>(empolyeeList2);
var computeEmployees2 = _mapper.Map<List<ComputeEmployee>>(empolyeeList2);
logManageService.WriteMsg("正在生成绩效", "行政中高层 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult2 = computeDirector.Compute(computeEmployees2, allot, baiscnormList, accountbasicList);
var empolyeeList3 = perforImemployeelogisticsRepository.GetEntities(t => t.AllotID == allot.ID);
var computeEmployees3 = Mapper.Map<List<ComputeEmployee>>(empolyeeList3);
var computeEmployees3 = _mapper.Map<List<ComputeEmployee>>(empolyeeList3);
logManageService.WriteMsg("正在生成绩效", "行政后勤 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult3 = computeDirector.Compute(computeEmployees3, allot, baiscnormList, accountbasicList);
......@@ -107,9 +110,9 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet)
//计算 行政人员 平均值
baiscNormService.ComputeOtherAvg(baiscnormList, computResult3, empolyeeList3);
var computes = Mapper.Map<List<res_compute>>(computResult);
computes.AddRange(Mapper.Map<List<res_compute>>(computResult2));
computes.AddRange(Mapper.Map<List<res_compute>>(computResult3));
var computes = _mapper.Map<List<res_compute>>(computResult);
computes.AddRange(_mapper.Map<List<res_compute>>(computResult2));
computes.AddRange(_mapper.Map<List<res_compute>>(computResult3));
computes.ForEach(t => t.AllotID = allot.ID);
perforRescomputeRepository.AddRange(computes.ToArray());
......@@ -144,7 +147,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
var groupSpeList = dataList.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, Number = t.OrderBy(w => w.RowNumber).FirstOrDefault().Number, });
var empolyeeList = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType == UnitType.特殊核算组.ToString());
List<ComputeEmployee> computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList);
List<ComputeEmployee> computeEmployees = _mapper.Map<List<ComputeEmployee>>(empolyeeList);
List<ComputeResult> computeList = new List<ComputeResult>();
foreach (var group in groupSpeList)
......@@ -303,7 +306,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
computeList.Add(compute);
}
}
var computes = Mapper.Map<List<res_compute>>(computeList);
var computes = _mapper.Map<List<res_compute>>(computeList);
computes.ForEach(t => t.AllotID = allot.ID);
perforRescomputeRepository.AddRange(computes.ToArray());
perforResspecialunitRepository.AddRange(resDataList.ToArray());
......@@ -674,7 +677,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
if ((item.RealGiveFee ?? 0) == 0 && (item.PreRealGiveFee ?? 0) > 0)
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
var promptSecond = _mapper.Map<IssuedPromptResponse>(item);
promptSecond.RealGiveFee = item.PreRealGiveFee;
promptSecond.StatusRemake = "";
promptSecond.IssueStatus = 4;
......@@ -682,7 +685,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
}
else if (isDiffer && !status.Contains(item.Status.Value) && (IsOpen==true? !status.Contains(item.NursingDeptStatus.Value):true))
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
var promptSecond = _mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = $@"未提交科室实发绩效变更,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 3;
promptSecond.RealGiveFee = item.PreRealGiveFee;
......@@ -690,7 +693,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
}
else if (isDiffer && status.Contains(item.Status.Value) && (IsOpen==true? status.Contains(item.NursingDeptStatus.Value):true))
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
var promptSecond = _mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = $@"已提交或已审核科室实发绩效变更驳回,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 2;
promptSecond.RealGiveFee = item.PreRealGiveFee;
......@@ -707,7 +710,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
}
else if ((item.RealGiveFee ?? 0) >= 0 && (item.PreRealGiveFee ?? 0) == 0)
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
var promptSecond = _mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = "";
promptSecond.IssueStatus = 1;
promptSeconds.Add(promptSecond);
......
using AutoMapper;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
......@@ -12,9 +14,13 @@
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using Microsoft.Extensions.Caching.Memory;
namespace Performance.Services
{
......@@ -27,11 +33,13 @@ public class AllotService : IAutoInjection
private ResultComputeService resultComputeService;
private PerforLogdbugRepository logdbug;
private ConfigService configService;
private IHostingEnvironment _evn;
private IWebHostEnvironment _evn;
private ILogger<AllotService> _logger;
private readonly IMapper _mapper;
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private readonly IOptions<Application> options;
private readonly IOptions<AppConnection> _appConnection;
private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository;
......@@ -53,6 +61,7 @@ public class AllotService : IAutoInjection
private readonly QueryDataService queryDataService;
public AllotService(
IMapper mapper,
PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService,
CheckDataService checkDataService,
......@@ -61,9 +70,10 @@ public class AllotService : IAutoInjection
ResultComputeService resultComputeService,
ConfigService configService,
PerforLogdbugRepository logdbug,
IHostingEnvironment evn, ILogger<AllotService> logger,
IWebHostEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService,
IOptions<Application> options,
IOptions<AppConnection> appConnection,
ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository,
......@@ -82,6 +92,7 @@ public class AllotService : IAutoInjection
PerforPeremployeeRepository perforPeremployeeRepository,
QueryDataService queryDataService)
{
_mapper = mapper;
_allotRepository = allotRepository;
_againallotRepository = againallotRepository;
_logger = logger;
......@@ -93,6 +104,7 @@ public class AllotService : IAutoInjection
this.resultComputeService = resultComputeService;
this.emailService = emailService;
this.options = options;
_appConnection = appConnection;
_computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository;
......@@ -127,7 +139,7 @@ public List<AllotResponse> GetAllotList(int? hospitalId)
var allotList = _allotRepository.GetEntities(t => t.HospitalId == hospitalId);
allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList();
var isconfig = perforHospitalconfigRepository.GetEntity(t => t.HospitalId == hospitalId) == null ? false : true;
var result = Mapper.Map<List<AllotResponse>>(allotList);
var result = _mapper.Map<List<AllotResponse>>(allotList);
result?.ForEach(t =>
{
t.IsDown = !string.IsNullOrEmpty(t.ExtractPath);
......@@ -156,7 +168,7 @@ public List<AllotResponse> GetSuccAllotList(int? hospitalId)
&& new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States));
allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList();
var isconfig = perforHospitalconfigRepository.GetEntity(t => t.HospitalId == hospitalId) == null ? false : true;
var reuslt = Mapper.Map<List<AllotResponse>>(allotList);
var reuslt = _mapper.Map<List<AllotResponse>>(allotList);
reuslt?.ForEach(t =>
{
t.IsDown = !string.IsNullOrEmpty(t.ExtractPath);
......@@ -179,7 +191,7 @@ public per_allot InsertAllot(AllotRequest request, int userID)
if (repAllot != null && repAllot.Count() > 0)
throw new PerformanceException("当前绩效记录已存在");
var allot = Mapper.Map<per_allot>(request);
var allot = _mapper.Map<per_allot>(request);
allot.CreateDate = DateTime.Now;
allot.CreateUser = userID;
allot.States = (int)AllotStates.NoData;
......@@ -212,7 +224,7 @@ public AllotResponse UpdateAllot(AllotRequest request)
if (!_allotRepository.Update(allot))
throw new PerformanceException("保存失败");
return Mapper.Map<AllotResponse>(allot);
return _mapper.Map<AllotResponse>(allot);
}
/// <summary>
......@@ -309,7 +321,6 @@ public per_allot UpdateAllotShowFormula(int allotId)
/// <param name="user"></param>
public void Generate(per_allot allot)
{
DateTime time = DateTime.Now;
try
{
logManageService.WriteMsg("绩效开始执行", $"正在生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage", true);
......@@ -464,7 +475,6 @@ public void Generate(per_allot allot)
catch (Exception ex)
{
logManageService.WriteMsg("绩效生成失败", ex.Message, 4, allot.ID, "ReceiveMessage");
logdbug.Add(allot.ID, "绩效生成失败", ex.ToString(), 4, 1);
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail));
//SendEmail(allot, mail, 2, time);
//throw ex;
......@@ -486,7 +496,10 @@ public void GenerateReport(per_allot allot)
/// <param name="allot"></param>
public void AccoungtingVerify(int allotId)
{
reportService.ExecProc("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId });
using (IDbConnection connection = new MySqlConnection(_appConnection.Value.PerformanceConnectionString))
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId });
}
}
/// <summary>
......@@ -502,7 +515,7 @@ public void Recalculation(int allotId, decimal money)
if (empolyeeList == null) return;
var computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList);
var computeEmployees = _mapper.Map<List<ComputeEmployee>>(empolyeeList);
computeEmployees.ForEach(w => w.FitPeopleValue = money);
List<res_baiscnorm> baiscnormList = new List<res_baiscnorm>();
......@@ -517,7 +530,7 @@ public void Recalculation(int allotId, decimal money)
if (historyRescompute != null && historyRescompute.Any())
_perforRescomputeRepository.RemoveRange(historyRescompute.ToArray());
var computes = Mapper.Map<List<res_compute>>(computResult);
var computes = _mapper.Map<List<res_compute>>(computResult);
computes.ForEach(t => t.AllotID = allot.ID);
_perforRescomputeRepository.AddRange(computes.ToArray());
......@@ -525,7 +538,7 @@ public void Recalculation(int allotId, decimal money)
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));
perforResbaiscnormRepository.AddRange(_mapper.Map<res_baiscnorm[]>(baiscnormList));
}
/// <summary>
......@@ -595,7 +608,7 @@ public void Pigeonhole(per_allot allot)
public List<AgainAllotResponse> GetAgainAllotNotSucceed(per_allot allot)
{
var again = _againallotRepository.GetEntities(t => t.AllotID == allot.ID && (!t.States.HasValue || t.States.Value != 3));
List<AgainAllotResponse> result = Mapper.Map<List<AgainAllotResponse>>(again);
List<AgainAllotResponse> result = _mapper.Map<List<AgainAllotResponse>>(again);
if (result != null && result.Count > 0)
{
result.ForEach(t => { t.Year = allot.Year; t.Month = allot.Month; });
......@@ -711,7 +724,7 @@ public List<OwnerPerformanceDto> GetOwnerPerformance(int userid)
.Where(p => p.Year == w.Key.Year && p.Month == w.Key.Month && p.JobNumber == w.Key.JobNumber)
.Select(detial =>
{
var dto = Mapper.Map<OwnerPerformanceDto>(detial);
var dto = _mapper.Map<OwnerPerformanceDto>(detial);
dto.Source = string.IsNullOrEmpty(detial.SourceItem) ? detial.Source : $"{detial.Source}-{detial.SourceItem}";
// 应发绩效
dto.ShouldGiveFee = Math.Round((dto.RealPerformance ?? 0) + (dto.OtherPerfor ?? 0) + (dto.HideOtherPerfor ?? 0) + (dto.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero);
......
......@@ -14,18 +14,22 @@ namespace Performance.Services
{
public class BudgetService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly PerforPerbudgetamountRepository perbudgetamountRepository;
private readonly PerforPerbudgetratioRepository perbudgetratioRepository;
private readonly PerforPerbudgetresultRepository perbudgetresultRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly ILogger logger;
public BudgetService(PerforPerbudgetamountRepository perbudgetamountRepository,
public BudgetService(
IMapper mapper,
PerforPerbudgetamountRepository perbudgetamountRepository,
PerforPerbudgetratioRepository perbudgetratioRepository,
PerforPerbudgetresultRepository perbudgetresultRepository,
PerforPerallotRepository perallotRepository,
ILogger<BudgetService> logger)
{
_mapper = mapper;
this.perbudgetamountRepository = perbudgetamountRepository;
this.perbudgetratioRepository = perbudgetratioRepository;
this.perbudgetresultRepository = perbudgetresultRepository;
......@@ -43,12 +47,12 @@ public List<BudgetResponse> QueryBudgetByYear(int hospitalid, int year)
{
var amounts = perbudgetamountRepository.GetEntities(t => t.HospitalId == hospitalid && t.MainYear == year);
var ratios = perbudgetratioRepository.GetEntities(t => t.HospitalId == hospitalid && t.MainYear == year);
var result = Mapper.Map<List<BudgetResponse>>(amounts);
var result = _mapper.Map<List<BudgetResponse>>(amounts);
if (result == null)
return Mapper.Map<List<BudgetResponse>>(ratios);
return _mapper.Map<List<BudgetResponse>>(ratios);
else if (ratios != null && ratios.Any())
{
result.AddRange(Mapper.Map<List<BudgetResponse>>(ratios));
result.AddRange(_mapper.Map<List<BudgetResponse>>(ratios));
}
return result.OrderBy(t => t.Year).ToList();
}
......@@ -68,7 +72,7 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI
if (entity != null && entity.Any())
throw new PerformanceException($"{mainYear}年数据已存在");
var amounts = Mapper.Map<List<per_budget_amount>>(request.Where(t => t.Type == 1));
var amounts = _mapper.Map<List<per_budget_amount>>(request.Where(t => t.Type == 1));
amounts.ForEach(t =>
{
t.MainYear = mainYear;
......@@ -77,7 +81,7 @@ 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 ratios = _mapper.Map<List<per_budget_ratio>>(request.Where(t => t.Type == 2));
var budgetData = request.FirstOrDefault(t => t.Type == 2);
ratios.ForEach(t =>
{
......
......@@ -17,6 +17,7 @@ namespace Performance.Services
{
public class ComputeService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly PerforResaccountRepository perforResaccountRepository;
private readonly PerforPersheetRepository _perforPerSheetRepository;
private readonly PerforImdataRepository _perforImDataRepository;
......@@ -39,6 +40,7 @@ public class ComputeService : IAutoInjection
private readonly PerforReportRepository reportRepository;
public ComputeService(
IMapper mapper,
PerforResaccountRepository perforResaccountRepository,
PerforPersheetRepository perforPerSheetRepository,
PerforImdataRepository perforImDataRepository,
......@@ -60,6 +62,7 @@ public class ComputeService : IAutoInjection
PerforCofaliasRepository cofaliasRepository,
PerforReportRepository reportRepository)
{
_mapper = mapper;
this.perforResaccountRepository = perforResaccountRepository;
this._perforPerSheetRepository = perforPerSheetRepository;
this._perforImDataRepository = perforImDataRepository;
......@@ -170,7 +173,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
//}
//if (joinData == null || !joinData.Any()) return new List<ResComputeResponse>();
//data = Mapper.Map<List<ResComputeResponse>>(joinData);
//data = _mapper.Map<List<ResComputeResponse>>(joinData);
#endregion MyRegion
......@@ -180,7 +183,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
var computes = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && pairs[type].Contains(t.UnitType));
if (computes == null || !computes.Any()) return new List<ResComputeResponse>();
data = Mapper.Map<List<ResComputeResponse>>(computes);
data = _mapper.Map<List<ResComputeResponse>>(computes);
data.ForEach(t =>
{
......@@ -209,7 +212,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
if (compute == null || !compute.Any()) return new List<ResComputeResponse>();
data = Mapper.Map<List<ResComputeResponse>>(compute);
data = _mapper.Map<List<ResComputeResponse>>(compute);
data = data.OrderByDescending(t => t.RealGiveFee).ThenBy(t => t.FitPeople).ThenBy(t => t.AccountingUnit).ToList();
data.ForEach(t =>
{
......@@ -262,7 +265,7 @@ public List<res_specialunit> GetSpecial(int allotId)
if (list != null && list.Any())
{
list = list.OrderByDescending(t => t.AccountingUnit).ThenBy(t => t.RealGiveFee).ToList();
return Mapper.Map<List<res_specialunit>>(list);
return _mapper.Map<List<res_specialunit>>(list);
}
return new List<res_specialunit>();
}
......@@ -276,7 +279,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId)
{
List<int> types = new List<int> { (int)UnitType.医生组, (int)UnitType.医技组 };
var list = perforResaccountRepository.GetEntities(t => types.Contains(t.UnitType.Value) && t.AllotID == allotId)?.OrderBy(t => t.UnitType).ThenByDescending(t => t.AccountingUnit);
List<DeptResponse> doctor = Mapper.Map<List<DeptResponse>>(list);
List<DeptResponse> doctor = _mapper.Map<List<DeptResponse>>(list);
doctor?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return doctor;
}
......@@ -289,7 +292,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId)
public List<DeptResponse> GetNursePerformance(int allotId)
{
var list = perforResaccountRepository.GetEntities(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == allotId)?.OrderBy(t => t.UnitType).ThenByDescending(t => t.AccountingUnit);
List<DeptResponse> nurse = Mapper.Map<List<DeptResponse>>(list);
List<DeptResponse> nurse = _mapper.Map<List<DeptResponse>>(list);
nurse?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return nurse;
}
......@@ -303,7 +306,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId)
{
var unitType = new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组, (int)UnitType.专家组 };
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId)?.OrderBy(t => t.UnitType).ThenByDescending(t => t.AccountingUnit);
List<DeptResponse> other = Mapper.Map<List<DeptResponse>>(list);
List<DeptResponse> other = _mapper.Map<List<DeptResponse>>(list);
other?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return other;
}
......@@ -320,7 +323,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId)
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId && t.NeedSecondAllot == "是")
?.OrderBy(t => t.UnitType)
.ThenByDescending(t => t.AccountingUnit);
List<DeptResponse> other = Mapper.Map<List<DeptResponse>>(list);
List<DeptResponse> other = _mapper.Map<List<DeptResponse>>(list);
other?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return other;
}
......@@ -350,7 +353,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId)
// var resData = perforResaccountRepository.GetEntities(t => t.AllotID == allotId);
// if (resData != null && resData.Any())
// {
// result.AddRange(Mapper.Map<List<DeptResponse>>(resData));
// result.AddRange(_mapper.Map<List<DeptResponse>>(resData));
// result.ForEach(t =>
// {
// t.UnitName = ((UnitType)t.UnitType).ToString();
......@@ -750,7 +753,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
DeptDetailResponse response = new DeptDetailResponse()
{
Pandect = Mapper.Map<PerDataAccountBaisc>(account),
Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Economic = new List<DeptDetail>(),
Workload = new List<DeptDetail>()
};
......@@ -776,7 +779,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
var nurse = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == allotId && t.ID == accountId);
DeptDetailResponse response = new DeptDetailResponse()
{
Pandect = Mapper.Map<PerDataAccountBaisc>(nurse),
Pandect = _mapper.Map<PerDataAccountBaisc>(nurse),
Economic = new List<DeptDetail>(),
Workload = new List<DeptDetail>()
};
......@@ -1213,7 +1216,7 @@ public DeptDataDetails DeptDetail(int accountId)
DeptDataDetails deptDetails = new DeptDataDetails
{
ShowFormula = allot.ShowFormula,
Pandect = Mapper.Map<PerDataAccountBaisc>(account),
Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Detail = new List<DetailDtos>()
};
......@@ -1521,7 +1524,7 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
DeptDataDetails deptDetails = new DeptDataDetails
{
ShowFormula = allot.ShowFormula,
Pandect = Mapper.Map<PerDataAccountBaisc>(account),
Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Detail = new List<DetailDtos>()
};
......@@ -1919,10 +1922,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request)
{
if (request.Id == 0)
{
var baiscnorm = Mapper.Map<res_baiscnorm>(request);
var baiscnorm = _mapper.Map<res_baiscnorm>(request);
if (!perforResbaiscnormRepository.Add(baiscnorm))
throw new PerformanceException("保存失败");
return Mapper.Map<res_baiscnorm>(baiscnorm);
return _mapper.Map<res_baiscnorm>(baiscnorm);
}
else
{
......@@ -1934,10 +1937,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request)
baiscnorm.TotelValue = request.TotelValue;
baiscnorm.AvgValue = request.AvgValue;
//var baiscnorm = Mapper.Map<res_baiscnorm>(request);
//var baiscnorm = _mapper.Map<res_baiscnorm>(request);
if (!perforResbaiscnormRepository.Update(baiscnorm))
throw new PerformanceException("保存失败");
return Mapper.Map<res_baiscnorm>(baiscnorm);
return _mapper.Map<res_baiscnorm>(baiscnorm);
}
}
......
......@@ -18,6 +18,7 @@ namespace Performance.Services
{
public class CostTransferService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly ILogger<CostTransferService> logger;
private readonly Application application;
private readonly PerforCosttransferRepository costtransferRepository;
......@@ -32,6 +33,7 @@ public class CostTransferService : IAutoInjection
private readonly PerforExmoduleRepository perforExmodule;
public CostTransferService(
IMapper mapper,
ILogger<CostTransferService> logger,
IOptions<Application> application,
PerforCosttransferRepository costtransferRepository,
......@@ -46,6 +48,7 @@ public class CostTransferService : IAutoInjection
PerforExmoduleRepository perforExmodule
)
{
_mapper = mapper;
this.logger = logger;
this.application = application.Value;
this.costtransferRepository = costtransferRepository;
......@@ -115,7 +118,7 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
foreach (var item in costTransfers)
{
var result = new CostTransferResponse();
result = Mapper.Map<CostTransferResponse>(item);
result = _mapper.Map<CostTransferResponse>(item);
result.Items = costItem?.Where(t => t.TransferId == item.Id)?.Select(t => new Option
{
Id = t.Id,
......@@ -271,8 +274,8 @@ public bool Applicat(CostTransferRequest request)
if (request.Adopted.Department == request.Applicant.Department && request.Adopted.UnitType == request.Applicant.UnitType)
throw new PerformanceException("参数错误,提交科室相同");
var item=request.Items.Where(t => string.IsNullOrEmpty(t.Source) || string.IsNullOrEmpty(t.Category));
if(item.Count()>0) throw new PerformanceException("参数错误,申请信息填写不完整");
var item = request.Items.Where(t => string.IsNullOrEmpty(t.Source) || string.IsNullOrEmpty(t.Category));
if (item.Count() > 0) throw new PerformanceException("参数错误,申请信息填写不完整");
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
var allotStatus = new[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive };
......@@ -546,7 +549,7 @@ public void IntoLastTiemData(int hospitalId, int allotId)
foreach (var item in transferLast)
{
var newTransfers = new cost_transfer();
newTransfers = Mapper.Map<cost_transfer>(item);
newTransfers = _mapper.Map<cost_transfer>(item);
newTransfers.AllotId = allotId;
newTransfers.Status = 0;
newTransfers.AdminStatus = 0;
......
......@@ -21,7 +21,7 @@
// {
// #region
// private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment;
// private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService;
// private readonly PerforHospitalRepository perforHospitalRepository;
......@@ -44,7 +44,7 @@
// private per_allot Allot;
// public DFExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment,
// IWebHostEnvironment environment,
// IEmailService emailService,
// PerSheetService perSheetService,
// PerforHospitalRepository perforHospitalRepository,
......
......@@ -28,7 +28,7 @@ public class DownloadService : IAutoInjection
private readonly PerforCofaliasRepository perforCofalias;
private readonly ConfigService configService;
private readonly ComputeService _computeService;
private readonly IHostingEnvironment evn;
private readonly IWebHostEnvironment evn;
public DownloadService(ILogger<DownloadService> logger,
PerforPerallotRepository perallotRepository,
......@@ -36,7 +36,7 @@ public class DownloadService : IAutoInjection
PerforCofaliasRepository perforCofalias,
ConfigService configService,
ComputeService computeService,
IHostingEnvironment evn)
IWebHostEnvironment evn)
{
this.logger = logger;
this.perallotRepository = perallotRepository;
......
......@@ -20,6 +20,7 @@ namespace Performance.Services
{
public class EmployeeService : IAutoInjection
{
private readonly IMapper _mapper;
private PerforImemployeeRepository perforImemployeeRepository;
private PerforPersheetRepository perforPersheetRepository;
private PerforImdataRepository perforImdataRepository;
......@@ -39,6 +40,7 @@ public class EmployeeService : IAutoInjection
private ILogger<EmployeeService> logger;
public EmployeeService(
IMapper mapper,
PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository,
PerforImdataRepository perforImdataRepository,
......@@ -57,6 +59,7 @@ public class EmployeeService : IAutoInjection
PerforImheaderRepository imheaderRepository,
ILogger<EmployeeService> logger)
{
_mapper = mapper;
this.perforImemployeeRepository = perforImemployeeRepository;
this.perforPersheetRepository = perforPersheetRepository;
this.perforImdataRepository = perforImdataRepository;
......@@ -133,7 +136,7 @@ public im_employee Insert(EmployeeRequest request)
perforPersheetRepository.Add(sheet);
}
var employee = Mapper.Map<im_employee>(request);
var employee = _mapper.Map<im_employee>(request);
employee.WorkTime = ConvertHelper.To<DateTime?>(request.WorkTime);
employee.SheetID = sheet.ID;
perforImemployeeRepository.Add(employee);
......
......@@ -99,10 +99,10 @@ public void Handler(int hospitalId, per_allot allot, string groupName, bool isSi
HisData(allot, configs.FirstOrDefault(t => t.Id == item.ConfigId), item);
}
}
catch (Exception ex)
catch (Exception)
{
logger.LogError("获取数据时发生异常");
throw ex;
throw;
}
}
......@@ -134,7 +134,7 @@ private void Employee(per_allot allot, List<sys_hospitalconfig> configs, IEnumer
{
data = data.GroupJoin(hrpDepartments, outer => new { department = outer.Department }, inner => new { department = inner.HRPDepartment }, (outer, inner) => new { outer, inner }).Select(t =>
{
t.outer.AccountingUnit = t.inner?.FirstOrDefault()?.AccountingUnit;
t.outer.AccountingUnit = t.inner?.FirstOrDefault()?.AccountingUnit ?? t.outer.AccountingUnit;
return t.outer;
}).ToList();
}
......@@ -191,7 +191,8 @@ private void JudgeDataEqual(List<string> columns, List<per_employee> emps, List<
{ nameof(per_employee.BankCard), (t) => t.BankCard },
};
if (columns.Contains(nameof(per_employee.PersonnelNumber))) columns.Remove(nameof(per_employee.PersonnelNumber));
if (columns.Contains(nameof(per_employee.PersonnelNumber).ToLower())) columns.Remove(nameof(per_employee.PersonnelNumber).ToLower());
if (!columns.Contains(nameof(per_employee.AccountingUnit).ToLower())) columns.Add(nameof(per_employee.AccountingUnit).ToLower());
List<per_employee> updateData = new List<per_employee>();
foreach (var emp in emps)
......
......@@ -14,7 +14,7 @@ namespace Performance.Services.ExtractExcelService
public class ExtractJobService : IAutoInjection
{
private readonly ILogger logger;
private readonly IHostingEnvironment env;
private readonly IWebHostEnvironment env;
private readonly AllotService allotService;
private readonly ConfigService configService;
private readonly DictionaryService dictionaryService;
......@@ -26,7 +26,7 @@ public class ExtractJobService : IAutoInjection
public ExtractJobService(
ILogger<ExtractJobService> logger,
IHostingEnvironment env,
IWebHostEnvironment env,
AllotService allotService,
ConfigService configService,
DictionaryService dictionaryService,
......
......@@ -110,10 +110,10 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName
}
return data;
}
catch (Exception ex)
catch (Exception)
{
logger.LogError("获取数据时发生异常");
throw ex;
throw;
}
}
......@@ -203,8 +203,15 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
try
{
if (!pools.ContainsKey(config.Id))
pools.Add(config.Id, ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword));
try
{
if (!pools.ContainsKey(config.Id))
pools.Add(config.Id, ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword));
}
catch
{
logService.ReturnTheLog(allot.ID, groupName, 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle);
}
IDbConnection connection = pools[config.Id];
......@@ -229,7 +236,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......@@ -238,8 +245,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
}
catch (Exception ex)
{
logger.LogError($"数据库“{config.DbName}”连接失败: {ex}; {Infrastructure.JsonHelper.Serialize(script)}");
logService.ReturnTheLog(allot.ID, groupName, 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle);
logger.LogError($"typeId: {typeId}提取数据异常{ex}{Infrastructure.JsonHelper.Serialize(script)}");
}
}
}
......@@ -301,7 +307,7 @@ private List<ex_result> ExtractItemData(per_allot allot, string groupName, bool
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......@@ -364,7 +370,7 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......
......@@ -27,7 +27,7 @@
// public class ExtractService : IAutoInjection
// {
// private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment;
// private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService;
// private readonly PerHeaderService perHeaderService;
......@@ -43,7 +43,7 @@
// private readonly PerforHospitalconfigRepository perforHospitalconfigRepository;
// public ExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment,
// IWebHostEnvironment environment,
// IEmailService emailService,
// PerSheetService perSheetService,
// PerHeaderService perHeaderService,
......@@ -540,12 +540,12 @@
// ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
// };
// var perHeadList = perforImheaderRepository.GetEntities(t => t.SheetID == sheet.ID);
// perSheet.PerHeader = AutoMapper.Mapper.Map<List<PerHeader>>(perHeadList);
// perSheet.PerHeader = AutoMapper._mapper.Map<List<PerHeader>>(perHeadList);
// if (SheetType.Employee == (SheetType)sheet.SheetType)
// {
// perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType);
// var employeeList = perforImemployeeRepository.GetEntities(t => t.AllotID == sheet.AllotID);
// var perEmployeeList = AutoMapper.Mapper.Map<List<PerDataEmployee>>(employeeList);
// var perEmployeeList = AutoMapper._mapper.Map<List<PerDataEmployee>>(employeeList);
// perSheet.PerData = perEmployeeList?.ConvertAll(new Converter<PerDataEmployee, IPerData>(m => m));
// }
// else if (SheetType.SpecialUnit == (SheetType)sheet.SheetType)
......@@ -556,7 +556,7 @@
// {
// perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType);
// var basicList = perforImaccountbasicRepository.GetEntities(t => t.AllotID == sheet.AllotID);
// var perBasicList = AutoMapper.Mapper.Map<List<PerDataAccountBaisc>>(basicList);
// var perBasicList = AutoMapper._mapper.Map<List<PerDataAccountBaisc>>(basicList);
// perSheet.PerData = perBasicList?.ConvertAll(new Converter<PerDataAccountBaisc, IPerData>(m => m));
// }
// sheetList.Add(perSheet);
......
using Microsoft.Extensions.Logging;
using AutoMapper;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
......@@ -16,6 +17,7 @@ namespace Performance.Services
{
public class HistoryService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly ILogger<EmployeeService> logger;
private readonly PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository;
private readonly PerforReportoriginalstaysRepository reportoriginalstaysRepository;
......@@ -23,12 +25,14 @@ public class HistoryService : IAutoInjection
private readonly PerforPerdeptdicRepository perdeptdicRepository;
public HistoryService(
IMapper mapper,
ILogger<EmployeeService> logger,
PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository,
PerforReportoriginalstaysRepository reportoriginalstaysRepository,
PerforReportoriginalpersontimeRepository reportoriginalpersontimeRepository,
PerforPerdeptdicRepository perdeptdicRepository)
{
_mapper = mapper;
this.logger = logger;
this.reportoriginalsurgeryRepository = reportoriginalsurgeryRepository;
this.reportoriginalstaysRepository = reportoriginalstaysRepository;
......@@ -48,7 +52,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data1.Select(s => s.Month).Distinct().ToList();
reportoriginalpersontimeRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_persontime>>(@data1);
var @data = _mapper.Map<List<report_original_persontime>>(@data1);
reportoriginalpersontimeRepository.AddRange(@data.ToArray());
}
var @data2 = entities.Where(w => w.SheetName == "手术量");
......@@ -58,7 +62,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data2.Select(s => s.Month).Distinct().ToList();
reportoriginalsurgeryRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_surgery>>(@data2);
var @data = _mapper.Map<List<report_original_surgery>>(@data2);
reportoriginalsurgeryRepository.AddRange(@data.ToArray());
}
var @data3 = entities.Where(w => w.SheetName == "住院天数");
......@@ -68,7 +72,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data3.Select(s => s.Month).Distinct().ToList();
reportoriginalstaysRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month));
var @data = AutoMapper.Mapper.Map<List<report_original_stays>>(@data3);
var @data = _mapper.Map<List<report_original_stays>>(@data3);
reportoriginalstaysRepository.AddRange(@data.ToArray());
}
}
......
......@@ -11,17 +11,21 @@ namespace Performance.Services
{
public class HospitalService : IAutoInjection
{
private readonly IMapper _mapper;
private PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _joinRepository;
private PerforHospitalconfigRepository _hospitalconfigRepository;
private PerforPerfirstRepository _perfirstRepository;
private PerforPerallotRepository _perallotRepository;
public HospitalService(PerforHospitalRepository hospitalRepository,
public HospitalService(
IMapper mapper,
PerforHospitalRepository hospitalRepository,
PerforUserhospitalRepository joinRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforPerfirstRepository perfirstRepository,
PerforPerallotRepository perallotRepository)
{
_mapper = mapper;
this._hospitalRepository = hospitalRepository;
this._joinRepository = joinRepository;
this._hospitalconfigRepository = hospitalconfigRepository;
......@@ -50,7 +54,7 @@ public List<HospitalResponse> GetUserHopital(int userid)
//获取已经上传过模板的hospital
var firstId = _perfirstRepository.GetEntities(t => hosId.Contains(t.HospitalId.Value))?.Select(t => t.HospitalId.Value).ToList();
var list = Mapper.Map<List<sys_hospital>, List<HospitalResponse>>(hosList);
var list = _mapper.Map<List<sys_hospital>, List<HospitalResponse>>(hosList);
list.ForEach(t =>
{
if (hosId != null && hosId.Contains(t.HosID))
......@@ -103,7 +107,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid)
{
if (null != _hospitalRepository.GetEntity(t => t.HosName == request.HosName))
throw new PerformanceException("医院名称重复");
var hospital = Mapper.Map<sys_hospital>(request);
var hospital = _mapper.Map<sys_hospital>(request);
hospital.CreateDate = DateTime.Now;
hospital.CreateUser = userid;
hospital.States = (int)States.Enabled;
......@@ -111,7 +115,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid)
if (!_hospitalRepository.Add(hospital))
throw new PerformanceException("保存失败");
return Mapper.Map<HospitalResponse>(hospital);
return _mapper.Map<HospitalResponse>(hospital);
}
/// <summary>
......@@ -141,7 +145,7 @@ public HospitalResponse Update(HospitalRequest request)
if (!_hospitalRepository.Update(hospital))
throw new PerformanceException("保存失败");
return Mapper.Map<HospitalResponse>(hospital);
return _mapper.Map<HospitalResponse>(hospital);
}
/// <summary>
......
......@@ -3,75 +3,74 @@
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Services
{
public class HubGroupInfo
{
public DateTime AddTime { get; set; }
public string ConnectionId { get; set; }
}
public class AllotLogHub : Hub
{
private readonly ILogger<AllotLogHub> logger;
private readonly IMemoryCache cache;
private static ConcurrentDictionary<int, List<ConnectionUser>> _pairs
= new ConcurrentDictionary<int, List<ConnectionUser>>();
public AllotLogHub(
ILogger<AllotLogHub> logger,
IMemoryCache cache)
public AllotLogHub(ILogger<AllotLogHub> logger)
{
this.logger = logger;
this.cache = cache;
}
public override Task OnConnectedAsync()
{
logger.LogDebug($"日志推送 连接{Context.ConnectionId}");
return base.OnConnectedAsync();
}
public override Task OnDisconnectedAsync(Exception exception)
{
var connectionId = Context.ConnectionId;
logger.LogDebug($"日志推送 断开连接{connectionId}");
var userId = Context.User?.Claims.FirstOrDefault(w => w.Type == "id").Value ?? "";
string key = $"AllotLogGroup_{connectionId}";
//1 查询用户分组信息
var groupName = "";
//2 删除数据库中用户分组数据
if (cache.TryGetValue(key, out string value))
if (!string.IsNullOrEmpty(userId))
{
cache.Remove(key);
foreach (var item in _pairs)
{
var conn = item.Value.FirstOrDefault(w => w.ConnectionId == connectionId);
if (conn != null)
{
Groups.RemoveFromGroupAsync(connectionId, item.Key.ToString()).Wait();
logger.LogDebug($"日志推送 断开连接{connectionId}-{item.Key}-{userId}");
}
}
}
logger.LogDebug($"日志推送 断开连接{connectionId}-{groupName}");
//3 分组中删除用户
Groups.RemoveFromGroupAsync(connectionId, groupName);
return base.OnDisconnectedAsync(exception);
}
public async Task AddGroup(string token, string groupName)
public async Task AddGroup(string token, int groupName)
{
var connectionId = Context.ConnectionId;
string key = $"AllotLogGroup_{connectionId}";
if (cache.TryGetValue(key, out string value))
var userId = Context.User?.Claims.FirstOrDefault(w => w.Type == "id").Value ?? "";
if (!string.IsNullOrEmpty(userId))
{
cache.Remove(key);
if (_pairs.ContainsKey(groupName))
_pairs[groupName].Add(new ConnectionUser { ConnectionId = connectionId, UserId = userId });
else
_pairs[groupName] = new List<ConnectionUser> { new ConnectionUser { ConnectionId = connectionId, UserId = userId } };
await Groups.AddToGroupAsync(connectionId, groupName.ToString());
}
cache.Set(key, groupName, new TimeSpan(1, 0, 0));
logger.LogDebug($"日志推送 添加用户组{connectionId}-{groupName}");
logger.LogDebug($"日志推送 添加用户组{connectionId}-{groupName}-{userId}");
//2 将用户插入分组
await Groups.AddToGroupAsync(connectionId, groupName);
}
public async Task SendMessage(string groupName, string message)
class ConnectionUser
{
await Clients.Group(groupName).SendAsync("ReceiveMessage", "测试", message);
public string ConnectionId { get; set; }
public string UserId { get; set; }
}
}
}
using Microsoft.AspNetCore.SignalR;
using Dapper;
using Dapper.Contrib.Extensions;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
......@@ -8,6 +11,8 @@
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Services
......@@ -16,19 +21,19 @@ public class LogManageService : IAutoInjection
{
private readonly ILogger<LogManageService> logger;
private readonly IHubContext<AllotLogHub> hubContext;
private readonly IOptions<AppConnection> _options;
private readonly WebapiUrl url;
private PerforLogdbugRepository logdbug;
public LogManageService(
ILogger<LogManageService> logger,
IHubContext<AllotLogHub> hubContext,
IOptions<WebapiUrl> url,
PerforLogdbugRepository logdbug)
IOptions<AppConnection> options)
{
this.logger = logger;
this.hubContext = hubContext;
_options = options;
this.url = url.Value;
this.logdbug = logdbug;
}
/// <summary>
......@@ -45,7 +50,15 @@ public void WriteMsg(string tag, string message, int level, int allotId, string
hubContext.Clients.Group(allotId.ToString()).SendAsync(method, tag, message, level);
if (isDebug)
{
logdbug.Add(allotId, tag, message, level, 1);
Insert(allotId, tag, message, level, 1);
}
}
private void Insert(int allotId, string tag, string message, int level, int type)
{
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
connection.Insert<log_dbug>(new log_dbug { AllotID = allotId, CreateTime = DateTime.Now, Title = tag, Message = message, Level = level, Type = type });
}
}
......@@ -103,7 +116,7 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
if (isSingle) hubContext.Clients.Group(groupName).SendAsync("Schedule", ratio, level);
}
logdbug.Add(allotId, tag, content, level, type);
Insert(allotId, tag, content, level, type);
if (!isSingle)
{
var http = new RestSharpHelper();
......@@ -128,15 +141,22 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
}
}
public bool ClearExtractLog(int allotId)
public int ClearExtractLog(int allotId)
{
return logdbug.ClearExtractLog(allotId);
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
return connection.Execute("delete from log_dbug where AllotID = @allotId and Type in @type", new { allotId, type = new int[] { 2, 3 } });
}
}
//todo:log信息展示
public List<log_dbug> GetLogDbug(int allotId)
{
return logdbug.GetEntities(t => t.AllotID == allotId && t.Type==2);
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
var logs = connection.Query<log_dbug>("select * from log_dbug where AllotID = @allotId and Type = @type", new { allotId, type = 2 });
return logs == null || logs.Count() == 0 ? new List<log_dbug>() : logs.ToList();
}
}
}
}
......@@ -11,9 +11,13 @@ namespace Performance.Services
{
public class MenuService : IAutoInjection
{
private readonly IMapper _mapper;
private PerforMenuRepository _menuRepository;
public MenuService(PerforMenuRepository menuRepository)
public MenuService(
IMapper mapper,
PerforMenuRepository menuRepository)
{
_mapper = mapper;
_menuRepository = menuRepository;
}
......@@ -31,7 +35,7 @@ private List<MenuResponse> RecursionFill(List<sys_menu> menuList, int parentId)
var list = new List<MenuResponse>();
foreach (var item in menuList.Where(t => t.ParentID == parentId).OrderBy(t => t.Sort))
{
var menu = Mapper.Map<MenuResponse>(item);
var menu = _mapper.Map<MenuResponse>(item);
menu.Children = RecursionFill(menuList, item.ID);
list.Add(menu);
}
......
......@@ -29,7 +29,7 @@
// {
// #region
// private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment;
// private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService;
// private readonly PerforHospitalRepository perforHospitalRepository;
......@@ -51,7 +51,7 @@
// private int AllotId;
// public NewExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment,
// IWebHostEnvironment environment,
// IEmailService emailService,
// PerSheetService perSheetService,
// PerforHospitalRepository perforHospitalRepository,
......
using NPOI.HSSF.Record.Chart;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using Performance.DtoModels;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Remotion.Linq.Clauses.ResultOperators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Performance.Services
{
......
using Performance.DtoModels;
using AutoMapper;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
......@@ -15,6 +16,7 @@ namespace Performance.Services
/// </summary>
public class ComputeDirector : IAutoInjection
{
private readonly IMapper _mapper;
private readonly BaiscNormService baiscNormService;
private readonly PerforCofdirectorRepository perforCofdirectorRepository;
private readonly PerforCofworkyearRepository perforCofworkyearRepository;
......@@ -23,13 +25,16 @@ public class ComputeDirector : IAutoInjection
private readonly BudgetService budgetService;
//private readonly PerforResaccountdoctorRepository perforResAccountdoctorRepository;
public ComputeDirector(BaiscNormService baiscNormService,
public ComputeDirector(
IMapper mapper,
BaiscNormService baiscNormService,
PerforCofdirectorRepository perforCofdirectorRepository,
PerforCofworkyearRepository perforCofworkyearRepository,
PerforResaccountRepository perforResaccountRepository,
PerforRescomputeRepository perforRescomputeRepository,
BudgetService budgetService)
{
_mapper = mapper;
this.baiscNormService = baiscNormService;
this.perforCofdirectorRepository = perforCofdirectorRepository;
this.perforCofworkyearRepository = perforCofworkyearRepository;
......@@ -156,7 +161,7 @@ public class ComputeDirector : IAutoInjection
// List<res_account> dataList = new List<res_account>();
// foreach (var account in accountSheet)
// {
// dataList.AddRange(AutoMapper.Mapper.Map<List<res_account>>(account.PerData.Select(t => (PerDataAccountBaisc)t)));
// dataList.AddRange(_mapper.Map<List<res_account>>(account.PerData.Select(t => (PerDataAccountBaisc)t)));
// }
// var multi = accountbasicList.GroupBy(t => new { t.UnitType, t.DoctorAccountingUnit })
// .Select(t => new { t.Key.UnitType, t.Key.DoctorAccountingUnit, Count = t.Count(), })
......@@ -297,7 +302,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<PerS
List<res_account> dataList = new List<res_account>();
foreach (var account in accountSheet)
{
dataList.AddRange(AutoMapper.Mapper.Map<List<res_account>>(account.PerData.Select(t => (PerDataAccountBaisc)t)));
dataList.AddRange(_mapper.Map<List<res_account>>(account.PerData.Select(t => (PerDataAccountBaisc)t)));
}
List<ComputeResult> computeList = new List<ComputeResult>();
if (empolyeeList == null) return computeList;
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="PerExcelService\ComputeEmpolyee\BaiscNormService.cs" />
<Compile Remove="PerExcelService\PerExcelService.cs" />
<Compile Remove="PerExcelService\SheetDataCompute\PerSheetDataComputeEconomicMerge.cs" />
</ItemGroup>
<ItemGroup>
<Compile Remove="PerExcelService\ComputeEmpolyee\BaiscNormService.cs" />
<Compile Remove="PerExcelService\PerExcelService.cs" />
<Compile Remove="PerExcelService\SheetDataCompute\PerSheetDataComputeEconomicMerge.cs" />
</ItemGroup>
<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>
<ItemGroup>
<PackageReference Include="FluentScheduler" Version="5.5.1" />
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="MassTransit.AspNetCore" Version="7.2.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
<ProjectReference Include="..\Performance.Infrastructure\Performance.Infrastructure.csproj" />
<ProjectReference Include="..\Performance.Repository\Performance.Repository.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
<ProjectReference Include="..\Performance.Infrastructure\Performance.Infrastructure.csproj" />
<ProjectReference Include="..\Performance.Repository\Performance.Repository.csproj" />
</ItemGroup>
</Project>
using AutoMapper;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPOI.SS.UserModel;
......@@ -17,13 +16,13 @@
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services
{
public class PersonService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly ILogger<PersonService> logger;
private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
......@@ -35,7 +34,7 @@ public class PersonService : IAutoInjection
private readonly PerforHospitalRepository perforHospitalRepository;
private readonly UserService userService;
private readonly Application application;
private readonly IHostingEnvironment evn;
private readonly IWebHostEnvironment evn;
private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{
......@@ -49,7 +48,9 @@ public class PersonService : IAutoInjection
{ nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) },
};
public PersonService(ILogger<PersonService> logger,
public PersonService(
IMapper mapper,
ILogger<PersonService> logger,
PerforPerdeptdicRepository perdeptdicRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforPerallotRepository perallotRepository,
......@@ -60,9 +61,10 @@ public class PersonService : IAutoInjection
PerforHospitalRepository perforHospitalRepository,
UserService userService,
IOptions<Application> application,
IHostingEnvironment evn
IWebHostEnvironment evn
)
{
_mapper = mapper;
this.logger = logger;
this.perdeptdicRepository = perdeptdicRepository;
this.peremployeeRepository = peremployeeRepository;
......@@ -87,9 +89,11 @@ public void CreateAllotPersons(int hospitalId, int allotId, int prevAllotId = -1
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("绩效信息错误!");
var isExist = (peremployeeRepository.GetEntities(t => t.HospitalId == hospitalId && t.AllotId == allotId)?.Count ?? 0) > 0;
if (isExist) return;
//如果为空则先删除在执行下面的代码
if (isExist) { peremployeeRepository.DeleteFromQuery(u => u.HospitalId == hospitalId && u.AllotId == allotId);}
List<per_employee> persons = new List<per_employee>();
if (!new int[] { -1, 0 }.Contains(prevAllotId))
......@@ -240,7 +244,7 @@ public per_employee CreatePerson(PerEmployeeResponse request)
if (!unittype.Contains(request.UnitType))
throw new PerformanceException($"人员类别不符合规范!");
var entity = Mapper.Map<per_employee>(request);
var entity = _mapper.Map<per_employee>(request);
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
int day = DateTime.DaysInMonth(allot.Year, allot.Month);
entity.Attendance = request.AttendanceDay / day;
......@@ -273,7 +277,7 @@ public bool UpdatePerson(PerEmployeeResponse request)
if (employee == null)
employee = peremployeeRepository.GetEntity(t => t.Id == request.Id) ?? throw new PerformanceException("人员信息无效!");
//Mapper.Map(request, employee, typeof(per_employee), typeof(per_employee));
//_mapper.Map(request, employee, typeof(per_employee), typeof(per_employee));
employee.AccountingUnit = request.AccountingUnit;
employee.Department = request.Department;
......@@ -440,7 +444,7 @@ public bool UpdateDeptDic(per_dept_dic request)
if (deptdic != null && deptdic.Id != request.Id)
throw new PerformanceException($"{request.Department}数据重复!");
Mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
_mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
return perdeptdicRepository.Add(deptdic);
}
......
......@@ -225,7 +225,7 @@ public void ImportAllotData(int hospitalId, string filePath)
{
hisimportbaiscnormRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportbaiscnormRepository.BulkInsert(basicnormData);
hisimportbaiscnormRepository.InsertExecute(basicnormData);
}
#endregion 科室总绩效 人均绩效
......@@ -276,7 +276,7 @@ private void ImportBasicData(ISheet sheet, List<string> columns, int hospitalId,
{
hisimportdataRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Category == sheetName && t.Year == item.Year && t.Month == item.Month);
}
hisimportdataRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportdataRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
}
private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId, List<per_allot> allots, List<his_import_baiscnorm> basicnormData)
......@@ -342,7 +342,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
{
hisimportaccountRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportaccountRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportaccountRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
#endregion his_import_account
}
......@@ -377,7 +377,7 @@ private void ImporAccountTag(ISheet sheet, List<string> columns, int hospitalId)
});
reportperformancetagsRepository.DeleteFromQuery(t => t.HospitalId == hospitalId);
reportperformancetagsRepository.BulkInsert(data.Where(t => !string.IsNullOrEmpty(t.UnitType) && !string.IsNullOrEmpty(t.AccountingUnit)));
reportperformancetagsRepository.InsertExecute(data.Where(t => !string.IsNullOrEmpty(t.UnitType) && !string.IsNullOrEmpty(t.AccountingUnit)));
}
private void ImporClinicData(ISheet sheet, List<string> columns, int hospitalId, List<per_allot> allots, List<his_import_baiscnorm> basicnormData)
......@@ -445,7 +445,7 @@ private void ImporClinicData(ISheet sheet, List<string> columns, int hospitalId,
{
hisimportclinicRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportclinicRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportclinicRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
#endregion his_import_clinic
}
......@@ -482,7 +482,7 @@ private void ImporClinicTag(ISheet sheet, List<string> columns, int hospitalId)
});
reportperformancepersontagsRepository.DeleteFromQuery(t => t.HospitalId == hospitalId);
reportperformancepersontagsRepository.BulkInsert(data.Where(t => !string.IsNullOrEmpty(t.PersonnelName) && !string.IsNullOrEmpty(t.PersonnelNumber)));
reportperformancepersontagsRepository.InsertExecute(data.Where(t => !string.IsNullOrEmpty(t.PersonnelName) && !string.IsNullOrEmpty(t.PersonnelNumber)));
}
private List<string> GetColumns(ISheet sheet, string sheetName, out string sourceType)
......
......@@ -11,14 +11,18 @@ namespace Performance.Services
{
public class RoleService : IAutoInjection
{
private readonly IMapper _mapper;
private PerforRoleRepository _roleRepository;
private PerforUserroleRepository _userroleRepository;
private PerforUserRepository _userRepository;
public RoleService(PerforRoleRepository roleRepository,
public RoleService(
IMapper mapper,
PerforRoleRepository roleRepository,
PerforUserroleRepository userroleRepository,
PerforUserRepository userRepository)
{
_mapper = mapper;
this._roleRepository = roleRepository;
this._userroleRepository = userroleRepository;
_userRepository = userRepository;
......@@ -32,7 +36,7 @@ public class RoleService : IAutoInjection
public List<RoleResponse> GetUserRole(int userid)
{
var roles = GetRole(userid);
return Mapper.Map<List<RoleResponse>>(roles);
return _mapper.Map<List<RoleResponse>>(roles);
}
......@@ -71,7 +75,7 @@ public List<RoleResponse> GetUsersRole(int userid)
foreach (var sysUser in ParentUser)
{
var useRoles = GetARole(sysUser.ID);
var role = Mapper.Map<RoleResponse>(useRoles);
var role = _mapper.Map<RoleResponse>(useRoles);
var uRole = userRole.Find(t => t.RoleID == role.RoleID && t.UserID == sysUser.ID);
if (uRole?.UserID != null) role.Value = (int)uRole?.UserID;
roleResponses.Add(role);
......@@ -83,7 +87,7 @@ public List<RoleResponse> GetUsersRole(int userid)
if (roles != null)
{
var role = Mapper.Map<RoleResponse>(roles);
var role = _mapper.Map<RoleResponse>(roles);
role.Value = isParent ? userid : (int)user.ParentID;
roleResponses.Add(role);
}
......
......@@ -15,6 +15,7 @@ namespace Performance.Services
{
public class SecondAllotDetails : IAutoInjection
{
private readonly IMapper _mapper;
private readonly ILogger<SecondAllotDetails> _logger;
private readonly PerforImemployeelogisticsRepository _imemployeelogisticsRepository;
private readonly Application _application;
......@@ -33,6 +34,7 @@ public class SecondAllotDetails : IAutoInjection
private readonly UserService _userService;
public SecondAllotDetails(
IMapper mapper,
ILogger<SecondAllotDetails> logger,
IOptions<Application> application,
PerforImemployeelogisticsRepository imemployeelogisticsRepository,
......@@ -51,6 +53,7 @@ public class SecondAllotDetails : IAutoInjection
UserService userService
)
{
_mapper = mapper;
_logger = logger;
_imemployeelogisticsRepository = imemployeelogisticsRepository;
_application = application.Value;
......@@ -136,14 +139,14 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se
configHeaders = configHeaders?.Where(w => !SecondAllotService.defaultValues.Select(t => t.Item1).Contains(w.ItemName)).ToList();
// 初始化固定列
var headItems = Mapper.Map<List<HeadItem>>(fixedHeaders) ?? new List<HeadItem>();
var headItems = _mapper.Map<List<HeadItem>>(fixedHeaders) ?? new List<HeadItem>();
//获取工作量、单项奖励列
if (configHeaders != null && configHeaders.Any())
{
foreach (var workTypeId in configHeaders.Select(t => t.WorkTypeId).Distinct())
{
var workDtos = Mapper.Map<List<HeadItem>>(configHeaders.Where(t => t.WorkTypeId == workTypeId));
var workDtos = _mapper.Map<List<HeadItem>>(configHeaders.Where(t => t.WorkTypeId == workTypeId));
int type = workTypeId == (int)AgWorkloadType.SingleAwards
? (int)TempColumnType.SingleAwardsColumns
: (int)TempColumnType.WorkloadColumns;
......@@ -638,7 +641,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId))
{
result.HeadItems.Add(item);
var body = Mapper.Map<BodyItem>(item);
var body = _mapper.Map<BodyItem>(item);
body.RowNumber = rownumber;
if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName))
body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue;
......
......@@ -17,6 +17,7 @@ namespace Performance.Services
{
public partial class SecondAllotService : IAutoInjection
{
private readonly IMapper _mapper;
private readonly ILogger logger;
private readonly Application application;
private readonly PerforAgsecondallotRepository agsecondallotRepository;
......@@ -52,6 +53,7 @@ public partial class SecondAllotService : IAutoInjection
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(
IMapper mapper,
ILogger<SecondAllotService> logger,
IOptions<Application> application,
PerforAgsecondallotRepository agsecondallotRepository,
......@@ -84,6 +86,7 @@ public partial class SecondAllotService : IAutoInjection
ComputeService computeService
)
{
_mapper = mapper;
this.logger = logger;
this.application = application.Value;
this.agsecondallotRepository = agsecondallotRepository;
......@@ -149,7 +152,7 @@ public List<SecondListResponse> GetSecondList(int userId)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = agsecondallotRepository.GetEntities(exp);
var list = Mapper.Map<List<SecondListResponse>>(secondList);
var list = _mapper.Map<List<SecondListResponse>>(secondList);
var hospital = hospitalRepository.GetEntity(t => t.ID == userhospital.HospitalID);
list?.ForEach(t =>
{
......@@ -374,7 +377,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
//var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems = GetEmployees(second, userId, headItems, second.UnitType);
var bodys = Mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1));
var bodys = _mapper.Map<List<BodyItem>>(headItems.Where(t => t.Type == 1));
if (bodys != null && bodys.Any())
bodys.ForEach(t => t.RowNumber = -1);
result.BodyItems.AddRange(bodys);
......@@ -460,7 +463,7 @@ private List<BodyItem> GetEmployees(ag_secondallot second, int userId, List<Head
var head = heads.FirstOrDefault(t => t.FiledName == item.Key.Item1 && t.FiledId == item.Key.Item2);
if (head != null)
{
var body = Mapper.Map<BodyItem>(head);
var body = _mapper.Map<BodyItem>(head);
body.Value = item.Value.Invoke(employee)?.ToString();
body.RowNumber = rowNumber;
list.Add(body);
......@@ -697,7 +700,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId))
{
result.HeadItems.Add(item);
var body = Mapper.Map<BodyItem>(item);
var body = _mapper.Map<BodyItem>(item);
body.RowNumber = rownumber;
if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName))
body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue;
......@@ -875,7 +878,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps);
var secondTemps = _mapper.Map<List<SecondTempResponse>>(temps);
if (useTemp != null)
secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId);
return secondTemps;
......@@ -895,7 +898,7 @@ public bool UseTemp(UseTempRequest request)
&& t.Department == request.Department && t.UnitType == request.UnitType);
if (entity == null)
{
entity = Mapper.Map<ag_usetemp>(request);
entity = _mapper.Map<ag_usetemp>(request);
result = agusetempRepository.Add(entity);
}
else
......@@ -912,7 +915,7 @@ public bool UseTemp(UseTempRequest request)
var allotList = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var seconds = agsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value) && new List<int> { 1, 4 }.Contains(t.Status ?? 1));
var secondList = Mapper.Map<List<SecondListResponse>>(seconds);
var secondList = _mapper.Map<List<SecondListResponse>>(seconds);
secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
//获取未归档 未提交 驳回 的二次绩效
......@@ -1859,7 +1862,7 @@ public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department
{
var tempItem = agtempitemRepository.GetEntities(t => t.TempId == tempId);
var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
var headItems = _mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
var temp = agtempRepository.GetEntity(w => w.Id == tempId);
......@@ -1871,11 +1874,11 @@ public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department
var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
if (workItem != null && workItem.Count > 0)
{
var workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards));
var workDtos = _mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards));
workDtos.ForEach(t => { t.Type = 3; });
headItems.AddRange(workDtos);
workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId == (int)AgWorkloadType.SingleAwards));
workDtos = _mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId == (int)AgWorkloadType.SingleAwards));
workDtos.ForEach(t => { t.Type = 4; });
headItems.AddRange(workDtos);
}
......@@ -2141,7 +2144,7 @@ public dynamic Print(int secondId)
var data = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (data == null || !data.Any()) return new List<SecPrintResponse>();
result = Mapper.Map<List<SecPrintResponse>>(data);
result = _mapper.Map<List<SecPrintResponse>>(data);
header.TotalDistPerformance = second.RealGiveFee ?? 0;
header.HosOtherPerformance = result.Sum(t => t.OtherPerformance ?? 0);
......@@ -2173,7 +2176,7 @@ public dynamic Print(int secondId)
var headerdata = agheadsourceRepository.GetEntity(t => t.SecondId == secondId);
header = Mapper.Map<SecPrintHeaderResponse>(headerdata);
header = _mapper.Map<SecPrintHeaderResponse>(headerdata);
//header.HosOtherPerformance = result.Sum(t => t.OtherPerformance ?? 0);
}
else if ((new int[] { 7, 8 }).Contains(useTempId))
......@@ -2246,7 +2249,7 @@ public dynamic Print(int secondId)
var headerdata = agheadsourceRepository.GetEntity(t => t.SecondId == secondId);
header = Mapper.Map<SecPrintHeaderResponse>(headerdata);
header = _mapper.Map<SecPrintHeaderResponse>(headerdata);
}
// 补充医院其他绩效 及 预留比例
......
using System;
using System.Collections.Generic;
using System.Text;
//using System;
//using System.Collections.Generic;
//using System.Text;
namespace Performance.Services
{
public static class ServiceLocator
{
public static IServiceProvider Instance { get; set; }
}
}
//namespace Performance.Services
//{
// public static class ServiceLocator
// {
// public static IServiceProvider Instance { get; set; }
// }
//}
......@@ -15,6 +15,7 @@ namespace Performance.Services
/// </summary>
public class SheetSevice : IAutoInjection
{
private readonly IMapper _mapper;
private PerforPerallotRepository _perforAllotRepository;
private PerforPersheetRepository _perforImSheetRepository;
private PerforImdataRepository _perforImDataRepository;
......@@ -28,7 +29,9 @@ public class SheetSevice : IAutoInjection
private readonly PerforImemployeelogisticsRepository _perforImemployeelogisticsRepository;
private readonly string[] percentparam = new string[] { "预算比例", "考核得分率", "调节系数" };
public SheetSevice(PerforPerallotRepository perforAllotRepository,
public SheetSevice(
IMapper mapper,
PerforPerallotRepository perforAllotRepository,
PerforPersheetRepository perforImSheetRepository,
PerforImdataRepository perforImDataRepository,
PerforImheaderRepository perforImHeaderRepository,
......@@ -40,6 +43,7 @@ public class SheetSevice : IAutoInjection
PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository)
{
_mapper = mapper;
_perforAllotRepository = perforAllotRepository;
_perforImSheetRepository = perforImSheetRepository;
_perforImDataRepository = perforImDataRepository;
......@@ -68,7 +72,7 @@ public List<SheetResponse> SheetList(int allotID, int source)
throw new PerformanceException("参数source无效");
var sheetList = _perforImSheetRepository.GetEntities(t => t.AllotID == allotID && t.Source == source);
return Mapper.Map<List<SheetResponse>>(sheetList);
return _mapper.Map<List<SheetResponse>>(sheetList);
}
/// <summary>
......
......@@ -18,6 +18,7 @@ public class UserService : IAutoInjection
{
private Application application;
private PerforUserRepository _userRepository;
private readonly IMapper _mapper;
private PerforSmsRepository _smsRepository;
private PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _userhospitalRepository;
......@@ -32,7 +33,9 @@ public class UserService : IAutoInjection
private PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofaccountingRepository perforCofaccountingRepository;
public UserService(IOptions<Application> application,
public UserService(
IMapper mapper,
IOptions<Application> application,
PerforSmsRepository smsRepository,
PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository,
......@@ -50,6 +53,7 @@ public class UserService : IAutoInjection
{
this.application = application.Value;
this._userRepository = userRepository;
_mapper = mapper;
this._smsRepository = smsRepository;
this._hospitalRepository = hospitalRepository;
this._userhospitalRepository = userhospitalRepository;
......@@ -82,7 +86,7 @@ public UserIdentity Login(LoginRequest request)
if (user == null)
throw new PerformanceException("用户信息查询失败");
var data = Mapper.Map<UserIdentity>(user);
var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N");
return data;
}
......@@ -95,7 +99,7 @@ public UserIdentity Login(LoginRequest request)
if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase))
throw new PerformanceException($"密码错误");
var data = Mapper.Map<UserIdentity>(user);
var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N");
return data;
}
......@@ -108,7 +112,7 @@ public UserIdentity GetUser(int userId)
if (user == null)
throw new PerformanceException("用户信息查询失败");
return Mapper.Map<UserIdentity>(user);
return _mapper.Map<UserIdentity>(user);
}
/// <summary>
......@@ -142,7 +146,7 @@ public List<int> GetUserHospital(int userId)
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public List<UserResponse> GetUserList(int userID,int roleType=1)
public List<UserResponse> GetUserList(int userID, int roleType = 1)
{
var userRoles = _userroleRepository.GetEntities();
var userHospitals = _userhospitalRepository.GetEntities();
......@@ -154,15 +158,15 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (roleType == 12)
{
var jxQuery = userRoles.Where(t=>t.RoleID==roles?.FirstOrDefault(c=>c.RoleName=="绩效查询")?.ID).Select(t => t.UserID);
var jxQuery = userRoles.Where(t => t.RoleID == roles?.FirstOrDefault(c => c.RoleName == "绩效查询")?.ID).Select(t => t.UserID);
users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
}
else
{
var jxQuery = userRoles.Where(t =>roles.Where(c => c.RoleName != "绩效查询").Select(c=>c.ID).Contains(t.RoleID)).Select(t => t.UserID);
var jxQuery = userRoles.Where(t => roles.Where(c => c.RoleName != "绩效查询").Select(c => c.ID).Contains(t.RoleID)).Select(t => t.UserID);
users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
}
if (userrole == null)
throw new PerformanceException("用户未配置角色");
var role = roles?.FirstOrDefault(t => t.ID == userrole.RoleID);
......@@ -184,7 +188,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (parentUser == null) continue;
parentUser.Department = user.Department;
}
result = Mapper.Map<List<UserResponse>>(userlist);
result = _mapper.Map<List<UserResponse>>(userlist);
}
else
{
......@@ -203,7 +207,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (parentUser == null) continue;
parentUser.Department = user?.Department;
}
result = Mapper.Map<List<UserResponse>>(userlist);
result = _mapper.Map<List<UserResponse>>(userlist);
}
if (result != null && result.Count > 0)
{
......@@ -277,7 +281,7 @@ public UserResponse Insert(UserRequest request, int userid)
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request);
var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now;
user.CreateUser = userid;
user.States = (int)States.Enabled;
......@@ -291,7 +295,7 @@ public UserResponse Insert(UserRequest request, int userid)
//添加用户医院
SetHospital(user.ID, request.HosIDArray);
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
/// <summary>
......@@ -371,7 +375,7 @@ public UserResponse Update(UserRequest request, bool isAgainAdmin)
//添加用户医院
SetHospital(user.ID, request.HosIDArray);
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
/// <summary>
......@@ -400,7 +404,7 @@ public UserResponse UpdateSelf(UserRequest request)
if (!_userRepository.Update(user))
throw new PerformanceException("保存失败");
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
/// <summary>
......@@ -422,7 +426,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId)
if (!_userRepository.Update(user))
throw new PerformanceException("保存失败");
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
/// <summary>
......@@ -543,7 +547,7 @@ public UserIdentity GetDemoUserIdentity(int userId)
if (user == null)
throw new PerformanceException($"用户不存在,请先创建!");
var data = Mapper.Map<UserIdentity>(user);
var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N");
return data;
}
......@@ -566,7 +570,7 @@ public UserResponse ResetPwd(int userId, int loginUserId)
user.Password = "123456";
if (!_userRepository.Update(user))
throw new PerformanceException("重置失败");
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
#region 多角色
......@@ -584,7 +588,7 @@ public UserResponse InsertUser(UserRequest request, int userid)
if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request);
var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now;
user.CreateUser = userid;
user.States = (int)States.Enabled;
......@@ -613,7 +617,7 @@ public UserResponse InsertUser(UserRequest request, int userid)
//添加用户医院
SetHospital(user.ID, request.HosIDArray);
}
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
/// <summary>
......@@ -691,7 +695,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
//添加子用户医院
SetHospital(diffUser.ID, request.HosIDArray);
}
return Mapper.Map<UserResponse>(user);
return _mapper.Map<UserResponse>(user);
}
public ApiResponse DeleteUser(int iD)
......@@ -760,7 +764,7 @@ public string SaveUserHandsFlat(UserCollectData request)
var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities();
var accounts = perforCofaccountingRepository.GetEntities();
//var allot = _perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
//var res = accounts?.Join(allot, t => t.AllotId, w => w.ID, (t, w) => new cof_accounting { AccountingUnit = t.AccountingUnit }).Distinct();
......@@ -844,9 +848,9 @@ public string SaveUserHandsFlat(UserCollectData request)
return "";
}
catch (Exception e)
catch (Exception)
{
throw e;
throw;
}
}
......
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