Commit 5f87b304 by 李承祥

更新exeractpath记录

parent e0dddd80
......@@ -26,12 +26,14 @@ public class TemplateController : Controller
private IHostingEnvironment evn;
private ClaimService claim;
private Application application;
private readonly AllotService allotService;
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
ExtractService extractService,
IHostingEnvironment evn,
ClaimService claim,
IOptions<Application> options)
IOptions<Application> options,
AllotService allotService)
{
this.templateService = templateService;
this.extractService = extractService;
......@@ -39,6 +41,7 @@ public class TemplateController : Controller
this.evn = evn;
this.claim = claim;
this.application = options.Value;
this.allotService = allotService;
}
/// <summary>
......@@ -100,12 +103,19 @@ public ApiResponse Import([FromForm] IFormCollection form)
/// <returns></returns>
[Route("extractdata")]
[HttpPost]
public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Delete"), FromBody]HospitalRequest request)
public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBody]AllotRequest request)
{
var hospital = hospitalService.GetHopital(request.ID);
var allot = allotService.GetAllot(request.ID);
if (allot == null)
return new ApiResponse(ResponseType.Fail, "该绩效无效");
var hospital = hospitalService.GetHopital(request.HospitalId.Value);
if (hospital == null)
return new ApiResponse(ResponseType.Fail, "医院无效");
var user = claim.At(request.Token);
//extractService.ExtractData(request.ID, user.Mail, hospital);
BackgroundJob.Enqueue(() => extractService.ExtractData(request.ID, user.Mail, hospital));
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
}
......
......@@ -48,6 +48,12 @@ public AllotRequestValidator()
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Template", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
});
}
}
}
......@@ -70,5 +70,10 @@ public class per_allot
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 提取绩效数据文件生成路径
/// </summary>
public string ExtractPath { get; set; }
}
}
......@@ -64,16 +64,16 @@ public class ExtractService : IAutoInjection
this.perforHospitalconfigRepository = perforHospitalconfigRepository;
}
public void ExtractData(int hospitalId, string mail, sys_hospital hospital)
public void ExtractData(int allotId, string mail, sys_hospital hospital)
{
List<PerSheet> sheetList = new List<PerSheet>();
try
{
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId);
var configList = perforHospitalconfigRepository.GetEntities(t => t.HospitalId == hospitalId);
var firstList = perforPerfirstRepository.GetEntities(t => t.HospitalId == hospitalId);
var scriptList = perforExtractRepository.GetEntities(t => t.HospitalId == hospitalId);
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.ID);
var configList = perforHospitalconfigRepository.GetEntities(t => t.HospitalId == hospital.ID);
var firstList = perforPerfirstRepository.GetEntities(t => t.HospitalId == hospital.ID);
var scriptList = perforExtractRepository.GetEntities(t => t.HospitalId == hospital.ID);
if (configList == null || !configList.Any())
throw new PerformanceException($"暂不支持自动提取绩效数据");
......@@ -94,16 +94,29 @@ public void ExtractData(int hospitalId, string mail, sys_hospital hospital)
else
{
//非首次 从数据库中获取人员信息,SHEET页信息,列头信息
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
sheetList = GetRepositoryData(allot.ID);
originalPath = allot.Path;
allotList = allotList.Where(t => t.Path != null && t.Path != "").ToList();
if (allotList != null && allotList.Count > 0)
{
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
sheetList = GetRepositoryData(allot.ID);
originalPath = allot.Path;
}
else
throw new PerformanceException($"历史绩效未上传文件");
}
var dpath = Path.Combine(environment.ContentRootPath, "Files", $"{hospitalId}", "autoextract");
var dpath = Path.Combine(environment.ContentRootPath, "Files", $"{hospital.ID}", "autoextract");
FileHelper.CreateDirectory(dpath);
string path = Path.Combine(dpath, $"绩效数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx");
//根据SHEET页信息,列头信息,创建EXCEL文件
if (WriteExcel(path, originalPath, sheetList, hospitalConfig, hospitalId, out string filepath))
if (WriteExcel(path, originalPath, sheetList, hospitalConfig, hospital.ID, out string filepath))
{
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
allot.ExtractPath = filepath;
if (!string.IsNullOrEmpty(filepath))
perforPerallotRepository.Update(allot);
SendEmail(mail, filepath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
}
}
catch (PerformanceException ex)
{
......
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