94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using Infrastructure.Attribute;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ZR.Model.mes.md;
|
|
using ZR.Service.mes.md.IService;
|
|
using ZR.Service.MES.md.IService;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace ZR.Service.MES.md
|
|
{
|
|
|
|
[AppService(ServiceType = typeof(IMdBOMService), ServiceLifetime = LifeTime.Transient)]
|
|
public class MdBOMService : BaseService<MdWorkstation>, IMdBOMService
|
|
{
|
|
int IMdBOMService.AddWorkline(MdBom workline)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
int IMdBOMService.deleteWorkline(int[] ids)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
(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);
|
|
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();
|
|
|
|
//2. 查询儿子
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
data.AddRange(data1);
|
|
data.AddRange(data2);
|
|
|
|
}
|
|
return (data.Count(),data);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int IMdBOMService.UpdateWorkline(MdBom workline)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|