using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class InspectionContentBundle
|
{
|
/// <summary>
|
/// 通过 CorpID 获取缓存
|
/// </summary>
|
/// <param name="CorpID"></param>
|
/// <returns></returns>
|
private List<Model.ProductInspectionContentViewModel> 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<Model.ProductInspectionContentViewModel>();
|
}
|
|
var service_item = new Service.ProductInspectionContentItem();
|
var model_item_list = service_item.GetByCorpID(CorpID);
|
if (model_item_list == null)
|
{
|
return new List<Model.ProductInspectionContentViewModel>();
|
}
|
|
var service_value = new Service.ProductInspectionContentValue();
|
var model_value_list = service_value.GetByCorpID(CorpID);
|
if (model_value_list == null)
|
{
|
model_value_list = new List<Model.ProductInspectionContentValue>();
|
}
|
|
|
List<Model.ProductInspectionContentViewModel> v_list = new List<Model.ProductInspectionContentViewModel>();
|
|
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<Model.ProductInspectionContentValue.BaseInfo>();
|
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);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="CorpID"></param>
|
/// <param name="ProductID"></param>
|
/// <returns></returns>
|
public List<IStation.Model.ProductInspectionContentViewModel> 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();
|
}
|
|
/// <summary>
|
/// 获取哪些已经配置的产品ID列表
|
/// </summary>
|
/// <param name="CorpID"></param>
|
/// <returns></returns>
|
public List<long> GetProductIDList(long CorpID)
|
{
|
var all = GetCorpCache(CorpID);
|
return (from x in all select x.ProductID).Distinct().ToList();
|
}
|
|
|
}
|
}
|