Example #1
0
        /// <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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }