| | |
| | | { |
| | | return ProductCacheHelper.GetSet(projectId, () => |
| | | { |
| | | var entities = _dal.QueryAll(projectId); |
| | | var entities = _dal.GetAll(projectId); |
| | | var models = Entity2Models(entities); |
| | | if (models == null) |
| | | { |
| | |
| | | //根据 Id 更新缓存 |
| | | private void UpdateProjectCache(long projectId, long Id) |
| | | { |
| | | var entity_ds = _dal.QueryById(projectId, Id); |
| | | var entity_ds = _dal.GetById(projectId, Id); |
| | | var model_ds = Entity2Model(entity_ds); |
| | | var all = GetProjectCache(projectId); |
| | | var model = all.Find(x => x.Id == Id); |
| | |
| | | { |
| | | if (Ids == null || Ids.Count() < 1) |
| | | return; |
| | | var entities = _dal.QueryByIds(projectId, Ids); |
| | | var entities = _dal.GetByIds(projectId, Ids); |
| | | var models = Entity2Models(entities); |
| | | var all = GetProjectCache(projectId); |
| | | all.RemoveAll(x => Ids.Contains(x.Id)); |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region Query |
| | | #region Get |
| | | |
| | | /// <summary> |
| | | /// 查询全部 |
| | | /// </summary> |
| | | public List<Model.Product> QueryAll(long projectId) |
| | | public List<Model.Product> GetAll(long projectId) |
| | | { |
| | | var all = GetProjectCache(projectId); |
| | | return all.OrderBy(x => x.SortCode).ToList(); |
| | |
| | | /// <summary> |
| | | /// 根据 Id查询 |
| | | /// </summary> |
| | | public Model.Product QueryById(long projectId, long Id) |
| | | public Model.Product GetById(long projectId, long Id) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Find(x => x.Id == Id); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 Ids 查询 |
| | | /// </summary> |
| | | public List<Model.Product> QueryByIds(long projectId, IEnumerable<long> Ids) |
| | | public List<Model.Product> GetByIds(long projectId, IEnumerable<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count() < 1) |
| | | return default; |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => Ids.Contains(x.Id)).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 Catalog 查询 |
| | | /// </summary> |
| | | public List<Model.Product> QueryByCatalog(long projectId, string catalog) |
| | | public List<Model.Product> GetByCatalog(long projectId, string catalog) |
| | | { |
| | | if (string.IsNullOrEmpty(catalog)) |
| | | return default; |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => x.Catalog == catalog).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 BelongType 和 BelongId 查询 |
| | | /// </summary> |
| | | public List<Model.Product> QueryByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | public List<Model.Product> GetByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => x.BelongType == belongType && x.BelongId == belongId).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 BelongType 和 BelongIds 查询 |
| | | /// </summary> |
| | | public List<Model.Product> QueryByBelongTypeAndBelongIds(long projectId, string belongType, List<long> belongIds) |
| | | public List<Model.Product> GetByBelongTypeAndBelongIds(long projectId, string belongType, List<long> belongIds) |
| | | { |
| | | if (belongIds == null || belongIds.Count() < 1) |
| | | return default; |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => x.BelongType == belongType && belongIds.Contains(x.BelongId)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 Id 查询所有子项 |
| | | /// </summary> |
| | | public List<Model.Product> QueryChildrenById(long projectId, long Id) |
| | | public List<Model.Product> GetChildrenById(long projectId, long Id) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => x.ParentIds.Contains(Id)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 Id获取子项和自身 |
| | | /// </summary> |
| | | public List<Model.Product> QueryChildAndSelfById(long projectId, long Id) |
| | | public List<Model.Product> GetChildAndSelfById(long projectId, long Id) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Where(x => (x.Id == Id) || x.ParentIds.Contains(Id)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据 机泵获取子泵 |
| | | /// </summary> |
| | | public Model.Product<Model.Pump> QueryChildPumpByEnginePumpId(long projectId, long enginePumpId) |
| | | public Model.Product<Model.Pump> GetChildPumpByEnginePumpId(long projectId, long enginePumpId) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | var self = all.Find(x => x.Id == enginePumpId); |
| | | if (self == null) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 根据 机泵获取子电机 |
| | | /// </summary> |
| | | public Model.Product<Model.Motor> QueryChildMotorByEnginePumpId(long projectId, long enginePumpId) |
| | | public Model.Product<Model.Motor> GetChildMotorByEnginePumpId(long projectId, long enginePumpId) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | var self = all.Find(x => x.Id == enginePumpId); |
| | | if (self == null) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 根据 BelongType 和 BelongId 查询机泵列表 |
| | | /// </summary> |
| | | public List<Model.Product<Model.EnginePump>> QueryEnginePumpListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | public List<Model.Product<Model.EnginePump>> GetEnginePumpListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | { |
| | | var all = QueryByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var all = GetByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var engine_pump_list = all?.Where(x => x.Catalog == IStation.Product.Catalog_JiBeng).OrderBy(x => x.SortCode).ToList(); |
| | | if (engine_pump_list == null || engine_pump_list.Count < 1) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 查询机泵 |
| | | /// </summary> |
| | | public Model.Product<Model.EnginePump> QueryEnginePumpByProductId(long projectId, long ProductId) |
| | | public Model.Product<Model.EnginePump> GetEnginePumpByProductId(long projectId, long ProductId) |
| | | { |
| | | var all = this.QueryAll(projectId); |
| | | var all = this.GetAll(projectId); |
| | | var engine_pump = all?.Find(x => x.Catalog == IStation.Product.Catalog_JiBeng && x.Id == ProductId); |
| | | if (engine_pump == null) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 根据 BelongType 和 BelongId 查询泵列表 |
| | | /// </summary> |
| | | public List<Model.Product<Model.Pump>> QueryPumpListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | public List<Model.Product<Model.Pump>> GetPumpListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | { |
| | | var all = QueryByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var all = GetByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var engine_pump_list = all?.Where(x => x.Catalog == IStation.Product.Catalog_Beng).OrderBy(x => x.SortCode).ToList(); |
| | | if (engine_pump_list == null || engine_pump_list.Count < 1) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 根据 ProductId 查询摄像头 |
| | | /// </summary> |
| | | public Model.Product<Model.Camera> QueryCameraByProductId(long projectId, long ProductId) |
| | | public Model.Product<Model.Camera> GetCameraByProductId(long projectId, long ProductId) |
| | | { |
| | | var all = this.QueryAll(projectId); |
| | | var all = this.GetAll(projectId); |
| | | var camera = all?.Find(x => x.Catalog == IStation.Product.Catalog_SheXiangTou && x.Id == ProductId); |
| | | if (camera == null) |
| | | return default; |
| | |
| | | /// <summary> |
| | | /// 根据 BelongType 和 BelongId 查询摄像头列表 |
| | | /// </summary> |
| | | public List<Model.Product<Model.Camera>> QueryCameraListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | public List<Model.Product<Model.Camera>> GetCameraListByBelongTypeAndBelongId(long projectId, string belongType, long belongId) |
| | | { |
| | | var all = QueryByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var all = GetByBelongTypeAndBelongId(projectId, belongType, belongId); |
| | | var cameraList = all?.Where(x => x.Catalog == IStation.Product.Catalog_SheXiangTou).OrderBy(x => x.SortCode).ToList(); |
| | | if (cameraList == null || cameraList.Count < 1) |
| | | return default; |
| | |
| | | /// </summary> |
| | | public bool IsExistById(long projectId, long Id) |
| | | { |
| | | var all = QueryAll(projectId); |
| | | var all = GetAll(projectId); |
| | | return all.Exists(x => x.Id == Id); |
| | | } |
| | | #endregion |