コード例 #1
0
        public async Task <OperationResult> SetMaterialOutStorageMaterialBatch(Guid MaterialOutStorageId, MatInventoryItemInfoInputDto MaterialOutStorageDtos, string UserName)
        {
            int count = 0;
            //
            //////////////批次表
            MaterialBatchInfo materialbatchInfo      = MaterialBatchInfoRepository.TrackEntities.Where(m => m.Id == MaterialOutStorageDtos.MaterialBatch_Id).FirstOrDefault();
            decimal           dMaterialBatchQuantity = materialbatchInfo.Quantity.Value;

            //
            materialbatchInfo.Quantity = MaterialOutStorageDtos.ActualAmount;
            //
            materialbatchInfo.LastUpdatorUserId = UserName;
            materialbatchInfo.LastUpdatedTime   = DateTime.Now;
            //
            count += await MaterialBatchInfoRepository.UpdateAsync(materialbatchInfo);

            //////////////
            //////////////流水帐
            MaterialStorageLogInfo materialstoragelogInfo = new MaterialStorageLogInfo();
            //
            Guid MaterialBatch_Id = materialbatchInfo.Id;

            materialstoragelogInfo.MaterialBatch = MaterialBatchInfoRepository.TrackEntities.Where(m => m.Id == MaterialBatch_Id).FirstOrDefault();
            //
            Guid MaterialID = materialstoragelogInfo.MaterialBatch.Material.Id;

            materialstoragelogInfo.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == MaterialID).FirstOrDefault();
            //
            materialstoragelogInfo.ChangedAmount = MaterialOutStorageDtos.DifferenceAmount;
            //
            materialstoragelogInfo.OriginalAmount = dMaterialBatchQuantity;
            materialstoragelogInfo.ChangedAmount  = MaterialOutStorageDtos.DifferenceAmount;
            materialstoragelogInfo.CurrentAmount  = materialbatchInfo.Quantity;
            //
            //盘点
            materialstoragelogInfo.StorageChangeType = (int)StorageChangeTypeEnumModel.StorageChangeType.InventoryStorageChangeType;
            //
            materialstoragelogInfo.CreatorUserId     = UserName;
            materialstoragelogInfo.CreatedTime       = DateTime.Now;
            materialstoragelogInfo.LastUpdatorUserId = materialstoragelogInfo.CreatorUserId;
            materialstoragelogInfo.LastUpdatedTime   = materialstoragelogInfo.CreatedTime;
            //
            count += await MaterialStorageLogInfoRepository.InsertAsync(materialstoragelogInfo);

            //
            return(count > 0
                ? new OperationResult(OperationResultType.Success, "出库任务“{0}”指派库位批次操作成功".FormatWith("Test"))
                : OperationResult.NoChanged);
        }
コード例 #2
0
        /// <summary>
        /// 更新物料批次信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Update(params MaterialBatchInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            //
            foreach (MaterialBatchInfoInputDto dtoData in inputDtos)
            {
                //if (string.IsNullOrEmpty(dtoData.WareHouseCode))
                //    return new OperationResult(OperationResultType.Error, "请正确填写仓库编号,该组数据不被存储。");
                //if (string.IsNullOrEmpty(dtoData.WareHouseName))
                //    return new OperationResult(OperationResultType.Error, "请正确填写仓库名称,该组数据不被存储。");
                ////
                //if (MaterialBatchInfoRepository.CheckExists(x => x.WareHouseCode == dtoData.WareHouseCode && x.Id != dtoData.Id ))
                //    return new OperationResult(OperationResultType.Error, $"仓库编号 {dtoData.WareHouseCode} 的数据已存在,该组数据不被存储。");
                //if (MaterialBatchInfoRepository.CheckExists(x => x.WareHouseName == dtoData.WareHouseName && x.Id != dtoData.Id ))
                //    return new OperationResult(OperationResultType.Error, $"仓库名称 {dtoData.WareHouseName} 的数据已存在,该组数据不被存储。");
            }
            //
            MaterialBatchInfoRepository.UnitOfWork.BeginTransaction();
            //
            //EntAreaInfo info = new EntAreaInfo();
            //foreach (var item in inputDtos)
            //{
            //    info = EntAreaInfoRepository.TrackEntities.Where(m => m.Id == item.EntArea_Id).FirstOrDefault();
            //    item.EntArea = info;
            //}
            ////
            //MaterialBatchInfoTypeInfo matwarehousetypeinfo = new MaterialBatchInfoTypeInfo();
            //foreach (var item in inputDtos)
            //{
            //    matwarehousetypeinfo = MaterialBatchInfoTypeInfoRepository.TrackEntities.Where(m => m.Id == item.MaterialBatchInfoType_Id).FirstOrDefault();
            //    item.MaterialBatchInfoType = matwarehousetypeinfo;
            //}
            //
            var result = await MaterialBatchInfoRepository.UpdateAsync(inputDtos);

            MaterialBatchInfoRepository.UnitOfWork.Commit();
            return(result);
        }
コード例 #3
0
        public async Task <OperationResult> SetMaterialOutStorageMaterialBatch(Guid MaterialOutStorageId, MatStorageMoveInfoInputDto MaterialOutStorageDtos, string UserName)
        {
            int count = 0;
            //
            //空托盘 移库
            //托盘及物料 移库
            //
            //////////////库位表
            MatWareHouseLocationInfo frommatwarehouselocationInfo = new MatWareHouseLocationInfo();

            frommatwarehouselocationInfo = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == MaterialOutStorageDtos.FromLocationID).FirstOrDefault();
            if (!Equals(frommatwarehouselocationInfo.PalletID, null))
            {
                Guid PalletID = frommatwarehouselocationInfo.PalletID.Value;
                //
                MatWareHouseLocationInfo tomatwarehouselocationInfo = new MatWareHouseLocationInfo();
                tomatwarehouselocationInfo = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == MaterialOutStorageDtos.ToLocationID).FirstOrDefault();
                //
                //if (tomatwarehouselocationInfo.PalletID == null)
                //修改关永强代码  by cxh
                if (Equals(tomatwarehouselocationInfo.PalletID, null) || Equals(tomatwarehouselocationInfo.PalletID, Guid.Empty))
                {
                    //frommatwarehouselocationInfo.PalletID = null;
                    //tomatwarehouselocationInfo.PalletID = PalletID;
                    ////
                    //count += await MatWareHouseLocationInfoRepository.UpdateAsync(frommatwarehouselocationInfo);
                    //count += await MatWareHouseLocationInfoRepository.UpdateAsync(tomatwarehouselocationInfo);
                    //
                    //批次表 修改 by cxh 20181126 增加条件,解决插入库存流水多条数据的问题
                    // List<MaterialBatchInfo> materialbatchInfoList = MaterialBatchInfoRepository.TrackEntities.Where(m => m.MatWareHouseLocation.Id == MaterialOutStorageDtos.FromLocationID).ToList();
                    List <MaterialBatchInfo> materialbatchInfoList = MaterialBatchInfoRepository.TrackEntities.Where(m => m.MatWareHouseLocation.Id == MaterialOutStorageDtos.FromLocationID && m.MatWareHouseLocation.PalletID != null && m.MatWareHouseLocation.PalletID != Guid.Empty && m.Quantity > 0).ToList();
                    foreach (MaterialBatchInfo materialbatchInfo in materialbatchInfoList)
                    {
                        //////////////库位表
                        MatWareHouseLocationInfo matwarehouselocationInfo = new MatWareHouseLocationInfo();
                        matwarehouselocationInfo = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == MaterialOutStorageDtos.ToLocationID).FirstOrDefault();
                        //
                        materialbatchInfo.MatWareHouseLocation = matwarehouselocationInfo;
                        //
                        materialbatchInfo.LastUpdatorUserId = UserName;
                        materialbatchInfo.LastUpdatedTime   = DateTime.Now;
                        //
                        count += await MaterialBatchInfoRepository.UpdateAsync(materialbatchInfo);

                        //////////////
                        //////////////流水帐
                        MaterialStorageLogInfo materialstoragelogInfo = new MaterialStorageLogInfo();
                        //
                        Guid MaterialBatch_Id = materialbatchInfo.Id;
                        materialstoragelogInfo.MaterialBatch = MaterialBatchInfoRepository.TrackEntities.Where(m => m.Id == MaterialBatch_Id).FirstOrDefault();
                        //
                        Guid MaterialID = materialstoragelogInfo.MaterialBatch.Material.Id;
                        materialstoragelogInfo.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == MaterialID).FirstOrDefault();
                        //
                        materialstoragelogInfo.OriginalAmount = materialbatchInfo.Quantity;
                        //materialstoragelogInfo.ChangedAmount = materialbatchInfo.Quantity;
                        materialstoragelogInfo.ChangedAmount = 0;
                        materialstoragelogInfo.CurrentAmount = materialbatchInfo.Quantity;
                        //
                        //移库
                        materialstoragelogInfo.StorageChangeType = (int)StorageChangeTypeEnumModel.StorageChangeType.MoveStorageChangeType;
                        //
                        materialstoragelogInfo.CreatorUserId     = UserName;
                        materialstoragelogInfo.CreatedTime       = DateTime.Now;
                        materialstoragelogInfo.LastUpdatorUserId = materialstoragelogInfo.CreatorUserId;
                        materialstoragelogInfo.LastUpdatedTime   = materialstoragelogInfo.CreatedTime;
                        //
                        count += await MaterialStorageLogInfoRepository.InsertAsync(materialstoragelogInfo);
                    }
                    frommatwarehouselocationInfo.PalletID = null;
                    tomatwarehouselocationInfo.PalletID   = PalletID;
                    //
                    count += await MatWareHouseLocationInfoRepository.UpdateAsync(frommatwarehouselocationInfo);

                    count += await MatWareHouseLocationInfoRepository.UpdateAsync(tomatwarehouselocationInfo);
                }
                else
                {
                    return(new OperationResult(OperationResultType.Error, "目标库位不为空库位"));
                }
            }
            else
            {
                return(new OperationResult(OperationResultType.Error, "原库位为空库位"));
            }
            //
            return(count > 0
                ? new OperationResult(OperationResultType.Success, "出库任务“{0}”指派库位批次操作成功".FormatWith("Test"))
                : OperationResult.NoChanged);
        }