Commit f5b6c8d5 by 李承祥

方案抽取

parent 3a8ab121
......@@ -25,6 +25,7 @@ public class TemplateController : Controller
{
private readonly TemplateService templateService;
private readonly ExtractService extractService;
private readonly NewExtractService newExtractService;
private HospitalService hospitalService;
private IHostingEnvironment env;
private ClaimService claim;
......@@ -36,6 +37,7 @@ public class TemplateController : Controller
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
ExtractService extractService,
NewExtractService newExtractService,
IHostingEnvironment env,
ClaimService claim,
IOptions<Application> options,
......@@ -45,6 +47,7 @@ public class TemplateController : Controller
{
this.templateService = templateService;
this.extractService = extractService;
this.newExtractService = newExtractService;
this.hospitalService = hospitalService;
this.env = env;
this.claim = claim;
......@@ -194,7 +197,7 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
}
#endregion
#region 版提取
#region 版提取
/// <summary>
/// 提取绩效数据
/// </summary>
......@@ -202,13 +205,48 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
/// <returns></returns>
[Route("NewExtractData")]
[HttpPost]
public void NewExtractData([CustomizeValidator, FromBody]ExtractRequest request)
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)
throw new PerformanceException("正在提取数据,请稍等!");
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.Error, "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 特殊核算单元绩效测算表(数量、考核得分率、奖罚、其他)
......@@ -259,17 +297,22 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
[AllowAnonymous]
public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int hospitalId)
{
LogHelper.Information($"请求参数:allotId:{allotId} hospitalId:{hospitalId}", "保存提取文件");
logger.LogInformation($"保存提取文件 参数:allotId:{allotId} hospitalId:{hospitalId}");
try
{
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
{
LogHelper.Error($"返回文件为空!", "保存提取文件");
return new ApiResponse(ResponseType.Error, "上传文件无效");
}
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", "autoextract");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
LogHelper.Information($"保存路径:" + path, "保存提取文件");
using (var stream = file.OpenReadStream())
{
......@@ -287,6 +330,7 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
catch (Exception ex)
{
logger.LogInformation($"保存提取文件异常{ex.ToString()}");
LogHelper.Error($"保存失败:" + ex.ToString(), "保存提取文件");
}
return new ApiResponse(ResponseType.Error);
}
......
......@@ -58,9 +58,6 @@
<Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.DtoModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.EntityModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
......
......@@ -26,6 +26,7 @@
"WebapiUrl": {
"ImportFirst": "http://localhost:50997/api/extract/import",
"ExtractData": "http://localhost:50997/api/extract/index",
"ImportFile": ""
"ImportFile": "http://localhost:5001/api/template/savefile",
"HttpPost": "http://localhost:50997/api"
}
}
......@@ -27,6 +27,7 @@
"WebapiUrl": {
"ImportFirst": "http://localhost:50997/api/extract/import",
"ExtractData": "http://localhost:50997/api/extract/index",
"ImportFile": ""
"ImportFile": "http://localhost:5001/api/template/savefile",
"HttpPost": "http://localhost:50997/api"
}
}
......@@ -21,6 +21,11 @@ public class ExtractRequest
/// 使用方案
/// </summary>
public int UseScheme { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
}
......
......@@ -117,7 +117,25 @@ public void Index([FromBody]AllotRequest request)
[HttpPost]
public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
{
newExtractService.ExtractData(request.AllotId, "", request.HospitalId);
LogHelper.Information("请求参数:" + JsonHelper.Serialize(request), "提取绩效数据");
string filePath = newExtractService.ExtractData(request.AllotId, "", request.HospitalId);
LogHelper.Information("提取文件路径:" + filePath, "提取绩效数据");
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
{
int i = 1;
while (i <= 5)
{
LogHelper.Information("请求路径:" + url.ImportFile, "保存提取文件");
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 ((int)ret.State == 1)
break;
i++;
}
}
}
#endregion
......
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