using System; using System.Collections.Generic; using System.Linq; using System.Text; using CY.IDAL; using AbstractFactory; using CY.Model; using CY.BLL.EC; namespace CY.BLL.Sys { /// /// 字典表业务逻辑操作类 /// public class SysInquiry_PrintingTypeBLL { private ISysInquiry_PrintingTypeDAL _sysInquiry_PrintingTypeDal;//字典表数据访问服务接口 EC_SellerBusinessLimitsBLL _eC_SellerBusinessLimitsBLL = null; /// /// 初始化 /// public SysInquiry_PrintingTypeBLL() { _sysInquiry_PrintingTypeDal = Factory.GetDALByInterfaceName(DALInterface.ISysInquiry_PrintingTypeDAL) as ISysInquiry_PrintingTypeDAL;//获取数据访问接口实现对象 _eC_SellerBusinessLimitsBLL = new EC_SellerBusinessLimitsBLL(); } /// /// 添加数据 /// /// /// public bool AddData(SysInquiry_PrintingType dicInfo) { return _sysInquiry_PrintingTypeDal.InserModel(dicInfo); } /// /// 更新数据 /// /// /// public bool UpdataData(SysInquiry_PrintingType dicInfo) { return _sysInquiry_PrintingTypeDal.UpdateModel(dicInfo); } /// /// 删除数据 /// /// /// public bool DeleteData(SysInquiry_PrintingType dicInfo) { return _sysInquiry_PrintingTypeDal.DeleteModel(dicInfo); } /// /// 获取有效的印刷业务类型 /// /// public IEnumerable SelectUsedModles() { return _sysInquiry_PrintingTypeDal.SelectUsedModles(); } /// /// 排序获取有效的印刷业务类型 /// /// public IEnumerable SelectUsedModlesByIndex() { return _sysInquiry_PrintingTypeDal.SelectUsedModlesByIndex(); } /// /// 获取某个厂商有效的印刷业务类型 /// /// public IEnumerable SelectUsedModlesByFirm(Guid firmId) { IEnumerable list = _sysInquiry_PrintingTypeDal.SelectUsedModles(); list = list.Where(p => _eC_SellerBusinessLimitsBLL.IsUsed(p.KeyId, firmId)); return list; } /// /// 获取某个厂商有效的印刷业务类型的父类型列表 /// /// public IList SelectParentModelListByFirm(Guid firmId) { IList parentTypeList = new List(); IEnumerable childTypeList = SelectUsedModlesByFirm(firmId); if (childTypeList != null && childTypeList.Count() > 0) { foreach (SysInquiry_PrintingType child in childTypeList) { SysInquiry_PrintingType parent = GetModelById(child.ParentId.Value); if (!IsExist(parentTypeList, parent.KeyId)) parentTypeList.Add(parent); } } return parentTypeList; } /// /// 根据父类型获取有效且特殊的印刷业务类型(用于纸张配置) /// /// public IEnumerable SelectUsedModlesByFirm(int parentId, Guid firmId) { IEnumerable childTypeList = SelectUsedModlesByFirm(firmId).Where(p => p.ParentId == parentId); return childTypeList; } /// /// 获取有效且特殊的印刷业务类型(用于纸张配置) /// /// public IEnumerable SelectUsedModlesBySpecial() { return _sysInquiry_PrintingTypeDal.SelectUsedModles().Where(p => p.KeyId != 13 && p.KeyId != 31 && p.KeyId != 32 && p.KeyId != 34 && p.KeyId != 36 && p.KeyId != 17 && p.KeyId != 33 && p.KeyId != 18 && p.KeyId != 19); } /// /// 获取有效且特殊的印刷业务类型的父类型列表(用于纸张配置) /// /// public IList SelectParentModelListBySpecial() { IList parentTypeList=new List(); IEnumerable childTypeList = SelectUsedModlesBySpecial(); if (childTypeList != null && childTypeList.Count() > 0) { foreach (SysInquiry_PrintingType child in childTypeList) { SysInquiry_PrintingType parent = GetModelById(child.ParentId.Value); if (!IsExist(parentTypeList,parent.KeyId)) parentTypeList.Add(parent); } } return parentTypeList; } /// /// 判断父类型中是否已存在 /// /// /// /// private bool IsExist(IList parentTypeList, int keyId) { if (parentTypeList == null || parentTypeList.Count == 0) return false; IList resultList = parentTypeList.Where(p => p.KeyId == keyId).ToList(); if (resultList != null && resultList.Count > 0) { return true; } else { return false; } } /// /// 根据父类型获取有效且特殊的印刷业务类型(用于纸张配置) /// /// public IEnumerable SelectUsedModlesBySpecial(int parentId) { IEnumerable childTypeList = SelectUsedModlesBySpecial().Where(p => p.ParentId == parentId); return childTypeList; } /// /// 获取有效且特殊的印刷业务类型(用于后道消耗) /// /// /// public IEnumerable SelectUsedModlesByAfterConsumption(Guid firmId) { IEnumerable list = _sysInquiry_PrintingTypeDal.SelectUsedModles().Where(p => p.KeyId != 13 && p.KeyId != 31 && p.KeyId != 32 && p.KeyId != 34 && p.KeyId != 36&&p.KeyId!=17&&p.KeyId!=33&&p.KeyId!=35); list = list.Where(p => _eC_SellerBusinessLimitsBLL.IsUsedBySpecialFlag(p.KeyId, firmId)); return list; } /// /// 获取有效且特殊的印刷业务类型的父类型列表(用于后道消耗) /// /// public IList SelectParentModelListByAfterConsumption(Guid firmId) { IList parentTypeList = new List(); IEnumerable childTypeList = SelectUsedModlesByAfterConsumption(firmId); if (childTypeList != null && childTypeList.Count() > 0) { foreach (SysInquiry_PrintingType child in childTypeList) { SysInquiry_PrintingType parent = GetModelById(child.ParentId.Value); if (!IsExist(parentTypeList, parent.KeyId)) parentTypeList.Add(parent); } } return parentTypeList; } /// /// 根据父类型获取有效且特殊的印刷业务类型(用于后道消耗) /// /// public IEnumerable SelectUsedModlesByAfterConsumption(int parentId, Guid firmId) { IEnumerable childTypeList = SelectUsedModlesByAfterConsumption(firmId).Where(p => p.ParentId == parentId); return childTypeList; } /// /// 获取有效且特殊的印刷业务类型(用于后道设置) /// /// /// public IEnumerable SelectUsedModlesByAfterSet(Guid firmId) { IEnumerable list = _sysInquiry_PrintingTypeDal.SelectUsedModles().Where(p => p.KeyId != 32 && p.KeyId != 34 && p.KeyId != 17 && p.KeyId != 18 && p.KeyId != 19); list = list.Where(p => _eC_SellerBusinessLimitsBLL.IsUsed(p.KeyId, firmId)); return list; } /// /// 获取有效且特殊的印刷业务类型的父类型列表(用于后道设置) /// /// public IList SelectParentModelListByAfterSet(Guid firmId) { IList parentTypeList = new List(); IEnumerable childTypeList = SelectUsedModlesByAfterSet(firmId); if (childTypeList != null && childTypeList.Count() > 0) { foreach (SysInquiry_PrintingType child in childTypeList) { SysInquiry_PrintingType parent = GetModelById(child.ParentId.Value); if (!IsExist(parentTypeList, parent.KeyId)) parentTypeList.Add(parent); } } return parentTypeList; } /// /// 根据父类型获取有效且特殊的印刷业务类型(用于后道消耗) /// /// public IEnumerable SelectUsedModlesByAfterSet(int parentId, Guid firmId) { IEnumerable childTypeList = SelectUsedModlesByAfterSet(firmId).Where(p => p.ParentId == parentId); return childTypeList; } /// /// 获取有效的合版印刷业务类型 /// /// /// public IEnumerable SelectUsedModlesByJoin(Guid firmId) { IEnumerable list = SelectUsedModles(); list = list.Where(p => p.JoinFlag == 1); list = list.Where(p => _eC_SellerBusinessLimitsBLL.IsUsedByJoin(p.KeyId, firmId)); return list; } /// /// 根据keyId获取印刷类型 /// /// /// public SysInquiry_PrintingType GetModelById(int keyId) { return _sysInquiry_PrintingTypeDal.GetModelById(keyId); } /// /// 获取所有有效的印刷类型(包含父) /// /// public IEnumerable GetAllModelList() { return _sysInquiry_PrintingTypeDal.GetAllModelList(); } /// /// 获取所有有效的一级类别 /// /// public IEnumerable GetModelListByParent() { IEnumerable typeList = _sysInquiry_PrintingTypeDal.GetAllModelList().Where(p => p.ParentId == 0); return typeList; } /// /// 获取有效的一级类别下的所有类别 /// /// /// public IEnumerable GetModelListByParent(int parentId) { IEnumerable typeList = _sysInquiry_PrintingTypeDal.GetAllModelList().Where(p => p.ParentId == parentId); return typeList; } /// /// 获取所有有效首页使用的印刷类型列表 /// /// public IEnumerable GetModelListByHome() { IEnumerable typeList = _sysInquiry_PrintingTypeDal.SelectUsedModles().Where(p => p.KeyId!=17&&p.KeyId!=34&&p.KeyId!=36); return typeList; } /// /// 获取有效的印刷业务类型(首页) /// /// public IEnumerable SelectUsedModlesHome() { IEnumerable typeList = _sysInquiry_PrintingTypeDal.SelectUsedModlesHome().Where(p => p.KeyId != 25 && p.KeyId != 26 && p.KeyId != 35&& p.KeyId != 29 && p.KeyId != 32); return typeList; } } }