Commit 21b54e71 by Licx

其他绩效上传,返回错误内容

parent f2f5ee46
......@@ -471,7 +471,9 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
}
var result = employeeService.ImpoerAprEmployees(allotid, path, claim.GetUserId());
return result == "" ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.ParameterError, result);
return result != null && result.Any()
? new ApiResponse(ResponseType.OK)
: new ApiResponse(ResponseType.WarningTable, result);
}
/// <summary>
......
......@@ -640,11 +640,13 @@ public ApiResponse AprMark(int userid, AprAmountMarkRequest request)
/// <param name="allotid"></param>
/// <param name="path"></param>
/// <param name="userid"></param>
public string ImpoerAprEmployees(int allotid, string path, int userid)
public List<Dictionary<string, string>> ImpoerAprEmployees(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
{
......@@ -655,7 +657,7 @@ public string ImpoerAprEmployees(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);
......@@ -703,34 +705,44 @@ public string ImpoerAprEmployees(int allotid, string path, int userid)
CreateDate = createtime,
CreateUser = 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 (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 (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
// throw new PerformanceException("文件中存在“录入科室”为空的数据");
//var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid);
//foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber)))
//{
// item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.PersonnelNumber)?.AccountingUnit ?? "";
//}
perapramountRepository.AddRange(entities.ToArray());
}
return "";
return errors;
}
catch (PerformanceException ex)
{
......@@ -739,7 +751,7 @@ public string ImpoerAprEmployees(int allotid, string path, int userid)
catch (Exception ex)
{
logger.LogError(ex.ToString());
return "上传失败";
return errors;
}
}
......
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