コード例 #1
0
        public IActionResult EmployeePersonalDashboard(string employee, string date, string fdate = "")
        {
            DateTime currentDate;
            DateTime startDate;
            DateTime endDate;


            if (string.IsNullOrEmpty(date))
            {
                date        = DateTime.Now.ToShortDateString();
                currentDate = DateTime.Parse(date);
                startDate   = new DateTime(currentDate.Year, currentDate.Month, 1);
                endDate     = startDate.AddMonths(1).AddDays(-1);
            }
            else
            {
                startDate = DateTime.Parse(date);
                endDate   = DateTime.Parse(fdate);
            }


            var model = _dashboardModelFactory.GetPersonalDashboardData(int.Parse(employee).ToString("00000"), startDate, endDate);

            model.FechaInicial = startDate.ToShortDateString();
            model.FechaFinal   = endDate.ToShortDateString();

            return(View(model));
        }
コード例 #2
0
        public JsonResult ProcesstIncidents(string iDate, string eDate,
                                            [FromServices] IRepository <EmployeeDiscount> discountRepo,
                                            [FromServices] IOrganigramaModelFactory organimgramaModelFactory,
                                            [FromServices] IDashboardModelFactory dashboardModelFactory,
                                            [FromServices] IRepository <NOMIPAQIncidence> nomiPAQIncidence,
                                            [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                            [FromServices] IRepository <NOMIPAQVacation> nomiPAQVacation,
                                            [FromServices] INomipaqIncidenciasModelFactory nomipaqincidenciasModelFactory)
        {
            var employeess = organimgramaModelFactory.GetAllData();
            List <PersonalDashboardData> personalData      = new List <PersonalDashboardData>();
            List <EmployeeIncidents>     employeeIncidents = new List <EmployeeIncidents>();

            var formatos = employeeFormatModelFactory.GetAllFormats(DateTime.Parse(iDate), DateTime.Parse(eDate));

            if (formatos.Any())
            {
                formatos.Where(f => f.Approved == true && f.FormatName.ToLower().Contains("vacacion")).ToList().ForEach(t =>
                {
                    List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                    parameters.Add(new KeyValuePair <string, string>("@fechaInicio", t.StartDate));
                    parameters.Add(new KeyValuePair <string, string>("@fechaFin", t.EndDate));
                    parameters.Add(new KeyValuePair <string, string>("@fechaPago", t.FechaSolicitud));
                    parameters.Add(new KeyValuePair <string, string>("@EMP", t.EmployeeId));
                    nomiPAQVacation.GetStoredProcData("VacacionesNominPAQ", parameters);
                });
            }

            employeess.Employess.ToList().ForEach(emp =>
            {
                var dashInfo = dashboardModelFactory.GetPersonalDashboardData(int.Parse(emp.Id).ToString("00000"), DateTime.Parse(iDate), DateTime.Parse(eDate));
                personalData.Add(dashInfo);
            });

            personalData.ForEach(emp =>
            {
                if (emp.PorcentajeRetardos > 0)
                {
                    int veces    = 0;
                    bool process = false;
                    emp.Days.Where(r => r.RetardoEntrada.Equals(1)).ToList().ForEach(day =>
                    {
                        DateTime dateA = DateTime.Parse($"{day.RegisterDate} {day.StartJobDay}");
                        DateTime dateB = DateTime.Parse($"{day.RegisterDate} {day.StartWorkDate}");

                        var diff = (dateA - dateB).TotalMinutes;

                        if (diff < 11 && !process)
                        {
                            veces++;
                            if (veces == 3)
                            {
                                employeeIncidents.Add(new EmployeeIncidents()
                                {
                                    Employee  = emp.EmployeeId,
                                    Mnemonico = "RET1",
                                    Period    = day.RegisterDate
                                });
                                process = true;
                            }
                        }

                        if (diff < 61 && !process)
                        {
                            employeeIncidents.Add(new EmployeeIncidents()
                            {
                                Employee  = emp.EmployeeId,
                                Mnemonico = "RET2",
                                Period    = day.RegisterDate
                            });
                            process = true;
                        }

                        if (diff < 121 && !process)
                        {
                            employeeIncidents.Add(new EmployeeIncidents()
                            {
                                Employee  = emp.EmployeeId,
                                Mnemonico = "RET3",
                                Period    = day.RegisterDate
                            });
                            process = true;
                        }
                    });
                }
            });

            if (formatos.Any())
            {
                var formatApproved = formatos.Where(f => f.Approved == true && f.FormatName.ToLower().Contains("permiso")).ToList();

                formatApproved.ToList().ForEach(t =>
                {
                    string mnemonico = string.Empty;
                    if (t.AdditionalInfo.Equals("Con goce de sueldo"))
                    {
                        mnemonico = "PCS";
                    }
                    else
                    {
                        mnemonico = "PSS";
                    }
                    employeeIncidents.Add(new EmployeeIncidents()
                    {
                        Employee  = int.Parse(t.EmployeeId).ToString("00000"),
                        Period    = t.StartDate,
                        Mnemonico = mnemonico
                    });
                });
            }

            var dias = Math.Abs(Math.Round((DateTime.Parse(iDate) - DateTime.Parse(eDate)).TotalDays, 0));

            if (dias == 0)
            {
                dias = 1;
            }

            for (int i = 0; i < dias; i++)
            {
                var t       = DateTime.Parse(iDate).AddDays(i);
                var results = dashboardModelFactory.GetNoRegistry(t.ToShortDateString());
                results.ForEach(f =>
                {
                    employeeIncidents.Add(new EmployeeIncidents()
                    {
                        Employee  = int.Parse(f.ID).ToString("00000"),
                        Period    = f.Fecha,
                        Mnemonico = "FINJ"
                    });
                });
            }

            var incidencias = nomipaqincidenciasModelFactory.GetAllIncidencias();

            var incidenciasNomipaq = incidencias.Where(g => g.Fecha >= DateTime.Parse(iDate) && g.Fecha <= (DateTime.Parse(eDate)));


            if (employeeIncidents.Any())
            {
                employeeIncidents.ForEach(item =>
                {
                    List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                    parameters.Add(new KeyValuePair <string, string>("@Empleado", item.Employee));
                    parameters.Add(new KeyValuePair <string, string>("@TipoIncidencia", item.Mnemonico));
                    parameters.Add(new KeyValuePair <string, string>("@fecha", item.Period));
                    nomiPAQIncidence.GetStoredProcData("IncidenciasNominPAQ", parameters);
                });
            }

            return(Json("Ok"));
        }