using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Repository;
using System.Linq;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
namespace ZR.Service.mes.wms
{
///
/// 成品库当前货物表Service业务层处理
///
[AppService(ServiceType = typeof(IWmGoodsNowProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsNowProductionService : BaseService, IWmGoodsNowProductionService
{
///
/// 查询成品库当前货物表列表
///
///
///
public PagedInfo GetList(WmGoodsNowProductionQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), it => it.PackageCodeClient.Contains(parm.PackageCodeClient))
.AndIF(!string.IsNullOrEmpty(parm.LocationCode), it => it.LocationCode.Contains(parm.LocationCode))
;
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public WmGoodsNowProduction GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加成品库当前货物表
///
///
///
public WmGoodsNowProduction AddWmGoodsNowProduction(WmGoodsNowProduction model)
{
if (string.IsNullOrEmpty(model.Id))
{
model.Id = SnowFlakeSingle.Instance.NextId().ToString();//也可以在程序中直接获取ID
}
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改成品库当前货物表
///
///
///
public int UpdateWmGoodsNowProduction(WmGoodsNowProduction model)
{
//var response = Update(w => w.Id == model.Id, it => new WmGoodsNowProduction()
//{
// PackageCode = model.PackageCode,
// PackageCodeClient = model.PackageCodeClient,
// PackageCodeOriginal = model.PackageCodeOriginal,
// LocationCode = model.LocationCode,
// Partnumber = model.Partnumber,
// GoodsNumLogic = model.GoodsNumLogic,
// GoodsNumAction = model.GoodsNumAction,
// EntryWarehouseTime = model.EntryWarehouseTime,
// Remark = model.Remark,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
//});
//return response;
return Update(model, true);
}
}
}