Commit 82be2bf2 by 钟博

绩效发放表排序,医院其他绩效添加时核对人员字典

parent 8279aa70
......@@ -436,8 +436,8 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
}
employeeService.ImpoerAprEmployees(allotid, path, claim.GetUserId());
return new ApiResponse(ResponseType.OK);
var result = employeeService.ImpoerAprEmployees(allotid, path, claim.GetUserId());
return result == "" ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.ParameterError, result);
}
/// <summary>
......@@ -469,7 +469,7 @@ public ApiResponse AprOverview(int allotId)
var result = new List<Dictionary<string, string>>();
if (role.Any(t => roleType.Contains(t.Type.Value)))
result = employeeService.GetOtherPerStats(allotId,user.Department??"");
result = employeeService.GetOtherPerStats(allotId, user.Department ?? "");
else
result = employeeService.GetOtherPerStats(allotId);
......
......@@ -697,8 +697,15 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
result.AddRange(hideOtherResult);
#endregion
var enumItems = EnumHelper.GetItems<AccountUnitType>();
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value)/*.ThenBy(t => t.AccountingUnit)*/.ToList();
var enumItems = EnumHelper.GetItems<UnitType>();
enumItems.ForEach(t =>
{
t.Value = UnitTypeUtil.Is(t.Name, UnitType.护理组) ? t.Value + 2 : t.Value;
if (t.Name == UnitType.行政后勤.ToString())
t.Name = "行政工勤";
});
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value).ThenBy(t => t.AccountingUnit).ToList();
return result;
}
......
......@@ -445,6 +445,10 @@ public bool InsertApr(per_apr_amount request, int userId)
if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
var employee = peremployeeRepository.GetEntity(t => t.AllotId == request.AllotId && t.PersonnelNumber == request.PersonnelNumber);
if (employee == null)
throw new PerformanceException("工号在字典中不存在");
request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 2;
request.CreateDate = DateTime.Now;
......@@ -538,7 +542,7 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
/// <param name="allotid"></param>
/// <param name="path"></param>
/// <param name="userid"></param>
public void ImpoerAprEmployees(int allotid, string path, int userid)
public string ImpoerAprEmployees(int allotid, string path, int userid)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
......@@ -563,7 +567,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
if (workbook == null) return;
if (workbook == null) return "";
var sheet = workbook.GetSheetAt(0);
var firstRow = sheet.GetRow(0);
......@@ -592,6 +596,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entities = new List<per_apr_amount>();
var createtime = DateTime.Now;
var typeIn = GetTypeInDepartment(userid);
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allotid);
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
{
var row = sheet.GetRow(rowindex);
......@@ -613,6 +619,13 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
entities.Add(entity);
}
var numbers = entities.Select(t => t.PersonnelNumber).Except(employees.Select(w => w.PersonnelNumber));
if (numbers?.Count() > 0 && numbers?.Count() <= 5)
return $@"以下工号在字典中不存在:{JsonHelper.Serialize(numbers.ToArray())}";
else if (numbers?.Count() > 5)
return $@"以下工号在字典中不存在:{JsonHelper.Serialize(numbers.Take(5)).Replace("]", ",...]")}";
// 补充核算单元
if (entities.Any())
{
......@@ -630,6 +643,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
//}
perapramountRepository.AddRange(entities.ToArray());
}
return "";
}
catch (PerformanceException ex)
{
......@@ -638,6 +652,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
catch (Exception ex)
{
logger.LogError(ex.ToString());
return "上传失败";
}
}
......@@ -714,7 +729,7 @@ public view_per_apr_amount GetEmployeeMessage(int allotId, string personnelNumbe
var user = userRepository.GetEntity(w => w.ID == userId && w.IsDelete == 1);
if (user == null) throw new PerformanceException("操作用户不存在或用户信息错误!");
var employee = peremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber.Trim() == personnelNumber.Trim());
var employee = peremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber != null && w.PersonnelNumber.Trim() == personnelNumber.Trim());
if (employee == null) return new view_per_apr_amount();
return new view_per_apr_amount
......
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