/// <summary>
        /// 增加物料批次信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Add(params MaterialBatchInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            foreach (var 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))
                //    return new OperationResult(OperationResultType.Error, $"仓库编号 {dtoData.WareHouseCode} 的数据已存在,该组数据不被存储。");
                //if (MaterialBatchInfoRepository.CheckExists(x => x.WareHouseName == dtoData.WareHouseName))
                //    return new OperationResult(OperationResultType.Error, $"仓库名称 {dtoData.WareHouseName} 的数据已存在,该组数据不被存储。");
                ////
                //dtoData.EntArea = EntAreaInfoRepository.TrackEntities.Where(m => m.Id == dtoData.EntArea_Id).FirstOrDefault();
                //if (Equals(dtoData.EntArea, null))
                //{
                //    return new OperationResult(OperationResultType.Error, $"对应的所属区域不存在,该组数据不被存储。");
                //}
                ////
                //dtoData.MaterialBatchInfoType = MaterialBatchInfoTypeInfoRepository.TrackEntities.Where(m => m.Id == dtoData.MaterialBatchInfoType_Id).FirstOrDefault();
                //if (Equals(dtoData.MaterialBatchInfoType, null))
                //{
                //    return new OperationResult(OperationResultType.Error, $"对应的仓库类型不存在,该组数据不被存储。");
                //}
            }
            MaterialBatchInfoRepository.UnitOfWork.BeginTransaction();
            var result = await MaterialBatchInfoRepository.InsertAsync(inputDtos);

            MaterialBatchInfoRepository.UnitOfWork.Commit();
            //
            return(result);
        }
        /// <summary>
        /// 物理删除物料批次信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public async Task <OperationResult> Delete(params Guid[] ids)
        {
            ids.CheckNotNull("ids");
            MaterialBatchInfoRepository.UnitOfWork.BeginTransaction();
            var result = await MaterialBatchInfoRepository.DeleteAsync(ids);

            MaterialBatchInfoRepository.UnitOfWork.Commit();
            return(result);
        }
Beispiel #3
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);
        }
        /// <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);
        }
        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);
        }
 /// <summary>
 /// 检查实体是否存在
 /// </summary>
 /// <param name="predicate"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool CheckExists(Expression <Func <MaterialBatchInfo, bool> > predicate, Guid id)
 {
     return(MaterialBatchInfoRepository.CheckExists(predicate, id));
 }
Beispiel #7
0
        /// <summary>
        /// 设置入库任务的库位
        /// </summary>
        /// <param name="id">入库任务编号</param>
        /// <param name="roleIds">库位编号集合</param>
        /// <returns>业务操作结果</returns>
        public async Task <OperationResult> SetMaterialInStorageWareHouseLocation(Guid MaterialInStorageId, MaterialInStorageInfoInputDto MaterialInStorageDtos, Guid[] WareHouseLocationIds, string UserName)
        {
            //User user = await UserRepository.GetByKeyAsync(id);
            //if (user == null)
            //{
            //    return new OperationResult(OperationResultType.QueryNull, "指定编号的用户信息不存在");
            //}
            ////
            //
            //MaterialBatchInfoRepository.UnitOfWork.BeginTransaction();
            ////
            int count = 0;
            //foreach (Guid addId in addIds)
            //{
            //    //Role role = await RoleRepository.GetByKeyAsync(addId);
            //    //if (role == null)
            //    //{
            //    //    return new OperationResult(OperationResultType.QueryNull, "指定编号的角色信息不存在");
            //    //}

            //    MaterialBatchInfo map = new MaterialBatchInfo() { Id = addId, BatchCode = "2018/07/27" };
            //    //
            //    count += await MaterialBatchInfoRepository.InsertAsync(map);
            //}
            //count += await MaterialBatchInfoRepository.DeleteAsync(m => m.MaterialInStorage.Id == id);
            //MaterialBatchInfoRepository.UnitOfWork.Commit();
            //
            //////////////
            //MatWareHouseTypeInfo matwarehousetypeInfo = new MatWareHouseTypeInfo();
            //matwarehousetypeInfo.WareHouseTypeCode = "0001";
            //matwarehousetypeInfo.WareHouseTypeName = "库位1";
            //await MatWareHouseTypeInfoRepository.InsertAsync(matwarehousetypeInfo);

            //MaterialOutStorageInfo materialoutstorageInfo = new MaterialOutStorageInfo();
            //materialoutstorageInfo.Remark = "0001";
            ////
            //Guid Material_Id = Guid.Parse("3C973F9E-1F8B-E811-895C-005056C00008");
            //materialoutstorageInfo.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == Material_Id).FirstOrDefault();
            //if (Equals(materialoutstorageInfo.Material, null))
            //{
            //    return new OperationResult(OperationResultType.Error, $"对应的物料信息不存在,该组数据不被存储。");
            //}
            ////materialoutstorageInfo.WareHouseTypeName = "库位1";
            //count += await MaterialOutStorageInfoRepository.InsertAsync(materialoutstorageInfo);

            //////////////入库单
            MaterialInStorageInfo materialinstorageInfo = new MaterialInStorageInfo();

            materialinstorageInfo = MaterialInStorageRepository.TrackEntities.Where(m => m.Id == MaterialInStorageId).FirstOrDefault();
            //////////////
            string  sBatchCode = GetInStorageBatchCode();
            decimal dQuantity  = materialinstorageInfo.Quantity.Value;
            //
            //decimal dPalletQuantity = materialinstorageInfo.PalletQuantity.Value;
            //decimal dFullPalletQuantity = 2;
            //
            Guid MaterialID0         = MaterialInStorageDtos.MaterialID.Value;
            int  dFullPalletQuantity = MaterialInfoRepository.TrackEntities.Where(m => m.Id == MaterialID0).Select(m => m.FullPalletQuantity).FirstOrDefault().Value;

            //////////////库位表
            foreach (Guid WareHouseLocationId in WareHouseLocationIds)
            {
                MaterialBatchInfo materialbatchInfo = new MaterialBatchInfo();
                //
                Guid MaterialInStorage_Id = MaterialInStorageId;
                materialbatchInfo.MaterialInStorage = MaterialInStorageRepository.TrackEntities.Where(m => m.Id == MaterialInStorage_Id).FirstOrDefault();
                //
                Guid MaterialID = MaterialInStorageDtos.MaterialID.Value;
                materialbatchInfo.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == MaterialID).FirstOrDefault();
                //
                //Guid MatSupplier_Id = Guid.Parse("750B08C8-BC8F-E811-8BE2-005056C00008");
                //materialbatchInfo.MatSupplier = MatSupplierInfoRepository.TrackEntities.Where(m => m.Id == MatSupplier_Id).FirstOrDefault();
                //
                Guid MatWareHouseLocation_Id = WareHouseLocationId;
                materialbatchInfo.MatWareHouseLocation = MatWareHouseLocationInfoRepository.TrackEntities.Where(m => m.Id == MatWareHouseLocation_Id).FirstOrDefault();
                //
                materialbatchInfo.BatchCode = sBatchCode;
                //
                if (dQuantity > dFullPalletQuantity)
                {
                    materialbatchInfo.Quantity = dFullPalletQuantity;
                    dQuantity = dQuantity - dFullPalletQuantity;
                }
                else
                {
                    materialbatchInfo.Quantity = dQuantity;
                }
                //
                materialbatchInfo.Description   = "";
                materialbatchInfo.MatSupplierID = materialinstorageInfo.MatSupplierID;
                //
                materialbatchInfo.CreatorUserId     = UserName;
                materialbatchInfo.CreatedTime       = DateTime.Now;
                materialbatchInfo.LastUpdatorUserId = materialbatchInfo.CreatorUserId;
                materialbatchInfo.LastUpdatedTime   = materialbatchInfo.CreatedTime;
                //
                count += await MaterialBatchInfoRepository.InsertAsync(materialbatchInfo);

                //////////////
                //////////////流水帐

                MaterialStorageLogInfo materialstoragelogInfo = new MaterialStorageLogInfo();
                //
                Guid MaterialBatch_Id = materialbatchInfo.Id;
                materialstoragelogInfo.MaterialBatch = MaterialBatchInfoRepository.TrackEntities.Where(m => m.Id == MaterialBatch_Id).FirstOrDefault();
                //
                MaterialID = MaterialInStorageDtos.MaterialID.Value;
                materialstoragelogInfo.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == MaterialID).FirstOrDefault();
                //
                materialstoragelogInfo.InStorageID = materialinstorageInfo.Id;
                //
                materialstoragelogInfo.OriginalAmount = 0;
                materialstoragelogInfo.ChangedAmount  = materialbatchInfo.Quantity;
                materialstoragelogInfo.CurrentAmount  = materialbatchInfo.Quantity;
                //
                //入库
                materialstoragelogInfo.StorageChangeType = (int)StorageChangeTypeEnumModel.StorageChangeType.InStorageChangeType;
                //
                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);
        }