using SqlSugar; using System; using System.Collections.Generic; using WMS.Info; using WMS.Util; namespace WMS.Core { public class BaseWarehouse { public const string WarehouseHead = "37731699696042abb0d46c7699e29c60"; /// /// 获取列表数据 /// /// public IEnumerable GetList(string keyword) { try { return SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0).WhereIF(!keyword.IsEmpty(), it => it.F_NO.Contains(keyword) || it.F_NAME.Contains(keyword)).ToList(); } catch (Exception ex) { throw ex; } } /// /// 获取启用列表数据 /// /// public IEnumerable GetEnableList() { try { return SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); } catch (Exception ex) { throw ex; } } /// /// 获取树型 /// /// public List GetCheckTree() { List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); List treeList = new List(); { TreeModel node = new TreeModel(); node.id = ACLAuthorize.ALLAuthorize; node.text = " 仓库"; node.value = ""; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ""; treeList.Add(node); } foreach (var item in list) { TreeModel node = new TreeModel(); node.id = item.F_NO; node.text = item.F_NAME; node.value = item.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ACLAuthorize.ALLAuthorize; treeList.Add(node); } return treeList.ToTree(); } /// /// 获取树型 /// /// public List GetCheckWWTree() { List treeList = new List(); List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); foreach (var item in list) { TreeModel node = new TreeModel(); node.id = item.F_NO; node.text = item.F_NAME; node.value = item.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ""; treeList.Add(node); } List warealist = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); foreach (var item in warealist) { TreeModel node = new TreeModel(); node.id = item.F_NO; node.text = item.F_NAME; node.value = item.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = item.F_WAREHOUSENO; treeList.Add(node); } return treeList.ToTree(); } public List GetCheckWWTreeByLocation() { List treeList = new List(); List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0 && it.F_TYPENUM == 1).ToList(); foreach (var item in list) { TreeModel node = new TreeModel(); node.id = item.F_NO; node.text = item.F_NAME; node.value = item.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ""; treeList.Add(node); } return treeList.ToTree(); } /// /// 获取树型 /// /// public List GetCheckWWACLTree() { List treeList = new List(); List list = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); { TreeModel node = new TreeModel(); node.id = ACLAuthorize.ALLAuthorize; node.text = " 仓库"; node.value = ""; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ""; treeList.Add(node); } foreach (var item in list) { TreeModel node = new TreeModel(); node.id = WarehouseHead + "_" + item.F_NO; node.text = item.F_NAME; node.value = WarehouseHead + "_" + item.F_NO; node.showcheck = true; node.checkstate = 0; node.isexpand = true; node.icon = ACLAuthorize.IcoAuthorize; node.parentId = ACLAuthorize.ALLAuthorize; treeList.Add(node); } //List warealist = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).ToList(); //foreach (var item in warealist) //{ // TreeModel node = new TreeModel(); // node.id = item.F_NO; // node.text = item.F_NAME; // node.value = item.F_NO; // node.showcheck = true; // node.checkstate = 0; // node.isexpand = true; // node.icon = ACLAuthorize.IcoAuthorize; // node.parentId = WarehouseHead + "_" + item.F_WAREHOUSENO; // treeList.Add(node); //} return treeList.ToTree(); } /// /// 获取分页数据 /// /// public IEnumerable GetPageList(string keyword, Pagination pagination) { try { int count = 0; var db = SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0).WhereIF(!keyword.IsEmpty(), it => it.F_NO.Contains(keyword) || it.F_NAME.Contains(keyword)); List list = new List(); if (pagination.sord.ToUpper() == "ASC") { list = db.OrderBy(pagination.sidx).ToPageList(pagination.page, pagination.rows, ref count); } else { string orderstr = pagination.sidx + " desc"; list = db.OrderBy(orderstr).ToPageList(pagination.page, pagination.rows, ref count); } pagination.records = count; return list; } catch (Exception ex) { throw ex; } } /// /// 获取实体数据 /// 主键 /// /// public BASE_WAREHOUSE GetEntity(string keyValue) { try { return SysDbCore.GetDbCtx().Queryable().Where(it => it.F_ISDELETE == 0 && it.F_NO == keyValue).First(); } catch (Exception ex) { throw ex; } } /// /// 删除实体数据 /// 主键 /// /// public void DeleteEntity(string keyValue) { try { //SysDbCore.GetDbCtx().Deleteable().Where(it => it.F_NO == keyValue).ExecuteCommand(); SysDbCore.GetDbCtx().Updateable().UpdateColumns(it => new BASE_WAREHOUSE { F_ISDELETE = 1 }).Where(it => it.F_NO == keyValue).ExecuteCommand(); } catch (Exception ex) { throw ex; } } /// /// 保存实体数据(新增、修改) /// 主键 /// /// public void SaveEntity(LoginUserInfo loginUserInfo, string keyValue, BASE_WAREHOUSE entity) { try { if (entity == null) { throw SysExCore.ThrowFailException("输入数据为空。"); } if (string.IsNullOrWhiteSpace(entity.F_NO)) { throw SysExCore.ThrowFailException("编码为空。"); } if (string.IsNullOrWhiteSpace(entity.F_NAME)) { throw SysExCore.ThrowFailException("名称为空。"); } entity.F_EDITTIME = DateTime.Now; entity.F_EDITUSERNO = loginUserInfo.UserNo; if (string.IsNullOrEmpty(keyValue)) { var item = SysDbCore.GetDbCtx().Queryable().First(v => v.F_NO == entity.F_NO); if (item != null) { throw SysExCore.ThrowFailException("添加仓库时,仓库编号不能重复。"); } entity.F_ADDTIME = DateTime.Now; entity.F_ADDUSERNO = loginUserInfo.UserNo; entity.F_ISDELETE = 0; //entity.F_ISSTOP = 0; SysDbCore.GetDbCtx().Insertable(entity).ExecuteCommand(); } else { SysDbCore.GetDbCtx().Updateable(entity).IgnoreColumns(it => new { it.F_ADDTIME, it.F_ADDUSERNO }).Where(it => it.F_NO == keyValue).ExecuteCommand(); } } catch (Exception ex) { throw ex; } } /// /// 获取仓库和区域列表数据 /// /// 父节点主键(0表示顶层) /// 关键字查询(名称/编号) /// //public List GetList(string parentId, string keyword) //{ // try // { // //if (string.IsNullOrWhiteSpace(parentId)) // //{ // // parentId = "0"; // //} // //var db = SysDbCore.GetDbCtx().Queryable().Where(v => v.F_PARENTID == parentId); // //var list = db.Where(t => t.F_NAME.Contains(keyword)).ToList(); // return null; // } // catch (Exception ex) // { // throw ex; // } //} public Dictionary GetMap() { try { Dictionary dics = new Dictionary(); SysDbCore.GetDbCtx().Queryable().ToList().ForEach(it => dics.Add(it.F_NO, it)); return dics; } catch (Exception ex) { throw ex; } } } }