public async Task <JsonResult> GetBrigades() { await CheckPermission(); var er = new BrigadeRepository(_logger); var result = await er.GetAll(); return(Json(result)); }
public async Task <JsonResult> Delete([FromBody] Brigade equipment) { await CheckPermission(); var sqlR = new BrigadeRepository(_logger); var result = await sqlR.Delete(equipment.Id); return(Json(result)); }
public async Task <JsonResult> Add([FromBody] Brigade input) { await CheckPermission(); var sqlR = new BrigadeRepository(_logger); if (input.Id != 0) { await sqlR.Update(input); } else { await sqlR.Add(input); } return(Json(new { message = "addOrUpdate OK" })); }
public async Task <JsonResult> GetAll(int skip, int limit, string filter) { await CheckPermission(); var er = new BrigadeRepository(_logger); BrigadeRepository.BrigadePaging result; if (filter != null) { result = await er.GetAll(skip, limit, filter); } else { result = await er.GetAll(skip, limit); } return(Json(result)); }
/// <summary> /// Приемка/Сдача ЛБ таблица /// </summary> private static async Task <ReportResponse> GetLocomotvInspectionsTable(ReportRequest input, 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 sqlRBrigade = new BrigadeRepository(logger); var result = new ReportResponse { Rows = new List <Row>() }; result.Columns = new List <Column> { new Column("col0", "Состав", "string"), new Column("col1", "Тип", "string"), new Column("col2", "Время начала", "date"), new Column("col3", "Время окончания", "date"), new Column("col4", "Меток считано", "number"), new Column("col5", "Новых инцидентов заведено (из них критических)", "number"), new Column("col6", "Инцидентов на составе всего", "string"), new Column("col7", "Километров всего", "number"), new Column("col8", "Километров за смену", "number"), new Column("col9", "КВт*ч (по каждому вагону)", "string"), }; var planedRouteTrain = await sqlRPlanedRouteTrains.ById(planedRouteTrainId); //var route = await sqlRRoute.ById(planedRouteTrain.RouteId); var currentTrainInspections = await sqlRInspections.GetByTrainId(planedRouteTrain.TrainId); var currentDayInspections = currentTrainInspections.Where(x => x.DateStart.Date.Equals(planedRouteTrain.CreateDate)); foreach (var currentDayInspection in currentDayInspections) { var user = await sqlRUser.ById(currentDayInspection.UserId); if (user.BrigadeId == null) { continue; } var brigade = await sqlRBrigade.ById((int)user.BrigadeId); if (brigade.BrigadeType != BrigadeType.Locomotiv) { continue; } var row = new Row { Id = new RowId(currentDayInspection.Id, 1), HasItems = false.ToString(), ParentId = null, //Состав Col0 = (await sqlRTrains.ById(planedRouteTrain.TrainId)).Name, //Тип Col1 = GetStringInspectionType(currentDayInspection.CheckListType), //Время начала Col2 = currentDayInspection.DateStart.ToStringDateTime(), //Время окончания Col3 = currentDayInspection.DateEnd?.ToStringDateTime(), //Меток считано Col4 = "666", //Новых инцидентов заведено (из них критических) Col5 = "666", //Инцидентов на составе всего Col6 = "666", //Километров всего Col7 = "666", //Километров за смену Col8 = "666", //КВт*ч (по каждому вагону) Col9 = "In Development", }; result.Rows.Add(row); } return(result); }
private static Brigade GetBrigadeById(BrigadeRepository sqlR, int id) { return(sqlR.ById(id).Result); }
//30 - Приёмка поезда ПР //31 - Выпуск поезда ПР //32 - Приёмка поезда ЛБ //33 - Сдача поезда ЛБ public async Task <JournalPaging> GetJournalInspectionAndTasks(int skip, int limit, string filter) { var sqlr = new InspectionRepository(_logger); var inspdatarep = new InspectionDataRepository(_logger); var sqlTrainR = new TrainRepository(_logger); var sqlUserR = new UserRepository(_logger); var iR = new InspectionRepository(_logger); var mR = new MeterageRepository(_logger); var sqlStatusR = new TaskStatusRepository(_logger); var sqlExecutorR = new ExecutorRepository(_logger); var sqlRTask = new TaskRepository(_logger); var sqlRBrigade = new BrigadeRepository(_logger); var sqlRJournal = new JournalRepository(_logger); var listFull = new List <JournalDateItem>(); var fromSqlsInspections = await sqlr.GetAll(); foreach (var fromSqlsInspection in fromSqlsInspections) { var train = (await sqlTrainR.ByIdWithStations(fromSqlsInspection.TrainId)); var user = await sqlUserR.ById(fromSqlsInspection.UserId); var journalInspection = new JournalInspection { Id = fromSqlsInspection.Id, Type = "inspection", InspectionId = fromSqlsInspection.Id, StatusId = (int)fromSqlsInspection.Status, TypeId = (int)fromSqlsInspection.CheckListType, Date = fromSqlsInspection.DateStart, TrainName = train.Name, TrainId = train.Id, Tabs = new JournalInspectionTabs(), UserName = user.Name, }; if (user.BrigadeId != null) { journalInspection.OwnerBrigadeType = (await sqlRBrigade.ById((int)user.BrigadeId)).BrigadeType; } //дескрипшен var counters = await iR.GetCounters(fromSqlsInspection.Id); journalInspection.Tabs.Description = new JournalInspectionDescription { TasksCount = counters.Tasks, DataEnd = fromSqlsInspection.DateEnd, //Выдает количество уникальных меток AllLabelCount = counters.Labels, TempCount = counters.Measurements }; //лейблы await getInspectionLabels(mR, fromSqlsInspection, journalInspection); //измерения await getInspectionMeterage(mR, fromSqlsInspection, journalInspection); //счетчики await GetInspectionCouters(inspdatarep, fromSqlsInspection, journalInspection); //говнохак под ебанутые фильтры и вывод. TypeId == 2 - Приемка, 3 - сдача changeInspetionTypeForUi(journalInspection); //Фильтруем var isFiltered = await InspectionFilter(filter, sqlRTask, fromSqlsInspection, journalInspection); if (!isFiltered) { listFull.Add(new JournalDateItem { Date = journalInspection.Date, Inspection = journalInspection } ); } } //Таски var fromSqlsT = await sqlRJournal.GetAllTaskForJournal(); foreach (var fromSql in fromSqlsT) { var journalTask = new JournalTask { Type = "Task", TaskId = fromSql.TaskId, TaskType = fromSql.TaskType, TrainName = fromSql.TrainName, TrainId = fromSql.TrainId, UserName = fromSql.UserName, Date = fromSql.CreateDate, CarriageName = CreateCarriageName(fromSql.TrainName, fromSql.CarriageNumber), CarriageNum = fromSql.CarriageNumber, CarriageId = fromSql.CarriageId, EquipmentName = fromSql.EquipmentName, FaultName = fromSql.FaultName, InspectionInfo = _GetInspectionInfo(fromSql.InspectionId, fromSql.InspectionType), CarriagesSerialNumber = fromSql.CarriagesSerialNumber, TaskAttributeId = fromSql.TaskAttributeId }; var executor = (await sqlExecutorR.GetByTaskId(fromSql.TaskId)).LastOrDefault(); if (executor != null) { journalTask.ExecutorBrigadeType = (int)executor.BrigadeType; } var taskStatus = sqlStatusR.GetByTrainTaskId(fromSql.TaskId); if (taskStatus != null) { journalTask.StatusId = (int)sqlStatusR.GetByTrainTaskId(fromSql.TaskId).Status; } //journalTask.StatusId = fromSql.TaskId; var isFiltered = TaskFilter(filter, fromSql, journalTask); if (!isFiltered) { //response.Add(journalTask.ToJson()); listFull.Add(new JournalDateItem { Date = journalTask.Date, Task = journalTask } ); } } //sort by date listFull.Sort((x, y) => y.Date.CompareTo(x.Date)); //пагинация List <JournalDateItem> listSkiplimit = paging(skip, ref limit, listFull); //Делаем жсон стрингу для вывода var pagingList = new List <string>(); converToJsonString(listSkiplimit, pagingList); var result = new JournalPaging { Data = pagingList.ToArray(), Total = listFull.Count }; return(result); }
private async Task AddInspectionData(TaskByIdDto result, TaskDetailFromSql item) { var sqlRInspection = new InspectionRepository(_logger); var sqlRUsers = new UserRepository(_logger); var sqlRBrigade = new BrigadeRepository(_logger); var inspection = await sqlRInspection.ById(item.AttributeInspectionId); var inspectionUser = await sqlRUsers.ById(inspection.UserId); int?inspectionBrigadeType = null; if (inspectionUser.BrigadeId.HasValue) { var inspectionBrigade = await sqlRBrigade.ById(inspectionUser.BrigadeId.Value); inspectionBrigadeType = (int)inspectionBrigade.BrigadeType; } var inspectionToAdd = new InspectionTaskDto { Id = inspection.Id, DateStart = inspection.DateStart, DateEnd = inspection.DateEnd, User = inspectionUser.Name, Type = (int)inspection.CheckListType, BrigadeType = inspectionBrigadeType, Texts = new List <string>() }; if (item.AttributeCheckListEquipmentId.HasValue) { var toAddText = $"{item.EquipmentName} -> {item.CheckListEquipmentTaskName} -> "; var checkListStringValue = string.Empty; var taskAttributeStringValue = string.Empty; if (item.CheckListEquipmentValueType == 1) { if (item.CheckListEquipmentValue == 0) { checkListStringValue = "Нет"; } if (item.CheckListEquipmentValue == 1) { checkListStringValue = "Да"; } if (item.AttributeValue == 0) { taskAttributeStringValue = "Нет"; } if (item.AttributeValue == 1) { taskAttributeStringValue = "да"; } } else { checkListStringValue = item.CheckListEquipmentValue.ToString(); taskAttributeStringValue = item.AttributeValue.ToString(); } toAddText += $"{checkListStringValue} -> {taskAttributeStringValue}"; inspectionToAdd.Texts.Add(toAddText); } // Для ТО-1 ТО-2 и тд if (inspection.CheckListType == CheckListType.TO1 || inspection.CheckListType == CheckListType.TO2) { // Уровень критичности → Высокий if (item.TaskLevel.HasValue) { var toAddText = $"Уровень критичности -> {GetStringTaskLevel(item.TaskLevel.Value)}"; inspectionToAdd.Texts.Add(toAddText); } //Смотрим что добавилось в рамках мероприятия TaskLevel или FaultId, пишим в текст if (item.AttributeFaultId.HasValue) { var toAddText = $"{item.FaultName} -> {item.EquipmentName}"; inspectionToAdd.Texts.Add(toAddText); } } result.Inspections.Add(inspectionToAdd); }