微调

parent e8433753
...@@ -155,8 +155,9 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al ...@@ -155,8 +155,9 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
var allot = _allotService.GetAllot(request.ID); var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path)) if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件"); throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
//_perExcelService.Execute(allot); var user = _claim.At(request);
BackgroundJob.Enqueue(() => _allotService.Generate(allot)); _allotService.Generate(allot, user);
//BackgroundJob.Enqueue(() => _allotService.Generate(allot, user));
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
} }
......
...@@ -22,9 +22,11 @@ public class AllotService : IAutoInjection ...@@ -22,9 +22,11 @@ public class AllotService : IAutoInjection
private ProcessComputService processComputService; private ProcessComputService processComputService;
private ResultComputeService resultComputeService; private ResultComputeService resultComputeService;
private ConfigService configService;
private IHostingEnvironment _evn; private IHostingEnvironment _evn;
private ILogger<AllotService> _logger; private ILogger<AllotService> _logger;
private PerforPerAllotRepository _allotRepository; private PerforPerAllotRepository _allotRepository;
private IEmailService emailService;
public AllotService(PerforPerAllotRepository allotRepository, public AllotService(PerforPerAllotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
...@@ -32,7 +34,9 @@ public class AllotService : IAutoInjection ...@@ -32,7 +34,9 @@ public class AllotService : IAutoInjection
ImportDataService importDataService, ImportDataService importDataService,
ProcessComputService processComputService, ProcessComputService processComputService,
ResultComputeService resultComputeService, ResultComputeService resultComputeService,
IHostingEnvironment evn, ILogger<AllotService> logger) ConfigService configService,
IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService)
{ {
_allotRepository = allotRepository; _allotRepository = allotRepository;
_logger = logger; _logger = logger;
...@@ -42,6 +46,8 @@ public class AllotService : IAutoInjection ...@@ -42,6 +46,8 @@ public class AllotService : IAutoInjection
this.importDataService = importDataService; this.importDataService = importDataService;
this.processComputService = processComputService; this.processComputService = processComputService;
this.resultComputeService = resultComputeService; this.resultComputeService = resultComputeService;
this.emailService = emailService;
this.configService = configService;
} }
#region 基础功能 #region 基础功能
...@@ -163,14 +169,21 @@ public bool Update(per_allot allot) ...@@ -163,14 +169,21 @@ public bool Update(per_allot allot)
} }
#endregion #endregion
public void Generate(per_allot allot) /// <summary>
/// 生成绩效
/// </summary>
/// <param name="allot"></param>
/// <param name="user"></param>
public void Generate(per_allot allot, UserIdentity user)
{ {
configService.Clear(allot.ID);
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.InCheckData, EnumHelper.GetDescription(AllotStates.InCheckData)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.InCheckData, EnumHelper.GetDescription(AllotStates.InCheckData));
// 导出数据 // 导出数据
var excel = importDataService.ReadDataAndSave(allot); var excel = importDataService.ReadDataAndSave(allot);
if (checkDataService.Check(excel, allot)) if (!checkDataService.Check(excel, allot))
{ {
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail));
SendEmail(allot, user);
return; return;
} }
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.InGenerate, EnumHelper.GetDescription(AllotStates.InGenerate)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.InGenerate, EnumHelper.GetDescription(AllotStates.InGenerate));
...@@ -185,12 +198,19 @@ public void Generate(per_allot allot) ...@@ -185,12 +198,19 @@ public void Generate(per_allot allot)
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
//发送邮件 //发送邮件
SendEmail(allot); SendEmail(allot, user);
} }
private void SendEmail(per_allot allot) private void SendEmail(per_allot allot, UserIdentity user)
{ {
var message = new EmailMessage
{
To = new List<string> { user.Mail },
DisplayName = "溯直健康",
Subject = "绩效生成结束",
Body = "绩效生成结束"
};
emailService.SendAsync(message);
} }
} }
} }
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