Commit fcd71ca0 by ruyun.zhang@suvalue.com

Merge branch 'feature/extract' into develop

parents 1cfac1b2 d983e5f2
...@@ -25,6 +25,7 @@ public class TemplateController : Controller ...@@ -25,6 +25,7 @@ public class TemplateController : Controller
{ {
private readonly TemplateService templateService; private readonly TemplateService templateService;
private readonly ExtractService extractService; private readonly ExtractService extractService;
private readonly NewExtractService newExtractService;
private HospitalService hospitalService; private HospitalService hospitalService;
private IHostingEnvironment env; private IHostingEnvironment env;
private ClaimService claim; private ClaimService claim;
...@@ -36,6 +37,7 @@ public class TemplateController : Controller ...@@ -36,6 +37,7 @@ public class TemplateController : Controller
public TemplateController(TemplateService templateService, public TemplateController(TemplateService templateService,
HospitalService hospitalService, HospitalService hospitalService,
ExtractService extractService, ExtractService extractService,
NewExtractService newExtractService,
IHostingEnvironment env, IHostingEnvironment env,
ClaimService claim, ClaimService claim,
IOptions<Application> options, IOptions<Application> options,
...@@ -45,6 +47,7 @@ public class TemplateController : Controller ...@@ -45,6 +47,7 @@ public class TemplateController : Controller
{ {
this.templateService = templateService; this.templateService = templateService;
this.extractService = extractService; this.extractService = extractService;
this.newExtractService = newExtractService;
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.env = env; this.env = env;
this.claim = claim; this.claim = claim;
...@@ -74,6 +77,7 @@ public IActionResult DownFile(int type = 1) ...@@ -74,6 +77,7 @@ public IActionResult DownFile(int type = 1)
} }
memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider(); var provider = new FileExtensionContentTypeProvider();
var memi = provider.Mappings[".xlsx"]; var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(path)); return File(memoryStream, memi, Path.GetFileName(path));
} }
...@@ -130,6 +134,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -130,6 +134,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
#region 老版提取
/// <summary> /// <summary>
/// 提取绩效数据 /// 提取绩效数据
/// </summary> /// </summary>
...@@ -190,6 +195,68 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo ...@@ -190,6 +195,68 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
throw ex; throw ex;
} }
} }
#endregion
#region 新版提取
/// <summary>
/// 提取绩效数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("NewExtractData")]
[HttpPost]
public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest request)
{
var allot = allotService.GetAllot(request.AllotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
// 判断是那种抽取
try
{
string message = newExtractService.Judge(request.AllotId, request.HospitalId, request.UseScheme);
if (!string.IsNullOrEmpty(message))
return new ApiResponse(ResponseType.Fail, message);
allot.IsExtracting = allot.IsExtracting ?? 0;
if (allot.IsExtracting == 1)
return new ApiResponse(ResponseType.OK, "正在提取数据,请稍等!");
allot.IsExtracting = 1;
allotService.Update(allot);
var email = claim.GetUserClaim(JwtClaimTypes.Mail);
request.Email = email;
//if (request.UseScheme == (int)UseTemplate.Config)
//{
LogHelper.Information("请求路径:" + url.HttpPost + "/extract/extract", "提取绩效数据");
HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
//}
//else
//{
// return new ApiResponse(ResponseType.Fail, "该功能暂未实现!");
//}
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
}
catch (Exception ex)
{
if (allot != null)
{
allot.IsExtracting = 3;
allotService.Update(allot);
}
logger.LogError("提取绩效数据:" + ex.ToString());
throw new Exception(ex.Message);
}
// A 使用上传绩效作为模板
// A-1 判断上传绩效是否存在,并执行成功
// A-2 医院人员名单、1.0.1 额外收入(写出列头)、2.1 成本支出统计表(写出列头)、4.1 临床科室医护绩效测算表、4.2 特殊核算单元绩效测算表(数量、考核得分率、奖罚、其他)
// A-3 收入 根据收入配置sheet名称获取抽取SQL,执行填充结果
// A-4 工作量 根据配置项获取抽取SQL,执行填充结果
// B 使用配置作为模板
}
#endregion
/// <summary> /// <summary>
/// 从WebAPI下载文件 /// 从WebAPI下载文件
...@@ -230,36 +297,54 @@ public IActionResult DownFile([FromQuery]AllotRequest request) ...@@ -230,36 +297,54 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
[AllowAnonymous] [AllowAnonymous]
public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int hospitalId) public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int hospitalId)
{ {
LogHelper.Information($"请求参数:allotId:{allotId} hospitalId:{hospitalId}", "保存提取文件");
logger.LogInformation($"保存提取文件 参数:allotId:{allotId} hospitalId:{hospitalId}"); logger.LogInformation($"保存提取文件 参数:allotId:{allotId} hospitalId:{hospitalId}");
try try
{ {
var file = ((FormFileCollection)form.Files).FirstOrDefault(); var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null) if (file == null)
{
LogHelper.Error($"返回文件为空!", "保存提取文件");
return new ApiResponse(ResponseType.Error, "上传文件无效"); return new ApiResponse(ResponseType.Error, "上传文件无效");
}
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", "autoextract"); var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", "autoextract");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName)); var path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
LogHelper.Information($"保存路径:" + path, "保存提取文件");
using (var stream = file.OpenReadStream()) using (var stream = file.OpenReadStream())
{ {
byte[] bytes = new byte[stream.Length]; byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length); stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes)) if (!FileHelper.CreateFile(path, bytes))
{
LogHelper.Error($"保存失败", "保存提取文件");
return new ApiResponse(ResponseType.Error, "保存失败"); return new ApiResponse(ResponseType.Error, "保存失败");
} }
}
var allot = allotService.GetAllot(allotId); var allot = allotService.GetAllot(allotId);
allot.ExtractPath = path; allot.ExtractPath = path;
allot.IsExtracting = 2; allot.IsExtracting = 2;
if (!string.IsNullOrEmpty(path) && allotService.Update(allot)) if (string.IsNullOrEmpty(path) || !FileHelper.IsExistFile(path))
{
LogHelper.Information($"文件未保存成功,保存文件不存在!", "保存提取文件");
return new ApiResponse(ResponseType.Fail, "上传成功!");
}
if (!allotService.Update(allot))
{
LogHelper.Information($"更新文件路径失败!", "保存提取文件");
return new ApiResponse(ResponseType.Fail, "上传成功!");
}
return new ApiResponse(ResponseType.OK, "上传成功!"); return new ApiResponse(ResponseType.OK, "上传成功!");
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogInformation($"保存提取文件异常{ex.ToString()}"); logger.LogInformation($"保存提取文件异常{ex.ToString()}");
LogHelper.Error($"保存失败:" + ex.ToString(), "保存提取文件");
return new ApiResponse(ResponseType.Error,ex.Message);
} }
return new ApiResponse(ResponseType.Error);
} }
} }
} }
\ No newline at end of file
...@@ -58,9 +58,6 @@ ...@@ -58,9 +58,6 @@
<Content Update="wwwroot\Performance.Api.xml"> <Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Update="wwwroot\Performance.DtoModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.EntityModels.xml"> <Content Update="wwwroot\Performance.EntityModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
...@@ -75,6 +72,15 @@ ...@@ -75,6 +72,15 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project> </Project>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"WebapiUrl": { "WebapiUrl": {
"ImportFirst": "http://localhost:50997/api/extract/import", "ImportFirst": "http://localhost:50997/api/extract/import",
"ExtractData": "http://localhost:50997/api/extract/index", "ExtractData": "http://localhost:50997/api/extract/index",
"ImportFile": "" "ImportFile": "http://localhost:5001/api/template/savefile",
"HttpPost": "http://localhost:50997/api"
} }
} }
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
"WebapiUrl": { "WebapiUrl": {
"ImportFirst": "http://localhost:50997/api/extract/import", "ImportFirst": "http://localhost:50997/api/extract/import",
"ExtractData": "http://localhost:50997/api/extract/index", "ExtractData": "http://localhost:50997/api/extract/index",
"ImportFile": "" "ImportFile": "http://localhost:5001/api/template/savefile",
"HttpPost": "http://localhost:50997/api"
} }
} }
...@@ -673,6 +673,13 @@ ...@@ -673,6 +673,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.TemplateController.NewExtractData(Performance.DtoModels.ExtractRequest)">
<summary>
提取绩效数据
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.DownFile(Performance.DtoModels.AllotRequest)"> <member name="M:Performance.Api.Controllers.TemplateController.DownFile(Performance.DtoModels.AllotRequest)">
<summary> <summary>
从WebAPI下载文件 从WebAPI下载文件
......
...@@ -92,6 +92,24 @@ ...@@ -92,6 +92,24 @@
<member name="T:Performance.DtoModels.States"> <member name="T:Performance.DtoModels.States">
<summary> 用户状态 </summary> <summary> 用户状态 </summary>
</member> </member>
<member name="T:Performance.DtoModels.UseTemplate">
<summary> 提取数据使用模板 </summary>
</member>
<member name="F:Performance.DtoModels.UseTemplate.LastAllot">
<summary> 上次绩效 </summary>
</member>
<member name="F:Performance.DtoModels.UseTemplate.Config">
<summary> 配置模板 </summary>
</member>
<member name="T:Performance.DtoModels.DbSrouceType">
<summary> 提取数据使用模板 </summary>
</member>
<member name="F:Performance.DtoModels.DbSrouceType.Standard">
<summary> 标准库 </summary>
</member>
<member name="F:Performance.DtoModels.DbSrouceType.Performance">
<summary> 绩效库 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.NoData"> <member name="F:Performance.DtoModels.AllotStates.NoData">
<summary> 用户状态 </summary> <summary> 用户状态 </summary>
</member> </member>
...@@ -1205,6 +1223,26 @@ ...@@ -1205,6 +1223,26 @@
发放系数 发放系数
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.ExtractRequest.AllotId">
<summary>
绩效ID
</summary>
</member>
<member name="P:Performance.DtoModels.ExtractRequest.HospitalId">
<summary>
医院ID
</summary>
</member>
<member name="P:Performance.DtoModels.ExtractRequest.UseScheme">
<summary>
使用方案
</summary>
</member>
<member name="P:Performance.DtoModels.ExtractRequest.Email">
<summary>
邮箱
</summary>
</member>
<member name="T:Performance.DtoModels.HospitalRequest"> <member name="T:Performance.DtoModels.HospitalRequest">
<summary> <summary>
登录请求 登录请求
...@@ -1609,6 +1647,11 @@ ...@@ -1609,6 +1647,11 @@
科室 科室
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.DeptResponse.ManagerNumber">
<summary>
科主任/护士长数量
</summary>
</member>
<member name="P:Performance.DtoModels.DeptResponse.Number"> <member name="P:Performance.DtoModels.DeptResponse.Number">
<summary> <summary>
核算单元医生数量 核算单元医生数量
......
...@@ -108,7 +108,7 @@ public AutoMapperConfigs() ...@@ -108,7 +108,7 @@ public AutoMapperConfigs()
//CreateMap<PerDataAccountBaisc, im_accountbasic>(); //CreateMap<PerDataAccountBaisc, im_accountbasic>();
//CreateMap<im_accountbasic, PerDataAccountBaisc>(); //CreateMap<im_accountbasic, PerDataAccountBaisc>();
CreateMap<PerDataAccountBaisc, im_accountbasic>() CreateMap<PerDataAccountBaisc, im_accountbasic>()
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => src.UnitType)) .ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType).Value))
.ForMember(dest => dest.DoctorAccountingUnit, opt => opt.MapFrom(src => src.AccountingUnit)) .ForMember(dest => dest.DoctorAccountingUnit, opt => opt.MapFrom(src => src.AccountingUnit))
.ForMember(dest => dest.Department, opt => opt.MapFrom(src => src.Department)) .ForMember(dest => dest.Department, opt => opt.MapFrom(src => src.Department))
.ForMember(dest => dest.DoctorDirectorNumber, opt => opt.MapFrom(src => src.ManagerNumber)) .ForMember(dest => dest.DoctorDirectorNumber, opt => opt.MapFrom(src => src.ManagerNumber))
...@@ -146,8 +146,10 @@ public AutoMapperConfigs() ...@@ -146,8 +146,10 @@ public AutoMapperConfigs()
//CreateMap<PerDataAccountDoctor, res_accountdoctor>(); //CreateMap<PerDataAccountDoctor, res_accountdoctor>();
//CreateMap<PerDataAccountNurse, res_accountnurse>(); //CreateMap<PerDataAccountNurse, res_accountnurse>();
//CreateMap<res_accountdoctor, PerDataAccountBaisc>(); //CreateMap<res_accountdoctor, PerDataAccountBaisc>();
CreateMap<res_account, PerDataAccountBaisc>(); CreateMap<res_account, PerDataAccountBaisc>()
CreateMap<PerDataAccountBaisc, res_account>(); .ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => ((UnitType)src.UnitType).ToString()));
CreateMap<PerDataAccountBaisc, res_account>()
.ForMember(dest => dest.UnitType, opt => opt.MapFrom(src => EnumHelper.GetItems<UnitType>().First(t => t.Name == src.UnitType).Value));
//CreateMap<PerDataAccountBaisc, res_accountnurse>(); //CreateMap<PerDataAccountBaisc, res_accountnurse>();
//CreateMap<res_accountdoctor, ComputeSource>(); //CreateMap<res_accountdoctor, ComputeSource>();
......
...@@ -23,6 +23,28 @@ public enum States ...@@ -23,6 +23,28 @@ public enum States
Disabled = 2, Disabled = 2,
} }
/// <summary> 提取数据使用模板 </summary>
public enum UseTemplate
{
/// <summary> 上次绩效 </summary>
[Description("上次绩效")]
LastAllot = 1,
/// <summary> 配置模板 </summary>
[Description("配置模板")]
Config = 2,
}
/// <summary> 提取数据使用模板 </summary>
public enum DbSrouceType
{
/// <summary> 标准库 </summary>
[Description("标准库")]
Standard = 1,
/// <summary> 绩效库 </summary>
[Description("绩效库")]
Performance = 2,
}
public enum AllotStates public enum AllotStates
{ {
/// <summary> 用户状态 </summary> /// <summary> 用户状态 </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ExtractDto
{
public string Department { get; set; }
public string Category { get; set; }
public decimal Value { get; set; }
}
}
...@@ -21,6 +21,8 @@ public enum UnitType ...@@ -21,6 +21,8 @@ public enum UnitType
护理组 = 2, 护理组 = 2,
[Description("医技组")] [Description("医技组")]
医技组 = 3, 医技组 = 3,
[Description("专家组")]
专家组 = 4,
} }
public enum SheetType public enum SheetType
......
...@@ -21,7 +21,7 @@ public class PerDataAccountBaisc : IPerData ...@@ -21,7 +21,7 @@ public class PerDataAccountBaisc : IPerData
/// <summary> /// <summary>
/// 核算单元类别 1 医生组 2护理组 3医技组 /// 核算单元类别 1 医生组 2护理组 3医技组
/// </summary> /// </summary>
public Nullable<int> UnitType { get; set; } public string UnitType { get; set; }
/// <summary> /// <summary>
/// 核算单元 /// 核算单元
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class DownRequest
{
public int TempType { get; set; }
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ExtractRequest
{
/// <summary>
/// 绩效ID
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 医院ID
/// </summary>
public int HospitalId { get; set; }
/// <summary>
/// 使用方案
/// </summary>
public int UseScheme { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
}
public class ExtractRequestValidator : AbstractValidator<ExtractRequest>
{
public ExtractRequestValidator()
{
RuleFor(x => x.AllotId).NotNull().GreaterThan(0);
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
//RuleFor(x => x.UseScheme).NotNull().InclusiveBetween(1, 2);
}
}
}
...@@ -39,6 +39,11 @@ public class DeptResponse ...@@ -39,6 +39,11 @@ public class DeptResponse
public string Department { get; set; } public string Department { get; set; }
/// <summary> /// <summary>
/// 科主任/护士长数量
/// </summary>
public Nullable<int> ManagerNumber { get; set; }
/// <summary>
/// 核算单元医生数量 /// 核算单元医生数量
/// </summary> /// </summary>
public Nullable<decimal> Number { get; set; } public Nullable<decimal> Number { get; set; }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.EntityModels
{
public class AccountUnitEntity
{
public string SheetName { get; set; }
public string AccountingUnit { get; set; }
public string Department { get; set; }
public int UnitType { get; set; }
}
}
using System; using FluentValidation.AspNetCore;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
...@@ -15,6 +10,11 @@ ...@@ -15,6 +10,11 @@
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Extract.Api.Controllers namespace Performance.Extract.Api.Controllers
{ {
...@@ -22,15 +22,20 @@ namespace Performance.Extract.Api.Controllers ...@@ -22,15 +22,20 @@ namespace Performance.Extract.Api.Controllers
public class ExtractController : Controller public class ExtractController : Controller
{ {
private readonly ExtractService extractService; private readonly ExtractService extractService;
private readonly NewExtractService newExtractService;
private readonly HospitalService hospitalService; private readonly HospitalService hospitalService;
private readonly WebapiUrl url; private readonly WebapiUrl url;
private readonly ILogger<ExtractController> logger; private readonly ILogger<ExtractController> logger;
private IHostingEnvironment evn; private readonly IHostingEnvironment evn;
public ExtractController(ExtractService extractService, HospitalService hospitalService, public ExtractController(ExtractService extractService,
IOptions<WebapiUrl> url, ILogger<ExtractController> logger, NewExtractService newExtractService,
HospitalService hospitalService,
IOptions<WebapiUrl> url,
ILogger<ExtractController> logger,
IHostingEnvironment evn) IHostingEnvironment evn)
{ {
this.extractService = extractService; this.extractService = extractService;
this.newExtractService = newExtractService;
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.url = url.Value; this.url = url.Value;
this.logger = logger; this.logger = logger;
...@@ -100,5 +105,48 @@ public void Index([FromBody]AllotRequest request) ...@@ -100,5 +105,48 @@ public void Index([FromBody]AllotRequest request)
} }
logger.LogInformation(token + ",提取结束,请求参数:" + JsonHelper.Serialize(request)); logger.LogInformation(token + ",提取结束,请求参数:" + JsonHelper.Serialize(request));
} }
#region 新版提取
/// <summary>
/// 提取绩效数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("extract")]
[HttpPost]
public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
{
LogHelper.Information("请求参数:" + JsonHelper.Serialize(request), "提取绩效数据");
string filePath = newExtractService.ExtractData(request.AllotId, request.Email, request.HospitalId);
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
{
LogHelper.Information("请求路径:" + url.ImportFile + ",请求参数" + JsonHelper.Serialize(new { allotId = request.AllotId, hospitalId = request.HospitalId }), "保存提取文件");
int i = 1;
while (i <= 5)
{
if (i == 5)
LogHelper.Information($"保存文件失败,已尝试执行五次,请联系开发人员!", "保存提取文件");
else
LogHelper.Information($"正在尝试第{i}次保存!", "保存提取文件");
//保存文件
string retJson = HttpHelper.HttpClient(url.ImportFile + $"?allotId={request.AllotId}&hospitalId={request.HospitalId}", filePath);
LogHelper.Information("返回结果:" + JsonHelper.Serialize(retJson), "保存提取文件");
logger.LogInformation(retJson);
var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
if (ret != null && (int)ret.State == 1)
{
LogHelper.Information("保存成功!", "保存提取文件");
break;
}
i++;
}
}
else
LogHelper.Information($"提取文件不存在!", "保存提取文件");
}
#endregion
} }
} }
\ No newline at end of file
...@@ -25,6 +25,19 @@ ...@@ -25,6 +25,19 @@
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" /> <ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Template\" />
</ItemGroup>
<ItemGroup>
<None Include="..\Performance.Api\Template\医院二次分配绩效模板.xlsx" Link="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Performance.Api\Template\医院绩效模板.xlsx" Link="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project> </Project>
...@@ -31,6 +31,15 @@ public IEnumerable<TEntity> DapperQuery(string sql, object param, int? commandTi ...@@ -31,6 +31,15 @@ public IEnumerable<TEntity> DapperQuery(string sql, object param, int? commandTi
{ {
return context.Database.GetDbConnection().Query<TEntity>(sql, param, commandTimeout: commandTimeout); return context.Database.GetDbConnection().Query<TEntity>(sql, param, commandTimeout: commandTimeout);
} }
public IEnumerable<T> DapperQuery<T>(string sql, object param) where T : class, new()
{
return context.Database.GetDbConnection().Query<T>(sql, param);
}
public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeout = null)
{
return context.Database.GetDbConnection().Query<T>(sql, param, commandTimeout: commandTimeout);
}
public int Execute(string sql, object param) public int Execute(string sql, object param)
{ {
......
...@@ -29,5 +29,15 @@ public IEnumerable<im_data> GetAccountingUnit(int hospitalid, int sheettype, Lis ...@@ -29,5 +29,15 @@ public IEnumerable<im_data> GetAccountingUnit(int hospitalid, int sheettype, Lis
"where allot.hospitalid = @hospitalid and sheet.sheettype = @sheettype and im.department in @deptList"; "where allot.hospitalid = @hospitalid and sheet.sheettype = @sheettype and im.department in @deptList";
return DapperQuery(sql, new { hospitalid, sheettype, deptList }, 1000 * 60 * 5); return DapperQuery(sql, new { hospitalid, sheettype, deptList }, 1000 * 60 * 5);
} }
/// <summary>
/// 삿혤뵙炬데禱
/// </summary>
/// <returns></returns>
public IEnumerable<AccountUnitEntity> GetAccountUnit(int allotId)
{
string sql = "select distinct SheetName,AccountingUnit,Department,UnitType from per_sheet st join im_data dt on st.ID = dt.SheetID where st.AllotID = @allotId";
return DapperQuery<AccountUnitEntity>(sql, new { allotId }, 1000 * 60 * 5);
}
} }
} }
...@@ -121,7 +121,7 @@ public List<res_baiscnorm> DocterNurseBaiscnorm(List<res_baiscnorm> baiscnormLis ...@@ -121,7 +121,7 @@ public List<res_baiscnorm> DocterNurseBaiscnorm(List<res_baiscnorm> baiscnormLis
var sheet = list.FirstOrDefault(t => t.SheetType == info.SheetType); var sheet = list.FirstOrDefault(t => t.SheetType == info.SheetType);
var perData = sheet.PerData.Select(t => (PerDataAccountBaisc)t); var perData = sheet.PerData.Select(t => (PerDataAccountBaisc)t);
//剔除不同科室相同核算单元 //剔除不同科室相同核算单元
var groupData = perData.Where(t => t.UnitType == (int)info.UnitType) var groupData = perData.Where(t => t.UnitType == info.UnitType.ToString())
.GroupBy(t => t.AccountingUnit) .GroupBy(t => t.AccountingUnit)
.Select(t => new { AccountingUnit = t.Key, Number = t.Sum(p => p.ManagerNumber + p.Number), PerforTotal = t.Max(p => p.PerforTotal) }); .Select(t => new { AccountingUnit = t.Key, Number = t.Sum(p => p.ManagerNumber + p.Number), PerforTotal = t.Max(p => p.PerforTotal) });
......
...@@ -97,31 +97,6 @@ public bool Discern(PerExcel excel, per_allot allot) ...@@ -97,31 +97,6 @@ public bool Discern(PerExcel excel, per_allot allot)
.Select(t => t.CellName).Distinct().ToList(); .Select(t => t.CellName).Distinct().ToList();
if (headerCheck != null) if (headerCheck != null)
{ {
if ((int)sheet.SheetType == 4)
{
string str = sheet.SheetName.Contains("医生组") ? "医生组" : "护理组";
var filter = new List<string>() { $"核算单元({str})", "科室名称" };
var list = cellValue.Intersect(filter).ToList(); //求交集
if (list == null)
{
message = $"{sheet.SheetName} -- 列头不规范,缺少列头或命名不规范:“核算单元({str})、科室名称”不存在;";
flag = false;
}
else if (!cellValue.Contains($"核算单元({str})"))
{
message = $"{sheet.SheetName} -- 列头不规范,缺少列头或命名不规范:“核算单元({str})”不存在;";
flag = false;
}
else if (!cellValue.Contains("科室名称"))
{
message = $"{sheet.SheetName} -- 列头不规范,缺少列头或命名不规范:“科室名称”不存在;";
flag = false;
}
}
else
{
var list = cellValue.Intersect(headerCheck).ToList(); //求交集,提交的列头和数据库中保存的列头 var list = cellValue.Intersect(headerCheck).ToList(); //求交集,提交的列头和数据库中保存的列头
var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allot.ID); var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugtype != null && drugtype.Count > 0) if (drugtype != null && drugtype.Count > 0)
...@@ -132,7 +107,6 @@ public bool Discern(PerExcel excel, per_allot allot) ...@@ -132,7 +107,6 @@ public bool Discern(PerExcel excel, per_allot allot)
flag = false; flag = false;
message = $"{sheet.SheetName} -- 列头不规范,缺少列头或命名不规范:“{String.Join("、", lack.ToArray())}”不存在;"; message = $"{sheet.SheetName} -- 列头不规范,缺少列头或命名不规范:“{String.Join("、", lack.ToArray())}”不存在;";
} }
}
if (!flag) if (!flag)
result = false; result = false;
} }
......
...@@ -243,8 +243,9 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid) ...@@ -243,8 +243,9 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid)
{ {
var pairs = new[] var pairs = new[]
{ {
new { Name = "医生组临床科室单元核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount, UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组 } }, new { Name = "医生组临床科室单元核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount, UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组, UnitType.专家组 } },
new { Name = "护理组临床科室单元核算表", Data = nurseWorkloadData, SheetType = SheetType.ComputeNurseAccount, UnitTypes = new List<UnitType> { UnitType.护理组 } }, new { Name = "护理组临床科室单元核算表", Data = nurseWorkloadData, SheetType = SheetType.ComputeNurseAccount, UnitTypes = new List<UnitType> { UnitType.护理组 } },
new { Name = "专家核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount, UnitTypes = new List<UnitType> { UnitType.专家组 } },
}; };
List<PerSheet> result = new List<PerSheet>(); List<PerSheet> result = new List<PerSheet>();
foreach (var info in pairs) foreach (var info in pairs)
...@@ -252,14 +253,20 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid) ...@@ -252,14 +253,20 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid)
PerSheet sheet = new PerSheet(info.Name, info.Name, info.SheetType, new List<PerHeader>(), new List<IPerData>()); PerSheet sheet = new PerSheet(info.Name, info.Name, info.SheetType, new List<PerHeader>(), new List<IPerData>());
foreach (var unitType in info.UnitTypes) foreach (var unitType in info.UnitTypes)
{ {
var atDataList = dataList.Where(t => t.UnitType == (int)unitType); var atDataList = dataList.Where(t => t.UnitType == unitType.ToString());
foreach (var dept in dataList.Where(t => t.UnitType == (int)unitType)) if (atDataList == null || !atDataList.Any())
continue;
foreach (var dept in dataList.Where(t => t.UnitType == unitType.ToString()))
{ {
if (string.IsNullOrEmpty(dept.AccountingUnit)) if (string.IsNullOrEmpty(dept.AccountingUnit))
continue; continue;
var econDoctor = economicData.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.Department); var econDoctor = economicData.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.Department);
var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.Department); var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.Department);
if (UnitType.专家组 == unitType)
{
econDoctor = economicData.FirstOrDefault(t => t.AccountingUnit == dept.Department);
workDoctor = info.Data.FirstOrDefault(t => t.AccountingUnit == dept.Department);
}
//保底绩效 //保底绩效
var minimum = baiscnormList.FirstOrDefault(t => t.PositionName == dept.MinimumReference); var minimum = baiscnormList.FirstOrDefault(t => t.PositionName == dept.MinimumReference);
if (!string.IsNullOrEmpty(dept.MinimumReference) && minimum != null) if (!string.IsNullOrEmpty(dept.MinimumReference) && minimum != null)
...@@ -299,9 +306,11 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid) ...@@ -299,9 +306,11 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid)
} }
} }
} }
sheet.PerData.AddRange(atDataList); sheet.PerData.AddRange(atDataList);
} }
if ("专家核算表" == info.Name && (sheet.PerData == null || sheet.PerData.Any()))
continue;
result.Add(sheet); result.Add(sheet);
} }
return result; return result;
...@@ -325,7 +334,7 @@ public List<res_baiscnorm> ComputeMinimum(IEnumerable<PerDataAccountBaisc> accou ...@@ -325,7 +334,7 @@ public List<res_baiscnorm> ComputeMinimum(IEnumerable<PerDataAccountBaisc> accou
foreach (var rule in basicRuleList) foreach (var rule in basicRuleList)
{ {
var dataList = accountList.Where(t => t.UnitType == (int)rule.UnitType); var dataList = accountList.Where(t => t.UnitType == rule.UnitType.ToString());
var count = dataList.Sum(t => t.ManagerNumber + t.Number); var count = dataList.Sum(t => t.ManagerNumber + t.Number);
decimal totalValue = 0m; decimal totalValue = 0m;
foreach (var dept in dataList) foreach (var dept in dataList)
......
using NPOI.HSSF.UserModel;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Services
{
public enum StyleType
{
//列头固定,
列头,
系数,
数据,
默认,
}
public enum CellFormat
{
数字,
数字2,
百分比,
百分比2,
时间,
默认,
}
public class CellStyle
{
public static ICellStyle CreateCellStyle(IWorkbook wb, StyleType type = StyleType.默认, CellFormat format = CellFormat.默认)
{
ICellStyle cellStyle = wb.CreateCellStyle();
//字体
IFont font = wb.CreateFont();
font.FontHeightInPoints = 11;
font.FontName = "微软雅黑";
font.Color = HSSFColor.Black.Index;
//边框
cellStyle.BorderBottom = BorderStyle.Thin;
cellStyle.BorderLeft = BorderStyle.Thin;
cellStyle.BorderRight = BorderStyle.Thin;
cellStyle.BorderTop = BorderStyle.Thin;
//边框颜色
cellStyle.BottomBorderColor = HSSFColor.Black.Index;
cellStyle.TopBorderColor = HSSFColor.Black.Index;
cellStyle.LeftBorderColor = HSSFColor.Black.Index;
cellStyle.RightBorderColor = HSSFColor.Black.Index;
cellStyle.SetFont(font);
//居中
cellStyle.Alignment = HorizontalAlignment.Center;//水平居中
cellStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
switch (type)
{
case StyleType.列头:
cellStyle.FillForegroundColor = HSSFColor.Gold.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
break;
case StyleType.系数:
cellStyle.FillForegroundColor = HSSFColor.Green.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
break;
case StyleType.数据:
cellStyle.FillForegroundColor = HSSFColor.SkyBlue.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
break;
case StyleType.默认:
cellStyle.SetFont(font);
break;
}
IDataFormat datastyle = wb.CreateDataFormat();
switch (format)
{
case CellFormat.时间:
cellStyle.DataFormat = datastyle.GetFormat("yyyy/mm/dd");
break;
case CellFormat.数字:
cellStyle.DataFormat = datastyle.GetFormat("0");
break;
case CellFormat.数字2:
cellStyle.DataFormat = datastyle.GetFormat("0.00");
break;
case CellFormat.百分比:
cellStyle.DataFormat = datastyle.GetFormat("0%");
break;
case CellFormat.百分比2:
cellStyle.DataFormat = datastyle.GetFormat("0.00%");
break;
case CellFormat.默认:
cellStyle.SetFont(font);
break;
}
return cellStyle;
}
}
}
...@@ -333,7 +333,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee ...@@ -333,7 +333,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
var importRow = importSheet.CreateRow(maxHeaderRowNumber + i + 1); var importRow = importSheet.CreateRow(maxHeaderRowNumber + i + 1);
Dictionary<string, Func<PerDataAccountBaisc, object>> keyValues = new Dictionary<string, Func<PerDataAccountBaisc, object>> Dictionary<string, Func<PerDataAccountBaisc, object>> keyValues = new Dictionary<string, Func<PerDataAccountBaisc, object>>
{ {
{ "核算单元类型", (t) => EnumHelper.GetDescription((UnitType)t.UnitType) }, { "核算单元类型", (t) => t.UnitType },
{ "核算单元", (t) => t.AccountingUnit }, { "核算单元", (t) => t.AccountingUnit },
{ "科室名称", (t) => t.Department }, { "科室名称", (t) => t.Department },
{ "医生组核算单元医生数量", (t) => t.Number }, { "医生组核算单元医生数量", (t) => t.Number },
......
...@@ -43,7 +43,7 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType) ...@@ -43,7 +43,7 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType)
var titlevalue = new List<TitleValue>(); var titlevalue = new List<TitleValue>();
var list = perforModextractRepository.GetEntities(t => (t.HospitalId == hospitalId || t.HospitalId == null) && executeType.Contains(t.ExecuteType.Value)); var list = perforModextractRepository.GetEntities(t => (t.HospitalId == hospitalId || t.HospitalId == null) && executeType.Contains(t.ExecuteType.Value));
if (list != null && list.Any()) if (list != null && list.Any())
titlevalue = list.Select(t => new TitleValue { Title = string.IsNullOrEmpty(t.Description) ? t.EName : $"{t.EName}({t.Description})", Value = t.Id.ToString() }).OrderBy(t => t.Title).ToList(); titlevalue = list.OrderBy(t => t.EName).Select(t => new TitleValue { Title = string.IsNullOrEmpty(t.Description) ? t.EName : $"{t.EName}({t.Description})", Value = t.Id.ToString() }).OrderBy(t => t.Title).ToList();
return titlevalue; return titlevalue;
} }
...@@ -140,7 +140,6 @@ public List<mod_module> Module(int hospitalId) ...@@ -140,7 +140,6 @@ public List<mod_module> Module(int hospitalId)
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
private void AddModule(int hospitalId) private void AddModule(int hospitalId)
{ {
var extractList = perforModextractRepository.GetEntities(t => t.IsEnable == 1 && t.ExecuteType == 1);
var moduleList = new mod_module[] var moduleList = new mod_module[]
{ {
new mod_module{ ModuleName = "1.0.1 额外收入", SheetType = (int)SheetType.OtherIncome }, new mod_module{ ModuleName = "1.0.1 额外收入", SheetType = (int)SheetType.OtherIncome },
...@@ -194,9 +193,9 @@ public mod_module EditModule(ModModuleRequest request) ...@@ -194,9 +193,9 @@ public mod_module EditModule(ModModuleRequest request)
throw new PerformanceException("绩效模板已存在!"); throw new PerformanceException("绩效模板已存在!");
entity.ModuleName = request.ModuleName ?? entity.ModuleName; entity.ModuleName = request.ModuleName ?? entity.ModuleName;
entity.SheetType = request.SheetType ?? entity.SheetType; entity.SheetType = request.SheetType;
entity.Description = request.Description ?? entity.Description; entity.Description = request.Description;
entity.ExtractId = request.ExtractId ?? entity.ExtractId; entity.ExtractId = request.ExtractId;
if (!perforModmoduleRepository.Update(entity)) if (!perforModmoduleRepository.Update(entity))
throw new PerformanceException("修改失败!"); throw new PerformanceException("修改失败!");
...@@ -236,7 +235,7 @@ public void DelModule(int moduleId) ...@@ -236,7 +235,7 @@ public void DelModule(int moduleId)
public List<mod_item> Items(int moduleId) public List<mod_item> Items(int moduleId)
{ {
var list = perforModitemRepository.GetEntities(t => t.ModuleId == moduleId); var list = perforModitemRepository.GetEntities(t => t.ModuleId == moduleId);
return list?.OrderBy(t => t.ItemName).ToList(); return list?.OrderBy(t => t.Id).ToList();
} }
/// <summary> /// <summary>
...@@ -427,7 +426,7 @@ public void AddItems(int moduleId) ...@@ -427,7 +426,7 @@ public void AddItems(int moduleId)
{ {
var hospitalConfig = configList.First(); var hospitalConfig = configList.First();
var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword); var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword);
string sql = "SELECT ITEM_TYPE FROM dbo.DIC_FEE GROUP BY ITEM_TYPE;"; string sql = "SELECT ITEM_TYPE FROM dbo.DIC_FEE GROUP BY ITEM_TYPE ORDER BY ITEM_TYPE;";
var dataList = perforExtractRepository.ExecuteScript(connection, sql, null); var dataList = perforExtractRepository.ExecuteScript(connection, sql, null);
if (dataList != null && dataList.Any()) if (dataList != null && dataList.Any())
{ {
...@@ -436,6 +435,7 @@ public void AddItems(int moduleId) ...@@ -436,6 +435,7 @@ public void AddItems(int moduleId)
ItemName = t.Value.ToString(), ItemName = t.Value.ToString(),
FactorValue1 = 0m, FactorValue1 = 0m,
FactorValue2 = 0m, FactorValue2 = 0m,
FactorValue3 = 0m,
ModuleId = module.Id, ModuleId = module.Id,
ExtractId = module.ExtractId, ExtractId = module.ExtractId,
ReadOnly = 1 ReadOnly = 1
......
...@@ -102,7 +102,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null) ...@@ -102,7 +102,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
{ {
//获取最大列坐标位置 //获取最大列坐标位置
int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1; int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1;
PerHeader perHead = new PerHeader(0, thiscell, "工作量绩效合计", 0, 2, 1, new List<PerHeader>(), 1); PerHeader perHead = new PerHeader(0, thiscell, "工作量绩效合计", 0, 1, 1, new List<PerHeader>(), 1);
var dataList = sheet.PerData.Select(t => (PerData)t); var dataList = sheet.PerData.Select(t => (PerData)t);
......
...@@ -32,7 +32,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) ...@@ -32,7 +32,7 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
PerDataAccountBaisc unifyUnit = new PerDataAccountBaisc(); PerDataAccountBaisc unifyUnit = new PerDataAccountBaisc();
unifyUnit.RowNumber = r; unifyUnit.RowNumber = r;
unifyUnit.UnitType = UnitType(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "核算单元类型").PointCell)?.ToString()); unifyUnit.UnitType = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "核算单元类型").PointCell)?.ToString();
unifyUnit.AccountingUnit = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "核算单元").PointCell)?.ToString(); unifyUnit.AccountingUnit = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "核算单元").PointCell)?.ToString();
unifyUnit.Department = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "科室名称").PointCell)?.ToString(); unifyUnit.Department = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "科室名称").PointCell)?.ToString();
unifyUnit.ManagerNumber = ConvertHelper.To<decimal>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "科主任/护士长人数").PointCell)?.ToString()); unifyUnit.ManagerNumber = ConvertHelper.To<decimal>(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "科主任/护士长人数").PointCell)?.ToString());
......
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