Exemple #1
0
 public static Location_CE ToCE(LocationEntity item)
 {
     Location_CE target = new Location_CE();
     target.ID=item.ID;
     target.LocalNum=item.LocalNum;
     target.LocalBarCode=item.LocalBarCode;
     target.LocalName=item.LocalName;
     target.StorageNum=item.StorageNum;
     target.StorageType=item.StorageType;
     target.LocalType=item.LocalType;
     target.Rack=item.Rack;
     target.Length=item.Length;
     target.Width=item.Width;
     target.Height=item.Height;
     target.X=item.X;
     target.Y=item.Y;
     target.Z=item.Z;
     target.Unit=item.Unit;
     target.UnitName=item.UnitName;
     target.Remark=item.Remark;
     target.IsForbid=item.IsForbid;
     target.IsDefault=item.IsDefault;
     target.IsDelete=item.IsDelete;
     target.CreateTime=item.CreateTime;
     return target;
 }
        /// <summary>
        /// 新增库位
        /// 如果设置为默认库位,则其他的库位修改为非默认库位
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(LocationEntity entity)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                //设置默认值
                if (entity.IsDefault == (int)EBool.Yes)
                {
                    LocationEntity temp = new LocationEntity();
                    temp.IsDefault = (int)EBool.No;
                    temp.IncludeIsDefault(true);
                    temp.Where(a => a.LocalNum == entity.LocalNum);
                    this.Location.Update(temp);
                }

                //绑定仓库信息
                StorageProvider storageProvider = new StorageProvider();
                List<StorageEntity> listStorage = storageProvider.GetList();
                if (entity.StorageNum.IsEmpty())
                {
                    if (!listStorage.IsNullOrEmpty())
                    {
                        StorageEntity storage = listStorage.FirstOrDefault(a => a.IsDefault == (int)EBool.Yes);
                        if (storage != null)
                        {
                            entity.StorageNum = storage.StorageNum;
                            entity.StorageType = storage.StorageType;
                        }
                    }
                }
                else
                {
                    if (!listStorage.IsNullOrEmpty())
                    {
                        StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == entity.StorageNum);
                        if (storage != null)
                        {
                            entity.StorageType = storage.StorageType;
                        }
                    }
                }
                entity.IncludeAll();
                int line = this.Location.Add(entity);
                if (line > 0)
                {
                    Clear();
                }
                ts.Complete();
                return line;
            }
        }
 public ActionResult Audit(string LocalNum, string IsForbid)
 {
     LocationProvider provider = new LocationProvider();
     LocationEntity entity = new LocationEntity();
     entity.IncludeIsForbid(true);
     entity.IsForbid = ConvertHelper.ToType<int>(IsForbid);
     entity.Where(a => a.LocalNum == LocalNum);
     int line = provider.Update(entity);
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
Exemple #4
0
        /// <summary>
        /// 获得库存信息
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        public List<LocalProductEntity> GetList(string barCode)
        {
            LocalProductEntity entity = new LocalProductEntity();
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.BarCode == barCode).Or(a => a.ProductNum == barCode);

            LocationEntity location = new LocationEntity();
            entity.Left<LocationEntity>(location, new Params<string, string>() { Item1 = "LocalNum", Item2 = "LocalNum" });
            location.Where(a => a.LocalType == (int)ELocalType.Normal);
            List<LocalProductEntity> listResult = this.LocalProduct.GetList(entity);
            return listResult;
        }
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            string StorageNum = WebUtil.GetFormValue<string>("StorageName", string.Empty);
            string LocalName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string LocalType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            LocationProvider provider = new LocationProvider();
            LocationEntity entity = new LocationEntity();

            StorageEntity SEntity = new StorageEntity();
            SEntity.Include(a => new { StorageName = a.StorageName });
            entity.Left<StorageEntity>(SEntity, new Params<string, string>() { Item1 = "StorageNum", Item2 = "StorageNum" });
            if (!StorageNum.IsEmpty())
            {
                entity.Where<LocationEntity>("StorageNum", ECondition.Like, "%" + StorageNum + "%");
            }
            if (!LocalName.IsEmpty())
            {
                entity.Begin<LocationEntity>()
                    .Where<LocationEntity>("LocalName", ECondition.Like, "%" + LocalName + "%")
                    .Or<LocationEntity>("LocalNum", ECondition.Like, "%" + LocalName + "%")
                    .Or<LocationEntity>("LocalBarCode", ECondition.Like, "%" + LocalName + "%")
                    .End<LocationEntity>()
                    ;
            }
            if (!LocalType.IsEmpty())
            {
                entity.Where<LocationEntity>("LocalType", ECondition.Like, "%" + LocalType + "%");
            }
            List<LocationEntity> listResult = provider.GetList(entity, ref pageInfo);
            listResult = listResult.IsNull() ? new List<LocationEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("库位编号 "));
                dt.Columns.Add(new DataColumn("库位名 "));
                dt.Columns.Add(new DataColumn("所在仓库 "));
                dt.Columns.Add(new DataColumn("库位类型"));
                dt.Columns.Add(new DataColumn("是否禁用"));
                dt.Columns.Add(new DataColumn("是否默认"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (LocationEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.LocalNum;
                    row[2] = t.LocalName;
                    row[3] = t.StorageName;
                    row[4] = EnumHelper.GetEnumDesc<ELocalType>(t.LocalType);
                    row[5] = EnumHelper.GetEnumDesc<EBool>(t.IsForbid);
                    row[6] = EnumHelper.GetEnumDesc<EBool>(t.IsDefault);
                    row[7] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("库位管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel = new NPOIExcel("库位管理", "库位", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }
        public ActionResult GetList()
        {
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 1);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 15);
            string LocalName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string LocalType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            LocationProvider provider = new LocationProvider();
            LocationEntity entity = new LocationEntity();
            StorageEntity SEntity = new StorageEntity();
            SEntity.Include(a => new { StorageName = a.StorageName });
            entity.Left<StorageEntity>(SEntity, new Params<string, string>() { Item1 = "StorageNum", Item2 = "StorageNum" });
            string StorageNum = this.DefaultStore;
            entity.Where<LocationEntity>("StorageNum", ECondition.Eth, StorageNum);
            if (!LocalName.IsEmpty())
            {
                entity.Begin<LocationEntity>()
                    .Where<LocationEntity>("LocalName", ECondition.Like, "%" + LocalName + "%")
                    .Or<LocationEntity>("LocalNum", ECondition.Like, "%" + LocalName + "%")
                    .Or<LocationEntity>("LocalBarCode", ECondition.Like, "%" + LocalName + "%")
                    .End<LocationEntity>()
                    ;
            }
            if (!LocalType.IsEmpty())
            {
                entity.Where<LocationEntity>("LocalType", ECondition.Eth, LocalType);
            }

            List<LocationEntity> listResult = provider.GetList(entity, ref pageInfo);
            string json = ConvertJson.ListToJson<LocationEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return Content(this.ReturnJson.ToString());
        }
 /// <summary>
 /// 根据库存编码查询仓库信息
 /// </summary>
 /// <param name="storageNum"></param>
 /// <returns></returns>
 public LocationEntity GetSingleByNum(string LocalNum)
 {
     LocationEntity entity = new LocationEntity();
     entity.IncludeAll();
     entity.Where(a => a.LocalNum == LocalNum);
     entity = this.Location.GetSingle(entity);
     return entity;
 }
 /// <summary>
 /// 查询分页
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="pageInfo"></param>
 /// <returns></returns>
 public List<LocationEntity> GetList(LocationEntity entity, ref PageInfo pageInfo)
 {
     try
     {
         entity.IncludeAll();
         entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
         entity.OrderBy(a => a.ID, EOrderBy.DESC);
         int rowCount = 0;
         List<LocationEntity> listResult = this.Location.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);
         pageInfo.RowCount = rowCount;
         if (!listResult.IsNullOrEmpty())
         {
             StorageProvider storageProvider = new StorageProvider();
             List<StorageEntity> listStorage = storageProvider.GetList();
             listStorage = listStorage.IsNull() ? new List<StorageEntity>() : listStorage;
             foreach (LocationEntity item in listResult)
             {
                 StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum);
                 if (storage != null)
                 {
                     item.StorageName = storage.StorageName;
                 }
                 else
                 {
                     item.StorageName = "";
                 }
             }
         }
         return listResult;
     }
     catch (Exception e)
     {
         log.Error(e.Message);
     }
     return null;
 }
 /// <summary>
 /// 获得所有的库位
 /// </summary>
 /// <returns></returns>
 public List<LocationEntity> GetList()
 {
     List<LocationEntity> listResult = CacheHelper.Get<List<LocationEntity>>(CacheKey.JOOSHOW_LOCATION_CACHE);
     if (!listResult.IsNullOrEmpty())
     {
         return listResult;
     }
     LocationEntity entity = new LocationEntity();
     entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
     entity.IncludeAll();
     listResult = this.Location.GetList(entity);
     if (!listResult.IsNullOrEmpty())
     {
         StorageProvider storageProvider = new StorageProvider();
         List<StorageEntity> listStorage = storageProvider.GetList();
         listStorage = listStorage.IsNull() ? new List<StorageEntity>() : listStorage;
         foreach (LocationEntity item in listResult)
         {
             StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum);
             if (storage != null)
             {
                 item.StorageName = storage.StorageName;
             }
         }
         CacheHelper.Insert(CacheKey.JOOSHOW_LOCATION_CACHE, listResult, null, DateTime.Now.AddHours(6));
     }
     return listResult;
 }
 /// <summary>
 /// 删除库位信息
 /// </summary>
 /// <param name="storageNum"></param>
 /// <returns></returns>
 public int Delete(string LocalNum)
 {
     LocationEntity entity = new LocationEntity();
     entity.IsDelete = (int)EIsDelete.Deleted;
     entity.IncludeIsDelete(true);
     entity.Where(a => a.LocalNum == LocalNum);
     int line = this.Location.Update(entity);
     if (line > 0)
     {
         Clear();
     }
     return line;
 }