Commit 2c0b4dc7 by 李承祥

绩效归档,归档前检查数据

parent 741530f5
......@@ -74,11 +74,10 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var again = againAllotService.GetAgainallot(againid);
if (again == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
var allot = allotService.GetAllot(again.AllotID.Value);
if (again == null || allot == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName);
......
......@@ -160,5 +160,37 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
BackgroundJob.Enqueue(() => _allotService.Generate(allot, user));
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 归档绩效记录
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("pigeonhole")]
[HttpPost]
public ApiResponse Pigeonhole([CustomizeValidator(RuleSet = "Delete"), FromBody]AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
_allotService.Pigeonhole(allot);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 检索数据是否合格
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("checkdata")]
[HttpPost]
public ApiResponse CheckData([CustomizeValidator(RuleSet = "Delete"), FromBody]AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
var list = _allotService.CheckData(allot);
return new ApiResponse(ResponseType.OK, list);
}
}
}
......@@ -42,7 +42,7 @@ public class AgainAllotResponse
public string Path { get; set; }
/// <summary>
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败 5 归档
/// </summary>
public Nullable<int> States { get; set; }
}
......
......@@ -52,7 +52,7 @@ public class per_againallot
public string Path { get; set; }
/// <summary>
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败 5 归档
/// </summary>
public Nullable<int> States { get; set; }
......
......@@ -392,13 +392,13 @@ public List<AgainAllotResponse> GetAllotList(int userid)
}
/// <summary>
/// 获取二次绩效的记录
/// 获取状态不是归档的二次绩效的记录
/// </summary>
/// <param name="againid"></param>
/// <returns></returns>
public per_againallot GetAgainallot(int againid)
{
var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid && t.States != 5);
return list;
}
}
......
......@@ -28,6 +28,7 @@ public class AllotService : IAutoInjection
private ILogger<AllotService> _logger;
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private PerforPeragainallotRepository _againallotRepository;
public AllotService(PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService,
......@@ -38,9 +39,11 @@ public class AllotService : IAutoInjection
ConfigService configService,
PerforLogdbugRepository logdbug,
IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService)
IEmailService emailService,
PerforPeragainallotRepository againallotRepository)
{
_allotRepository = allotRepository;
_againallotRepository = againallotRepository;
_logger = logger;
_evn = evn;
this.baiscNormService = baiscNormService;
......@@ -219,6 +222,13 @@ public void Generate(per_allot allot, UserIdentity user)
}
}
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="allot"></param>
/// <param name="mail"></param>
/// <param name="subject"></param>
/// <param name="body"></param>
private void SendEmail(per_allot allot, string mail, string subject, string body)
{
var message = new EmailMessage
......@@ -230,5 +240,41 @@ private void SendEmail(per_allot allot, string mail, string subject, string body
};
emailService.SendAsync(message);
}
/// <summary>
/// 归档绩效记录
/// </summary>
/// <param name="allot"></param>
public void Pigeonhole(per_allot allot)
{
allot.States = 8;
allot.Remark = "归档";
if (_allotRepository.Update(allot))
{
var again = _againallotRepository.GetEntities(t => t.AllotID == allot.ID);
foreach (var item in again)
{
item.States = 5;
item.Remark = "归档";
_againallotRepository.Update(item);
}
}
}
/// <summary>
/// 检索数据是否合格
/// </summary>
/// <param name="allot"></param>
public List<AgainAllotResponse> CheckData(per_allot allot)
{
List<int> states = new List<int>() { 0, 1, 2, 4 };
var again = _againallotRepository.GetEntities(t => t.AllotID == allot.ID && states.Contains(t.States.Value));
List<AgainAllotResponse> result = Mapper.Map<List<AgainAllotResponse>>(again);
if (result != null && result.Count > 0)
{
result.ForEach(t => { t.Year = allot.Year; t.Month = allot.Month; });
}
return result;
}
}
}
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