using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Service { /// /// /// public class InspectionContentBundle { /// /// 通过 CorpID 获取缓存 /// /// /// private List GetCorpCache(long CorpID) { return InspectionContentBundleCacheHelper.GetSet(CorpID, () => { var service_grp = new Service.ProductInspectionContentGrp(); var model_grp_list = service_grp.GetByCorpID(CorpID); if (model_grp_list == null) { return new List(); } var service_item = new Service.ProductInspectionContentItem(); var model_item_list = service_item.GetByCorpID(CorpID); if (model_item_list == null) { return new List(); } var service_value = new Service.ProductInspectionContentValue(); var model_value_list = service_value.GetByCorpID(CorpID); if (model_value_list == null) { model_value_list = new List(); } List v_list = new List(); foreach(var grp in model_grp_list) { if (grp.UseStatus != Model.ProductInspectionContentGrp.eUseStatus.有效) continue; foreach (var item in model_item_list) { if (item.GroupID != grp.ID) continue; if (item.UseStatus != Model.ProductInspectionContentItem.eUseStatus.有效) continue; var v_item = new Model.ProductInspectionContentViewModel(item); v_item.GroupName = grp.Name; var vvv = model_value_list.Where(x => x.ItemID == item.ID); if (vvv.Count() > 0) { v_item.ValueList = new List(); foreach(var v in vvv) { if(v.UseStatus == Model.ProductInspectionContentValue.eUseStatus.有效) v_item.ValueList.Add(new Model.ProductInspectionContentValue.BaseInfo(v)); } } v_list.Add(v_item); } } return v_list; }, ConfigHelper.CacheKeepTime, ConfigHelper.CacheRandomTime); } /// /// /// /// /// /// public List GetByProductID(long CorpID, long ProductID) { var all = GetCorpCache(CorpID); if (all == null || all.Count == 0) return null; return (from x in all where x.ProductID == ProductID select x).ToList(); } /// /// 获取哪些已经配置的产品ID列表 /// /// /// public List GetProductIDList(long CorpID) { var all = GetCorpCache(CorpID); return (from x in all select x.ProductID).Distinct().ToList(); } } }