shgx_tz_mom/ZR.Service/mes/md/MdProductDefineService.cs

105 lines
3.3 KiB
C#

using Infrastructure.Attribute;
using Infrastructure.Extensions;
using SqlSugar;
using System;
using ZR.Model.mes.md;
using ZR.Model.mes.md.DTO;
using ZR.Service.mes.md.IService;
namespace ZR.Service.mes.md
{
[AppService(ServiceType = typeof(IMdProductDefineService), ServiceLifetime = LifeTime.Transient)]
public class MdProductDefineService : BaseService<MdProductDefine>, IMdProductDefineService
{
public int deleteProductDefine(int[] ids)
{
return Delete(ids);
}
public MdProductDefineDTO GetList(string name, string code, int pageNum, int pageSize)
{
int totalNum = 0;
var predicate = Expressionable.Create<MdProductDefine>()
.AndIF(name.IsNotEmpty(), pro => pro.ProductName.Contains(name))
.AndIF(code.IsNotEmpty(), pro => pro.ProductCode.Contains(code)).ToExpression();
List<MdProductDefine> data = Context.Queryable<MdProductDefine>()
.LeftJoin<MdUnit>((pro, unit) => pro.ProductUnit == unit.MeasureId)
.Where(predicate)
.Select((pro, unit) => new MdProductDefine()
{
ProductUnitName = unit.MeasureName
},
true).ToPageList(pageNum, pageSize, ref totalNum);
MdProductDefineDTO productPageDto = new MdProductDefineDTO();
productPageDto.list = data;
productPageDto.Total = totalNum;
return productPageDto;
}
public List<MdProductDefine> GetList(DateTime starttime, DateTime endtime, string productCode, string productName)
{
var predicate = Expressionable.Create<MdProductDefine>()
.AndIF(productCode.IsNotEmpty(), pro => pro.ProductCode.Contains(productCode))
.AndIF(productName.IsNotEmpty(), pro => pro.ProductName.Contains(productName))
.AndIF(starttime.IsNotEmpty(), pro => pro.CreatedTime >= starttime)
.AndIF(endtime.IsNotEmpty(), pro => pro.CreatedTime >= endtime)
.ToExpression();
return Context.Queryable<MdProductDefine>().Where(predicate).ToList();
}
public MdProductDefine GetProductDefinebyPK(int measure)
{
MdProductDefine product = GetId(measure);
MdUnit unit = Context.Queryable<MdUnit>().Where(it => it.MeasureId == product.ProductUnit).First();
if (unit != null)
{
product.ProductUnitName = unit.MeasureName;
}
return product;
}
public List<MdUnit> GetProductDefineList(string name)
{
return Context.Queryable<MdUnit>().Where(it => it.MeasureName.Contains(name)).ToList();
}
public List<MdUnit> GetProductDefineList()
{
return Context.Queryable<MdUnit>().ToList();
}
public List<MdWorkline> GetWorklineList()
{
return Context.Queryable<MdWorkline>().ToList();
}
public int InsertProductDefine(MdProductDefine jo)
{
return Insert(jo);
}
public int UpdateProductDefine(MdWorkshop paramss)
{
throw new NotImplementedException();
}
public int UpdateProductDefine(MdProductDefine paramss)
{
return Update(paramss, true);
}
}
}