using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Central.Control.Domain;
using Ant.Service.Common;
namespace MES.Production.Service.ServiceImp
{
///
/// Service层代码配置
/// add 作者: 季健国 QQ:181589805 by 2016-05-22
///
public class CodeManage : RepositoryBase,IService.ICodeManage
{
///
/// 根据编码类型获取编码集合
///
public List GetCode(string codetype, params string[] codevalue)
{
var predicate = PredicateBuilder.True();
predicate = predicate.And(p => p.CODETYPE == codetype);
if (codevalue != null && codevalue.Length > 0)
{
var str = codevalue.ToList();
predicate = predicate.And(p => str.Contains(p.CODEVALUE));
}
return this.LoadAll(predicate).OrderBy(p => p.SHOWORDER).ToList();
}
///
/// 通过系统字典获取编码值
///
public IQueryable GetDicType()
{
Dictionary code = Ant.Service.Common.Enums.ClsDic.DicCodeType;
string dic = code.Aggregate(string.Empty, (current, item) => current + (item.Value + ",")).TrimEnd(',');
return this.LoadAll(p => dic.Contains(p.CODETYPE)).OrderBy(p => p.SHOWORDER);
}
///
/// 根据字典ID与类型获取一条数据
///
public string GetCodeByID(int id,string codetype)
{
return (this.Get(p => p.ID == id) ?? new SYS_CODE()).NAMETEXT;
}
///
/// 根据字典编码值与类型获取一条数据
///
public string GetCodeNameByCodeValue(string codeType, string codevalue)
{
if (string.IsNullOrEmpty(codevalue))
return "";
var entity= this.Get(p => p.CODETYPE == codeType && p.CODEVALUE == codevalue);
if (entity == null) return "";
return entity.NAMETEXT;
}
}
}