Commit f1f3a48d by lcx

Merge branch 'v2020morge-graphql' into v2020morge-signalr

# Conflicts:
#	performance/Performance.Api/wwwroot/Performance.EntityModels.xml
#	performance/Performance.Infrastructure/Performance.Infrastructure.csproj
parents ac1dbf9b d3cb8581
......@@ -297,14 +297,14 @@ public ApiResponse<UserResponse> Password(int userId)
#region 多角色
/// <summary>
/// 查询用户信息
/// </summary>
/// <returns></returns>
[Route("selfInfos")]
[HttpPost]
public ApiResponse SelfInfos()
public ApiResponse SelfInfos([FromBody] UserRequest request)
{
var userid = _claim.GetUserId();
var user = _userService.GetUser(userid);
......@@ -312,7 +312,10 @@ public ApiResponse SelfInfos()
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First(t=>t.RoleID==request.Role).Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user);
}
......@@ -345,7 +348,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUsersRole(userId);
//var roleType = roles.Select(c => c.Type).ToArray();
var intersect= roleArray.Intersect(roles.Select(c=>(int)c.Type).ToArray());
var intersect = roleArray.Intersect(roles.Select(c => (int)c.Type).ToArray());
var isAgainAdmin = roles != null ? intersect.Any() : false;
var user = _userService.UpdateUser(request, isAgainAdmin);
......@@ -364,7 +367,7 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
{
return _userService.DeleteUser(request.ID);
}
#endregion
}
}
\ No newline at end of file
......@@ -170,7 +170,19 @@ public ApiResponse Import([FromForm] IFormCollection form)
_configService.Clear(allot.ID);
}
return new ApiResponse(ResponseType.OK);
//var email = _claim.GetUserClaim(JwtClaimTypes.Mail);
//if (allot.States == (int)AllotStates.FileUploaded)
// _backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
// {
// using (var scope = _serviceScopeFactory.CreateScope())
// {
// var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
// scopedServices.Generate(allot, email);
// await Task.Delay(TimeSpan.FromSeconds(5), token);
// }
// });
return new ApiResponse(ResponseType.OK, true);
}
......
......@@ -258,7 +258,7 @@ public ConfigController(ConfigService configService, AllotService allotService)
[HttpPost]
public ApiResponse GetDrugtypeList([CustomizeValidator(RuleSet = "Select"), FromBody] DrugpropRequest request)
{
var list = _configService.GetDrugtypeList(request.AllotID);
var list = _configService.GetDrugtypeList(request.HospitalId,request.AllotID);
return new ApiResponse(ResponseType.OK, "ok", list);
}
......
using GraphQL;
using GraphQL.Types;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using System.Threading.Tasks;
namespace Performance.Api
{
[AllowAnonymous]
[Route("api/graphql")]
[ApiController]
public class GraphQLController : ControllerBase
{
public ISchema performanceSchema { get; }
public IDocumentExecuter documentExecuter { get; }
public ILogger logger { get; set; }
public GraphQLController(ISchema performanceSchema, IDocumentExecuter documentExecuter, ILogger<GraphQLController> logger)
{
this.performanceSchema = performanceSchema;
this.documentExecuter = documentExecuter;
this.logger = logger;
}
/// <summary>
/// GraphQL请求地址
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResponse> Post(GraphQLRequest query)
{
var result = await documentExecuter.ExecuteAsync(options =>
{
options.Schema = performanceSchema;
options.Query = query.Query;
});
if (result.Errors?.Count > 0)
{
return new ApiResponse(ResponseType.Error, result.Errors);
}
return new ApiResponse(ResponseType.OK, result.Data);
}
}
}
......@@ -51,7 +51,7 @@ public ApiResponse Rank([FromBody] HospitalIdRequest request)
public ApiResponse Selection([FromBody] SelectionRequest report)
{
var userId = claimService.GetUserId();
var result = reportDataService.GetReportSelection(report.GroupId, userId);
var result = reportDataService.GetReportSelection(report.GroupId, userId, report.HospitalId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -70,12 +70,12 @@ public ApiResponse Search([FromBody] SearchReportRequest report)
if (report.Values == null || !report.Values.Any())
return new ApiResponse(ResponseType.OK, new List<ReportData>());
string[] keys = new string[] { "year", "month", };
foreach (var item in report.Values.Where(t => keys.Contains(t.Title)))
{
if (item.Values == null || !item.Values.Any(t => !string.IsNullOrEmpty(t)))
return new ApiResponse(ResponseType.OK, new List<ReportData>());
}
//string[] keys = new string[] { "year", "month", };
//foreach (var item in report.Values.Where(t => keys.Contains(t.Title)))
//{
// if (item.Values == null || !item.Values.Any(t => !string.IsNullOrEmpty(t)))
// return new ApiResponse(ResponseType.OK, new List<ReportData>());
//}
var userId = claimService.GetUserId();
var result = reportDataService.GetReportData(report.HospitalId, report.GroupId, report.ReportId, report.Values ?? new List<SelectionValues>(), userId);
......
......@@ -97,6 +97,10 @@ public IActionResult DownFile(int type = 1)
case 5:
path = Path.Combine(env.ContentRootPath, "Template", "工作量数据导入模板.xlsx");
break;
case 6:
path = Path.Combine(env.ContentRootPath, "Template", "导入数据模板.xlsx");
break;
}
var memoryStream = new MemoryStream();
......@@ -181,7 +185,11 @@ public ApiResponse Prejudge([FromRoute] int allotId)
var data = configService.CheckHasNewDepartmentOrCategory(allotId);
return new ApiResponse(ResponseType.OK, new { haserror = (data != null && data.Any()), data });
}
return new ApiResponse(ResponseType.OK);
return new ApiResponse(ResponseType.OK, new
{
haserror = true,
data = new Dictionary<string, string> { { "未发现历史文件,是否直接上传", "" } }
});
}
/// <summary>
......
using GraphQL.Types;
using Performance.DtoModels;
namespace Performance.Api
{
public class ChartDataType : ObjectGraphType<ChartData>
{
public ChartDataType()
{
Field(x => x.X, nullable: true);
Field(x => x.Y, nullable: true);
Field(x => x.Name, nullable: true);
Field(x => x.Value, nullable: true);
Field(x => x.Total, nullable: true);
Field(x => x.Type, nullable: true);
}
}
}
using GraphQL;
using GraphQL.Types;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api
{
public static class GraphQLExtension
{
public static void AddGraphQLSchemaAndTypes(this IServiceCollection services)
{
services.AddScoped<ChartDataType>();
services.AddScoped<ReportDataType>();
services.AddScoped<ReportPerformanceType>();
services.AddScoped<PerformanceQuery>();
services.AddScoped<ISchema, PerformanceSchema>();
services.AddScoped<IDocumentExecuter, DocumentExecuter>();
services.AddScoped<IDependencyResolver>(provider => new FuncDependencyResolver
(
type => provider.GetRequiredService(type)
));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api
{
public class GraphQLRequest
{
public string Query { get; set; }
}
}
using Dapper;
using GraphQL.Types;
using Performance.DtoModels;
using Performance.Infrastructure;
using Performance.Services;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Performance.Api
{
public class PerformanceQuery : ObjectGraphType
{
public PerformanceQuery(GraphQLService service)
{
Field<ListGraphType<ReportDataType>>("info",
resolve: context =>
{
return service.GetReportsInfo();
}
);
Field<ReportDataType>("report",
arguments: new QueryArguments
(
new QueryArgument<IntGraphType>() { Name = QueryParams.reportId }
),
resolve: context =>
{
int reportId = context.Arguments.ContainsKey(QueryParams.reportId)
? ConvertHelper.To<int>(context.Arguments[QueryParams.reportId])
: 0;
return service.GetReport(reportId);
}
);
Field<ListGraphType<ChartDataType>>("chartdata",
arguments: Arguments(
new QueryArgument<StringGraphType>() { Name = QueryParams.accountingUnit }
),
resolve: context =>
{
int reportId = context.Arguments.ContainsKey(QueryParams.reportId)
? ConvertHelper.To<int>(context.Arguments[QueryParams.reportId])
: 0;
var parameters = GetDynamicParameters(context.Arguments, QueryParams.hospitalId, QueryParams.year, QueryParams.month, QueryParams.accountingUnit);
return service.GetChartData(reportId, parameters);
}
);
Field<ListGraphType<ReportPerformanceType>>("performances",
arguments: Arguments(
new QueryArgument<StringGraphType>() { Name = QueryParams.accountingUnit },
new QueryArgument<StringGraphType>() { Name = QueryParams.category },
new QueryArgument<StringGraphType>() { Name = QueryParams.itemName }
),
resolve: context =>
{
int reportId = context.Arguments.ContainsKey(QueryParams.reportId)
? ConvertHelper.To<int>(context.Arguments[QueryParams.reportId])
: 0;
var parameters = GetDynamicParameters(context.Arguments, QueryParams.hospitalId, QueryParams.year, QueryParams.month, QueryParams.accountingUnit, QueryParams.category, QueryParams.itemName);
return service.GetReportPerformance(reportId, parameters);
}
);
}
public static QueryArguments Arguments(params QueryArgument[] args)
{
var basic = new QueryArguments
{
new QueryArgument<IntGraphType>() { Name = QueryParams.reportId },
new QueryArgument<IntGraphType>() { Name = QueryParams.hospitalId },
new QueryArgument<IntGraphType>() { Name = QueryParams.year },
new QueryArgument<IntGraphType>() { Name = QueryParams.month }
};
if (args != null && args.Any())
{
foreach (var item in args)
{
basic.Add(item);
}
}
return basic;
}
public DynamicParameters GetDynamicParameters(Dictionary<string, object> arguments, params string[] fields)
{
DynamicParameters parameters = new DynamicParameters();
if (arguments == null || !arguments.Any()) return parameters;
if (fields != null && fields.Any())
{
foreach (var item in fields)
{
if (arguments.ContainsKey(item))
{
parameters.Add(item.ToLower(), arguments[item]);
}
}
}
return parameters;
}
}
}
using GraphQL;
using GraphQL.Types;
namespace Performance.Api
{
public class PerformanceSchema : Schema
{
public PerformanceSchema(PerformanceQuery query, IDependencyResolver dependencyResolver)
{
Query = query;
DependencyResolver = dependencyResolver;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api
{
public struct QueryParams
{
public const string pageSize = "pageSize";
public const string pageNumber = "pageNumber";
public const string hospitalId = "hospitalId";
public const string year = "year";
public const string month = "month";
public const string reportId = "reportID";
public const string sourceType = "sourceType";
public const string accountingUnit = "accountingUnit";
public const string category = "category";
public const string itemName = "itemName";
}
}
using GraphQL.Types;
using Performance.DtoModels;
using Performance.Infrastructure;
using Performance.Services;
namespace Performance.Api
{
public class ReportDataType : ObjectGraphType<ReportData>
{
public ReportDataType()
{
Field(x => x.ReportID, type: typeof(IdGraphType));
Field(x => x.ChartType, nullable: true);
Field(x => x.Sort, nullable: true);
Field(x => x.Title);
Field(x => x.QueryName);
Field(x => x.QueryArguments);
Field(x => x.XTitle);
Field(x => x.XUnit);
Field(x => x.YTitle);
Field(x => x.YUnit);
Field(x => x.VTitle);
Field(x => x.VUnit);
Field(x => x.NTitle);
Field(x => x.NUnit);
Field(x => x.Formula);
Field(x => x.DataType, nullable: true);
Field(x => x.FilterValue, nullable: true);
}
}
}
using GraphQL.Types;
using Performance.DtoModels;
using Performance.EntityModels;
namespace Performance.Api
{
public class ReportPerformanceType : ObjectGraphType<ReportTable>
{
public ReportPerformanceType()
{
Field(x => x.PersonnelName, nullable: true);
Field(x => x.PersonnelNumber, nullable: true);
Field(x => x.AccountingUnit, nullable: true);
Field(x => x.Category, nullable: true);
Field(x => x.ItemName, nullable: true);
Field(x => x.CurrentValue, nullable: true);
Field(x => x.LastIssueValue, nullable: true);
Field(x => x.SamePeriodValue, nullable: true);
Field(x => x.BudgetValue, nullable: true);
Field(x => x.RatioValue, nullable: true);
}
}
}
......@@ -40,6 +40,7 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="Hangfire" Version="1.6.22" />
<PackageReference Include="Hangfire.MySql.Core" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.App" />
......@@ -105,6 +106,9 @@
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\导入数据模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
......
......@@ -54,6 +54,8 @@ public void ConfigureServices(IServiceCollection services)
var connection = services.BuildServiceProvider().GetService<IOptions<AppConnection>>();
services.AddGraphQLSchemaAndTypes();
#region json & fluentvalidation & filter
services
......@@ -261,4 +263,4 @@ public bool Authorize(Hangfire.Dashboard.DashboardContext context)
}
#endregion hangfire 权限
}
\ No newline at end of file
}
......@@ -110,7 +110,7 @@
<param name="userId">用户id</param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.SelfInfos">
<member name="M:Performance.Api.Controllers.AccountController.SelfInfos(Performance.DtoModels.UserRequest)">
<summary>
查询用户信息
</summary>
......@@ -1451,6 +1451,13 @@
返回日志
</summary>
</member>
<member name="M:Performance.Api.GraphQLController.Post(Performance.Api.GraphQLRequest)">
<summary>
GraphQL请求地址
</summary>
<param name="query"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.ClaimService.GetUserId">
<summary>
获取当前请求登录ID
......
......@@ -1600,20 +1600,30 @@
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.ChartType">
<summary>
<summary>
</summary>
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.Sort">
<summary>
<summary>
</summary>
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.Title">
<summary>
报表标题
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.QueryName">
<summary>
查询方法名称
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.QueryArguments">
<summary>
查询参数
</summary>
</member>
<member name="P:Performance.DtoModels.ReportData.XTitle">
<summary>
X轴标题
......@@ -1784,6 +1794,56 @@
Not In
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.PersonnelName">
<summary>
人员信息
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.PersonnelNumber">
<summary>
人员工号
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.Category">
<summary>
统计大分类
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.ItemName">
<summary>
统计小分类
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.CurrentValue">
<summary>
本期
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.LastIssueValue">
<summary>
上期
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.SamePeriodValue">
<summary>
同期
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.BudgetValue">
<summary>
预算
</summary>
</member>
<member name="P:Performance.DtoModels.ReportTable.RatioValue">
<summary>
比率
</summary>
</member>
<member name="T:Performance.DtoModels.AgainAllotRequest">
<summary>
二次分配请求
......
......@@ -13,6 +13,8 @@ public ReportData(rep_report report)
ChartType = report.ChartType;
Sort = report.Sort;
Title = report.Title;
QueryName = report.QueryName;
QueryArguments = report.QueryArguments;
XTitle = report.XTitle;
XUnit = report.XUnit;
YTitle = report.YTitle;
......@@ -30,12 +32,12 @@ public ReportData(rep_report report)
public int ReportID { get; set; }
/// <summary>
///
///
/// </summary>
public Nullable<int> ChartType { get; set; }
/// <summary>
///
///
/// </summary>
public Nullable<int> Sort { get; set; }
......@@ -45,6 +47,16 @@ public ReportData(rep_report report)
public string Title { get; set; }
/// <summary>
/// 查询方法名称
/// </summary>
public string QueryName { get; set; }
/// <summary>
/// 查询参数
/// </summary>
public string QueryArguments { get; set; }
/// <summary>
/// X轴标题
/// </summary>
public string XTitle { get; set; }
......@@ -115,23 +127,27 @@ public class ChartData
/// X轴内容
/// </summary>
public string X { get; set; }
/// <summary>
/// Y轴内容
/// </summary>
public string Y { get; set; }
/// <summary>
/// 分类
/// </summary>
public string Name { get; set; }
/// <summary>
/// 值
/// </summary>
public Double Value { get; set; }
public decimal Value { get; set; }
/// <summary>
/// 总量
/// </summary>
public Double? Total { get; set; }
public Nullable<decimal> Total { get; set; }
/// <summary>
/// ChartData 类型标签
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ReportTable
{
/// <summary>
/// 人员信息
/// </summary>
public string PersonnelName { get; set; }
/// <summary>
/// 人员工号
/// </summary>
public string PersonnelNumber { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 统计大分类
/// </summary>
public string Category { get; set; }
/// <summary>
/// 统计小分类
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 本期
/// </summary>
public decimal CurrentValue { get; set; }
/// <summary>
/// 上期
/// </summary>
public decimal LastIssueValue { get; set; }
/// <summary>
/// 同期
/// </summary>
public decimal SamePeriodValue { get; set; }
/// <summary>
/// 预算
/// </summary>
public decimal BudgetValue { get; set; }
/// <summary>
/// 比率
/// </summary>
public decimal RatioValue { get; set; }
}
}
......@@ -9,6 +9,8 @@ public class DrugpropRequest
{
public int ID { get; set; }
public int HospitalId { get; set; }
public int AllotID { get; set; }
/// <summary>
/// 药占比最大范围(小于)
......@@ -43,6 +45,7 @@ public DrugpropRequestValidator()
RuleSet("Insert", () =>
{
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
RuleFor(x => x.AllotID).NotNull().GreaterThan(0);
});
......
......@@ -14,8 +14,8 @@ public class SecondEmpRequest
public string EmployeeName { get; set; }
public string JobNumber { get; set; }
}
public class SecondEmpRequestValidator : AbstractValidator<SecondEmpRequest>
{
public SecondEmpRequestValidator()
......
......@@ -9,7 +9,7 @@ public class HospitalIdRequest
{
public int HospitalId { get; set; }
}
public class SelectionRequest
public class SelectionRequest : HospitalIdRequest
{
public int GroupId { get; set; }
}
......
......@@ -106,10 +106,10 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> </summary>
public virtual DbSet<his_import_clinic> his_import_clinic { get; set; }
/// <summary> </summary>
public virtual DbSet<his_import_summary> his_import_summary { get; set; }
/// <summary> </summary>
public virtual DbSet<his_importdata> his_importdata { get; set; }
/// <summary> </summary>
/// <summary> </summary>
public virtual DbSet<his_script> his_script { get; set; }
/// <summary> </summary>
public virtual DbSet<hos_personfee> hos_personfee { get; set; }
/// <summary> 科室核算导入信息 </summary>
public virtual DbSet<im_accountbasic> im_accountbasic { get; set; }
......@@ -180,8 +180,6 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> </summary>
public virtual DbSet<report_original_workload> report_original_workload { get; set; }
/// <summary> </summary>
public virtual DbSet<report_performance_category> report_performance_category { get; set; }
/// <summary> </summary>
public virtual DbSet<report_performance_person_tags> report_performance_person_tags { get; set; }
/// <summary> </summary>
public virtual DbSet<report_performance_tags> report_performance_tags { get; set; }
......
......@@ -20,7 +20,12 @@ public class cof_drugtype
/// </summary>
[Key]
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> HospitalId { get; set; }
/// <summary>
///
/// </summary>
......
//-----------------------------------------------------------------------
// <copyright file=" his_script.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("his_script")]
public class his_script
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> HospitalId { get; set; }
/// <summary>
/// 来源
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string Category { get; set; }
/// <summary>
/// 执行sql
/// </summary>
public string ExecScript { get; set; }
/// <summary>
/// 数据库类型1、Sql Server 2、Orcale
/// </summary>
public int DatabaseType { get; set; }
/// <summary>
/// 配置Id
/// </summary>
public int ConfigId { get; set; }
/// <summary>
/// 是否可用 1 可用 2 不可用
/// </summary>
public int IsEnable { get; set; }
}
}
......@@ -72,7 +72,7 @@ public class per_employee
public string JobTitle { get; set; }
/// <summary>
/// 人员类别
/// 核算单元类别
/// </summary>
public string UnitType { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" his_import_summary.cs">
// <copyright file=" report_performance.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
......@@ -12,8 +12,8 @@ namespace Performance.EntityModels
/// <summary>
///
/// </summary>
[Table("his_import_summary")]
public class his_import_summary
[Table("report_performance")]
public class report_performance
{
/// <summary>
///
......@@ -22,38 +22,78 @@ public class his_import_summary
public int Id { get; set; }
/// <summary>
/// 医院ID
///
/// </summary>
public int HospitalId { get; set; }
/// <summary>
/// ID
///
/// </summary>
public int AllotId { get; set; }
public int Year { get; set; }
/// <summary>
/// 绩效发放年
///
/// </summary>
public int Year { get; set; }
public int Month { get; set; }
/// <summary>
/// 绩效发放月
/// 人员信息
/// </summary>
public int Month { get; set; }
public string PersonnelName { get; set; }
/// <summary>
///
/// 人员工号
/// </summary>
public string PersonnelNumber { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
///
/// 医院科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 统计分类
/// </summary>
public string SourceType { get; set; }
/// <summary>
/// 统计大分类
/// </summary>
public string Category { get; set; }
/// <summary>
/// 统计小分类
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 本期
/// </summary>
public Nullable<decimal> CurrentValue { get; set; }
/// <summary>
/// 上期
/// </summary>
public Nullable<decimal> LastIssueValue { get; set; }
/// <summary>
/// 同期
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
public Nullable<decimal> SamePeriodValue { get; set; }
/// <summary>
/// 创建时间
/// 预算
/// </summary>
public Nullable<DateTime> CreateTime { get; set; }
public Nullable<decimal> BudgetValue { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.EntityModels
{
public class HisData
{
/// <summary>
/// His科室
/// </summary>
public string HisDepartment { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string DoctorName { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string PersonnelName { get; set; }
/// <summary>
/// 人员工号
/// </summary>
public string PersonnelNumber { get; set; }
/// <summary>
/// 类别
/// </summary>
public string Category { get; set; }
/// <summary>
/// 类别
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 原始分类
/// </summary>
public string Original { get; set; }
/// <summary>
/// 费用
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Performance.Infrastructure.Models
{
public class PageList<T> : List<T>
{
public int CurrentPage { get; private set; }
public int TotalPages { get; private set; }
public int PageSize { get; private set; }
public int TotalCount { get; private set; }
public bool HasPrevious => CurrentPage > 1;
public bool HasNext => CurrentPage < TotalPages;
public PageList(List<T> items, int totalCount, int pageNumber, int pageSize)
{
TotalCount = totalCount;
CurrentPage = pageNumber;
PageSize = pageSize;
TotalPages = (int)Math.Ceiling((double)totalCount / PageSize);
AddRange(items);
}
public static PageList<T> Create(IQueryable<T> source, int pageNumber, int pageSize)
{
var totalCount = source.Count();
var items = source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
var list = new PageList<T>(items, totalCount, pageNumber, pageSize);
return list;
}
}
}
......@@ -8,6 +8,7 @@
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
......
//-----------------------------------------------------------------------
// <copyright file=" his_import_summary.cs">
// * FileName: his_import_summary.cs
// <copyright file=" his_script.cs">
// * FileName: his_script.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
......@@ -9,11 +9,11 @@
namespace Performance.Repository
{
/// <summary>
/// his_import_summary Repository
/// his_script Repository
/// </summary>
public partial class PerforHisimportsummaryRepository : PerforRepository<his_import_summary>
public partial class PerforHisscriptRepository : PerforRepository<his_script>
{
public PerforHisimportsummaryRepository(PerformanceDbContext context) : base(context)
public PerforHisscriptRepository(PerformanceDbContext context) : base(context)
{
}
}
......
//-----------------------------------------------------------------------
// <copyright file=" report_performance_category.cs">
// * FileName: report_performance_category.cs
//-----------------------------------------------------------------------
// <copyright file=" report_performance.cs">
// * FileName: report_performance.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
......@@ -9,11 +9,11 @@
namespace Performance.Repository
{
/// <summary>
/// report_performance_category Repository
/// report_performance Repository
/// </summary>
public partial class PerforReportperformancecategoryRepository : PerforRepository<report_performance_category>
public partial class PerforReportperformanceRepository : PerforRepository<report_performance>
{
public PerforReportperformancecategoryRepository(PerformanceDbContext context) : base(context)
public PerforReportperformanceRepository(PerformanceDbContext context) : base(context)
{
}
}
......
......@@ -293,17 +293,17 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
//var materialsExtra = materialsExtras?.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 econDoctor = economicData.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
var econDoctor = economicData?.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
if (UnitType.专家组 == unitType || UnitType.其他医技组 == unitType || UnitType.其他医生组 == unitType || UnitType.其他护理组 == unitType)
{
econDoctor = economicData.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
econDoctor = economicData?.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
workDoctor = info.Data.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
}
if (UnitType.医技组 == unitType && workDoctor == null)
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 = accountExtraData?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
dept.NightShiftWorkPerforFee = nightShift;
//dept.MedicineFactor = workDoctor?.MedicineFactor;
......
......@@ -175,7 +175,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 nightShift = accountExtraData.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
var nightShift = accountExtraData?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0;
decimal? headcount = null;
if (typeList.Any(o => o.Description == item.QuantitativeIndicators))
......@@ -214,8 +214,8 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
NightShiftWorkPerforFee = nightShift,
};
res.PerforTotal = (sumValue ?? 0) + res.AssessBeforeOtherFee;
res.GiveFee = Math.Round(res.PerforTotal + res.AssessLaterOtherFee ?? 0);
res.RealGiveFee = Math.Round(res.GiveFee * res.ScoringAverage * res.Adjust + res.Punishment + res.AdjustLaterOtherFee ?? 0);
res.GiveFee = Math.Round(res.PerforTotal * res.ScoringAverage + res.AssessLaterOtherFee ?? 0);
res.RealGiveFee = Math.Round(res.GiveFee * res.Adjust + res.Punishment + res.AdjustLaterOtherFee ?? 0);
res.Avg = Math.Round((group.Number != 0 ? res.GiveFee / group.Number : null) ?? 0);
res.ResultsTotalFee = Math.Round(sumValue ?? 0);
......
......@@ -977,7 +977,7 @@ public res_compute UpdateRealfee(ComputerRequest request, int userId, string rea
/// <returns></returns>
public List<res_baiscnorm> GetBaiscnorm(int allotId)
{
return perforResbaiscnormRepository.GetEntities(t => t.AllotID == allotId).OrderBy(t => t.PositionName).ToList();
return perforResbaiscnormRepository.GetEntities(t => t.AllotID == allotId)?.OrderBy(t => t.PositionName).ToList();
}
/// <summary>
......
......@@ -313,9 +313,9 @@ public class ConfigService : IAutoInjection
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<cof_drugtype> GetDrugtypeList(int allotId)
public List<cof_drugtype> GetDrugtypeList(int HospitalId, int allotId)
{
var list = _drugtypeRepository.GetEntities(t => t.AllotID == allotId);
var list = _drugtypeRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId==HospitalId);
return list;
}
......@@ -328,6 +328,7 @@ public cof_drugtype DrugtypeInsert(DrugpropRequest request)
{
var entity = new cof_drugtype
{
HospitalId = request.HospitalId,
AllotID = request.AllotID,
Charge = request.Charge,
ChargeType = request.ChargeType
......@@ -710,7 +711,7 @@ public void Copy(per_allot allot)
if (cofDrugtype == null || cofDrugtype.Count == 0)
{
var drugtype = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = drugtype.Select(t => new cof_drugtype { 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());
}
......
......@@ -46,6 +46,7 @@ public class CustomExtractService : IAutoInjection
_perforHospitalconfigRepository = perforHospitalconfigRepository;
_perforcustscriptRepository = perforcustscriptRepository;
}
public bool CheckConfigScript(int userId, int allotId)
{
var allot = _perallotRepository.GetEntity(w => w.ID == allotId)
......@@ -170,8 +171,8 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
// “科室名称”必须存在 “来源”必须存在
if (deptIndex > -1)
{
string atDepartment = temp.ElementAt(deptIndex).Value?.ToString() ?? ""; // 当前行“科室名称”
string atUnitType = (unitIndex > -1) ? temp.ElementAt(unitIndex).Value?.ToString() : ""; // 当前行“核算单元类别”
string atDepartment = temp.ElementAt(deptIndex).Value?.ToString() ?? ""; // 当前行“科室名称”
string atUnitType = (unitIndex > -1) ? temp.ElementAt(unitIndex).Value?.ToString() : ""; // 当前行“核算单元类别”
// 如果是科主任护士长 则取角色的 核算单元类别
// 如果是核算办 则取数据中 核算单元类别
......@@ -190,7 +191,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
}
else
{
string atSource = temp.ElementAt(sourceIndex).Value?.ToString() ?? ""; // 当前行“来源”
string atSource = temp.ElementAt(sourceIndex).Value?.ToString() ?? ""; // 当前行“来源”
accountUnit = tempDepts.FirstOrDefault(w => w.Source == atSource)?.AccountingUnit ?? "";
}
}
......@@ -201,7 +202,8 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
if (string.IsNullOrEmpty(atUnitType) || !atUnitTypeList.Contains(atUnitType)) continue;
}
}
#endregion
#endregion 替换原始科室名称及跳过写入EXCEL逻辑
int col = 4;
for (int c = 0; c < headers.Count; c++)
......@@ -316,4 +318,4 @@ private bool IsSecondAdmin(int userId, out string[] unitType)
return (isSecondAdmin, department, unitType);
}
}
}
\ No newline at end of file
}
......@@ -506,7 +506,7 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType, int
Expression<Func<ex_type, bool>> exp = t => new List<int> { 0, hospitalId }.Contains(t.HospitalId);
if (executeType.FirstOrDefault() == 1)
exp = exp.And(t => t.Source == (int)SheetType.Income);
else if (sheetType != null && !new int[] { 0, (int)SheetType.Income }.Contains(sheetType.Value))
else if (sheetType.HasValue && sheetType.Value != 0)
exp = exp.And(t => t.Source == sheetType);
else
exp = exp.And(t => t.Source != (int)SheetType.Income);
......
......@@ -20,6 +20,8 @@ public class DictionaryService : IAutoInjection
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
private readonly PerforExscriptRepository exscriptRepository;
private readonly PerforHisdataRepository hisdataRepository;
private readonly PerforHisscriptRepository hisscriptRepository;
public DictionaryService(
ILogger<DictionaryService> logger,
......@@ -28,7 +30,9 @@ public class DictionaryService : IAutoInjection
PerforPeremployeeRepository peremployeeRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
PerforExscriptRepository exscriptRepository
PerforExscriptRepository exscriptRepository,
PerforHisdataRepository hisdataRepository,
PerforHisscriptRepository hisscriptRepository
)
{
this.logger = logger;
......@@ -38,6 +42,8 @@ PerforExscriptRepository exscriptRepository
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
this.hisdataRepository = hisdataRepository;
this.hisscriptRepository = hisscriptRepository;
}
public void Handler(int hospitalId, per_allot allot, string groupName, bool isSingle)
......@@ -48,20 +54,28 @@ public void Handler(int hospitalId, per_allot allot, string groupName, bool isSi
if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息");
var types = extypeRepository.GetEntities(t => t.HospitalId == hospitalId && new int[] { 2 }.Contains(t.Source));
if (types == null || !types.Any()) return;
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取人员信息数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => types.Select(s => s.Id).Contains(t.TypeId) && t.IsEnable == 1);
if (scripts != null && scripts.Any())
if (types != null && types.Any())
{
if (types.Any(t => t.Source == (int)SheetType.Employee)) //人员字典抽取配置
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取人员信息数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => types.Select(s => s.Id).Contains(t.TypeId) && t.IsEnable == 1);
if (scripts != null && scripts.Any())
{
var typeIds = types.Where(t => t.Source == (int)SheetType.Employee).Select(t => t.Id);
var script = scripts.FirstOrDefault(t => typeIds.Contains(t.TypeId));
if (script == null) return;
Employee(allot, configs.FirstOrDefault(t => t.Id == script.ConfigId), script.ExecScript);
if (types.Any(t => t.Source == (int)SheetType.Employee)) //人员字典抽取配置
{
var typeIds = types.Where(t => t.Source == (int)SheetType.Employee).Select(t => t.Id);
var script = scripts.FirstOrDefault(t => typeIds.Contains(t.TypeId));
if (script != null)
Employee(allot, configs.FirstOrDefault(t => t.Id == script.ConfigId), script.ExecScript);
}
}
}
var hisScrips = hisscriptRepository.GetEntities(t => t.HospitalId == hospitalId);
if (hisScrips == null || !hisScrips.Any()) return;
foreach (var item in hisScrips)
{
HisData(allot, configs.FirstOrDefault(t => t.Id == item.ConfigId), item);
}
}
catch (Exception ex)
{
......@@ -98,8 +112,54 @@ private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
}
}
private void HisData(per_allot allot, sys_hospitalconfig config, his_script script)
{
try
{
if (config == null || string.IsNullOrEmpty(script.ExecScript)) return;
var data = queryService.QueryData<HisData>(config, allot, script.ExecScript);
if (data == null || !data.Any()) return;
var hisdata = hisdataRepository.GetEntities(t => t.AllotId == allot.ID && t.SourceType == script.SourceType && t.Category == script.Category);
if (hisdata != null && hisdata.Any())
{
hisdataRepository.RemoveRange(hisdata.ToArray());
}
var insertData = data.Select(t => new his_data
{
HospitalId = allot.HospitalId,
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
HisDepartment = GetSaveValue(t.HisDepartment, t.Department, t.AccountingUnit),
PersonnelName = t.DoctorName,
PersonnelNumber = GetSaveValue(t.PersonnelNumber, t.DoctorName),
SourceType = script.SourceType,
Category = script.Category,
Original = GetSaveValue(t.Category, t.ItemName, t.Original),
Value = t.Value,
CreateTime = DateTime.Now,
});
hisdataRepository.AddRange(insertData.ToArray());
}
catch (Exception ex)
{
logger.LogError("获取his_data时发生异常:" + ex.ToString());
}
}
private void Department()
{
}
private string GetSaveValue(params string[] arr)
{
string value = string.Empty;
if (arr == null || !arr.Any())
return value;
return arr.FirstOrDefault(w => !string.IsNullOrEmpty(w));
}
}
}
......@@ -36,6 +36,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
if (exSpecials == null || !exSpecials.Any()) return;
var extractDto = (data as List<ExtractTransDto>) ?? new List<ExtractTransDto>();
logger.LogInformation("特殊科室数据1:" + JsonHelper.Serialize(extractDto));
var mergedRegions = new List<SpecialCellRange>();
RemoveMergedRegion(sheet, ref mergedRegions);
......
using Dapper;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure.Models;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Performance.Services
{
public class GraphQLService : IAutoInjection
{
private readonly ILogger logger;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforRepreportRepository repreportRepository;
private readonly PerforReportperformanceRepository reportperformanceRepository;
public GraphQLService(
ILogger<GraphQLService> logger,
PerforPeremployeeRepository peremployeeRepository,
PerforRepreportRepository repreportRepository,
PerforReportperformanceRepository reportperformanceRepository
)
{
this.logger = logger;
this.peremployeeRepository = peremployeeRepository;
this.repreportRepository = repreportRepository;
this.reportperformanceRepository = reportperformanceRepository;
}
public List<ReportData> GetReportsInfo()
{
var reports = repreportRepository.GetEntities(t => t.Sort < 5000);
if (reports == null || !reports.Any()) return new List<ReportData>();
var result = new List<ReportData>();
foreach (var item in reports.OrderBy(t => t.Sort))
{
result.Add(new ReportData(item));
}
return result;
}
public ReportData GetReport(int reportId)
{
if (reportId == 0) return new ReportData(new rep_report());
var report = repreportRepository.GetEntity(t => t.ID == reportId) ?? new rep_report();
return new ReportData(report);
}
public List<ChartData> GetChartData(int reportId, DynamicParameters parameters)
{
if (reportId == 0) return new List<ChartData>();
try
{
var report = repreportRepository.GetEntity(t => t.ID == reportId);
if (report == null || string.IsNullOrEmpty(report.Content)) return new List<ChartData>();
var sql = report.Content.ToLower();
string where = GetQueryCondition(sql, parameters);
sql = sql.Replace("{wh}", where);
var chartData = repreportRepository.DapperQuery<ChartData>(sql, parameters, 60 * 5);
return chartData != null && chartData.Any() ? chartData.ToList() : new List<ChartData>();
}
catch (Exception ex)
{
logger.LogError("GetChartData获取报表数据异常: " + ex.ToString());
return new List<ChartData>();
}
}
public List<ReportTable> GetReportPerformance(int reportId, DynamicParameters parameters)
{
if (reportId == 0) return new List<ReportTable>();
try
{
var report = repreportRepository.GetEntity(t => t.ID == reportId);
if (report == null || string.IsNullOrEmpty(report.Content)) return new List<ReportTable>();
var sql = report.Content.ToLower();
string where = GetQueryCondition(sql, parameters);
sql = sql.Replace("{wh}", where);
var chartData = repreportRepository.DapperQuery<ReportTable>(sql, parameters, 60 * 5);
return chartData != null && chartData.Any() ? chartData.ToList() : new List<ReportTable>();
}
catch (Exception ex)
{
logger.LogError("GetReportPerformance获取报表数据异常: " + ex.ToString());
return new List<ReportTable>();
}
}
private string GetQueryCondition(string sql, DynamicParameters parameters)
{
StringBuilder builder = new StringBuilder();
if (parameters != null && parameters.ParameterNames.Any())
{
foreach (var parameter in parameters.ParameterNames.Select(t => t))
{
string key = "@" + parameter;
if (sql.IndexOf(key) == -1)
{
builder.Append($" and {parameter} = {key} ");
}
}
}
return builder.ToString();
}
}
}
......@@ -93,8 +93,8 @@ public SheetType GetSheetType(string sheetName)
return SheetType.Expend;
else if (sheetName.StartsWith("3.1") || sheetName.StartsWith("3.2"))
return SheetType.Workload;
else if (sheetName.StartsWith("3."))
return SheetType.OtherWorkload;
//else if (sheetName.StartsWith("3."))
// return SheetType.OtherWorkload;
else if (sheetName.StartsWith("4.1"))
return SheetType.AccountBasic;
else if (sheetName.StartsWith("4.2"))
......
......@@ -53,7 +53,7 @@ public class ReportDataService : IAutoInjection
/// </summary>
/// <param name="groupId"></param>
/// <returns></returns>
public List<SelectionOptions> GetReportSelection(int groupId, int userId)
public List<SelectionOptions> GetReportSelection(int groupId, int userId, int hospitalId)
{
List<SelectionOptions> options = new List<SelectionOptions>();
......@@ -71,10 +71,14 @@ public List<SelectionOptions> GetReportSelection(int groupId, int userId)
foreach (var item in selections.Where(t => t.State.HasValue && !dispaly.Contains(t.State.Value)))
{
SelectionOptionDefault handle = new SelectionOptionDefault();
//if (item.LoadType == (int)LoadType.InstantLoad && item.Type == 2)
// handle = new SelectionOptionDynamic();
SelectionOptions selection = new SelectionOptions(item);
selection.Options = handle.GetOptions(item);
if (item.LoadType == (int)LoadType.InstantLoad && item.Type == 2)
handle = new SelectionOptionDynamic(reportRepository, hospitalId);
SelectionOptions selection = new SelectionOptions(item)
{
Options = handle.GetOptions(item)
};
if (isMedical)
{
selection.Options.RemoveAll(t => t.Title == "全院");
......@@ -138,8 +142,7 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
List<ReportData> result = new List<ReportData>();
foreach (var report in reports)
{
var sql = report.Content.ToLower();
var sql = report.Content;
//不重复条件,动态拼接WHERE条件
string @where = "";
if (selections != null && selections.Any())
......@@ -148,7 +151,7 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
@where = GetFilterSelection(selections, values);
}
@where += $" and hospitalid={hospitalId}";
if (isMedical && sql.IndexOf("report_allot_crowd") < 0)
if (isMedical)
@where += $" and accountingunit='{department}'";
// 固定占位符
var pairs = PredefinePlaceholder(values);
......@@ -164,6 +167,7 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
{
sql = Regex.Replace(sql, item.Key, item.Value.ToString(), RegexOptions.IgnoreCase);
}
logger.LogInformation($"报表SQL语句:{sql}");
// 执行SQL
var chartData = reportRepository.DapperQuery<ChartData>(sql, null);
......@@ -189,19 +193,19 @@ private string GetFilterSelection(List<rep_selection> selections, List<Selection
foreach (var selection in selections)
{
var value = values.FirstOrDefault(w => w.Title == selection.InputName)?.Values;
if (value == null || !value.Any())
continue;
if (selection.Joint.Equals(SQLOperator.Equal.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName}='{value.First()}'";
else if (selection.Joint.Equals(SQLOperator.Like.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} like '%{value.First()}%'";
else if (selection.Joint.Equals(SQLOperator.NotLike.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} not like '%{value.First()}%'";
else if (selection.Joint.Equals(SQLOperator.In.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} in ({string.Join(",", value.Select(t => $"'{t}'"))})";
else if (selection.Joint.Equals(SQLOperator.NotIn.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} not in ({string.Join(",", value.Select(t => $"'{t}'"))})";
if (value != null && value.Any(w => !string.IsNullOrEmpty(w)))
{
if (selection.Joint.Equals(SQLOperator.Equal.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName}='{value.First()}'";
else if (selection.Joint.Equals(SQLOperator.Like.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} like '%{value.First()}%'";
else if (selection.Joint.Equals(SQLOperator.NotLike.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} not like '%{value.First()}%'";
else if (selection.Joint.Equals(SQLOperator.In.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} in ({string.Join(",", value.Select(t => $"'{t}'"))})";
else if (selection.Joint.Equals(SQLOperator.NotIn.ToString(), StringComparison.OrdinalIgnoreCase))
where += $" and {selection.InputName} not in ({string.Join(",", value.Select(t => $"'{t}'"))})";
}
}
return where;
}
......@@ -303,7 +307,7 @@ private string AddSelectionToReportTitle(List<rep_selection> selections, List<Se
foreach (var key in keys1)
{
var list = values.FirstOrDefault(w => w.Title.ToLower() == key)?.Values;
if (list != null && list.Any())
if (list != null && list.Any(w => !string.IsNullOrEmpty(w)))
{
var arr = Array.ConvertAll(list.ToArray(), input => int.Parse(input));
pairs.Add(key, arr.Max());
......@@ -400,16 +404,34 @@ public virtual List<TitleValue> GetOptions(rep_selection selection)
}
public class SelectionOptionDynamic : SelectionOptionDefault
{
private PerforRepreportRepository _reportRepository;
private readonly int _hospitalId;
public SelectionOptionDynamic(PerforRepreportRepository reportRepository, int hospitalId)
{
_reportRepository = reportRepository;
_hospitalId = hospitalId;
}
public override List<TitleValue> GetOptions(rep_selection selection)
{
//List<TitleValue> values = new List<TitleValue>();
//if (selection.Type != 1)
// return values;
List<TitleValue> values = new List<TitleValue>();
if (selection.Type != 2)
return values;
//if (string.IsNullOrEmpty(selection.Content))
// return values;
if (string.IsNullOrEmpty(selection.Content))
return values;
SortedDictionary<string, object> dic = new SortedDictionary<string, object>
{
{ "hospitalid", _hospitalId},
};
string sql = selection.Content;
if (sql.IndexOf("@hospitalid", StringComparison.OrdinalIgnoreCase) > -1 && dic.ContainsKey("hospitalid"))
sql = Regex.Replace(sql, "@hospitalid", dic.GetValue<string>("hospitalid"), RegexOptions.IgnoreCase);
return base.GetOptions(selection);
// 执行SQL
var selections = _reportRepository.DapperQuery<TitleValue>(sql, null);
return selections == null ? new List<TitleValue>() : selections.ToList();
}
}
}
......@@ -67,22 +67,27 @@ public List<RoleResponse> GetUsersRole(int userid)
if (ParentUser != null)
{
var userRole = _userroleRepository.GetEntities();
foreach (var sysUser in ParentUser)
{
var useRoles = GetARole(sysUser.ID);
var role = Mapper.Map<RoleResponse>(useRoles);
role.Value = sysUser.ID;
var uRole = userRole.Find(t => t.RoleID == role.RoleID && t.UserID == sysUser.ID);
if (uRole?.UserID != null) role.Value = (int)uRole?.UserID;
roleResponses.Add(role);
}
}
var roles = GetARole(userid);
if (roles!=null)
var isParent = user.ParentID == null || user.ParentID == 0;
var roles = GetARole(isParent ? userid : (int)user.ParentID);
if (roles != null)
{
var role = Mapper.Map<RoleResponse>(roles);
role.Value = userid;
role.Value = isParent ? userid : (int)user.ParentID;
roleResponses.Add(role);
}
return roleResponses;
return roleResponses?.OrderBy(t => t.Type).ToList();
}
/// <summary>
......
......@@ -335,7 +335,11 @@ private void AccountNurseExport(int sheetID, SheetExportResponse response)
int index = 1;
foreach (var item in pairs)
{
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6));
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6)
{
FieldName = item.Item1,
CellType = "header"
});
index += 1;
}
response.Header.Add(row);
......@@ -388,7 +392,11 @@ private void AccountDoctorExport(int sheetID, SheetExportResponse response)
int index = 1;
foreach (var item in pairs)
{
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6));
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6)
{
FieldName = item.Item1,
CellType = "header"
});
index += 1;
}
response.Header.Add(row);
......
......@@ -143,6 +143,16 @@ public List<UserResponse> GetUserList(int userID)
if (role.IsViewAllUsers == 2)
{
var userlist = _userRepository.GetEntities(t => t.CreateUser == userID && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null));
var sonUser = _userRepository.GetEntities(t => t.ParentID != 0 && t.ParentID != null);
if (sonUser != null)
foreach (var user in sonUser)
{
if (user.Department == "")
continue;
var parentUser = userlist.Find(t => t.ID == user.ParentID);
if (parentUser == null) continue;
parentUser.Department = user.Department;
}
result = Mapper.Map<List<UserResponse>>(userlist);
}
else
......@@ -152,6 +162,16 @@ public List<UserResponse> GetUserList(int userID)
var userIds = _userhospitalRepository.GetEntities(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 sonUser = _userRepository.GetEntities(t => t.ParentID != 0 && t.ParentID != null);
if (sonUser != null)
foreach (var user in sonUser)
{
if (user.Department == "")
continue;
var parentUser = userlist.Find(t => t.ID == user.ParentID);
if (parentUser == null) continue;
parentUser.Department = user?.Department;
}
result = Mapper.Map<List<UserResponse>>(userlist);
}
if (result != null && result.Count > 0)
......@@ -171,17 +191,18 @@ public List<UserResponse> GetUserList(int userID)
item.Role = userRole.RoleID;
roleId.Add(userRole.RoleID);
}
var diffUserRole = _userRepository.GetEntities(c => c.ParentID == item.UserID);
if (diffUserRole != null)
{
foreach (var user in diffUserRole)
{
var diffRole = _userroleRepository.GetEntity(t => t.UserID == user.ID);
roleId.Add(diffRole.RoleID);
}
}
item.RoleArr = roleId?.ToArray();
}
}
......@@ -524,8 +545,6 @@ public UserResponse InsertUser(UserRequest request, int userid)
{
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
throw new PerformanceException("登录名重复");
if (request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department))
......@@ -581,9 +600,6 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
if (isAgainAdmin && request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
user.Login = request.Login;
user.Mobile = request.Mobile;
......@@ -606,7 +622,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
//删除子用户角色关联关系
var userSubset = _userRepository.GetEntities(c => c.ParentID == user.ID);
if (userSubset!=null)
if (userSubset != null)
{
foreach (var item in userSubset)
{
......@@ -616,7 +632,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
}
_userRepository.RemoveRange(userSubset.ToArray());
}
var userID = user.ID;
var userLogin = user.Login;
......@@ -633,7 +649,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
diffUser.Mail = request.Mail;
diffUser.States = request.States;
diffUser.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password;
diffUser.Department = roleArray.Contains(request.RoleArr[0]) ? request.Department : "";
diffUser.Department = roleArray.Contains(request.RoleArr[i]) ? request.Department : "";
if (!_userRepository.Add(diffUser))
throw new PerformanceException("保存失败");
//添加子用户角色关联关系
......@@ -653,7 +669,7 @@ public ApiResponse DeleteUser(int iD)
var result = _userRepository.Remove(user);
var users = _userRepository.GetEntities(t => t.ParentID == user.ID && t.IsDelete == 1)?.ToArray();
if (users!=null)
if (users != null)
{
_userRepository.RemoveRange(users);
foreach (var item in users)
......@@ -663,7 +679,7 @@ public ApiResponse DeleteUser(int iD)
_userroleRepository.Remove(userRole);
}
}
return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail);
}
......
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