Example #1
0
        public async Task <InspectionByIdDto> InspectionByIdForEventTable(int inspectionId)
        {
            var sqlRInspection = new InspectionRepository(_logger);
            var inspectionDto  = await sqlRInspection.ByIdForEventTable(inspectionId);

            var sqlRTrainTaskAttributes = new TrainTaskAttributesRepository(_logger);

            if (inspectionDto == null)
            {
                throw new NotFoundException();
            }
            inspectionDto.Id = "M" + inspectionDto.InspectionId;

            inspectionDto.Type        = GetStringInspectionType((CheckListType)inspectionDto.TypeInt);
            inspectionDto.Status      = GetStringInspectionStatus((InspectionStatus)inspectionDto.StatusInt);
            inspectionDto.BrigadeName = GetStringBrigadeType((BrigadeType)inspectionDto.BrigadeTypeInt);

            var endDateString = string.Empty;

            if (inspectionDto.DateEnd.HasValue)
            {
                endDateString = $" - {inspectionDto.DateEnd:g}";
            }
            inspectionDto.Date = $"{inspectionDto.DateStart:g}" + endDateString;


            //TaskCount
            var taskAttributesByInspectionCount = await sqlRTrainTaskAttributes.ByInspectionId(inspectionId);

            inspectionDto.TaskCount = taskAttributesByInspectionCount.Count;

            //Метки
            inspectionDto.Labels = await GetInspectionLabels(inspectionId);

            //Счетчики киловат и прочей хери
            inspectionDto.InspectionDataCarriages = await GetInspectionCounters(inspectionId);

            //Остальные данные по инспекции
            inspectionDto.InspectionDataUis = await GetInspectionOtherData(inspectionId);

            return(inspectionDto);
        }
Example #2
0
        /// <summary>
        ///  То1 таблица
        /// </summary>
        private static async Task <ReportResponse> GetTo1Table(int planedRouteTrainId, ILogger logger)
        {
            var sqlRTrains            = new TrainRepository(logger);
            var sqlRPlanedRouteTrains = new PlanedRouteTrainsRepository(logger);
            var sqlRRoute             = new RoutesRepository(logger);
            var sqlRInspections       = new InspectionRepository(logger);
            var sqlRTaskAttributes    = new TrainTaskAttributesRepository(logger);
            var sqlRUser = new UserRepository(logger);

            var result = new ReportResponse {
                Rows = new List <Row>()
            };

            result.Columns = new List <Column>
            {
                new Column("col0", "Номер", "number"),
                new Column("col1", "Состав", "string"),
                new Column("col2", "Рейс", "string"),
                new Column("col3", "Время начала", "date"),
                new Column("col4", "Время окончания", "date"),
                new Column("col5", "Количество созданных инцидентов", "number"),
                new Column("col6", "Исполнитель", "string"),
                new Column("col7", "Меток считано всего (в том числе при обходе и закрытии задач)", "number"),
            };

            var planedRouteTrain = await sqlRPlanedRouteTrains.ById(planedRouteTrainId);

            var route = await sqlRRoute.ById(planedRouteTrain.RouteId);

            //Надо получить ТО 1 на этот день или блядь для этого поезда. хуй его знает
            var currentTrainInspections = await sqlRInspections.GetByTrainId(planedRouteTrain.TrainId);

            //Выбираем за текущий денек
            var currentDayInspections =
                currentTrainInspections.Where(x => x.DateStart.Date.Equals(planedRouteTrain.CreateDate) && x.CheckListType == CheckListType.TO1);

            foreach (var currentDayInspection in currentDayInspections)
            {
                var row = new Row
                {
                    Id       = new RowId(currentDayInspection.Id, 1),
                    HasItems = false.ToString(),
                    ParentId = null,
                    //Номер
                    Col0 = currentDayInspection.Id.ToString(),
                    //Состав
                    Col1 = (await sqlRTrains.ById(planedRouteTrain.TrainId)).Name,
                    //Рейс
                    Col2 = route.Name,
                    //Время начала
                    Col3 = currentDayInspection.DateStart.ToStringDateTime(),
                    //Время окончания
                    Col4 = currentDayInspection.DateEnd?.ToStringDateTime(),
                    //Количество созданных инцидентов
                    Col5 = (await sqlRTaskAttributes.ByInspectionId(currentDayInspection.Id))?.Count.ToString(),
                    //Исполнитель
                    Col6 = (await sqlRUser.ById(currentDayInspection.UserId))?.Name,
                    //Меток считано всего (в том числе при обходе и закрытии задач)
                    Col7 = "In Development",
                };

                result.Rows.Add(row);
            }

            return(result);
        }
Example #3
0
 private static List <TrainTaskAttribute> GetTrainTaskAttributesCountByInspectionId(TrainTaskAttributesRepository sqlR, int id)
 {
     return(sqlR.ByInspectionId(id).Result);
 }