bom完成
This commit is contained in:
@@ -16,78 +16,84 @@ namespace ZR.Service.MES.md
|
||||
{
|
||||
|
||||
[AppService(ServiceType = typeof(IMdBOMService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class MdBOMService : BaseService<MdWorkstation>, IMdBOMService
|
||||
public class MdBOMService : BaseService<MdBom>, IMdBOMService
|
||||
{
|
||||
int IMdBOMService.AddWorkline(MdBom workline)
|
||||
public int deleteBOM(int[] ids)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Delete(ids);
|
||||
|
||||
}
|
||||
|
||||
int IMdBOMService.deleteWorkline(int[] ids)
|
||||
public List<MdUnit> GetAllunitList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Context.Queryable<MdUnit>().Where(it=>it.EnableFlag=='Y').ToList();
|
||||
}
|
||||
|
||||
public int UpdateBOM(MdBom mdBom)
|
||||
{
|
||||
return Context.Updateable(mdBom).WhereColumns(it => new {it.Id, it.ProductCode }).ExecuteCommand();
|
||||
}
|
||||
|
||||
int IMdBOMService.AddBom(MdBom bom)
|
||||
{
|
||||
return Insert(bom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
(int, List<MdBom>) IMdBOMService.GetAll(string productCode, string productName, int pageNum, int pageSize)
|
||||
{
|
||||
int totalNum = 0;
|
||||
|
||||
if (string.IsNullOrEmpty(productCode) && string.IsNullOrEmpty(productName))
|
||||
{
|
||||
var data = Context.Queryable<MdBom>().ToPageList(pageNum, pageSize,ref totalNum);
|
||||
List<MdBom> data = Context.Queryable<MdBom>().ToTree(it => it.Child, it => it.ParentProductId, null);
|
||||
totalNum = data.Count();
|
||||
data = data.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();
|
||||
|
||||
|
||||
return (totalNum, data);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//1. 查询本体
|
||||
var predicate = Expressionable.Create<MdBom>()
|
||||
.AndIF(!string.IsNullOrEmpty(productCode), it => it.ProductCode.Contains(productCode))
|
||||
.AndIF(!string.IsNullOrEmpty(productName), it => it.ProductName.Contains(productName))
|
||||
.ToExpression();
|
||||
List<MdBom> data = Context.Queryable<MdBom>().Where(predicate).ToList();
|
||||
.AndIF(!string.IsNullOrEmpty(productCode), it => it.ProductCode.Contains(productCode))
|
||||
.AndIF(!string.IsNullOrEmpty(productName), it => it.ProductName.Contains(productName))
|
||||
.And(it=>it.ParentProductId==null)
|
||||
.ToExpression();
|
||||
|
||||
//2. 查询儿子
|
||||
if (data != null & data.Count > 0)
|
||||
List<MdBom> data = Context.Queryable<MdBom>().Where(predicate).ToList();
|
||||
totalNum = data.Count();
|
||||
List<MdBom> dataSons = new List<MdBom>();
|
||||
if (data != null && data.Count > 0)
|
||||
{
|
||||
List<MdBom> data1 = new List<MdBom>();
|
||||
List<MdBom> data2 = new List<MdBom>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
List<MdBom> dataItems = Context.Queryable<MdBom>().Where(it => it.ParentProductId == item.Id).ToList();
|
||||
data1.AddRange(dataItems);
|
||||
dataItems.Clear();
|
||||
|
||||
// 3. 查询孙子
|
||||
if (data1 != null & data1.Count > 0)
|
||||
{
|
||||
foreach (var item1 in data1)
|
||||
{
|
||||
List<MdBom> dataItemss = Context.Queryable<MdBom>().Where(it1 => it1.ParentProductId == item1.Id).ToList();
|
||||
data2.AddRange(dataItemss);
|
||||
dataItemss.Clear();
|
||||
}
|
||||
}
|
||||
List<MdBom> data1 = Context.Queryable<MdBom>().ToTree(it => it.Child, it => it.ParentProductId, item.Id);
|
||||
item.Child=data1;
|
||||
}
|
||||
|
||||
data.AddRange(data1);
|
||||
data.AddRange(data2);
|
||||
|
||||
}
|
||||
return (data.Count(),data);
|
||||
data = data.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();
|
||||
return (totalNum, data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int IMdBOMService.UpdateWorkline(MdBom workline)
|
||||
List<MdBom> IMdBOMService.QueryBOM(string queryString)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var predicate = Expressionable.Create<MdBom>()
|
||||
.AndIF(!string.IsNullOrEmpty(queryString), it => it.ProductCode.Contains(queryString))
|
||||
.ToExpression();
|
||||
return Context.Queryable<MdBom>().Where(predicate).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user