Commit 9da16caa by ruyun.zhang@suvalue.com

Merge branch 'feature/new_report' into dev

parents ba95946d be83b464
......@@ -59,6 +59,19 @@ public ApiResponse List([FromBody]AllotRequest request)
}
/// <summary>
/// 生成成功或归档绩效记录
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("list/success")]
[HttpPost]
public ApiResponse Success([FromBody]AllotRequest request)
{
List<AllotResponse> allots = _allotService.GetSuccAllotList(request.HospitalId);
return new ApiResponse(ResponseType.OK, allots);
}
/// <summary>
/// 新增绩效
/// </summary>
/// <param name="request"></param>
......
......@@ -15,9 +15,11 @@ namespace Performance.Api.Controllers
public class EmployeeController : Controller
{
private EmployeeService employeeService;
public EmployeeController(EmployeeService employeeService)
private ClaimService claim;
public EmployeeController(EmployeeService employeeService, ClaimService claim)
{
this.employeeService = employeeService;
this.claim = claim;
}
/// <summary>
......@@ -29,7 +31,7 @@ public EmployeeController(EmployeeService employeeService)
[HttpPost]
public ApiResponse GetEmployeeList([CustomizeValidator(RuleSet = "Select"), FromBody]EmployeeRequest request)
{
var employee = employeeService.GetEmployeeList(request.AllotID.Value);
var employee = employeeService.GetEmployeeList(request.AllotID, claim.GetUserId());
return new ApiResponse(ResponseType.OK, "ok", employee);
}
......@@ -82,10 +84,10 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Empl
[HttpPost]
public ApiResponse GetEmployeeClinicList([CustomizeValidator(RuleSet = "Select"), FromBody]im_employee_clinic request)
{
if ((request.AllotID ?? 0) == 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
//if ((request.AllotID ?? 0) == 0)
// return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
var employee = employeeService.GetEmployeeClinicList(request.AllotID.Value);
var employee = employeeService.GetEmployeeClinicList(request.AllotID, claim.GetUserId());
return new ApiResponse(ResponseType.OK, "ok", employee);
}
......
......@@ -115,7 +115,7 @@ public EmployeeRequestValidator()
};
RuleSet("Select", () =>
{
RuleFor(x => x.AllotID).NotNull().GreaterThan(0);
//RuleFor(x => x.AllotID).NotNull().GreaterThan(0);
});
RuleSet("Insert", () =>
......
......@@ -109,6 +109,31 @@ public List<AllotResponse> GetAllotList(int? hospitalId)
}
/// <summary>
/// 生成成功或归档绩效记录
/// </summary>
/// <param name="hospitalId"></param>
/// <returns></returns>
public List<AllotResponse> GetSuccAllotList(int? hospitalId)
{
if (!hospitalId.HasValue || hospitalId.Value <= 0)
throw new PerformanceException("hospitalId无效");
var allotList = _allotRepository.GetEntities(t => t.HospitalId == hospitalId
&& new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States));
allotList = allotList == null ? allotList : allotList.OrderByDescending(t => t.ID).ToList();
var isconfig = perforHospitalconfigRepository.GetEntity(t => t.HospitalId == hospitalId) == null ? false : true;
var reuslt = Mapper.Map<List<AllotResponse>>(allotList);
reuslt?.ForEach(t =>
{
t.IsDown = !string.IsNullOrEmpty(t.ExtractPath);
if (!string.IsNullOrEmpty(t.ExtractPath))
t.ExtractPath = t.ExtractPath.Replace(options.Value.AbsolutePath, options.Value.HttpPath).Replace("\\", "/");
t.HasConfig = isconfig ? 3 : 0;
});
return reuslt;
}
/// <summary>
/// 新增
/// </summary>
/// <param name="request"></param>
......@@ -216,7 +241,7 @@ public void UpdateAllotStates(int allotId, int states, string remark)
{
_allotRepository.UpdateAllotStates(allotId, states, remark);
}
/// <summary>
/// 生成绩效
/// </summary>
......
......@@ -19,15 +19,21 @@ public class EmployeeService : IAutoInjection
private PerforPersheetRepository perforPersheetRepository;
private PerforPerallotRepository perforPerallotRepository;
private PerforImemployeeclinicRepository perforImemployeeclinicRepository;
private PerforUserhospitalRepository perforUserhospitalRepository;
private PerforPerallotRepository perallotRepository;
public EmployeeService(PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository,
PerforPerallotRepository perforPerallotRepository,
PerforImemployeeclinicRepository perforImemployeeclinicRepository)
PerforImemployeeclinicRepository perforImemployeeclinicRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perallotRepository)
{
this.perforImemployeeRepository = perforImemployeeRepository;
this.perforPersheetRepository = perforPersheetRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforImemployeeclinicRepository = perforImemployeeclinicRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perallotRepository = perallotRepository;
}
#region 行政人员
......@@ -50,8 +56,21 @@ public im_employee GetEmployee(EmployeeRequest request)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public List<im_employee> GetEmployeeList(int allotId)
public List<im_employee> GetEmployeeList(int? allotId, int userId)
{
if (allotId == null || allotId == 0)
{
var userHospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId);
if (userHospital == null)
throw new PerformanceException("用户未绑定医院!");
var allotList = perallotRepository.GetEntities(t => t.HospitalId == userHospital.HospitalID
&& new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States));
if (allotList != null && allotList.Any())
{
allotId = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First().ID;
}
}
var employee = perforImemployeeRepository.GetEntities(t => t.AllotID == allotId);
return employee?.OrderBy(t => t.RowNumber).ToList();
}
......@@ -136,8 +155,21 @@ public bool Delete(EmployeeRequest request)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public List<im_employee_clinic> GetEmployeeClinicList(int allotId)
public List<im_employee_clinic> GetEmployeeClinicList(int? allotId, int userId)
{
if (allotId == null || allotId == 0)
{
var userHospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId);
if (userHospital == null)
throw new PerformanceException("用户未绑定医院!");
var allotList = perallotRepository.GetEntities(t => t.HospitalId == userHospital.HospitalID
&& new List<int> { (int)AllotStates.Archive, (int)AllotStates.GenerateSucceed }.Contains(t.States));
if (allotList != null && allotList.Any())
{
allotId = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First().ID;
}
}
var employee = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allotId);
return employee?.OrderBy(t => t.RowNumber).ToList();
}
......
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