public SubordinatesResultDTO GetSubordinatesResultInPeriod(long periodIdParam, string managerEmployeeNo) { var periodId = new PeriodId(periodIdParam); var period = periodRep.GetById(periodId); var manager = employeeRepository.GetBy(new EmployeeId(managerEmployeeNo, periodId)); if (manager == null) { throw new Exception("شماره پرسنلی شما در سیستم موجود نمی باشد"); } var managerJobPositionIds = manager.JobPositions.Select(j => j.JobPositionId).ToList(); var managerUnitIds = new List <UnitId>(); var unitNames = string.Empty; var unitRootNames = string.Empty; var calculation = calculationRepository.GetDeterministicCalculation(period); foreach (var jobPositionId in managerJobPositionIds) { var jobPosition = jobPositionRepository.GetBy(jobPositionId); managerUnitIds.Add(jobPosition.UnitId); } foreach (var unitId in managerUnitIds) { var unit = unitRepository.GetBy(unitId); unitNames += unit.Name; if (managerUnitIds.Count > 1) { unitNames += " - "; } unitRootNames += unit.Parent.Name; if (managerUnitIds.Count > 1) { unitRootNames += " - "; } } //var finalUnitPoint = jobIndexPointRepository.GetFinalUnitPoint(calculation.Id, manager.Id); var res = new SubordinatesResultDTO { PeriodName = period.Name, PeriodTimeLine = "از تاریخ " + PDateHelper.GregorianToHijri(period.StartDate, false) + " تا تاریخ " + PDateHelper.GregorianToHijri(period.EndDate.Date, false), EmployeeUnitName = unitNames, EmployeeUnitRootName = unitRootNames, //TotalUnitPoint = finalUnitPoint == null ? (0).ToString() : finalUnitPoint.Value.ToString(CultureInfo.InvariantCulture), Subordinates = new List <EmployeeResultDTO>() }; var subordinateEmployeeJobposition = new List <JobPosition>(); foreach (var managerJobPositionId in managerJobPositionIds) { subordinateEmployeeJobposition.AddRange(jobPositionRepository.GetAllJobPositionByParentId(managerJobPositionId)); } var employeeIds = subordinateEmployeeJobposition.SelectMany(sj => sj.Employees.Select(e => e.EmployeeId)).ToList(); var oneOfSubordinate = employeeIds.FirstOrDefault(); if (oneOfSubordinate != null) { var finalUnitPoint = jobIndexPointRepository.GetFinalUnitPoint(calculation.Id, oneOfSubordinate); res.TotalUnitPoint = finalUnitPoint.Value.ToString(CultureInfo.InvariantCulture); } foreach (var employeeId in employeeIds) { var employee = employeeRepository.GetBy(employeeId); var employeeIndexPoints = jobIndexPointRepository.GetBy(calculation.Id, employee.Id); var employeeResult = new EmployeeResultDTO { EmployeeFullName = employee.FullName, EmployeeNo = employeeId.EmployeeNo, JobIndexValues = new List <JobIndexValueDTO>(), //EmployeeJobPositionName = jobPositionNames, TotalPoint = employee.FinalPoint.ToString(CultureInfo.InvariantCulture), }; foreach (var indexPoint in employeeIndexPoints) { var jobIndex = (JobIndex)jobIndexRepository.GetById(indexPoint.JobIndexId); employeeResult.JobIndexValues.Add(new JobIndexValueDTO { JobIndexName = jobIndex.Name, IndexValue = indexPoint.Value.ToString(), JobIndexId = jobIndex.SharedJobIndexId.Id, Id = indexPoint.Id.Id }); } res.Subordinates.Add(employeeResult); } return(res); }
public List <JobPosition> GetAllJobPositionByParentId(JobPositionId jobPositionId) { return(jobPositionRep.GetAllJobPositionByParentId(jobPositionId)); }