shgx_tz_mom/ZR.Service/mes/wms/WmGoodsOutProductionService.cs

118 lines
4.5 KiB
C#
Raw Normal View History

2024-03-22 08:54:11 +08:00
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;
2024-03-26 15:21:21 +08:00
using static System.Runtime.InteropServices.JavaScript.JSType;
2024-03-22 08:54:11 +08:00
2024-03-22 09:53:34 +08:00
namespace ZR.Service.mes.wms
2024-03-22 08:54:11 +08:00
{
/// <summary>
/// 出库货物记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)]
2024-03-22 08:54:11 +08:00
public class WmGoodsOutProductionService : BaseService<WmGoodsOutRecord>, IWmGoodsOutProductionService
2024-03-22 08:54:11 +08:00
{
/// <summary>
/// 查询出库货物记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
2024-03-26 15:21:21 +08:00
public (List<WmGoodsOutProductionDto>,int) GetList(WmGoodsOutProductionQueryDto parm)
2024-03-22 08:54:11 +08:00
{
2024-03-26 15:21:21 +08:00
int total = 0;
2024-03-23 14:31:50 +08:00
var predicate = Expressionable.Create<WmGoodsOutRecord>()
.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))
;
2024-03-22 08:54:11 +08:00
var response = Queryable()
2024-03-26 15:21:21 +08:00
.LeftJoin<WmMaterial>((wgo, wml) => wgo.Partnumber == wml.Partnumber)
2024-03-22 08:54:11 +08:00
.Where(predicate.ToExpression())
2024-03-26 15:21:21 +08:00
.Select((wgo, wml) => new WmGoodsOutProductionDto { Description = wml.Description }, true)
.ToPageList(parm.PageNum, parm.PageSize,ref total);
return (response,total);
2024-03-22 08:54:11 +08:00
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
2024-03-22 08:54:11 +08:00
public WmGoodsOutRecord GetInfo(string Id)
2024-03-22 08:54:11 +08:00
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
2024-03-22 08:54:11 +08:00
public WmGoodsOutRecord AddWmGoodsOutProduction(WmGoodsOutRecord model)
2024-03-22 08:54:11 +08:00
{
2024-03-26 15:21:21 +08:00
if(string.IsNullOrEmpty(model.PackageCode))
{
model.PackageCode = "L" + DateTime.Now.ToString("yyMMddHHmmss");
}
if (string.IsNullOrEmpty(model.Id))
{
model.Id= SnowFlakeSingle.Instance.NextId().ToString();//也可以在程序中直接获取ID
}
2024-03-26 15:21:21 +08:00
//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();
2024-03-22 08:54:11 +08:00
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
2024-03-22 08:54:11 +08:00
public int UpdateWmGoodsOutProduction(WmGoodsOutRecord model)
2024-03-22 08:54:11 +08:00
{
//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);
}
}
}