分批发放标记

parent 2458960b
......@@ -435,8 +435,19 @@ public ApiResponse CustomColumnHeaders([FromBody] ComputerAliasRequest request)
[HttpPost]
public ApiResponse Batch([FromBody] BatchRequest request)
{
var result = _computeService.Batch(request);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
return _computeService.Batch(request);
}
/// <summary>
/// 取消全院绩效进行批次标记
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("allcompute/batch/cancel")]
[HttpPost]
public ApiResponse BatchCancel([FromBody] BatchCancelRequest request)
{
return _computeService.BatchCancel(request);
}
#region 发放表下载
......
......@@ -566,6 +566,13 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.BatchCancel(Performance.DtoModels.Request.BatchCancelRequest)">
<summary>
取消全院绩效进行批次标记
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.GetAdminPerDownload(System.Int32)">
<summary>
下载院领导、中层、工勤组绩效
......
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace Performance.DtoModels.Request
{
public class BatchCancelRequest
{
public int HospitalId { get; set; }
public int AllotId { get; set; }
public List<BatchDetail> Details { get; set; }
}
public class BatchRequest
{
public int HospitalId { get; set; }
public int AllotId { get; set; }
public string Batch { get; set; }
public DateTime? BatchDate { get; set; }
public string BankName { get; set; }
public List<BatchDetail> Details { get; set; }
}
......
......@@ -40,6 +40,7 @@ public class per_batch
/// 批次日期
/// </summary>
public DateTime BatchDate { get; set; }
public string BankName { get; set; }
/// <summary>
/// 核算单元分类
......
......@@ -2139,29 +2139,115 @@ public List<cof_alias> CustomColumnHeaders(int hospitalId, string route, params
return init?.OrderBy(t => t.Sort).ToList();
}
public bool Batch(BatchRequest request)
#region 标记批次号
/// <summary>
/// 标记批次号
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="PerformanceException"></exception>
public ApiResponse Batch(BatchRequest request)
{
if (request == null || request.Details == null || !request.Details.Any())
throw new PerformanceException("参数错误");
throw new PerformanceException("提交了空白的人员信息,当前操作已拒绝");
if (string.IsNullOrEmpty(request.Batch))
throw new PerformanceException("“批次信息”空白,当前操作已拒绝");
var batchs = perforPerbatchRepository.GetEntities(w => w.AllotId == request.AllotId) ?? new List<per_batch>();
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
foreach (var item in request.Details)
{
var bt = batchs.FirstOrDefault(w => !string.IsNullOrEmpty(w.Batch) && w.UnitType == item.UnitType && w.AccountingUnit == item.AccountingUnit && w.PersonnelNumber == item.JobNumber);
if (bt != null)
{
error.Add(new Dictionary<string, string>
{
{ "核算组别", item.UnitType??"" },
{ "核算单元", item.AccountingUnit??"" },
{ "人员工号", item.JobNumber??"" },
{ "姓名", item.EmployeeName??"" },
{ "错误原因",$"已经标记;请取消标记后重试;批次“{bt.Batch}”" },
});
}
if (string.IsNullOrEmpty(item.UnitType) || string.IsNullOrEmpty(item.AccountingUnit) || string.IsNullOrEmpty(item.JobNumber))
{
error.Add(new Dictionary<string, string>
{
{ "核算组别", item.UnitType??"" },
{ "核算单元", item.AccountingUnit??"" },
{ "人员工号", item.JobNumber??"" },
{ "姓名", item.EmployeeName??"" },
{ "错误原因",$"关键信息缺失" },
});
}
}
if (request.Details.Any(t => !string.IsNullOrEmpty(t.Batch)))
throw new PerformanceException("包含已标记数据");
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
DateTime dateTime = DateTime.Now;
string batch = DateTime.Now.ToString("yyyyMMddfff");
var data = request.Details.Select(t => new per_batch
{
HospitalId = request.HospitalId,
AllotId = request.AllotId,
Batch = batch,
BatchDate = dateTime,
Batch = request.Batch,
BatchDate = request.BatchDate ?? DateTime.Now,
BankName = request.BankName,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
PersonnelNumber = t.JobNumber,
PersonnelName = t.EmployeeName
});
return perforPerbatchRepository.AddRange(data.ToArray());
perforPerbatchRepository.AddRange(data.ToArray());
return new ApiResponse(ResponseType.OK, "标记成功");
}
/// <summary>
/// 取消标记
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="PerformanceException"></exception>
public ApiResponse BatchCancel(BatchCancelRequest request)
{
if (request == null || request.Details == null || !request.Details.Any())
throw new PerformanceException("提交了空白的人员信息,当前操作已拒绝");
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
var batchs = perforPerbatchRepository.GetEntities(w => w.AllotId == request.AllotId) ?? new List<per_batch>();
var deletes = new List<per_batch>();
foreach (var item in request.Details)
{
if (string.IsNullOrEmpty(item.UnitType) || string.IsNullOrEmpty(item.AccountingUnit) || string.IsNullOrEmpty(item.JobNumber))
{
error.Add(new Dictionary<string, string>
{
{ "核算组别", item.UnitType??"" },
{ "核算单元", item.AccountingUnit??"" },
{ "人员工号", item.JobNumber??"" },
{ "姓名", item.EmployeeName??"" },
{ "错误原因",$"关键信息缺失" },
});
}
var bt = batchs.FirstOrDefault(w => w.UnitType == item.UnitType && w.AccountingUnit == item.AccountingUnit && w.PersonnelNumber == item.JobNumber);
if (bt != null)
{
deletes.Add(bt);
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
if (deletes.Count > 0)
perforPerbatchRepository.RemoveRange(deletes.ToArray());
return new ApiResponse(ResponseType.OK, "取消标记操作成功");
}
#endregion
public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewName)
{
......
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