Commit b875151f by 李承祥

增加获取人员列表,修改人员信息调整,表cog_again相关修改对应allotid,

parent 70967a56
......@@ -107,8 +107,8 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (!againAllotService.Update(allot, againid))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(againid);
configService.CopyAgain(againid);
configService.ClearAgain(allot.ID);
configService.CopyAgain(allot.ID);
}
return new ApiResponse(ResponseType.OK);
......
......@@ -255,7 +255,7 @@ public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromB
[HttpPost]
public ApiResponse GetAgainList([CustomizeValidator(RuleSet = "Select"), FromBody]CofAgainRequest request)
{
var list = _configService.GetAgainList(request.AgainAllotID);
var list = _configService.GetAgainList(request.AllotID);
return new ApiResponse(ResponseType.OK, "ok", list);
}
......
......@@ -21,6 +21,19 @@ public EmployeeController(EmployeeService employeeService)
}
/// <summary>
/// 获取人员列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("getlist")]
[HttpPost]
public ApiResponse GetEmployeeList([CustomizeValidator(RuleSet = "Select"), FromBody]EmployeeRequest request)
{
var employee = employeeService.GetEmployeeList(request.AllotID.Value);
return new ApiResponse(ResponseType.OK, "ok", employee);
}
/// <summary>
/// 新增人员
/// </summary>
/// <param name="request"></param>
......
......@@ -13,11 +13,6 @@ public class CofAgainRequest: ApiRequest
public int AllotID { get; set; }
/// <summary>
///
/// </summary>
public int AgainAllotID { get; set; }
/// <summary>
/// 1 职称绩效 2 工作量绩效 3 满勤天数
/// </summary>
public int Type { get; set; }
......@@ -38,7 +33,7 @@ public CofAgainRequestValidator()
{
RuleSet("Select", () =>
{
RuleFor(x => x.AgainAllotID).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AllotID).NotNull().NotEmpty().GreaterThan(0);
});
RuleSet("Update", () =>
......
......@@ -113,6 +113,10 @@ public EmployeeRequestValidator()
RuleFor(x => x.AccountingUnit).NotNull().NotEmpty();
RuleFor(x => x.DoctorName).NotNull().NotEmpty();
};
RuleSet("Select", () =>
{
RuleFor(x => x.AllotID).NotNull().GreaterThan(0);
});
RuleSet("Insert", () =>
{
......
......@@ -27,11 +27,6 @@ public class cof_again
public Nullable<int> AllotID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AgainAllotID { get; set; }
/// <summary>
/// 1 职称绩效 2 工作量绩效 3 满勤天数
/// </summary>
public Nullable<int> Type { get; set; }
......
......@@ -74,12 +74,12 @@ public bool Generate(AgainAllotRequest request, UserIdentity user)
perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
//清理二次绩效无用数据
configService.ClearAgain(againAllot.ID);
configService.ClearAgain(againAllot.AllotID.Value);
try
{
#region 基础信息
//获取基础配置信息
var config = perforCofagainRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
......
......@@ -345,9 +345,9 @@ public void Copy(per_allot allot)
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<cof_again> GetAgainList(int againId)
public List<cof_again> GetAgainList(int allotId)
{
var list = _againRepository.GetEntities(t => t.AgainAllotID == againId);
var list = _againRepository.GetEntities(t => t.AllotID == allotId);
return list;
}
......@@ -358,10 +358,10 @@ public List<cof_again> GetAgainList(int againId)
/// <returns></returns>
public cof_again AgainInsert(CofAgainRequest request)
{
var workyear = Mapper.Map<cof_again>(request);
if (!_againRepository.Add(workyear))
var again = Mapper.Map<cof_again>(request);
if (!_againRepository.Add(again))
throw new PerformanceException("保存失败");
return workyear;
return again;
}
/// <summary>
......@@ -414,12 +414,9 @@ public void ClearAgain(int againId)
/// 复制报表基础配置
/// </summary>
/// <param name="iD"></param>
public void CopyAgain(int againid)
public void CopyAgain(int allotId)
{
var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
if (again == null)
throw new PerformanceException("二次绩效不存在");
var allot = perforPerAllotRepository.GetEntity(t => t.ID == again.AllotID);
var allot = perforPerAllotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("绩效不存在");
......@@ -432,22 +429,13 @@ public void CopyAgain(int againid)
}
List<cof_again> record = new List<cof_again>();
//根据上月绩效获取二次绩效信息
var beforeAgain = perforPeragainallotRepository.GetEntity(t => t.AllotID == allot.ID);
if (again.AllotID != allot.ID && beforeAgain != null)
record = _againRepository.GetEntities(t => t.AgainAllotID == beforeAgain.ID);
if (record == null || record.Count == 0)
record = _againRepository.GetEntities(t => t.AgainAllotID == -1);
var againList = record.Select(t => new cof_again
{
AllotID = allot.ID,
AgainAllotID = againid,
Type = t.Type,
TypeName = t.TypeName,
Value = t.Value
});
_againRepository.AddRange(againList.ToArray());
var data = _againRepository.GetEntities(t => t.AllotID == allotId);
if (data == null || data.Count == 0)
{
var again = _againRepository.GetEntities(t => t.AllotID == allot.ID) ?? _againRepository.GetEntities(t => t.AllotID == -1);
var newAgains = again.Select(t => new cof_again { AllotID = allot.ID, Type = t.Type, TypeName = t.TypeName, Value = t.Value });
_againRepository.AddRange(newAgains.ToArray());
}
}
#endregion
}
......
......@@ -22,6 +22,30 @@ public EmployeeService(PerforImemployeeRepository perforImemployeeRepository)
}
/// <summary>
///获取人员信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public im_employee GetEmployee(EmployeeRequest request)
{
var employee = perforImemployeeRepository.GetEntity(t => t.ID == request.ID);
if (employee == null)
throw new PerformanceException("该人员不存在");
return employee;
}
/// <summary>
///获取人员列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public List<im_employee> GetEmployeeList(int allotId)
{
var employee = perforImemployeeRepository.GetEntities(t => t.AllotID == allotId);
return employee;
}
/// <summary>
/// 新增人员
/// </summary>
/// <param name="request"></param>
......@@ -34,7 +58,7 @@ public im_employee Insert(EmployeeRequest request)
}
/// <summary>
/// 修改人员
/// 修改人员信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
......@@ -44,10 +68,23 @@ public im_employee Update(EmployeeRequest request)
if (employee == null)
throw new PerformanceException("该人员不存在");
employee.AccountingUnit = request.AccountingUnit;
employee.Department = request.Department ?? employee.Department;
employee.FitPeople = request.FitPeople ?? employee.FitPeople;
employee.DoctorName = request.DoctorName;
employee.JobTitle = request.JobTitle ?? employee.JobTitle;
employee.AccountType = request.AccountType;
employee.Department = request.Department;
employee.FitPeople = request.FitPeople;
employee.JobTitle = request.JobTitle;
employee.PostCoefficient = request.PostCoefficient;
employee.WorkTime = request.WorkTime;
employee.ScoreAverageRate = request.ScoreAverageRate;
employee.Attendance = request.Attendance;
employee.PeopleNumber = request.PeopleNumber;
employee.Workload = request.Workload;
employee.OtherPerfor = request.OtherPerfor;
employee.Punishment = request.Punishment;
employee.Adjust = request.Adjust;
employee.Grant = request.Grant;
//修改人员信息
perforImemployeeRepository.Update(employee);
return employee;
}
......@@ -59,7 +96,10 @@ public im_employee Update(EmployeeRequest request)
/// <returns></returns>
public bool Delete(EmployeeRequest request)
{
var employee = Mapper.Map<im_employee>(request);
var employee = perforImemployeeRepository.GetEntity(t => t.ID == request.ID);
if (null == employee)
throw new PerformanceException($"ID不存在 :{request.ID}");
return perforImemployeeRepository.Remove(employee);
}
}
......
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