Commit 1757a005 by ruyun.zhang@suvalue.com

Merge branch 'v2020morge-graphql'

parents 9ee21fb0 bb491167
using Microsoft.AspNetCore.Mvc;
using Performance.Subsidy.Services;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class SubsidyController : ControllerBase
{
private readonly SubsidyService _service;
public SubsidyController(
SubsidyService service)
{
_service = service;
}
/// <summary>
/// 绩效列表
/// </summary>
/// <returns></returns>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<view_allot>), (int)HttpStatusCode.OK)]
public async Task<ApiResponse> GetAllot()
{
var allots = await _service.GetAllot();
return new ApiResponse(Status.Ok, allots);
}
// 职称查询
[HttpGet("{allotId}/jobtitle")]
public async Task<ApiResponse> GetJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 重新查询职称
[HttpPost("{allotId}/reset-jobtitle")]
public async Task ResetJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 职称标准保存
[HttpPost("{allotId}/jobtitle")]
public async Task SaveJobTitle(int allotId)
{
throw new NotImplementedException();
}
// 个人职称补贴结果查询
[HttpGet("{allotId}/jobtitle/subsidy")]
public Task<ApiResponse> GetJobTitleSubsidy(int allotId)
{
throw new NotImplementedException();
}
// 个人职称补贴结果保存
[HttpPost("{allotId}/jobtitle/subsidy")]
public async Task SaveJobTitleSubsidy(int allotId)
{
throw new NotImplementedException();
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.Subsidy.Services\Performance.Subsidy.Services.csproj" />
</ItemGroup>
</Project>
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29135",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Performance.Subsidy.Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:29135",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
using Autofac;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Performance.Subsidy.Services;
using Performance.Subsidy.Services.Models;
using Performance.Subsidy.Services.Repository;
namespace Performance.Subsidy.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureContainer(ContainerBuilder builder)
{
var connectionString = Configuration.GetConnectionString("DefaultConnectionString");
builder.RegisterType<SubsidyService>().InstancePerLifetimeScope();
builder.RegisterType<ConnectionStringBuilder>().SingleInstance();
builder.RegisterInstance(new ConnectionFactory(connectionString)).SingleInstance();
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" });
});
services.Configure<ConnectionStringTemplates>(Configuration.GetSection("ConnectionStringTemplates"));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Performance.Subsidy.Api v1"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"DefaultConnectionString": "server=192.168.18.166;database=db_performance_subsidy;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;"
},
"ConnectionStringTemplates": {
"MySQLTemplates": "Server={0};Database={1};Uid={2};Pwd={3};pooling=true;charset=utf8;Convert Zero Datetime=True;port=3306;Allow User Variables=True;",
"SqlServerTemplates": "data source={0};initial catalog={1};user id={2};password={3};",
"OracleTemplates": "Password={3};User ID={2};Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME={1})));"
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services.Models
{
public class ConnectionStringTemplates
{
public string MySQLTemplates { get; set; }
public string SqlServerTemplates { get; set; }
public string OracleTemplates { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services.Repository
{
public class ConfigService
{
private readonly ConnectionFactory _factory;
public ConfigService(
ConnectionFactory factory)
{
_factory = factory;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Subsidy
{
public class ApiResponse<TEntity>
where TEntity : class, new()
{
public Status State { get; set; }
/// <summary>
/// 消息内容。
/// </summary>
public string Message { get; set; }
/// <summary>
/// 返回数据。
/// </summary>
public TEntity Data { get; set; }
public ApiResponse()
: this(Status.Fail, "", null)
{
}
public ApiResponse(Status type)
: this(type, type.ToString(), null)
{
}
public ApiResponse(Status type, string message)
: this(type, message, null)
{
}
public ApiResponse(Status type, TEntity entity)
: this(type, type.ToString(), entity)
{
}
public ApiResponse(Status type, string message, TEntity entity)
{
State = type;
Message = message;
Data = entity;
}
}
public sealed class ApiResponse : ApiResponse<Object>
{
public ApiResponse()
{
}
public ApiResponse(Status type) : base(type)
{
}
public ApiResponse(Status type, string message) : base(type, message)
{
}
public ApiResponse(Status type, object entity) : base(type, entity)
{
}
public ApiResponse(Status type, string message, object entity) : base(type, message, entity)
{
}
}
}
namespace Performance.Subsidy
{
public enum Status
{
Ok = 1,
Fail = 2,
Error = 3,
TokenError = 4,
NotFound = 5,
ParameterError = 6,
Disable = 7,
}
public enum DatabaseType
{
MySQL,
SqlServer,
Oracle,
}
}
namespace Performance.Subsidy.Services
{
public class ex_script { }
}
namespace Performance.Subsidy.Services
{
public class sub_jobtitle
{
public int ID { get; set; }
public int AllotId { get; set; }
public string JobTitle { get; set; }
public decimal? BasicPerforFee { get; set; }
}
}
namespace Performance.Subsidy.Services
{
public class sub_subsidy
{
public int ID { get; set; }
public int AllotID { get; set; }
public string Department { get; set; }
public string PersonnelNumber { get; set; }
public string PersonnelName { get; set; }
public string JobTitle { get; set; }
public decimal? BasicPerforFee { get; set; }
public decimal? Attendance { get; set; }
public decimal? GiveAmount { get; set; }
public decimal? RealAmount { get; set; }
}
}
namespace Performance.Subsidy.Services
{
public class view_allot
{
public int AllotId { get; set; }
public int HospitalId { get; set; }
public int Year { get; set; }
public int Month { get; set; }
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.24" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
</Project>
using Dapper;
using Microsoft.Extensions.Configuration;
using Performance.Subsidy.Services.Repository;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services
{
public class SubsidyService
{
private readonly ConnectionFactory _factory;
private readonly int _commandTimeout;
public SubsidyService(
ConnectionFactory factory)
{
_factory = factory;
_commandTimeout = 60 * 5;
}
public async Task<IEnumerable<view_allot>> GetAllot()
{
return await _factory.CreateDefault().QueryAsync<view_allot>("SELECT * FROM view_allot");
}
public async Task<IEnumerable<sub_jobtitle>> GetJobTitle(int allotId)
{
return await _factory.CreateDefault().QueryAsync<sub_jobtitle>("SELECT * FROM sub_jobtitle WHERE AllotID=@allotId", new { allotId });
}
}
}
using MySql.Data.MySqlClient;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services.Repository
{
public class ConnectionFactory
{
private readonly string _connectionString;
public ConnectionFactory(string connectionString)
{
_connectionString = connectionString;
}
public IDbConnection CreateDefault()
{
return new MySqlConnection(_connectionString);
}
public IDbConnection Create(DatabaseType type, string connectionString)
{
try
{
switch (type)
{
case DatabaseType.MySQL:
return new MySqlConnection(connectionString);
case DatabaseType.SqlServer:
return new SqlConnection(connectionString);
case DatabaseType.Oracle:
return new OracleConnection(connectionString);
default:
throw new ArgumentException("DatabaseType类型不支持");
}
}
catch (Exception ex)
{
throw;
}
}
}
}
using Microsoft.Extensions.Options;
using Performance.Subsidy.Services.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services
{
public class ConnectionStringBuilder
{
private readonly IOptions<ConnectionStringTemplates> _options;
public ConnectionStringBuilder(IOptions<ConnectionStringTemplates> options)
{
_options = options;
}
public string GetConnectionString(DatabaseType type, string ip, string database, string uid, string pwd)
{
switch (type)
{
case DatabaseType.MySQL:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd);
case DatabaseType.SqlServer:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd);
case DatabaseType.Oracle:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd);
default:
throw new ArgumentException("DatabaseType类型不支持");
}
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Api", "Performance.Subsidy.Api\Performance.Subsidy.Api.csproj", "{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}.Release|Any CPU.Build.0 = Release|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75937D89-4F57-4D95-A03E-DD64D782C700}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF4E84C3-E4BA-40EF-8B82-41EEDA53BE8B}
EndGlobalSection
EndGlobal
...@@ -92,13 +92,13 @@ public ApiResponse<JwtToken> Refresh() ...@@ -92,13 +92,13 @@ public ApiResponse<JwtToken> Refresh()
var userClaim = _claim.GetUserClaim(); var userClaim = _claim.GetUserClaim();
var claims = new Claim[] var claims = new Claim[]
{ {
new Claim(JwtClaimTypes.Id, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Id).Value), new Claim(JwtClaimTypes.Id, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Id)?.Value??""),
new Claim(JwtClaimTypes.Login, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Login).Value), new Claim(JwtClaimTypes.Login, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Login)?.Value??""),
new Claim(JwtClaimTypes.RealName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.RealName).Value), new Claim(JwtClaimTypes.RealName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.RealName)?.Value??""),
new Claim(JwtClaimTypes.Mail, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Mail).Value), new Claim(JwtClaimTypes.Mail, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Mail)?.Value??""),
new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName).Value), new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName)?.Value??""),
new Claim(JwtClaimTypes.Device, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device).Value), new Claim(JwtClaimTypes.Device, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device)?.Value??""),
new Claim(JwtClaimTypes.Department, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Department).Value), new Claim(JwtClaimTypes.Department, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Department)?.Value??""),
}; };
var jwtToken = JwtTokenHelper.GenerateToken(claims, _options.ExpirationMinutes); var jwtToken = JwtTokenHelper.GenerateToken(claims, _options.ExpirationMinutes);
...@@ -271,9 +271,9 @@ public ApiResponse<JwtToken> DemoUsers(int userId) ...@@ -271,9 +271,9 @@ public ApiResponse<JwtToken> DemoUsers(int userId)
new Claim(JwtClaimTypes.Id, user.UserID.ToString()), new Claim(JwtClaimTypes.Id, user.UserID.ToString()),
new Claim(JwtClaimTypes.Login, user.Login), new Claim(JwtClaimTypes.Login, user.Login),
new Claim(JwtClaimTypes.RealName, user.RealName), new Claim(JwtClaimTypes.RealName, user.RealName),
new Claim(JwtClaimTypes.Mail, user.Mail), new Claim(JwtClaimTypes.Mail, user.Mail??""),
new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName).Value), new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName)?.Value??""),
new Claim(JwtClaimTypes.Device,userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device).Value), new Claim(JwtClaimTypes.Device,userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device)?.Value??""),
new Claim(JwtClaimTypes.Department, user.Department ?? ""), new Claim(JwtClaimTypes.Department, user.Department ?? ""),
}; };
......
...@@ -189,7 +189,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -189,7 +189,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
/// <summary> /// <summary>
/// 上传文件 /// 上传文件
/// </summary> /// </summary>
/// <param name="form"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
[Route("ImportExtraction/{allotId}")] [Route("ImportExtraction/{allotId}")]
[HttpPost] [HttpPost]
...@@ -244,7 +244,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -244,7 +244,6 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
var allot = _allotService.GetAllot(request.ID); var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path)) if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件"); throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
var email = _claim.GetUserClaim(JwtClaimTypes.Mail);
if (allot.States == (int)AllotStates.Wait) if (allot.States == (int)AllotStates.Wait)
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成"); return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
...@@ -252,7 +251,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -252,7 +251,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate); _allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
if (_evn.IsEnvironment("Localhost")) if (_evn.IsEnvironment("Localhost"))
{ {
_allotService.Generate(allot, email); _allotService.Generate(allot);
} }
else else
{ {
...@@ -263,7 +262,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -263,7 +262,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
{ {
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>(); var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.Generate(allot, email); scopedServices.Generate(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token); await Task.Delay(TimeSpan.FromSeconds(5), token);
} }
}); });
...@@ -274,6 +273,34 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -274,6 +273,34 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email)); ////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email));
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
/// <summary>
/// 绩效生成报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("genreport")]
[HttpPost]
public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromBody] AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
var states = new[] { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed, (int)AllotStates.GenerateAccomplish };
if (null == allot || !states.Contains(allot.States))
throw new PerformanceException("当前绩效暂未生成,无法统计报表数据。");
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.GenerateReport(allot);
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
return new ApiResponse(ResponseType.OK);
}
/* /*
[Route("recalculation")] [Route("recalculation")]
[HttpPost] [HttpPost]
...@@ -284,7 +311,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request) ...@@ -284,7 +311,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
*/ */
/// <summary> /// <summary>
/// 重新计算院领导绩效 /// 重新计算院领导绩效
/// </summary> /// </summary>
......
...@@ -290,14 +290,16 @@ public ApiResponse AllComputeByPM([FromBody] ComputerRequest request) ...@@ -290,14 +290,16 @@ public ApiResponse AllComputeByPM([FromBody] ComputerRequest request)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var isShowManage = _computeService.IsShowManage(request.AllotId); var isShowManage = _computeService.IsShowManage(request.AllotId);
var list = _computeService.AllCompute(request.AllotId, allot.HospitalId, isShowManage); var list = _computeService.AllCompute(request.AllotId, allot.HospitalId, isShowManage, true);
if (list == null || !list.Any()) if (list == null || !list.Any())
return new ApiResponse(ResponseType.OK, "ok", list); return new ApiResponse(ResponseType.OK, "ok", list);
var result = list.GroupBy(t => new { t.EmployeeName, t.JobNumber }).Select(t => new ComputeResponse var result = list.GroupBy(t => new { t.AccountingUnit, t.UnitType, t.EmployeeName, t.JobNumber }).Select(t => new ComputeResponse
{ {
EmployeeName = t.Key.EmployeeName,
JobNumber = t.Key.JobNumber, JobNumber = t.Key.JobNumber,
EmployeeName = t.Key.EmployeeName,
AccountingUnit = t.Key.AccountingUnit,
UnitType = t.Key.UnitType,
PerforSumFee = t.Sum(s => s.PerforSumFee), PerforSumFee = t.Sum(s => s.PerforSumFee),
PerforManagementFee = t.Sum(s => s.PerforManagementFee), PerforManagementFee = t.Sum(s => s.PerforManagementFee),
AdjustLaterOtherFee = t.Sum(s => s.AdjustLaterOtherFee), AdjustLaterOtherFee = t.Sum(s => s.AdjustLaterOtherFee),
......
...@@ -142,29 +142,29 @@ public ApiResponse InpatFeeAvg([CustomizeValidator(RuleSet = "Query"), FromBody] ...@@ -142,29 +142,29 @@ public ApiResponse InpatFeeAvg([CustomizeValidator(RuleSet = "Query"), FromBody]
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
/// <summary> ///// <summary>
/// 科室药占比 ///// 科室药占比
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[Route("medicine")] //[Route("medicine")]
[HttpPost] //[HttpPost]
public ApiResponse Medicine([CustomizeValidator(RuleSet = "Query"), FromBody] ReportRequest request) //public ApiResponse Medicine([CustomizeValidator(RuleSet = "Query"), FromBody] ReportRequest request)
{ //{
var list = reportService.Medicine(request.HospitalId, request.IsIndex); // var list = reportService.Medicine(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, "", list); // return new ApiResponse(ResponseType.OK, "", list);
} //}
/// <summary> ///// <summary>
/// 科室有效收入占比 ///// 科室有效收入占比
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[Route("income")] //[Route("income")]
[HttpPost] //[HttpPost]
public ApiResponse Income([CustomizeValidator(RuleSet = "Query"), FromBody] ReportRequest request) //public ApiResponse Income([CustomizeValidator(RuleSet = "Query"), FromBody] ReportRequest request)
{ //{
var list = reportService.Income(request.HospitalId, request.IsIndex); // var list = reportService.Income(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, "", list); // return new ApiResponse(ResponseType.OK, "", list);
} //}
/// <summary> /// <summary>
/// 月群体人均绩效 /// 月群体人均绩效
......
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels; using Performance.DtoModels;
...@@ -80,7 +81,7 @@ public ApiResponse SaveValue(int secondid, [FromBody] List<ag_fixatitem> request ...@@ -80,7 +81,7 @@ public ApiResponse SaveValue(int secondid, [FromBody] List<ag_fixatitem> request
if (unitTypeCount != 1 || request.Any(t => string.IsNullOrEmpty(t.UnitType))) if (unitTypeCount != 1 || request.Any(t => string.IsNullOrEmpty(t.UnitType)))
throw new PerformanceException("科室类型错误"); throw new PerformanceException("科室类型错误");
var repetition = request.GroupBy(t => new { t.RowNumber, t.ItemName }).Where(t => t.Count() > 1); var repetition = request.GroupBy(t => new { t.RowNumber, t.ItemName /*, WorkType = t.WorkType ?? 0*/ }).Where(t => t.Count() > 1);
if (repetition.Any()) if (repetition.Any())
throw new PerformanceException(string.Join(";", repetition.Select(t => $"行{t.Key.RowNumber}项‘{t.Key.ItemName}’重复录入"))); throw new PerformanceException(string.Join(";", repetition.Select(t => $"行{t.Key.RowNumber}项‘{t.Key.ItemName}’重复录入")));
...@@ -152,6 +153,7 @@ public ApiResponse SecondDetail([CustomizeValidator(RuleSet = "Refresh"), FromBo ...@@ -152,6 +153,7 @@ public ApiResponse SecondDetail([CustomizeValidator(RuleSet = "Refresh"), FromBo
public ApiResponse AutoComplete([FromBody] SecondEmpRequest request) public ApiResponse AutoComplete([FromBody] SecondEmpRequest request)
{ {
var result = secondAllotService.AutoComplete(request, claimService.GetUserId()); var result = secondAllotService.AutoComplete(request, claimService.GetUserId());
//var result = secondAllotService.AutoComplete(request.SecondId, request.JobNumber);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -405,7 +407,7 @@ public ApiResponse OtherList([FromBody] AgOtherRequest request) ...@@ -405,7 +407,7 @@ public ApiResponse OtherList([FromBody] AgOtherRequest request)
//var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount); //var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
var obj = new var obj = new
{ {
header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(t=>t.RealAmount)), header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(t => t.RealAmount)),
body = result, body = result,
}; };
return new ApiResponse(ResponseType.OK, obj); return new ApiResponse(ResponseType.OK, obj);
...@@ -464,5 +466,68 @@ public ApiResponse DeptComputeDetail(int allotId) ...@@ -464,5 +466,68 @@ public ApiResponse DeptComputeDetail(int allotId)
var data = secondAllotService.DeptComputeDetailList(userId, allotId, out int isShowManage); var data = secondAllotService.DeptComputeDetailList(userId, allotId, out int isShowManage);
return new ApiResponse(ResponseType.OK, new { isShowManage, data }); return new ApiResponse(ResponseType.OK, new { isShowManage, data });
} }
/// <summary>
/// 获取二次绩效详情数据
/// </summary>
/// <param name="secondId"></param>
/// <param name="employeeSource"></param>
/// <returns></returns>
[HttpPost("api/second/detail/{secondId}/{employeeSource}")]
public ApiResponse GetSecondAllotDetail([FromRoute] int secondId, int employeeSource)
{
var detail = secondAllotService.GetSecondSavedData(claimService.GetUserId(), secondId, employeeSource);
return new ApiResponse(ResponseType.OK, detail);
}
/// <summary>
/// 获取工作量类型
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
[HttpPost("api/second/worktype/{secondId}")]
public ApiResponse GetWorktypeDict([FromRoute] int secondId)
{
var detail = secondAllotService.GetWorkTypeDict(secondId);
return new ApiResponse(ResponseType.OK, detail);
}
/// <summary>
/// 获取工作量明细项
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
[HttpPost("api/second/workload/{secondId}")]
public ApiResponse GetWorkloadDict([FromRoute] int secondId)
{
var detail = secondAllotService.GetWorkloadDict(secondId);
return new ApiResponse(ResponseType.OK, detail);
}
/// <summary>
/// 二次绩效项目内容保存
/// </summary>
/// <param name="secondId"></param>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("api/second/savedata/{secondId}")]
[AllowAnonymous]
public ApiResponse SaveValue([FromRoute] int secondId, [FromBody] dynamic request)
{
secondAllotService.SaveSecondAllotData(secondId, request);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 二次绩效录入页面自动补全
/// </summary>
/// <returns></returns>
[Route("api/second/autocomplete/{secondId}/{jobNumber}")]
[HttpPost]
public ApiResponse AutoCompleteBodyData([FromRoute] int secondId, string jobNumber)
{
var result = secondAllotService.AutoComplete(secondId, jobNumber);
return new ApiResponse(ResponseType.OK, result);
}
} }
} }
using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using Performance.Services.ExtractExcelService;
namespace Performance.Api
{
public class ExtractDataJob : IJob
{
private readonly ExtractJobService extractJobService;
public ExtractDataJob()
{
this.extractJobService = ServiceLocator.Instance.GetService<ExtractJobService>();
}
public void Execute()
{
extractJobService.Execute();
}
}
}
using FluentScheduler;
namespace Performance.Api
{
public class JobRegistry : Registry
{
public JobRegistry()
{
Schedule<ExtractDataJob>().ToRunNow().AndEvery(1).Days().At(23, 0);
//Schedule<ExtractDataJob>().ToRunEvery(1).Days().At(23, 0);
}
}
}
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<PackageReference Include="AutoMapper" Version="8.0.0" /> <PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" /> <PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="FluentScheduler" Version="5.5.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" /> <PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
<PackageReference Include="GraphQL" Version="2.4.0" /> <PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="Hangfire" Version="1.6.22" /> <PackageReference Include="Hangfire" Version="1.6.22" />
......
...@@ -209,6 +209,9 @@ public void ConfigureServices(IServiceCollection services) ...@@ -209,6 +209,9 @@ public void ConfigureServices(IServiceCollection services)
}); });
#endregion swagger #endregion swagger
ServiceLocator.Instance = services.BuildServiceProvider();
FluentScheduler.JobManager.Initialize(new JobRegistry());
} }
// 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.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
}, },
"AppConnection": { "AppConnection": {
//"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", //"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_performance_screen;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", "PerformanceConnectionString": "server=192.168.18.166;database=db_test_liutie;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;", "HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2" "RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
}, },
......
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
<summary> <summary>
上传文件 上传文件
</summary> </summary>
<param name="form"></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.Generate(Performance.DtoModels.AllotRequest)">
...@@ -218,6 +218,13 @@ ...@@ -218,6 +218,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AllotController.GenerateReport(Performance.DtoModels.AllotRequest)">
<summary>
绩效生成报表
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.Recalculation(Performance.DtoModels.RecalculationRequest)"> <member name="M:Performance.Api.Controllers.AllotController.Recalculation(Performance.DtoModels.RecalculationRequest)">
<summary> <summary>
重新计算院领导绩效 重新计算院领导绩效
...@@ -1135,18 +1142,6 @@ ...@@ -1135,18 +1142,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ReportController.Medicine(Performance.DtoModels.ReportRequest)">
<summary>
科室药占比
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.Income(Performance.DtoModels.ReportRequest)">
<summary>
科室有效收入占比
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.AvgPerfor(Performance.DtoModels.ReportRequest)"> <member name="M:Performance.Api.Controllers.ReportController.AvgPerfor(Performance.DtoModels.ReportRequest)">
<summary> <summary>
月群体人均绩效 月群体人均绩效
...@@ -1411,6 +1406,42 @@ ...@@ -1411,6 +1406,42 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.SecondAllotController.GetSecondAllotDetail(System.Int32,System.Int32)">
<summary>
获取二次绩效详情数据
</summary>
<param name="secondId"></param>
<param name="employeeSource"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.GetWorktypeDict(System.Int32)">
<summary>
获取工作量类型
</summary>
<param name="secondId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.GetWorkloadDict(System.Int32)">
<summary>
获取工作量明细项
</summary>
<param name="secondId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.SaveValue(System.Int32,System.Object)">
<summary>
二次绩效项目内容保存
</summary>
<param name="secondId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.AutoCompleteBodyData(System.Int32,System.String)">
<summary>
二次绩效录入页面自动补全
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SheetController.SheetList(Performance.DtoModels.SheetRequest)"> <member name="M:Performance.Api.Controllers.SheetController.SheetList(Performance.DtoModels.SheetRequest)">
<summary> <summary>
sheet 列表 sheet 列表
......
...@@ -1109,6 +1109,46 @@ ...@@ -1109,6 +1109,46 @@
夜班绩效 夜班绩效
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.JobTitle">
<summary>
职称
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.AccountType">
<summary>
核算单元类型
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.JobNumber">
<summary>
工号
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.FitPeople">
<summary>
绩效基数核算参考对象
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.FitPeopleValue">
<summary>
绩效基础核算参考值
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.FitPeopleRatio">
<summary>
绩效基础核算系数
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.Basics">
<summary>
基础绩效系数
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataAccountBaisc.PostCoefficient">
<summary>
岗位系数
</summary>
</member>
<member name="P:Performance.DtoModels.PerDataClinicEmployee.UnitType"> <member name="P:Performance.DtoModels.PerDataClinicEmployee.UnitType">
<summary> <summary>
核算单元分类 核算单元分类
...@@ -2426,7 +2466,12 @@ ...@@ -2426,7 +2466,12 @@
</member> </member>
<member name="P:Performance.DtoModels.WorkloadRequest.WorkTypeId"> <member name="P:Performance.DtoModels.WorkloadRequest.WorkTypeId">
<summary> <summary>
1、工作量 2、其他 自定义工作量类型Id(不包括默认工作量绩效类型、单项奖励)
</summary>
</member>
<member name="P:Performance.DtoModels.WorkloadRequest.IsSingleAwards">
<summary>
是否是单项奖励
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.WorkyearRequest.MaxRange"> <member name="P:Performance.DtoModels.WorkyearRequest.MaxRange">
...@@ -3429,6 +3474,21 @@ ...@@ -3429,6 +3474,21 @@
首页地址 首页地址
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.Detail.IsArchive">
<summary> 是否归档 </summary>
</member>
<member name="P:Performance.DtoModels.Detail.States">
<summary>
0 数据未上传 1 数据已上传 2 正在校验数据 3 数据验证通过
4 数据错误 5 正在生成绩效 6 下发绩效 7 绩效解析失败
8 归档 9 等待生成 10 绩效结果解析成功
</summary>
</member>
<member name="P:Performance.DtoModels.Detail.Status">
<summary>
状态 1 未提交 2 等待审核 3 审核通过 4 驳回
</summary>
</member>
<member name="P:Performance.DtoModels.SecondListResponse.IsArchive"> <member name="P:Performance.DtoModels.SecondListResponse.IsArchive">
<summary> 是否归档 </summary> <summary> 是否归档 </summary>
</member> </member>
......
...@@ -185,8 +185,7 @@ public AutoMapperConfigs() ...@@ -185,8 +185,7 @@ public AutoMapperConfigs()
CreateMap<ag_tempitem, HeadItem>(); CreateMap<ag_tempitem, HeadItem>();
CreateMap<ag_workload, HeadItem>() CreateMap<ag_workload, HeadItem>()
.ForMember(dest => dest.FiledId, opt => opt.MapFrom(src => src.ItemId)) .ForMember(dest => dest.FiledId, opt => opt.MapFrom(src => src.ItemId))
.ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName)) .ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName));
.ForMember(dest => dest.WorkType, opt => opt.MapFrom(src => src.WorkTypeId));
CreateMap<ag_fixatitem, BodyItem>() CreateMap<ag_fixatitem, BodyItem>()
.ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName)) .ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName))
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue)); .ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue));
......
...@@ -87,11 +87,11 @@ public enum AgWorkloadType ...@@ -87,11 +87,11 @@ public enum AgWorkloadType
/// <summary> /// <summary>
/// 单项奖励 /// 单项奖励
/// </summary> /// </summary>
SingleAwards = 1, SingleAwards = -1,
/// <summary> /// <summary>
/// 工作量 /// 工作量
/// </summary> /// </summary>
Workload = 2, Workload = 0,
} }
public enum DataFormat public enum DataFormat
{ {
......
...@@ -91,12 +91,12 @@ public class PerDataAccountBaisc : IPerData ...@@ -91,12 +91,12 @@ public class PerDataAccountBaisc : IPerData
/// <summary> /// <summary>
/// 医院奖罚 /// 医院奖罚
/// </summary> /// </summary>
public decimal Extra { get; set; } public Nullable<decimal> Extra { get; set; }
/// <summary> /// <summary>
/// 考核对分率 /// 考核对分率
/// </summary> /// </summary>
public decimal ScoringAverage { get; set; } public Nullable<decimal> ScoringAverage { get; set; }
/// <summary> /// <summary>
/// 考核后管理绩效 /// 考核后管理绩效
...@@ -116,7 +116,7 @@ public class PerDataAccountBaisc : IPerData ...@@ -116,7 +116,7 @@ public class PerDataAccountBaisc : IPerData
/// <summary> /// <summary>
/// 调节系数 /// 调节系数
/// </summary> /// </summary>
public decimal AdjustFactor { get; set; } public Nullable<decimal> AdjustFactor { get; set; }
/// <summary> /// <summary>
/// 调节后其他绩效 /// 调节后其他绩效
...@@ -243,5 +243,46 @@ public class PerDataAccountBaisc : IPerData ...@@ -243,5 +243,46 @@ public class PerDataAccountBaisc : IPerData
public Nullable<decimal> NightShiftWorkPerforFee { get; set; } public Nullable<decimal> NightShiftWorkPerforFee { get; set; }
#endregion 由计算得出 #endregion 由计算得出
/// <summary>
/// 职称
/// </summary>
public string JobTitle { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string AccountType { get; set; }
/// <summary>
/// 工号
/// </summary>
public string JobNumber { get; set; }
/// <summary>
/// 绩效基数核算参考对象
/// </summary>
public string FitPeople { get; set; }
/// <summary>
/// 绩效基础核算参考值
/// </summary>
public Nullable<decimal> FitPeopleValue { get; set; }
/// <summary>
/// 绩效基础核算系数
/// </summary>
public Nullable<decimal> FitPeopleRatio { get; set; }
/// <summary>
/// 基础绩效系数
/// </summary>
public Nullable<decimal> Basics { get; set; }
/// <summary>
/// 岗位系数
/// </summary>
public Nullable<decimal> PostCoefficient { get; set; }
} }
} }
...@@ -20,7 +20,7 @@ public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest> ...@@ -20,7 +20,7 @@ public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
{ {
public SecondEmpRequestValidator() public SecondEmpRequestValidator()
{ {
RuleFor(x => x.TempId).NotNull().GreaterThan(0); //RuleFor(x => x.TempId).NotNull().GreaterThan(0);
RuleFor(x => x.SecondId).NotNull().GreaterThan(0); RuleFor(x => x.SecondId).NotNull().GreaterThan(0);
} }
} }
......
...@@ -8,7 +8,7 @@ namespace Performance.DtoModels ...@@ -8,7 +8,7 @@ namespace Performance.DtoModels
public class WorkDetailRequest public class WorkDetailRequest
{ {
public int AllotId { get; set; } public int AllotId { get; set; }
public int SecondId { get; set; } //public int SecondId { get; set; }
public string Source { get; set; } public string Source { get; set; }
public string AccountingUnit { get; set; } public string AccountingUnit { get; set; }
} }
...@@ -20,7 +20,7 @@ public WorkDetailRequestValidator() ...@@ -20,7 +20,7 @@ public WorkDetailRequestValidator()
RuleSet("Select", () => RuleSet("Select", () =>
{ {
RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0); RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.SecondId).NotNull().NotEmpty().GreaterThan(0); //RuleFor(x => x.SecondId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AccountingUnit).NotNull().NotEmpty(); RuleFor(x => x.AccountingUnit).NotNull().NotEmpty();
}); });
} }
......
...@@ -43,9 +43,14 @@ public class WorkloadRequest ...@@ -43,9 +43,14 @@ public class WorkloadRequest
public Nullable<decimal> Sort { get; set; } public Nullable<decimal> Sort { get; set; }
/// <summary> /// <summary>
/// 1、工作量 2、其他 /// 自定义工作量类型Id(不包括默认工作量绩效类型、单项奖励)
/// </summary> /// </summary>
public int WorkTypeId { get; set; } public int WorkTypeId { get; set; }
/// <summary>
/// 是否是单项奖励
/// </summary>
public bool IsSingleAwards { get; set; }
} }
public class WorkloadRequestValidator : AbstractValidator<WorkloadRequest> public class WorkloadRequestValidator : AbstractValidator<WorkloadRequest>
{ {
......
using Newtonsoft.Json.Linq;
namespace Performance.DtoModels
{
public class SecondAllotResponse
{
public Detail Detail { get; set; }
public JObject Head { get; set; }
public JArray Body { get; set; }
}
public class Detail
{
public int TempId { get; set; }
public string TempName { get; set; }
/// <summary> 是否归档 </summary>
public int IsArchive { get; set; }
/// <summary>
/// 0 数据未上传 1 数据已上传 2 正在校验数据 3 数据验证通过
/// 4 数据错误 5 正在生成绩效 6 下发绩效 7 绩效解析失败
/// 8 归档 9 等待生成 10 绩效结果解析成功
/// </summary>
public int States { get; set; }
/// <summary>
/// 状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary>
public int Status { get; set; }
public string Department { get; set; }
public string UnitType { get; set; }
}
}
...@@ -52,7 +52,6 @@ public BodyItem(HeadItem headItem) ...@@ -52,7 +52,6 @@ public BodyItem(HeadItem headItem)
SourceType = headItem.SourceType; SourceType = headItem.SourceType;
IsBring = headItem.IsBring; IsBring = headItem.IsBring;
SpecialAttr = headItem.SpecialAttr; SpecialAttr = headItem.SpecialAttr;
WorkType = headItem.WorkType;
} }
} }
} }
...@@ -11,13 +11,16 @@ public class UserResponse ...@@ -11,13 +11,16 @@ public class UserResponse
public int CreateUser { get; set; } public int CreateUser { get; set; }
public string RealName { get; set; } public string RealName { get; set; }
public string Login { get; set; } public string Login { get; set; }
public string Password { get; set; }
public string Mail { get; set; } public string Mail { get; set; }
public string Mobile { get; set; } public string Mobile { get; set; }
public int States { get; set; } public int States { get; set; }
public string Hospital { get; set; } public string Hospital { get; set; }
public int Role { get; set; } public int Role { get; set; }
public string Department { get; set; } public string Department { get; set; }
public int[] RoleArr { get; set; } public int[] RoleArr { get; set; }
public string[] RoleNameArr { get; set; }
public string[] HospitalNameArr { get; set; }
} }
} }
...@@ -15,7 +15,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -15,7 +15,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> 二次分配概览 </summary> /// <summary> 二次分配概览 </summary>
public virtual DbSet<ag_againsituation> ag_againsituation { get; set; } public virtual DbSet<ag_againsituation> ag_againsituation { get; set; }
/// <summary> 二次绩效结果表 </summary> /// <summary> 二次绩效保存数据 </summary>
public virtual DbSet<ag_bodysource> ag_bodysource { get; set; }
/// <summary> 二次绩效结果表 </summary>
public virtual DbSet<ag_compute> ag_compute { get; set; } public virtual DbSet<ag_compute> ag_compute { get; set; }
/// <summary> 二次分配不固定数据 </summary> /// <summary> 二次分配不固定数据 </summary>
public virtual DbSet<ag_data> ag_data { get; set; } public virtual DbSet<ag_data> ag_data { get; set; }
...@@ -25,7 +27,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -25,7 +27,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<ag_fixatitem> ag_fixatitem { get; set; } public virtual DbSet<ag_fixatitem> ag_fixatitem { get; set; }
/// <summary> 二次分配不固定列头数据 </summary> /// <summary> 二次分配不固定列头数据 </summary>
public virtual DbSet<ag_header> ag_header { get; set; } public virtual DbSet<ag_header> ag_header { get; set; }
/// <summary> 科室二次绩效录入内容 </summary> /// <summary> 二次绩效顶部数据 </summary>
public virtual DbSet<ag_headsource> ag_headsource { get; set; }
/// <summary> 科室二次绩效录入内容 </summary>
public virtual DbSet<ag_itemvalue> ag_itemvalue { get; set; } public virtual DbSet<ag_itemvalue> ag_itemvalue { get; set; }
/// <summary> 二次绩效其他绩效来源 </summary> /// <summary> 二次绩效其他绩效来源 </summary>
public virtual DbSet<ag_othersource> ag_othersource { get; set; } public virtual DbSet<ag_othersource> ag_othersource { get; set; }
...@@ -39,9 +43,13 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -39,9 +43,13 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<ag_usetemp> ag_usetemp { get; set; } public virtual DbSet<ag_usetemp> ag_usetemp { get; set; }
/// <summary> 二次绩效工作量绩效 </summary> /// <summary> 二次绩效工作量绩效 </summary>
public virtual DbSet<ag_workload> ag_workload { get; set; } public virtual DbSet<ag_workload> ag_workload { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<ag_workload_source> ag_workload_source { get; set; }
/// <summary> </summary>
public virtual DbSet<ag_workload_type> ag_workload_type { get; set; } public virtual DbSet<ag_workload_type> ag_workload_type { get; set; }
/// <summary> 考核类别 </summary> /// <summary> </summary>
public virtual DbSet<ag_worktype_source> ag_worktype_source { get; set; }
/// <summary> 考核类别 </summary>
public virtual DbSet<as_assess> as_assess { get; set; } public virtual DbSet<as_assess> as_assess { get; set; }
/// <summary> 考核列头 </summary> /// <summary> 考核列头 </summary>
public virtual DbSet<as_columns> as_columns { get; set; } public virtual DbSet<as_columns> as_columns { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" ag_bodysource.cs">
// * FileName: 二次绩效保存数据.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
/// 二次绩效保存数据
/// </summary>
[Table("ag_bodysource")]
public class ag_bodysource
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int SecondId { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> RowNumber { get; set; }
/// <summary>
/// 人员工号
/// </summary>
public string WorkNumber { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 岗位
/// </summary>
public string Post { get; set; }
/// <summary>
/// 人员系数
/// </summary>
public Nullable<decimal> StaffCoefficient { get; set; }
/// <summary>
/// 出勤
/// </summary>
public Nullable<decimal> ActualAttendance { get; set; }
/// <summary>
/// 职称
/// </summary>
public string JobTitle { get; set; }
/// <summary>
/// 职称系数
/// </summary>
public Nullable<decimal> TitleCoefficient { get; set; }
/// <summary>
/// 职称绩效
/// </summary>
public Nullable<decimal> TitlePerformance { get; set; }
/// <summary>
/// 管理津贴
/// </summary>
public Nullable<decimal> ManagementAllowance { get; set; }
/// <summary>
/// 单项奖励
/// </summary>
public Nullable<decimal> IndividualReward { get; set; }
/// <summary>
/// 重点专科分配
/// </summary>
public Nullable<decimal> AllocationOfKeySpecialty { get; set; }
/// <summary>
/// 科室单项奖励
/// </summary>
public Nullable<decimal> DeptReward { get; set; }
/// <summary>
/// 主任基础绩效
/// </summary>
public Nullable<decimal> BasisPerformance { get; set; }
/// <summary>
/// 可分配绩效
/// </summary>
public Nullable<decimal> DistPerformance { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public Nullable<decimal> OtherPerformance { get; set; }
/// <summary>
/// 夜班工作量绩效
/// </summary>
public Nullable<decimal> NightWorkPerformance { get; set; }
/// <summary>
/// 实发绩效工资金额
/// </summary>
public Nullable<decimal> RealAmount { get; set; }
/// <summary>
/// 签字
/// </summary>
public string Signature { get; set; }
/// <summary>
/// 预留比例
/// </summary>
public Nullable<decimal> ReservedRatio { get; set; }
/// <summary>
/// 预留金额
/// </summary>
public Nullable<decimal> ReservedAmount { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_headsource.cs">
// * FileName: 二次绩效顶部数据.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
/// 二次绩效顶部数据
/// </summary>
[Table("ag_headsource")]
public class ag_headsource
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int SecondId { get; set; }
/// <summary>
/// 可分配绩效
/// </summary>
public Nullable<decimal> TotalPerformance { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public Nullable<decimal> HosOtherPerformance { get; set; }
/// <summary>
/// 夜班绩效总和
/// </summary>
public Nullable<decimal> NightShiftWorkPerforTotal { get; set; }
/// <summary>
/// 科室总绩效
/// </summary>
public Nullable<decimal> TotalDistPerformance { get; set; }
/// <summary>
/// 主任基础绩效
/// </summary>
public Nullable<decimal> DirectorBasisPerformance { get; set; }
/// <summary>
/// 科室单项奖励
/// </summary>
public Nullable<decimal> TheTotalAllocationOfPerformanceResults { get; set; }
/// <summary>
/// 业绩分配绩效总额
/// </summary>
public Nullable<decimal> BasisPerformance { get; set; }
/// <summary>
/// 年资职称绩效占比
/// </summary>
public Nullable<decimal> SeniorityTitlesAccountedPerformance { get; set; }
/// <summary>
/// 年资职称绩效
/// </summary>
public Nullable<decimal> SeniorityTitlesPerformance { get; set; }
/// <summary>
/// 工作量绩效占比
/// </summary>
public Nullable<decimal> Workload_Ratio_Default { get; set; }
/// <summary>
/// 工作量分配绩效金额
/// </summary>
public Nullable<decimal> Workload_Amount_Default { get; set; }
/// <summary>
/// 满勤天数
/// </summary>
public Nullable<decimal> DaysFullAttendance { get; set; }
/// <summary>
/// 科室人均
/// </summary>
public Nullable<decimal> DepartmentsPerCapita { get; set; }
/// <summary>
/// 发放月份
/// </summary>
public string PaymentOfTheMonth { get; set; }
/// <summary>
/// 科室核算人数
/// </summary>
public Nullable<decimal> TheNumberOfAccountingDepartment { get; set; }
}
}
...@@ -82,7 +82,7 @@ public class ag_secondallot ...@@ -82,7 +82,7 @@ public class ag_secondallot
public Nullable<int> Status { get; set; } public Nullable<int> Status { get; set; }
/// <summary> /// <summary>
/// 提交类型 1使用模板 2 其他类型数据 /// 提交类型 1 使用模板 2 其他类型数据
/// </summary> /// </summary>
public Nullable<int> SubmitType { get; set; } public Nullable<int> SubmitType { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" ag_workload_source.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("ag_workload_source")]
public class ag_workload_source
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int WorkloadId { get; set; }
/// <summary>
///
/// </summary>
public int BodyId { get; set; }
/// <summary>
/// 工作量考核项ID
/// </summary>
public string ItemId { get; set; }
/// <summary>
/// 工作量名称
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 工作量系数
/// </summary>
public Nullable<decimal> FactorValue { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> Sort { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> Value { get; set; }
/// <summary>
/// 1、单项奖励 2、工作量占比 ..(自定义占比)
/// </summary>
public Nullable<int> WorkTypeId { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_worktype_source.cs">
// * FileName: ag_worktype_source.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("ag_worktype_source")]
public class ag_worktype_source
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int WorkTypeId { get; set; }
/// <summary>
///
/// </summary>
public int SecondId { get; set; }
/// <summary>
///
/// </summary>
public string FieldId { get; set; }
/// <summary>
///
/// </summary>
public string FieldName { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
...@@ -7,105 +7,110 @@ ...@@ -7,105 +7,110 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels namespace Performance.EntityModels
{ {
/// <summary> /// <summary>
/// 医院信息 /// 医院信息
/// </summary> /// </summary>
[Table("sys_hospital")] [Table("sys_hospital")]
public class sys_hospital public class sys_hospital
{ {
/// <summary> /// <summary>
/// ID /// ID
/// </summary> /// </summary>
[Key] [Key]
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Nullable<DateTime> CreateDate { get; set; } public Nullable<DateTime> CreateDate { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Nullable<int> CreateUser { get; set; } public Nullable<int> CreateUser { get; set; }
/// <summary> /// <summary>
/// 医院名称 /// 医院名称
/// </summary> /// </summary>
public string HosName { get; set; } public string HosName { get; set; }
/// <summary> /// <summary>
/// 简称 /// 简称
/// </summary> /// </summary>
public string ShortName { get; set; } public string ShortName { get; set; }
/// <summary> /// <summary>
/// 医院区域编码 /// 医院区域编码
/// </summary> /// </summary>
public string AreaCode { get; set; } public string AreaCode { get; set; }
/// <summary> /// <summary>
/// 医院等级 /// 医院等级
/// </summary> /// </summary>
public string HosLevel { get; set; } public string HosLevel { get; set; }
/// <summary> /// <summary>
/// 医院类型 /// 医院类型
/// </summary> /// </summary>
public string HosType { get; set; } public string HosType { get; set; }
/// <summary> /// <summary>
/// 医院状态 1 启用 2 禁用 /// 医院状态 1 启用 2 禁用
/// </summary> /// </summary>
public Nullable<int> States { get; set; } public Nullable<int> States { get; set; }
/// <summary> ///// <summary>
/// 是否开启年资系数 1 启用 2 禁用 ///// 是否开启年资系数 1 启用 2 禁用
/// </summary> ///// </summary>
public Nullable<int> IsOpenWorkYear { get; set; } //public Nullable<int> IsOpenWorkYear { get; set; }
/// <summary> ///// <summary>
/// 是否开启药占比系数 1 启用 2 禁用 ///// 是否开启药占比系数 1 启用 2 禁用
/// </summary> ///// </summary>
public Nullable<int> IsOpenDrugprop { get; set; } //public Nullable<int> IsOpenDrugprop { get; set; }
/// <summary> ///// <summary>
/// 是否开启ICU有效收入系数 1 启用 2 禁用 ///// 是否开启ICU有效收入系数 1 启用 2 禁用
/// </summary> ///// </summary>
public Nullable<int> IsOpenIncome { get; set; } //public Nullable<int> IsOpenIncome { get; set; }
/// <summary> ///// <summary>
/// 是否开启规模/效率绩效 1 启用 2 禁用 ///// 是否开启规模/效率绩效 1 启用 2 禁用
/// </summary> ///// </summary>
public Nullable<int> IsOpenDirector { get; set; } //public Nullable<int> IsOpenDirector { get; set; }
/// <summary> /// <summary>
/// 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效 /// 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
/// </summary> /// </summary>
public Nullable<int> IsShowManage { get; set; } public Nullable<int> IsShowManage { get; set; }
/// <summary> ///// <summary>
/// 是否开启科室CMI占比 1 启用 2 禁用 ///// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary> ///// </summary>
public Nullable<int> IsOpenCMIPercent { get; set; } //public Nullable<int> IsOpenCMIPercent { get; set; }
/// <summary> /// <summary>
/// 是否开启护理部审核 1 启用 2 禁用 /// 是否开启护理部审核 1 启用 2 禁用
/// </summary> /// </summary>
public Nullable<int> IsOpenNursingDeptAudit { get; set; } public Nullable<int> IsOpenNursingDeptAudit { get; set; }
/// <summary> /// <summary>
/// 是否显示二次绩效科主任1 启用 2 禁用 /// 是否显示二次绩效科主任1 启用 2 禁用
/// </summary> /// </summary>
public Nullable<int> IsShowSecondDirector { get; set; } public Nullable<int> IsShowSecondDirector { get; set; }
///// <summary>
///// 是否开启行政后勤二次绩效分配 1 启用 2 禁用
///// </summary>
//public Nullable<int> IsOpenLogisticsSecondAllot { get; set; }
/// <summary> /// <summary>
/// 是否开启行政后勤二次绩效分配 1 启用 2 禁用 /// 是否开启定时抽取任务 1 是 2 否
/// </summary> /// </summary>
public Nullable<int> IsOpenLogisticsSecondAllot { get; set; } public Nullable<int> IsOpenTimedTasks { get; set; }
/// <summary> /// <summary>
/// 抽取项目是否在同一环境 1 是 2 否 /// 抽取项目是否在同一环境 1 是 2 否
/// </summary> /// </summary>
......
...@@ -49,9 +49,9 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeo ...@@ -49,9 +49,9 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeo
return context.Database.GetDbConnection().Query<T>(sql, param, commandTimeout: commandTimeout); return context.Database.GetDbConnection().Query<T>(sql, param, commandTimeout: commandTimeout);
} }
public int Execute(string sql, object param) public int Execute(string sql, object param, int? commandTimeout = null)
{ {
return context.Database.GetDbConnection().Execute(sql, param); return context.Database.GetDbConnection().Execute(sql, param, commandTimeout: commandTimeout);
} }
public bool Add(TEntity entity) public bool Add(TEntity entity)
...@@ -111,6 +111,23 @@ public bool UpdateRange(params TEntity[] entities) ...@@ -111,6 +111,23 @@ public bool UpdateRange(params TEntity[] entities)
return context.SaveChanges() > 0; return context.SaveChanges() > 0;
} }
public bool UpdateByState(TEntity entity)
{
var entry = context.Entry(entity);
entry.State = EntityState.Modified;
return context.SaveChanges() > 0;
}
public bool UpdateRangeByState(IEnumerable<TEntity> entities)
{
foreach (var entity in entities)
{
var entry = context.Entry(entity);
entry.State = EntityState.Modified;
}
return context.SaveChanges() > 0;
}
public bool Update(TEntity entity, Action<TEntity> action) public bool Update(TEntity entity, Action<TEntity> action)
{ {
action?.Invoke(entity); action?.Invoke(entity);
......
...@@ -173,22 +173,25 @@ public void ImportWorkloadData(per_allot allot, object parameters) ...@@ -173,22 +173,25 @@ public void ImportWorkloadData(per_allot allot, object parameters)
/// 查询工作量数据 /// 查询工作量数据
/// </summary> /// </summary>
/// <param name="allotid"></param> /// <param name="allotid"></param>
public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string unittype, int hospitalid) public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string[] unittypes, int hospitalid)
{ {
using (var connection = context.Database.GetDbConnection()) using (var connection = context.Database.GetDbConnection())
{ {
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try try
{ {
string unittype = unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("医生"))
? "医生组"
: unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("护理")) ? "护理组" : "其他组";
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1 string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype = @unittype AND t3.unittype in @unittypes
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND t1.Source LIKE CONCAT('%',@unittype,'工作量%') AND t1.Source LIKE CONCAT('%',@unittype,'工作量%')
AND T1.IsDelete = 0 AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;"; ORDER BY t1.doctorname,t1.Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60); return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes, unittype, hospitalid }, commandTimeout: 60 * 60);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -201,7 +204,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -201,7 +204,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
/// 查询门诊收入数据 /// 查询门诊收入数据
/// </summary> /// </summary>
/// <param name="allotid"></param> /// <param name="allotid"></param>
public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string accountingunit, string unittype, int hospitalid) public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string accountingunit, string[] unittype, int hospitalid)
{ {
using (var connection = context.Database.GetDbConnection()) using (var connection = context.Database.GetDbConnection())
{ {
...@@ -211,9 +214,9 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string ...@@ -211,9 +214,9 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string
string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1 string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype = @unittype AND t3.unittype in @unittype
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND t1.Source like '%{source}开单%' AND (t1.Source like '%{source}开单%' OR t1.Source like '%{source}就诊%')
AND T1.IsDelete = 0 AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;"; ORDER BY t1.doctorname,t1.Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60); return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
......
...@@ -59,33 +59,33 @@ public List<PerReport> InpatFeeAvg(int hospitalId, List<string> date) ...@@ -59,33 +59,33 @@ public List<PerReport> InpatFeeAvg(int hospitalId, List<string> date)
return DapperQuery(sql, new { date, hospitalId }).ToList(); return DapperQuery(sql, new { date, hospitalId }).ToList();
} }
/// <summary> // /// <summary>
/// 科室药占比 // /// 科室药占比
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
public List<PerReport> Medicine(int hospitalId, List<string> date) // public List<PerReport> Medicine(int hospitalId, List<string> date)
{ // {
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(cd.id is null,0,cellvalue)) / sum(cellvalue))*100,2) value // string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(cd.id is null,0,cellvalue)) / sum(cellvalue))*100,2) value
from per_allot aot join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id // from per_allot aot join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id
left join cof_drugtype cd on cd.allotid=dt.allotid and cd.charge=dt.TypeName and cd.chargetype in ('药费') where unittype=1 and sheettype=3 //left join cof_drugtype cd on cd.allotid=dt.allotid and cd.charge=dt.TypeName and cd.chargetype in ('药费') where unittype=1 and sheettype=3
and sheetname like '%开单收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0')) // and sheetname like '%开单收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;"; // in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { hospitalId, date }).ToList(); // return DapperQuery(sql, new { hospitalId, date }).ToList();
} // }
/// <summary> // /// <summary>
/// 科室有效收入占比 // /// 科室有效收入占比
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
public List<PerReport> Income(int hospitalId, List<string> date) // public List<PerReport> Income(int hospitalId, List<string> date)
{ // {
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(cd.id is null,cellvalue,0)) / sum(cellvalue))*100,2) value // string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(cd.id is null,cellvalue,0)) / sum(cellvalue))*100,2) value
from per_allot aot join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id // from per_allot aot join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id
left join cof_drugtype cd on cd.allotid=dt.allotid and cd.charge=dt.TypeName and cd.chargetype in ('药费','材料费') //left join cof_drugtype cd on cd.allotid=dt.allotid and cd.charge=dt.TypeName and cd.chargetype in ('药费','材料费')
where unittype=1 and sheettype=3 and sheetname like '%开单收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0')) //where unittype=1 and sheettype=3 and sheetname like '%开单收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;"; // in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { hospitalId, date }).ToList(); // return DapperQuery(sql, new { hospitalId, date }).ToList();
} // }
#region 首页报表 #region 首页报表
/// <summary> /// <summary>
......
//-----------------------------------------------------------------------
// <copyright file=" ag_bodysource.cs">
// * FileName: ag_bodysource.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// ag_bodysource Repository
/// </summary>
public partial class PerforAgbodysourceRepository : PerforRepository<ag_bodysource>
{
public PerforAgbodysourceRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_headsource.cs">
// * FileName: ag_headsource.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// ag_headsource Repository
/// </summary>
public partial class PerforAgheadsourceRepository : PerforRepository<ag_headsource>
{
public PerforAgheadsourceRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_workload_source.cs">
// * FileName: ag_workload_source.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// ag_workload_source Repository
/// </summary>
public partial class PerforAgworkloadsourceRepository : PerforRepository<ag_workload_source>
{
public PerforAgworkloadsourceRepository(PerformanceDbContext context) : base(context)
{
}
}
}
//-----------------------------------------------------------------------
// <copyright file=" ag_worktype_source.cs">
// * FileName: ag_worktype_source.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// ag_worktype_source Repository
/// </summary>
public partial class PerforAgworktypesourceRepository : PerforRepository<ag_worktype_source>
{
public PerforAgworktypesourceRepository(PerformanceDbContext context) : base(context)
{
}
}
}
...@@ -268,7 +268,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot ...@@ -268,7 +268,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
var economicData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeEconomic)?.PerData?.Select(t => (PerData)t); var economicData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeEconomic)?.PerData?.Select(t => (PerData)t);
var doctorWorkloadData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeDoctorWorkload)?.PerData?.Select(t => (PerData)t); var doctorWorkloadData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeDoctorWorkload)?.PerData?.Select(t => (PerData)t);
var nurseWorkloadData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeNurseWorkload)?.PerData?.Select(t => (PerData)t); var nurseWorkloadData = perSheet.FirstOrDefault(t => t.SheetType == SheetType.ComputeNurseWorkload)?.PerData?.Select(t => (PerData)t);
var accountExtraData = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountExtra)?.PerData?.Select(t => (PerData)t); var adjustLaterOtherFee = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountAdjustLaterOtherFee)?.PerData?.Select(t => (PerData)t);
var pairs = new[] var pairs = new[]
{ {
...@@ -303,7 +303,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot ...@@ -303,7 +303,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
if (UnitType.医技组 == unitType && workDoctor == null) if (UnitType.医技组 == unitType && workDoctor == null)
workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit); workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit);
// 夜班绩效 从医院奖罚的明细项中获取 // 夜班绩效 从医院奖罚的明细项中获取
var nightShift = accountExtraData?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0; var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
dept.NightShiftWorkPerforFee = nightShift; dept.NightShiftWorkPerforFee = nightShift;
//dept.MedicineFactor = workDoctor?.MedicineFactor; //dept.MedicineFactor = workDoctor?.MedicineFactor;
...@@ -349,6 +349,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel) ...@@ -349,6 +349,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
{ {
//取出科室 //取出科室
var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t); var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t);
var adjustLaterOtherFee = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountAdjustLaterOtherFee)?.PerData?.Select(t => (PerData)t);
List<string> involves = new List<string> List<string> involves = new List<string>
{ {
...@@ -383,6 +384,10 @@ public void ComputeOffice(per_allot allot, PerExcel excel) ...@@ -383,6 +384,10 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
if (UnitTypeUtil.IsOffice(resAccount?.UnitType) && dept.NeedSecondAllot == "是") if (UnitTypeUtil.IsOffice(resAccount?.UnitType) && dept.NeedSecondAllot == "是")
{ {
// 夜班绩效 从医院奖罚的明细项中获取
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == resAccount?.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
dept.NightShiftWorkPerforFee = nightShift;
dept.ScoringAverage = resAccount?.ScoringAverage == null ? 0 : resAccount.ScoringAverage; dept.ScoringAverage = resAccount?.ScoringAverage == null ? 0 : resAccount.ScoringAverage;
dept.AdjustFactor = (isBudget ? adjust : resAccount?.AdjustFactor) ?? 1; dept.AdjustFactor = (isBudget ? adjust : resAccount?.AdjustFactor) ?? 1;
dept.Extra = resAccount?.Extra ?? 0; dept.Extra = resAccount?.Extra ?? 0;
...@@ -411,7 +416,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel) ...@@ -411,7 +416,7 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
//dept.MedicineExtra = 0;// (drugExtra ?? 0); //dept.MedicineExtra = 0;// (drugExtra ?? 0);
//dept.MaterialsExtra = 0;//(materialsExtra ?? 0); //dept.MaterialsExtra = 0;//(materialsExtra ?? 0);
dept.PerforFee = empolyees.Sum(w => w.PerforTotal ?? 0); dept.PerforFee = empolyees.Sum(w => w.PerforTotal ?? 0);
dept.PerforTotal = Math.Round(empolyees.Sum(w => w.GiveFee ?? 0)); dept.PerforTotal = Math.Round(empolyees.Sum(w => w.GiveFee ?? 0));
dept.AssessLaterPerforTotal = Math.Round((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.Extra) ?? 0); dept.AssessLaterPerforTotal = Math.Round((dept.PerforTotal * dept.ScoringAverage + dept.MedicineExtra + dept.MaterialsExtra + dept.Extra) ?? 0);
...@@ -640,10 +645,11 @@ public IEnumerable<AccountUnitTotal> GetAccountScoreAverage(PerExcel excel, Shee ...@@ -640,10 +645,11 @@ public IEnumerable<AccountUnitTotal> GetAccountScoreAverage(PerExcel excel, Shee
/// 获取药占比分割比例 /// 获取药占比分割比例
/// </summary> /// </summary>
/// <param name="excel"></param> /// <param name="excel"></param>
/// <param name="sheetType"></param>
/// <returns></returns> /// <returns></returns>
private IEnumerable<CofDrugProp> GetFactors(PerExcel excel, SheetType sheetType) private IEnumerable<CofDrugProp> GetFactors(PerExcel excel, SheetType sheetType)
{ {
var perDatas = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.WorkloadMedicineProp)?.PerData.Select(w => (PerData)w); var perDatas = excel.PerSheet.FirstOrDefault(t => t.SheetType == sheetType)?.PerData.Select(w => (PerData)w);
var factors = perDatas var factors = perDatas
?.Where(w => w.IsTotal == 1) ?.Where(w => w.IsTotal == 1)
.Select(w => new CofDrugProp .Select(w => new CofDrugProp
......
...@@ -140,7 +140,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -140,7 +140,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
//取出科室 //取出科室
var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t); var accountList = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountBasic)?.PerData?.Select(t => (PerDataAccountBaisc)t);
var accountExtraData = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountExtra)?.PerData?.Select(t => (PerData)t); var adjustLaterOtherFee = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.AccountAdjustLaterOtherFee)?.PerData?.Select(t => (PerData)t);
List<res_specialunit> resDataList = new List<res_specialunit>(); List<res_specialunit> resDataList = new List<res_specialunit>();
...@@ -179,7 +179,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -179,7 +179,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
//var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue; //var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
// 夜班绩效 从医院奖罚的明细项中获取 // 夜班绩效 从医院奖罚的明细项中获取
var nightShift = accountExtraData?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0; var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
decimal? headcount = null; decimal? headcount = null;
if (typeList.Any(o => o.Description == item.QuantitativeIndicators)) if (typeList.Any(o => o.Description == item.QuantitativeIndicators))
...@@ -262,6 +262,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -262,6 +262,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
//OtherPerfor = empolyee.OtherPerfor, //OtherPerfor = empolyee.OtherPerfor,
OtherManagePerfor = empolyee?.OtherManagePerfor ?? 0, OtherManagePerfor = empolyee?.OtherManagePerfor ?? 0,
Number = resAccount.Number, Number = resAccount.Number,
PermanentStaff = empolyee.PermanentStaff,
PerforTotal = resAccount.PerforTotal, PerforTotal = resAccount.PerforTotal,
Adjust = empolyeeAdjust ?? 1m, Adjust = empolyeeAdjust ?? 1m,
Grant = isBudget ? grant : empolyee.Management, Grant = isBudget ? grant : empolyee.Management,
...@@ -522,6 +523,7 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -522,6 +523,7 @@ public void GenerateSecondAllot(per_allot allot)
List<ag_secondallot> tempSecond = new List<ag_secondallot>(); List<ag_secondallot> tempSecond = new List<ag_secondallot>();
List<ag_secondallot> insSecond = new List<ag_secondallot>(); List<ag_secondallot> insSecond = new List<ag_secondallot>();
List<ag_secondallot> updSecond = new List<ag_secondallot>(); List<ag_secondallot> updSecond = new List<ag_secondallot>();
List<ag_secondallot> delSecond = new List<ag_secondallot>();
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政后勤 }; var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政后勤 };
//// 获取医院是否开启后勤二次分配 //// 获取医院是否开启后勤二次分配
...@@ -608,15 +610,42 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -608,15 +610,42 @@ public void GenerateSecondAllot(per_allot allot)
second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交"; second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
} }
second.RealGiveFee = item.RealGiveFee; second.RealGiveFee = item.RealGiveFee;
second.NightShiftWorkPerforFee = item.NightShiftWorkPerforFee;
updSecond.Add(second); updSecond.Add(second);
} }
} }
if (secondList != null && secondList.Any())
{
foreach (var item in secondList)
{
var second = tempSecond?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
if (second == null)
{
delSecond.Add(item);
}
}
}
if (insSecond.Any()) if (insSecond.Any())
perforAgsecondallotRepository.AddRange(insSecond.ToArray()); perforAgsecondallotRepository.AddRange(insSecond.ToArray());
if (updSecond.Any()) if (updSecond.Any())
{
perforAgsecondallotRepository.UpdateRange(updSecond.ToArray()); perforAgsecondallotRepository.UpdateRange(updSecond.ToArray());
foreach (var item in updSecond.Where(w => w.Status == 4))
{
// 自动驳回,需要清空该科室历史数据
var histories = perforAgcomputeRepository.GetEntities(w => w.SecondId == item.Id);
if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray());
}
}
if (delSecond.Any())
{
perforAgsecondallotRepository.RemoveRange(delSecond.ToArray());
}
} }
} }
} }
...@@ -303,7 +303,7 @@ public per_allot UpdateAllotShowFormula(int allotId) ...@@ -303,7 +303,7 @@ public per_allot UpdateAllotShowFormula(int allotId)
/// </summary> /// </summary>
/// <param name="allot"></param> /// <param name="allot"></param>
/// <param name="user"></param> /// <param name="user"></param>
public void Generate(per_allot allot, string mail) public void Generate(per_allot allot)
{ {
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
try try
...@@ -441,7 +441,7 @@ public void Generate(per_allot allot, string mail) ...@@ -441,7 +441,7 @@ public void Generate(per_allot allot, string mail)
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate); UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID); perforCofdirectorRepository.SupplementaryData(allot.ID);
logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
//var res = reportService.ImportData(allot); //var res = reportService.ImportData(allot);
//var flag = reportService.UpdateData(allot); //var flag = reportService.UpdateData(allot);
//logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true);
...@@ -465,6 +465,15 @@ public void Generate(per_allot allot, string mail) ...@@ -465,6 +465,15 @@ public void Generate(per_allot allot, string mail)
} }
/// <summary> /// <summary>
/// 绩效生成报表
/// </summary>
/// <param name="allot"></param>
public void GenerateReport(per_allot allot)
{
reportService.ExecProc("call proc_report_performance(@hospitalid, @year, @month);", new { allot.HospitalId, allot.Year, allot.Month });
}
/// <summary>
/// 重新计算院领导绩效 /// 重新计算院领导绩效
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
......
...@@ -386,7 +386,7 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName) ...@@ -386,7 +386,7 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName)
if (sTypes.Contains((int)sheet.SheetType) || sTypeName.Contains(sheet.SheetName)) if (sTypes.Contains((int)sheet.SheetType) || sTypeName.Contains(sheet.SheetName))
{ {
List<HandsonCellData> cells = new List<HandsonCellData>(); List<HandsonCellData> cells = new List<HandsonCellData>();
var perSheet = perforPersheetRepository.GetEntity(t=>t.AllotID==allotId && t.SheetName=="4.1 临床科室医护绩效测算表"); var perSheet = perforPersheetRepository.GetEntity(t => t.AllotID == allotId && t.SheetName == "4.1 临床科室医护绩效测算表");
var dept = perforPerdeptdicRepository.GetAccountBasicAccountingUnit(allot.HospitalId); var dept = perforPerdeptdicRepository.GetAccountBasicAccountingUnit(allot.HospitalId);
GetAccountBasic(perSheet, dept, cells); GetAccountBasic(perSheet, dept, cells);
UnitFit(rowDatas, cells, sheet); UnitFit(rowDatas, cells, sheet);
...@@ -751,10 +751,6 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa ...@@ -751,10 +751,6 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa
bool exists = false; bool exists = false;
bool exists2 = false; bool exists2 = false;
var cells = new List<HandsonCellData>(); var cells = new List<HandsonCellData>();
if (cell.Name == "总务科")
{
var ss = 1;
}
foreach (var rowData in rowDatas) foreach (var rowData in rowDatas)
{ {
foreach (var cellData in rowData.CellData) foreach (var cellData in rowData.CellData)
...@@ -787,7 +783,7 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa ...@@ -787,7 +783,7 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa
if (exists == false || (exists == false && exists2 == false) || exists2 == false) if (exists == false || (exists == false && exists2 == false) || exists2 == false)
{ {
cells.Add(new HandsonCellData("核算单元", cell.Name)); cells.Add(new HandsonCellData("核算单元", cell.Name));
if (sheet.SheetName == "5.2业务中层行政中高层医院奖罚") if (sheet.SheetName == "5.2业务中层行政中高层医院奖罚")
{ {
...@@ -801,7 +797,7 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa ...@@ -801,7 +797,7 @@ private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDa
{ {
cells.Add(new HandsonCellData("核算单元类型", cell.Value)); cells.Add(new HandsonCellData("核算单元类型", cell.Value));
} }
suppRowDatas.Add(new HandsonRowData(++rowCount, cells)); suppRowDatas.Add(new HandsonRowData(++rowCount, cells));
} }
} }
......
...@@ -324,7 +324,7 @@ public class ConfigService : IAutoInjection ...@@ -324,7 +324,7 @@ public class ConfigService : IAutoInjection
/// <returns></returns> /// <returns></returns>
public List<cof_drugtype> GetDrugtypeList(int HospitalId, int allotId) public List<cof_drugtype> GetDrugtypeList(int HospitalId, int allotId)
{ {
var list = _drugtypeRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId==HospitalId); var list = _drugtypeRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId == HospitalId);
return list; return list;
} }
...@@ -705,9 +705,9 @@ public void Copy(per_allot allot) ...@@ -705,9 +705,9 @@ public void Copy(per_allot allot)
logger.LogInformation($"workItem"); logger.LogInformation($"workItem");
var workItem = _workitemRepository.GetEntities(t => t.AllotID == allot.ID); var workItem = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (hospital != null && hospital?.IsOpenDrugprop == 1 && (workItem == null || workItem.Count == 0)) if (workItem == null || workItem.Count == 0)
{ {
workItem = _workitemRepository.GetEntities(t => t.AllotID == allotId); workItem = _workitemRepository.GetEntities(t => t.AllotID == allotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItem != null && workItem.Count > 0) if (workItem != null && workItem.Count > 0)
{ {
var newWorkItem = workItem.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item }); var newWorkItem = workItem.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
...@@ -720,7 +720,7 @@ public void Copy(per_allot allot) ...@@ -720,7 +720,7 @@ public void Copy(per_allot allot)
if (cofDrugtype == null || cofDrugtype.Count == 0) if (cofDrugtype == null || cofDrugtype.Count == 0)
{ {
var drugtype = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1); var drugtype = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = drugtype.Select(t => new cof_drugtype {HospitalId=allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType }); var newAgains = drugtype.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newAgains.ToArray()); _drugtypeRepository.AddRange(newAgains.ToArray());
} }
...@@ -845,8 +845,8 @@ private void CopyAprData(int prevAllotId, int allotId) ...@@ -845,8 +845,8 @@ private void CopyAprData(int prevAllotId, int allotId)
#region HRP人员科室 #region HRP人员科室
public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId) public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
{ {
var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission
{ {
...@@ -921,13 +921,13 @@ public HandsonTable GetSecondaryAlias() ...@@ -921,13 +921,13 @@ public HandsonTable GetSecondaryAlias()
if (column.Data == "状态") if (column.Data == "状态")
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
column.Source = new[] {"可用", "禁用"}; column.Source = new[] { "可用", "禁用" };
column.Strict = true; column.Strict = true;
} }
} }
} }
var data = perforCofaliasRepository.GetEntities()?.OrderBy(t=>t.Route); var data = perforCofaliasRepository.GetEntities()?.OrderBy(t => t.Route);
if (data==null) return result; if (data == null) return result;
List<HandsonRowData> rowDatas = new List<HandsonRowData>(); List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 0; int i = 0;
...@@ -935,13 +935,13 @@ public HandsonTable GetSecondaryAlias() ...@@ -935,13 +935,13 @@ public HandsonTable GetSecondaryAlias()
{ {
var json = JsonHelper.Serialize(item); var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json); var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
firstDic["states"]=firstDic["states"] == "1" ? "可用" : "禁用"; firstDic["states"] = firstDic["states"] == "1" ? "可用" : "禁用";
var cells = (from conf in Alias join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList(); var cells = (from conf in Alias join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
rowDatas.Add(new HandsonRowData(i,cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas,rowDatas!=null); result.SetRowData(rowDatas, rowDatas != null);
return result; return result;
} }
...@@ -952,22 +952,22 @@ public void SaveSecondaryAlias(SaveCollectData request) ...@@ -952,22 +952,22 @@ public void SaveSecondaryAlias(SaveCollectData request)
List<cof_alias> aliases = new List<cof_alias>(); List<cof_alias> aliases = new List<cof_alias>();
foreach (var item in dicData) foreach (var item in dicData)
{ {
var states = new[] {"可用", "禁用"}; var states = new[] { "可用", "禁用" };
if (item["States"]!=null && states.Contains(item["States"])) if (item["States"] != null && states.Contains(item["States"]))
{ {
item["States"] = item["States"] == "可用" ? "1" : "0"; item["States"] = item["States"] == "可用" ? "1" : "0";
} }
else continue; else continue;
var json = JsonHelper.Serialize(item); var json = JsonHelper.Serialize(item);
var data = JsonHelper.Deserialize<cof_alias>(json); var data = JsonHelper.Deserialize<cof_alias>(json);
if (!string.IsNullOrEmpty(data.Name) && !string.IsNullOrEmpty(data.OriginalName)&& !string.IsNullOrEmpty(data.Route) && !string.IsNullOrEmpty(data.Alias)) if (!string.IsNullOrEmpty(data.Name) && !string.IsNullOrEmpty(data.OriginalName) && !string.IsNullOrEmpty(data.Route) && !string.IsNullOrEmpty(data.Alias))
{ {
aliases.Add(data); aliases.Add(data);
} }
} }
perforCofaliasRepository.Execute("delete from cof_alias",null); perforCofaliasRepository.Execute("delete from cof_alias", null);
perforCofaliasRepository.AddRange(aliases.ToArray()); perforCofaliasRepository.AddRange(aliases.ToArray());
} }
...@@ -1015,7 +1015,7 @@ public void SaveSecondaryAlias(SaveCollectData request) ...@@ -1015,7 +1015,7 @@ public void SaveSecondaryAlias(SaveCollectData request)
return result; return result;
} }
///// <summary> ///// <summary>
///// CMI值 ///// CMI值
///// </summary> ///// </summary>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -72,6 +72,7 @@ public List<ex_module> QueryModule(int hospitalId) ...@@ -72,6 +72,7 @@ public List<ex_module> QueryModule(int hospitalId)
DefaultModules(hospitalId); DefaultModules(hospitalId);
var list = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId).OrderBy(t => t.ModuleName).ToList(); var list = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId).OrderBy(t => t.ModuleName).ToList();
list?.ForEach(t => t.ReadOnly = t.SheetType == (int)SheetType.Income ? 0 : 1);
return list; return list;
} }
...@@ -90,7 +91,7 @@ private void DefaultModules(int hospitalId) ...@@ -90,7 +91,7 @@ private void DefaultModules(int hospitalId)
}; };
var data = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId); var data = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId);
var inexistence = data == null ? moduleList : moduleList.Where(t => !data.Select(p => p.ModuleName).ToArray().Contains(t.ModuleName)); var inexistence = data == null ? moduleList : moduleList.Where(t => !data.Any(w => w.ModuleName.StartsWith(t.ModuleName.Split(' ')[0])));
if (inexistence != null && inexistence.Any()) if (inexistence != null && inexistence.Any())
{ {
...@@ -102,7 +103,7 @@ private void DefaultModules(int hospitalId) ...@@ -102,7 +103,7 @@ private void DefaultModules(int hospitalId)
HospitalId = hospitalId, HospitalId = hospitalId,
ModuleName = item.ModuleName, ModuleName = item.ModuleName,
SheetType = (int)item.SheetType, SheetType = (int)item.SheetType,
ReadOnly = 1, ReadOnly = item.SheetType == (int)SheetType.Income ? 0 : 1,
TypeId = null, TypeId = null,
}; };
modules.Add(module); modules.Add(module);
...@@ -120,8 +121,7 @@ public ex_module AddModule(ModModuleRequest request) ...@@ -120,8 +121,7 @@ public ex_module AddModule(ModModuleRequest request)
string addname = ""; string addname = "";
if (request.SheetType == (int)SheetType.Income) if (request.SheetType == (int)SheetType.Income)
{ {
string[] array = new string[] { "开单收入", "执行收入" }; if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("就诊收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
throw new PerformanceException("模块名称规则错误"); throw new PerformanceException("模块名称规则错误");
//if (!Regex.IsMatch(request.ModuleName, @"^[\u4e00-\u9fa5]+$")) //if (!Regex.IsMatch(request.ModuleName, @"^[\u4e00-\u9fa5]+$"))
// throw new PerformanceException("模块名称规则错误,请使用全中文命名"); // throw new PerformanceException("模块名称规则错误,请使用全中文命名");
...@@ -132,7 +132,7 @@ public ex_module AddModule(ModModuleRequest request) ...@@ -132,7 +132,7 @@ public ex_module AddModule(ModModuleRequest request)
throw new PerformanceException("绩效模板已存在!"); throw new PerformanceException("绩效模板已存在!");
var moduleList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.ModuleName.IndexOf("1.") != -1); var moduleList = exmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.ModuleName.IndexOf("1.") != -1);
string name = request.ModuleName.Replace("开单收入", "").Replace("执行收入", ""); string name = request.ModuleName.Replace("开单收入", "").Replace("就诊收入", "").Replace("执行收入", "");
var exist = moduleList.Where(t => t.ModuleName.Contains(name)); var exist = moduleList.Where(t => t.ModuleName.Contains(name));
if (exist != null && exist.Any()) if (exist != null && exist.Any())
{ {
......
...@@ -57,7 +57,7 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo ...@@ -57,7 +57,7 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank()); var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank());
if (sheet == null) if (sheet == null)
{ {
string[] keyArray = new string[] { "开单", "执行" }; string[] keyArray = new string[] { "开单", "就诊", "执行" };
if (keyArray.Any(key => module.ModuleName.Contains(key))) if (keyArray.Any(key => module.ModuleName.Contains(key)))
{ {
var item = pairs.Where(t => t.Key.StartsWith("1.")).OrderByDescending(t => t.Key).First(); var item = pairs.Where(t => t.Key.StartsWith("1.")).OrderByDescending(t => t.Key).First();
...@@ -154,7 +154,7 @@ public static void ClearSheetTemplate(ISheet sheet, PerSheetPoint point, SheetTy ...@@ -154,7 +154,7 @@ public static void ClearSheetTemplate(ISheet sheet, PerSheetPoint point, SheetTy
sheet.ShiftRows(point.DataFirstRowNum.Value, sheet.LastRowNum + 1, -1); sheet.ShiftRows(point.DataFirstRowNum.Value, sheet.LastRowNum + 1, -1);
} }
} }
public static void CloseAutoFilter(string path) public static void CloseAutoFilter(string path)
{ {
try try
...@@ -175,7 +175,7 @@ public static void CloseAutoFilter(string path) ...@@ -175,7 +175,7 @@ public static void CloseAutoFilter(string path)
package.Save(); package.Save();
} }
} }
catch (Exception ex) catch (Exception)
{ {
} }
} }
......
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Services.ExtractExcelService
{
public class ExtractJobService : IAutoInjection
{
private readonly ILogger logger;
private readonly AllotService allotService;
private readonly ConfigService configService;
private readonly DictionaryService dictionaryService;
private readonly QueryService queryService;
private readonly PerforUserRepository userRepository;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerallotRepository perallotRepository;
public ExtractJobService(
ILogger<ExtractJobService> logger,
AllotService allotService,
ConfigService configService,
DictionaryService dictionaryService,
QueryService queryService,
PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository
)
{
this.logger = logger;
this.allotService = allotService;
this.configService = configService;
this.dictionaryService = dictionaryService;
this.queryService = queryService;
this.userRepository = userRepository;
this.hospitalRepository = hospitalRepository;
this.perallotRepository = perallotRepository;
}
public void Execute()
{
var hospitals = hospitalRepository.GetEntities(w => w.IsOpenTimedTasks == 1);
if (hospitals == null || !hospitals.Any()) return;
var userId = userRepository.GetEntity(t => t.Login.ToLower() == "admin" && t.States == 1 && t.IsDelete == 1)?.ID ?? 1;
var date = DateTime.Now;
var allots = perallotRepository.GetEntities(t => hospitals.Select(w => w.ID).Contains(t.HospitalId) && t.Year == date.Year && t.Month == date.Month);
foreach (var hospital in hospitals)
{
try
{
var allot = allots?.FirstOrDefault(t => t.HospitalId == hospital.ID);
if (allot == null)
{
allot = allotService.InsertAllot(new AllotRequest
{
HospitalId = hospital.ID,
Year = date.Year,
Month = date.Month
}, userId);
configService.Copy(allot);
}
if (allot == null || allot.ID == 0) continue;
var dict = new Dictionary<ExDataDict, object>();
var isSingle = hospital.IsSingleProject == 1;
dictionaryService.Handler(hospital.ID, allot, "", isSingle);
var data = queryService.Handler(hospital.ID, allot, "", isSingle, ref dict);
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
}
}
}
}
}
...@@ -139,7 +139,7 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD ...@@ -139,7 +139,7 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
logger.LogInformation($"allotId: {allot.ID}: 总金额 - {extractDto?.Sum(s => s.Value ?? 0)}"); logger.LogInformation($"allotId: {allot.ID}: 总金额 - {extractDto?.Sum(s => s.Value ?? 0)}");
WriteDataFactory factory = new WriteDataFactory(); WriteDataFactory factory = new WriteDataFactory();
var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload, SheetType.AccountBasic }; var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload/*, SheetType.AccountBasic*/ };
decimal ratio = 60m; decimal ratio = 60m;
for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++) for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++)
{ {
...@@ -209,14 +209,12 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re ...@@ -209,14 +209,12 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re
var dict = personService.GetDepartments(hospitalId)?.ToList(); var dict = personService.GetDepartments(hospitalId)?.ToList();
if (dict == null || !dict.Any()) if (dict == null || !dict.Any())
return results.Select(t => new ExtractTransDto return results.GroupBy(t => new { t.Department, t.Category, t.Source }).Select(t => new ExtractTransDto
{ {
SheetName = t.Source, SheetName = t.Key.Source,
DoctorName = t.DoctorName, Department = t.Key.Department,
PersonnelNumber = t.PersonnelNumber, Category = t.Key.Category,
Department = t.Department, Value = t.Sum(group => group.Fee) == 0 ? null : t.Sum(group => group.Fee),
Category = t.Category,
Value = t.Fee ?? 0
}).ToList(); }).ToList();
dict.ForEach(t => dict.ForEach(t =>
......
...@@ -131,9 +131,9 @@ public HospitalResponse Update(HospitalRequest request) ...@@ -131,9 +131,9 @@ public HospitalResponse Update(HospitalRequest request)
hospital.States = request.States; hospital.States = request.States;
//hospital.IsOpenWorkYear = request.IsOpenWorkYear; //hospital.IsOpenWorkYear = request.IsOpenWorkYear;
//hospital.IsOpenDirector = request.IsOpenDirector; //hospital.IsOpenDirector = request.IsOpenDirector;
hospital.IsOpenDrugprop = request.IsOpenDrugprop; //hospital.IsOpenDrugprop = request.IsOpenDrugprop;
hospital.IsShowManage = request.IsShowManage; hospital.IsShowManage = request.IsShowManage;
hospital.IsOpenCMIPercent = request.IsOpenCMIPercent; //hospital.IsOpenCMIPercent = request.IsOpenCMIPercent;
//hospital.IsOpenLogisticsSecondAllot = request.IsOpenLogisticsSecondAllot; //hospital.IsOpenLogisticsSecondAllot = request.IsOpenLogisticsSecondAllot;
//hospital.IsOpenIncome = request.IsOpenIncome; //hospital.IsOpenIncome = request.IsOpenIncome;
......
...@@ -71,7 +71,7 @@ public static string GetValue(this ICell cell) ...@@ -71,7 +71,7 @@ public static string GetValue(this ICell cell)
case CellType.Numeric: case CellType.Numeric:
return cell?.NumericCellValue.ToString(); return cell?.NumericCellValue.ToString();
case CellType.String: case CellType.String:
return cell?.StringCellValue.ToString(); return cell?.StringCellValue?.ToString() ?? "";
case CellType.Formula: case CellType.Formula:
cell?.SetCellType(CellType.String); cell?.SetCellType(CellType.String);
return cell?.StringCellValue?.ToString(); return cell?.StringCellValue?.ToString();
......
...@@ -39,14 +39,15 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -39,14 +39,15 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
var unit = Point.AccountingUnit.First(); var unit = Point.AccountingUnit.First();
//查询除了 核算单元 科室名称 有效数据列头位置 //查询除了 核算单元 科室名称 有效数据列头位置
var vhead = perHeader.Where(t => t.PointCell != unit.UnitTypeNum && t.PointCell != unit.AccountingUnitCellNum && t.PointCell != unit.DeptCellNum).OrderBy(t => t.PointCell); var vhead = perHeader.Where(t => t.PointCell != unit.UnitTypeNum && t.PointCell != unit.AccountingUnitCellNum && t.PointCell != unit.JobCellNum && t.PointCell != unit.EmpNameCellNum).OrderBy(t => t.PointCell);
//var vhead = perHeader.OrderBy(t => t.PointCell);
for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++) for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
{ {
var row = sheet.GetRow(r); var row = sheet.GetRow(r);
if (row == null) continue; if (row == null) continue;
for (int c = Point.DataFirstCellNum.Value; c < vhead.Count(); c++) for (int c = 0; c < vhead.Count(); c++)
{ {
var athead = vhead.ElementAt(c); var athead = vhead.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
......
...@@ -509,15 +509,14 @@ public List<TitleValue> DeptDics(int hospitalId, int type) ...@@ -509,15 +509,14 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns> /// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId) public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{ {
var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId); string[] unitTypes = GetUnitType(userId);
if (second == null) if (unitTypes == null || !unitTypes.Any()) return new string[] { };
return null;
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null) if (allot == null)
return null; return null;
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, second.UnitType, allot.HospitalId); var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, unitTypes, allot.HospitalId);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
...@@ -541,9 +540,8 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId) ...@@ -541,9 +540,8 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// <returns></returns> /// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId) public object DeptIncomeDetail(WorkDetailRequest request, int userId)
{ {
var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId); string[] unitTypes = GetUnitType(userId);
if (second == null) if (unitTypes == null || !unitTypes.Any()) return new string[] { };
return null;
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null) if (allot == null)
...@@ -552,7 +550,7 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId) ...@@ -552,7 +550,7 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
if (!sources.Contains(request.Source)) if (!sources.Contains(request.Source))
throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}"); throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}");
var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, request.AccountingUnit, second.UnitType, allot.HospitalId); var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, request.AccountingUnit, unitTypes, allot.HospitalId);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
...@@ -568,5 +566,27 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId) ...@@ -568,5 +566,27 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
return new string[] { }; return new string[] { };
} }
private string[] GetUnitType(int userId)
{
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{
{ application.DirectorRole, new string []{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.医技组.ToString() } },
{ application.NurseRole, new string []{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString() } },
{ application.SpecialRole, new string []{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string []{ UnitType.行政后勤.ToString() } },
};
var user = perforUserRepository.GetEntity(t => t.ID == userId);
if (user == null)
throw new NotImplementedException("人员ID无效");
var userrole = perforUserroleRepository.GetEntity(t => t.UserID == userId);
var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (!role.Type.HasValue || !dict.ContainsKey(role.Type.Value))
return new string[] { };
return dict[role.Type.Value];
}
} }
} }
...@@ -182,53 +182,53 @@ public List<PerReport> InpatFeeAvg(int hospitalId) ...@@ -182,53 +182,53 @@ public List<PerReport> InpatFeeAvg(int hospitalId)
return perforReportRepository.InpatFeeAvg(hospitalId, date); return perforReportRepository.InpatFeeAvg(hospitalId, date);
} }
/// <summary> ///// <summary>
/// 科室药占比 ///// 科室药占比
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
public List<PerReport> Medicine(int hospitalId, int isIndex) //public List<PerReport> Medicine(int hospitalId, int isIndex)
{ //{
var states = new List<int>() { 6, 8 }; // var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId && states.Contains(t.States)); // var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId && states.Contains(t.States));
if (allotList == null || !allotList.Any()) // if (allotList == null || !allotList.Any())
throw new PerformanceException("用户未创建绩效!"); // throw new PerformanceException("用户未创建绩效!");
var date = new List<string>(); // var date = new List<string>();
if (isIndex == 1) // if (isIndex == 1)
{ // {
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault(); // var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault();
date.Add(allot.Year + "-" + allot.Month.ToString().PadLeft(2, '0')); // date.Add(allot.Year + "-" + allot.Month.ToString().PadLeft(2, '0'));
} // }
else // else
{ // {
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); // date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
} // }
return perforReportRepository.Medicine(hospitalId, date); // return perforReportRepository.Medicine(hospitalId, date);
} //}
/// <summary> ///// <summary>
/// 科室有效收入占比 ///// 科室有效收入占比
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
public List<PerReport> Income(int hospitalId, int isIndex) //public List<PerReport> Income(int hospitalId, int isIndex)
{ //{
var states = new List<int>() { 6, 8 }; // var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId && states.Contains(t.States)); // var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId && states.Contains(t.States));
if (allotList == null || !allotList.Any()) // if (allotList == null || !allotList.Any())
throw new PerformanceException("用户未创建绩效!"); // throw new PerformanceException("用户未创建绩效!");
var date = new List<string>(); // var date = new List<string>();
if (isIndex == 1) // if (isIndex == 1)
{ // {
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault(); // var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault();
date.Add(allot.Year + "-" + allot.Month.ToString().PadLeft(2, '0')); // date.Add(allot.Year + "-" + allot.Month.ToString().PadLeft(2, '0'));
} // }
else // else
{ // {
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); // date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
} // }
return perforReportRepository.Income(hospitalId, date); // return perforReportRepository.Income(hospitalId, date);
} //}
/// <summary> /// <summary>
/// 只支持EXCEL抽取报表数据 /// 只支持EXCEL抽取报表数据
...@@ -395,7 +395,7 @@ public void ExecProc(string execsql, object param) ...@@ -395,7 +395,7 @@ public void ExecProc(string execsql, object param)
{ {
try try
{ {
perforPerallotRepository.Execute(execsql, param); perforPerallotRepository.Execute(execsql, param, 60 * 60);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -60,7 +60,7 @@ public List<RoleResponse> GetUsersRole(int userid) ...@@ -60,7 +60,7 @@ public List<RoleResponse> GetUsersRole(int userid)
List<RoleResponse> roleResponses = new List<RoleResponse>(); List<RoleResponse> roleResponses = new List<RoleResponse>();
var user=_userRepository.GetEntity(c => c.ID == userid); var user=_userRepository.GetEntity(c => c.ID == userid);
var ParentUser = _userRepository.GetEntities(c => c.ParentID == userid); var ParentUser = _userRepository.GetEntities(c => c.ParentID == userid);
if (user.ParentID!=null || user.ParentID==0) if (user.ParentID!=null && user.ParentID!=0)
{ {
ParentUser=_userRepository.GetEntities(c => c.ParentID == user.ParentID); ParentUser=_userRepository.GetEntities(c => c.ParentID == user.ParentID);
} }
......
...@@ -95,9 +95,6 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId, ...@@ -95,9 +95,6 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId,
if (tempId == (int)Temp.other) return new SecondResponse(); if (tempId == (int)Temp.other) return new SecondResponse();
if (isArchive == 1 || new List<int> { (int)SecondAllotStatus.WaitReview, (int)SecondAllotStatus.PassAudit }.Contains(secondAllot.Status ?? (int)SecondAllotStatus.Uncommitted))
employeeSource = (int)EmployeeSource.Initial;
// 历史保存过的数据,groupby取最后的一条记录,避免重复数据,在同一rownumber中itemname重复会导致数据丢失 // 历史保存过的数据,groupby取最后的一条记录,避免重复数据,在同一rownumber中itemname重复会导致数据丢失
var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == secondAllot.Id); var savedDataList = agfixatitemRepository.GetEntities(w => w.SecondId == secondAllot.Id);
if (savedDataList != null && savedDataList.Any()) if (savedDataList != null && savedDataList.Any())
...@@ -108,13 +105,13 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId, ...@@ -108,13 +105,13 @@ public SecondResponse GetSecondDetails(int userId, int secondId, int hospitalId,
var header = GetHeadItems(hospitalId, tempId, secondAllot); var header = GetHeadItems(hospitalId, tempId, secondAllot);
var body = GetBodyItems(userId, employeeSource, secondAllot, prevSecondAllot, header, savedDataList); var body = GetBodyItems(userId, employeeSource, secondAllot, prevSecondAllot, header, savedDataList, isArchive);
var result = new SecondResponse { HeadItems = header, BodyItems = body }; var result = new SecondResponse { HeadItems = header, BodyItems = body };
SupplyHeaderByWorkItem(hospitalId, result, secondAllot, savedDataList); SupplyHeaderByWorkItem(hospitalId, result, secondAllot, savedDataList);
result.HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.WorkType).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(); result.HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList();
result.BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ToList(); result.BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ToList();
return result; return result;
...@@ -135,6 +132,9 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se ...@@ -135,6 +132,9 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se
// 用户自定义的工作量、单项奖励 // 用户自定义的工作量、单项奖励
var configHeaders = agworkloadRepository.GetEntities(w => w.HospitalId == hospitalId && w.Department == secondAllot.Department && w.UnitType == secondAllot.UnitType); var configHeaders = agworkloadRepository.GetEntities(w => w.HospitalId == hospitalId && w.Department == secondAllot.Department && w.UnitType == secondAllot.UnitType);
if (SecondAllotService.defaultValues != null && SecondAllotService.defaultValues.Any())
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>();
...@@ -168,7 +168,7 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se ...@@ -168,7 +168,7 @@ public List<HeadItem> GetHeadItems(int hospitalId, int tempId, ag_secondallot se
/// <param name="prevSecondAllot"></param> /// <param name="prevSecondAllot"></param>
/// <param name="headItems"></param> /// <param name="headItems"></param>
/// <returns></returns> /// <returns></returns>
public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallot secondAllot, ag_secondallot prevSecondAllot, List<HeadItem> headItems, List<ag_fixatitem> savedDataList) public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallot secondAllot, ag_secondallot prevSecondAllot, List<HeadItem> headItems, List<ag_fixatitem> savedDataList, int isArchive)
{ {
var bodyItems = new List<BodyItem>(); var bodyItems = new List<BodyItem>();
...@@ -185,6 +185,9 @@ public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallo ...@@ -185,6 +185,9 @@ public List<BodyItem> GetBodyItems(int userId, int employeeSource, ag_secondallo
} }
} }
if (isArchive == 1 || new List<int> { (int)SecondAllotStatus.WaitReview, (int)SecondAllotStatus.PassAudit }.Contains(secondAllot.Status ?? (int)SecondAllotStatus.Uncommitted))
employeeSource = (int)EmployeeSource.Initial;
var topFixedColumns = headItems.Where(w => w.Type == (int)TempColumnType.TopFixedColumns)?.ToList(); var topFixedColumns = headItems.Where(w => w.Type == (int)TempColumnType.TopFixedColumns)?.ToList();
if (topFixedColumns != null) if (topFixedColumns != null)
{ {
...@@ -258,8 +261,8 @@ public List<BodyItem> GetEmployeeFromSavedData(int userId, ag_secondallot second ...@@ -258,8 +261,8 @@ public List<BodyItem> GetEmployeeFromSavedData(int userId, ag_secondallot second
if (savedData != null) if (savedData != null)
{ {
tableFixedData.Value = savedData.ItemValue; tableFixedData.Value = savedData.ItemValue;
tableFixedData.RowNumber = rowNumber;
} }
tableFixedData.RowNumber = rowNumber;
tableFixedDataList.Add(tableFixedData); tableFixedDataList.Add(tableFixedData);
} }
} }
...@@ -370,8 +373,8 @@ public List<BodyItem> GetEmployeeFromPrevData(int userId, ag_secondallot secondA ...@@ -370,8 +373,8 @@ public List<BodyItem> GetEmployeeFromPrevData(int userId, ag_secondallot secondA
if (savedData != null) if (savedData != null)
{ {
tableFixedData.Value = savedData.ItemValue; tableFixedData.Value = savedData.ItemValue;
tableFixedData.RowNumber = rowNumber;
} }
tableFixedData.RowNumber = rowNumber;
tableFixedDataList.Add(tableFixedData); tableFixedDataList.Add(tableFixedData);
} }
...@@ -410,7 +413,6 @@ private void SupplementFixedData(ag_secondallot secondAllot, List<BodyItem> body ...@@ -410,7 +413,6 @@ private void SupplementFixedData(ag_secondallot secondAllot, List<BodyItem> body
{ {
{ "发放月份", $"{secondAllot.Year}{secondAllot.Month.ToString().PadLeft(2, '0')}月" }, { "发放月份", $"{secondAllot.Year}{secondAllot.Month.ToString().PadLeft(2, '0')}月" },
{ "可分配绩效", secondAllot.RealGiveFee.ToString() }, { "可分配绩效", secondAllot.RealGiveFee.ToString() },
{ "满勤天数", DateTime.DaysInMonth(secondAllot.Year.Value, secondAllot.Month.Value).ToString() },
}; };
var pairs = new Dictionary<string, string> var pairs = new Dictionary<string, string>
...@@ -465,6 +467,10 @@ private void SupplementFixedData(ag_secondallot secondAllot, List<BodyItem> body ...@@ -465,6 +467,10 @@ private void SupplementFixedData(ag_secondallot secondAllot, List<BodyItem> body
if (field != null && !string.IsNullOrEmpty(item.Value)) if (field != null && !string.IsNullOrEmpty(item.Value))
field.Value = item.Value; field.Value = item.Value;
} }
var days = bodyItems.FirstOrDefault(w => w.RowNumber == -1 && w.FiledName == "满勤天数");
if (days != null && string.IsNullOrEmpty(days.Value))
days.Value = DateTime.DaysInMonth(secondAllot.Year.Value, secondAllot.Month.Value).ToString();
} }
/// <summary> /// <summary>
...@@ -598,7 +604,6 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se ...@@ -598,7 +604,6 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
headItem.FiledName += "金额"; headItem.FiledName += "金额";
headItem.FiledId += item.Id; headItem.FiledId += item.Id;
headItem.Sort = maxSortValue + sortindex; headItem.Sort = maxSortValue + sortindex;
headItem.WorkType = item.Id;
headerItems.Add(headItem); headerItems.Add(headItem);
sortindex++; sortindex++;
} }
...@@ -606,19 +611,17 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se ...@@ -606,19 +611,17 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
} }
var defauleHeader = new List<ag_workload_type> var defauleHeader = new List<ag_workload_type>
{ {
new ag_workload_type { Id = 2, TypeName = "工作量绩效占比", }, new ag_workload_type { Id = (int) AgWorkloadType.Workload, TypeName = "工作量绩效占比", },
new ag_workload_type { Id = 2, TypeName = "工作量分配绩效金额" }, new ag_workload_type { Id = (int) AgWorkloadType.Workload, TypeName = "工作量分配绩效金额" },
}; };
foreach (var item in defauleHeader) foreach (var item in defauleHeader)
{ {
result.HeadItems.Where(t => t.FiledName == item.TypeName).ToList()?.ForEach(t => result.HeadItems.Where(t => t.FiledName == item.TypeName).ToList()?.ForEach(t =>
{ {
t.WorkType = item.Id;
t.SpecialAttr = item.TypeName.IndexOf("占比") > -1 ? 1 : 2; t.SpecialAttr = item.TypeName.IndexOf("占比") > -1 ? 1 : 2;
}); });
result.BodyItems.Where(t => t.FiledName == item.TypeName).ToList()?.ForEach(t => result.BodyItems.Where(t => t.FiledName == item.TypeName).ToList()?.ForEach(t =>
{ {
t.WorkType = item.Id;
t.SpecialAttr = item.TypeName.IndexOf("占比") > -1 ? 1 : 2; t.SpecialAttr = item.TypeName.IndexOf("占比") > -1 ? 1 : 2;
}); });
} }
...@@ -740,7 +743,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is ...@@ -740,7 +743,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
var types = new string[] { "行政后勤", "行政工勤" }; var types = new string[] { "行政后勤", "行政工勤" };
var logistics = _imemployeelogisticsRepository.GetEntities(w => w.AllotID == secondAllot.AllotId && types.Contains(w.AccountType) && w.AccountingUnit == secondAllot.Department); var logistics = _imemployeelogisticsRepository.GetEntities(w => w.AllotID == secondAllot.AllotId && types.Contains(w.AccountType) && w.AccountingUnit == secondAllot.Department);
result = (logistics ?? new List<im_employee_logistics>()) result = (logistics ?? new List<im_employee_logistics>())
.OrderBy(t => Convert.ToInt32(t.PersonnelNumber)).Select(w => new ag_othersource .OrderBy(t => ConvertHelper.To<Int64>(t.PersonnelNumber, 0)).Select(w => new ag_othersource
{ {
SecondId = secondId, SecondId = secondId,
WorkNumber = w.PersonnelNumber, WorkNumber = w.PersonnelNumber,
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Services
{
public static class ServiceLocator
{
public static IServiceProvider Instance { get; set; }
}
}
...@@ -133,23 +133,31 @@ public sys_role GetUserFirstRole(int userId) ...@@ -133,23 +133,31 @@ public sys_role GetUserFirstRole(int userId)
/// <returns></returns> /// <returns></returns>
public List<UserResponse> GetUserList(int userID) public List<UserResponse> GetUserList(int userID)
{ {
var userrole = _userroleRepository.GetEntity(t => t.UserID == userID); var userRoles = _userroleRepository.GetEntities();
if (userrole == null) throw new PerformanceException("用户未配置角色"); var userHospitals = _userhospitalRepository.GetEntities();
var role = _roleRepository.GetEntity(t => t.ID == userrole.RoleID); var users = _userRepository.GetEntities();
if (role == null) throw new PerformanceException("用户角色不存在"); var hospitals = _hospitalRepository.GetEntities();
var roles = _roleRepository.GetEntities();
var userrole = userRoles?.FirstOrDefault(t => t.UserID == userID);
if (userrole == null)
throw new PerformanceException("用户未配置角色");
var role = roles?.FirstOrDefault(t => t.ID == userrole.RoleID);
if (role == null)
throw new PerformanceException("用户角色不存在");
var result = new List<UserResponse>(); var result = new List<UserResponse>();
if (role.IsViewAllUsers == 2) if (role.IsViewAllUsers == 2)
{ {
var userlist = _userRepository.GetEntities(t => t.CreateUser == userID && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null)); var userlist = users?.Where(t => t.CreateUser == userID && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null));
var sonUser = _userRepository.GetEntities(t => t.ParentID != 0 && t.ParentID != null); var sonUser = users?.Where(t => t.ParentID != 0 && t.ParentID != null);
if (sonUser != null) if (sonUser != null)
foreach (var user in sonUser) foreach (var user in sonUser)
{ {
if (user.Department == "") if (user.Department == "")
continue; continue;
var parentUser = userlist.Find(t => t.ID == user.ParentID); var parentUser = userlist.FirstOrDefault(t => t.ID == user.ParentID);
if (parentUser == null) continue; if (parentUser == null) continue;
parentUser.Department = user.Department; parentUser.Department = user.Department;
} }
...@@ -157,18 +165,18 @@ public List<UserResponse> GetUserList(int userID) ...@@ -157,18 +165,18 @@ public List<UserResponse> GetUserList(int userID)
} }
else else
{ {
var hospitalIds = _userhospitalRepository.GetEntities(t => t.UserID == userID)?.Select(t => t.HospitalID); var hospitalIds = userHospitals?.Where(t => t.UserID == userID)?.Select(t => t.HospitalID);
if (hospitalIds == null || !hospitalIds.Any()) return result; if (hospitalIds == null || !hospitalIds.Any()) return result;
var userIds = _userhospitalRepository.GetEntities(t => hospitalIds.Contains(t.HospitalID)).Select(t => t.UserID).Distinct(); var userIds = userHospitals?.Where(t => hospitalIds.Contains(t.HospitalID)).Select(t => t.UserID).Distinct();
var userlist = _userRepository.GetEntities(t => t.ID != userID && userIds.Contains(t.ID) && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null)); var userlist = users?.Where(t => t.ID != userID && userIds.Contains(t.ID) && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null));
var sonUser = _userRepository.GetEntities(t => t.ParentID != 0 && t.ParentID != null); var sonUser = users?.Where(t => t.ParentID != 0 && t.ParentID != null);
if (sonUser != null) if (sonUser != null)
foreach (var user in sonUser) foreach (var user in sonUser)
{ {
if (user.Department == "") if (user.Department == "")
continue; continue;
var parentUser = userlist.Find(t => t.ID == user.ParentID); var parentUser = userlist.FirstOrDefault(t => t.ID == user.ParentID);
if (parentUser == null) continue; if (parentUser == null) continue;
parentUser.Department = user?.Department; parentUser.Department = user?.Department;
} }
...@@ -178,32 +186,35 @@ public List<UserResponse> GetUserList(int userID) ...@@ -178,32 +186,35 @@ public List<UserResponse> GetUserList(int userID)
{ {
foreach (var item in result) foreach (var item in result)
{ {
var hoslist = _userhospitalRepository.GetEntities(p => p.UserID == item.UserID); var hoslist = userHospitals?.Where(p => p.UserID == item.UserID);
if (hoslist != null && hoslist.Count() > 0) if (hoslist != null && hoslist.Count() > 0)
{ {
item.Hospital = string.Join(",", hoslist.Select(p => p.HospitalID.Value)); var hosids = hoslist.Select(p => p.HospitalID.Value).ToList();
item.Hospital = string.Join(",", hosids);
item.HospitalNameArr = hospitals?.Where(w => hosids.Contains(w.ID)).Select(w => w.HosName).ToArray();
} }
List<int> roleId = new List<int>(); List<int> roleId = new List<int>();
var userRole = _userroleRepository.GetEntity(t => t.UserID == item.UserID); var userRole = userRoles?.FirstOrDefault(t => t.UserID == item.UserID);
if (userRole != null) if (userRole != null)
{ {
item.Role = userRole.RoleID; item.Role = userRole.RoleID;
roleId.Add(userRole.RoleID); roleId.Add(userRole.RoleID);
} }
var diffUserRole = _userRepository.GetEntities(c => c.ParentID == item.UserID); var diffUserRole = users?.Where(c => c.ParentID == item.UserID);
if (diffUserRole != null) if (diffUserRole != null)
{ {
foreach (var user in diffUserRole) foreach (var user in diffUserRole)
{ {
var diffRole = _userroleRepository.GetEntity(t => t.UserID == user.ID); var diffRole = userRoles?.FirstOrDefault(t => t.UserID == user.ID);
roleId.Add(diffRole.RoleID); roleId.Add(diffRole.RoleID);
} }
} }
item.RoleArr = roleId?.ToArray(); item.RoleArr = roleId?.ToArray();
item.RoleNameArr = roles?.Where(w => roleId.Contains(w.ID)).Select(w => w.RoleName).ToArray();
} }
} }
return result; return result;
...@@ -526,8 +537,8 @@ public UserResponse ResetPwd(int userId, int loginUserId) ...@@ -526,8 +537,8 @@ public UserResponse ResetPwd(int userId, int loginUserId)
if (user == null) if (user == null)
throw new PerformanceException($"用户不存在 UserId:{userId}"); throw new PerformanceException($"用户不存在 UserId:{userId}");
if (user.CreateUser != loginUserId) //if (user.CreateUser != loginUserId)
throw new PerformanceException($"当前用户无权限重置用户密码"); // throw new PerformanceException($"当前用户无权限重置用户密码");
user.Password = "123456"; user.Password = "123456";
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
......
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