渝北院领导计算 代码丢失找回

parent e6ede3ac
......@@ -217,6 +217,15 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
return new ApiResponse(ResponseType.OK);
}
[Route("recalculation")]
[HttpPost]
public ApiResponse Recalculation([FromBody] RecalculationRequest request)
{
if (request.Money.HasValue && request.Money.Value > 0)
_allotService.Recalculation(request.AllotId, request.Money.Value);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 归档绩效记录
/// </summary>
......
namespace Performance.DtoModels
{
public class RecalculationRequest
{
public int AllotId { get; set; }
public decimal? Money { get; set; }
}
}
......@@ -33,6 +33,9 @@ public class AllotService : IAutoInjection
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private readonly IOptions<Application> options;
private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository;
private PerforPeragainallotRepository _againallotRepository;
private PerforLogcheckRepository perforLogcheckRepository;
private readonly PerforHospitalRepository perforHospitalRepository;
......@@ -60,6 +63,9 @@ public class AllotService : IAutoInjection
IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService,
IOptions<Application> options,
ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository,
PerforPeragainallotRepository againallotRepository,
PerforLogcheckRepository perforLogcheckRepository,
PerforHospitalRepository perforHospitalRepository,
......@@ -84,6 +90,9 @@ public class AllotService : IAutoInjection
this.resultComputeService = resultComputeService;
this.emailService = emailService;
this.options = options;
_computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository;
this.configService = configService;
this.logdbug = logdbug;
this.perforresreservedRepository = perforresreservedRepository;
......@@ -453,6 +462,39 @@ public void Generate(per_allot allot, string mail)
}
}
public void Recalculation(int allotId, decimal money)
{
var allot = _allotRepository.GetEntity(w => w.ID == allotId);
var empolyeeList = _perforImEmployeeRepository.GetEntities(t => t.AllotID == allotId && t.AccountType == AccountUnitType.行政高层.ToString());
if (empolyeeList == null) return;
var computeEmployees = Mapper.Map<List<ComputeEmployee>>(empolyeeList);
computeEmployees.ForEach(w => w.FitPeopleValue = money);
List<res_baiscnorm> baiscnormList = new List<res_baiscnorm>();
var computResult = _computeDirector.Compute(computeEmployees, allot, baiscnormList);
if (computResult == null) return;
baiscnormList = baiscNormService.ComputeOtherAvg(baiscnormList, computResult, empolyeeList);
var historyRescompute = _perforRescomputeRepository.GetEntities(w => w.AllotID == allotId && w.AccountType == AccountUnitType.行政高层.ToString());
if (historyRescompute != null && historyRescompute.Any())
_perforRescomputeRepository.RemoveRange(historyRescompute.ToArray());
var computes = Mapper.Map<List<res_compute>>(computResult);
computes.ForEach(t => t.AllotID = allot.ID);
_perforRescomputeRepository.AddRange(computes.ToArray());
var names = baiscnormList.Select(b => b.PositionName).ToList();
var historyResbaiscnorm = perforResbaiscnormRepository.GetEntities(w => w.AllotID == allotId && names.Contains(w.PositionName));
if (historyResbaiscnorm != null && historyResbaiscnorm.Any())
perforResbaiscnormRepository.RemoveRange(historyResbaiscnorm.ToArray());
perforResbaiscnormRepository.AddRange(Mapper.Map<res_baiscnorm[]>(baiscnormList));
}
/// <summary>
/// 发送邮件
/// </summary>
......
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