/////////// /// <summary> /// 更新作业单据信息 /// </summary> /// <param name="dtos">包含更新信息的物料DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddTask(params MatStorageMoveInfoInputDto[] dtos) { List <string> names = new List <string>(); var setResult = new OperationResult(); // MatStorageMoveInfoRepository.UnitOfWork.BeginTransaction(); foreach (MatStorageMoveInfoInputDto dto in dtos) { names.Add(dto.StorageMoveCode); List <Guid> MaterialBatchIds = new List <Guid>(); // setResult = await SetMaterialOutStorageMaterialBatch(dto.Id, dto, dto.UserName); if (setResult.ResultType.Equals(OperationResultType.Error)) { return(setResult); } // //dto.FinishTime = DateTime.Now; //移库完成 dto.StorageMoveState = (int)StorageMoveStateEnumModel.StorageMoveState.StorageMoveFinishState; // int count = 0; // MatStorageMoveInfo materialoutstorageInfo = new MatStorageMoveInfo(); materialoutstorageInfo = dto.MapTo(materialoutstorageInfo); // count += await MatStorageMoveInfoRepository.UpdateAsync(materialoutstorageInfo); } MatStorageMoveInfoRepository.UnitOfWork.Commit(); //return new OperationResult(OperationResultType.Success, "库位“{0}”更新成功".FormatWith(names.ExpandAndToString())); return(setResult); }
/// <summary> /// 更新移库信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Update(params MatStorageMoveInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); // foreach (MatStorageMoveInfoInputDto dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.StorageMoveCode)) { return(new OperationResult(OperationResultType.Error, "请正确填写单据编号,该组数据不被存储。")); } //if (string.IsNullOrEmpty(dtoData.WareHouseName)) // return new OperationResult(OperationResultType.Error, "请正确填写仓库名称,该组数据不被存储。"); //// //if (MatStorageMoveInfoRepository.CheckExists(x => x.WareHouseCode == dtoData.WareHouseCode && x.Id != dtoData.Id )) // return new OperationResult(OperationResultType.Error, $"仓库编号 {dtoData.WareHouseCode} 的数据已存在,该组数据不被存储。"); //if (MatStorageMoveInfoRepository.CheckExists(x => x.WareHouseName == dtoData.WareHouseName && x.Id != dtoData.Id )) // return new OperationResult(OperationResultType.Error, $"仓库名称 {dtoData.WareHouseName} 的数据已存在,该组数据不被存储。"); // var FromLocationID = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == dtoData.FromLocationID).FirstOrDefault(); if (Equals(FromLocationID, null)) { return(new OperationResult(OperationResultType.Error, $"对应的原库位信息不存在,该组数据不被存储。")); } // var ToLocationID = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == dtoData.ToLocationID).FirstOrDefault(); if (Equals(ToLocationID, null)) { return(new OperationResult(OperationResultType.Error, $"对应的现库位信息不存在,该组数据不被存储。")); } // if (dtoData.FromLocationID.Equals(dtoData.ToLocationID)) { return(new OperationResult(OperationResultType.Error, $"对应的现库位信息与原库位信息相同,该组数据不被存储。")); } } // MatStorageMoveInfoRepository.UnitOfWork.BeginTransaction(); // //MaterialInfo info = new MaterialInfo(); //foreach (var item in inputDtos) //{ // info = MaterialInfoRepository.TrackEntities.Where(m => m.Id == item.Material_Id).FirstOrDefault(); // item.Material = info; //} //// //MaterialInStorageTypeInfo matwarehousetypeinfo = new MaterialInStorageTypeInfo(); //foreach (var item in inputDtos) //{ // matwarehousetypeinfo = MaterialInStorageTypeInfoRepository.TrackEntities.Where(m => m.Id == item.MaterialInStorageType_Id).FirstOrDefault(); // item.MaterialInStorageType = matwarehousetypeinfo; //} // var result = await MatStorageMoveInfoRepository.UpdateAsync(inputDtos); MatStorageMoveInfoRepository.UnitOfWork.Commit(); return(result); }