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

105 lines
3.3 KiB
C#
Raw Normal View History

2023-08-09 15:16:45 +08:00
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)
{
2023-08-10 10:27:53 +08:00
return Delete(ids);
2023-08-09 15:16:45 +08:00
}
2023-08-10 10:27:53 +08:00
2023-08-09 15:16:45 +08:00
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;
}
2023-08-10 11:33:34 +08:00
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))
2024-06-07 11:04:26 +08:00
.AndIF(starttime.IsNotEmpty(), pro => pro.CreatedTime >= starttime)
.AndIF(endtime.IsNotEmpty(), pro => pro.CreatedTime >= endtime)
2023-08-10 11:33:34 +08:00
.ToExpression();
2024-06-07 11:04:26 +08:00
return Context.Queryable<MdProductDefine>().Where(predicate).ToList();
2023-08-10 11:33:34 +08:00
}
2023-08-09 15:16:45 +08:00
2023-08-10 10:27:53 +08:00
public MdProductDefine GetProductDefinebyPK(int measure)
2023-08-09 15:16:45 +08:00
{
2024-06-07 11:04:26 +08:00
MdProductDefine product = GetId(measure);
MdUnit unit = Context.Queryable<MdUnit>().Where(it => it.MeasureId == product.ProductUnit).First();
2023-10-12 11:51:10 +08:00
if (unit != null)
{
product.ProductUnitName = unit.MeasureName;
}
2024-06-07 11:04:26 +08:00
2023-08-10 10:27:53 +08:00
return product;
2023-08-09 15:16:45 +08:00
}
public List<MdUnit> GetProductDefineList(string name)
{
2024-06-07 11:04:26 +08:00
return Context.Queryable<MdUnit>().Where(it => it.MeasureName.Contains(name)).ToList();
2023-08-09 15:16:45 +08:00
}
public List<MdUnit> GetProductDefineList()
{
return Context.Queryable<MdUnit>().ToList();
}
2024-06-07 11:04:26 +08:00
2023-10-12 11:51:10 +08:00
public List<MdWorkline> GetWorklineList()
{
return Context.Queryable<MdWorkline>().ToList();
}
2023-08-10 10:27:53 +08:00
public int InsertProductDefine(MdProductDefine jo)
2023-08-09 15:16:45 +08:00
{
2023-08-10 10:27:53 +08:00
return Insert(jo);
2023-08-09 15:16:45 +08:00
}
2023-08-11 19:29:28 +08:00
public int UpdateProductDefine(MdWorkshop paramss)
2023-08-09 15:16:45 +08:00
{
throw new NotImplementedException();
}
2023-08-10 10:27:53 +08:00
public int UpdateProductDefine(MdProductDefine paramss)
{
2024-06-07 11:04:26 +08:00
return Update(paramss, true);
2023-08-10 10:27:53 +08:00
}
2024-06-07 11:04:26 +08:00
2023-08-10 10:27:53 +08:00
2023-08-09 15:16:45 +08:00
}
}