第三稿

parent b74593d8
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 ...@@ -10,9 +10,7 @@ public static class AutoMapperConfig
public static void AddAutoMapperConfiguration(this IServiceCollection services) public static void AddAutoMapperConfiguration(this IServiceCollection services)
{ {
if (services == null) throw new ArgumentNullException(nameof(services)); if (services == null) throw new ArgumentNullException(nameof(services));
services.AddAutoMapper(typeof(AutoMapperConfigs));
Mapper.Initialize(cfg => cfg.AddProfile<AutoMapperConfigs>());
services.AddAutoMapper();
} }
} }
} }
...@@ -17,8 +17,14 @@ public static void AddDatabaseConfiguration(this IServiceCollection services) ...@@ -17,8 +17,14 @@ public static void AddDatabaseConfiguration(this IServiceCollection services)
services.AddDbContext<PerformanceDbContext>(options => 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 ...@@ -55,17 +55,4 @@ public static void AddDependencyInjectionConfiguration(this IServiceCollection s
.AddPerformanceRepoitory(); .AddPerformanceRepoitory();
} }
} }
#region hangfire 权限
public class HangfireAuthorizationFilter : Hangfire.Dashboard.IDashboardAuthorizationFilter
{
//这里需要配置权限规则
public bool Authorize(Hangfire.Dashboard.DashboardContext context)
{
return true;
}
}
#endregion hangfire 权限
} }
...@@ -373,7 +373,6 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody] ...@@ -373,7 +373,6 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
/// <summary> /// <summary>
/// 批量新增用户表头 /// 批量新增用户表头
/// </summary> /// </summary>
/// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("GetBatchUserStructrue")] [Route("GetBatchUserStructrue")]
[HttpPost] [HttpPost]
...@@ -387,7 +386,6 @@ public ApiResponse GetBatchUserStructrue() ...@@ -387,7 +386,6 @@ public ApiResponse GetBatchUserStructrue()
/// <summary> /// <summary>
/// 批量新增用户 /// 批量新增用户
/// </summary> /// </summary>
/// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("BatchSaveUser")] [Route("BatchSaveUser")]
[HttpPost] [HttpPost]
......
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Hangfire;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; 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 // 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 ...@@ -34,14 +27,14 @@ public class AgainAllotController : Controller
private ComputeService computeService; private ComputeService computeService;
private ClaimService claimService; private ClaimService claimService;
private AllotService allotService; private AllotService allotService;
private IHostingEnvironment env; private IWebHostEnvironment env;
private ConfigService configService; private ConfigService configService;
private Application application; private Application application;
public AgainAllotController(AgainAllotService againAllotService, public AgainAllotController(AgainAllotService againAllotService,
RoleService roleService, RoleService roleService,
ClaimService claimService, ClaimService claimService,
AllotService allotService, AllotService allotService,
IHostingEnvironment env, IWebHostEnvironment env,
ConfigService configService, ConfigService configService,
ComputeService computeService, ComputeService computeService,
IOptions<Application> options) IOptions<Application> options)
...@@ -171,7 +164,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -171,7 +164,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
/// <returns></returns> /// <returns></returns>
[Route("detail")] [Route("detail")]
[HttpPost] [HttpPost]
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request)
{ {
var result = againAllotService.Detail(request); var result = againAllotService.Detail(request);
return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport }); return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport });
......
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using MassTransit;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Infrastructure; using Performance.Infrastructure;
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; 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 // 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 ...@@ -30,7 +30,7 @@ public class AllotController : Controller
private AllotService _allotService; private AllotService _allotService;
private ResultComputeService _resultComputeService; private ResultComputeService _resultComputeService;
private ConfigService _configService; private ConfigService _configService;
private IHostingEnvironment _evn; private IWebHostEnvironment _evn;
private ILogger<AllotController> _logger; private ILogger<AllotController> _logger;
private ClaimService _claim; private ClaimService _claim;
private LogManageService _logManageService; private LogManageService _logManageService;
...@@ -42,7 +42,7 @@ public class AllotController : Controller ...@@ -42,7 +42,7 @@ public class AllotController : Controller
ResultComputeService resultComputeService, ResultComputeService resultComputeService,
ConfigService configService, ConfigService configService,
ILogger<AllotController> logger, ILogger<AllotController> logger,
IHostingEnvironment evn, IWebHostEnvironment evn,
IBackgroundTaskQueue backgroundTaskQueue, IBackgroundTaskQueue backgroundTaskQueue,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
ClaimService claim, ClaimService claim,
...@@ -247,7 +247,7 @@ public ApiResponse ImportExtraction(int allotId) ...@@ -247,7 +247,7 @@ public ApiResponse ImportExtraction(int allotId)
/// <returns></returns> /// <returns></returns>
[Route("generate")] [Route("generate")]
[HttpPost] [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); var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path)) if (null == allot || string.IsNullOrEmpty(allot.Path))
...@@ -263,8 +263,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -263,8 +263,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
} }
else else
{ {
//BackgroundJob.Schedule(() => _allotService.Generate(allot, email), TimeSpan.FromSeconds(1));
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => _backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{ {
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
...@@ -274,6 +272,8 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -274,6 +272,8 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
await Task.Delay(TimeSpan.FromSeconds(5), token); 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"); _logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
...@@ -297,15 +297,8 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -297,15 +297,8 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB
if (null == allot || !states.Contains(allot.States)) if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。"); throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => //_publishEndpoint.Publish(allot).Wait();
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.GenerateReport(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
return new ApiResponse(ResponseType.OK, "统计报表数据任务开始"); return new ApiResponse(ResponseType.OK, "统计报表数据任务开始");
} }
......
...@@ -834,7 +834,6 @@ public ApiResponse LoadTheLastTime([FromBody] CopyRequest request) ...@@ -834,7 +834,6 @@ public ApiResponse LoadTheLastTime([FromBody] CopyRequest request)
/// <summary> /// <summary>
/// 下拉 /// 下拉
/// </summary> /// </summary>
/// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("copydropdown")] [HttpPost("copydropdown")]
public ApiResponse CopyDropDown() public ApiResponse CopyDropDown()
......
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -21,12 +20,12 @@ public class EmployeeController : Controller ...@@ -21,12 +20,12 @@ public class EmployeeController : Controller
private EmployeeService employeeService; private EmployeeService employeeService;
private AllotService allotService; private AllotService allotService;
private ClaimService claim; private ClaimService claim;
private IHostingEnvironment evn; private IWebHostEnvironment evn;
private readonly RoleService roleService; private readonly RoleService roleService;
private readonly UserService userService; private readonly UserService userService;
public EmployeeController(EmployeeService employeeService, AllotService allotService, public EmployeeController(EmployeeService employeeService, AllotService allotService,
ClaimService claim, IHostingEnvironment evn, RoleService roleService, ClaimService claim, IWebHostEnvironment evn, RoleService roleService,
UserService userService) UserService userService)
{ {
this.employeeService = employeeService; this.employeeService = employeeService;
......
using System; using Microsoft.AspNetCore.Hosting;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System;
using System.IO;
using System.Linq;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
...@@ -20,11 +17,11 @@ public class HistoryController : ControllerBase ...@@ -20,11 +17,11 @@ public class HistoryController : ControllerBase
{ {
private readonly HistoryService historyService; private readonly HistoryService historyService;
private readonly ClaimService claim; private readonly ClaimService claim;
private readonly IHostingEnvironment evn; private readonly IWebHostEnvironment evn;
public HistoryController( public HistoryController(
HistoryService historyService, HistoryService historyService,
ClaimService claim, ClaimService claim,
IHostingEnvironment evn) IWebHostEnvironment evn)
{ {
this.historyService = historyService; this.historyService = historyService;
this.claim = claim; this.claim = claim;
......
...@@ -21,22 +21,19 @@ public class ModExtractController : Controller ...@@ -21,22 +21,19 @@ public class ModExtractController : Controller
private readonly CustomExtractService _extractService; private readonly CustomExtractService _extractService;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IHubNotificationQueue _notificationQueue; private readonly IHubNotificationQueue _notificationQueue;
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
public ModExtractController( public ModExtractController(
ClaimService claim, ClaimService claim,
AllotService allotService, AllotService allotService,
CustomExtractService extractService, CustomExtractService extractService,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
IHubNotificationQueue notificationQueue, IHubNotificationQueue notificationQueue)
IBackgroundTaskQueue backgroundTaskQueue)
{ {
_claim = claim; _claim = claim;
_allotService = allotService; _allotService = allotService;
_extractService = extractService; _extractService = extractService;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_notificationQueue = notificationQueue; _notificationQueue = notificationQueue;
_backgroundTaskQueue = backgroundTaskQueue;
} }
[HttpPost("custom/{allotId}")] [HttpPost("custom/{allotId}")]
...@@ -46,27 +43,27 @@ public ApiResponse CustomExtract(int allotId) ...@@ -46,27 +43,27 @@ public ApiResponse CustomExtract(int allotId)
if (!_extractService.CheckConfigScript(userId, allotId)) if (!_extractService.CheckConfigScript(userId, allotId))
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。"); return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token => //_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{ //{
using (var scope = _serviceScopeFactory.CreateScope()) // using (var scope = _serviceScopeFactory.CreateScope())
{ // {
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>(); // var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>(); // var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>(); // var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
if (scopedServices.ExtractData(userId, allotId, out string resultFilePath)) // if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
{ // {
scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath); // scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId))); // scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
} // }
else // else
{ // {
scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR))); // 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("自定义数据提取任务开始执行"))); _notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
......
...@@ -218,7 +218,7 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R ...@@ -218,7 +218,7 @@ public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody] R
var list = reportService.MenuReport(request); var list = reportService.MenuReport(request);
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
/// <summary>
/// 菜单报表 /// 菜单报表
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
......
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -8,10 +7,8 @@ ...@@ -8,10 +7,8 @@
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
...@@ -19,12 +16,12 @@ namespace Performance.Api.Controllers ...@@ -19,12 +16,12 @@ namespace Performance.Api.Controllers
[Route("api/{hospitalId}/report/global")] [Route("api/{hospitalId}/report/global")]
public class ReportGlobalController : Controller public class ReportGlobalController : Controller
{ {
private readonly IHostingEnvironment env; private readonly IWebHostEnvironment env;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly ReportGlobalService reportGlobalService; private readonly ReportGlobalService reportGlobalService;
public ReportGlobalController( public ReportGlobalController(
IHostingEnvironment env, IWebHostEnvironment env,
AllotService allotService, AllotService allotService,
ReportGlobalService reportGlobalService ReportGlobalService reportGlobalService
) )
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
...@@ -27,7 +26,7 @@ namespace Performance.Api.Controllers ...@@ -27,7 +26,7 @@ namespace Performance.Api.Controllers
public class TemplateController : Controller public class TemplateController : Controller
{ {
private readonly ILogger logger; private readonly ILogger logger;
private readonly IHostingEnvironment env; private readonly IWebHostEnvironment env;
private readonly ClaimService claim; private readonly ClaimService claim;
private readonly WebapiUrl url; private readonly WebapiUrl url;
private readonly Application application; private readonly Application application;
...@@ -41,7 +40,7 @@ public class TemplateController : Controller ...@@ -41,7 +40,7 @@ public class TemplateController : Controller
public TemplateController( public TemplateController(
ILogger<ExceptionsFilter> logger, ILogger<ExceptionsFilter> logger,
IHostingEnvironment env, IWebHostEnvironment env,
ClaimService claim, ClaimService claim,
IOptions<WebapiUrl> url, IOptions<WebapiUrl> url,
IOptions<Application> options, IOptions<Application> options,
......
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Performance.Api namespace Performance.Api
...@@ -21,9 +16,9 @@ public class ActionsFilter : IAsyncActionFilter ...@@ -21,9 +16,9 @@ public class ActionsFilter : IAsyncActionFilter
{ {
private readonly ILogger<ActionsFilter> _logger; private readonly ILogger<ActionsFilter> _logger;
private readonly IMemoryCache _cache; 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._logger = factory.CreateLogger<ActionsFilter>();
this._cache = cache; this._cache = cache;
...@@ -38,7 +33,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron ...@@ -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() : "" }; var req = new { request.Path, request.Method, context.ActionArguments, Token = authorization.Count > 0 ? authorization.First() : "" };
_logger.LogInformation($"请求内容 {JsonHelper.Serialize(req)}"); _logger.LogInformation($"请求内容 {JsonHelper.Serialize(req)}");
//启用body倒带功能 //启用body倒带功能
request.EnableRewind(); request.EnableBuffering();
//接口禁用 //接口禁用
if (context.Filters.Any(item => item is ApiDisableAttribute)) if (context.Filters.Any(item => item is ApiDisableAttribute))
......
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup> </PropertyGroup>
...@@ -11,55 +11,12 @@ ...@@ -11,55 +11,12 @@
<NoWarn>1701;1702;1591</NoWarn> <NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup> </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>
<ItemGroup>
<None Remove="Template\~%24医院绩效模板.xlsx" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<UserSecretsId>e732666b-5531-4cd8-b713-2fe3db31126c</UserSecretsId> <UserSecretsId>e732666b-5531-4cd8-b713-2fe3db31126c</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" /> <ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" /> <ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup> </ItemGroup>
...@@ -112,6 +69,10 @@ ...@@ -112,6 +69,10 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JSONSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project> </Project>
...@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. ...@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishUrl>D:\publish\jx.suvalue.com2</PublishUrl> <PublishUrl>D:\publish\jx.suvalue.com2</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod> <WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish /> <SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid> <ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained> <SelfContained>false</SelfContained>
</PropertyGroup> </PropertyGroup>
......
using FluentValidation; using FluentValidation;
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using MassTransit;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Performance.Api.Configurations; using Performance.Api.Configurations;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
...@@ -40,19 +44,20 @@ public void ConfigureServices(IServiceCollection services) ...@@ -40,19 +44,20 @@ public void ConfigureServices(IServiceCollection services)
#region json & fluentvalidation & filter #region json & fluentvalidation & filter
services 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<ActionsFilter>();
option.Filters.Add<ExceptionsFilter>(); option.Filters.Add<ExceptionsFilter>();
}) })
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddNewtonsoftJson(JsonOptions) //json格式配置
.AddJsonOptions(JsonOptions) //json格式配置
.AddFluentValidation(fv => .AddFluentValidation(fv =>
{ {
// model验证,禁用其他以使FluentValidation是唯一执行的验证库 //// model验证,禁用其他以使FluentValidation是唯一执行的验证库
fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false; //fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
var assembly = Assembly.Load("Performance.DtoModels"); var assembly = Assembly.Load("Performance.DtoModels");
var types = ReflectionHelper.GetInstances<IValidator>(assembly); var types = ReflectionHelper.GetInstances<IValidator>(assembly);
...@@ -64,6 +69,8 @@ public void ConfigureServices(IServiceCollection services) ...@@ -64,6 +69,8 @@ public void ConfigureServices(IServiceCollection services)
#endregion json & fluentvalidation & filter #endregion json & fluentvalidation & filter
services.AddAuthenticationConfiguration(Configuration);
// dbcontext // dbcontext
services.AddDatabaseConfiguration(); services.AddDatabaseConfiguration();
...@@ -90,10 +97,25 @@ public void ConfigureServices(IServiceCollection services) ...@@ -90,10 +97,25 @@ public void ConfigureServices(IServiceCollection services)
// fluentscheduler // fluentscheduler
services.AddFluentSchedulerConfiguration(); services.AddFluentSchedulerConfiguration();
//services.AddMassTransit(x =>
//{
// x.AddConsumer<AllotGenerateConsumer>();
// x.UsingInMemory((context, cfg) =>
// {
// cfg.TransportConcurrencyLimit = 20;
// cfg.ConfigureEndpoints(context);
// cfg.ReceiveEndpoint("event-listener", e =>
// {
// e.ConfigureConsumer<AllotGenerateConsumer>(context);
// });
// });
//});
//services.AddMassTransitHostedService();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
...@@ -103,19 +125,26 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) ...@@ -103,19 +125,26 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ {
app.UseStatusCodePagesWithReExecute("/error/{0}"); app.UseStatusCodePagesWithReExecute("/error/{0}");
} }
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<RequestRateLimitingMiddleware>(); app.UseMiddleware<RequestRateLimitingMiddleware>();
app.UseCors("SignalrCore"); app.UseCors("SignalrCore");
app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/performance/allotLogHub")); app.UseEndpoints(endpoints =>
{
app.UseMvc(); endpoints.MapHub<AllotLogHub>("/performance/allotLogHub");
endpoints.MapControllers();
});
app.UseSwaggerSetup(Configuration); app.UseSwaggerSetup(Configuration);
} }
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.Converters.Add(new IsoDateTimeConverterContent() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
......
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace Performance.Api namespace Performance.Api
{ {
......
...@@ -141,14 +141,12 @@ ...@@ -141,14 +141,12 @@
<summary> <summary>
批量新增用户表头 批量新增用户表头
</summary> </summary>
<param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AccountController.BatchSaveUser(Performance.DtoModels.UserCollectData)"> <member name="M:Performance.Api.Controllers.AccountController.BatchSaveUser(Performance.DtoModels.UserCollectData)">
<summary> <summary>
批量新增用户 批量新增用户
</summary> </summary>
<param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Performance.Api.Controllers.AgainAllotController"> <member name="T:Performance.Api.Controllers.AgainAllotController">
...@@ -225,7 +223,7 @@ ...@@ -225,7 +223,7 @@
<param name="allotId"></param> <param name="allotId"></param>
<returns></returns> <returns></returns>
</member> </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>
绩效生成 绩效生成
</summary> </summary>
...@@ -854,7 +852,6 @@ ...@@ -854,7 +852,6 @@
<summary> <summary>
下拉 下拉
</summary> </summary>
<param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.CustomHeads(Performance.DtoModels.CustomPagingRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.CustomHeads(Performance.DtoModels.CustomPagingRequest)">
...@@ -1592,7 +1589,13 @@ ...@@ -1592,7 +1589,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </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)"> <member name="M:Performance.Api.Controllers.ReportController.TableNormal(Performance.DtoModels.ConditionRequest)">
<summary> <summary>
绩效汇报表 绩效汇报表
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -22,19 +22,6 @@ ...@@ -22,19 +22,6 @@
</ItemGroup> </ItemGroup>
<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.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" /> <ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup> </ItemGroup>
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...@@ -13,10 +13,6 @@ ...@@ -13,10 +13,6 @@
<Compile Remove="PerExcel\PerComputeData.cs" /> <Compile Remove="PerExcel\PerComputeData.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" /> <ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...@@ -10,7 +10,12 @@ ...@@ -10,7 +10,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" /> <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>
<ItemGroup> <ItemGroup>
......
...@@ -16,13 +16,13 @@ namespace Performance.Extract.Api.Controllers ...@@ -16,13 +16,13 @@ namespace Performance.Extract.Api.Controllers
[Route("api/[controller]")] [Route("api/[controller]")]
public class ExtractController : Controller public class ExtractController : Controller
{ {
private readonly IHostingEnvironment evn; private readonly IWebHostEnvironment evn;
private readonly ILogger logger; private readonly ILogger logger;
private readonly WebapiUrl options; private readonly WebapiUrl options;
private readonly ExtractService extractService1; private readonly ExtractService extractService1;
public ExtractController( public ExtractController(
IHostingEnvironment evn, IWebHostEnvironment evn,
ILogger<ExtractController> logger, ILogger<ExtractController> logger,
IOptions<WebapiUrl> options, IOptions<WebapiUrl> options,
ExtractService extractService1) ExtractService extractService1)
......
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>3af57781-f816-4c0e-ab66-9b69387e7d35</UserSecretsId> <UserSecretsId>3af57781-f816-4c0e-ab66-9b69387e7d35</UserSecretsId>
</PropertyGroup> </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> <ItemGroup>
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" /> <ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
...@@ -36,11 +21,19 @@ ...@@ -36,11 +21,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.6.6" />
</ItemGroup>
<ItemGroup>
<None Update="Template\东方医院绩效模板.xlsx"> <None Update="Template\东方医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JSONSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project> </Project>
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Web;
namespace Performance.Extract.Api namespace Performance.Extract.Api
{ {
...@@ -14,11 +15,37 @@ public class Program ...@@ -14,11 +15,37 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
CreateWebHostBuilder(args).Build().Run(); 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) => public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(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 AutoMapper;
using CSRedis;
using FluentValidation; using FluentValidation;
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
...@@ -7,6 +8,7 @@ ...@@ -7,6 +8,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
...@@ -16,21 +18,16 @@ ...@@ -16,21 +18,16 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace Performance.Extract.Api namespace Performance.Extract.Api
{ {
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration, IHostingEnvironment env) public Startup(IConfiguration configuration)
{ {
env.ConfigureNLog("nlog.config");
Configuration = configuration; Configuration = configuration;
} }
...@@ -55,13 +52,11 @@ public void ConfigureServices(IServiceCollection services) ...@@ -55,13 +52,11 @@ public void ConfigureServices(IServiceCollection services)
#region json & fluentvalidation & filter #region json & fluentvalidation & filter
services services
//筛选器配置 //筛选器配置
.AddMvc(option => .AddControllers(option =>
{ {
option.Filters.Add<ExceptionsFilter>(); option.Filters.Add<ExceptionsFilter>();
}) })
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddNewtonsoftJson(json =>
//json格式配置
.AddJsonOptions(json =>
{ {
json.SerializerSettings.Converters.Add(new IsoDateTimeConverterContent() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }); json.SerializerSettings.Converters.Add(new IsoDateTimeConverterContent() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
...@@ -94,15 +89,8 @@ public void ConfigureServices(IServiceCollection services) ...@@ -94,15 +89,8 @@ public void ConfigureServices(IServiceCollection services)
.AddPerformanceRepoitory(); .AddPerformanceRepoitory();
#endregion #endregion
#region automapper services.AddAutoMapper(typeof(AutoMapperConfigs));
Mapper.Initialize(cfg => cfg.AddProfile<AutoMapperConfigs>()); RedisHelper.Initialization(new CSRedisClient(connection.Value.RedisConnectionString));
services.AddAutoMapper();
#endregion
#region redis
var csredis = new CSRedis.CSRedisClient(connection.Value.RedisConnectionString);
RedisHelper.Initialization(csredis);
#endregion
#region email #region email
...@@ -118,13 +106,10 @@ public void ConfigureServices(IServiceCollection services) ...@@ -118,13 +106,10 @@ public void ConfigureServices(IServiceCollection services)
#endregion #endregion
#region //ef配置
services.AddDbContext<PerformanceDbContext>(options => services.AddDbContext<PerformanceDbContext>(options =>
{ {
options.UseMySQL(connection.Value.PerformanceConnectionString); options.UseMySql(connection.Value.PerformanceConnectionString, ServerVersion.AutoDetect(connection.Value.PerformanceConnectionString));
}); });
#endregion
services.AddSignalR(); services.AddSignalR();
services.AddCors(options => services.AddCors(options =>
{ {
...@@ -136,20 +121,21 @@ public void ConfigureServices(IServiceCollection services) ...@@ -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. // 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()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
app.UseCors("SignalrCore"); app.UseCors("SignalrCore");
app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/allotLogHub"));
loggerFactory.CreateLogger<Startup>().LogDebug(env.EnvironmentName); 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) ...@@ -170,7 +170,7 @@ public static bool CreateFile(string filePath, byte[] buffer)
fs.Close(); fs.Close();
} }
} }
catch (Exception ex) catch (Exception)
{ {
return false; return false;
} }
......
...@@ -60,9 +60,9 @@ public static string HttpPost(string Url, string postDataStr, string encoding = ...@@ -60,9 +60,9 @@ public static string HttpPost(string Url, string postDataStr, string encoding =
return retString; return retString;
} }
} }
catch (Exception ex) catch (Exception)
{ {
throw ex; throw;
} }
finally finally
{ {
...@@ -149,9 +149,9 @@ public static void HttpPostNoRequest(string Url, string postDataStr, bool IsJson ...@@ -149,9 +149,9 @@ public static void HttpPostNoRequest(string Url, string postDataStr, bool IsJson
request.GetResponseAsync(); request.GetResponseAsync();
Thread.Sleep(1000); Thread.Sleep(1000);
} }
catch (Exception ex) catch (Exception)
{ {
throw ex; throw;
} }
finally finally
{ {
...@@ -188,9 +188,9 @@ public static string HttpClient(string url, string file, bool IsAsync = false) ...@@ -188,9 +188,9 @@ public static string HttpClient(string url, string file, bool IsAsync = false)
client.UploadFileAsync(new Uri(url), "POST", file); client.UploadFileAsync(new Uri(url), "POST", file);
return ""; 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 ...@@ -219,9 +219,9 @@ public static string HttpPost(string url, int timeout = -1, Dictionary<string, s
IRestResponse response = client.Execute(request); IRestResponse response = client.Execute(request);
return response.Content; return response.Content;
} }
catch (Exception ex) catch (Exception)
{ {
throw ex; throw;
} }
} }
} }
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" /> <PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" /> <PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="2.2.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" /> <PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="RestSharp" Version="106.13.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" /> <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.2.15" />
<PackageReference Include="RestSharp" Version="106.11.4" /> <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>
<ItemGroup> <ItemGroup>
......
...@@ -92,7 +92,7 @@ public bool RemoveRange(params TEntity[] entities) ...@@ -92,7 +92,7 @@ public bool RemoveRange(params TEntity[] entities)
public bool RemoveRange(Expression<Func<TEntity, bool>> exp) 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(); var entities = query == null || query.Count() == 0 ? null : query.ToList();
if (entities != null) if (entities != null)
context.Set<TEntity>().RemoveRange(entities); context.Set<TEntity>().RemoveRange(entities);
...@@ -142,30 +142,17 @@ public List<TEntity> GetEntities() ...@@ -142,30 +142,17 @@ public List<TEntity> GetEntities()
public List<TEntity> GetEntities(Expression<Func<TEntity, bool>> exp) public List<TEntity> GetEntities(Expression<Func<TEntity, bool>> exp)
{ {
var query = CompileQuery(exp); return context.Set<TEntity>().AsQueryable().Where(exp).ToList();
return query == null || query.Count() == 0 ? null : query.ToList();
} }
public List<TEntity> GetEntitiesForPaging(int Page, int pageSize, Expression<Func<TEntity, bool>> exp) 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) public TEntity GetEntity(Expression<Func<TEntity, bool>> exp)
{ {
return CompileQuerySingle(exp); return context.Set<TEntity>().AsQueryable().FirstOrDefault(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);
} }
#region Bulk #region Bulk
......
using MySql.Data.MySqlClient; using Microsoft.Data.SqlClient;
using MySql.Data.MySqlClient;
using Oracle.ManagedDataAccess.Client; using Oracle.ManagedDataAccess.Client;
using System; using System;
using System.Data; using System.Data;
using System.Data.SqlClient;
namespace Performance.Repository namespace Performance.Repository
{ {
......
...@@ -92,10 +92,10 @@ public bool ImportData(rep_importconfig import, Dictionary<string, object> pairs ...@@ -92,10 +92,10 @@ public bool ImportData(rep_importconfig import, Dictionary<string, object> pairs
transaction.Commit(); transaction.Commit();
} }
catch (Exception ex) catch (Exception)
{ {
transaction.Rollback(); transaction.Rollback();
throw ex; throw;
} }
} }
} }
...@@ -129,9 +129,9 @@ public void ClearResultData(int allotid) ...@@ -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);"; 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); 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) ...@@ -159,10 +159,10 @@ public void ImportWorkloadData(per_allot allot, object parameters)
transaction.Commit(); transaction.Commit();
} }
catch (Exception ex) catch (Exception)
{ {
transaction.Rollback(); transaction.Rollback();
throw ex; throw;
} }
} }
} }
...@@ -187,9 +187,9 @@ FROM view_second_report_workload ...@@ -187,9 +187,9 @@ FROM view_second_report_workload
ORDER BY doctorname,Category;"; ORDER BY doctorname,Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes = unittypes.Union(new string[] { "通用工作量" }), hospitalid }, commandTimeout: 60 * 60); 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 ...@@ -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); 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 ...@@ -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"; 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); 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) ...@@ -275,9 +275,9 @@ public IEnumerable<string> GetSecondWorkloadMaps(int hospitalId)
WHERE IFNULL(Category,'')<>''"; WHERE IFNULL(Category,'')<>''";
return connection.Query<string>(query, new { hospitalId }, commandTimeout: 60 * 60); 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> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
<PackageReference Include="Dapper.Contrib" Version="1.60.1" /> <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.4" />
<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>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" /> <ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" /> <ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
......
...@@ -14,6 +14,7 @@ namespace Performance.Services ...@@ -14,6 +14,7 @@ namespace Performance.Services
public class AgainAllotService : IAutoInjection public class AgainAllotService : IAutoInjection
{ {
private Application application; private Application application;
private readonly IMapper _mapper;
private AgainService againService; private AgainService againService;
private RoleService roleService; private RoleService roleService;
private ConfigService configService; private ConfigService configService;
...@@ -30,7 +31,10 @@ public class AgainAllotService : IAutoInjection ...@@ -30,7 +31,10 @@ public class AgainAllotService : IAutoInjection
private PerforAgemployeeRepository perforAgemployeeRepository; private PerforAgemployeeRepository perforAgemployeeRepository;
private PerforAgheaderRepository perforAgheaderRepository; private PerforAgheaderRepository perforAgheaderRepository;
public AgainAllotService(IOptions<Application> options, AgainService againService, public AgainAllotService(
IOptions<Application> options,
IMapper mapper,
AgainService againService,
RoleService roleService, RoleService roleService,
PerforCofagainRepository perforCofagainRepository, PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository, PerforPeragainallotRepository perforPeragainallotRepository,
...@@ -46,6 +50,7 @@ public class AgainAllotService : IAutoInjection ...@@ -46,6 +50,7 @@ public class AgainAllotService : IAutoInjection
ConfigService configService) ConfigService configService)
{ {
this.application = options.Value; this.application = options.Value;
_mapper = mapper;
this.againService = againService; this.againService = againService;
this.roleService = roleService; this.roleService = roleService;
this.perforCofagainRepository = perforCofagainRepository; this.perforCofagainRepository = perforCofagainRepository;
...@@ -197,24 +202,24 @@ public class AgainAllotService : IAutoInjection ...@@ -197,24 +202,24 @@ public class AgainAllotService : IAutoInjection
// #region 保存 // #region 保存
// var againsituation = Mapper.Map<ag_againsituation>(situation); // var againsituation = _mapper.Map<ag_againsituation>(situation);
// againsituation.AllotID = againAllot.AllotID; // againsituation.AllotID = againAllot.AllotID;
// againsituation.AgainAllotID = againAllot.ID; // againsituation.AgainAllotID = againAllot.ID;
// perforAgagainsituationRepository.Add(againsituation); // 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; }); // employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgemployeeRepository.AddRange(employeeList.ToArray()); // 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.AllotID = againAllot.AllotID;
// pHeader.AgainAllotID = againAllot.ID; // 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; }); // cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgheaderRepository.Add(pHeader); // perforAgheaderRepository.Add(pHeader);
// perforAgheaderRepository.AddRange(cHeaderList.ToArray()); // 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; }); // dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgdataRepository.AddRange(dataList.ToArray()); // perforAgdataRepository.AddRange(dataList.ToArray());
...@@ -314,27 +319,27 @@ public class AgainAllotService : IAutoInjection ...@@ -314,27 +319,27 @@ public class AgainAllotService : IAutoInjection
throw new PerformanceException("绩效二次分配不存在"); throw new PerformanceException("绩效二次分配不存在");
var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID); 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 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 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 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 pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
var head = Mapper.Map<PerHeader>(pHead); var head = _mapper.Map<PerHeader>(pHead);
var cHead = Mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资")); var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
head.Children = cHead; head.Children = cHead;
var perAgainExcel = new PerAgainExcel var perAgainExcel = new PerAgainExcel
{ {
Header = head, Header = head,
AgainData = Mapper.Map<List<PerAgainData>>(data), AgainData = _mapper.Map<List<PerAgainData>>(data),
AgainEmployee = Mapper.Map<List<PerAgainEmployee>>(againEmployee) AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee)
}; };
return SheetFormat(perAgainExcel, againsituation); return SheetFormat(perAgainExcel, againsituation);
...@@ -395,7 +400,7 @@ public List<AgainAllotResponse> GetAllotList(int userid) ...@@ -395,7 +400,7 @@ public List<AgainAllotResponse> GetAllotList(int userid)
} }
again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == 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 => list.ForEach(t =>
{ {
var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault(); var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
......
...@@ -28,15 +28,18 @@ namespace Performance.Services.AllotCompute ...@@ -28,15 +28,18 @@ namespace Performance.Services.AllotCompute
/// </summary> /// </summary>
public class ImportDataService : IAutoInjection public class ImportDataService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly IOptions<AppConnection> _options; private readonly IOptions<AppConnection> _options;
private readonly PerSheetService _perSheetService; private readonly PerSheetService _perSheetService;
private readonly LogManageService _logManageService; private readonly LogManageService _logManageService;
public ImportDataService( public ImportDataService(
IMapper mapper,
IOptions<AppConnection> options, IOptions<AppConnection> options,
PerSheetService perSheetService, PerSheetService perSheetService,
LogManageService logManageService) LogManageService logManageService)
{ {
_mapper = mapper;
_options = options; _options = options;
_perSheetService = perSheetService; _perSheetService = perSheetService;
_logManageService = logManageService; _logManageService = logManageService;
...@@ -85,8 +88,8 @@ private PerExcel Import(per_allot allot) ...@@ -85,8 +88,8 @@ private PerExcel Import(per_allot allot)
var sheetType = _perSheetService.GetSheetType(sheet.SheetName); var sheetType = _perSheetService.GetSheetType(sheet.SheetName);
if (SheetType.Unidentifiable != sheetType) if (SheetType.Unidentifiable != sheetType)
_logManageService.WriteMsg("准备读取文件", $"正在准备读取“{sheet.SheetName}”", 1, allot.ID, "ReceiveMessage", true); _logManageService.WriteMsg("准备读取文件", $"正在准备读取“{sheet.SheetName}”", 1, allot.ID, "ReceiveMessage", true);
else //else
_logManageService.WriteMsg("准备读取文件", $"忽略文件“{sheet.SheetName}”", 1, allot.ID, "ReceiveMessage", true); //_logManageService.WriteMsg("准备读取文件", $"忽略文件“{sheet.SheetName}”", 1, allot.ID, "ReceiveMessage", true);
try try
{ {
...@@ -114,7 +117,7 @@ private PerExcel Import(per_allot allot) ...@@ -114,7 +117,7 @@ private PerExcel Import(per_allot allot)
catch (Exception ex) catch (Exception ex)
{ {
_logManageService.WriteMsg("读取文件", ex.Message.ToString(), 4, allot.ID, "ReceiveMessage", true); _logManageService.WriteMsg("读取文件", ex.Message.ToString(), 4, allot.ID, "ReceiveMessage", true);
throw ex; throw;
} }
} }
...@@ -206,7 +209,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi ...@@ -206,7 +209,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
var employeeList = connection.Query<im_employee>("select * from im_employee where AllotID = @allotid", new { AllotID = allot.ID }); var employeeList = connection.Query<im_employee>("select * from im_employee where AllotID = @allotid", new { AllotID = allot.ID });
if (employeeList != null && employeeList.Count() > 0) if (employeeList != null && employeeList.Count() > 0)
{ {
dataList = Mapper.Map<List<PerDataEmployee>>(employeeList); dataList = _mapper.Map<List<PerDataEmployee>>(employeeList);
break; break;
} }
} }
...@@ -214,7 +217,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi ...@@ -214,7 +217,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
List<im_employee> addList = new List<im_employee>(); List<im_employee> addList = new List<im_employee>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_employee>(data); var imdata = _mapper.Map<im_employee>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
//imdata.OtherPerfor = data.OthePerfor; //imdata.OtherPerfor = data.OthePerfor;
...@@ -238,7 +241,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi ...@@ -238,7 +241,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
// var employeeList = perforImEmployeeRepository.GetEntities(t => t.AllotID == item.ID); // var employeeList = perforImEmployeeRepository.GetEntities(t => t.AllotID == item.ID);
// if (employeeList != null && employeeList.Count > 0) // if (employeeList != null && employeeList.Count > 0)
// { // {
// dataList = Mapper.Map<List<PerDataEmployee>>(employeeList); // dataList = _mapper.Map<List<PerDataEmployee>>(employeeList);
// break; // break;
// } // }
// } // }
...@@ -246,7 +249,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi ...@@ -246,7 +249,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
//List<im_employee> addList = new List<im_employee>(); //List<im_employee> addList = new List<im_employee>();
//foreach (var data in dataList) //foreach (var data in dataList)
//{ //{
// var imdata = Mapper.Map<im_employee>(data); // var imdata = _mapper.Map<im_employee>(data);
// imdata.SheetID = imsheet.ID; // imdata.SheetID = imsheet.ID;
// imdata. AllotID =allot.ID; // imdata. AllotID =allot.ID;
// //imdata.OtherPerfor = data.OthePerfor; // //imdata.OtherPerfor = data.OthePerfor;
...@@ -278,7 +281,7 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a ...@@ -278,7 +281,7 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
var employeeList = connection.Query<im_employee_clinic>("select * from im_employee_clinic where AllotID = @allotid", new { AllotID = allot.ID }); var employeeList = connection.Query<im_employee_clinic>("select * from im_employee_clinic where AllotID = @allotid", new { AllotID = allot.ID });
if (employeeList != null && employeeList.Count() > 0) if (employeeList != null && employeeList.Count() > 0)
{ {
dataList = Mapper.Map<List<PerDataClinicEmployee>>(employeeList); dataList = _mapper.Map<List<PerDataClinicEmployee>>(employeeList);
break; break;
} }
} }
...@@ -286,7 +289,7 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a ...@@ -286,7 +289,7 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
List<im_employee_clinic> addList = new List<im_employee_clinic>(); List<im_employee_clinic> addList = new List<im_employee_clinic>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_employee_clinic>(data); var imdata = _mapper.Map<im_employee_clinic>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
imdata.OtherPerfor = data.OthePerfor; imdata.OtherPerfor = data.OthePerfor;
...@@ -319,7 +322,7 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot ...@@ -319,7 +322,7 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
var employeeList = connection.Query<im_employee_logistics>("select * from im_employee_logistics where AllotID = @allotid", new { AllotID = allot.ID }); var employeeList = connection.Query<im_employee_logistics>("select * from im_employee_logistics where AllotID = @allotid", new { AllotID = allot.ID });
if (employeeList != null && employeeList.Count() > 0) if (employeeList != null && employeeList.Count() > 0)
{ {
dataList = Mapper.Map<List<PerDataLogisticsEmployee>>(employeeList); dataList = _mapper.Map<List<PerDataLogisticsEmployee>>(employeeList);
break; break;
} }
} }
...@@ -327,7 +330,7 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot ...@@ -327,7 +330,7 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
List<im_employee_logistics> addList = new List<im_employee_logistics>(); List<im_employee_logistics> addList = new List<im_employee_logistics>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_employee_logistics>(data); var imdata = _mapper.Map<im_employee_logistics>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
imdata.OtherPerfor = data.OthePerfor; imdata.OtherPerfor = data.OthePerfor;
...@@ -367,7 +370,7 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she ...@@ -367,7 +370,7 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she
List<im_accountbasic> addList = new List<im_accountbasic>(); List<im_accountbasic> addList = new List<im_accountbasic>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_accountbasic>(data); var imdata = _mapper.Map<im_accountbasic>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
addList.Add(imdata); addList.Add(imdata);
...@@ -394,7 +397,7 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot) ...@@ -394,7 +397,7 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot)
List<im_specialunit> addList = new List<im_specialunit>(); List<im_specialunit> addList = new List<im_specialunit>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_specialunit>(data); var imdata = _mapper.Map<im_specialunit>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
addList.Add(imdata); addList.Add(imdata);
...@@ -436,7 +439,7 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets) ...@@ -436,7 +439,7 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets)
var dataList = sheet.PerData.Select(t => (PerData)t); var dataList = sheet.PerData.Select(t => (PerData)t);
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_data>(data); var imdata = _mapper.Map<im_data>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
addDataList.Add(imdata); addDataList.Add(imdata);
...@@ -460,7 +463,7 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid) ...@@ -460,7 +463,7 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid)
List<im_header> addHeadList = new List<im_header>(); List<im_header> addHeadList = new List<im_header>();
foreach (var header in sheet.PerHeader) foreach (var header in sheet.PerHeader)
{ {
var imheader = Mapper.Map<im_header>(header); var imheader = _mapper.Map<im_header>(header);
imheader.SheetID = imsheetid; imheader.SheetID = imsheetid;
imheader.AllotID = allot.ID; imheader.AllotID = allot.ID;
imheader.ID = (int)connection.Insert(imheader); imheader.ID = (int)connection.Insert(imheader);
...@@ -469,7 +472,7 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid) ...@@ -469,7 +472,7 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid)
{ {
foreach (var child in header.Children) foreach (var child in header.Children)
{ {
var imheaderChild = Mapper.Map<im_header>(child); var imheaderChild = _mapper.Map<im_header>(child);
imheaderChild.SheetID = imsheetid; imheaderChild.SheetID = imsheetid;
imheaderChild.ParentID = imheader.ID; imheaderChild.ParentID = imheader.ID;
imheaderChild.AllotID = allot.ID; imheaderChild.AllotID = allot.ID;
......
...@@ -16,6 +16,7 @@ namespace Performance.Services.AllotCompute ...@@ -16,6 +16,7 @@ namespace Performance.Services.AllotCompute
/// </summary> /// </summary>
public class ProcessComputService : IAutoInjection public class ProcessComputService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly BudgetService _budgetService; private readonly BudgetService _budgetService;
private PerforCofincomeRepository perforCofincomeRepository; private PerforCofincomeRepository perforCofincomeRepository;
private PerforPersheetRepository perforPerSheetRepository; private PerforPersheetRepository perforPerSheetRepository;
...@@ -33,6 +34,7 @@ public class ProcessComputService : IAutoInjection ...@@ -33,6 +34,7 @@ public class ProcessComputService : IAutoInjection
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
public ProcessComputService( public ProcessComputService(
IMapper mapper,
BudgetService budgetService, BudgetService budgetService,
PerforCofincomeRepository perforCofincomeRepository, PerforCofincomeRepository perforCofincomeRepository,
PerforPersheetRepository perforPerSheetRepository, PerforPersheetRepository perforPerSheetRepository,
...@@ -49,6 +51,7 @@ public class ProcessComputService : IAutoInjection ...@@ -49,6 +51,7 @@ public class ProcessComputService : IAutoInjection
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository) PerforPerallotRepository perallotRepository)
{ {
_mapper = mapper;
_budgetService = budgetService; _budgetService = budgetService;
this.perforCofincomeRepository = perforCofincomeRepository; this.perforCofincomeRepository = perforCofincomeRepository;
this.perforPerSheetRepository = perforPerSheetRepository; this.perforPerSheetRepository = perforPerSheetRepository;
...@@ -101,7 +104,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId) ...@@ -101,7 +104,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
List<res_account> addList = new List<res_account>(); List<res_account> addList = new List<res_account>();
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<res_account>(data); var imdata = _mapper.Map<res_account>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId; imdata.AllotID = allotId;
addList.Add(imdata); addList.Add(imdata);
...@@ -123,7 +126,7 @@ private void SaveCommon(PerSheet sheet, int allotId) ...@@ -123,7 +126,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
List<im_header> addHeadList = new List<im_header>(); List<im_header> addHeadList = new List<im_header>();
foreach (var header in sheet.PerHeader) 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.SheetID = imsheet.ID;
imheader.AllotID = allotId; imheader.AllotID = allotId;
perforImHeaderRepository.Add(imheader); perforImHeaderRepository.Add(imheader);
...@@ -131,7 +134,7 @@ private void SaveCommon(PerSheet sheet, int allotId) ...@@ -131,7 +134,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
{ {
foreach (var child in header.Children) 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.SheetID = imsheet.ID;
imheaderChild.ParentID = imheader.ID; imheaderChild.ParentID = imheader.ID;
imheaderChild.AllotID = allotId; imheaderChild.AllotID = allotId;
...@@ -145,7 +148,7 @@ private void SaveCommon(PerSheet sheet, int allotId) ...@@ -145,7 +148,7 @@ private void SaveCommon(PerSheet sheet, int allotId)
var dataList = sheet.PerData.Select(t => (PerData)t); var dataList = sheet.PerData.Select(t => (PerData)t);
foreach (var data in dataList) foreach (var data in dataList)
{ {
var imdata = Mapper.Map<im_data>(data); var imdata = _mapper.Map<im_data>(data);
imdata.SheetID = imsheet.ID; imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId; imdata.AllotID = allotId;
addDataList.Add(imdata); addDataList.Add(imdata);
...@@ -429,7 +432,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel) ...@@ -429,7 +432,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
List<res_account> addList = new List<res_account>(); List<res_account> addList = new List<res_account>();
foreach (var data in perDatas) foreach (var data in perDatas)
{ {
var imdata = Mapper.Map<res_account>(data); var imdata = _mapper.Map<res_account>(data);
imdata.AllotID = allot.ID; imdata.AllotID = allot.ID;
addList.Add(imdata); addList.Add(imdata);
} }
......
...@@ -12,6 +12,7 @@ namespace Performance.Services.AllotCompute ...@@ -12,6 +12,7 @@ namespace Performance.Services.AllotCompute
{ {
public class QueryDataService : IAutoInjection public class QueryDataService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly LogManageService logManageService; private readonly LogManageService logManageService;
private readonly PerforPersheetRepository persheetRepository; private readonly PerforPersheetRepository persheetRepository;
private readonly PerforImemployeeRepository imemployeeRepository; private readonly PerforImemployeeRepository imemployeeRepository;
...@@ -21,7 +22,9 @@ public class QueryDataService : IAutoInjection ...@@ -21,7 +22,9 @@ public class QueryDataService : IAutoInjection
private readonly PerforImdataRepository imdataRepository; private readonly PerforImdataRepository imdataRepository;
private readonly PerforImheaderRepository imheaderRepository; private readonly PerforImheaderRepository imheaderRepository;
public QueryDataService(LogManageService logManageService, public QueryDataService(
IMapper mapper,
LogManageService logManageService,
PerforPersheetRepository persheetRepository, PerforPersheetRepository persheetRepository,
PerforImemployeeRepository imemployeeRepository, PerforImemployeeRepository imemployeeRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository, PerforImemployeeclinicRepository imemployeeclinicRepository,
...@@ -30,6 +33,7 @@ public class QueryDataService : IAutoInjection ...@@ -30,6 +33,7 @@ public class QueryDataService : IAutoInjection
PerforImdataRepository imdataRepository, PerforImdataRepository imdataRepository,
PerforImheaderRepository imheaderRepository) PerforImheaderRepository imheaderRepository)
{ {
_mapper = mapper;
this.logManageService = logManageService; this.logManageService = logManageService;
this.persheetRepository = persheetRepository; this.persheetRepository = persheetRepository;
this.imemployeeRepository = imemployeeRepository; this.imemployeeRepository = imemployeeRepository;
...@@ -121,7 +125,7 @@ private PerExcel Query(List<per_sheet> sheets, int allotId) ...@@ -121,7 +125,7 @@ private PerExcel Query(List<per_sheet> sheets, int allotId)
private void QueryEmployee(int allotId, int sheetId, PerSheet sheet) private void QueryEmployee(int allotId, int sheetId, PerSheet sheet)
{ {
var data = imemployeeRepository.GetEntities(t => t.AllotID == allotId && t.SheetID == sheetId); 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()) if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData); sheet.PerData.AddRange(sheetData);
} }
...@@ -129,7 +133,7 @@ private void QueryEmployee(int allotId, int sheetId, PerSheet sheet) ...@@ -129,7 +133,7 @@ private void QueryEmployee(int allotId, int sheetId, PerSheet sheet)
private void QueryClinicEmployee(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 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()) if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData); sheet.PerData.AddRange(sheetData);
} }
...@@ -137,7 +141,7 @@ private void QueryClinicEmployee(int allotId, int sheetId, PerSheet sheet) ...@@ -137,7 +141,7 @@ private void QueryClinicEmployee(int allotId, int sheetId, PerSheet sheet)
private void QueryAccountBasic(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 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()) if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData); sheet.PerData.AddRange(sheetData);
} }
...@@ -145,7 +149,7 @@ private void QueryAccountBasic(int allotId, int sheetId, PerSheet sheet) ...@@ -145,7 +149,7 @@ private void QueryAccountBasic(int allotId, int sheetId, PerSheet sheet)
private void QuerySpecialUnit(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 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()) if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData); sheet.PerData.AddRange(sheetData);
} }
...@@ -153,7 +157,7 @@ private void QuerySpecialUnit(int allotId, int sheetId, PerSheet sheet) ...@@ -153,7 +157,7 @@ private void QuerySpecialUnit(int allotId, int sheetId, PerSheet sheet)
private void QueryCommon(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 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()) if (sheetData != null && sheetData.Any())
sheet.PerData.AddRange(sheetData); sheet.PerData.AddRange(sheetData);
} }
...@@ -169,7 +173,7 @@ private List<PerHeader> GetHeaderAndChild(List<im_header> headers, List<im_heade ...@@ -169,7 +173,7 @@ private List<PerHeader> GetHeaderAndChild(List<im_header> headers, List<im_heade
{ {
foreach (var header in headers) 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); var children = allheaders.Where(t => t.ParentID == header.ID);
if (children != null && children.Any()) if (children != null && children.Any())
{ {
......
...@@ -23,6 +23,7 @@ public class ResultComputeService : IAutoInjection ...@@ -23,6 +23,7 @@ public class ResultComputeService : IAutoInjection
private readonly PerforPerallotRepository perforPerallotRepository; private readonly PerforPerallotRepository perforPerallotRepository;
//private readonly PerforAgcomputeRepository perforAgcomputeRepository; //private readonly PerforAgcomputeRepository perforAgcomputeRepository;
private readonly PerforAgsecondallotRepository perforAgsecondallotRepository; private readonly PerforAgsecondallotRepository perforAgsecondallotRepository;
private readonly IMapper _mapper;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforImemployeeRepository perforImEmployeeRepository; private readonly PerforImemployeeRepository perforImEmployeeRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository; private readonly PerforRescomputeRepository perforRescomputeRepository;
...@@ -36,6 +37,7 @@ public class ResultComputeService : IAutoInjection ...@@ -36,6 +37,7 @@ public class ResultComputeService : IAutoInjection
private readonly ILogger logger; private readonly ILogger logger;
public ResultComputeService( public ResultComputeService(
IMapper mapper,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforImemployeeRepository perforImEmployeeRepository, PerforImemployeeRepository perforImEmployeeRepository,
PerforRescomputeRepository perforRescomputeRepository, PerforRescomputeRepository perforRescomputeRepository,
...@@ -55,6 +57,7 @@ public class ResultComputeService : IAutoInjection ...@@ -55,6 +57,7 @@ public class ResultComputeService : IAutoInjection
{ {
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
this.computeDirector = computeDirector; this.computeDirector = computeDirector;
_mapper = mapper;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.perforImEmployeeRepository = perforImEmployeeRepository; this.perforImEmployeeRepository = perforImEmployeeRepository;
this.perforRescomputeRepository = perforRescomputeRepository; this.perforRescomputeRepository = perforRescomputeRepository;
...@@ -83,7 +86,7 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet) ...@@ -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 empolyeeList = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID);
var accountbasicList = perforImaccountbasicRepository.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"); logManageService.WriteMsg("正在生成绩效", "科室主任、护士长 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult = computeDirector.Compute(computeEmployees, accountSheet, allot); var computResult = computeDirector.Compute(computeEmployees, accountSheet, allot);
...@@ -93,12 +96,12 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet) ...@@ -93,12 +96,12 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet)
baiscNormService.DocterNurseBaiscnorm(baiscnormList, accountbasicList, accountSheet); baiscNormService.DocterNurseBaiscnorm(baiscnormList, accountbasicList, accountSheet);
var empolyeeList2 = perforImEmployeeRepository.GetEntities(t => t.AllotID == allot.ID); 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"); logManageService.WriteMsg("正在生成绩效", "行政中高层 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult2 = computeDirector.Compute(computeEmployees2, allot, baiscnormList, accountbasicList); var computResult2 = computeDirector.Compute(computeEmployees2, allot, baiscnormList, accountbasicList);
var empolyeeList3 = perforImemployeelogisticsRepository.GetEntities(t => t.AllotID == allot.ID); 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"); logManageService.WriteMsg("正在生成绩效", "行政后勤 最终绩效数据计算", 1, allot.ID, "ReceiveMessage");
var computResult3 = computeDirector.Compute(computeEmployees3, allot, baiscnormList, accountbasicList); var computResult3 = computeDirector.Compute(computeEmployees3, allot, baiscnormList, accountbasicList);
...@@ -107,9 +110,9 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet) ...@@ -107,9 +110,9 @@ public List<res_baiscnorm> Compute(per_allot allot, List<PerSheet> accountSheet)
//计算 行政人员 平均值 //计算 行政人员 平均值
baiscNormService.ComputeOtherAvg(baiscnormList, computResult3, empolyeeList3); baiscNormService.ComputeOtherAvg(baiscnormList, computResult3, empolyeeList3);
var computes = Mapper.Map<List<res_compute>>(computResult); var computes = _mapper.Map<List<res_compute>>(computResult);
computes.AddRange(Mapper.Map<List<res_compute>>(computResult2)); computes.AddRange(_mapper.Map<List<res_compute>>(computResult2));
computes.AddRange(Mapper.Map<List<res_compute>>(computResult3)); computes.AddRange(_mapper.Map<List<res_compute>>(computResult3));
computes.ForEach(t => t.AllotID = allot.ID); computes.ForEach(t => t.AllotID = allot.ID);
perforRescomputeRepository.AddRange(computes.ToArray()); perforRescomputeRepository.AddRange(computes.ToArray());
...@@ -144,7 +147,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -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 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()); 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>(); List<ComputeResult> computeList = new List<ComputeResult>();
foreach (var group in groupSpeList) foreach (var group in groupSpeList)
...@@ -303,7 +306,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -303,7 +306,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
computeList.Add(compute); 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); computes.ForEach(t => t.AllotID = allot.ID);
perforRescomputeRepository.AddRange(computes.ToArray()); perforRescomputeRepository.AddRange(computes.ToArray());
perforResspecialunitRepository.AddRange(resDataList.ToArray()); perforResspecialunitRepository.AddRange(resDataList.ToArray());
...@@ -674,7 +677,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req ...@@ -674,7 +677,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
if ((item.RealGiveFee ?? 0) == 0 && (item.PreRealGiveFee ?? 0) > 0) 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.RealGiveFee = item.PreRealGiveFee;
promptSecond.StatusRemake = ""; promptSecond.StatusRemake = "";
promptSecond.IssueStatus = 4; promptSecond.IssueStatus = 4;
...@@ -682,7 +685,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req ...@@ -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)) 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.StatusRemake = $@"未提交科室实发绩效变更,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 3; promptSecond.IssueStatus = 3;
promptSecond.RealGiveFee = item.PreRealGiveFee; promptSecond.RealGiveFee = item.PreRealGiveFee;
...@@ -690,7 +693,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req ...@@ -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)) 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.StatusRemake = $@"已提交或已审核科室实发绩效变更驳回,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 2; promptSecond.IssueStatus = 2;
promptSecond.RealGiveFee = item.PreRealGiveFee; promptSecond.RealGiveFee = item.PreRealGiveFee;
...@@ -707,7 +710,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req ...@@ -707,7 +710,7 @@ public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest req
} }
else if ((item.RealGiveFee ?? 0) >= 0 && (item.PreRealGiveFee ?? 0) == 0) 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.StatusRemake = "";
promptSecond.IssueStatus = 1; promptSecond.IssueStatus = 1;
promptSeconds.Add(promptSecond); promptSeconds.Add(promptSecond);
......
using AutoMapper; using AutoMapper;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -12,9 +14,13 @@ ...@@ -12,9 +14,13 @@
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using Dapper;
using Microsoft.Extensions.Caching.Memory;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -27,11 +33,13 @@ public class AllotService : IAutoInjection ...@@ -27,11 +33,13 @@ public class AllotService : IAutoInjection
private ResultComputeService resultComputeService; private ResultComputeService resultComputeService;
private PerforLogdbugRepository logdbug; private PerforLogdbugRepository logdbug;
private ConfigService configService; private ConfigService configService;
private IHostingEnvironment _evn; private IWebHostEnvironment _evn;
private ILogger<AllotService> _logger; private ILogger<AllotService> _logger;
private readonly IMapper _mapper;
private PerforPerallotRepository _allotRepository; private PerforPerallotRepository _allotRepository;
private IEmailService emailService; private IEmailService emailService;
private readonly IOptions<Application> options; private readonly IOptions<Application> options;
private readonly IOptions<AppConnection> _appConnection;
private readonly ComputeDirector _computeDirector; private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository; private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository; private readonly PerforImemployeeRepository _perforImEmployeeRepository;
...@@ -53,6 +61,7 @@ public class AllotService : IAutoInjection ...@@ -53,6 +61,7 @@ public class AllotService : IAutoInjection
private readonly QueryDataService queryDataService; private readonly QueryDataService queryDataService;
public AllotService( public AllotService(
IMapper mapper,
PerforPerallotRepository allotRepository, PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
CheckDataService checkDataService, CheckDataService checkDataService,
...@@ -61,9 +70,10 @@ public class AllotService : IAutoInjection ...@@ -61,9 +70,10 @@ public class AllotService : IAutoInjection
ResultComputeService resultComputeService, ResultComputeService resultComputeService,
ConfigService configService, ConfigService configService,
PerforLogdbugRepository logdbug, PerforLogdbugRepository logdbug,
IHostingEnvironment evn, ILogger<AllotService> logger, IWebHostEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService, IEmailService emailService,
IOptions<Application> options, IOptions<Application> options,
IOptions<AppConnection> appConnection,
ComputeDirector computeDirector, ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository, PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository, PerforImemployeeRepository perforImEmployeeRepository,
...@@ -82,6 +92,7 @@ public class AllotService : IAutoInjection ...@@ -82,6 +92,7 @@ public class AllotService : IAutoInjection
PerforPeremployeeRepository perforPeremployeeRepository, PerforPeremployeeRepository perforPeremployeeRepository,
QueryDataService queryDataService) QueryDataService queryDataService)
{ {
_mapper = mapper;
_allotRepository = allotRepository; _allotRepository = allotRepository;
_againallotRepository = againallotRepository; _againallotRepository = againallotRepository;
_logger = logger; _logger = logger;
...@@ -93,6 +104,7 @@ public class AllotService : IAutoInjection ...@@ -93,6 +104,7 @@ public class AllotService : IAutoInjection
this.resultComputeService = resultComputeService; this.resultComputeService = resultComputeService;
this.emailService = emailService; this.emailService = emailService;
this.options = options; this.options = options;
_appConnection = appConnection;
_computeDirector = computeDirector; _computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository; _perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository; _perforImEmployeeRepository = perforImEmployeeRepository;
...@@ -127,7 +139,7 @@ public List<AllotResponse> GetAllotList(int? hospitalId) ...@@ -127,7 +139,7 @@ public List<AllotResponse> GetAllotList(int? hospitalId)
var allotList = _allotRepository.GetEntities(t => t.HospitalId == hospitalId); var allotList = _allotRepository.GetEntities(t => t.HospitalId == hospitalId);
allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList(); allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList();
var isconfig = perforHospitalconfigRepository.GetEntity(t => t.HospitalId == hospitalId) == null ? false : true; 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 => result?.ForEach(t =>
{ {
t.IsDown = !string.IsNullOrEmpty(t.ExtractPath); t.IsDown = !string.IsNullOrEmpty(t.ExtractPath);
...@@ -156,7 +168,7 @@ public List<AllotResponse> GetSuccAllotList(int? hospitalId) ...@@ -156,7 +168,7 @@ public List<AllotResponse> GetSuccAllotList(int? hospitalId)
&& new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States)); && new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States));
allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList(); allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList();
var isconfig = perforHospitalconfigRepository.GetEntity(t => t.HospitalId == hospitalId) == null ? false : true; 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 => reuslt?.ForEach(t =>
{ {
t.IsDown = !string.IsNullOrEmpty(t.ExtractPath); t.IsDown = !string.IsNullOrEmpty(t.ExtractPath);
...@@ -179,7 +191,7 @@ public per_allot InsertAllot(AllotRequest request, int userID) ...@@ -179,7 +191,7 @@ public per_allot InsertAllot(AllotRequest request, int userID)
if (repAllot != null && repAllot.Count() > 0) if (repAllot != null && repAllot.Count() > 0)
throw new PerformanceException("当前绩效记录已存在"); throw new PerformanceException("当前绩效记录已存在");
var allot = Mapper.Map<per_allot>(request); var allot = _mapper.Map<per_allot>(request);
allot.CreateDate = DateTime.Now; allot.CreateDate = DateTime.Now;
allot.CreateUser = userID; allot.CreateUser = userID;
allot.States = (int)AllotStates.NoData; allot.States = (int)AllotStates.NoData;
...@@ -212,7 +224,7 @@ public AllotResponse UpdateAllot(AllotRequest request) ...@@ -212,7 +224,7 @@ public AllotResponse UpdateAllot(AllotRequest request)
if (!_allotRepository.Update(allot)) if (!_allotRepository.Update(allot))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<AllotResponse>(allot); return _mapper.Map<AllotResponse>(allot);
} }
/// <summary> /// <summary>
...@@ -484,7 +496,10 @@ public void GenerateReport(per_allot allot) ...@@ -484,7 +496,10 @@ public void GenerateReport(per_allot allot)
/// <param name="allot"></param> /// <param name="allot"></param>
public void AccoungtingVerify(int allotId) 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> /// <summary>
...@@ -500,7 +515,7 @@ public void Recalculation(int allotId, decimal money) ...@@ -500,7 +515,7 @@ public void Recalculation(int allotId, decimal money)
if (empolyeeList == null) return; if (empolyeeList == null) return;
var computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList); var computeEmployees = _mapper.Map<List<ComputeEmployee>>(empolyeeList);
computeEmployees.ForEach(w => w.FitPeopleValue = money); computeEmployees.ForEach(w => w.FitPeopleValue = money);
List<res_baiscnorm> baiscnormList = new List<res_baiscnorm>(); List<res_baiscnorm> baiscnormList = new List<res_baiscnorm>();
...@@ -515,7 +530,7 @@ public void Recalculation(int allotId, decimal money) ...@@ -515,7 +530,7 @@ public void Recalculation(int allotId, decimal money)
if (historyRescompute != null && historyRescompute.Any()) if (historyRescompute != null && historyRescompute.Any())
_perforRescomputeRepository.RemoveRange(historyRescompute.ToArray()); _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); computes.ForEach(t => t.AllotID = allot.ID);
_perforRescomputeRepository.AddRange(computes.ToArray()); _perforRescomputeRepository.AddRange(computes.ToArray());
...@@ -523,7 +538,7 @@ public void Recalculation(int allotId, decimal money) ...@@ -523,7 +538,7 @@ public void Recalculation(int allotId, decimal money)
var historyResbaiscnorm = perforResbaiscnormRepository.GetEntities(w => w.AllotID == allotId && names.Contains(w.PositionName)); var historyResbaiscnorm = perforResbaiscnormRepository.GetEntities(w => w.AllotID == allotId && names.Contains(w.PositionName));
if (historyResbaiscnorm != null && historyResbaiscnorm.Any()) if (historyResbaiscnorm != null && historyResbaiscnorm.Any())
perforResbaiscnormRepository.RemoveRange(historyResbaiscnorm.ToArray()); perforResbaiscnormRepository.RemoveRange(historyResbaiscnorm.ToArray());
perforResbaiscnormRepository.AddRange(Mapper.Map<res_baiscnorm[]>(baiscnormList)); perforResbaiscnormRepository.AddRange(_mapper.Map<res_baiscnorm[]>(baiscnormList));
} }
/// <summary> /// <summary>
...@@ -593,7 +608,7 @@ public void Pigeonhole(per_allot allot) ...@@ -593,7 +608,7 @@ public void Pigeonhole(per_allot allot)
public List<AgainAllotResponse> GetAgainAllotNotSucceed(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)); 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) if (result != null && result.Count > 0)
{ {
result.ForEach(t => { t.Year = allot.Year; t.Month = allot.Month; }); result.ForEach(t => { t.Year = allot.Year; t.Month = allot.Month; });
...@@ -709,7 +724,7 @@ public List<OwnerPerformanceDto> GetOwnerPerformance(int userid) ...@@ -709,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) .Where(p => p.Year == w.Key.Year && p.Month == w.Key.Month && p.JobNumber == w.Key.JobNumber)
.Select(detial => .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.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); 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 ...@@ -14,18 +14,22 @@ namespace Performance.Services
{ {
public class BudgetService : IAutoInjection public class BudgetService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly PerforPerbudgetamountRepository perbudgetamountRepository; private readonly PerforPerbudgetamountRepository perbudgetamountRepository;
private readonly PerforPerbudgetratioRepository perbudgetratioRepository; private readonly PerforPerbudgetratioRepository perbudgetratioRepository;
private readonly PerforPerbudgetresultRepository perbudgetresultRepository; private readonly PerforPerbudgetresultRepository perbudgetresultRepository;
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
private readonly ILogger logger; private readonly ILogger logger;
public BudgetService(PerforPerbudgetamountRepository perbudgetamountRepository, public BudgetService(
IMapper mapper,
PerforPerbudgetamountRepository perbudgetamountRepository,
PerforPerbudgetratioRepository perbudgetratioRepository, PerforPerbudgetratioRepository perbudgetratioRepository,
PerforPerbudgetresultRepository perbudgetresultRepository, PerforPerbudgetresultRepository perbudgetresultRepository,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
ILogger<BudgetService> logger) ILogger<BudgetService> logger)
{ {
_mapper = mapper;
this.perbudgetamountRepository = perbudgetamountRepository; this.perbudgetamountRepository = perbudgetamountRepository;
this.perbudgetratioRepository = perbudgetratioRepository; this.perbudgetratioRepository = perbudgetratioRepository;
this.perbudgetresultRepository = perbudgetresultRepository; this.perbudgetresultRepository = perbudgetresultRepository;
...@@ -43,12 +47,12 @@ public List<BudgetResponse> QueryBudgetByYear(int hospitalid, int year) ...@@ -43,12 +47,12 @@ public List<BudgetResponse> QueryBudgetByYear(int hospitalid, int year)
{ {
var amounts = perbudgetamountRepository.GetEntities(t => t.HospitalId == hospitalid && t.MainYear == year); var amounts = perbudgetamountRepository.GetEntities(t => t.HospitalId == hospitalid && t.MainYear == year);
var ratios = perbudgetratioRepository.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) if (result == null)
return Mapper.Map<List<BudgetResponse>>(ratios); return _mapper.Map<List<BudgetResponse>>(ratios);
else if (ratios != null && ratios.Any()) 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(); return result.OrderBy(t => t.Year).ToList();
} }
...@@ -68,7 +72,7 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI ...@@ -68,7 +72,7 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI
if (entity != null && entity.Any()) if (entity != null && entity.Any())
throw new PerformanceException($"{mainYear}年数据已存在"); 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 => amounts.ForEach(t =>
{ {
t.MainYear = mainYear; t.MainYear = mainYear;
...@@ -77,7 +81,7 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI ...@@ -77,7 +81,7 @@ public bool SaveBudgetData(int mainYear, List<BudgetResponse> request, int userI
}); });
if (amounts != null && perbudgetamountRepository.AddRange(amounts.ToArray())) 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); var budgetData = request.FirstOrDefault(t => t.Type == 2);
ratios.ForEach(t => ratios.ForEach(t =>
{ {
......
...@@ -17,6 +17,7 @@ namespace Performance.Services ...@@ -17,6 +17,7 @@ namespace Performance.Services
{ {
public class ComputeService : IAutoInjection public class ComputeService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly PerforResaccountRepository perforResaccountRepository; private readonly PerforResaccountRepository perforResaccountRepository;
private readonly PerforPersheetRepository _perforPerSheetRepository; private readonly PerforPersheetRepository _perforPerSheetRepository;
private readonly PerforImdataRepository _perforImDataRepository; private readonly PerforImdataRepository _perforImDataRepository;
...@@ -39,6 +40,7 @@ public class ComputeService : IAutoInjection ...@@ -39,6 +40,7 @@ public class ComputeService : IAutoInjection
private readonly PerforReportRepository reportRepository; private readonly PerforReportRepository reportRepository;
public ComputeService( public ComputeService(
IMapper mapper,
PerforResaccountRepository perforResaccountRepository, PerforResaccountRepository perforResaccountRepository,
PerforPersheetRepository perforPerSheetRepository, PerforPersheetRepository perforPerSheetRepository,
PerforImdataRepository perforImDataRepository, PerforImdataRepository perforImDataRepository,
...@@ -60,6 +62,7 @@ public class ComputeService : IAutoInjection ...@@ -60,6 +62,7 @@ public class ComputeService : IAutoInjection
PerforCofaliasRepository cofaliasRepository, PerforCofaliasRepository cofaliasRepository,
PerforReportRepository reportRepository) PerforReportRepository reportRepository)
{ {
_mapper = mapper;
this.perforResaccountRepository = perforResaccountRepository; this.perforResaccountRepository = perforResaccountRepository;
this._perforPerSheetRepository = perforPerSheetRepository; this._perforPerSheetRepository = perforPerSheetRepository;
this._perforImDataRepository = perforImDataRepository; this._perforImDataRepository = perforImDataRepository;
...@@ -170,7 +173,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type) ...@@ -170,7 +173,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
//} //}
//if (joinData == null || !joinData.Any()) return new List<ResComputeResponse>(); //if (joinData == null || !joinData.Any()) return new List<ResComputeResponse>();
//data = Mapper.Map<List<ResComputeResponse>>(joinData); //data = _mapper.Map<List<ResComputeResponse>>(joinData);
#endregion MyRegion #endregion MyRegion
...@@ -180,7 +183,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type) ...@@ -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)); var computes = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && pairs[type].Contains(t.UnitType));
if (computes == null || !computes.Any()) return new List<ResComputeResponse>(); if (computes == null || !computes.Any()) return new List<ResComputeResponse>();
data = Mapper.Map<List<ResComputeResponse>>(computes); data = _mapper.Map<List<ResComputeResponse>>(computes);
data.ForEach(t => data.ForEach(t =>
{ {
...@@ -209,7 +212,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type) ...@@ -209,7 +212,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
if (compute == null || !compute.Any()) return new List<ResComputeResponse>(); 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 = data.OrderByDescending(t => t.RealGiveFee).ThenBy(t => t.FitPeople).ThenBy(t => t.AccountingUnit).ToList();
data.ForEach(t => data.ForEach(t =>
{ {
...@@ -262,7 +265,7 @@ public List<res_specialunit> GetSpecial(int allotId) ...@@ -262,7 +265,7 @@ public List<res_specialunit> GetSpecial(int allotId)
if (list != null && list.Any()) if (list != null && list.Any())
{ {
list = list.OrderByDescending(t => t.AccountingUnit).ThenBy(t => t.RealGiveFee).ToList(); 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>(); return new List<res_specialunit>();
} }
...@@ -276,7 +279,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId) ...@@ -276,7 +279,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId)
{ {
List<int> types = new List<int> { (int)UnitType.医生组, (int)UnitType.医技组 }; 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); 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()); doctor?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return doctor; return doctor;
} }
...@@ -289,7 +292,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId) ...@@ -289,7 +292,7 @@ public List<DeptResponse> GetDoctorPerformance(int allotId)
public List<DeptResponse> GetNursePerformance(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); 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()); nurse?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return nurse; return nurse;
} }
...@@ -303,7 +306,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId) ...@@ -303,7 +306,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId)
{ {
var unitType = new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组, (int)UnitType.专家组 }; 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); 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()); other?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return other; return other;
} }
...@@ -320,7 +323,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId) ...@@ -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 == "是") var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId && t.NeedSecondAllot == "是")
?.OrderBy(t => t.UnitType) ?.OrderBy(t => t.UnitType)
.ThenByDescending(t => t.AccountingUnit); .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()); other?.ForEach(t => t.UnitName = ((UnitType)t.UnitType).ToString());
return other; return other;
} }
...@@ -350,7 +353,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId) ...@@ -350,7 +353,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId)
// var resData = perforResaccountRepository.GetEntities(t => t.AllotID == allotId); // var resData = perforResaccountRepository.GetEntities(t => t.AllotID == allotId);
// if (resData != null && resData.Any()) // if (resData != null && resData.Any())
// { // {
// result.AddRange(Mapper.Map<List<DeptResponse>>(resData)); // result.AddRange(_mapper.Map<List<DeptResponse>>(resData));
// result.ForEach(t => // result.ForEach(t =>
// { // {
// t.UnitName = ((UnitType)t.UnitType).ToString(); // t.UnitName = ((UnitType)t.UnitType).ToString();
...@@ -750,7 +753,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -750,7 +753,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
DeptDetailResponse response = new DeptDetailResponse() DeptDetailResponse response = new DeptDetailResponse()
{ {
Pandect = Mapper.Map<PerDataAccountBaisc>(account), Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Economic = new List<DeptDetail>(), Economic = new List<DeptDetail>(),
Workload = new List<DeptDetail>() Workload = new List<DeptDetail>()
}; };
...@@ -776,7 +779,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -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); var nurse = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == allotId && t.ID == accountId);
DeptDetailResponse response = new DeptDetailResponse() DeptDetailResponse response = new DeptDetailResponse()
{ {
Pandect = Mapper.Map<PerDataAccountBaisc>(nurse), Pandect = _mapper.Map<PerDataAccountBaisc>(nurse),
Economic = new List<DeptDetail>(), Economic = new List<DeptDetail>(),
Workload = new List<DeptDetail>() Workload = new List<DeptDetail>()
}; };
...@@ -1213,7 +1216,7 @@ public DeptDataDetails DeptDetail(int accountId) ...@@ -1213,7 +1216,7 @@ public DeptDataDetails DeptDetail(int accountId)
DeptDataDetails deptDetails = new DeptDataDetails DeptDataDetails deptDetails = new DeptDataDetails
{ {
ShowFormula = allot.ShowFormula, ShowFormula = allot.ShowFormula,
Pandect = Mapper.Map<PerDataAccountBaisc>(account), Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Detail = new List<DetailDtos>() Detail = new List<DetailDtos>()
}; };
...@@ -1521,7 +1524,7 @@ public DeptDataDetails DeptOfficeDetail(int accountId) ...@@ -1521,7 +1524,7 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
DeptDataDetails deptDetails = new DeptDataDetails DeptDataDetails deptDetails = new DeptDataDetails
{ {
ShowFormula = allot.ShowFormula, ShowFormula = allot.ShowFormula,
Pandect = Mapper.Map<PerDataAccountBaisc>(account), Pandect = _mapper.Map<PerDataAccountBaisc>(account),
Detail = new List<DetailDtos>() Detail = new List<DetailDtos>()
}; };
...@@ -1919,10 +1922,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request) ...@@ -1919,10 +1922,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request)
{ {
if (request.Id == 0) if (request.Id == 0)
{ {
var baiscnorm = Mapper.Map<res_baiscnorm>(request); var baiscnorm = _mapper.Map<res_baiscnorm>(request);
if (!perforResbaiscnormRepository.Add(baiscnorm)) if (!perforResbaiscnormRepository.Add(baiscnorm))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<res_baiscnorm>(baiscnorm); return _mapper.Map<res_baiscnorm>(baiscnorm);
} }
else else
{ {
...@@ -1934,10 +1937,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request) ...@@ -1934,10 +1937,10 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request)
baiscnorm.TotelValue = request.TotelValue; baiscnorm.TotelValue = request.TotelValue;
baiscnorm.AvgValue = request.AvgValue; baiscnorm.AvgValue = request.AvgValue;
//var baiscnorm = Mapper.Map<res_baiscnorm>(request); //var baiscnorm = _mapper.Map<res_baiscnorm>(request);
if (!perforResbaiscnormRepository.Update(baiscnorm)) if (!perforResbaiscnormRepository.Update(baiscnorm))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<res_baiscnorm>(baiscnorm); return _mapper.Map<res_baiscnorm>(baiscnorm);
} }
} }
......
...@@ -17,6 +17,7 @@ namespace Performance.Services ...@@ -17,6 +17,7 @@ namespace Performance.Services
{ {
public class ConfigService : IAutoInjection public class ConfigService : IAutoInjection
{ {
private readonly IMapper _mapper;
#region #region
private readonly PerforCofdirectorRepository _directorRepository; private readonly PerforCofdirectorRepository _directorRepository;
//private readonly PerforCofdrugpropRepository _drugpropRepository; //private readonly PerforCofdrugpropRepository _drugpropRepository;
...@@ -44,7 +45,9 @@ public class ConfigService : IAutoInjection ...@@ -44,7 +45,9 @@ public class ConfigService : IAutoInjection
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
private readonly PerforReportRepository perforReport; private readonly PerforReportRepository perforReport;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository, public ConfigService(
IMapper mapper,
PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository, //PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofagainRepository againRepository, PerforCofagainRepository againRepository,
PerforCofdrugtypeRepository drugtypeRepository, PerforCofdrugtypeRepository drugtypeRepository,
...@@ -70,6 +73,7 @@ public class ConfigService : IAutoInjection ...@@ -70,6 +73,7 @@ public class ConfigService : IAutoInjection
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
PerforReportRepository perforReport) PerforReportRepository perforReport)
{ {
_mapper = mapper;
this._directorRepository = cofdirectorRepository; this._directorRepository = cofdirectorRepository;
//this._drugpropRepository = cofdrugpropRepository; //this._drugpropRepository = cofdrugpropRepository;
this._workitemRepository = workitemRepository; this._workitemRepository = workitemRepository;
...@@ -109,7 +113,7 @@ public class ConfigService : IAutoInjection ...@@ -109,7 +113,7 @@ public class ConfigService : IAutoInjection
//public List<DirectorResponse> GetDireList(int allotId) //public List<DirectorResponse> GetDireList(int allotId)
//{ //{
// var list = _directorRepository.GetEntities(t => t.AllotID == allotId); // var list = _directorRepository.GetEntities(t => t.AllotID == allotId);
// return Mapper.Map<List<DirectorResponse>>(list); // return _mapper.Map<List<DirectorResponse>>(list);
//} //}
///// <summary> ///// <summary>
...@@ -119,10 +123,10 @@ public class ConfigService : IAutoInjection ...@@ -119,10 +123,10 @@ public class ConfigService : IAutoInjection
///// <returns></returns> ///// <returns></returns>
//public DirectorResponse DireInsert(DirectorRequest request) //public DirectorResponse DireInsert(DirectorRequest request)
//{ //{
// var director = Mapper.Map<cof_director>(request); // var director = _mapper.Map<cof_director>(request);
// if (!_directorRepository.Add(director)) // if (!_directorRepository.Add(director))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<DirectorResponse>(director); // return _mapper.Map<DirectorResponse>(director);
//} //}
///// <summary> ///// <summary>
...@@ -142,7 +146,7 @@ public class ConfigService : IAutoInjection ...@@ -142,7 +146,7 @@ public class ConfigService : IAutoInjection
// if (!_directorRepository.Update(director)) // if (!_directorRepository.Update(director))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<DirectorResponse>(director); // return _mapper.Map<DirectorResponse>(director);
//} //}
///// <summary> ///// <summary>
...@@ -168,7 +172,7 @@ public class ConfigService : IAutoInjection ...@@ -168,7 +172,7 @@ public class ConfigService : IAutoInjection
//public List<IncomeResponse> GetIncomeList(int allotId) //public List<IncomeResponse> GetIncomeList(int allotId)
//{ //{
// var list = _incomeRepository.GetEntities(T => T.AllotID == allotId); // var list = _incomeRepository.GetEntities(T => T.AllotID == allotId);
// return Mapper.Map<List<IncomeResponse>>(list); // return _mapper.Map<List<IncomeResponse>>(list);
//} //}
///// <summary> ///// <summary>
...@@ -178,10 +182,10 @@ public class ConfigService : IAutoInjection ...@@ -178,10 +182,10 @@ public class ConfigService : IAutoInjection
///// <returns></returns> ///// <returns></returns>
//public IncomeResponse IncomeInsert(IncomeRequest request) //public IncomeResponse IncomeInsert(IncomeRequest request)
//{ //{
// var income = Mapper.Map<cof_income>(request); // var income = _mapper.Map<cof_income>(request);
// if (!_incomeRepository.Add(income)) // if (!_incomeRepository.Add(income))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<IncomeResponse>(income); // return _mapper.Map<IncomeResponse>(income);
//} //}
///// <summary> ///// <summary>
...@@ -201,7 +205,7 @@ public class ConfigService : IAutoInjection ...@@ -201,7 +205,7 @@ public class ConfigService : IAutoInjection
// if (!_incomeRepository.Update(income)) // if (!_incomeRepository.Update(income))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<IncomeResponse>(income); // return _mapper.Map<IncomeResponse>(income);
//} //}
///// <summary> ///// <summary>
...@@ -227,7 +231,7 @@ public class ConfigService : IAutoInjection ...@@ -227,7 +231,7 @@ public class ConfigService : IAutoInjection
//public List<WorkyearResponse> GetWorkList(int allotId) //public List<WorkyearResponse> GetWorkList(int allotId)
//{ //{
// var list = _workyearRepository.GetEntities(t => t.AllotID == allotId); // var list = _workyearRepository.GetEntities(t => t.AllotID == allotId);
// return Mapper.Map<List<WorkyearResponse>>(list); // return _mapper.Map<List<WorkyearResponse>>(list);
//} //}
///// <summary> ///// <summary>
...@@ -237,10 +241,10 @@ public class ConfigService : IAutoInjection ...@@ -237,10 +241,10 @@ public class ConfigService : IAutoInjection
///// <returns></returns> ///// <returns></returns>
//public WorkyearResponse WorkInsert(WorkyearRequest request) //public WorkyearResponse WorkInsert(WorkyearRequest request)
//{ //{
// var workyear = Mapper.Map<cof_workyear>(request); // var workyear = _mapper.Map<cof_workyear>(request);
// if (!_workyearRepository.Add(workyear)) // if (!_workyearRepository.Add(workyear))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<WorkyearResponse>(workyear); // return _mapper.Map<WorkyearResponse>(workyear);
//} //}
///// <summary> ///// <summary>
...@@ -260,7 +264,7 @@ public class ConfigService : IAutoInjection ...@@ -260,7 +264,7 @@ public class ConfigService : IAutoInjection
// if (!_workyearRepository.Update(workyear)) // if (!_workyearRepository.Update(workyear))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<WorkyearResponse>(workyear); // return _mapper.Map<WorkyearResponse>(workyear);
//} //}
///// <summary> ///// <summary>
...@@ -289,7 +293,7 @@ public class ConfigService : IAutoInjection ...@@ -289,7 +293,7 @@ public class ConfigService : IAutoInjection
//public List<DrugpropResponse> GetDrugList(int allotId) //public List<DrugpropResponse> GetDrugList(int allotId)
//{ //{
// var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId); // var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
// return Mapper.Map<List<DrugpropResponse>>(list); // return _mapper.Map<List<DrugpropResponse>>(list);
//} //}
///// <summary> ///// <summary>
...@@ -299,10 +303,10 @@ public class ConfigService : IAutoInjection ...@@ -299,10 +303,10 @@ public class ConfigService : IAutoInjection
///// <returns></returns> ///// <returns></returns>
//public DrugpropResponse DrugInsert(DrugpropRequest request) //public DrugpropResponse DrugInsert(DrugpropRequest request)
//{ //{
// var drugprop = Mapper.Map<cof_drugprop>(request); // var drugprop = _mapper.Map<cof_drugprop>(request);
// if (!_drugpropRepository.Add(drugprop)) // if (!_drugpropRepository.Add(drugprop))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<DrugpropResponse>(drugprop); // return _mapper.Map<DrugpropResponse>(drugprop);
//} //}
///// <summary> ///// <summary>
...@@ -322,7 +326,7 @@ public class ConfigService : IAutoInjection ...@@ -322,7 +326,7 @@ public class ConfigService : IAutoInjection
// if (!_drugpropRepository.Update(drugprop)) // if (!_drugpropRepository.Update(drugprop))
// throw new PerformanceException("保存失败"); // throw new PerformanceException("保存失败");
// return Mapper.Map<DrugpropResponse>(drugprop); // return _mapper.Map<DrugpropResponse>(drugprop);
//} //}
///// <summary> ///// <summary>
...@@ -517,7 +521,7 @@ public List<cof_workitem> GetWorkItems(int allotId, int type) ...@@ -517,7 +521,7 @@ public List<cof_workitem> GetWorkItems(int allotId, int type)
? _workitemRepository.GetEntities(t => t.AllotID == allotId && t.Type == type) ? _workitemRepository.GetEntities(t => t.AllotID == allotId && t.Type == type)
: _workitemRepository.GetEntities(t => t.AllotID == allotId); : _workitemRepository.GetEntities(t => t.AllotID == allotId);
return Mapper.Map<List<cof_workitem>>(list); return _mapper.Map<List<cof_workitem>>(list);
} }
/// <summary> /// <summary>
...@@ -527,10 +531,10 @@ public List<cof_workitem> GetWorkItems(int allotId, int type) ...@@ -527,10 +531,10 @@ public List<cof_workitem> GetWorkItems(int allotId, int type)
/// <returns></returns> /// <returns></returns>
public cof_workitem WorkItemInsert(WorkItemRequest request) public cof_workitem WorkItemInsert(WorkItemRequest request)
{ {
var workyear = Mapper.Map<cof_workitem>(request); var workyear = _mapper.Map<cof_workitem>(request);
if (!_workitemRepository.Add(workyear)) if (!_workitemRepository.Add(workyear))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<cof_workitem>(workyear); return _mapper.Map<cof_workitem>(workyear);
} }
/// <summary> /// <summary>
...@@ -549,7 +553,7 @@ public cof_workitem WorkItemUpdate(WorkItemRequest request) ...@@ -549,7 +553,7 @@ public cof_workitem WorkItemUpdate(WorkItemRequest request)
if (!_workitemRepository.Update(workyear)) if (!_workitemRepository.Update(workyear))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<cof_workitem>(workyear); return _mapper.Map<cof_workitem>(workyear);
} }
/// <summary> /// <summary>
...@@ -712,7 +716,7 @@ public List<cof_again> GetAgainList(int allotId) ...@@ -712,7 +716,7 @@ public List<cof_again> GetAgainList(int allotId)
/// <returns></returns> /// <returns></returns>
public cof_again AgainInsert(CofAgainRequest request) public cof_again AgainInsert(CofAgainRequest request)
{ {
var again = Mapper.Map<cof_again>(request); var again = _mapper.Map<cof_again>(request);
if (!_againRepository.Add(again)) if (!_againRepository.Add(again))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return again; return again;
......
...@@ -18,6 +18,7 @@ namespace Performance.Services ...@@ -18,6 +18,7 @@ namespace Performance.Services
{ {
public class CostTransferService : IAutoInjection public class CostTransferService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly ILogger<CostTransferService> logger; private readonly ILogger<CostTransferService> logger;
private readonly Application application; private readonly Application application;
private readonly PerforCosttransferRepository costtransferRepository; private readonly PerforCosttransferRepository costtransferRepository;
...@@ -32,6 +33,7 @@ public class CostTransferService : IAutoInjection ...@@ -32,6 +33,7 @@ public class CostTransferService : IAutoInjection
private readonly PerforExmoduleRepository perforExmodule; private readonly PerforExmoduleRepository perforExmodule;
public CostTransferService( public CostTransferService(
IMapper mapper,
ILogger<CostTransferService> logger, ILogger<CostTransferService> logger,
IOptions<Application> application, IOptions<Application> application,
PerforCosttransferRepository costtransferRepository, PerforCosttransferRepository costtransferRepository,
...@@ -46,6 +48,7 @@ public class CostTransferService : IAutoInjection ...@@ -46,6 +48,7 @@ public class CostTransferService : IAutoInjection
PerforExmoduleRepository perforExmodule PerforExmoduleRepository perforExmodule
) )
{ {
_mapper = mapper;
this.logger = logger; this.logger = logger;
this.application = application.Value; this.application = application.Value;
this.costtransferRepository = costtransferRepository; this.costtransferRepository = costtransferRepository;
...@@ -115,7 +118,7 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro ...@@ -115,7 +118,7 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
foreach (var item in costTransfers) foreach (var item in costTransfers)
{ {
var result = new CostTransferResponse(); 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 result.Items = costItem?.Where(t => t.TransferId == item.Id)?.Select(t => new Option
{ {
Id = t.Id, Id = t.Id,
...@@ -271,8 +274,8 @@ public bool Applicat(CostTransferRequest request) ...@@ -271,8 +274,8 @@ public bool Applicat(CostTransferRequest request)
if (request.Adopted.Department == request.Applicant.Department && request.Adopted.UnitType == request.Applicant.UnitType) if (request.Adopted.Department == request.Applicant.Department && request.Adopted.UnitType == request.Applicant.UnitType)
throw new PerformanceException("参数错误,提交科室相同"); throw new PerformanceException("参数错误,提交科室相同");
var item=request.Items.Where(t => string.IsNullOrEmpty(t.Source) || string.IsNullOrEmpty(t.Category)); var item = request.Items.Where(t => string.IsNullOrEmpty(t.Source) || string.IsNullOrEmpty(t.Category));
if(item.Count()>0) throw new PerformanceException("参数错误,申请信息填写不完整"); if (item.Count() > 0) throw new PerformanceException("参数错误,申请信息填写不完整");
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId); var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
var allotStatus = new[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive }; var allotStatus = new[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive };
...@@ -546,7 +549,7 @@ public void IntoLastTiemData(int hospitalId, int allotId) ...@@ -546,7 +549,7 @@ public void IntoLastTiemData(int hospitalId, int allotId)
foreach (var item in transferLast) foreach (var item in transferLast)
{ {
var newTransfers = new cost_transfer(); var newTransfers = new cost_transfer();
newTransfers = Mapper.Map<cost_transfer>(item); newTransfers = _mapper.Map<cost_transfer>(item);
newTransfers.AllotId = allotId; newTransfers.AllotId = allotId;
newTransfers.Status = 0; newTransfers.Status = 0;
newTransfers.AdminStatus = 0; newTransfers.AdminStatus = 0;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
// { // {
// #region // #region
// private readonly ILogger<ExtractService> logger; // private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment; // private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService; // private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService; // private readonly PerSheetService perSheetService;
// private readonly PerforHospitalRepository perforHospitalRepository; // private readonly PerforHospitalRepository perforHospitalRepository;
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
// private per_allot Allot; // private per_allot Allot;
// public DFExtractService(ILogger<ExtractService> logger, // public DFExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment, // IWebHostEnvironment environment,
// IEmailService emailService, // IEmailService emailService,
// PerSheetService perSheetService, // PerSheetService perSheetService,
// PerforHospitalRepository perforHospitalRepository, // PerforHospitalRepository perforHospitalRepository,
......
...@@ -28,7 +28,7 @@ public class DownloadService : IAutoInjection ...@@ -28,7 +28,7 @@ public class DownloadService : IAutoInjection
private readonly PerforCofaliasRepository perforCofalias; private readonly PerforCofaliasRepository perforCofalias;
private readonly ConfigService configService; private readonly ConfigService configService;
private readonly ComputeService _computeService; private readonly ComputeService _computeService;
private readonly IHostingEnvironment evn; private readonly IWebHostEnvironment evn;
public DownloadService(ILogger<DownloadService> logger, public DownloadService(ILogger<DownloadService> logger,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
...@@ -36,7 +36,7 @@ public class DownloadService : IAutoInjection ...@@ -36,7 +36,7 @@ public class DownloadService : IAutoInjection
PerforCofaliasRepository perforCofalias, PerforCofaliasRepository perforCofalias,
ConfigService configService, ConfigService configService,
ComputeService computeService, ComputeService computeService,
IHostingEnvironment evn) IWebHostEnvironment evn)
{ {
this.logger = logger; this.logger = logger;
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
......
...@@ -20,6 +20,7 @@ namespace Performance.Services ...@@ -20,6 +20,7 @@ namespace Performance.Services
{ {
public class EmployeeService : IAutoInjection public class EmployeeService : IAutoInjection
{ {
private readonly IMapper _mapper;
private PerforImemployeeRepository perforImemployeeRepository; private PerforImemployeeRepository perforImemployeeRepository;
private PerforPersheetRepository perforPersheetRepository; private PerforPersheetRepository perforPersheetRepository;
private PerforImdataRepository perforImdataRepository; private PerforImdataRepository perforImdataRepository;
...@@ -37,6 +38,7 @@ public class EmployeeService : IAutoInjection ...@@ -37,6 +38,7 @@ public class EmployeeService : IAutoInjection
private ILogger<EmployeeService> logger; private ILogger<EmployeeService> logger;
public EmployeeService( public EmployeeService(
IMapper mapper,
PerforImemployeeRepository perforImemployeeRepository, PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository, PerforPersheetRepository perforPersheetRepository,
PerforImdataRepository perforImdataRepository, PerforImdataRepository perforImdataRepository,
...@@ -53,6 +55,7 @@ public class EmployeeService : IAutoInjection ...@@ -53,6 +55,7 @@ public class EmployeeService : IAutoInjection
PerforPerapramounthideRepository hideRepository, PerforPerapramounthideRepository hideRepository,
ILogger<EmployeeService> logger) ILogger<EmployeeService> logger)
{ {
_mapper = mapper;
this.perforImemployeeRepository = perforImemployeeRepository; this.perforImemployeeRepository = perforImemployeeRepository;
this.perforPersheetRepository = perforPersheetRepository; this.perforPersheetRepository = perforPersheetRepository;
this.perforImdataRepository = perforImdataRepository; this.perforImdataRepository = perforImdataRepository;
...@@ -127,7 +130,7 @@ public im_employee Insert(EmployeeRequest request) ...@@ -127,7 +130,7 @@ public im_employee Insert(EmployeeRequest request)
perforPersheetRepository.Add(sheet); 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.WorkTime = ConvertHelper.To<DateTime?>(request.WorkTime);
employee.SheetID = sheet.ID; employee.SheetID = sheet.ID;
perforImemployeeRepository.Add(employee); perforImemployeeRepository.Add(employee);
......
...@@ -99,10 +99,10 @@ public void Handler(int hospitalId, per_allot allot, string groupName, bool isSi ...@@ -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); HisData(allot, configs.FirstOrDefault(t => t.Id == item.ConfigId), item);
} }
} }
catch (Exception ex) catch (Exception)
{ {
logger.LogError("获取数据时发生异常"); logger.LogError("获取数据时发生异常");
throw ex; throw;
} }
} }
......
...@@ -14,7 +14,7 @@ namespace Performance.Services.ExtractExcelService ...@@ -14,7 +14,7 @@ namespace Performance.Services.ExtractExcelService
public class ExtractJobService : IAutoInjection public class ExtractJobService : IAutoInjection
{ {
private readonly ILogger logger; private readonly ILogger logger;
private readonly IHostingEnvironment env; private readonly IWebHostEnvironment env;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly ConfigService configService; private readonly ConfigService configService;
private readonly DictionaryService dictionaryService; private readonly DictionaryService dictionaryService;
...@@ -26,7 +26,7 @@ public class ExtractJobService : IAutoInjection ...@@ -26,7 +26,7 @@ public class ExtractJobService : IAutoInjection
public ExtractJobService( public ExtractJobService(
ILogger<ExtractJobService> logger, ILogger<ExtractJobService> logger,
IHostingEnvironment env, IWebHostEnvironment env,
AllotService allotService, AllotService allotService,
ConfigService configService, ConfigService configService,
DictionaryService dictionaryService, DictionaryService dictionaryService,
......
...@@ -110,10 +110,10 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName ...@@ -110,10 +110,10 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName
} }
return data; return data;
} }
catch (Exception ex) catch (Exception)
{ {
logger.LogError("获取数据时发生异常"); logger.LogError("获取数据时发生异常");
throw ex; throw;
} }
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// public class ExtractService : IAutoInjection // public class ExtractService : IAutoInjection
// { // {
// private readonly ILogger<ExtractService> logger; // private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment; // private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService; // private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService; // private readonly PerSheetService perSheetService;
// private readonly PerHeaderService perHeaderService; // private readonly PerHeaderService perHeaderService;
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
// private readonly PerforHospitalconfigRepository perforHospitalconfigRepository; // private readonly PerforHospitalconfigRepository perforHospitalconfigRepository;
// public ExtractService(ILogger<ExtractService> logger, // public ExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment, // IWebHostEnvironment environment,
// IEmailService emailService, // IEmailService emailService,
// PerSheetService perSheetService, // PerSheetService perSheetService,
// PerHeaderService perHeaderService, // PerHeaderService perHeaderService,
...@@ -540,12 +540,12 @@ ...@@ -540,12 +540,12 @@
// ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType), // ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
// }; // };
// var perHeadList = perforImheaderRepository.GetEntities(t => t.SheetID == sheet.ID); // 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) // if (SheetType.Employee == (SheetType)sheet.SheetType)
// { // {
// perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType); // perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType);
// var employeeList = perforImemployeeRepository.GetEntities(t => t.AllotID == sheet.AllotID); // 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)); // perSheet.PerData = perEmployeeList?.ConvertAll(new Converter<PerDataEmployee, IPerData>(m => m));
// } // }
// else if (SheetType.SpecialUnit == (SheetType)sheet.SheetType) // else if (SheetType.SpecialUnit == (SheetType)sheet.SheetType)
...@@ -556,7 +556,7 @@ ...@@ -556,7 +556,7 @@
// { // {
// perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType); // perSheet.PerHeader = GetHeader((SheetType)sheet.SheetType);
// var basicList = perforImaccountbasicRepository.GetEntities(t => t.AllotID == sheet.AllotID); // 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)); // perSheet.PerData = perBasicList?.ConvertAll(new Converter<PerDataAccountBaisc, IPerData>(m => m));
// } // }
// sheetList.Add(perSheet); // sheetList.Add(perSheet);
......
using Microsoft.Extensions.Logging; using AutoMapper;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
...@@ -16,6 +17,7 @@ namespace Performance.Services ...@@ -16,6 +17,7 @@ namespace Performance.Services
{ {
public class HistoryService : IAutoInjection public class HistoryService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly ILogger<EmployeeService> logger; private readonly ILogger<EmployeeService> logger;
private readonly PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository; private readonly PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository;
private readonly PerforReportoriginalstaysRepository reportoriginalstaysRepository; private readonly PerforReportoriginalstaysRepository reportoriginalstaysRepository;
...@@ -23,12 +25,14 @@ public class HistoryService : IAutoInjection ...@@ -23,12 +25,14 @@ public class HistoryService : IAutoInjection
private readonly PerforPerdeptdicRepository perdeptdicRepository; private readonly PerforPerdeptdicRepository perdeptdicRepository;
public HistoryService( public HistoryService(
IMapper mapper,
ILogger<EmployeeService> logger, ILogger<EmployeeService> logger,
PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository, PerforReportoriginalsurgeryRepository reportoriginalsurgeryRepository,
PerforReportoriginalstaysRepository reportoriginalstaysRepository, PerforReportoriginalstaysRepository reportoriginalstaysRepository,
PerforReportoriginalpersontimeRepository reportoriginalpersontimeRepository, PerforReportoriginalpersontimeRepository reportoriginalpersontimeRepository,
PerforPerdeptdicRepository perdeptdicRepository) PerforPerdeptdicRepository perdeptdicRepository)
{ {
_mapper = mapper;
this.logger = logger; this.logger = logger;
this.reportoriginalsurgeryRepository = reportoriginalsurgeryRepository; this.reportoriginalsurgeryRepository = reportoriginalsurgeryRepository;
this.reportoriginalstaysRepository = reportoriginalstaysRepository; this.reportoriginalstaysRepository = reportoriginalstaysRepository;
...@@ -48,7 +52,7 @@ public void ImportHistoryData(int hospitalid, string path) ...@@ -48,7 +52,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data1.Select(s => s.Month).Distinct().ToList(); var months = @data1.Select(s => s.Month).Distinct().ToList();
reportoriginalpersontimeRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month)); 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()); reportoriginalpersontimeRepository.AddRange(@data.ToArray());
} }
var @data2 = entities.Where(w => w.SheetName == "手术量"); var @data2 = entities.Where(w => w.SheetName == "手术量");
...@@ -58,7 +62,7 @@ public void ImportHistoryData(int hospitalid, string path) ...@@ -58,7 +62,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data2.Select(s => s.Month).Distinct().ToList(); var months = @data2.Select(s => s.Month).Distinct().ToList();
reportoriginalsurgeryRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month)); 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()); reportoriginalsurgeryRepository.AddRange(@data.ToArray());
} }
var @data3 = entities.Where(w => w.SheetName == "住院天数"); var @data3 = entities.Where(w => w.SheetName == "住院天数");
...@@ -68,7 +72,7 @@ public void ImportHistoryData(int hospitalid, string path) ...@@ -68,7 +72,7 @@ public void ImportHistoryData(int hospitalid, string path)
var months = @data3.Select(s => s.Month).Distinct().ToList(); var months = @data3.Select(s => s.Month).Distinct().ToList();
reportoriginalstaysRepository.RemoveRange(w => w.HospitalID == hospitalid && years.Contains(w.Year) && months.Contains(w.Month)); 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()); reportoriginalstaysRepository.AddRange(@data.ToArray());
} }
} }
......
...@@ -11,17 +11,21 @@ namespace Performance.Services ...@@ -11,17 +11,21 @@ namespace Performance.Services
{ {
public class HospitalService : IAutoInjection public class HospitalService : IAutoInjection
{ {
private readonly IMapper _mapper;
private PerforHospitalRepository _hospitalRepository; private PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _joinRepository; private PerforUserhospitalRepository _joinRepository;
private PerforHospitalconfigRepository _hospitalconfigRepository; private PerforHospitalconfigRepository _hospitalconfigRepository;
private PerforPerfirstRepository _perfirstRepository; private PerforPerfirstRepository _perfirstRepository;
private PerforPerallotRepository _perallotRepository; private PerforPerallotRepository _perallotRepository;
public HospitalService(PerforHospitalRepository hospitalRepository, public HospitalService(
IMapper mapper,
PerforHospitalRepository hospitalRepository,
PerforUserhospitalRepository joinRepository, PerforUserhospitalRepository joinRepository,
PerforHospitalconfigRepository hospitalconfigRepository, PerforHospitalconfigRepository hospitalconfigRepository,
PerforPerfirstRepository perfirstRepository, PerforPerfirstRepository perfirstRepository,
PerforPerallotRepository perallotRepository) PerforPerallotRepository perallotRepository)
{ {
_mapper = mapper;
this._hospitalRepository = hospitalRepository; this._hospitalRepository = hospitalRepository;
this._joinRepository = joinRepository; this._joinRepository = joinRepository;
this._hospitalconfigRepository = hospitalconfigRepository; this._hospitalconfigRepository = hospitalconfigRepository;
...@@ -50,7 +54,7 @@ public List<HospitalResponse> GetUserHopital(int userid) ...@@ -50,7 +54,7 @@ public List<HospitalResponse> GetUserHopital(int userid)
//获取已经上传过模板的hospital //获取已经上传过模板的hospital
var firstId = _perfirstRepository.GetEntities(t => hosId.Contains(t.HospitalId.Value))?.Select(t => t.HospitalId.Value).ToList(); 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 => list.ForEach(t =>
{ {
if (hosId != null && hosId.Contains(t.HosID)) if (hosId != null && hosId.Contains(t.HosID))
...@@ -103,7 +107,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid) ...@@ -103,7 +107,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid)
{ {
if (null != _hospitalRepository.GetEntity(t => t.HosName == request.HosName)) if (null != _hospitalRepository.GetEntity(t => t.HosName == request.HosName))
throw new PerformanceException("医院名称重复"); throw new PerformanceException("医院名称重复");
var hospital = Mapper.Map<sys_hospital>(request); var hospital = _mapper.Map<sys_hospital>(request);
hospital.CreateDate = DateTime.Now; hospital.CreateDate = DateTime.Now;
hospital.CreateUser = userid; hospital.CreateUser = userid;
hospital.States = (int)States.Enabled; hospital.States = (int)States.Enabled;
...@@ -111,7 +115,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid) ...@@ -111,7 +115,7 @@ public HospitalResponse Insert(HospitalRequest request, int userid)
if (!_hospitalRepository.Add(hospital)) if (!_hospitalRepository.Add(hospital))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<HospitalResponse>(hospital); return _mapper.Map<HospitalResponse>(hospital);
} }
/// <summary> /// <summary>
...@@ -141,7 +145,7 @@ public HospitalResponse Update(HospitalRequest request) ...@@ -141,7 +145,7 @@ public HospitalResponse Update(HospitalRequest request)
if (!_hospitalRepository.Update(hospital)) if (!_hospitalRepository.Update(hospital))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<HospitalResponse>(hospital); return _mapper.Map<HospitalResponse>(hospital);
} }
/// <summary> /// <summary>
......
...@@ -69,9 +69,10 @@ public override Task OnDisconnectedAsync(Exception exception) ...@@ -69,9 +69,10 @@ public override Task OnDisconnectedAsync(Exception exception)
await Groups.AddToGroupAsync(connectionId, groupName); await Groups.AddToGroupAsync(connectionId, groupName);
} }
public async Task SendMessage(string groupName, string message) public Task SendMessage(string user, string message)
{ {
await Clients.Group(groupName).SendAsync("ReceiveMessage", "测试", message); logger.LogDebug($"日志推送 SendMessage *****************************************************************************");
return Clients.All.SendAsync("ReceiveMessage", user, message);
} }
} }
} }
...@@ -11,9 +11,13 @@ namespace Performance.Services ...@@ -11,9 +11,13 @@ namespace Performance.Services
{ {
public class MenuService : IAutoInjection public class MenuService : IAutoInjection
{ {
private readonly IMapper _mapper;
private PerforMenuRepository _menuRepository; private PerforMenuRepository _menuRepository;
public MenuService(PerforMenuRepository menuRepository) public MenuService(
IMapper mapper,
PerforMenuRepository menuRepository)
{ {
_mapper = mapper;
_menuRepository = menuRepository; _menuRepository = menuRepository;
} }
...@@ -31,7 +35,7 @@ private List<MenuResponse> RecursionFill(List<sys_menu> menuList, int parentId) ...@@ -31,7 +35,7 @@ private List<MenuResponse> RecursionFill(List<sys_menu> menuList, int parentId)
var list = new List<MenuResponse>(); var list = new List<MenuResponse>();
foreach (var item in menuList.Where(t => t.ParentID == parentId).OrderBy(t => t.Sort)) 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); menu.Children = RecursionFill(menuList, item.ID);
list.Add(menu); list.Add(menu);
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// { // {
// #region // #region
// private readonly ILogger<ExtractService> logger; // private readonly ILogger<ExtractService> logger;
// private readonly IHostingEnvironment environment; // private readonly IWebHostEnvironment environment;
// private readonly IEmailService emailService; // private readonly IEmailService emailService;
// private readonly PerSheetService perSheetService; // private readonly PerSheetService perSheetService;
// private readonly PerforHospitalRepository perforHospitalRepository; // private readonly PerforHospitalRepository perforHospitalRepository;
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
// private int AllotId; // private int AllotId;
// public NewExtractService(ILogger<ExtractService> logger, // public NewExtractService(ILogger<ExtractService> logger,
// IHostingEnvironment environment, // IWebHostEnvironment environment,
// IEmailService emailService, // IEmailService emailService,
// PerSheetService perSheetService, // PerSheetService perSheetService,
// PerforHospitalRepository perforHospitalRepository, // PerforHospitalRepository perforHospitalRepository,
......
using NPOI.HSSF.Record.Chart; using Performance.DtoModels;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using Remotion.Linq.Clauses.ResultOperators;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text;
namespace Performance.Services namespace Performance.Services
{ {
......
using Performance.DtoModels; using AutoMapper;
using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
...@@ -15,6 +16,7 @@ namespace Performance.Services ...@@ -15,6 +16,7 @@ namespace Performance.Services
/// </summary> /// </summary>
public class ComputeDirector : IAutoInjection public class ComputeDirector : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly BaiscNormService baiscNormService; private readonly BaiscNormService baiscNormService;
private readonly PerforCofdirectorRepository perforCofdirectorRepository; private readonly PerforCofdirectorRepository perforCofdirectorRepository;
private readonly PerforCofworkyearRepository perforCofworkyearRepository; private readonly PerforCofworkyearRepository perforCofworkyearRepository;
...@@ -23,13 +25,16 @@ public class ComputeDirector : IAutoInjection ...@@ -23,13 +25,16 @@ public class ComputeDirector : IAutoInjection
private readonly BudgetService budgetService; private readonly BudgetService budgetService;
//private readonly PerforResaccountdoctorRepository perforResAccountdoctorRepository; //private readonly PerforResaccountdoctorRepository perforResAccountdoctorRepository;
public ComputeDirector(BaiscNormService baiscNormService, public ComputeDirector(
IMapper mapper,
BaiscNormService baiscNormService,
PerforCofdirectorRepository perforCofdirectorRepository, PerforCofdirectorRepository perforCofdirectorRepository,
PerforCofworkyearRepository perforCofworkyearRepository, PerforCofworkyearRepository perforCofworkyearRepository,
PerforResaccountRepository perforResaccountRepository, PerforResaccountRepository perforResaccountRepository,
PerforRescomputeRepository perforRescomputeRepository, PerforRescomputeRepository perforRescomputeRepository,
BudgetService budgetService) BudgetService budgetService)
{ {
_mapper = mapper;
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
this.perforCofdirectorRepository = perforCofdirectorRepository; this.perforCofdirectorRepository = perforCofdirectorRepository;
this.perforCofworkyearRepository = perforCofworkyearRepository; this.perforCofworkyearRepository = perforCofworkyearRepository;
...@@ -156,7 +161,7 @@ public class ComputeDirector : IAutoInjection ...@@ -156,7 +161,7 @@ public class ComputeDirector : IAutoInjection
// List<res_account> dataList = new List<res_account>(); // List<res_account> dataList = new List<res_account>();
// foreach (var account in accountSheet) // 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 }) // var multi = accountbasicList.GroupBy(t => new { t.UnitType, t.DoctorAccountingUnit })
// .Select(t => new { t.Key.UnitType, t.Key.DoctorAccountingUnit, Count = t.Count(), }) // .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 ...@@ -297,7 +302,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<PerS
List<res_account> dataList = new List<res_account>(); List<res_account> dataList = new List<res_account>();
foreach (var account in accountSheet) 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>(); List<ComputeResult> computeList = new List<ComputeResult>();
if (empolyeeList == null) return computeList; if (empolyeeList == null) return computeList;
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.0.45" /> <PackageReference Include="FluentScheduler" Version="5.5.1" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.1" /> <PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="EPPlus" Version="4.5.3.2" /> <PackageReference Include="MassTransit.AspNetCore" Version="7.2.4" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using AutoMapper; using AutoMapper;
using Microsoft.EntityFrameworkCore.Internal; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
...@@ -17,13 +16,13 @@ ...@@ -17,13 +16,13 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Performance.Services namespace Performance.Services
{ {
public class PersonService : IAutoInjection public class PersonService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly ILogger<PersonService> logger; private readonly ILogger<PersonService> logger;
private readonly PerforPerdeptdicRepository perdeptdicRepository; private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforPeremployeeRepository peremployeeRepository; private readonly PerforPeremployeeRepository peremployeeRepository;
...@@ -35,7 +34,7 @@ public class PersonService : IAutoInjection ...@@ -35,7 +34,7 @@ public class PersonService : IAutoInjection
private readonly PerforHospitalRepository perforHospitalRepository; private readonly PerforHospitalRepository perforHospitalRepository;
private readonly UserService userService; private readonly UserService userService;
private readonly Application application; private readonly Application application;
private readonly IHostingEnvironment evn; private readonly IWebHostEnvironment evn;
private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)> private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{ {
...@@ -49,7 +48,9 @@ public class PersonService : IAutoInjection ...@@ -49,7 +48,9 @@ public class PersonService : IAutoInjection
{ nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) }, { nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) },
}; };
public PersonService(ILogger<PersonService> logger, public PersonService(
IMapper mapper,
ILogger<PersonService> logger,
PerforPerdeptdicRepository perdeptdicRepository, PerforPerdeptdicRepository perdeptdicRepository,
PerforPeremployeeRepository peremployeeRepository, PerforPeremployeeRepository peremployeeRepository,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
...@@ -60,9 +61,10 @@ public class PersonService : IAutoInjection ...@@ -60,9 +61,10 @@ public class PersonService : IAutoInjection
PerforHospitalRepository perforHospitalRepository, PerforHospitalRepository perforHospitalRepository,
UserService userService, UserService userService,
IOptions<Application> application, IOptions<Application> application,
IHostingEnvironment evn IWebHostEnvironment evn
) )
{ {
_mapper = mapper;
this.logger = logger; this.logger = logger;
this.perdeptdicRepository = perdeptdicRepository; this.perdeptdicRepository = perdeptdicRepository;
this.peremployeeRepository = peremployeeRepository; this.peremployeeRepository = peremployeeRepository;
...@@ -240,7 +242,7 @@ public per_employee CreatePerson(PerEmployeeResponse request) ...@@ -240,7 +242,7 @@ public per_employee CreatePerson(PerEmployeeResponse request)
if (!unittype.Contains(request.UnitType)) if (!unittype.Contains(request.UnitType))
throw new PerformanceException($"人员类别不符合规范!"); 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); var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
int day = DateTime.DaysInMonth(allot.Year, allot.Month); int day = DateTime.DaysInMonth(allot.Year, allot.Month);
entity.Attendance = request.AttendanceDay / day; entity.Attendance = request.AttendanceDay / day;
...@@ -273,7 +275,7 @@ public bool UpdatePerson(PerEmployeeResponse request) ...@@ -273,7 +275,7 @@ public bool UpdatePerson(PerEmployeeResponse request)
if (employee == null) if (employee == null)
employee = peremployeeRepository.GetEntity(t => t.Id == request.Id) ?? throw new PerformanceException("人员信息无效!"); 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.AccountingUnit = request.AccountingUnit;
employee.Department = request.Department; employee.Department = request.Department;
...@@ -440,7 +442,7 @@ public bool UpdateDeptDic(per_dept_dic request) ...@@ -440,7 +442,7 @@ public bool UpdateDeptDic(per_dept_dic request)
if (deptdic != null && deptdic.Id != request.Id) if (deptdic != null && deptdic.Id != request.Id)
throw new PerformanceException($"{request.Department}数据重复!"); 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); return perdeptdicRepository.Add(deptdic);
} }
......
...@@ -11,14 +11,18 @@ namespace Performance.Services ...@@ -11,14 +11,18 @@ namespace Performance.Services
{ {
public class RoleService : IAutoInjection public class RoleService : IAutoInjection
{ {
private readonly IMapper _mapper;
private PerforRoleRepository _roleRepository; private PerforRoleRepository _roleRepository;
private PerforUserroleRepository _userroleRepository; private PerforUserroleRepository _userroleRepository;
private PerforUserRepository _userRepository; private PerforUserRepository _userRepository;
public RoleService(PerforRoleRepository roleRepository, public RoleService(
IMapper mapper,
PerforRoleRepository roleRepository,
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforUserRepository userRepository) PerforUserRepository userRepository)
{ {
_mapper = mapper;
this._roleRepository = roleRepository; this._roleRepository = roleRepository;
this._userroleRepository = userroleRepository; this._userroleRepository = userroleRepository;
_userRepository = userRepository; _userRepository = userRepository;
...@@ -32,7 +36,7 @@ public class RoleService : IAutoInjection ...@@ -32,7 +36,7 @@ public class RoleService : IAutoInjection
public List<RoleResponse> GetUserRole(int userid) public List<RoleResponse> GetUserRole(int userid)
{ {
var roles = GetRole(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) ...@@ -71,7 +75,7 @@ public List<RoleResponse> GetUsersRole(int userid)
foreach (var sysUser in ParentUser) foreach (var sysUser in ParentUser)
{ {
var useRoles = GetARole(sysUser.ID); 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); var uRole = userRole.Find(t => t.RoleID == role.RoleID && t.UserID == sysUser.ID);
if (uRole?.UserID != null) role.Value = (int)uRole?.UserID; if (uRole?.UserID != null) role.Value = (int)uRole?.UserID;
roleResponses.Add(role); roleResponses.Add(role);
...@@ -83,7 +87,7 @@ public List<RoleResponse> GetUsersRole(int userid) ...@@ -83,7 +87,7 @@ public List<RoleResponse> GetUsersRole(int userid)
if (roles != null) if (roles != null)
{ {
var role = Mapper.Map<RoleResponse>(roles); var role = _mapper.Map<RoleResponse>(roles);
role.Value = isParent ? userid : (int)user.ParentID; role.Value = isParent ? userid : (int)user.ParentID;
roleResponses.Add(role); roleResponses.Add(role);
} }
......
...@@ -15,6 +15,7 @@ namespace Performance.Services ...@@ -15,6 +15,7 @@ namespace Performance.Services
{ {
public class SecondAllotDetails : IAutoInjection public class SecondAllotDetails : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly ILogger<SecondAllotDetails> _logger; private readonly ILogger<SecondAllotDetails> _logger;
private readonly PerforImemployeelogisticsRepository _imemployeelogisticsRepository; private readonly PerforImemployeelogisticsRepository _imemployeelogisticsRepository;
private readonly Application _application; private readonly Application _application;
...@@ -33,6 +34,7 @@ public class SecondAllotDetails : IAutoInjection ...@@ -33,6 +34,7 @@ public class SecondAllotDetails : IAutoInjection
private readonly UserService _userService; private readonly UserService _userService;
public SecondAllotDetails( public SecondAllotDetails(
IMapper mapper,
ILogger<SecondAllotDetails> logger, ILogger<SecondAllotDetails> logger,
IOptions<Application> application, IOptions<Application> application,
PerforImemployeelogisticsRepository imemployeelogisticsRepository, PerforImemployeelogisticsRepository imemployeelogisticsRepository,
...@@ -51,6 +53,7 @@ public class SecondAllotDetails : IAutoInjection ...@@ -51,6 +53,7 @@ public class SecondAllotDetails : IAutoInjection
UserService userService UserService userService
) )
{ {
_mapper = mapper;
_logger = logger; _logger = logger;
_imemployeelogisticsRepository = imemployeelogisticsRepository; _imemployeelogisticsRepository = imemployeelogisticsRepository;
_application = application.Value; _application = application.Value;
...@@ -136,14 +139,14 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se ...@@ -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(); 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()) if (configHeaders != null && configHeaders.Any())
{ {
foreach (var workTypeId in configHeaders.Select(t => t.WorkTypeId).Distinct()) 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 type = workTypeId == (int)AgWorkloadType.SingleAwards
? (int)TempColumnType.SingleAwardsColumns ? (int)TempColumnType.SingleAwardsColumns
: (int)TempColumnType.WorkloadColumns; : (int)TempColumnType.WorkloadColumns;
...@@ -638,7 +641,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se ...@@ -638,7 +641,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId)) if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId))
{ {
result.HeadItems.Add(item); result.HeadItems.Add(item);
var body = Mapper.Map<BodyItem>(item); var body = _mapper.Map<BodyItem>(item);
body.RowNumber = rownumber; body.RowNumber = rownumber;
if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName)) if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName))
body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue; body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue;
......
...@@ -17,6 +17,7 @@ namespace Performance.Services ...@@ -17,6 +17,7 @@ namespace Performance.Services
{ {
public partial class SecondAllotService : IAutoInjection public partial class SecondAllotService : IAutoInjection
{ {
private readonly IMapper _mapper;
private readonly ILogger logger; private readonly ILogger logger;
private readonly Application application; private readonly Application application;
private readonly PerforAgsecondallotRepository agsecondallotRepository; private readonly PerforAgsecondallotRepository agsecondallotRepository;
...@@ -52,6 +53,7 @@ public partial class SecondAllotService : IAutoInjection ...@@ -52,6 +53,7 @@ public partial class SecondAllotService : IAutoInjection
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>(); private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService( public SecondAllotService(
IMapper mapper,
ILogger<SecondAllotService> logger, ILogger<SecondAllotService> logger,
IOptions<Application> application, IOptions<Application> application,
PerforAgsecondallotRepository agsecondallotRepository, PerforAgsecondallotRepository agsecondallotRepository,
...@@ -84,6 +86,7 @@ public partial class SecondAllotService : IAutoInjection ...@@ -84,6 +86,7 @@ public partial class SecondAllotService : IAutoInjection
ComputeService computeService ComputeService computeService
) )
{ {
_mapper = mapper;
this.logger = logger; this.logger = logger;
this.application = application.Value; this.application = application.Value;
this.agsecondallotRepository = agsecondallotRepository; this.agsecondallotRepository = agsecondallotRepository;
...@@ -149,7 +152,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -149,7 +152,7 @@ public List<SecondListResponse> GetSecondList(int userId)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString()); exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = agsecondallotRepository.GetEntities(exp); 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); var hospital = hospitalRepository.GetEntity(t => t.ID == userhospital.HospitalID);
list?.ForEach(t => list?.ForEach(t =>
{ {
...@@ -374,7 +377,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId) ...@@ -374,7 +377,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
//var employees = personService.GetPersons(second.AllotId.Value, userId); //var employees = personService.GetPersons(second.AllotId.Value, userId);
result.BodyItems = GetEmployees(second, userId, headItems, second.UnitType); 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()) if (bodys != null && bodys.Any())
bodys.ForEach(t => t.RowNumber = -1); bodys.ForEach(t => t.RowNumber = -1);
result.BodyItems.AddRange(bodys); result.BodyItems.AddRange(bodys);
...@@ -460,7 +463,7 @@ private List<BodyItem> GetEmployees(ag_secondallot second, int userId, List<Head ...@@ -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); var head = heads.FirstOrDefault(t => t.FiledName == item.Key.Item1 && t.FiledId == item.Key.Item2);
if (head != null) if (head != null)
{ {
var body = Mapper.Map<BodyItem>(head); var body = _mapper.Map<BodyItem>(head);
body.Value = item.Value.Invoke(employee)?.ToString(); body.Value = item.Value.Invoke(employee)?.ToString();
body.RowNumber = rowNumber; body.RowNumber = rowNumber;
list.Add(body); list.Add(body);
...@@ -697,7 +700,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -697,7 +700,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId)) if (!result.HeadItems.Select(t => t.FiledId).Contains(item.FiledId))
{ {
result.HeadItems.Add(item); result.HeadItems.Add(item);
var body = Mapper.Map<BodyItem>(item); var body = _mapper.Map<BodyItem>(item);
body.RowNumber = rownumber; body.RowNumber = rownumber;
if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName)) if (fixatitems != null && fixatitems.Any(t => t.ItemName == item.FiledName))
body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue; body.Value = fixatitems.FirstOrDefault(t => t.ItemName == item.FiledName).ItemValue;
...@@ -875,7 +878,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -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)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var useTemp = agusetempRepository.GetEntity(exp); var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps); var secondTemps = _mapper.Map<List<SecondTempResponse>>(temps);
if (useTemp != null) if (useTemp != null)
secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId); secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId);
return secondTemps; return secondTemps;
...@@ -895,7 +898,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -895,7 +898,7 @@ public bool UseTemp(UseTempRequest request)
&& t.Department == request.Department && t.UnitType == request.UnitType); && t.Department == request.Department && t.UnitType == request.UnitType);
if (entity == null) if (entity == null)
{ {
entity = Mapper.Map<ag_usetemp>(request); entity = _mapper.Map<ag_usetemp>(request);
result = agusetempRepository.Add(entity); result = agusetempRepository.Add(entity);
} }
else else
...@@ -912,7 +915,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -912,7 +915,7 @@ public bool UseTemp(UseTempRequest request)
var allotList = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId); 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 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); 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 ...@@ -1859,7 +1862,7 @@ public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department
{ {
var tempItem = agtempitemRepository.GetEntities(t => t.TempId == tempId); 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); var temp = agtempRepository.GetEntity(w => w.Id == tempId);
...@@ -1871,11 +1874,11 @@ public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department ...@@ -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); var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
if (workItem != null && workItem.Count > 0) 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; }); workDtos.ForEach(t => { t.Type = 3; });
headItems.AddRange(workDtos); 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; }); workDtos.ForEach(t => { t.Type = 4; });
headItems.AddRange(workDtos); headItems.AddRange(workDtos);
} }
...@@ -2141,7 +2144,7 @@ public dynamic Print(int secondId) ...@@ -2141,7 +2144,7 @@ public dynamic Print(int secondId)
var data = agothersourceRepository.GetEntities(t => t.SecondId == secondId); var data = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (data == null || !data.Any()) return new List<SecPrintResponse>(); 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.TotalDistPerformance = second.RealGiveFee ?? 0;
header.HosOtherPerformance = result.Sum(t => t.OtherPerformance ?? 0); header.HosOtherPerformance = result.Sum(t => t.OtherPerformance ?? 0);
...@@ -2173,7 +2176,7 @@ public dynamic Print(int secondId) ...@@ -2173,7 +2176,7 @@ public dynamic Print(int secondId)
var headerdata = agheadsourceRepository.GetEntity(t => t.SecondId == 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); //header.HosOtherPerformance = result.Sum(t => t.OtherPerformance ?? 0);
} }
else if ((new int[] { 7, 8 }).Contains(useTempId)) else if ((new int[] { 7, 8 }).Contains(useTempId))
...@@ -2246,7 +2249,7 @@ public dynamic Print(int secondId) ...@@ -2246,7 +2249,7 @@ public dynamic Print(int secondId)
var headerdata = agheadsourceRepository.GetEntity(t => t.SecondId == secondId); var headerdata = agheadsourceRepository.GetEntity(t => t.SecondId == secondId);
header = Mapper.Map<SecPrintHeaderResponse>(headerdata); header = _mapper.Map<SecPrintHeaderResponse>(headerdata);
} }
// 补充医院其他绩效 及 预留比例 // 补充医院其他绩效 及 预留比例
......
...@@ -15,6 +15,7 @@ namespace Performance.Services ...@@ -15,6 +15,7 @@ namespace Performance.Services
/// </summary> /// </summary>
public class SheetSevice : IAutoInjection public class SheetSevice : IAutoInjection
{ {
private readonly IMapper _mapper;
private PerforPerallotRepository _perforAllotRepository; private PerforPerallotRepository _perforAllotRepository;
private PerforPersheetRepository _perforImSheetRepository; private PerforPersheetRepository _perforImSheetRepository;
private PerforImdataRepository _perforImDataRepository; private PerforImdataRepository _perforImDataRepository;
...@@ -28,7 +29,9 @@ public class SheetSevice : IAutoInjection ...@@ -28,7 +29,9 @@ public class SheetSevice : IAutoInjection
private readonly PerforImemployeelogisticsRepository _perforImemployeelogisticsRepository; private readonly PerforImemployeelogisticsRepository _perforImemployeelogisticsRepository;
private readonly string[] percentparam = new string[] { "预算比例", "考核得分率", "调节系数" }; private readonly string[] percentparam = new string[] { "预算比例", "考核得分率", "调节系数" };
public SheetSevice(PerforPerallotRepository perforAllotRepository, public SheetSevice(
IMapper mapper,
PerforPerallotRepository perforAllotRepository,
PerforPersheetRepository perforImSheetRepository, PerforPersheetRepository perforImSheetRepository,
PerforImdataRepository perforImDataRepository, PerforImdataRepository perforImDataRepository,
PerforImheaderRepository perforImHeaderRepository, PerforImheaderRepository perforImHeaderRepository,
...@@ -40,6 +43,7 @@ public class SheetSevice : IAutoInjection ...@@ -40,6 +43,7 @@ public class SheetSevice : IAutoInjection
PerforImemployeeclinicRepository perforImemployeeclinicRepository, PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository) PerforImemployeelogisticsRepository perforImemployeelogisticsRepository)
{ {
_mapper = mapper;
_perforAllotRepository = perforAllotRepository; _perforAllotRepository = perforAllotRepository;
_perforImSheetRepository = perforImSheetRepository; _perforImSheetRepository = perforImSheetRepository;
_perforImDataRepository = perforImDataRepository; _perforImDataRepository = perforImDataRepository;
...@@ -68,7 +72,7 @@ public List<SheetResponse> SheetList(int allotID, int source) ...@@ -68,7 +72,7 @@ public List<SheetResponse> SheetList(int allotID, int source)
throw new PerformanceException("参数source无效"); throw new PerformanceException("参数source无效");
var sheetList = _perforImSheetRepository.GetEntities(t => t.AllotID == allotID && t.Source == 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> /// <summary>
......
...@@ -18,6 +18,7 @@ public class UserService : IAutoInjection ...@@ -18,6 +18,7 @@ public class UserService : IAutoInjection
{ {
private Application application; private Application application;
private PerforUserRepository _userRepository; private PerforUserRepository _userRepository;
private readonly IMapper _mapper;
private PerforSmsRepository _smsRepository; private PerforSmsRepository _smsRepository;
private PerforHospitalRepository _hospitalRepository; private PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _userhospitalRepository; private PerforUserhospitalRepository _userhospitalRepository;
...@@ -32,7 +33,9 @@ public class UserService : IAutoInjection ...@@ -32,7 +33,9 @@ public class UserService : IAutoInjection
private PerforPerdeptdicRepository _perdeptdicRepository; private PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofaccountingRepository perforCofaccountingRepository; private readonly PerforCofaccountingRepository perforCofaccountingRepository;
public UserService(IOptions<Application> application, public UserService(
IMapper mapper,
IOptions<Application> application,
PerforSmsRepository smsRepository, PerforSmsRepository smsRepository,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
...@@ -50,6 +53,7 @@ public class UserService : IAutoInjection ...@@ -50,6 +53,7 @@ public class UserService : IAutoInjection
{ {
this.application = application.Value; this.application = application.Value;
this._userRepository = userRepository; this._userRepository = userRepository;
_mapper = mapper;
this._smsRepository = smsRepository; this._smsRepository = smsRepository;
this._hospitalRepository = hospitalRepository; this._hospitalRepository = hospitalRepository;
this._userhospitalRepository = userhospitalRepository; this._userhospitalRepository = userhospitalRepository;
...@@ -82,7 +86,7 @@ public UserIdentity Login(LoginRequest request) ...@@ -82,7 +86,7 @@ public UserIdentity Login(LoginRequest request)
if (user == null) if (user == null)
throw new PerformanceException("用户信息查询失败"); throw new PerformanceException("用户信息查询失败");
var data = Mapper.Map<UserIdentity>(user); var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N"); data.Token = Guid.NewGuid().ToString("N");
return data; return data;
} }
...@@ -95,7 +99,7 @@ public UserIdentity Login(LoginRequest request) ...@@ -95,7 +99,7 @@ public UserIdentity Login(LoginRequest request)
if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase)) if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase))
throw new PerformanceException($"密码错误"); throw new PerformanceException($"密码错误");
var data = Mapper.Map<UserIdentity>(user); var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N"); data.Token = Guid.NewGuid().ToString("N");
return data; return data;
} }
...@@ -108,7 +112,7 @@ public UserIdentity GetUser(int userId) ...@@ -108,7 +112,7 @@ public UserIdentity GetUser(int userId)
if (user == null) if (user == null)
throw new PerformanceException("用户信息查询失败"); throw new PerformanceException("用户信息查询失败");
return Mapper.Map<UserIdentity>(user); return _mapper.Map<UserIdentity>(user);
} }
/// <summary> /// <summary>
...@@ -142,7 +146,7 @@ public List<int> GetUserHospital(int userId) ...@@ -142,7 +146,7 @@ public List<int> GetUserHospital(int userId)
/// </summary> /// </summary>
/// <param name="userID"></param> /// <param name="userID"></param>
/// <returns></returns> /// <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 userRoles = _userroleRepository.GetEntities();
var userHospitals = _userhospitalRepository.GetEntities(); var userHospitals = _userhospitalRepository.GetEntities();
...@@ -154,12 +158,12 @@ public List<UserResponse> GetUserList(int userID,int roleType=1) ...@@ -154,12 +158,12 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (roleType == 12) 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(); users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
} }
else 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(); users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
} }
...@@ -184,7 +188,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1) ...@@ -184,7 +188,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (parentUser == null) continue; if (parentUser == null) continue;
parentUser.Department = user.Department; parentUser.Department = user.Department;
} }
result = Mapper.Map<List<UserResponse>>(userlist); result = _mapper.Map<List<UserResponse>>(userlist);
} }
else else
{ {
...@@ -203,7 +207,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1) ...@@ -203,7 +207,7 @@ public List<UserResponse> GetUserList(int userID,int roleType=1)
if (parentUser == null) continue; if (parentUser == null) continue;
parentUser.Department = user?.Department; parentUser.Department = user?.Department;
} }
result = Mapper.Map<List<UserResponse>>(userlist); result = _mapper.Map<List<UserResponse>>(userlist);
} }
if (result != null && result.Count > 0) if (result != null && result.Count > 0)
{ {
...@@ -277,7 +281,7 @@ public UserResponse Insert(UserRequest request, int userid) ...@@ -277,7 +281,7 @@ public UserResponse Insert(UserRequest request, int userid)
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department)) if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空"); throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request); var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now; user.CreateDate = DateTime.Now;
user.CreateUser = userid; user.CreateUser = userid;
user.States = (int)States.Enabled; user.States = (int)States.Enabled;
...@@ -291,7 +295,7 @@ public UserResponse Insert(UserRequest request, int userid) ...@@ -291,7 +295,7 @@ public UserResponse Insert(UserRequest request, int userid)
//添加用户医院 //添加用户医院
SetHospital(user.ID, request.HosIDArray); SetHospital(user.ID, request.HosIDArray);
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
/// <summary> /// <summary>
...@@ -371,7 +375,7 @@ public UserResponse Update(UserRequest request, bool isAgainAdmin) ...@@ -371,7 +375,7 @@ public UserResponse Update(UserRequest request, bool isAgainAdmin)
//添加用户医院 //添加用户医院
SetHospital(user.ID, request.HosIDArray); SetHospital(user.ID, request.HosIDArray);
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
/// <summary> /// <summary>
...@@ -400,7 +404,7 @@ public UserResponse UpdateSelf(UserRequest request) ...@@ -400,7 +404,7 @@ public UserResponse UpdateSelf(UserRequest request)
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
/// <summary> /// <summary>
...@@ -422,7 +426,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId) ...@@ -422,7 +426,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId)
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
/// <summary> /// <summary>
...@@ -543,7 +547,7 @@ public UserIdentity GetDemoUserIdentity(int userId) ...@@ -543,7 +547,7 @@ public UserIdentity GetDemoUserIdentity(int userId)
if (user == null) if (user == null)
throw new PerformanceException($"用户不存在,请先创建!"); throw new PerformanceException($"用户不存在,请先创建!");
var data = Mapper.Map<UserIdentity>(user); var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N"); data.Token = Guid.NewGuid().ToString("N");
return data; return data;
} }
...@@ -566,7 +570,7 @@ public UserResponse ResetPwd(int userId, int loginUserId) ...@@ -566,7 +570,7 @@ public UserResponse ResetPwd(int userId, int loginUserId)
user.Password = "123456"; user.Password = "123456";
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
throw new PerformanceException("重置失败"); throw new PerformanceException("重置失败");
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
#region 多角色 #region 多角色
...@@ -584,7 +588,7 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -584,7 +588,7 @@ public UserResponse InsertUser(UserRequest request, int userid)
if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department)) if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空"); throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request); var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now; user.CreateDate = DateTime.Now;
user.CreateUser = userid; user.CreateUser = userid;
user.States = (int)States.Enabled; user.States = (int)States.Enabled;
...@@ -613,7 +617,7 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -613,7 +617,7 @@ public UserResponse InsertUser(UserRequest request, int userid)
//添加用户医院 //添加用户医院
SetHospital(user.ID, request.HosIDArray); SetHospital(user.ID, request.HosIDArray);
} }
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
/// <summary> /// <summary>
...@@ -691,7 +695,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin) ...@@ -691,7 +695,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
//添加子用户医院 //添加子用户医院
SetHospital(diffUser.ID, request.HosIDArray); SetHospital(diffUser.ID, request.HosIDArray);
} }
return Mapper.Map<UserResponse>(user); return _mapper.Map<UserResponse>(user);
} }
public ApiResponse DeleteUser(int iD) public ApiResponse DeleteUser(int iD)
...@@ -844,9 +848,9 @@ public string SaveUserHandsFlat(UserCollectData request) ...@@ -844,9 +848,9 @@ public string SaveUserHandsFlat(UserCollectData request)
return ""; 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