Commit e36acb62 by lcx

修改返回日志方式

parent 9182833f
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
...@@ -235,13 +236,13 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -235,13 +236,13 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
if (allot.States == (int)AllotStates.Wait) if (allot.States == (int)AllotStates.Wait)
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成"); return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
int userId = _claim.GetUserId(); string key = NotificationsService.AllotGenerateKeyPrefix + allot.ID;
var uuid = Guid.NewGuid().ToString("N"); _notificationsService.SetCache(key, new SingleData(Guid.NewGuid().ToString("N"), _claim.GetUserId()));
_notificationsService.SendGenerateMessage(userId, allot.ID, $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!"); _notificationsService.SendGenerateMessage(allot.ID, $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!");
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate); _allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
if (_evn.IsEnvironment("Localhost")) if (_evn.IsEnvironment("Localhost"))
{ {
_allotService.Generate(allot, email, uuid, userId); _allotService.Generate(allot, email);
} }
else else
{ {
...@@ -252,13 +253,13 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -252,13 +253,13 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
{ {
var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>(); var scopedServices = scope.ServiceProvider.GetRequiredService<AllotService>();
scopedServices.Generate(allot, email, uuid, userId); scopedServices.Generate(allot, email);
await Task.Delay(TimeSpan.FromSeconds(5), token); await Task.Delay(TimeSpan.FromSeconds(5), token);
} }
}); });
} }
_notificationsService.SendGenerateMessage(userId, allot.ID, $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!"); _notificationsService.SendGenerateMessage(allot.ID, $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!");
//_allotService.Generate(allot, email); //_allotService.Generate(allot, email);
////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email)); ////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email));
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
...@@ -273,7 +274,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request) ...@@ -273,7 +274,7 @@ public ApiResponse Recalculation([FromBody] RecalculationRequest request)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
*/ */
/// <summary> /// <summary>
/// 重新计算院领导绩效 /// 重新计算院领导绩效
/// </summary> /// </summary>
......
...@@ -35,7 +35,7 @@ public class TemplateController : Controller ...@@ -35,7 +35,7 @@ public class TemplateController : Controller
private readonly ExConfigService configService; private readonly ExConfigService configService;
private readonly HospitalService hospitalService; private readonly HospitalService hospitalService;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly LogManageService logService; private readonly NotificationsService notificationsService;
private readonly IServiceScopeFactory serviceScopeFactory; private readonly IServiceScopeFactory serviceScopeFactory;
public TemplateController( public TemplateController(
...@@ -49,7 +49,7 @@ public class TemplateController : Controller ...@@ -49,7 +49,7 @@ public class TemplateController : Controller
ExConfigService configService, ExConfigService configService,
HospitalService hospitalService, HospitalService hospitalService,
AllotService allotService, AllotService allotService,
LogManageService logService, NotificationsService notificationsService,
IServiceScopeFactory serviceScopeFactory) IServiceScopeFactory serviceScopeFactory)
{ {
this.logger = logger; this.logger = logger;
...@@ -62,7 +62,7 @@ public class TemplateController : Controller ...@@ -62,7 +62,7 @@ public class TemplateController : Controller
this.configService = configService; this.configService = configService;
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.allotService = allotService; this.allotService = allotService;
this.logService = logService; this.notificationsService = notificationsService;
this.serviceScopeFactory = serviceScopeFactory; this.serviceScopeFactory = serviceScopeFactory;
} }
...@@ -365,18 +365,10 @@ public ApiResponse SaveFile() ...@@ -365,18 +365,10 @@ public ApiResponse SaveFile()
/// <param name="request"></param> /// <param name="request"></param>
[Route("returnlog")] [Route("returnlog")]
[HttpPost] [HttpPost]
[AllowAnonymous] public void ReturnLog([FromBody] MessageInfo request)
public void ReturnLog([FromBody] SignalrLogRequest request)
{ {
logger.LogInformation("返回日志:" + JsonHelper.Serialize(request)); logger.LogInformation("返回日志:" + JsonHelper.Serialize(request));
if (request.Type == 3) notificationsService.SendMessage(claim.GetUserId(), request);
{
logService.Schedule(request.GroupName, ConvertHelper.To<decimal>(request.Message), request.Level);
}
else
{
logService.ExtractLog(request.GroupName, request.Tag, request.Message, request.Level);
}
} }
/// <summary> /// <summary>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class SingleData
{
public string Uuid { get; set; }
public int UserId { get; set; }
public SingleData()
{
}
public SingleData(string uuid, int userId)
{
Uuid = uuid;
UserId = userId;
}
}
}
...@@ -30,8 +30,7 @@ public class ImportDataService : IAutoInjection ...@@ -30,8 +30,7 @@ public class ImportDataService : IAutoInjection
private PerforImspecialunitRepository perforImspecialunitRepository; private PerforImspecialunitRepository perforImspecialunitRepository;
private PerforImemployeeclinicRepository perforImemployeeclinicRepository; private PerforImemployeeclinicRepository perforImemployeeclinicRepository;
private PerforImemployeelogisticsRepository perforImemployeelogisticsRepository; private PerforImemployeelogisticsRepository perforImemployeelogisticsRepository;
//private PerforLogdbugRepository logdbug; private readonly NotificationsService notificationsService;
private readonly LogManageService logManageService;
private ILogger<ImportDataService> logger; private ILogger<ImportDataService> logger;
public ImportDataService(PerSheetService perSheetService, public ImportDataService(PerSheetService perSheetService,
...@@ -44,8 +43,7 @@ public class ImportDataService : IAutoInjection ...@@ -44,8 +43,7 @@ public class ImportDataService : IAutoInjection
PerforImspecialunitRepository perforImspecialunitRepository, PerforImspecialunitRepository perforImspecialunitRepository,
PerforImemployeeclinicRepository perforImemployeeclinicRepository, PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository, PerforImemployeelogisticsRepository perforImemployeelogisticsRepository,
//PerforLogdbugRepository logdbug NotificationsService notificationsService,
LogManageService logManageService,
ILogger<ImportDataService> logger) ILogger<ImportDataService> logger)
{ {
this.perSheetService = perSheetService; this.perSheetService = perSheetService;
...@@ -58,8 +56,7 @@ public class ImportDataService : IAutoInjection ...@@ -58,8 +56,7 @@ public class ImportDataService : IAutoInjection
this.perforImspecialunitRepository = perforImspecialunitRepository; this.perforImspecialunitRepository = perforImspecialunitRepository;
this.perforImemployeeclinicRepository = perforImemployeeclinicRepository; this.perforImemployeeclinicRepository = perforImemployeeclinicRepository;
this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository; this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository;
//this.logdbug = logdbug; this.notificationsService = notificationsService;
this.logManageService = logManageService;
this.logger = logger; this.logger = logger;
} }
...@@ -111,7 +108,7 @@ private PerExcel Import(per_allot allot) ...@@ -111,7 +108,7 @@ private PerExcel Import(per_allot allot)
} }
if (SheetType.Unidentifiable != sheetType) if (SheetType.Unidentifiable != sheetType)
{ {
logManageService.WriteMsg("开始读取excel文件", $"开始读取sheet -- {sheet.SheetName}", 1, allot.ID, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allot.ID, $"开始读取excel文件:开始读取sheet -- {sheet.SheetName}");
try try
{ {
var st = perSheetService.Sheet(sheet, isnew); var st = perSheetService.Sheet(sheet, isnew);
...@@ -119,7 +116,7 @@ private PerExcel Import(per_allot allot) ...@@ -119,7 +116,7 @@ private PerExcel Import(per_allot allot)
} }
catch (Exception ex) catch (Exception ex)
{ {
logManageService.WriteMsg("读取excel文件", ex.Message.ToString(), 4, allot.ID, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allot.ID, $"读取excel文件:{ex.Message}。", ComponentType.error);
throw ex; throw ex;
} }
} }
...@@ -129,7 +126,7 @@ private PerExcel Import(per_allot allot) ...@@ -129,7 +126,7 @@ private PerExcel Import(per_allot allot)
isnew = true; isnew = true;
} }
} }
logManageService.WriteMsg("开始读取excel文件", $"excel文件基础数据读取完成!", 1, allot.ID, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allot.ID, $"开始读取excel文件:excel文件基础数据读取完成!");
return excel; return excel;
} }
} }
...@@ -391,7 +388,7 @@ private bool Save(PerExcel excel, int allotId) ...@@ -391,7 +388,7 @@ private bool Save(PerExcel excel, int allotId)
{ {
foreach (var sheet in excel.PerSheet) foreach (var sheet in excel.PerSheet)
{ {
logManageService.WriteMsg("保存基础数据", $"开始保存数据 -- {sheet.SheetName}", 1, allotId, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allotId, $"保存基础数据:开始保存数据 -- {sheet.SheetName}。");
if (sheet.SheetType == SheetType.Employee) if (sheet.SheetType == SheetType.Employee)
{ {
var imsheetid = SaveEmployee(sheet, allotId); var imsheetid = SaveEmployee(sheet, allotId);
...@@ -423,7 +420,7 @@ private bool Save(PerExcel excel, int allotId) ...@@ -423,7 +420,7 @@ private bool Save(PerExcel excel, int allotId)
SaveHeader(sheet, allotId, imsheetid); SaveHeader(sheet, allotId, imsheetid);
} }
} }
logManageService.WriteMsg("保存基础数据", $"基础数据保存完成!", 1, allotId, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allotId, $"保存基础数据:基础数据保存完成!");
return true; return true;
} }
} }
......
...@@ -27,7 +27,7 @@ public class ProcessComputService : IAutoInjection ...@@ -27,7 +27,7 @@ public class ProcessComputService : IAutoInjection
private PerforCofdrugtypeRepository perforCofdrugtypeRepository; private PerforCofdrugtypeRepository perforCofdrugtypeRepository;
private PerforCofworkitemRepository perforCofworkitemRepository; private PerforCofworkitemRepository perforCofworkitemRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository; private readonly PerforRescomputeRepository perforRescomputeRepository;
private readonly LogManageService logManageService; private readonly NotificationsService notificationsService;
private readonly GuaranteeService guaranteeService; private readonly GuaranteeService guaranteeService;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
...@@ -44,7 +44,7 @@ public class ProcessComputService : IAutoInjection ...@@ -44,7 +44,7 @@ public class ProcessComputService : IAutoInjection
PerforCofdrugtypeRepository perforCofdrugtypeRepository, PerforCofdrugtypeRepository perforCofdrugtypeRepository,
PerforCofworkitemRepository perforCofworkitemRepository, PerforCofworkitemRepository perforCofworkitemRepository,
PerforRescomputeRepository perforRescomputeRepository, PerforRescomputeRepository perforRescomputeRepository,
LogManageService logManageService, NotificationsService notificationsService,
GuaranteeService guaranteeService, GuaranteeService guaranteeService,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository) PerforPerallotRepository perallotRepository)
...@@ -60,7 +60,7 @@ public class ProcessComputService : IAutoInjection ...@@ -60,7 +60,7 @@ public class ProcessComputService : IAutoInjection
this.perforCofdrugtypeRepository = perforCofdrugtypeRepository; this.perforCofdrugtypeRepository = perforCofdrugtypeRepository;
this.perforCofworkitemRepository = perforCofworkitemRepository; this.perforCofworkitemRepository = perforCofworkitemRepository;
this.perforRescomputeRepository = perforRescomputeRepository; this.perforRescomputeRepository = perforRescomputeRepository;
this.logManageService = logManageService; this.notificationsService = notificationsService;
this.guaranteeService = guaranteeService; this.guaranteeService = guaranteeService;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
...@@ -162,7 +162,7 @@ public void Save(List<PerSheet> perSheets, int allotId) ...@@ -162,7 +162,7 @@ public void Save(List<PerSheet> perSheets, int allotId)
{ {
foreach (var sheet in perSheets) foreach (var sheet in perSheets)
{ {
logManageService.WriteMsg("正在生成绩效", $"保存核算数据 - {sheet.SheetName}", 1, allotId, "ReceiveMessage"); notificationsService.SendGenerateMessage(allotId, $"正在生成绩效:保存核算数据 - {sheet.SheetName}");
if (sheet.SheetType == SheetType.ComputeDoctorAccount || sheet.SheetType == SheetType.ComputeNurseAccount) if (sheet.SheetType == SheetType.ComputeDoctorAccount || sheet.SheetType == SheetType.ComputeNurseAccount)
{ {
SaveComputeAccount(sheet, allotId); SaveComputeAccount(sheet, allotId);
......
...@@ -17,7 +17,6 @@ public class ConfigService : IAutoInjection ...@@ -17,7 +17,6 @@ public class ConfigService : IAutoInjection
{ {
#region #region
private PerforCofdirectorRepository _directorRepository; private PerforCofdirectorRepository _directorRepository;
//private PerforCofdrugpropRepository _drugpropRepository;
private PerforCofworkitemRepository _workitemRepository; private PerforCofworkitemRepository _workitemRepository;
private PerforCofagainRepository _againRepository; private PerforCofagainRepository _againRepository;
private PerforCofdrugtypeRepository _drugtypeRepository; private PerforCofdrugtypeRepository _drugtypeRepository;
...@@ -27,14 +26,12 @@ public class ConfigService : IAutoInjection ...@@ -27,14 +26,12 @@ public class ConfigService : IAutoInjection
private PerforImheaderRepository perforImheaderRepository; private PerforImheaderRepository perforImheaderRepository;
private PerforCofdepttypeRepository perforCofdepttypeRepository; private PerforCofdepttypeRepository perforCofdepttypeRepository;
private PerforPerapramountRepository perapramountRepository; private PerforPerapramountRepository perapramountRepository;
//private PerforCofcmiRepository perforCofcmiRepository;
private PerforCofHrpDeptRepository perforCofHrpDeptRepository; private PerforCofHrpDeptRepository perforCofHrpDeptRepository;
private PersonService personService; private PersonService personService;
private LogManageService logManageService; private NotificationsService notificationsService;
private ILogger<ConfigService> logger; private ILogger<ConfigService> logger;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository, public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofagainRepository againRepository, PerforCofagainRepository againRepository,
PerforCofdrugtypeRepository drugtypeRepository, PerforCofdrugtypeRepository drugtypeRepository,
PerforPerallotRepository perforPerAllotRepository, PerforPerallotRepository perforPerAllotRepository,
...@@ -44,14 +41,12 @@ public class ConfigService : IAutoInjection ...@@ -44,14 +41,12 @@ public class ConfigService : IAutoInjection
PerforImheaderRepository perforImheaderRepository, PerforImheaderRepository perforImheaderRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository, PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforPerapramountRepository perapramountRepository, PerforPerapramountRepository perapramountRepository,
//PerforCofcmiRepository perforCofcmiRepository,
PerforCofHrpDeptRepository perforCofHrpDeptRepository, PerforCofHrpDeptRepository perforCofHrpDeptRepository,
PersonService personService, PersonService personService,
LogManageService logManageService, NotificationsService notificationsService,
ILogger<ConfigService> logger) ILogger<ConfigService> logger)
{ {
this._directorRepository = cofdirectorRepository; this._directorRepository = cofdirectorRepository;
//this._drugpropRepository = cofdrugpropRepository;
this._workitemRepository = workitemRepository; this._workitemRepository = workitemRepository;
this._againRepository = againRepository; this._againRepository = againRepository;
this._drugtypeRepository = drugtypeRepository; this._drugtypeRepository = drugtypeRepository;
...@@ -64,7 +59,7 @@ public class ConfigService : IAutoInjection ...@@ -64,7 +59,7 @@ public class ConfigService : IAutoInjection
//this.perforCofcmiRepository = perforCofcmiRepository; //this.perforCofcmiRepository = perforCofcmiRepository;
this.perforCofHrpDeptRepository = perforCofHrpDeptRepository; this.perforCofHrpDeptRepository = perforCofHrpDeptRepository;
this.personService = personService; this.personService = personService;
this.logManageService = logManageService; this.notificationsService = notificationsService;
this.logger = logger; this.logger = logger;
} }
...@@ -753,7 +748,7 @@ public void Copy(per_allot allot) ...@@ -753,7 +748,7 @@ public void Copy(per_allot allot)
public void Clear(int allotId) public void Clear(int allotId)
{ {
var count = _directorRepository.DeleteData(allotId); var count = _directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allotId, $"清理无效数据:清理无效数据,受影响行数:{count}。");
} }
/// <summary> /// <summary>
...@@ -763,7 +758,7 @@ public void Clear(int allotId) ...@@ -763,7 +758,7 @@ public void Clear(int allotId)
public void ClearAllotData(int allotId) public void ClearAllotData(int allotId)
{ {
var count = _directorRepository.DeleteAllotData(allotId); var count = _directorRepository.DeleteAllotData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allotId, $"清理无效数据:清理无效数据,受影响行数:{count}。");
} }
/// <summary> /// <summary>
...@@ -773,7 +768,7 @@ public void ClearAllotData(int allotId) ...@@ -773,7 +768,7 @@ public void ClearAllotData(int allotId)
public void ClearResData(int allotId) public void ClearResData(int allotId)
{ {
var count = _directorRepository.DeleteResData(allotId); var count = _directorRepository.DeleteResData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true); notificationsService.SendGenerateMessage(allotId, $"清理无效数据:清理无效数据,受影响行数:{count}。");
} }
/// <summary> /// <summary>
...@@ -783,7 +778,7 @@ public void ClearResData(int allotId) ...@@ -783,7 +778,7 @@ public void ClearResData(int allotId)
public void ClearAgain(int againId) public void ClearAgain(int againId)
{ {
var count = _directorRepository.DelAgain(againId); var count = _directorRepository.DelAgain(againId);
logManageService.WriteMsg("清理无效数据", $"清除二次绩效中无效数据,受影响行数:{count}", 1, againId, "ReceiveMessage", true); //notificationsService.SendGenerateMessage(againId, $"清理无效数据:清除二次绩效中无效数据,受影响行数:{count}。");
} }
#endregion #endregion
...@@ -838,7 +833,7 @@ private void CopyAprData(int prevAllotId, int allotId) ...@@ -838,7 +833,7 @@ private void CopyAprData(int prevAllotId, int allotId)
} }
} }
public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId) public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
{ {
var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission
{ {
...@@ -858,7 +853,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId) ...@@ -858,7 +853,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId)
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json); var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in HrpDept join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList(); var cells = (from conf in HrpDept join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
...@@ -866,9 +861,9 @@ public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId) ...@@ -866,9 +861,9 @@ public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId)
return result; return result;
} }
public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData request) public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData request)
{ {
var dicData = CreateDataRow(hospitalId,allotId, request, HrpDept); var dicData = CreateDataRow(hospitalId, allotId, request, HrpDept);
List<cof_hrp_department> depts = new List<cof_hrp_department>(); List<cof_hrp_department> depts = new List<cof_hrp_department>();
foreach (var item in dicData) foreach (var item in dicData)
...@@ -884,7 +879,7 @@ public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData reques ...@@ -884,7 +879,7 @@ public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData reques
} }
perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid" perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
, new {hospitalId, allotId }); , new { hospitalId, allotId });
perforCofHrpDeptRepository.AddRange(depts.ToArray()); perforCofHrpDeptRepository.AddRange(depts.ToArray());
} }
...@@ -897,7 +892,7 @@ public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData reques ...@@ -897,7 +892,7 @@ public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData reques
// 创建固定数据列 // 创建固定数据列
Dictionary<string, string> baseData = CreateBaseData(request, config, r); Dictionary<string, string> baseData = CreateBaseData(request, config, r);
baseData.Add(nameof(cof_hrp_department.AllotId), allotId.ToString()); baseData.Add(nameof(cof_hrp_department.AllotId), allotId.ToString());
baseData.Add(nameof(cof_hrp_department.HospitalId),hospitalId.ToString()); baseData.Add(nameof(cof_hrp_department.HospitalId), hospitalId.ToString());
allData.Add(baseData); allData.Add(baseData);
} }
......
...@@ -13,29 +13,22 @@ namespace Performance.Services ...@@ -13,29 +13,22 @@ namespace Performance.Services
[Authorize] [Authorize]
public class AllotLogHub : Hub public class AllotLogHub : Hub
{ {
private readonly IMemoryCache cache;
private readonly ILogger<AllotLogHub> logger; private readonly ILogger<AllotLogHub> logger;
private readonly NotificationsService service;
public AllotLogHub( public AllotLogHub(
IMemoryCache cache, ILogger<AllotLogHub> logger,
ILogger<AllotLogHub> logger NotificationsService service
) )
{ {
this.cache = cache;
this.logger = logger; this.logger = logger;
this.service = service;
} }
public override Task OnConnectedAsync() public override Task OnConnectedAsync()
{ {
string key = Context.User.Claims.FirstOrDefault(t => t.Type == "id")?.Value; string key = Context.User.Claims.FirstOrDefault(t => t.Type == "id")?.Value;
if (!string.IsNullOrEmpty(key)) service.SetCache(key, Context.ConnectionId);
{
if (cache.TryGetValue(key, out _))
{
cache.Remove(key);
}
cache.Set(key, Context.ConnectionId);
}
logger.LogInformation($"用户在{DateTime.Now.ToString("yyyy年MM月dd日 hh时mm分ss秒")}创建连接"); logger.LogInformation($"用户在{DateTime.Now.ToString("yyyy年MM月dd日 hh时mm分ss秒")}创建连接");
return base.OnConnectedAsync(); return base.OnConnectedAsync();
} }
...@@ -43,13 +36,7 @@ public override Task OnConnectedAsync() ...@@ -43,13 +36,7 @@ public override Task OnConnectedAsync()
public override Task OnDisconnectedAsync(Exception exception) public override Task OnDisconnectedAsync(Exception exception)
{ {
string key = Context.User.Claims.FirstOrDefault(t => t.Type == "id")?.Value; string key = Context.User.Claims.FirstOrDefault(t => t.Type == "id")?.Value;
if (!string.IsNullOrEmpty(key)) service.RemoveCache(key);
{
if (cache.TryGetValue(key, out _))
{
cache.Remove(key);
}
}
logger.LogInformation($"用户在{DateTime.Now.ToString("yyyy年MM月dd日 hh时mm分ss秒")}断开连接"); logger.LogInformation($"用户在{DateTime.Now.ToString("yyyy年MM月dd日 hh时mm分ss秒")}断开连接");
return base.OnDisconnectedAsync(exception); return base.OnDisconnectedAsync(exception);
} }
......
...@@ -32,18 +32,30 @@ PerforLogdsignalrRepository repository ...@@ -32,18 +32,30 @@ PerforLogdsignalrRepository repository
this.repository = repository; this.repository = repository;
} }
public void SendGenerateMessage(int userId, int allotId, string message, ComponentType type = ComponentType.info) public const string AllotGenerateKeyPrefix = "Allot-Generate-";
public void SendGenerateMessage(int allotId, string message, ComponentType type = ComponentType.info)
{ {
var info = new MessageInfo("", allotId, "生成绩效", message, Component.Notification, type); var data = GetCache<SingleData>(AllotGenerateKeyPrefix + allotId);
SendMessage(userId, info); if (data == null || data.UserId == 0)
} return;
var info = new MessageInfo(data.Uuid, allotId, "生成绩效", message, Component.Notification, type);
SendMessage(data.UserId, info);
}
public void SendMessage(int userId, MessageInfo data) public void SendMessage(int userId, MessageInfo data)
{ {
string key = userId.ToString(); string key = userId.ToString();
if (cache.TryGetValue(key, out string connectionId) && !string.IsNullOrEmpty(connectionId)) if (cache.TryGetValue(key, out string connectionId) && !string.IsNullOrEmpty(connectionId))
{ {
if (data.Component == Component.Progress)
{
var percentage = ConvertHelper.To<decimal>(data.Message);
data.Message = (data.Status == ComponentType.success
? 100
: (data.Status != ComponentType.success && percentage >= 100) ? 99 : percentage).ToString();
}
SendMessageToClient(connectionId, data); SendMessageToClient(connectionId, data);
} }
} }
...@@ -57,5 +69,64 @@ private void SendMessageToClient(string connectionId, MessageInfo data, string m ...@@ -57,5 +69,64 @@ private void SendMessageToClient(string connectionId, MessageInfo data, string m
{ {
hubContext.Clients.Client(connectionId).SendAsync(method, data.Title, data); hubContext.Clients.Client(connectionId).SendAsync(method, data.Title, data);
} }
#region 缓存
/// <summary>
/// 添加缓存
/// </summary>
/// <param name="key">缓存Key</param>
/// <param name="value">缓存Value</param>
public void SetCache(string key, object value)
{
if (!string.IsNullOrEmpty(key))
{
if (cache.TryGetValue(key, out _))
{
cache.Remove(key);
}
cache.Set(key, value);
}
}
/// <summary>
/// 删除缓存
/// </summary>
/// <param name="key">缓存Key</param>
public void RemoveCache(string key)
{
if (!string.IsNullOrEmpty(key))
{
cache.Remove(key);
}
}
/// <summary>
/// 获取缓存
/// </summary>
/// <param name="key">缓存Key</param>
/// <returns></returns>
public T GetCache<T>(string key) where T : class
{
if (key == null)
throw new ArgumentNullException(nameof(key));
return cache.Get(key) as T;
}
/// <summary>
/// 获取缓存
/// </summary>
/// <param name="key">缓存Key</param>
/// <returns></returns>
public object GetCache(string key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
return cache.Get(key);
}
#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