Commit bf7cacaf by ruyun.zhang@suvalue.com

Merge branch 'v2020morge-graphql' into develop

parents 6d0fa74c 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]
......
...@@ -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>
重新计算院领导绩效 重新计算院领导绩效
...@@ -615,6 +622,18 @@ ...@@ -615,6 +622,18 @@
<param name=""></param> <param name=""></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetSecondaryAlias">
<summary>
获取二次分配别名配置
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.SaveSecondaryAlias(Performance.DtoModels.SaveCollectData)">
<summary>
保存二次分配别名配置
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetEmployeeList(Performance.DtoModels.EmployeeRequest)"> <member name="M:Performance.Api.Controllers.EmployeeController.GetEmployeeList(Performance.DtoModels.EmployeeRequest)">
<summary> <summary>
获取人员列表 获取人员列表
...@@ -1123,18 +1142,6 @@ ...@@ -1123,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>
月群体人均绩效 月群体人均绩效
...@@ -1199,6 +1206,36 @@ ...@@ -1199,6 +1206,36 @@
<param name="form"></param> <param name="form"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.ReportPersonTag(System.Int32)">
<summary>
获取人员标签配置
</summary>
<param name="hospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.SaveReportPersonTag(System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
保存科室标签配置
</summary>
<param name="hospitalId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.ReportTag(System.Int32)">
<summary>
获取人员标签配置
</summary>
<param name="hospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.SaveReportTag(System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
保存科室标签配置
</summary>
<param name="hospitalId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="T:Performance.Api.Controllers.SecondAllotController"> <member name="T:Performance.Api.Controllers.SecondAllotController">
<summary> <summary>
二次绩效 二次绩效
...@@ -1369,6 +1406,42 @@ ...@@ -1369,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>
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_againsituation"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_againsituation">
<summary> 二次分配概览 </summary> <summary> 二次分配概览 </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_bodysource">
<summary> 二次绩效保存数据 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_compute"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_compute">
<summary> 二次绩效结果表 </summary> <summary> 二次绩效结果表 </summary>
</member> </member>
...@@ -22,6 +25,9 @@ ...@@ -22,6 +25,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_header"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_header">
<summary> 二次分配不固定列头数据 </summary> <summary> 二次分配不固定列头数据 </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_headsource">
<summary> 二次绩效顶部数据 </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_itemvalue"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_itemvalue">
<summary> 科室二次绩效录入内容 </summary> <summary> 科室二次绩效录入内容 </summary>
</member> </member>
...@@ -43,9 +49,15 @@ ...@@ -43,9 +49,15 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_workload"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_workload">
<summary> 二次绩效工作量绩效 </summary> <summary> 二次绩效工作量绩效 </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_workload_source">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_workload_type"> <member name="P:Performance.EntityModels.PerformanceDbContext.ag_workload_type">
<summary> </summary> <summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ag_worktype_source">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.as_assess"> <member name="P:Performance.EntityModels.PerformanceDbContext.as_assess">
<summary> 考核类别 </summary> <summary> 考核类别 </summary>
</member> </member>
...@@ -64,6 +76,9 @@ ...@@ -64,6 +76,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_again"> <member name="P:Performance.EntityModels.PerformanceDbContext.cof_again">
<summary> </summary> <summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_alias">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_check"> <member name="P:Performance.EntityModels.PerformanceDbContext.cof_check">
<summary> 上传excel文件校验配置 </summary> <summary> 上传excel文件校验配置 </summary>
</member> </member>
...@@ -388,6 +403,131 @@ ...@@ -388,6 +403,131 @@
科室系数人均 科室系数人均
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.ag_bodysource">
<summary>
二次绩效保存数据
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.SecondId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.RowNumber">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.WorkNumber">
<summary>
人员工号
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.Name">
<summary>
姓名
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.Post">
<summary>
岗位
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.StaffCoefficient">
<summary>
人员系数
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.ActualAttendance">
<summary>
出勤
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.JobTitle">
<summary>
职称
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.TitleCoefficient">
<summary>
职称系数
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.TitlePerformance">
<summary>
职称绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.ManagementAllowance">
<summary>
管理津贴
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.IndividualReward">
<summary>
单项奖励
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.AllocationOfKeySpecialty">
<summary>
重点专科分配
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.DeptReward">
<summary>
科室单项奖励
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.BasisPerformance">
<summary>
主任基础绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.DistPerformance">
<summary>
可分配绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.OtherPerformance">
<summary>
医院其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.NightWorkPerformance">
<summary>
夜班工作量绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.RealAmount">
<summary>
实发绩效工资金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.Signature">
<summary>
签字
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.ReservedRatio">
<summary>
预留比例
</summary>
</member>
<member name="P:Performance.EntityModels.ag_bodysource.ReservedAmount">
<summary>
预留金额
</summary>
</member>
<member name="T:Performance.EntityModels.ag_compute"> <member name="T:Performance.EntityModels.ag_compute">
<summary> <summary>
二次绩效结果表 二次绩效结果表
...@@ -748,6 +888,96 @@ ...@@ -748,6 +888,96 @@
1 汇总 2原始数据 1 汇总 2原始数据
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.ag_headsource">
<summary>
二次绩效顶部数据
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.SecondId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.TotalPerformance">
<summary>
可分配绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.HosOtherPerformance">
<summary>
医院其他绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.NightShiftWorkPerforTotal">
<summary>
夜班绩效总和
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.TotalDistPerformance">
<summary>
科室总绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.DirectorBasisPerformance">
<summary>
主任基础绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.TheTotalAllocationOfPerformanceResults">
<summary>
科室单项奖励
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.BasisPerformance">
<summary>
业绩分配绩效总额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.SeniorityTitlesAccountedPerformance">
<summary>
年资职称绩效占比
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.SeniorityTitlesPerformance">
<summary>
年资职称绩效
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.Workload_Ratio_Default">
<summary>
工作量绩效占比
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.Workload_Amount_Default">
<summary>
工作量分配绩效金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.DaysFullAttendance">
<summary>
满勤天数
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.DepartmentsPerCapita">
<summary>
科室人均
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.PaymentOfTheMonth">
<summary>
发放月份
</summary>
</member>
<member name="P:Performance.EntityModels.ag_headsource.TheNumberOfAccountingDepartment">
<summary>
科室核算人数
</summary>
</member>
<member name="T:Performance.EntityModels.ag_itemvalue"> <member name="T:Performance.EntityModels.ag_itemvalue">
<summary> <summary>
科室二次绩效录入内容 科室二次绩效录入内容
...@@ -945,7 +1175,7 @@ ...@@ -945,7 +1175,7 @@
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.SubmitType"> <member name="P:Performance.EntityModels.ag_secondallot.SubmitType">
<summary> <summary>
提交类型 1使用模板 2 其他类型数据 提交类型 1 使用模板 2 其他类型数据
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.SubmitTime"> <member name="P:Performance.EntityModels.ag_secondallot.SubmitTime">
...@@ -1148,6 +1378,56 @@ ...@@ -1148,6 +1378,56 @@
1、单项奖励 2、工作量占比 ..(自定义占比) 1、单项奖励 2、工作量占比 ..(自定义占比)
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.ag_workload_source">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.WorkloadId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.BodyId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.ItemId">
<summary>
工作量考核项ID
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.ItemName">
<summary>
工作量名称
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.FactorValue">
<summary>
工作量系数
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.Sort">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.Value">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_workload_source.WorkTypeId">
<summary>
1、单项奖励 2、工作量占比 ..(自定义占比)
</summary>
</member>
<member name="T:Performance.EntityModels.ag_workload_type"> <member name="T:Performance.EntityModels.ag_workload_type">
<summary> <summary>
...@@ -1178,6 +1458,41 @@ ...@@ -1178,6 +1458,41 @@
科室类型 科室类型
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.ag_worktype_source">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.WorkTypeId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.SecondId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.FieldId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.FieldName">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ag_worktype_source.Value">
<summary>
</summary>
</member>
<member name="T:Performance.EntityModels.as_assess"> <member name="T:Performance.EntityModels.as_assess">
<summary> <summary>
考核类别 考核类别
...@@ -6523,36 +6838,11 @@ ...@@ -6523,36 +6838,11 @@
医院状态 1 启用 2 禁用 医院状态 1 启用 2 禁用
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenWorkYear">
<summary>
是否开启年资系数 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenDrugprop">
<summary>
是否开启药占比系数 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenIncome">
<summary>
是否开启ICU有效收入系数 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenDirector">
<summary>
是否开启规模/效率绩效 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsShowManage"> <member name="P:Performance.EntityModels.sys_hospital.IsShowManage">
<summary> <summary>
是否显示绩效合计 1 显示绩效合计 2 显示管理绩效 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenCMIPercent">
<summary>
是否开启科室CMI占比 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenNursingDeptAudit"> <member name="P:Performance.EntityModels.sys_hospital.IsOpenNursingDeptAudit">
<summary> <summary>
是否开启护理部审核 1 启用 2 禁用 是否开启护理部审核 1 启用 2 禁用
...@@ -6563,9 +6853,9 @@ ...@@ -6563,9 +6853,9 @@
是否显示二次绩效科主任1 启用 2 禁用 是否显示二次绩效科主任1 启用 2 禁用
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenLogisticsSecondAllot"> <member name="P:Performance.EntityModels.sys_hospital.IsOpenTimedTasks">
<summary> <summary>
是否开启行政后勤二次绩效分配 1 启用 2 禁用 是否开启定时抽取任务 1 是 2 否
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.sys_hospital.IsSingleProject"> <member name="P:Performance.EntityModels.sys_hospital.IsSingleProject">
......
...@@ -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,6 +11,7 @@ public class UserResponse ...@@ -11,6 +11,7 @@ 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; }
...@@ -19,5 +20,7 @@ public class UserResponse ...@@ -19,5 +20,7 @@ public class UserResponse
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,6 +15,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -15,6 +15,8 @@ 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>
public virtual DbSet<ag_bodysource> ag_bodysource { get; set; }
/// <summary> 二次绩效结果表 </summary> /// <summary> 二次绩效结果表 </summary>
public virtual DbSet<ag_compute> ag_compute { get; set; } public virtual DbSet<ag_compute> ag_compute { get; set; }
/// <summary> 二次分配不固定数据 </summary> /// <summary> 二次分配不固定数据 </summary>
...@@ -25,6 +27,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -25,6 +27,8 @@ 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>
public virtual DbSet<ag_headsource> ag_headsource { get; set; }
/// <summary> 科室二次绩效录入内容 </summary> /// <summary> 科室二次绩效录入内容 </summary>
public virtual DbSet<ag_itemvalue> ag_itemvalue { get; set; } public virtual DbSet<ag_itemvalue> ag_itemvalue { get; set; }
/// <summary> 二次绩效其他绩效来源 </summary> /// <summary> 二次绩效其他绩效来源 </summary>
...@@ -40,7 +44,11 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -40,7 +44,11 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <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>
public virtual DbSet<ag_worktype_source> ag_worktype_source { get; set; }
/// <summary> 考核类别 </summary> /// <summary> 考核类别 </summary>
public virtual DbSet<as_assess> as_assess { get; set; } public virtual DbSet<as_assess> as_assess { get; set; }
/// <summary> 考核列头 </summary> /// <summary> 考核列头 </summary>
......
//-----------------------------------------------------------------------
// <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; }
}
}
...@@ -61,35 +61,35 @@ public class sys_hospital ...@@ -61,35 +61,35 @@ public class sys_hospital
/// </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 禁用
...@@ -101,10 +101,15 @@ public class sys_hospital ...@@ -101,10 +101,15 @@ public class sys_hospital
/// </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 否
......
...@@ -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);
......
...@@ -29,7 +29,6 @@ public int DeleteData(int allotId) ...@@ -29,7 +29,6 @@ public int DeleteData(int allotId)
"im_header", "im_header",
"im_specialunit", "im_specialunit",
"log_check", "log_check",
"per_employee",
"per_sheet", "per_sheet",
"res_account", "res_account",
"res_accountdoctor", "res_accountdoctor",
......
...@@ -30,6 +30,21 @@ public bool UpdateAllotStates(int allotId, int states, string remark, int genera ...@@ -30,6 +30,21 @@ public bool UpdateAllotStates(int allotId, int states, string remark, int genera
} }
/// <summary> /// <summary>
/// 执行存储过程
/// </summary>
/// <param name="execsql"></param>
/// <param name="param"></param>
/// <returns></returns>
public bool ExecProc(string execsql, object param)
{
using (var connection = context.Database.GetDbConnection())
{
Execute(execsql, param);
}
return true;
}
/// <summary>
/// 只支持EXCEL抽取报表数据 /// 只支持EXCEL抽取报表数据
/// </summary> /// </summary>
/// <param name="import"></param> /// <param name="import"></param>
...@@ -158,22 +173,25 @@ public void ImportWorkloadData(per_allot allot, object parameters) ...@@ -158,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)
{ {
...@@ -186,7 +204,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -186,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())
{ {
...@@ -196,9 +214,9 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string ...@@ -196,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;
...@@ -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
......
using AutoMapper; using AutoMapper;
using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
...@@ -33,6 +34,7 @@ public class ResultComputeService : IAutoInjection ...@@ -33,6 +34,7 @@ public class ResultComputeService : IAutoInjection
private readonly LogManageService logManageService; private readonly LogManageService logManageService;
private readonly PerforImemployeeclinicRepository perforImemployeeclinicRepository; private readonly PerforImemployeeclinicRepository perforImemployeeclinicRepository;
private readonly PerforImemployeelogisticsRepository perforImemployeelogisticsRepository; private readonly PerforImemployeelogisticsRepository perforImemployeelogisticsRepository;
private readonly ILogger logger;
public ResultComputeService( public ResultComputeService(
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
...@@ -50,7 +52,8 @@ public class ResultComputeService : IAutoInjection ...@@ -50,7 +52,8 @@ public class ResultComputeService : IAutoInjection
PerforAgsecondallotRepository perforAgsecondallotRepository, PerforAgsecondallotRepository perforAgsecondallotRepository,
PerforResreservedRepository perforresreservedRepository, PerforResreservedRepository perforresreservedRepository,
PerforImemployeeclinicRepository perforImemployeeclinicRepository, PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository) PerforImemployeelogisticsRepository perforImemployeelogisticsRepository,
ILogger<ResultComputeService> logger)
{ {
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
this.computeDirector = computeDirector; this.computeDirector = computeDirector;
...@@ -70,6 +73,7 @@ public class ResultComputeService : IAutoInjection ...@@ -70,6 +73,7 @@ public class ResultComputeService : IAutoInjection
this.perforresreservedRepository = perforresreservedRepository; this.perforresreservedRepository = perforresreservedRepository;
this.perforImemployeeclinicRepository = perforImemployeeclinicRepository; this.perforImemployeeclinicRepository = perforImemployeeclinicRepository;
this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository; this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository;
this.logger = logger;
} }
/// <summary> /// <summary>
...@@ -136,7 +140,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -136,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>();
...@@ -175,7 +179,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -175,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))
...@@ -214,6 +218,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -214,6 +218,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
AdjustLaterOtherFee = dept?.AdjustLaterOtherFee ?? 0, AdjustLaterOtherFee = dept?.AdjustLaterOtherFee ?? 0,
NightShiftWorkPerforFee = nightShift, NightShiftWorkPerforFee = nightShift,
}; };
logger.LogInformation($"特殊核算组-{group.AccountingUnit},sumValue:{sumValue},预算比例:{dept?.BasicFactor ?? -100}");
res.ResultsTotalFee = Math.Round((sumValue * (dept?.BasicFactor ?? 1m)) ?? 0); res.ResultsTotalFee = Math.Round((sumValue * (dept?.BasicFactor ?? 1m)) ?? 0);
res.PerforTotal = res.ResultsTotalFee + res.AssessBeforeOtherFee; res.PerforTotal = res.ResultsTotalFee + res.AssessBeforeOtherFee;
res.GiveFee = Math.Round((res.PerforTotal * res.ScoringAverage + res.MedicineExtra + res.MaterialsExtra + res.Punishment + res.AssessLaterOtherFee) ?? 0); res.GiveFee = Math.Round((res.PerforTotal * res.ScoringAverage + res.MedicineExtra + res.MaterialsExtra + res.Punishment + res.AssessLaterOtherFee) ?? 0);
...@@ -232,7 +237,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -232,7 +237,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
foreach (var empolyee in empolyees) foreach (var empolyee in empolyees)
{ {
var resAccount = resDataList.FirstOrDefault(t => t.AccountingUnit == empolyee.AccountingUnit); var resAccount = resDataList.FirstOrDefault(t => t.AccountingUnit == empolyee.AccountingUnit);
if (resAccount == null || empolyees.Count() == 1) if (resAccount == null)
continue; continue;
// 优先取 实际人均绩效 // 优先取 实际人均绩效
...@@ -257,6 +262,7 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -257,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,
...@@ -517,6 +523,7 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -517,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.行政后勤 };
//// 获取医院是否开启后勤二次分配 //// 获取医院是否开启后勤二次分配
...@@ -603,15 +610,42 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -603,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,10 +441,12 @@ public void Generate(per_allot allot, string mail) ...@@ -441,10 +441,12 @@ 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);
//reportService.ExecProc("call proc_report_performance(@hospitalid, @year, @month);", new { allot.HospitalId, allot.Year, allot.Month });
////发送邮件 ////发送邮件
//logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true);
...@@ -463,6 +465,15 @@ public void Generate(per_allot allot, string mail) ...@@ -463,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)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Performance.DtoModels.Request; using Performance.DtoModels.Request;
using Performance.DtoModels.Response; using Performance.DtoModels.Response;
using Performance.Services.ExtractExcelService;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -501,8 +502,8 @@ public List<DeptResponse> GetAdminPerformance(int allotId) ...@@ -501,8 +502,8 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
var employee = clinicalEmployees.FirstOrDefault(e => e.PersonnelNumber == t.JobNumber && e.AccountingUnit == t.AccountingUnit); var employee = clinicalEmployees.FirstOrDefault(e => e.PersonnelNumber == t.JobNumber && e.AccountingUnit == t.AccountingUnit);
var scoreAverageRate = t.ScoreAverageRate ?? employee.ScoreAverageRate ?? 1; var scoreAverageRate = t.ScoreAverageRate ?? employee.ScoreAverageRate ?? 1;
var attendance = t.Attendance ?? employee.Attendance ?? 0; var attendance = t.Attendance ?? employee.Attendance ?? 0;
t.GiveFee = (t.ShouldGiveFee ?? 0) * scoreAverageRate * attendance + (t.OtherPerfor ?? 0) + (t.Punishment ?? 0) + (t.AssessLaterOtherFee ?? 0); t.GiveFee = Math.Round((t.ShouldGiveFee ?? 0) * scoreAverageRate * attendance + (t.Punishment ?? 0) + (t.AssessLaterOtherFee ?? 0), 2);
t.RealGiveFee = t.GiveFee * (t.Adjust ?? 1m) + (t.AdjustLaterOtherFee ?? 0); t.RealGiveFee = Math.Round(t.GiveFee * (t.Adjust ?? 1m) + (t.AdjustLaterOtherFee ?? 0) ?? 0, 2);
} }
}); });
...@@ -717,7 +718,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -717,7 +718,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
/// <param name="isShowManage"> 仅显示管理绩效 isShowManage == 1 </param> /// <param name="isShowManage"> 仅显示管理绩效 isShowManage == 1 </param>
/// <returns></returns> /// <returns></returns>
public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowManage) public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowManage, bool isEmpDic = false)
{ {
// 获取一次次绩效结果 // 获取一次次绩效结果
var list = GetAllotPerformance(allotId, hospitalId, isShowManage); var list = GetAllotPerformance(allotId, hospitalId, isShowManage);
...@@ -732,6 +733,7 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM ...@@ -732,6 +733,7 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
// 预留比例 // 预留比例
if (result != null) if (result != null)
{ {
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政后勤.ToString(), "行政工勤" };
var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId); var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
foreach (var item in result) foreach (var item in result)
{ {
...@@ -742,13 +744,30 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM ...@@ -742,13 +744,30 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
item.PerforManagementFee = Math.Round((item.PerforManagementFee * adjust ?? 0), 2, MidpointRounding.AwayFromZero); item.PerforManagementFee = Math.Round((item.PerforManagementFee * adjust ?? 0), 2, MidpointRounding.AwayFromZero);
var real = Math.Round((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0) + (item.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero); var real = Math.Round((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0) + (item.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero);
// 这里是为了“全院核算绩效发放”金额一致
if (item.Source == "一次绩效")
{
if (isShowManage == 1)
real = Math.Round(real, 0);
else if (types.Contains(item.UnitType))
real = Math.Round(real, 0);
}
item.OthePerfor = Math.Round((item.OthePerfor ?? 0), 2, MidpointRounding.AwayFromZero); item.OthePerfor = Math.Round((item.OthePerfor ?? 0), 2, MidpointRounding.AwayFromZero);
item.NightWorkPerfor = Math.Round((item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero); item.NightWorkPerfor = Math.Round((item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero);
item.ShouldGiveFee = Math.Round(real + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero); item.ShouldGiveFee = Math.Round(real + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero);
item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0; item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
item.ReservedRatioFee = Math.Round(real * (item.ReservedRatio ?? 0), 2, MidpointRounding.AwayFromZero); item.ReservedRatioFee = Math.Round(real * (item.ReservedRatio ?? 0), 2, MidpointRounding.AwayFromZero);
item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 2, MidpointRounding.AwayFromZero); item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 2, MidpointRounding.AwayFromZero);
// 人员信息使用人员字典中数据
if (isEmpDic)
{
item.AccountingUnit = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.AccountingUnit ?? "";
item.UnitType = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.UnitType ?? "";
item.EmployeeName = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.DoctorName ?? "";
}
} }
} }
...@@ -802,7 +821,7 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i ...@@ -802,7 +821,7 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i
if (types1.Contains(t.AccountType)) if (types1.Contains(t.AccountType))
{ {
// 等同于考核后管理绩效 AssessLaterManagementFee // 等同于考核后管理绩效 AssessLaterManagementFee
comp.PerforManagementFee = Math.Round(t.ShouldGiveFee * t.ScoreAverageRate * t.Attendance + t.Punishment ?? 0); comp.PerforManagementFee = Math.Round(t.ShouldGiveFee * t.ScoreAverageRate * t.Attendance + t.Punishment ?? 0, 2);
// 仅显示管理绩效 // 仅显示管理绩效
if (isShowManage == 2) if (isShowManage == 2)
comp.PerforSumFee = 0; comp.PerforSumFee = 0;
...@@ -1028,6 +1047,20 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId) ...@@ -1028,6 +1047,20 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
var headers = _perforImheaderRepository.GetEntities(t => t.AllotID == account.AllotID); var headers = _perforImheaderRepository.GetEntities(t => t.AllotID == account.AllotID);
var basicData = _perforImDataRepository.GetEntities(t => t.AllotID == account.AllotID && t.AccountingUnit == account.AccountingUnit); var basicData = _perforImDataRepository.GetEntities(t => t.AllotID == account.AllotID && t.AccountingUnit == account.AccountingUnit);
Func<string, string> getShowKey = (name) =>
{
string _key = "开单";
if (string.IsNullOrEmpty(name)) return _key;
if (name.IndexOf("就诊") > -1)
_key = "就诊";
return _key;
};
string key = getShowKey.Invoke(persheet.FirstOrDefault(t => t.SheetName.NoBlank().StartsWith("1.1.1"))?.SheetName);
DeptDataDetails deptDetails = new DeptDataDetails DeptDataDetails deptDetails = new DeptDataDetails
{ {
ShowFormula = allot.ShowFormula, ShowFormula = allot.ShowFormula,
...@@ -1035,7 +1068,7 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId) ...@@ -1035,7 +1068,7 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
Detail = new List<DetailDtos>() Detail = new List<DetailDtos>()
}; };
if (basicData == null || !basicData.Any()) return MergeDetails(deptDetails); if (basicData == null || !basicData.Any()) return MergeDetails(deptDetails, key);
var sheetType = new List<int> var sheetType = new List<int>
{ {
...@@ -1097,7 +1130,13 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId) ...@@ -1097,7 +1130,13 @@ public DeptDataDetails<DetailModuleExtend> DeptDetail(int accountId)
} }
} }
return MergeDetails(deptDetails); // 展示额外处理,根据禅道057
deptDetails.Pandect.ScoringAverage = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountScoreAverage)?.Amount ?? deptDetails.Pandect.ScoringAverage;
deptDetails.Pandect.Extra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountExtra)?.Amount ?? deptDetails.Pandect.Extra;
deptDetails.Pandect.MaterialsExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountMaterialsAssess)?.Amount ?? deptDetails.Pandect.MaterialsExtra;
deptDetails.Pandect.MedicineExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountDrugAssess)?.Amount ?? deptDetails.Pandect.MedicineExtra;
return MergeDetails(deptDetails, key);
//return deptDetails; //return deptDetails;
} }
...@@ -1222,7 +1261,7 @@ private List<DetailModule> CommonDetailItems(List<im_data> basicData, List<im_he ...@@ -1222,7 +1261,7 @@ private List<DetailModule> CommonDetailItems(List<im_data> basicData, List<im_he
return items; return items;
} }
private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details) private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details, string key)
{ {
if (details == null) return new DeptDataDetails<DetailModuleExtend>(); if (details == null) return new DeptDataDetails<DetailModuleExtend>();
...@@ -1246,7 +1285,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details ...@@ -1246,7 +1285,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details
{ {
depts.AddRange(t.Items.Select(o => o.ItemName)); depts.AddRange(t.Items.Select(o => o.ItemName));
}); });
var billing = data.FirstOrDefault(t => t.ItemName.Replace("就诊", "开单").IndexOf("开单") > -1); var billing = data.FirstOrDefault(t => t.ItemName.IndexOf(key) > -1);
var execute = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1); var execute = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1);
foreach (var dept in depts.Distinct().OrderBy(t => t)) foreach (var dept in depts.Distinct().OrderBy(t => t))
{ {
...@@ -1295,7 +1334,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details ...@@ -1295,7 +1334,7 @@ private DeptDataDetails<DetailModuleExtend> MergeDetails(DeptDataDetails details
result.Detail.Add(new DetailDtos<DetailModuleExtend> result.Detail.Add(new DetailDtos<DetailModuleExtend>
{ {
ItemName = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1) is null ? data.First().ItemName : ItemName = data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1) is null ? data.First().ItemName :
data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1).ItemName?.Replace("执行", "开单/执行"), data.FirstOrDefault(t => t.ItemName.IndexOf("执行") > -1).ItemName?.Replace("执行", $"{key}/执行"),
IncomeType = data.First()?.IncomeType ?? 0, IncomeType = data.First()?.IncomeType ?? 0,
OriginalType = data.First()?.OriginalType ?? 0, OriginalType = data.First()?.OriginalType ?? 0,
Amount = data.Sum(w => w.Amount), Amount = data.Sum(w => w.Amount),
...@@ -1388,6 +1427,11 @@ public DeptDataDetails DeptOfficeDetail(int accountId) ...@@ -1388,6 +1427,11 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
} }
} }
} }
// 展示额外处理,根据禅道057
deptDetails.Pandect.ScoringAverage = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountScoreAverage)?.Amount ?? deptDetails.Pandect.ScoringAverage;
deptDetails.Pandect.Extra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountExtra)?.Amount ?? deptDetails.Pandect.Extra;
deptDetails.Pandect.MaterialsExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountMaterialsAssess)?.Amount ?? deptDetails.Pandect.MaterialsExtra;
deptDetails.Pandect.MedicineExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountDrugAssess)?.Amount ?? deptDetails.Pandect.MedicineExtra;
return deptDetails; return deptDetails;
} }
...@@ -1479,6 +1523,12 @@ public DeptDataDetails SpecialDeptDetail(ag_secondallot second) ...@@ -1479,6 +1523,12 @@ public DeptDataDetails SpecialDeptDetail(ag_secondallot second)
} }
} }
// 展示额外处理,根据禅道057
deptDetails.Pandect.ScoringAverage = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountScoreAverage)?.Amount ?? deptDetails.Pandect.ScoringAverage;
deptDetails.Pandect.Extra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountExtra)?.Amount ?? deptDetails.Pandect.Extra;
deptDetails.Pandect.MaterialsExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountMaterialsAssess)?.Amount ?? deptDetails.Pandect.MaterialsExtra;
deptDetails.Pandect.MedicineExtra = deptDetails.Detail?.FirstOrDefault(w => w.OriginalType == (int)SheetType.AccountDrugAssess)?.Amount ?? deptDetails.Pandect.MedicineExtra;
return deptDetails; return deptDetails;
} }
...@@ -1545,11 +1595,11 @@ public DeptDataDetails GetDoctorDetail(int computeId) ...@@ -1545,11 +1595,11 @@ public DeptDataDetails GetDoctorDetail(int computeId)
Pandect = new PerDataAccountBaisc Pandect = new PerDataAccountBaisc
{ {
BasicFactor = employee?.Basics ?? 0, //基础绩效系数 BasicFactor = employee?.Basics ?? 0, //基础绩效系数
Effic = employee.Efficiency ?? 0, //效率绩效系数 Effic = employee?.Efficiency ?? 0, //效率绩效系数
Scale = employee.Scale ?? 0, //规模绩效系数 Scale = employee?.Scale ?? 0, //规模绩效系数
Management = employee.Management,//管理绩效发放系数 Management = employee?.Management ?? 0,//管理绩效发放系数
AdjustFactor = employee?.Adjust ?? 1, //调节系数 AdjustFactor = employee?.Adjust ?? 1, //调节系数
AdjustLaterOtherFee = employee.AdjustLaterOtherFee, //调节后其他绩效 AdjustLaterOtherFee = employee?.AdjustLaterOtherFee ?? 0, //调节后其他绩效
AccountingUnit = resCompute.AccountingUnit, AccountingUnit = resCompute.AccountingUnit,
EmployeeName = resCompute.EmployeeName, EmployeeName = resCompute.EmployeeName,
...@@ -1576,7 +1626,93 @@ public DeptDataDetails GetDoctorDetail(int computeId) ...@@ -1576,7 +1626,93 @@ public DeptDataDetails GetDoctorDetail(int computeId)
if (isShowManage == 2) if (isShowManage == 2)
doctorDetails.Pandect.RealGiveFee = doctorDetails.Pandect.AssessLaterManagementFee; doctorDetails.Pandect.RealGiveFee = doctorDetails.Pandect.AssessLaterManagementFee;
var sheets = _perforPerSheetRepository.GetEntities(t => t.AllotID == resCompute.AllotID && new int[] { (int)SheetType.PersonExtra, (int)SheetType.PersonAdjustLaterOtherFee }.Contains(t.SheetType.Value)); var types = new int[]
{
(int)SheetType.PersonExtra, (int)SheetType.PersonAdjustLaterOtherFee, (int)SheetType.PersonAdjustLaterOtherManagePerforFee,
(int)SheetType.PersonPostCoefficient, (int)SheetType.PersonOtherManagePerforFee,
};
var sheets = _perforPerSheetRepository.GetEntities(t => t.AllotID == resCompute.AllotID && types.Contains(t.SheetType.Value));
if (sheets == null || !sheets.Any()) return doctorDetails;
var data = _perforImDataRepository.GetEntities(t => t.AllotID == resCompute.AllotID && sheets.Select(s => s.ID).Contains(t.SheetID.Value));
if (data == null || !data.Any(t => t.JobNumber == (resCompute.JobNumber ?? "") && t.EmployeeName == resCompute.EmployeeName)) return doctorDetails;
data = data.Where(t => t.JobNumber == (resCompute.JobNumber ?? "") && t.EmployeeName == resCompute.EmployeeName).ToList();
foreach (var sheet in sheets)
{
var sheetData = data.Where(t => t.SheetID == sheet.ID);
if (sheetData == null || !sheetData.Any()) continue;
var itemName = Regex.Replace(sheet.SheetName, @"\d", "");
var detail = new DetailDtos
{
ItemName = itemName.Replace(".", "").Replace(" ", ""),
IncomeType = sheet.SheetType == (int)SheetType.PersonExtra ? 5 : 8,
OriginalType = sheet.SheetType ?? 0,
Amount = sheetData.Where(t => t.IsTotal == 1)?.Sum(t => t.CellValue) ?? 0,
Items = sheetData.Where(t => t.IsTotal != 1)?.Select(t => new DetailModule
{
ItemName = t.TypeName,
ItemValue = t.CellValue
}).ToList()
};
doctorDetails.Detail.Add(detail);
}
return doctorDetails;
}
public DeptDataDetails GetAdministration(int computeId)
{
var resCompute = _perforRescomputeRepository.GetEntity(t => t.ID == computeId);
if (resCompute == null) return new DeptDataDetails();
var employee = _perforImemployeeRepository.GetEntity(t => t.AllotID == resCompute.AllotID && t.AccountingUnit == resCompute.AccountingUnit && t.PersonnelNumber == resCompute.JobNumber);
DeptDataDetails doctorDetails = new DeptDataDetails
{
ShowFormula = 0,
Pandect = new PerDataAccountBaisc
{
EmployeeName = employee.DoctorName,//医生姓名
JobNumber = employee.PersonnelNumber,//工号
AccountingUnit = employee.AccountingUnit,//核算单元
AccountType = employee.AccountType,//核算单元类型
JobTitle = employee.JobTitle,//职称
FitPeople = employee.FitPeople,//绩效基数核算参考对象
FitPeopleValue = employee.FitPeopleValue ?? 0,//绩效基础核算参考值
FitPeopleRatio = employee.FitPeopleRatio,//绩效基础核算系数
PostCoefficient = employee.PostCoefficient,//岗位系数
Attendance = employee.Attendance,//出勤率
ScoringAverage = employee?.ScoreAverageRate,//考核得分率
AssessBeforeOtherFee = employee.AssessBeforeOtherFee ?? 0,
Extra = employee.Punishment,//医院奖罚
NightShiftWorkPerforFee = employee.NightWorkPerfor,//夜班费
AdjustFactor = employee.Adjust,//调节系数
AdjustLaterOtherFee = employee?.AdjustLaterOtherFee ?? 0,//调解后其他绩效
PerforTotal = Math.Round(employee.FitPeopleValue ?? 0 * employee.PostCoefficient ?? 0 * employee.Attendance + employee.AssessBeforeOtherFee ?? 0),
//考核前绩效
},
Detail = new List<DetailDtos>()
};
var pandect = doctorDetails.Pandect;
//考核后绩效
doctorDetails.Pandect.AssessLaterPerforTotal = Math.Round(pandect.PerforTotal * pandect.ScoringAverage + pandect.Extra ?? 0);
//实发绩效
doctorDetails.Pandect.RealGiveFee = Math.Round((pandect.AssessLaterPerforTotal * pandect.AdjustFactor + pandect.AdjustLaterOtherFee) ?? 0);
var isShowManage = IsShowManage(resCompute.AllotID.Value);
// 开启 显示管理绩效
if (isShowManage == 2)
doctorDetails.Pandect.RealGiveFee = doctorDetails.Pandect.AssessLaterManagementFee;
var types = new int[]
{
(int)SheetType.PersonExtra, (int)SheetType.PersonAdjustLaterOtherFee, (int)SheetType.PersonAdjustLaterOtherManagePerforFee,
(int)SheetType.PersonPostCoefficient, (int)SheetType.PersonOtherManagePerforFee,
};
var sheets = _perforPerSheetRepository.GetEntities(t => t.AllotID == resCompute.AllotID && types.Contains(t.SheetType.Value));
if (sheets == null || !sheets.Any()) return doctorDetails; if (sheets == null || !sheets.Any()) return doctorDetails;
var data = _perforImDataRepository.GetEntities(t => t.AllotID == resCompute.AllotID && sheets.Select(s => s.ID).Contains(t.SheetID.Value)); var data = _perforImDataRepository.GetEntities(t => t.AllotID == resCompute.AllotID && sheets.Select(s => s.ID).Contains(t.SheetID.Value));
...@@ -1603,6 +1739,7 @@ public DeptDataDetails GetDoctorDetail(int computeId) ...@@ -1603,6 +1739,7 @@ public DeptDataDetails GetDoctorDetail(int computeId)
}; };
doctorDetails.Detail.Add(detail); doctorDetails.Detail.Add(detail);
} }
return doctorDetails; return doctorDetails;
} }
......
...@@ -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());
} }
...@@ -846,7 +846,7 @@ private void CopyAprData(int prevAllotId, int allotId) ...@@ -846,7 +846,7 @@ 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,8 +952,8 @@ public void SaveSecondaryAlias(SaveCollectData request) ...@@ -952,8 +952,8 @@ 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";
} }
...@@ -961,13 +961,13 @@ public void SaveSecondaryAlias(SaveCollectData request) ...@@ -961,13 +961,13 @@ public void SaveSecondaryAlias(SaveCollectData request)
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());
} }
......
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();
...@@ -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];
}
} }
} }
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -181,53 +182,53 @@ public List<PerReport> InpatFeeAvg(int hospitalId) ...@@ -181,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抽取报表数据
...@@ -384,5 +385,22 @@ public List<PerReport> MenuReport(ReportRequest request) ...@@ -384,5 +385,22 @@ public List<PerReport> MenuReport(ReportRequest request)
return report; return report;
} }
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="allot"></param>
/// <returns></returns>
public void ExecProc(string execsql, object param)
{
try
{
perforPerallotRepository.Execute(execsql, param, 60 * 60);
}
catch (Exception ex)
{
logger.LogError($"执行存储过程时发生异常,sql:{execsql};参数:{JsonHelper.Serialize(param)};异常:{ex.Message};");
}
}
} }
} }
...@@ -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 Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Services
{
public partial class SecondAllotService : IAutoInjection
{
#region 二次绩效详情
private bool IsAudit(int? secondStatus)
{
return new int[] { 2, 3 }.Contains(secondStatus ?? 1);
}
public SecondAllotResponse GetSecondSavedData(int userId, int secondId, int employeeSource)
{
var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("参数SecondId无效!");
var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) throw new PerformanceException("绩效记录不存在!");
if (!IsAudit(second.Status))
AddWorkTypeDefaultHeadValue(allot.HospitalId, second);
var (tempId, name) = GetUsingTempId(allot.HospitalId, second);
var detail = new Detail()
{
TempId = tempId,
TempName = name,
IsArchive = allot.States == 8 ? 1 : 0,
States = allot.States,
Status = second.Status ?? 1,
Department = second.Department,
UnitType = second.UnitType
};
SecondAllotResponse result = new SecondAllotResponse() { Detail = detail };
var head = agheadsourceRepository.GetEntity(t => t.SecondId == secondId)
?? new ag_headsource
{
SecondId = secondId,
TotalDistPerformance = second.RealGiveFee,
PaymentOfTheMonth = $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}月",
SeniorityTitlesAccountedPerformance = 0.2m,
Workload_Ratio_Default = 0.8m,
DaysFullAttendance = DateTime.DaysInMonth(allot.Year, allot.Month)
};
JObject jObject = JObject.Parse(JsonConvert.SerializeObject(head));
var headDynamic = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId);
if (headDynamic != null && headDynamic.Any())
{
foreach (var item in headDynamic.OrderBy(t => t.Id))
jObject.Add(new JProperty(item.FieldId, item.Value));
}
result.Head = jObject;
var prevSecond = GetPreviousSecondAllot(allot.HospitalId, second);
// 保存过数据,从保存的数据中心带出信息
// 未保存过数据,带入初始数据(首次填写二次绩效,人员信息来自人员字典,有历史二次绩效记录时,人员信息来自上次二次绩效填写记录)
if (head.Id == 0 && employeeSource == (int)EmployeeSource.Initial)
employeeSource = prevSecond == null ? (int)EmployeeSource.EmployeeDict : (int)EmployeeSource.PrevSecondAllot;
if (detail.IsArchive == 1 || new List<int> { (int)SecondAllotStatus.WaitReview, (int)SecondAllotStatus.PassAudit }.Contains(second.Status ?? (int)SecondAllotStatus.Uncommitted))
employeeSource = (int)EmployeeSource.Initial;
result.Body = GetBodyItemsByEmployeeSource(userId, employeeSource, second, prevSecond, allot);
return result;
}
/// <summary>
/// 根据不同情况获取不同数据
/// </summary>
/// <param name="userId"></param>
/// <param name="employeeSource"></param>
/// <param name="second"></param>
/// <param name="prevSecond"></param>
/// <param name="allot"></param>
/// <returns></returns>
private JArray GetBodyItemsByEmployeeSource(int userId, int employeeSource, ag_secondallot second, ag_secondallot prevSecond, per_allot allot)
{
List<ag_bodysource> bodysources = new List<ag_bodysource>();
var employeeList = personService.GetPersons(allot.ID, userId);
switch (employeeSource)
{
case (int)EmployeeSource.Initial:
bodysources = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id);
break;
case (int)EmployeeSource.EmployeeDict:
bodysources = GetEmployeeFromEmployeeDict(employeeList);
break;
case int source when source == (int)EmployeeSource.PrevSecondAllot && prevSecond != null:
bodysources = GetEmployeeFromPrevData(prevSecond, employeeList);
break;
default:
bodysources = new List<ag_bodysource>();
break;
}
SupplementOtherPerfor(second, bodysources, employeeList);
return IsAudit(second.Status) ? GetBodyResultAfterAudit(allot.HospitalId, second, bodysources) : GetBodyResult(allot.HospitalId, second, bodysources);
}
/// <summary>
/// 从人员字典中获取人员信息
/// </summary>
/// <param name="employeeList"></param>
/// <returns></returns>
public List<ag_bodysource> GetEmployeeFromEmployeeDict(List<per_employee> employeeList)
{
if (employeeList == null || !employeeList.Any()) return new List<ag_bodysource>();
List<ag_bodysource> bodysources = new List<ag_bodysource>();
int rowNumber = 1;
foreach (var employee in employeeList)
{
bodysources.Add(new ag_bodysource
{
RowNumber = rowNumber,
WorkNumber = employee.PersonnelNumber,
Department = employee.AccountingUnit,
Name = employee.DoctorName,
Post = getPost.Invoke(employee),
ActualAttendance = employee.AttendanceDay,
StaffCoefficient = 1,
JobTitle = employee.JobTitle,
ReservedRatio = employee.ReservedRatio,
OtherPerformance = 0
});
rowNumber++;
}
return bodysources;
}
/// <summary>
/// 从上一次的保存信息中获取人员信息
/// </summary>
/// <param name="prevSecondAllot"></param>
/// <param name="otherShowColumns"></param>
/// <returns></returns>
public List<ag_bodysource> GetEmployeeFromPrevData(ag_secondallot prevSecond, List<per_employee> employeeList)
{
var body = agbodysourceRepository.GetEntities(t => t.SecondId == prevSecond.Id);
if (body == null || !body.Any()) return new List<ag_bodysource>();
foreach (var item in body.Select(t => new ag_bodysource
{
WorkNumber = t.WorkNumber,
Name = t.Name,
Post = t.Post,
Department = t.Department,
StaffCoefficient = t.StaffCoefficient,
JobTitle = t.JobTitle,
TitleCoefficient = t.TitleCoefficient
}))
{
item.ActualAttendance = employeeList?.FirstOrDefault(w => w.PersonnelNumber == item.WorkNumber && w.DoctorName == item.Name)?.AttendanceDay;
}
return body;
}
/// <summary>
/// 补充医院其他绩效
/// </summary>
/// <param name="secondAllot"></param>
/// <param name="bodyItems"></param>
/// <param name="employeeList"></param>
/// <param name="isSupplyOtherEmployees">是否补充字典中该科室不存在,但有其它绩效的人员信息</param>
private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysource> bodyItems, List<per_employee> employeeList, bool isSupplyOtherEmployees = true)
{
if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return;
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == secondAllot.AllotId && t.Status == 3);
if (perapramounts == null || !perapramounts.Any()) return;
foreach (var rowitem in bodyItems)
{
var employee = employeeList.FirstOrDefault(w => w.PersonnelNumber == rowitem.WorkNumber);
if (employee == null) continue;
var hasAmountData = perapramounts?.Where(w => w.PersonnelNumber?.Trim() == rowitem.WorkNumber?.Trim());
if (hasAmountData == null || !hasAmountData.Any()) continue;
rowitem.OtherPerformance = secondAllot.Department == employee.AccountingUnit && secondAllot.UnitType == employee.UnitType ? hasAmountData.Sum(w => w.Amount) : 0;
perapramounts.RemoveAll(w => w.PersonnelNumber?.Trim() == rowitem.WorkNumber?.Trim());
}
// 补充字典中该科室不存在,但有其它绩效的人员信息
if (isSupplyOtherEmployees && perapramounts != null && perapramounts.Any(t => t.AccountingUnit == secondAllot.Department))
{
var groupData = perapramounts.Where(t => t.AccountingUnit == secondAllot.Department).GroupBy(t => t.PersonnelNumber)
.Select(t => new
{
PersonnelNumber = t.Key,
DoctorName = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.DoctorName))?.DoctorName,
Amount = t.Sum(w => w.Amount)
});
// int maxRownumber = bodyItems.Max(t => t.RowNumber ?? 0) + 1;
foreach (var item in groupData)
{
var employee = employeeList.FirstOrDefault(w => w.PersonnelNumber == item.PersonnelNumber);
if (employee != null && employee.UnitType == secondAllot.UnitType)
{
bodyItems.Add(new ag_bodysource
{
WorkNumber = item.PersonnelNumber,
Name = item.DoctorName,
Post = getPost.Invoke(employee),
ActualAttendance = employee.AttendanceDay,
StaffCoefficient = 1,
JobTitle = employee.JobTitle,
ReservedRatio = employee.ReservedRatio,
OtherPerformance = item.Amount
});
}
}
}
}
/// <summary>
/// 获取body的结果集
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
/// <param name="bodysources"></param>
/// <returns></returns>
private JArray GetBodyResult(int hospitalId, ag_secondallot second, List<ag_bodysource> bodysources)
{
JArray jArray = new JArray();
if (bodysources == null || !bodysources.Any())
return jArray;
var bodyDynamic = agworkloadsourceRepository.GetEntities(t => bodysources.Select(w => w.Id).Contains(t.BodyId));
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType)
?.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort).ToList();
if (workloads != null && workloads.Any())
{
foreach (var item in bodysources.OrderBy(t => t.Id))
{
JObject jObj = JObject.Parse(JsonConvert.SerializeObject(item)); //使用jsonHelper会自动隐藏空值的项
foreach (var workitem in workloads)
{
var value = bodyDynamic?.FirstOrDefault(w => w.BodyId == item.Id && w.WorkloadId == workitem.Id)?.Value;
jObj.Add(new JProperty(workitem.ItemId, value));
}
jArray.Add(jObj);
}
}
return jArray;
}
/// <summary>
/// 获取审核通过后body的结果集
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
/// <param name="bodysources"></param>
/// <returns></returns>
private JArray GetBodyResultAfterAudit(int hospitalId, ag_secondallot second, List<ag_bodysource> bodysources)
{
JArray jArray = new JArray();
if (bodysources == null || !bodysources.Any())
return jArray;
var bodyDynamic = agworkloadsourceRepository.GetEntities(t => bodysources.Select(w => w.Id).Contains(t.BodyId));
foreach (var item in bodysources.OrderBy(t => t.Id))
{
JObject jObj = JObject.Parse(JsonConvert.SerializeObject(item)); //使用jsonHelper会自动隐藏空值的项
if (bodyDynamic != null && bodyDynamic.Any(t => t.BodyId == item.Id))
{
foreach (var col in bodyDynamic.Where(t => t.BodyId == item.Id))
{
jObj.Add(new JProperty(col.ItemId, col.Value));
}
}
jArray.Add(jObj);
}
return jArray;
}
/// <summary>
/// 获取当前使用的模板
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
/// <returns></returns>
private (int tempId, string name) GetUsingTempId(int hospitalId, ag_secondallot second)
{
int usingTempId = (int)Temp.other;
var usedTemp = agusetempRepository.GetEntity(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usedTemp != null && usedTemp.UseTempId.HasValue)
{
usingTempId = usedTemp.UseTempId.Value;
if (IsAudit(second.Status))
usingTempId = (second.UseTempId ?? 0) == 0 ? (int)Temp.other : second.UseTempId.Value;
}
var temp = agtempRepository.GetEntity(t => t.Id == usingTempId);
return (usingTempId, temp?.TempName);
}
/// <summary>
/// 获取上一次的二次绩效
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="secondAllot"></param>
/// <returns></returns>
private ag_secondallot GetPreviousSecondAllot(int hospitalId, ag_secondallot secondAllot)
{
// 历史删除绩效时,未删除对应的二次绩效记录
var allotList = perallotRepository.GetEntities(w => w.HospitalId == hospitalId)?.OrderBy(s => s.Year).ThenBy(s => s.Month).ToList();
if (allotList == null || !allotList.Any()) throw new PerformanceException("未查询到符合的绩效记录");
var allot = allotList.FirstOrDefault(w => w.ID == secondAllot.AllotId);
if (allot == null) throw new PerformanceException("未查询到符合的绩效记录");
var index = allotList.IndexOf(allot);
if (index == 0) return null;
var prevAllot = allotList[index - 1];
var prevSecondAllot = agsecondallotRepository.GetEntity(w => w.AllotId == prevAllot.ID && w.UnitType == secondAllot.UnitType && w.Department == secondAllot.Department);
return prevSecondAllot;
}
/// <summary>
/// 获取岗位
/// </summary>
readonly Func<per_employee, string> getPost = (e) => (e.Duty?.IndexOf("主任") > -1 || e.Duty?.IndexOf("护士长") > -1) ? "科主任/护士长" : "其他";
/// <summary>
/// 二次绩效分配录入人员自动补全信息
/// </summary>
/// <param name="secodId"></param>
/// <param name="workNumber">工号</param>
/// <returns></returns>
public JArray AutoComplete(int secodId, string workNumber)
{
var second = agsecondallotRepository.GetEntity(t => t.Id == secodId);
if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null)
throw new PerformanceException("当前绩效信息无效");
var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板");
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID && !string.IsNullOrEmpty(t.PersonnelNumber) && t.PersonnelNumber.IndexOf(workNumber) > -1)
?.OrderBy(t => t.PersonnelNumber).ThenByDescending(t => t.DoctorName).ToList();
if (employees == null || !employees.Any()) return new JArray();
var bodysources = new List<ag_bodysource>();
if (employees.Any(t => !string.IsNullOrEmpty(t.DoctorName)))
bodysources = GetEmployeeFromEmployeeDict(employees.Where(t => !string.IsNullOrEmpty(t.DoctorName)).ToList());
else
bodysources = GetEmployeeFromEmployeeDict(employees);
SupplementOtherPerfor(second, bodysources, employees, false);
return GetBodyResult(allot.HospitalId, second, bodysources);
}
#endregion
#region 动态配置字典
public dynamic GetWorkTypeDict(int secondId)
{
var worktypeSources = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId) ?? new List<ag_worktype_source>();
return worktypeSources.OrderBy(t => t.Id).Select(t => new
{
Title = t.FieldId,
Value = t.FieldName
});
}
public dynamic GetWorkloadDict(int secondId)
{
var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("参数SecondId无效!");
if (IsAudit(second.Status)) return GetWorkloadDictAfterAudit(secondId);
var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) throw new PerformanceException("绩效记录不存在!");
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType)
?? new List<ag_workload>();
return workloads.OrderBy(t => t.WorkTypeId).ThenBy(t => t.Sort).Select(t => new
{
Title = t.ItemId,
Value = t.ItemName,
Factor = t.FactorValue
});
}
private dynamic GetWorkloadDictAfterAudit(int secondId)
{
var bodysources = agbodysourceRepository.GetEntities(t => t.SecondId == secondId);
if (bodysources == null || !bodysources.Any()) return new string[] { };
var workloadsources = agworkloadsourceRepository.GetEntities(t => bodysources.Select(w => w.Id).Contains(t.BodyId));
if (workloadsources == null || !workloadsources.Any()) return new string[] { };
var dict = workloadsources.GroupBy(t => new { t.ItemId, t.ItemName, t.FactorValue, t.Sort, t.WorkTypeId, t.WorkloadId })
.OrderBy(t => t.Key.WorkTypeId).ThenBy(t => t.Key.Sort)
.Select(t => new
{
Title = t.Key.ItemId,
Value = t.Key.ItemName,
Factor = t.Key.FactorValue
});
return dict;
}
#endregion
#region 保存数据
public void SaveSecondAllotData(int secondId, dynamic saveData)
{
try
{
var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("参数SecondId无效!");
var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) throw new PerformanceException("绩效记录不存在!");
var head = saveData["head"];
SaveSecondAllotHeadData(secondId, JsonHelper.Serialize(head));
var body = saveData["body"];
SaveSecondAllotBodyData(allot.HospitalId, second, body);
}
catch (Exception ex)
{
logger.LogError(ex.Message);
}
}
/// <summary>
/// 保存Head相关数据
/// </summary>
/// <param name="secondId"></param>
/// <param name="json"></param>
private void SaveSecondAllotHeadData(int secondId, string json)
{
if (string.IsNullOrEmpty(json)) return;
ag_headsource headsource = JsonHelper.Deserialize<ag_headsource>(json);
if (headsource == null) return;
headsource.SecondId = secondId;
if (headsource.Id == 0)
{
agheadsourceRepository.Add(headsource);
}
else
{
agheadsourceRepository.UpdateByState(headsource);
}
string[] prefix = new string[] { "Workload_Ratio_", "Workload_Amount_" };
Dictionary<string, object> dict = JsonHelper.Deserialize<Dictionary<string, object>>(json);
var keys = dict.Keys.Where(t => t.StartsWith(prefix[0]) || t.StartsWith(prefix[1]));
if (keys == null || !keys.Any())
return;
List<ag_worktype_source> insertData = new List<ag_worktype_source>();
var worktypeSources = agworktypesourceRepository.GetEntities(t => t.SecondId == secondId);
if (worktypeSources == null || !worktypeSources.Any())
return;
foreach (var key in keys)
{
var update = worktypeSources.FirstOrDefault(t => t.FieldId == key);
if (update != null)
{
update.Value = ConvertHelper.To<decimal>(dict[key]);
}
}
agworktypesourceRepository.UpdateRange(worktypeSources.ToArray());
}
/// <summary>
/// 保存Body相关数据
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
/// <param name="body"></param>
private void SaveSecondAllotBodyData(int hospitalId, ag_secondallot second, dynamic body)
{
// 允许空行数据提交,删除数据库存数数据
var bodyEntities = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id);
if (bodyEntities != null && bodyEntities.Any())
{
var workloadEntities = agworkloadsourceRepository.GetEntities(t => bodyEntities.Select(w => w.Id).Contains(t.BodyId));
if (workloadEntities != null && workloadEntities.Any())
agworkloadsourceRepository.RemoveRange(workloadEntities.ToArray());
agbodysourceRepository.RemoveRange(bodyEntities.ToArray());
}
if (body == null || !((IEnumerable<dynamic>)body).Any()) return;
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType)?.ToList();
if (workloads == null || !workloads.Any()) return;
string[] prefix = new string[] { "WorkloadScore_", "AssessmentScore_", "WorkPerformance_", $"{AgWorkloadType.SingleAwards}_", $"{AgWorkloadType.Workload}_" };
List<ag_workload_source> workloadSources = new List<ag_workload_source>();
foreach (var rowitem in body)
{
ag_bodysource bodySource = JsonHelper.Deserialize<ag_bodysource>(JsonHelper.Serialize(rowitem));
bodySource.SecondId = second.Id;
var result = agbodysourceRepository.Add(bodySource);
if (!result) continue;
Dictionary<string, object> dict = JsonHelper.Deserialize<Dictionary<string, object>>(JsonHelper.Serialize(rowitem));
var keys = dict.Keys.Where(t => t.StartsWith(prefix[0]) || t.StartsWith(prefix[1]) || t.StartsWith(prefix[2]) || t.StartsWith(prefix[3]) || t.StartsWith(prefix[4]));
if (keys == null || !keys.Any()) continue;
foreach (var key in keys)
{
var workload = workloads.FirstOrDefault(t => t.ItemId == key);
if (workload == null) continue;
workloadSources.Add(new ag_workload_source
{
WorkloadId = workload.Id,
BodyId = bodySource.Id,
ItemId = workload.ItemId,
ItemName = workload.ItemName,
FactorValue = workload.FactorValue,
Sort = workload.Sort,
Value = ConvertHelper.To<decimal>(dict[key]),
WorkTypeId = workload.WorkTypeId
});
}
}
if (workloadSources != null && workloadSources.Any())
agworkloadsourceRepository.AddRange(workloadSources.ToArray());
}
#endregion
}
}
...@@ -15,90 +15,105 @@ ...@@ -15,90 +15,105 @@
namespace Performance.Services namespace Performance.Services
{ {
public class SecondAllotService : IAutoInjection public partial class SecondAllotService : IAutoInjection
{ {
private readonly ILogger logger;
private readonly Application application; private readonly Application application;
private readonly ILogger<SecondAllotService> _logger; private readonly PerforAgsecondallotRepository agsecondallotRepository;
private readonly PerforAgtempRepository agtempRepository;
private readonly PerforAgtempitemRepository agtempitemRepository;
private readonly PerforAgusetempRepository agusetempRepository;
private readonly PerforAgworkloadRepository agworkloadRepository;
private readonly PerforAgworkloadtypeRepository agworkloadtypeRepository;
private readonly PerforAgbodysourceRepository agbodysourceRepository;
private readonly PerforAgheadsourceRepository agheadsourceRepository;
private readonly PerforAgworktypesourceRepository agworktypesourceRepository;
private readonly PerforAgworkloadsourceRepository agworkloadsourceRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforUserRepository userRepository;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforUserRepository perforUserRepository; private readonly PerforUserhospitalRepository userhospitalRepository;
private readonly PerforUserhospitalRepository perforUserhospitalRepository;
private readonly PerforPerallotRepository perforPerallotRepository;
private readonly PerforAgsecondallotRepository perforAgsecondallotRepository;
private readonly PerforResaccountRepository perforResaccountRepository;
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforAgworkloadRepository perforAgworkloadRepository;
private readonly PerforAgtempRepository perforAgtempRepository;
private readonly PerforAgtempitemRepository perforAgtempitemRepository;
private readonly PerforAgfixatitemRepository perforAgfixatitemRepository;
private readonly PerforAgusetempRepository perforAgusetempRepository;
private readonly PerforAgcomputeRepository perforAgcomputeRepository;
private readonly PerforCofagainRepository perforCofagainRepository;
private readonly PerforAgothersourceRepository perforAgothersourceRepository;
private readonly PerforAgworkloadtypeRepository perforAgworkloadtypeRepository;
private readonly PerforRoleRepository roleRepository; private readonly PerforRoleRepository roleRepository;
private readonly PerforPerapramountRepository perapramountRepository; private readonly PerforUserroleRepository userroleRepository;
private readonly PerforImemployeeclinicRepository imemployeeclinicRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforResaccountRepository resaccountRepository;
private readonly PerforRescomputeRepository rescomputeRepository;
private readonly PerforResspecialunitRepository resspecialunitRepository; private readonly PerforResspecialunitRepository resspecialunitRepository;
private readonly PersonService personService; private readonly PerforPerapramountRepository perapramountRepository;
private readonly PerforAgfixatitemRepository agfixatitemRepository;
private readonly PerforAgothersourceRepository agothersourceRepository;
private readonly PerforAgcomputeRepository agcomputeRepository;
private readonly PerforCofagainRepository cofagainRepository;
private readonly ComputeService computeService; private readonly ComputeService computeService;
private readonly PerforRescomputeRepository rescomputeRepository; private readonly PersonService personService;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforImemployeeclinicRepository imemployeeclinicRepository;
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>(); private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(IOptions<Application> application, public SecondAllotService(
ILogger<SecondAllotService> logger, ILogger<SecondAllotService> logger,
IOptions<Application> application,
PerforAgsecondallotRepository agsecondallotRepository,
PerforAgtempRepository agtempRepository,
PerforAgtempitemRepository agtempitemRepository,
PerforAgusetempRepository agusetempRepository,
PerforAgworkloadRepository agworkloadRepository,
PerforAgworkloadtypeRepository agworkloadtypeRepository,
PerforAgbodysourceRepository agbodysourceRepository,
PerforAgheadsourceRepository agheadsourceRepository,
PerforAgworktypesourceRepository agworktypesourceRepository,
PerforAgworkloadsourceRepository agworkloadsourceRepository,
PerforPerallotRepository perallotRepository,
PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforUserRepository perforUserRepository, PerforUserhospitalRepository userhospitalRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository,
PerforAgsecondallotRepository perforAgsecondallotRepository,
PerforResaccountRepository perforResaccountRepository,
PerforUserroleRepository userroleRepository,
PerforAgworkloadRepository perforAgworkloadRepository,
PerforAgtempRepository perforAgtempRepository,
PerforAgtempitemRepository perforAgtempitemRepository,
PerforAgfixatitemRepository perforAgfixatitemRepository,
PerforAgusetempRepository perforAgusetempRepository,
PerforAgcomputeRepository perforAgcomputeRepository,
PerforCofagainRepository perforCofagainRepository,
PerforAgothersourceRepository perforAgothersourceRepository,
PerforAgworkloadtypeRepository perforAgworkloadtypeRepository,
PerforRoleRepository roleRepository, PerforRoleRepository roleRepository,
PerforPerapramountRepository perapramountRepository, PerforUserroleRepository userroleRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforResaccountRepository resaccountRepository,
PerforRescomputeRepository rescomputeRepository,
PerforResspecialunitRepository resspecialunitRepository, PerforResspecialunitRepository resspecialunitRepository,
PerforPerapramountRepository perapramountRepository,
PerforAgfixatitemRepository agfixatitemRepository,
PerforAgothersourceRepository agothersourceRepository,
PerforAgcomputeRepository agcomputeRepository,
PerforCofagainRepository cofagainRepository,
PersonService personService, PersonService personService,
ComputeService computeService, ComputeService computeService
PerforRescomputeRepository rescomputeRepository, )
PerforPeremployeeRepository peremployeeRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository)
{ {
this.logger = logger;
this.application = application.Value; this.application = application.Value;
_logger = logger; this.agsecondallotRepository = agsecondallotRepository;
this.agtempRepository = agtempRepository;
this.agtempitemRepository = agtempitemRepository;
this.agusetempRepository = agusetempRepository;
this.agworkloadRepository = agworkloadRepository;
this.agworkloadtypeRepository = agworkloadtypeRepository;
this.agbodysourceRepository = agbodysourceRepository;
this.agheadsourceRepository = agheadsourceRepository;
this.agworktypesourceRepository = agworktypesourceRepository;
this.agworkloadsourceRepository = agworkloadsourceRepository;
this.perallotRepository = perallotRepository;
this.userRepository = userRepository;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.perforUserRepository = perforUserRepository; this.userhospitalRepository = userhospitalRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforAgsecondallotRepository = perforAgsecondallotRepository;
this.perforResaccountRepository = perforResaccountRepository;
this.userroleRepository = userroleRepository;
this.perforAgworkloadRepository = perforAgworkloadRepository;
this.perforAgtempRepository = perforAgtempRepository;
this.perforAgtempitemRepository = perforAgtempitemRepository;
this.perforAgfixatitemRepository = perforAgfixatitemRepository;
this.perforAgusetempRepository = perforAgusetempRepository;
this.perforAgcomputeRepository = perforAgcomputeRepository;
this.perforCofagainRepository = perforCofagainRepository;
this.perforAgothersourceRepository = perforAgothersourceRepository;
this.perforAgworkloadtypeRepository = perforAgworkloadtypeRepository;
this.roleRepository = roleRepository; this.roleRepository = roleRepository;
this.perapramountRepository = perapramountRepository; this.userroleRepository = userroleRepository;
this.imemployeeclinicRepository = imemployeeclinicRepository;
this.peremployeeRepository = peremployeeRepository;
this.resaccountRepository = resaccountRepository;
this.rescomputeRepository = rescomputeRepository;
this.resspecialunitRepository = resspecialunitRepository; this.resspecialunitRepository = resspecialunitRepository;
this.personService = personService; this.perapramountRepository = perapramountRepository;
this.agfixatitemRepository = agfixatitemRepository;
this.agothersourceRepository = agothersourceRepository;
this.agcomputeRepository = agcomputeRepository;
this.cofagainRepository = cofagainRepository;
this.computeService = computeService; this.computeService = computeService;
this.rescomputeRepository = rescomputeRepository; this.personService = personService;
this.peremployeeRepository = peremployeeRepository;
this.imemployeeclinicRepository = imemployeeclinicRepository;
this.tempitems = perforAgtempitemRepository.GetEntities();
} }
#region 二次绩效列表与数据保存 #region 二次绩效列表与数据保存
...@@ -110,15 +125,15 @@ public class SecondAllotService : IAutoInjection ...@@ -110,15 +125,15 @@ public class SecondAllotService : IAutoInjection
/// <returns></returns> /// <returns></returns>
public List<SecondListResponse> GetSecondList(int userId) public List<SecondListResponse> GetSecondList(int userId)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
throw new NotImplementedException("人员ID无效"); throw new NotImplementedException("人员ID无效");
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId); var hospital = userhospitalRepository.GetEntity(t => t.UserID == userId);
if (hospital == null) if (hospital == null)
throw new NotImplementedException("人员未选择医院"); throw new NotImplementedException("人员未选择医院");
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States)); var allotList = perallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States));
if (allotList == null || allotList.Count == 0) if (allotList == null || allotList.Count == 0)
return new List<SecondListResponse>(); return new List<SecondListResponse>();
...@@ -133,7 +148,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -133,7 +148,7 @@ public List<SecondListResponse> GetSecondList(int userId)
else if (role.Type == application.OfficeRole) else if (role.Type == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString()); exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = perforAgsecondallotRepository.GetEntities(exp); var secondList = agsecondallotRepository.GetEntities(exp);
var list = Mapper.Map<List<SecondListResponse>>(secondList); var list = Mapper.Map<List<SecondListResponse>>(secondList);
list?.ForEach(t => list?.ForEach(t =>
{ {
...@@ -145,6 +160,20 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -145,6 +160,20 @@ public List<SecondListResponse> GetSecondList(int userId)
t.ShowFormula = allot.ShowFormula; t.ShowFormula = allot.ShowFormula;
} }
}); });
if (secondList != null && secondList.Any())
{
// 暂时在加载列表时补充信息
var worktypes = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.Department == secondList.First().Department && t.UnitType == secondList.First().UnitType);
if (worktypes != null && worktypes.Any())
{
worktypes.ForEach(t => AddWorkTypeDefaultValues(t));
}
// 补充默认工作量项
CheckDefaultWorkload(hospital.HospitalID ?? 0, secondList.First().Department, secondList.First().UnitType);
}
return list; return list;
} }
...@@ -166,7 +195,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -166,7 +195,7 @@ public List<SecondListResponse> GetSecondList(int userId)
// var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() }; // var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() };
// //获取已录入数据 // //获取已录入数据
// var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue); // var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue);
// if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过 // if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) //归档 等待审核、审核通过
// { // {
// #region 已归档数据,根据数据获取 列 // #region 已归档数据,根据数据获取 列
...@@ -210,7 +239,7 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -210,7 +239,7 @@ public List<SecondListResponse> GetSecondList(int userId)
// .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList(); // .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
// var index = secondIdList.IndexOf(request.SecondId); // var index = secondIdList.IndexOf(request.SecondId);
// if (index != 0) // if (index != 0)
// fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue); // fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) && t.RowNumber.HasValue);
// fixatList = fixatList?.Where(t => bringhead.Select(h => h.FiledName).Contains(t.ItemName)).ToList(); // fixatList = fixatList?.Where(t => bringhead.Select(h => h.FiledName).Contains(t.ItemName)).ToList();
// if (fixatList != null && fixatList.Count > 0) // if (fixatList != null && fixatList.Count > 0)
...@@ -262,15 +291,15 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -262,15 +291,15 @@ public List<SecondListResponse> GetSecondList(int userId)
/// <returns></returns> /// <returns></returns>
public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId) public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效"); throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效信息无效"); throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity( var usetemp = agusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType); t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
...@@ -293,22 +322,22 @@ public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId) ...@@ -293,22 +322,22 @@ public List<BodyItem> AutoComplete(SecondEmpRequest request, int userId)
/// <returns></returns> /// <returns></returns>
public SecondResponse GetSecondDetail(UseTempRequest request, int userId) public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
{ {
var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType); //获取科室二次绩效费用分配使用的模板 && t.Department == request.Department && t.UnitType == request.UnitType); //获取科室二次绩效费用分配使用的模板
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
var temp = perforAgtempRepository.GetEntity(t => t.Id == usetemp.UseTempId); var temp = agtempRepository.GetEntity(t => t.Id == usetemp.UseTempId);
if (temp == null || temp.IsEnable != 1) if (temp == null || temp.IsEnable != 1)
throw new PerformanceException("模板无效,请重新选择"); throw new PerformanceException("模板无效,请重新选择");
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType); var headItems = GetHeadItems(request.TempId, usetemp.HospitalId.Value, usetemp.Department, usetemp.UnitType);
var result = new SecondResponse(); var result = new SecondResponse();
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue && !string.IsNullOrEmpty(t.ItemName)); var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue && !string.IsNullOrEmpty(t.ItemName));
//归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems //归档 或 等待审核、审核通过时,headItems不会随选择模板改动,带出已填写数据中的headItems
if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1)) if (request.IsArchive == 1 || new List<int> { 2, 3 }.Contains(second.Status ?? 1))
{ {
...@@ -357,7 +386,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId) ...@@ -357,7 +386,7 @@ public SecondResponse GetSecondDetail(UseTempRequest request, int userId)
return new SecondResponse return new SecondResponse
{ {
HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.WorkType).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(), HeadItems = result.HeadItems.OrderBy(t => t.Type).ThenBy(t => t.Sort).ThenBy(t => t.FiledName).ToList(),
BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(), BodyItems = result.BodyItems.OrderBy(t => t.RowNumber).ThenBy(t => t.Type).ThenBy(t => t.Sort).ToList(),
}; };
} }
...@@ -370,7 +399,7 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId) ...@@ -370,7 +399,7 @@ private void SupplementOtherPerfor(SecondResponse result, int allotId)
{ {
if (result?.BodyItems != null && result.BodyItems.Any()) if (result?.BodyItems != null && result.BodyItems.Any())
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.AllotId == allotId); var second = agsecondallotRepository.GetEntity(t => t.AllotId == allotId);
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3);
foreach (var rownum in result.BodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct()) foreach (var rownum in result.BodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct())
...@@ -408,9 +437,9 @@ private List<BodyItem> GetEmployees(List<per_employee> employees, ag_secondallot ...@@ -408,9 +437,9 @@ private List<BodyItem> GetEmployees(List<per_employee> employees, ag_secondallot
employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Trim() == jobNumber.Trim()).ToList(); employees = employees?.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber) && w.PersonnelNumber.Trim() == jobNumber.Trim()).ToList();
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3);
Func<per_employee, decimal?> getAprAmount = (t) => second.Department == t.AccountingUnit ? perapramounts Func<per_employee, decimal?> getAprAmount = (t) => second.Department == t.AccountingUnit && second.UnitType == t.UnitType
?.Where(w => w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim()) ? perapramounts?.Where(w => w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim())?.Sum(w => w.Amount)
?.Sum(w => w.Amount) : 0; : 0;
Dictionary<(string, string), Func<per_employee, object>> dict = new Dictionary<(string, string), Func<per_employee, object>> Dictionary<(string, string), Func<per_employee, object>> dict = new Dictionary<(string, string), Func<per_employee, object>>
{ {
...@@ -512,14 +541,14 @@ private List<BodyItem> GetBringItems(UseTempRequest request, List<HeadItem> head ...@@ -512,14 +541,14 @@ private List<BodyItem> GetBringItems(UseTempRequest request, List<HeadItem> head
var bringhead = headItems.Where(t => t.IsBring == 1).ToList(); var bringhead = headItems.Where(t => t.IsBring == 1).ToList();
if (bringhead != null && bringhead.Count > 0) if (bringhead != null && bringhead.Count > 0)
{ {
var allotIds = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID); var allotIds = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(a => a.ID);
var secondIdList = perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value) var secondIdList = agsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value)
&& t.Department == request.Department && t.UnitType == request.UnitType) && t.Department == request.Department && t.UnitType == request.UnitType)
.OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList(); .OrderBy(t => t.Year).ThenBy(t => t.Month).Select(t => t.Id).ToList();
var index = secondIdList.IndexOf(request.SecondId); var index = secondIdList.IndexOf(request.SecondId);
var fixatList = new List<ag_fixatitem>(); var fixatList = new List<ag_fixatitem>();
if (index != 0) if (index != 0)
fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1) fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == secondIdList.ElementAt(index - 1)
&& t.RowNumber.HasValue && t.RowNumber != -1 && bringhead.Select(s => s.FiledName).Contains(t.ItemName)); && t.RowNumber.HasValue && t.RowNumber != -1 && bringhead.Select(s => s.FiledName).Contains(t.ItemName));
if (fixatList != null && fixatList.Any()) if (fixatList != null && fixatList.Any())
...@@ -537,7 +566,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems) ...@@ -537,7 +566,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
{ {
if (bodyItems == null || !bodyItems.Any()) return; if (bodyItems == null || !bodyItems.Any()) return;
var account = perforResaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.AccountingUnit == second.Department && ((UnitType)t.UnitType).ToString() == second.UnitType); var account = resaccountRepository.GetEntity(t => t.AllotID == second.AllotId && t.AccountingUnit == second.Department && ((UnitType)t.UnitType).ToString() == second.UnitType);
var keyValue = new Dictionary<string, string> var keyValue = new Dictionary<string, string>
{ {
...@@ -559,7 +588,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems) ...@@ -559,7 +588,7 @@ private void FillData(ag_secondallot second, List<BodyItem> bodyItems)
{ "职称绩效", "年资职称绩效占比" }, { "职称绩效", "年资职称绩效占比" },
{ "工作量绩效", "工作量绩效占比" }, { "工作量绩效", "工作量绩效占比" },
}; };
var config = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId); var config = cofagainRepository.GetEntities(t => t.AllotID == second.AllotId);
if (config != null && config.Any()) if (config != null && config.Any())
{ {
foreach (var item in config) foreach (var item in config)
...@@ -619,7 +648,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -619,7 +648,7 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
var headerItems = new List<HeadItem>(); var headerItems = new List<HeadItem>();
var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType; var unit = second.UnitType == UnitType.医技组.ToString() ? UnitType.医生组.ToString() : second.UnitType;
var deptHeader = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit); var deptHeader = agworkloadtypeRepository.GetEntities(t => request.HospitalId == t.HospitalId && t.Department == second.Department && t.UnitType == unit);
if (deptHeader != null && deptHeader.Any()) if (deptHeader != null && deptHeader.Any())
{ {
int sortindex = 1; int sortindex = 1;
...@@ -635,7 +664,6 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -635,7 +664,6 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
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++;
} }
...@@ -643,19 +671,17 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -643,19 +671,17 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
} }
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;
}); });
} }
...@@ -684,11 +710,11 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul ...@@ -684,11 +710,11 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
/// <returns></returns> /// <returns></returns>
public bool SaveValue(List<ag_fixatitem> request, int secondId) public bool SaveValue(List<ag_fixatitem> request, int secondId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) if (second == null)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId); var fixatitems = agfixatitemRepository.GetEntities(t => t.SecondId == secondId);
#region old #region old
...@@ -717,16 +743,16 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId) ...@@ -717,16 +743,16 @@ public bool SaveValue(List<ag_fixatitem> request, int secondId)
//} //}
//else //else
// insert = request; // insert = request;
//result = perforAgfixatitemRepository.UpdateRange(update.ToArray()); //result = agfixatitemRepository.UpdateRange(update.ToArray());
//result = perforAgfixatitemRepository.AddRange(insert.ToArray()); //result = agfixatitemRepository.AddRange(insert.ToArray());
#endregion #endregion
bool result = false; bool result = false;
if (fixatitems != null && fixatitems.Any()) if (fixatitems != null && fixatitems.Any())
result = perforAgfixatitemRepository.RemoveRange(fixatitems.ToArray()); result = agfixatitemRepository.RemoveRange(fixatitems.ToArray());
result = perforAgfixatitemRepository.AddRange(request.ToArray()); result = agfixatitemRepository.AddRange(request.ToArray());
return result; return result;
} }
...@@ -745,9 +771,9 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -745,9 +771,9 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
{ {
if (oldFixatItems != null && oldFixatItems.Any()) if (oldFixatItems != null && oldFixatItems.Any())
{ {
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.ToArray()); result = agfixatitemRepository.RemoveRange(oldFixatItems.ToArray());
_logger.LogError($"删除二次分配录入数据:{oldFixatItems.Count()}"); logger.LogError($"删除二次分配录入数据:{oldFixatItems.Count()}");
_logger.LogError($"删除二次分配录入数据:{JsonHelper.Serialize(oldFixatItems.Select(w => w.ID))}"); logger.LogError($"删除二次分配录入数据:{JsonHelper.Serialize(oldFixatItems.Select(w => w.ID))}");
} }
return result; return result;
} }
...@@ -766,8 +792,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -766,8 +792,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
{ {
var delData = oldFixatItems.Where(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID)); var delData = oldFixatItems.Where(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
int flag = oldFixatItems.RemoveAll(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID)); int flag = oldFixatItems.RemoveAll(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
_logger.LogError($"删除二次分配录入数据:{delData.Count()}"); logger.LogError($"删除二次分配录入数据:{delData.Count()}");
result = perforAgfixatitemRepository.RemoveRange(delData.ToArray()); result = agfixatitemRepository.RemoveRange(delData.ToArray());
} }
// 删除行号不存在的数据 // 删除行号不存在的数据
...@@ -775,8 +801,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -775,8 +801,8 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
var delRows = oldFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct().Except(saveRows); var delRows = oldFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct().Except(saveRows);
if (delRows != null && delRows.Count() > 0) if (delRows != null && delRows.Count() > 0)
{ {
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.Where(t => delRows.Contains(t.RowNumber)).ToArray()); result = agfixatitemRepository.RemoveRange(oldFixatItems.Where(t => delRows.Contains(t.RowNumber)).ToArray());
_logger.LogError($"删除二次分配录入数据 删除行号不存在的数据:{oldFixatItems.Count()}"); logger.LogError($"删除二次分配录入数据 删除行号不存在的数据:{oldFixatItems.Count()}");
} }
} }
...@@ -791,24 +817,24 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix ...@@ -791,24 +817,24 @@ public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fix
public bool SaveCompute(List<ag_compute> request) public bool SaveCompute(List<ag_compute> request)
{ {
var secondId = request.First().SecondId; var secondId = request.First().SecondId;
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) if (second == null)
throw new PerformanceException("二次绩效ID不存在"); throw new PerformanceException("二次绩效ID不存在");
if (second.Status == 2) if (second.Status == 2)
throw new PerformanceException("二次绩效已提交,无法重复提交"); throw new PerformanceException("二次绩效已提交,无法重复提交");
var compute = perforAgcomputeRepository.GetEntities(t => t.SecondId == secondId); var compute = agcomputeRepository.GetEntities(t => t.SecondId == secondId);
foreach (var item in request) foreach (var item in request)
{ {
if (compute != null && compute.Any(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName)) if (compute != null && compute.Any(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName))
{ {
var cellItem = compute.First(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName); var cellItem = compute.First(t => t.SecondId == secondId && t.Department == item.Department && t.PersonName == item.PersonName);
cellItem.RealGiveFee = item.RealGiveFee; cellItem.RealGiveFee = item.RealGiveFee;
perforAgcomputeRepository.Update(cellItem); agcomputeRepository.Update(cellItem);
} }
else else
{ {
perforAgcomputeRepository.Add(item); agcomputeRepository.Add(item);
} }
} }
return true; return true;
...@@ -825,7 +851,7 @@ public bool SaveCompute(List<ag_compute> request) ...@@ -825,7 +851,7 @@ public bool SaveCompute(List<ag_compute> request)
/// <returns></returns> /// <returns></returns>
public List<SecondTempResponse> GetTemp(int hospitalid, string department, int userId) public List<SecondTempResponse> GetTemp(int hospitalid, string department, int userId)
{ {
var temps = perforAgtempRepository.GetEntities(t => t.IsEnable == 1); var temps = agtempRepository.GetEntities(t => t.IsEnable == 1);
if (temps != null && temps.Any()) if (temps != null && temps.Any())
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
...@@ -843,7 +869,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -843,7 +869,7 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value)) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var useTemp = perforAgusetempRepository.GetEntity(exp); var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps); var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps);
if (useTemp != null) if (useTemp != null)
secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId); secondTemps.ForEach(t => t.IsSelected = t.Id == useTemp.UseTempId);
...@@ -860,17 +886,17 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -860,17 +886,17 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
public bool UseTemp(UseTempRequest request) public bool UseTemp(UseTempRequest request)
{ {
var result = false; var result = false;
var entity = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId var entity = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId
&& t.Department == request.Department && t.UnitType == request.UnitType); && t.Department == request.Department && t.UnitType == request.UnitType);
if (entity == null) if (entity == null)
{ {
entity = Mapper.Map<ag_usetemp>(request); entity = Mapper.Map<ag_usetemp>(request);
result = perforAgusetempRepository.Add(entity); result = agusetempRepository.Add(entity);
} }
else else
{ {
entity.UseTempId = request.TempId; entity.UseTempId = request.TempId;
result = perforAgusetempRepository.Update(entity); result = agusetempRepository.Update(entity);
if (result) if (result)
{ {
//获取固定模板列 + 工作量列 //获取固定模板列 + 工作量列
...@@ -879,17 +905,17 @@ public bool UseTemp(UseTempRequest request) ...@@ -879,17 +905,17 @@ public bool UseTemp(UseTempRequest request)
List<ag_fixatitem> list = new List<ag_fixatitem>(); List<ag_fixatitem> list = new List<ag_fixatitem>();
var addList = new List<ag_fixatitem>(); var addList = new List<ag_fixatitem>();
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == request.HospitalId); var allotList = perallotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var seconds = perforAgsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value) && new List<int> { 1, 4 }.Contains(t.Status ?? 1)); var seconds = agsecondallotRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotId.Value) && new List<int> { 1, 4 }.Contains(t.Status ?? 1));
var secondList = Mapper.Map<List<SecondListResponse>>(seconds); var secondList = Mapper.Map<List<SecondListResponse>>(seconds);
secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0); secondList?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
//获取未归档 未提交 驳回 的二次绩效 //获取未归档 未提交 驳回 的二次绩效
var secondId = secondList.Where(s => s.IsArchive == 0)?.Select(s => s.Id); var secondId = secondList?.Where(s => s.IsArchive == 0).Select(s => s.Id);
if (secondId == null || secondId.Count() <= 0) if (secondId == null || secondId.Count() <= 0)
return result; return result;
var fixatList = perforAgfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value)); var fixatList = agfixatitemRepository.GetEntities(t => secondId.Contains(t.SecondId.Value));
#region 获取需要添加的数据 无需操作的数据 #region 获取需要添加的数据 无需操作的数据
...@@ -909,7 +935,7 @@ public bool UseTemp(UseTempRequest request) ...@@ -909,7 +935,7 @@ public bool UseTemp(UseTempRequest request)
list.AddRange(exist); list.AddRange(exist);
else if (head.Type == 1) else if (head.Type == 1)
{ {
var configs = perforCofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>(); var configs = cofagainRepository.GetEntities(t => t.AllotID == second.AllotId && t.Department == request.Department) ?? new List<cof_again>();
addList.Add(new ag_fixatitem addList.Add(new ag_fixatitem
{ {
ItemName = head.FiledName, ItemName = head.FiledName,
...@@ -936,10 +962,10 @@ public bool UseTemp(UseTempRequest request) ...@@ -936,10 +962,10 @@ public bool UseTemp(UseTempRequest request)
//if (list != null && list.Count > 0) //if (list != null && list.Count > 0)
//{ //{
// var delList = fixatList.Except(list); // var delList = fixatList.Except(list);
// perforAgfixatitemRepository.RemoveRange(delList.Where(w => w.SecondId == request.SecondId).ToArray()); // agfixatitemRepository.RemoveRange(delList.Where(w => w.SecondId == request.SecondId).ToArray());
// if (addList != null && addList.Count > 0) // if (addList != null && addList.Count > 0)
// perforAgfixatitemRepository.AddRange(addList.ToArray()); // agfixatitemRepository.AddRange(addList.ToArray());
//} //}
} }
} }
...@@ -952,17 +978,17 @@ public bool UseTemp(UseTempRequest request) ...@@ -952,17 +978,17 @@ public bool UseTemp(UseTempRequest request)
/// <returns></returns> /// <returns></returns>
public void RefreshTemp(UseTempRequest request) public void RefreshTemp(UseTempRequest request)
{ {
var usetemp = perforAgusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); var usetemp = agusetempRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("参数usetempId 无效"); throw new PerformanceException("参数usetempId 无效");
//获取工作量列头 //获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == usetemp.HospitalId && t.Department == usetemp.Department && t.UnitType == usetemp.UnitType); var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == usetemp.HospitalId && t.Department == usetemp.Department && t.UnitType == usetemp.UnitType);
//获取固定模板列头 //获取固定模板列头
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == usetemp.UseTempId); var tempItem = agtempitemRepository.GetEntities(t => t.TempId == usetemp.UseTempId);
var tempHeader = workItem == null ? tempItem.Select(t => t.FiledName) : tempItem.Select(t => t.FiledName).Union(workItem?.Select(t => t.ItemName)); var tempHeader = workItem == null ? tempItem.Select(t => t.FiledName) : tempItem.Select(t => t.FiledName).Union(workItem?.Select(t => t.ItemName));
//获取数据 //获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId); var fixatList = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId);
if (fixatList == null || fixatList.Count == 0) if (fixatList == null || fixatList.Count == 0)
throw new PerformanceException("未录入数据"); throw new PerformanceException("未录入数据");
...@@ -972,12 +998,12 @@ public void RefreshTemp(UseTempRequest request) ...@@ -972,12 +998,12 @@ public void RefreshTemp(UseTempRequest request)
t.Sort = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.Sort; t.Sort = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.Sort;
t.FactorValue = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.FactorValue; t.FactorValue = workItem?.FirstOrDefault(w => w.ItemName == t.ItemName)?.FactorValue;
}); });
perforAgfixatitemRepository.UpdateRange(fixatList.ToArray()); agfixatitemRepository.UpdateRange(fixatList.ToArray());
//删除 列 不存在的数据 //删除 列 不存在的数据
var header = fixatList.Select(t => t.ItemName).Distinct(); var header = fixatList.Select(t => t.ItemName).Distinct();
var delItems = header.Except(tempHeader); var delItems = header.Except(tempHeader);
if (delItems != null && delItems.Count() > 0) if (delItems != null && delItems.Count() > 0)
perforAgfixatitemRepository.RemoveRange(fixatList.Where(t => delItems.Contains(t.ItemName)).ToArray()); agfixatitemRepository.RemoveRange(fixatList.Where(t => delItems.Contains(t.ItemName)).ToArray());
//添加 新增列 的数据 //添加 新增列 的数据
var addItems = new List<ag_fixatitem>(); var addItems = new List<ag_fixatitem>();
fixatList.Select(t => t.RowNumber).Distinct().ToList().ForEach(t => fixatList.Select(t => t.RowNumber).Distinct().ToList().ForEach(t =>
...@@ -996,7 +1022,7 @@ public void RefreshTemp(UseTempRequest request) ...@@ -996,7 +1022,7 @@ public void RefreshTemp(UseTempRequest request)
})); }));
}); });
if (addItems != null && addItems.Count() > 0) if (addItems != null && addItems.Count() > 0)
perforAgfixatitemRepository.AddRange(addItems.ToArray()); agfixatitemRepository.AddRange(addItems.ToArray());
} }
#endregion 模板 #endregion 模板
...@@ -1004,14 +1030,302 @@ public void RefreshTemp(UseTempRequest request) ...@@ -1004,14 +1030,302 @@ public void RefreshTemp(UseTempRequest request)
#region 工作量绩效配置 #region 工作量绩效配置
/// <summary> /// <summary>
/// 获取工作量类型列表
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId)
{
var (unit, dept) = GetDeptAndUnit(userId);
var worktypes = agworkloadtypeRepository.GetEntities(t => request.HospitalId.Value == t.HospitalId && t.Department == dept && t.UnitType == unit);
if (worktypes != null && worktypes.Any())
{
return worktypes.Select(t => new TitleValue<int>
{
Title = t.TypeName,
Value = t.Id
}).ToList();
}
return null;
}
/// <summary>
/// 保存工作量类型
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public ag_workload_type SaveWorkType(ag_workload_type request, int userId)
{
var (unit, dept) = GetDeptAndUnit(userId);
var entity = agworkloadtypeRepository.GetEntity(t => request.HospitalId == t.HospitalId && t.Department == dept && t.UnitType == unit && t.TypeName == request.TypeName);
if (entity == null)
{
if (request.Id > 0)
{
entity = agworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
entity.HospitalId = request.HospitalId;
entity.TypeName = request.TypeName;
agworkloadtypeRepository.Update(entity);
}
else
{
entity = new ag_workload_type
{
HospitalId = request.HospitalId,
TypeName = request.TypeName,
Department = dept,
UnitType = unit,
};
agworkloadtypeRepository.Add(entity);
}
AddWorkTypeDefaultHeadValue(request.HospitalId, entity);
AddWorkTypeDefaultValues(entity);
return entity;
}
else if (request.Id != entity.Id)
throw new PerformanceException("类型已存在");
else
return request;
}
/// <summary>
/// 添加工作量类型默认项工作量得分、考核得分、工作量绩效工资
/// </summary>
/// <param name="type"></param>
private void AddWorkTypeDefaultValues(ag_workload_type type)
{
var workItems = agworkloadRepository.GetEntities(t => t.WorkTypeId == type.Id);
List<(string, string, int)> addItems = new List<(string, string, int)>();
if (workItems != null && workItems.Any())
{
foreach (var item in defaultValues)
{
if (!workItems.Any(t => t.ItemId == $"{item.Item2}_{type.Id}"))
addItems.Add(item);
}
}
else
addItems = defaultValues;
if (addItems == null || !addItems.Any()) return;
var insertData = addItems.Select(t => new ag_workload
{
HospitalId = type.HospitalId,
Department = type.Department,
UnitType = type.UnitType,
ItemId = $"{t.Item2}_{type.Id}",
ItemName = t.Item1,
FactorValue = null,
Sort = 100 + t.Item3,
WorkTypeId = type.Id
});
agworkloadRepository.AddRange(insertData.ToArray());
}
/// <summary>
/// 添加工作量类型默认配置 - 顶部数据中的占比、金额
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="type"></param>
private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_workload_type type)
{
List<ag_worktype_source> insertData = new List<ag_worktype_source>();
var seconds = GetNotAuditSeconds(hospitalId, type);
if (seconds == null || !seconds.Any())
return;
var worktypeSources = agworktypesourceRepository.GetEntities(t => t.WorkTypeId == type.Id);
if (worktypeSources == null || !worktypeSources.Any())
{
insertData = seconds.Select(t => new ag_worktype_source
{
WorkTypeId = type.Id,
SecondId = t.Id,
FieldId = $"{AgWorkloadType.Workload}_Ratio_{type.Id}",
FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比"
}).ToList();
}
else
{
var existedSeconds = worktypeSources.Select(t => t.SecondId);
var except = seconds.Select(t => t.Id).Except(existedSeconds);
if (except != null && except.Any())
{
insertData = except.Select(t => new ag_worktype_source
{
WorkTypeId = type.Id,
SecondId = t,
FieldId = $"{AgWorkloadType.Workload}_Ratio_{type.Id}",
FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比"
}).ToList();
}
worktypeSources.ForEach(t =>
{
t.FieldName = type.TypeName + t.FieldName.Substring(t.FieldName.Length - 2);
});
agworktypesourceRepository.UpdateRange(worktypeSources.ToArray());
}
var amounts = insertData.Select(t => new ag_worktype_source
{
WorkTypeId = type.Id,
SecondId = t.SecondId,
FieldId = $"{AgWorkloadType.Workload.ToString()}_Amount_{type.Id}",
FieldName = t.FieldName.Substring(0, t.FieldName.Length - 2) + "金额"
}).ToList();
insertData.AddRange(amounts);
agworktypesourceRepository.AddRange(insertData.OrderBy(t => t.SecondId).ThenBy(t => t.FieldName).ToArray());
}
/// <summary>
/// 添加工作量类型默认配置 - 顶部数据中的占比、金额
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="second"></param>
private void AddWorkTypeDefaultHeadValue(int hospitalId, ag_secondallot second)
{
/**
*
* 二次绩效提交时,跳过该绩效新增工作量类型
* 防止在二次绩效审核期间新增工作量类型,进行数据补充
*
*/
if (second == null || IsAudit(second.Status)) return;
var worktypeSources = agworktypesourceRepository.GetEntities(t => t.SecondId == second.Id);
var worktypes = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (worktypes == null || !worktypes.Any())
{
if (worktypeSources != null && worktypeSources.Any())
agworktypesourceRepository.RemoveRange(worktypeSources.ToArray());
return;
}
List<ag_worktype_source> insertData = new List<ag_worktype_source>(), updateData = new List<ag_worktype_source>();
foreach (var type in worktypes)
{
var sources = worktypeSources?.Where(t => t.WorkTypeId == type.Id).ToList();
if (sources != null && sources.Any())
{
sources.ForEach(t => t.FieldName = type.TypeName + t.FieldName.Substring(t.FieldName.Length - 2));
updateData.AddRange(sources);
}
else
{
insertData.Add(new ag_worktype_source
{
WorkTypeId = type.Id,
SecondId = second.Id,
FieldId = $"{AgWorkloadType.Workload}_Ratio_{type.Id}",
FieldName = type.TypeName.EndsWith("占比") ? type.TypeName : type.TypeName + "占比"
});
}
}
if (insertData != null && insertData.Any())
{
var amounts = insertData.Select(t => new ag_worktype_source
{
WorkTypeId = t.WorkTypeId,
SecondId = second.Id,
FieldId = $"{AgWorkloadType.Workload}_Amount_{t.WorkTypeId}",
FieldName = t.FieldName.Substring(0, t.FieldName.Length - 2) + "金额"
}).ToList();
insertData.AddRange(amounts);
agworktypesourceRepository.AddRange(insertData.OrderBy(t => t.WorkTypeId).ThenBy(t => t.FieldName).ToArray());
}
if (updateData != null && updateData.Any())
{
agworktypesourceRepository.UpdateRange(updateData.ToArray());
}
}
/// <summary>
/// 检查默认工作量项是否已添加,添加默认的工作量得分、考核得分、工作量绩效工资
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="department"></param>
/// <param name="unitType"></param>
private void CheckDefaultWorkload(int hospitalId, string department, string unitType)
{
var workloads = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
List<(string, string, int)> addItems = new List<(string, string, int)>();
if (workloads != null && workloads.Any())
{
foreach (var item in defaultValues)
{
if (!workloads.Any(t => t.ItemId == item.Item2 + "_Default"))
addItems.Add(item);
}
}
else
addItems = defaultValues;
if (addItems == null || !addItems.Any()) return;
var insertData = addItems.Select(t => new ag_workload
{
HospitalId = hospitalId,
Department = department,
UnitType = unitType,
ItemId = t.Item2 + "_Default",
ItemName = t.Item1,
FactorValue = null,
Sort = 100 + t.Item3,
WorkTypeId = (int)AgWorkloadType.Workload
});
agworkloadRepository.AddRange(insertData.ToArray());
}
internal static List<(string, string, int)> defaultValues = new List<(string, string, int)>
{
( "工作量得分", "WorkloadScore" , 1 ),
( "考核得分", "AssessmentScore", 2 ),
( "工作量绩效工资", "WorkPerformance", 3 )
};
/// <summary>
/// 删除工作量类型
/// </summary>
/// <param name="secondId"></param>
/// <returns></returns>
public bool DeleteWorkType(WorkloadRequest request)
{
var entity = agworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
if (entity != null)
{
var items = agworkloadRepository.GetEntities(t => t.WorkTypeId == request.Id);
if (items != null && items.Any())
agworkloadRepository.RemoveRange(items.ToArray());
var seconds = GetNotAuditSeconds(entity.HospitalId, entity);
if (seconds != null && seconds.Any())
{
// 删除未提交驳回的二次绩效的数据
var sources = agworktypesourceRepository.GetEntities(t => t.WorkTypeId == request.Id && seconds.Select(w => w.Id).Contains(t.SecondId));
if (sources != null && sources.Any())
agworktypesourceRepository.RemoveRange(sources.ToArray());
}
return agworkloadtypeRepository.Remove(entity);
}
else
return false;
}
/// <summary>
/// 获取工作量列表 /// 获取工作量列表
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="secondId"></param>
/// <returns></returns> /// <returns></returns>
public List<ag_workload> GetWorkloadList(WorkloadRequest request) public List<ag_workload> GetWorkloadList(WorkloadRequest request)
{ {
return perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department return agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
&& t.UnitType == request.UnitType && t.WorkTypeId != (int)AgWorkloadType.SingleAwards); && t.UnitType == request.UnitType && t.ItemId.StartsWith($"{AgWorkloadType.Workload}_"));
} }
/// <summary> /// <summary>
...@@ -1021,7 +1335,7 @@ public List<ag_workload> GetWorkloadList(WorkloadRequest request) ...@@ -1021,7 +1335,7 @@ public List<ag_workload> GetWorkloadList(WorkloadRequest request)
/// <returns></returns> /// <returns></returns>
public bool WorkloadAdd(WorkloadRequest request) public bool WorkloadAdd(WorkloadRequest request)
{ {
var workloadList = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); var workloadList = agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.ItemName == request.ItemName)) if (workloadList != null && workloadList.Any(t => t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复"); throw new PerformanceException("项目名称重复");
ag_workload workload = new ag_workload ag_workload workload = new ag_workload
...@@ -1032,13 +1346,13 @@ public bool WorkloadAdd(WorkloadRequest request) ...@@ -1032,13 +1346,13 @@ public bool WorkloadAdd(WorkloadRequest request)
FactorValue = request.FactorValue ?? 1, FactorValue = request.FactorValue ?? 1,
ItemName = request.ItemName, ItemName = request.ItemName,
Sort = request.Sort ?? 1, Sort = request.Sort ?? 1,
WorkTypeId = request.WorkTypeId, WorkTypeId = request.IsSingleAwards ? (int)AgWorkloadType.SingleAwards : request.WorkTypeId
}; };
var result = perforAgworkloadRepository.Add(workload); var result = agworkloadRepository.Add(workload);
if (result) if (result)
{ {
workload.ItemId = $"Feild{workload.Id}"; workload.ItemId = getWorkloadItemId.Invoke(request.IsSingleAwards, request.WorkTypeId, workload.Id);
perforAgworkloadRepository.Update(workload); agworkloadRepository.Update(workload);
} }
return result; return result;
...@@ -1051,7 +1365,7 @@ public bool WorkloadAdd(WorkloadRequest request) ...@@ -1051,7 +1365,7 @@ public bool WorkloadAdd(WorkloadRequest request)
/// <returns></returns> /// <returns></returns>
public bool WorkloadUpdate(WorkloadRequest request) public bool WorkloadUpdate(WorkloadRequest request)
{ {
var workloadList = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType); var workloadList = agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workloadList != null && workloadList.Any(t => t.Id != request.Id && t.ItemName == request.ItemName)) if (workloadList != null && workloadList.Any(t => t.Id != request.Id && t.ItemName == request.ItemName))
throw new PerformanceException("项目名称重复"); throw new PerformanceException("项目名称重复");
...@@ -1062,111 +1376,71 @@ public bool WorkloadUpdate(WorkloadRequest request) ...@@ -1062,111 +1376,71 @@ public bool WorkloadUpdate(WorkloadRequest request)
workload.FactorValue = request.FactorValue; workload.FactorValue = request.FactorValue;
workload.ItemName = request.ItemName; workload.ItemName = request.ItemName;
workload.Sort = request.Sort; workload.Sort = request.Sort;
workload.ItemId = $"Feild{workload.Id}"; workload.ItemId = getWorkloadItemId.Invoke(request.IsSingleAwards, request.WorkTypeId, workload.Id); ;
workload.WorkTypeId = request.WorkTypeId; workload.WorkTypeId = request.IsSingleAwards ? (int)AgWorkloadType.SingleAwards : request.WorkTypeId;
return perforAgworkloadRepository.Update(workload); return agworkloadRepository.Update(workload);
} }
/// <summary> /// <summary>
/// 删除工作量绩效配置 /// 获取工作量绩效配置的ItemId
/// </summary> /// </summary>
/// <param name="id"></param> readonly Func<bool, int, int, string> getWorkloadItemId = (isSingleAwards, workTypeId, workloadId) =>
/// <returns></returns> {
public bool WorkloadDelete(int id) /**
* 单项奖励 - SingleAwards_WorkloadId
* 默认工作量类型WorkTypeId=0 - Workload_Default_WorkloadId
* 自定义工作量类型WorkTypeId>0 - Workload_WorkTypeId_WorkloadId
*/
if (isSingleAwards)
return $"{AgWorkloadType.SingleAwards}_{workloadId}";
else
{ {
var workload = perforAgworkloadRepository.GetEntity(t => t.Id == id); return workTypeId == (int)AgWorkloadType.Workload ? $"{AgWorkloadType.Workload}_Default_{workloadId}"
return perforAgworkloadRepository.Remove(workload); : $"{AgWorkloadType.Workload}_{workTypeId}_{workloadId}";
} }
};
/// <summary> /// <summary>
/// 获取单行奖励列表 /// 获取等待提交或驳回的二次绩效(同一医院同一科室)
/// </summary> /// </summary>
/// <param name="secondId"></param> private List<ag_secondallot> GetNotAuditSeconds(int hospitalId, ag_workload_type type)
/// <returns></returns>
public List<ag_workload> GetSingleList(WorkloadRequest request)
{ {
return perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department List<ag_secondallot> seconds = new List<ag_secondallot>();
&& t.UnitType == request.UnitType && t.WorkTypeId == (int)AgWorkloadType.SingleAwards); var allots = perallotRepository.GetEntities(t => t.HospitalId == hospitalId);
} if (allots == null || !allots.Any()) return seconds;
/// <summary> /**
/// 获取工作量类型列表 * 添加数据时注意避免给已经提交过的数据添加,否则会造成提交时的数据和显示数据不一致
/// </summary> */
/// <param name="secondId"></param> return agsecondallotRepository.GetEntities(t => allots.Select(w => w.ID).Contains(t.AllotId.Value) && t.Department == type.Department && t.UnitType == type.UnitType && IsAudit(t.Status)) ?? seconds;
/// <returns></returns>
public List<TitleValue<int>> WorkTypeList(WorkloadRequest request, int userId)
{
var (unit, dept) = GetDeptAndUnit(userId);
var worktypes = perforAgworkloadtypeRepository.GetEntities(t => request.HospitalId.Value == t.HospitalId && t.Department == dept && t.UnitType == unit);
if (worktypes != null && worktypes.Any())
{
return worktypes.Select(t => new TitleValue<int>
{
Title = t.TypeName,
Value = t.Id
}).ToList();
}
return null;
} }
/// <summary> /// <summary>
/// 保存工作量类型 /// 删除工作量绩效配置
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
public ag_workload_type SaveWorkType(ag_workload_type request, int userId) public bool WorkloadDelete(int id)
{
var (unit, dept) = GetDeptAndUnit(userId);
var entity = perforAgworkloadtypeRepository.GetEntity(t => request.HospitalId == t.HospitalId && t.Department == dept && t.UnitType == unit && t.TypeName == request.TypeName);
if (entity == null)
{
if (request.Id > 0)
{
entity = perforAgworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
entity.HospitalId = request.HospitalId;
entity.TypeName = request.TypeName;
perforAgworkloadtypeRepository.Update(entity);
}
else
{
entity = new ag_workload_type
{ {
HospitalId = request.HospitalId, var workload = agworkloadRepository.GetEntity(t => t.Id == id);
TypeName = request.TypeName, return agworkloadRepository.Remove(workload);
Department = dept,
UnitType = unit,
};
perforAgworkloadtypeRepository.Add(entity);
}
return entity;
}
else if (request.Id != entity.Id)
throw new PerformanceException("类型已存在");
else
return request;
} }
/// <summary> /// <summary>
/// 获取工作量类型列表 /// 获取单行奖励列表
/// </summary> /// </summary>
/// <param name="secondId"></param> /// <param name="secondId"></param>
/// <returns></returns> /// <returns></returns>
public bool DeleteWorkType(WorkloadRequest request) public List<ag_workload> GetSingleList(WorkloadRequest request)
{
var entity = perforAgworkloadtypeRepository.GetEntity(t => t.Id == request.Id);
if (entity != null)
{ {
return perforAgworkloadtypeRepository.Remove(entity); return agworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department
} && t.UnitType == request.UnitType && t.ItemId.StartsWith(AgWorkloadType.SingleAwards.ToString()));
else
return false;
} }
public (string, string) GetDeptAndUnit(int userId) public (string, string) GetDeptAndUnit(int userId)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
...@@ -1193,11 +1467,17 @@ public bool DeleteWorkType(WorkloadRequest request) ...@@ -1193,11 +1467,17 @@ public bool DeleteWorkType(WorkloadRequest request)
/// <returns></returns> /// <returns></returns>
public List<ag_secondallot> AuditList(int allotId) public List<ag_secondallot> AuditList(int allotId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) if (allot == null)
throw new PerformanceException("所选绩效不存在!"); throw new PerformanceException("所选绩效不存在!");
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && !new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 }.Contains(t.UnitType.Value)); var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政后勤 };
var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// 查询需要进行二次分配的行政后勤科室
var xzAccountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政后勤 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID); var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit); return SecondList(allot, accountUnit, specialunit);
...@@ -1215,7 +1495,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou ...@@ -1215,7 +1495,7 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou
temps.Add(new res_account { UnitType = (int)UnitType.特殊核算组, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee }); temps.Add(new res_account { UnitType = (int)UnitType.特殊核算组, AccountingUnit = w.AccountingUnit, RealGiveFee = w.RealGiveFee });
}); });
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month); var secondList = agsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
var result = temps.Select(t => var result = temps.Select(t =>
{ {
var second = secondList?.FirstOrDefault(f => f.UnitType == ((UnitType)t.UnitType).ToString() && f.Department == t.AccountingUnit); var second = secondList?.FirstOrDefault(f => f.UnitType == ((UnitType)t.UnitType).ToString() && f.Department == t.AccountingUnit);
...@@ -1245,11 +1525,11 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou ...@@ -1245,11 +1525,11 @@ private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accou
/// <returns></returns> /// <returns></returns>
public List<ag_secondallot> NursingDeptlist(int allotId) public List<ag_secondallot> NursingDeptlist(int allotId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) if (allot == null)
throw new PerformanceException("所选绩效不存在!"); throw new PerformanceException("所选绩效不存在!");
var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 }; var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 };
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value)); var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value));
var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID); var specialunit = resspecialunitRepository.GetEntities(t => t.AllotID == allot.ID);
return SecondList(allot, accountUnit, specialunit); return SecondList(allot, accountUnit, specialunit);
} }
...@@ -1262,7 +1542,7 @@ public List<ag_secondallot> NursingDeptlist(int allotId) ...@@ -1262,7 +1542,7 @@ public List<ag_secondallot> NursingDeptlist(int allotId)
/// <returns></returns> /// <returns></returns>
public bool AuditSubmit(ag_secondallot second, int userId) public bool AuditSubmit(ag_secondallot second, int userId)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == second.AllotId); var allot = perallotRepository.GetEntity(t => t.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("二次绩效无效!"); throw new PerformanceException("二次绩效无效!");
...@@ -1281,39 +1561,45 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1281,39 +1561,45 @@ public bool AuditSubmit(ag_secondallot second, int userId)
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value)) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
var temp = perforAgusetempRepository.GetEntity(exp); var temp = agusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!"); throw new PerformanceException("选择模板不可用,请确定模板及数据是否存在!");
bool method(decimal? submitDataAmount, decimal? realGiveFee) //bool method(decimal? submitDataAmount, decimal? realGiveFee)
{ //{
if (!submitDataAmount.HasValue || !realGiveFee.HasValue) // if (!submitDataAmount.HasValue || !realGiveFee.HasValue)
return false; // return false;
decimal floatValue = 0.5m; // decimal floatValue = 0.5m;
return submitDataAmount >= (realGiveFee - floatValue) && submitDataAmount <= (realGiveFee + floatValue); // return submitDataAmount >= (realGiveFee - floatValue) && submitDataAmount <= (realGiveFee + floatValue);
} //}
if (temp.UseTempId == 6) if (temp.UseTempId == 6)
{ {
var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == second.Id); var data = agothersourceRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
var total = data.Sum(t => t.RealAmount); //var total = data.Sum(t => t.RealAmount);
if (!method(total, second.RealGiveFee)) //if (!method(total, second.RealGiveFee))
throw new PerformanceException("总金额与考核后金额不一致!"); // throw new PerformanceException("总金额与考核后金额不一致!");
} }
else else if (new int[] { 7, 8 }.Contains(temp.UseTempId.Value))
{ {
var data = perforAgfixatitemRepository.GetEntities(t => t.SecondId == second.Id); var data = agfixatitemRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any()) if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
var total = data.Where(t => t.ItemName == "实发绩效工资金额" && t.RowNumber > -1).GroupBy(t => t.RowNumber) //var total = data.Where(t => t.ItemName == "实发绩效工资金额" && t.RowNumber > -1).GroupBy(t => t.RowNumber)
.Sum(t => ConvertHelper.To<decimal>(t.OrderByDescending(o => o.ID).FirstOrDefault().ItemValue)); // .Sum(t => ConvertHelper.To<decimal>(t.OrderByDescending(o => o.ID).FirstOrDefault().ItemValue));
if (!method(total, second.RealGiveFee)) //if (!method(total, second.RealGiveFee))
throw new PerformanceException("总金额与考核后金额不一致!"); // throw new PerformanceException("总金额与考核后金额不一致!");
}
else if (new int[] { 9, 10 }.Contains(temp.UseTempId.Value))
{
var data = agbodysourceRepository.GetEntities(t => t.SecondId == second.Id);
if (data == null || !data.Any())
throw new PerformanceException("提交时未检测到数据!");
} }
second.UseTempId = temp.UseTempId; second.UseTempId = temp.UseTempId;
second.Status = 2; second.Status = 2;
...@@ -1321,7 +1607,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1321,7 +1607,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
second.SubmitType = temp.UseTempId == 6 ? 2 : 1; second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now; second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中"; //second.Remark = "已提交审核,等待审核中";
return perforAgsecondallotRepository.Update(second); return agsecondallotRepository.Update(second);
} }
/// <summary> /// <summary>
...@@ -1333,7 +1619,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee) ...@@ -1333,7 +1619,7 @@ bool method(decimal? submitDataAmount, decimal? realGiveFee)
/// <returns></returns> /// <returns></returns>
public bool ConfirmAudit(int userId, SecondAuditRequest request) public bool ConfirmAudit(int userId, SecondAuditRequest request)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
//if (second.Status != 2) //if (second.Status != 2)
// throw new PerformanceException("该绩效未提交至审核,请确认"); // throw new PerformanceException("该绩效未提交至审核,请确认");
...@@ -1354,19 +1640,19 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1354,19 +1640,19 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
//{ //{
// second.Remark = request.IsPass == 1 ? "审核通过" : "驳回"; // second.Remark = request.IsPass == 1 ? "审核通过" : "驳回";
//} //}
var result = perforAgsecondallotRepository.Update(second); var result = agsecondallotRepository.Update(second);
// 无论驳回还是通过,都需要清空该科室历史数据 // 无论驳回还是通过,都需要清空该科室历史数据
var histories = perforAgcomputeRepository.GetEntities(w => w.SecondId == request.SecondId); var histories = agcomputeRepository.GetEntities(w => w.SecondId == request.SecondId);
if (histories != null && histories.Any()) if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray()); agcomputeRepository.RemoveRange(histories.ToArray());
#region 添加至二次绩效汇总 #region 添加至二次绩效汇总
if (result && request.IsPass == 1) if (result && request.IsPass == 1)
{ {
// 护理部审核 // 护理部审核
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) return true; if (allot == null) return true;
var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId); var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
...@@ -1376,9 +1662,12 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1376,9 +1662,12 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
return true; return true;
var computes = new List<ag_compute>(); var computes = new List<ag_compute>();
if (second.SubmitType == 1)
var (tempId, name) = GetUsingTempId(hospital.ID, second);
if (new int[] { (int)Temp.crosswise, (int)Temp.lengthways }.Contains(tempId))
{ {
var items = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId); var items = agfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId);
if (items != null && items.Any()) if (items != null && items.Any())
{ {
var rowNumbers = items.Select(t => t.RowNumber).Where(t => t >= 0)?.Distinct(); var rowNumbers = items.Select(t => t.RowNumber).Where(t => t >= 0)?.Distinct();
...@@ -1406,9 +1695,9 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1406,9 +1695,9 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
} }
} }
} }
else if (second.SubmitType == 2) else if (tempId == (int)Temp.other)
{ {
var others = perforAgothersourceRepository.GetEntities(t => t.SecondId == request.SecondId); var others = agothersourceRepository.GetEntities(t => t.SecondId == request.SecondId);
if (others != null && others.Any()) if (others != null && others.Any())
{ {
foreach (var item in others) foreach (var item in others)
...@@ -1430,7 +1719,31 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1430,7 +1719,31 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
} }
} }
} }
perforAgcomputeRepository.AddRange(computes.ToArray()); else
{
var bodys = agbodysourceRepository.GetEntities(t => t.SecondId == request.SecondId);
if (bodys != null && bodys.Any())
{
foreach (var item in bodys)
{
computes.Add(new ag_compute
{
AllotId = second.AllotId,
SecondId = second.Id,
UnitType = second.UnitType,
Department = second.Department,
WorkPost = item.Post,
JobNumber = item.WorkNumber,
PersonName = item.Name,
PerforSumFee = item.DistPerformance,
OthePerfor = item.OtherPerformance,
NightWorkPerfor = item.NightWorkPerformance,
RealGiveFee = item.RealAmount,
});
}
}
}
agcomputeRepository.AddRange(computes.ToArray());
} }
#endregion 添加至二次绩效汇总 #endregion 添加至二次绩效汇总
...@@ -1447,7 +1760,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request) ...@@ -1447,7 +1760,7 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
/// <returns></returns> /// <returns></returns>
public bool NursingDeptAudit(int userId, SecondAuditRequest request) public bool NursingDeptAudit(int userId, SecondAuditRequest request)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("二次分配绩效无效"); throw new PerformanceException("二次分配绩效无效");
if (request.IsPass == 1) if (request.IsPass == 1)
...@@ -1464,7 +1777,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request) ...@@ -1464,7 +1777,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request)
second.NursingDeptAuditUser = userId; second.NursingDeptAuditUser = userId;
second.NursingDeptAuditTime = DateTime.Now; second.NursingDeptAuditTime = DateTime.Now;
return perforAgsecondallotRepository.Update(second); return agsecondallotRepository.Update(second);
} }
#endregion 二次绩效考核 #endregion 二次绩效考核
...@@ -1478,7 +1791,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request) ...@@ -1478,7 +1791,7 @@ public bool NursingDeptAudit(int userId, SecondAuditRequest request)
/// <returns></returns> /// <returns></returns>
public ag_secondallot GetSecondallot(int secondId) public ag_secondallot GetSecondallot(int secondId)
{ {
return perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); return agsecondallotRepository.GetEntity(t => t.Id == secondId);
} }
/// <summary> /// <summary>
...@@ -1491,18 +1804,18 @@ public ag_secondallot GetSecondallot(int secondId) ...@@ -1491,18 +1804,18 @@ public ag_secondallot GetSecondallot(int secondId)
/// <returns></returns> /// <returns></returns>
public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department, string unitType) public List<HeadItem> GetHeadItems(int tempId, int hospitalId, string department, string unitType)
{ {
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == tempId); var tempItem = agtempitemRepository.GetEntities(t => t.TempId == tempId);
var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>(); var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
var temp = perforAgtempRepository.GetEntity(w => w.Id == tempId); var temp = agtempRepository.GetEntity(w => w.Id == tempId);
// 其他来源不考虑工作量 // 其他来源不考虑工作量
if (temp?.Id == 6) if (temp?.Id == 6)
return headItems; return headItems;
//获取工作量列头 //获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType); var workItem = agworkloadRepository.GetEntities(t => t.HospitalId == hospitalId && t.Department == department && t.UnitType == unitType);
if (workItem != null && workItem.Count > 0) if (workItem != null && workItem.Count > 0)
{ {
var workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards)); var workDtos = Mapper.Map<List<HeadItem>>(workItem.Where(t => t.WorkTypeId != (int)AgWorkloadType.SingleAwards));
...@@ -1553,14 +1866,14 @@ public List<BodyItem> GetBodyItems(List<HeadItem> headItems, int source, List<co ...@@ -1553,14 +1866,14 @@ public List<BodyItem> GetBodyItems(List<HeadItem> headItems, int source, List<co
public List<ag_othersource> OtherList(int secondId, int userId) public List<ag_othersource> OtherList(int secondId, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) throw new PerformanceException("二次绩效信息无效!"); if (second == null) throw new PerformanceException("二次绩效信息无效!");
var employees = personService.GetPersons(second.AllotId.Value, userId); var employees = personService.GetPersons(second.AllotId.Value, userId);
employees = employees?.Where(t => t.UnitType == second.UnitType).ToList(); employees = employees?.Where(t => t.UnitType == second.UnitType).ToList();
List<ag_othersource> result = null; List<ag_othersource> result = null;
var otherSecondList = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var otherSecondList = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (otherSecondList != null && otherSecondList.Any()) if (otherSecondList != null && otherSecondList.Any())
{ {
result = otherSecondList.OrderBy(t => t.Id).ToList(); result = otherSecondList.OrderBy(t => t.Id).ToList();
...@@ -1592,15 +1905,15 @@ public List<ag_othersource> OtherList(int secondId, int userId) ...@@ -1592,15 +1905,15 @@ public List<ag_othersource> OtherList(int secondId, int userId)
/// <returns></returns> /// <returns></returns>
public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId) public List<ag_othersource> OtherAutoComplete(SecondEmpRequest request, int userId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId); var second = agsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null) if (second == null)
throw new PerformanceException("当前科室二次分配绩效信息无效"); throw new PerformanceException("当前科室二次分配绩效信息无效");
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效信息无效"); throw new PerformanceException("当前绩效信息无效");
var usetemp = perforAgusetempRepository.GetEntity( var usetemp = agusetempRepository.GetEntity(
t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType); t => t.HospitalId == allot.HospitalId && t.Department == second.Department && t.UnitType == second.UnitType);
if (usetemp == null) if (usetemp == null)
throw new PerformanceException("当前科室暂未配置绩效模板"); throw new PerformanceException("当前科室暂未配置绩效模板");
...@@ -1645,7 +1958,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -1645,7 +1958,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
// return; // return;
// 补充医院其他绩效 及 预留比例 // 补充医院其他绩效 及 预留比例
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3);
Func<per_employee, decimal?> getAprAmount = (t) => second.Department == t.AccountingUnit Func<per_employee, decimal?> getAprAmount = (t) => second.Department == t.AccountingUnit && second.UnitType == t.UnitType
? perapramounts?.Where(w => w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim())?.Sum(w => w.Amount) ? perapramounts?.Where(w => w.PersonnelNumber?.Trim() == t.PersonnelNumber?.Trim())?.Sum(w => w.Amount)
: 0; : 0;
...@@ -1671,7 +1984,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -1671,7 +1984,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount) public Dictionary<string, string> OtherListHeader(int secondId, decimal? amount)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) return new Dictionary<string, string>(); if (second == null) return new Dictionary<string, string>();
var keyValue = new Dictionary<string, string> var keyValue = new Dictionary<string, string>
...@@ -1686,40 +1999,26 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -1686,40 +1999,26 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request) public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request)
{ {
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); if (request == null || !request.Any()) return new List<ag_othersource>();
if (request.Any(t => t.Id != 0))
agothersourceRepository.UpdateRangeByState(request.Where(t => t.Id != 0));
var existEntities = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any()) if (existEntities != null && existEntities.Any())
{ {
foreach (var item in request.Where(t => t.Id != 0))
{
existEntities.First(t => t.Id == item.Id).WorkNumber = item.WorkNumber;
existEntities.First(t => t.Id == item.Id).Name = item.Name;
existEntities.First(t => t.Id == item.Id).Department = item.Department;
existEntities.First(t => t.Id == item.Id).WorkPost = item.WorkPost;
existEntities.First(t => t.Id == item.Id).TitlePerformance = item.TitlePerformance;
existEntities.First(t => t.Id == item.Id).WorkPerformance = item.WorkPerformance;
existEntities.First(t => t.Id == item.Id).DeptReward = item.DeptReward;
existEntities.First(t => t.Id == item.Id).DistPerformance = item.DistPerformance;
existEntities.First(t => t.Id == item.Id).OtherPerformance = item.OtherPerformance;
existEntities.First(t => t.Id == item.Id).NightWorkPerformance = item.NightWorkPerformance;
existEntities.First(t => t.Id == item.Id).RealAmount = item.RealAmount;
existEntities.First(t => t.Id == item.Id).ManagementAllowance = item.ManagementAllowance;
existEntities.First(t => t.Id == item.Id).IndividualReward = item.IndividualReward;
existEntities.First(t => t.Id == item.Id).AllocationOfKeySpecialty = item.AllocationOfKeySpecialty;
}
perforAgothersourceRepository.UpdateRange(existEntities.ToArray());
var delIds = existEntities.Select(t => t.Id).Except(request.Select(t => t.Id)); var delIds = existEntities.Select(t => t.Id).Except(request.Select(t => t.Id));
if (delIds != null) if (delIds != null)
perforAgothersourceRepository.RemoveRange(existEntities.Where(t => delIds.Contains(t.Id)).ToArray()); agothersourceRepository.RemoveRange(existEntities.Where(t => delIds.Contains(t.Id)).ToArray());
} }
var addEntities = request.Where(t => t.Id == 0).ToList(); var addEntities = request.Where(t => t.Id == 0).ToList();
if (addEntities != null && addEntities.Any()) if (addEntities != null && addEntities.Any())
{ {
addEntities.ForEach(t => t.SecondId = secondId); addEntities.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(addEntities.ToArray()); agothersourceRepository.AddRange(addEntities.ToArray());
} }
return perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); return agothersourceRepository.GetEntities(t => t.SecondId == secondId);
} }
public void OtherSave(int secondId, SaveCollectData collectData) public void OtherSave(int secondId, SaveCollectData collectData)
...@@ -1751,14 +2050,14 @@ public void OtherSave(int secondId, SaveCollectData collectData) ...@@ -1751,14 +2050,14 @@ public void OtherSave(int secondId, SaveCollectData collectData)
data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList(); data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList();
if (data == null || !data.Any()) return; if (data == null || !data.Any()) return;
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var existEntities = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any()) if (existEntities != null && existEntities.Any())
{ {
perforAgothersourceRepository.RemoveRange(existEntities.ToArray()); agothersourceRepository.RemoveRange(existEntities.ToArray());
} }
data.ForEach(t => t.SecondId = secondId); data.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(data.ToArray()); agothersourceRepository.AddRange(data.ToArray());
} }
#endregion 二次绩效其他来源 #endregion 二次绩效其他来源
...@@ -1767,10 +2066,10 @@ public void OtherSave(int secondId, SaveCollectData collectData) ...@@ -1767,10 +2066,10 @@ public void OtherSave(int secondId, SaveCollectData collectData)
public List<SecPrintResponse> Print(int secondId) public List<SecPrintResponse> Print(int secondId)
{ {
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId); var second = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null) return new List<SecPrintResponse>(); if (second == null) return new List<SecPrintResponse>();
//var computes = perforAgcomputeRepository.GetEntities(t => t.SecondId == secondId); //var computes = agcomputeRepository.GetEntities(t => t.SecondId == secondId);
//if (computes == null || !computes.Any()) //if (computes == null || !computes.Any())
// return new List<SecPrintResponse>(); // return new List<SecPrintResponse>();
...@@ -1778,7 +2077,7 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1778,7 +2077,7 @@ public List<SecPrintResponse> Print(int secondId)
if (isOtherTemp) if (isOtherTemp)
{ {
var data = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId); var data = agothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (data == null || !data.Any()) return new List<SecPrintResponse>(); if (data == null || !data.Any()) return new List<SecPrintResponse>();
var result = Mapper.Map<List<SecPrintResponse>>(data); var result = Mapper.Map<List<SecPrintResponse>>(data);
...@@ -1787,7 +2086,7 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1787,7 +2086,7 @@ public List<SecPrintResponse> Print(int secondId)
else else
{ {
var itemname = new List<string> { "人员工号", "姓名", "职称", "职称绩效", "工作量绩效工资", "单项奖励小计", "可分配绩效", "医院其他绩效", "夜班工作量绩效" }; var itemname = new List<string> { "人员工号", "姓名", "职称", "职称绩效", "工作量绩效工资", "单项奖励小计", "可分配绩效", "医院其他绩效", "夜班工作量绩效" };
var fixaitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId && itemname.Contains(t.ItemName)); var fixaitems = agfixatitemRepository.GetEntities(t => t.SecondId == secondId && itemname.Contains(t.ItemName));
if (fixaitems == null || !fixaitems.Any(t => t.RowNumber.HasValue && t.RowNumber != -1)) return new List<SecPrintResponse>(); if (fixaitems == null || !fixaitems.Any(t => t.RowNumber.HasValue && t.RowNumber != -1)) return new List<SecPrintResponse>();
...@@ -1819,64 +2118,64 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -1819,64 +2118,64 @@ public List<SecPrintResponse> Print(int secondId)
#endregion 打印 #endregion 打印
public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out int isShowManage) //public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId, out int isShowManage)
{ //{
var user = perforUserRepository.GetEntity(t => t.ID == userId); // var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) // if (user == null)
throw new NotImplementedException("人员ID无效"); // throw new NotImplementedException("人员ID无效");
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); // var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); // isShowManage = computeService.IsShowManage(allotId);
Dictionary<int, string> dict = new Dictionary<int, string>
{
{ application.DirectorRole, AccountUnitType.科主任.ToString() },
{ application.NurseRole, AccountUnitType.护士长.ToString() },
{ application.OfficeRole, AccountUnitType.行政中层.ToString() },
{ application.SpecialRole, AccountUnitType.科主任.ToString() },
};
if (!dict.Keys.Contains(role.Type.Value)) return new List<SecondPerforResponse>(); // var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
// var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
// Dictionary<int, string> dict = new Dictionary<int, string>
// {
// { application.DirectorRole, AccountUnitType.科主任.ToString() },
// { application.NurseRole, AccountUnitType.护士长.ToString() },
// { application.OfficeRole, AccountUnitType.行政中层.ToString() },
// { application.SpecialRole, AccountUnitType.科主任.ToString() },
// };
var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == user.Department && t.AccountType == dict[role.Type.Value]); // if (!dict.Keys.Contains(role.Type.Value)) return new List<SecondPerforResponse>();
if (computes == null || !computes.Any()) return new List<SecondPerforResponse>();
var data = GetAllotPerformance(allotId, computes, isShowManage); // var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == user.Department && t.AccountType == dict[role.Type.Value]);
// 补充医院其他绩效 // if (computes == null || !computes.Any()) return new List<SecondPerforResponse>();
var result = AddAprAmount(allotId, data);
// 预留比例 // var data = GetAllotPerformance(allotId, computes, isShowManage);
if (result != null) // // 补充医院其他绩效
{ // var result = AddAprAmount(allotId, data);
var empDic = peremployeeRepository.GetEntities(w => w.AllotId == allotId);
foreach (var item in result)
{
item.PerforSumFee = Math.Round(item.PerforSumFee ?? 0, 0, MidpointRounding.AwayFromZero);
item.PerforManagementFee = Math.Round(item.PerforManagementFee ?? 0, 0, MidpointRounding.AwayFromZero);
var real = Math.Round((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0), 0) * item.Adjust + (item.AdjustLaterOtherFee ?? 0);
item.OthePerfor = Math.Round(item.OthePerfor ?? 0, 0, MidpointRounding.AwayFromZero); // // 预留比例
item.NightWorkPerfor = Math.Round(item.NightWorkPerfor ?? 0, 0, MidpointRounding.AwayFromZero); // if (result != null)
item.ShouldGiveFee = Math.Round((real ?? 0) + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 0, MidpointRounding.AwayFromZero); // {
item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0; // var empDic = peremployeeRepository.GetEntities(w => w.AllotId == allotId);
item.ReservedRatioFee = Math.Round((real ?? 0) * (item.ReservedRatio ?? 0), 0, MidpointRounding.AwayFromZero); // foreach (var item in result)
item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 0, MidpointRounding.AwayFromZero); // {
} // item.PerforSumFee = Math.Round(item.PerforSumFee ?? 0, 0, MidpointRounding.AwayFromZero);
} // item.PerforManagementFee = Math.Round(item.PerforManagementFee ?? 0, 0, MidpointRounding.AwayFromZero);
// var real = Math.Round((item.PerforSumFee ?? 0) + (item.PerforManagementFee ?? 0), 0) * item.Adjust + (item.AdjustLaterOtherFee ?? 0);
// item.OthePerfor = Math.Round(item.OthePerfor ?? 0, 0, MidpointRounding.AwayFromZero);
// item.NightWorkPerfor = Math.Round(item.NightWorkPerfor ?? 0, 0, MidpointRounding.AwayFromZero);
// item.ShouldGiveFee = Math.Round((real ?? 0) + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 0, MidpointRounding.AwayFromZero);
// item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
// item.ReservedRatioFee = Math.Round((real ?? 0) * (item.ReservedRatio ?? 0), 0, MidpointRounding.AwayFromZero);
// item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 0, MidpointRounding.AwayFromZero);
// }
// }
return result; // return result;
} //}
public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage) public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
throw new NotImplementedException("人员ID无效"); throw new NotImplementedException("人员ID无效");
var deptDatas = new List<DeptDataDetails>(); var deptDatas = new List<DeptDataDetails>();
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId); isShowManage = computeService.IsShowManage(allotId);
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
...@@ -1895,6 +2194,9 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out ...@@ -1895,6 +2194,9 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
if (computes == null || !computes.Any()) return new List<DeptDataDetails>(); if (computes == null || !computes.Any()) return new List<DeptDataDetails>();
foreach (var item in computes) foreach (var item in computes)
{ {
if (item.AccountType==AccountUnitType.行政中层.ToString())
deptDatas.Add(computeService.GetAdministration(item.ID));
else
deptDatas.Add(computeService.GetDoctorDetail(item.ID)); deptDatas.Add(computeService.GetDoctorDetail(item.ID));
} }
return deptDatas; return deptDatas;
......
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