/// <summary> /// 增加路径信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Generate(params RouteInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.RouteNo)) { return(new OperationResult(OperationResultType.Error, "请正确填写路径编号,该组数据不被存储。")); } if (string.IsNullOrEmpty(dtoData.RouteName)) { return(new OperationResult(OperationResultType.Error, "请正确填写路径名称,该组数据不被存储。")); } if (RouteInfoRepository.CheckExists(x => x.MarkPoints == dtoData.MarkPoints /*&& x.IsDeleted == false*/)) { return(new OperationResult(OperationResultType.Error, $"地标点集合 {dtoData.MarkPoints} 的数据已存在,该组数据不被存储。")); } dtoData.StartMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.StartMarkPointInfo_Id); if (Equals(dtoData.StartMarkPointInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的开始地标点不存在,该组数据不被存储。")); } dtoData.EndMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.EndMarkPointInfo_Id); if (Equals(dtoData.EndMarkPointInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的结束地标点不存在,该组数据不被存储。")); } } RouteInfoRepository.UnitOfWork.BeginTransaction(); var result = await RouteInfoRepository.InsertAsync(inputDtos); RouteInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 更新地标点信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Update(params MarkPointInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (MarkPointInfoInputDto dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.MarkPointNo)) { return(new OperationResult(OperationResultType.Error, "请正确填写地标点编号,该组数据不被存储。")); } if (string.IsNullOrEmpty(dtoData.MarkPointName)) { return(new OperationResult(OperationResultType.Error, "请正确填写地标点名称,该组数据不被存储。")); } if (MarkPointInfoRepository.CheckExists(x => x.MarkPointNo == dtoData.MarkPointNo && x.Id != dtoData.Id)) { return(new OperationResult(OperationResultType.Error, $"地标点编号 {dtoData.MarkPointNo} 的数据已存在,该组数据不被存储。")); } if (MarkPointInfoRepository.CheckExists(x => x.MarkPointName == dtoData.MarkPointName && x.Id != dtoData.Id)) { return(new OperationResult(OperationResultType.Error, $"地标点名称 {dtoData.MarkPointName} 的数据已存在,该组数据不被存储。")); } } MarkPointInfoRepository.UnitOfWork.BeginTransaction(); var result = await MarkPointInfoRepository.UpdateAsync(inputDtos); MarkPointInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 物理删除地标点信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public async Task <OperationResult> Delete(params Guid[] ids) { ids.CheckNotNull("ids"); MarkPointInfoRepository.UnitOfWork.BeginTransaction(); var result = await MarkPointInfoRepository.DeleteAsync(ids); MarkPointInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 增加任务信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Add(params TaskInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.TaskName)) { return(new OperationResult(OperationResultType.Error, "请正确填写任务名称,该组数据不被存储。")); } if (TaskInfoRepository.CheckExists(x => x.TaskNo == dtoData.TaskNo /*&& x.IsDeleted == false*/)) { return(new OperationResult(OperationResultType.Error, $"任务编号 {dtoData.TaskNo} 的数据已存在,该组数据不被存储。")); } if (TaskInfoRepository.CheckExists(x => x.TaskName == dtoData.TaskName /* && x.IsDeleted == false*/)) { return(new OperationResult(OperationResultType.Error, $"任务名称 {dtoData.TaskName} 的数据已存在,该组数据不被存储。")); } dtoData.TargetPointInfo = MarkPointInfoRepository.GetByKey(dtoData.TargetPointInfo_Id); if (Equals(dtoData.TargetPointInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的目的地标点不存在,该组数据不被存储。")); } dtoData.TaskCar = AgvInfoRepository.GetByKey(dtoData.TaskCar_Id); if (Equals(dtoData.TaskCar, null)) { return(new OperationResult(OperationResultType.Error, $"对应的AGV小车不存在,该组数据不被存储。")); } dtoData.RouteInfo = RouteInfoRepository.GetByKey(dtoData.RouteInfo_Id); if (Equals(dtoData.RouteInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的路径不存在,该组数据不被存储。")); } } TaskInfoRepository.UnitOfWork.BeginTransaction(); var result = await TaskInfoRepository.InsertAsync(inputDtos); TaskInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 更新路段信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Update(params RoadInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.RoadNo)) { return(new OperationResult(OperationResultType.Error, "请正确填写路段编号,该组数据不被存储。")); } if (string.IsNullOrEmpty(dtoData.RoadName)) { return(new OperationResult(OperationResultType.Error, "请正确填写路段名称,该组数据不被存储。")); } if (RoadInfoRepository.CheckExists(x => x.RoadNo == dtoData.RoadNo && x.Id != dtoData.Id)) { return(new OperationResult(OperationResultType.Error, $"路段编号 {dtoData.RoadNo} 的数据已存在,该组数据不被存储。")); } if (RoadInfoRepository.CheckExists(x => x.RoadName == dtoData.RoadName && x.Id != dtoData.Id)) { return(new OperationResult(OperationResultType.Error, $"路段名称 {dtoData.RoadName} 的数据已存在,该组数据不被存储。")); } dtoData.StartMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.StartMarkPointInfo_Id); if (Equals(dtoData.StartMarkPointInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的开始地标点不存在,该组数据不被存储。")); } dtoData.EndMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.EndMarkPointInfo_Id); if (Equals(dtoData.EndMarkPointInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的结束地标点不存在,该组数据不被存储。")); } } RoadInfoRepository.UnitOfWork.BeginTransaction(); var result = await RoadInfoRepository.UpdateAsync(inputDtos); RoadInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 检查实体是否存在 /// </summary> /// <param name="predicate"></param> /// <param name="id"></param> /// <returns></returns> public bool CheckMarkPointInfoExists(Expression <Func <MarkPointInfo, bool> > predicate, Guid id) { return(MarkPointInfoRepository.CheckExists(predicate, id)); }