Commit 716adc59 by lcx

绩效抽取日志

parent 4de40ffa
......@@ -70,7 +70,7 @@ public IActionResult DownFile(int type = 1)
switch (type)
{
case 1:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xlsx");
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xls");
break;
case 2:
path = Path.Combine(env.ContentRootPath, "Template", "医院二次分配绩效模板.xlsx");
......@@ -78,6 +78,9 @@ public IActionResult DownFile(int type = 1)
case 3:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板(无执行科室).xlsx");
break;
case 4:
path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xls");
break;
}
var memoryStream = new MemoryStream();
......@@ -238,9 +241,9 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
//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)}&groupName = {request.GroupName}", "");
HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&userId={claim.GetUserId()}", "");
else
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&groupName = {request.GroupName}", filePath, true);
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&userId={claim.GetUserId()}", filePath, true);
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!", new { IsExtracting = false });
}
......@@ -357,24 +360,25 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
/// <summary>
/// 返回日志
/// </summary>
/// <param name="allotId">绩效Id</param>
/// <param name="type">1 进度条 2 信息</param>
/// <param name="tag"></param>
/// <param name="message"></param>
/// <param name="level"></param>
/// <param name="success"></param>
/// <param name="groupName"></param>
[Route("returnlog")]
[HttpPost]
[AllowAnonymous]
public void ReturnLog(int allotId, int type, string tag, string message, int level = 1, bool success = false)
public void ReturnLog(int type, string tag, string message, int level, string groupName)
{
logger.LogInformation("返回日志:" + JsonHelper.Serialize(new { type, tag, message, level, groupName }));
if (type == 3)
{
logService.Schedule(allotId, ConvertHelper.To<decimal>(message), level, success);
logService.Schedule(groupName, ConvertHelper.To<decimal>(message), level);
}
else
{
logService.ExtractLog(allotId, tag, message, level);
logService.ExtractLog(groupName, tag, message, level);
}
}
......
......@@ -83,9 +83,15 @@
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院人员绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板%28无执行科室%29.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
......
......@@ -1190,16 +1190,16 @@
<param name="hospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(System.Int32,System.Int32,System.String,System.String,System.Int32,System.Boolean)">
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(System.Int32,System.String,System.String,System.Int32,System.Boolean,System.String)">
<summary>
返回日志
</summary>
<param name="allotId">绩效Id</param>
<param name="type">1 进度条 2 信息</param>
<param name="tag"></param>
<param name="message"></param>
<param name="level"></param>
<param name="success"></param>
<param name="groupName"></param>
</member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(Performance.EntityModels.log_dbug)">
<summary>
......
......@@ -112,9 +112,9 @@ public ApiResponse Import([FromForm] IFormCollection form, int type, int hospita
/// <returns></returns>
[Route("extract")]
[HttpPost]
public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email)
public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email, string userId)
{
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email }));
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email, userId }));
if (allotId == 0 || hospitalId == 0)
return;
......@@ -149,7 +149,7 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
#endregion
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
string filePath = extractService.ExtractData(allotId, email, hospitalId, path); //抽取
string filePath = extractService.ExtractData(allotId, email, hospitalId, "User" + userId, path); //抽取
#region 保存文件到网站下
......
......@@ -38,7 +38,7 @@ public int DeleteData(int allotId)
};
string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;");
sql += "delete from log_dbug where allotid=@allotId and source=1;";
sql += "delete from log_dbug where allotid=@allotId and type=1;";
return Execute(sql, new { allotId });
}
......
......@@ -109,6 +109,9 @@ public void ClearResultData(int allotid)
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string update = "update ex_result set isdelete = 1 where allotid = @allotid ";
connection.Execute(update, new { allotid }, commandTimeout: 60 * 60);
string clear = "delete from ex_result where allotid = @allotid and isdelete = 1 and createtime < (select min(createtime) from (select distinct createtime from ex_result where allotid = @allotid and isdelete = 1 order by createtime desc limit 4) t);";
connection.Execute(clear, new { allotid }, commandTimeout: 60 * 60);
}
......
using AutoMapper;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
......@@ -330,7 +331,15 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
try
{
IWorkbook workbook = new XSSFWorkbook(path);
IWorkbook workbook = null;
var version = FileHelper.GetExtension(path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
{
workbook = (version == ExcelVersion.xlsx)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
if (workbook == null) return;
var sheet = workbook.GetSheetAt(0);
......
......@@ -64,6 +64,7 @@ public override Task OnDisconnectedAsync(Exception exception)
cache.Set(key, groupName, new TimeSpan(1, 0, 0));
logger.LogDebug($"日志推送 添加用户组{connectionId}-{groupName}");
//2 将用户插入分组
await Groups.AddToGroupAsync(connectionId, groupName);
}
......
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels.AppSettings;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Services
{
......@@ -52,36 +48,47 @@ public void WriteMsg(string tag, string message, int level, int allotId, string
/// <summary>
/// 抽取进度
/// </summary>
/// <param name="allotId"></param>
/// <param name="groupName"></param>
/// <param name="ratio"></param>
/// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param>
/// <param name="success"></param>
public void Schedule(int allotId, decimal ratio, int level = 1, bool success = false)
public void Schedule(string groupName, decimal ratio, int level)
{
if (!success && ratio > 100) ratio = 99;
ratio = Math.Round(ratio);
if (success && ratio != 100) ratio = 100;
if (level != 5 && ratio > 100) ratio = 99;
hubContext.Clients.Group($"Extract{allotId}").SendAsync("Schedule", ratio, level);
if (level == 5 && ratio != 100) ratio = 100;
hubContext.Clients.Group(groupName).SendAsync("Schedule", ratio, level);
}
/// <summary>
/// 抽取日志
/// </summary>
/// <param name="allotId"></param>
/// <param name="groupName"></param>
/// <param name="tag"></param>
/// <param name="message"></param>
/// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param>
public void ExtractLog(int allotId, string tag, string message, int level = 1)
public void ExtractLog(string groupName, string tag, string message, int level)
{
hubContext.Clients.Group($"Extract{allotId}").SendAsync("ExtractLog", tag, message, level);
hubContext.Clients.Group(groupName).SendAsync("ExtractLog", tag, message, level);
}
public void ReturnTheLog(int allotId, int type, string tag, object message, int level = 1, bool success = false)
public void ReturnTheLog(int allotId, string groupName, int type, string tag, object message, int level = 1)
{
logdbug.Add(allotId, tag, message.ToString(), level, type);
HttpHelper.HttpPostNoRequest(url.ImportFile + $"/template/returnlog?allotId={allotId}&type={type}&tag={tag}&message={message}&level={level}&success={success}", "");
try
{
var http = url.ImportFile + $"/template/returnlog?type={type}&tag={tag}&message={message}&level={level}&groupName={groupName}";
logger.LogInformation("发送日志:" + http);
logdbug.Add(allotId, tag, message.ToString(), level, type);
HttpHelper.HttpPostNoRequest(http, "");
}
catch (Exception ex)
{
logger.LogInformation("发送日志失败:" + ex.ToString());
}
}
public bool ClearExtractLog(int allotId)
......
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