Commit 91a49d67 by Licx

1.添加绩效类型

2.按时间倒序
3.添加验证
parent 21b54e71
......@@ -300,9 +300,12 @@ public ApiResponse GetAprGroupList([FromBody] AllotIdRequest request)
CreateDate = t.Key.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
Amount = t.Sum(s => s.Amount ?? 0),
Status = t.Any(s => s.Status == 2) ? 2 : t.Any(s => s.Status == 4) ? 4 : t.FirstOrDefault().Status,
PerforType = string.Join("/", t.Select(w => w.PerforType).Distinct()),
AuditTime = t.Any(s => s.Status == 2) ? "" : t.Max(w => w.AuditTime)?.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = t.Any(s => !s.MarkStatus.HasValue) ? "" : $"已审计{t.Max(w => w.MarkTime)?.ToString("(yyyy-MM-dd HH:mm:ss)")}"
});
if (result != null && result.Any())
result = result.OrderByDescending(o => o.CreateDate).ToList();
return new ApiResponse(ResponseType.OK, "ok", result);
}
......@@ -470,10 +473,10 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
}
var result = employeeService.ImpoerAprEmployees(allotid, path, claim.GetUserId());
return result != null && result.Any()
? new ApiResponse(ResponseType.OK)
: new ApiResponse(ResponseType.WarningTable, result);
var result = employeeService.ImportAprEmployees(allotid, path, claim.GetUserId());
return result != null && result.Count > 0
? new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", result)
: new ApiResponse(ResponseType.OK);
}
/// <summary>
......@@ -609,6 +612,8 @@ public ApiResponse GetAprHideList([FromBody] AprAmountAuditRequest request)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
var employee = employeeService.GetAprHideByTypeInDepartment(request.AllotId, request.TypeInDepartment, request.CreateDate);
if (employee != null && employee.Any())
employee = employee.OrderByDescending(o => o.CreateDate).ToList();
return new ApiResponse(ResponseType.OK, "ok", employee);
}
......@@ -635,9 +640,12 @@ public ApiResponse GetAprHideGroupList([FromBody] AllotIdRequest request)
CreateDate = t.Key.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
Amount = t.Sum(s => s.Amount ?? 0),
Status = t.Any(s => s.Status == 2) ? 2 : t.Any(s => s.Status == 4) ? 4 : t.FirstOrDefault().Status,
PerforType = string.Join("/", t.Select(w => w.PerforType).Distinct()),
AuditTime = t.Any(s => s.Status == 2) ? "" : t.Max(w => w.AuditTime)?.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = t.Any(s => !s.MarkStatus.HasValue) ? "" : $"已审计{t.Max(w => w.MarkTime)?.ToString("(yyyy-MM-dd HH:mm:ss)")}"
});
if (result != null && result.Any())
result = result.OrderByDescending(o => o.CreateDate).ToList();
return new ApiResponse(ResponseType.OK, "ok", result);
}
......@@ -805,8 +813,10 @@ public ApiResponse ImportAprHide([FromForm] IFormCollection form)
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
}
employeeService.ImpoerAprHideEmployees(allotid, path, claim.GetUserId());
return new ApiResponse(ResponseType.OK);
var result = employeeService.ImportAprHideEmployees(allotid, path, claim.GetUserId());
return result != null && result.Count > 0
? new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", result)
: new ApiResponse(ResponseType.OK);
}
/// <summary>
......
......@@ -12,6 +12,7 @@ public class OhterAmountAuditResponse
public decimal Amount { get; set; }
public int? Status { get; set; }
public string CreateDate { get; set; }
public string PerforType { get; set; }
public string AuditTime { get; set; }
public string Remark { get; set; }
}
......
......@@ -640,7 +640,7 @@ public ApiResponse AprMark(int userid, AprAmountMarkRequest request)
/// <param name="allotid"></param>
/// <param name="path"></param>
/// <param name="userid"></param>
public List<Dictionary<string, string>> ImpoerAprEmployees(int allotid, string path, int userid)
public List<Dictionary<string, string>> ImportAprEmployees(int allotid, string path, int userid)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
......@@ -726,7 +726,7 @@ public ApiResponse AprMark(int userid, AprAmountMarkRequest request)
{ "来源", "上传文件" },
{ "错误原因","“人员工号”错误,请修改或删除" },
});
else if(employee.DoctorName != entity.DoctorName)
else if (employee.DoctorName != entity.DoctorName)
errors.Add(new Dictionary<string, string>
{
{ "行号", $"第{rowindex}行" },
......@@ -740,9 +740,8 @@ public ApiResponse AprMark(int userid, AprAmountMarkRequest request)
}
// 补充核算单元
if (entities.Any())
if (errors.Count == 0 && entities.Any())
perapramountRepository.AddRange(entities.ToArray());
return errors;
}
catch (PerformanceException ex)
{
......@@ -751,8 +750,8 @@ public ApiResponse AprMark(int userid, AprAmountMarkRequest request)
catch (Exception ex)
{
logger.LogError(ex.ToString());
return errors;
}
return errors;
}
/// <summary>
......@@ -1117,11 +1116,13 @@ public ApiResponse AprMarkHide(int userid, AprAmountMarkRequest request)
/// <param name="allotid"></param>
/// <param name="path"></param>
/// <param name="userid"></param>
public void ImpoerAprHideEmployees(int allotid, string path, int userid)
public List<Dictionary<string, string>> ImportAprHideEmployees(int allotid, string path, int userid)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
List<Dictionary<string, string>> errors = new List<Dictionary<string, string>>();
var typeIn = GetTypeInDepartment(userid);
try
{
......@@ -1132,7 +1133,7 @@ public void ImpoerAprHideEmployees(int allotid, string path, int userid)
{
workbook = version == ExcelVersion.xlsx ? new XSSFWorkbook(fs) : new HSSFWorkbook(fs);
}
if (workbook == null) return;
if (workbook == null) return errors;
var sheet = workbook.GetSheetAt(0);
var firstRow = sheet.GetRow(0);
......@@ -1158,6 +1159,7 @@ public void ImpoerAprHideEmployees(int allotid, string path, int userid)
dict[key] = excelheader.First(w => w.Value == key).Key;
}
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allotid);
var entities = new List<per_apr_amount_hide>();
var createtime = DateTime.Now;
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
......@@ -1178,18 +1180,42 @@ public void ImpoerAprHideEmployees(int allotid, string path, int userid)
CreateDate = createtime,
CreateUser = userid,
};
if (string.IsNullOrEmpty(entity.DoctorName) || string.IsNullOrEmpty(entity.PersonnelNumber))
errors.Add(new Dictionary<string, string>
{
{ "行号", $"第{rowindex}行" },
{ "人员工号", entity.PersonnelNumber },
{ "姓名", entity.DoctorName },
{ "来源", "上传文件" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
var employee = employees.FirstOrDefault(w => w.PersonnelNumber == entity.PersonnelNumber);
if (employee == null)
errors.Add(new Dictionary<string, string>
{
{ "行号", $"第{rowindex}行" },
{ "人员工号", entity.PersonnelNumber },
{ "姓名", entity.DoctorName },
{ "来源", "上传文件" },
{ "错误原因","“人员工号”错误,请修改或删除" },
});
else if (employee.DoctorName != entity.DoctorName)
errors.Add(new Dictionary<string, string>
{
{ "行号", $"第{rowindex}行" },
{ "人员工号", entity.PersonnelNumber },
{ "姓名", entity.DoctorName },
{ "来源", "上传文件" },
{ "错误原因", "“姓名”错误,请修改或删除" },
});
entities.Add(entity);
}
// 补充核算单元
if (entities.Any())
{
if (entities.Any(w => string.IsNullOrEmpty(w.PersonnelNumber) && w.Amount != 0))
throw new PerformanceException("文件中存在“工号”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0))
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
if (errors.Count == 0 && entities.Any())
_hideRepository.AddRange(entities.ToArray());
}
}
catch (PerformanceException ex)
{
......@@ -1199,6 +1225,7 @@ public void ImpoerAprHideEmployees(int allotid, string path, int userid)
{
logger.LogError(ex.ToString());
}
return errors;
}
/// <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