Commit b932b898 by lcx

抽取修改

parent 123c69f4
......@@ -223,7 +223,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
// 判断是那种抽取
try
{
string message = newExtractService.Judge(request.AllotId, request.HospitalId, request.UseScheme);
string message = newExtractService.Judge(request.AllotId, request.HospitalId, request.UseScheme, out string filePath);
if (!string.IsNullOrEmpty(message))
return new ApiResponse(ResponseType.Fail, message);
......@@ -233,18 +233,14 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
allot.IsExtracting = 1;
allotService.Update(allot);
var email = claim.GetUserClaim(JwtClaimTypes.Mail);
request.Email = email;
//if (request.UseScheme == (int)UseTemplate.Config)
//{
//request.Email = claim.GetUserClaim(JwtClaimTypes.Mail);
logger.LogInformation("提取绩效数据请求路径:" + url.HttpPost + "/extract/extract");
HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
//}
//else
//{
// return new ApiResponse(ResponseType.Fail, "该功能暂未实现!");
//}
//HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
if (string.IsNullOrEmpty(filePath))
HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", "");
else
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", filePath);
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
}
catch (Exception ex)
......
......@@ -118,14 +118,48 @@ public void Index([FromBody]AllotRequest request)
/// <returns></returns>
[Route("extract")]
[HttpPost]
public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email)
{
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(request));
//string filePath = newExtractService.ExtractData(request.AllotId, request.Email, request.HospitalId);
string filePath = dfExtractService.ExtractData(request.AllotId, request.Email, request.HospitalId);
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email }));
if (allotId == 0 || hospitalId == 0)
return;
var path = string.Empty;
#region 保存历史绩效文件
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
logger.LogInformation($"文件为空!");
else
{
var dpath = Path.Combine(evn.ContentRootPath, "Files", "HospitalAllot", $"{hospitalId}");
FileHelper.CreateDirectory(dpath);
path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
logger.LogInformation($"保存历史绩效文件保存路径:" + path);
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
{
logger.LogInformation($"保存历史绩效文件保存失败");
}
}
}
#endregion
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
string filePath = dfExtractService.ExtractData(allotId, email, hospitalId, path); //抽取
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
#region 保存文件到网站下
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
{
logger.LogInformation("请求路径:" + url.ImportFile + ",请求参数" + JsonHelper.Serialize(new { allotId = request.AllotId, hospitalId = request.HospitalId }));
logger.LogInformation("请求路径:" + url.ImportFile + ",请求参数" + JsonHelper.Serialize(new { allotId, hospitalId }));
int i = 1;
while (i <= 5)
{
......@@ -135,7 +169,7 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
logger.LogInformation($"正在尝试第{i}次保存!");
//保存文件
string retJson = HttpHelper.HttpClient(url.ImportFile + $"?allotId={request.AllotId}&hospitalId={request.HospitalId}", filePath);
string retJson = HttpHelper.HttpClient(url.ImportFile + $"?allotId={allotId}&hospitalId={hospitalId}", filePath);
logger.LogInformation("保存提取文件返回结果:" + JsonHelper.Serialize(retJson));
logger.LogInformation(retJson);
var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
......@@ -149,6 +183,8 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
}
else
logger.LogInformation($"保存提取文件提取文件不存在!");
#endregion
}
#endregion
......
......@@ -888,9 +888,10 @@ public void OutToExcelCell(ICell cell, object obj)
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></param>
public string Judge(int allotId, int hospitalId, int useTemplate)
public string Judge(int allotId, int hospitalId, int useTemplate, out string filePath)
{
string result = null;
filePath = "";
try
{
// 获取绩效信息
......@@ -909,6 +910,8 @@ public string Judge(int allotId, int hospitalId, int useTemplate)
var statesArray = new int[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive };
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId && statesArray.Contains(t.States));
var allotLast = allotList?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
if (allotLast != null)
filePath = allotLast.Path;
// 获取当前医院模版信息
var modulesList = perforModmoduleRepository.GetEntities(t => t.HospitalId == hospitalId);
if (modulesList == null || modulesList.Count == 0)
......
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