using System; using SqlSugar; using Infrastructure.Attribute; using Infrastructure.Extensions; using ZR.Model; using ZR.Model.Dto; using ZR.Repository; using System.Linq; using ZR.Service.mes.wms.IService; using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; using static System.Runtime.InteropServices.JavaScript.JSType; namespace ZR.Service.mes.wms { /// /// 出库货物记录表Service业务层处理 /// [AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)] public class WmGoodsOutProductionService : BaseService, IWmGoodsOutProductionService { /// /// 查询出库货物记录表列表 /// /// /// public (List,int) GetList(WmGoodsOutProductionQueryDto parm) { int total = 0; 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)) .AndIF(!string.IsNullOrEmpty(parm.FkOutOrderId),it=>it.FkOutOrderId.Contains(parm.FkOutOrderId)) ; var response = Queryable() .LeftJoin((wgo, wml) => wgo.Partnumber == wml.Partnumber) .Where(predicate.ToExpression()) .Select((wgo, wml) => new WmGoodsOutProductionDto { Description = wml.Description }, true) .ToPageList(parm.PageNum, parm.PageSize,ref total); return (response,total); } /// /// 获取详情 /// /// /// public WmGoodsOutRecord GetInfo(string Id) { var response = Queryable() .Where(x => x.Id == Id) .First(); return response; } /// /// 添加出库货物记录表 /// /// /// public WmGoodsOutRecord AddWmGoodsOutProduction(WmGoodsOutRecord model) { if(string.IsNullOrEmpty(model.PackageCode)) { model.PackageCode = "L" + DateTime.Now.ToString("yyMMddHHmmss"); } if (string.IsNullOrEmpty(model.Id)) { model.Id= SnowFlakeSingle.Instance.NextId().ToString();//也可以在程序中直接获取ID } //2. 根据成品仓库id修改记录 WmGoodsNowProduction updateModel = new WmGoodsNowProduction(); updateModel.Id = model.FkNowProductionId; updateModel.GoodsNumAction = model.GoodsNumLogic - model.GoodsNumAction; if (updateModel.GoodsNumAction <= 0) { updateModel.GoodsNumAction = 0; } Context.Updateable(updateModel).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); return Context.Insertable(model).ExecuteReturnEntity(); } /// /// 修改出库货物记录表 /// /// /// public int UpdateWmGoodsOutProduction(WmGoodsOutRecord model) { //var response = Update(w => w.Id == model.Id, it => new WmGoodsOutProduction() //{ // PackageCode = model.PackageCode, // PackageCodeClient = model.PackageCodeClient, // PackageCodeOriginal = model.PackageCodeOriginal, // LocationCode = model.LocationCode, // Partnumber = model.Partnumber, // GoodsNumLogic = model.GoodsNumLogic, // GoodsNumAction = model.GoodsNumAction, // EntryWarehouseTime = model.EntryWarehouseTime, // OutTime = model.OutTime, // Remark = model.Remark, // UpdatedBy = model.UpdatedBy, // UpdatedTime = model.UpdatedTime, // CreatedBy = model.CreatedBy, // CreatedTime = model.CreatedTime, //}); //return response; return Update(model, true); } } }