Commit 2ddb327b by lcx

额外收入抽取,webclient异步传递文件

parent b932b898
...@@ -236,10 +236,11 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r ...@@ -236,10 +236,11 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
//request.Email = claim.GetUserClaim(JwtClaimTypes.Mail); //request.Email = claim.GetUserClaim(JwtClaimTypes.Mail);
logger.LogInformation("提取绩效数据请求路径:" + url.HttpPost + "/extract/extract"); logger.LogInformation("提取绩效数据请求路径:" + url.HttpPost + "/extract/extract");
//HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true); //HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", ""); HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", "");
else else
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", filePath); HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}", filePath, true);
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"); return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
} }
......
...@@ -168,7 +168,7 @@ public static void HttpPostNoRequest(string Url, string postDataStr, bool IsJson ...@@ -168,7 +168,7 @@ public static void HttpPostNoRequest(string Url, string postDataStr, bool IsJson
/// <param name="url">请求地址</param> /// <param name="url">请求地址</param>
/// <param name="file">文件路径</param> /// <param name="file">文件路径</param>
/// <returns></returns> /// <returns></returns>
public static string HttpClient(string url, string file) public static string HttpClient(string url, string file, bool IsAsync = false)
{ {
try try
{ {
...@@ -176,9 +176,15 @@ public static string HttpClient(string url, string file) ...@@ -176,9 +176,15 @@ public static string HttpClient(string url, string file)
client.Credentials = CredentialCache.DefaultCredentials; client.Credentials = CredentialCache.DefaultCredentials;
client.Headers.Add("Content-Type", "application/form-data");//注意头部必须是form-data client.Headers.Add("Content-Type", "application/form-data");//注意头部必须是form-data
client.QueryString["path"] = file; client.QueryString["path"] = file;
byte[] fileb = client.UploadFile(new Uri(url), "POST", file); if (!IsAsync)
string res = Encoding.UTF8.GetString(fileb); {
return res; byte[] fileb = client.UploadFile(new Uri(url), "POST", file);
string res = Encoding.UTF8.GetString(fileb);
return res;
}
else
client.UploadFileAsync(new Uri(url), "POST", file);
return "";
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -175,7 +175,7 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho ...@@ -175,7 +175,7 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
WriteIncome(sheet, sheetRead, unitList, configs, modules, items, extracts); WriteIncome(sheet, sheetRead, unitList, configs, modules, items, extracts);
break; break;
case SheetType.Expend: case SheetType.Expend:
WriteExpend(sheet, sheetRead, modules, items); WriteExpend(sheet, sheetRead, unitList, configs, modules, items, extracts);
break; break;
case SheetType.Workload: case SheetType.Workload:
WriteWorkload(sheet, sheetRead, unitList, configs, modules, items, extracts); WriteWorkload(sheet, sheetRead, unitList, configs, modules, items, extracts);
...@@ -241,7 +241,7 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp ...@@ -241,7 +241,7 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
break; break;
case SheetType.Expend: case SheetType.Expend:
ClearData(sheet, 5); ClearData(sheet, 5);
WriteExpend(sheet, sheetRead, modules, items, false); WriteExpend(sheet, sheetRead, unitList, configs, modules, items, extracts, false);
break; break;
case SheetType.Workload: case SheetType.Workload:
ClearData(sheet, 3); ClearData(sheet, 3);
...@@ -424,7 +424,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account ...@@ -424,7 +424,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
WriteSheetData(sheet, sheetRead, unitList, allExtract); WriteSheetData(sheet, sheetRead, unitList, allExtract);
} }
private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_module> modules, List<mod_item> items, bool IsWriteHead = true) private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
{ {
var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.Expend); var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.Expend);
if (module == null) return; if (module == null) return;
...@@ -434,6 +434,31 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_mod ...@@ -434,6 +434,31 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_mod
if (IsWriteHead) if (IsWriteHead)
WriteHeaderAndFactor(sheet, sheetRead, itemList); WriteHeaderAndFactor(sheet, sheetRead, itemList);
//查询数据
var extractIdList = itemList.Select(t => t.ExtractId).Distinct().ToList();
var extractList = extracts.Where(t => extractIdList.Contains(t.Id)).ToList();
if (extractList == null || extractList.Count == 0) return;
List<ExtractDto> allExtract = new List<ExtractDto>();
foreach (var item in extractList)
{
var category = itemList.Where(t => t.ExtractId == item.Id);
if (category == null || category.Count() == 0) continue;
foreach (var moditem in category)
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- {module.ModuleName}", 1, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 执行SQL脚本获取数据 -- {module.ModuleName},");
var config = configs.FirstOrDefault(t => t.Id == moditem.ConfigId);
if (config == null) continue;
var result = QueryDatabase(config, item, Allot, moditem.ItemName);
if (result != null)
allExtract.AddRange(result);
}
}
WriteSheetData(sheet, sheetRead, unitList, allExtract);
} }
private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true) private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
......
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