shgx_tz_mom/ZR.Service/mes/wms/WmGoodsOutProductionService.cs
赵正易 de15bc289a 出库单计划:发运清单
物料清单:发运单
数据对应完成,交由客户测试
2024-03-28 15:37:33 +08:00

117 lines
4.5 KiB
C#

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
{
/// <summary>
/// 出库货物记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsOutProductionService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsOutProductionService : BaseService<WmGoodsOutRecord>, IWmGoodsOutProductionService
{
/// <summary>
/// 查询出库货物记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public (List<WmGoodsOutProductionDto>,int) GetList(WmGoodsOutProductionQueryDto parm)
{
int total = 0;
var predicate = Expressionable.Create<WmGoodsOutRecord>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), wgo => wgo.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.PackageCodeClient), wgo => wgo.PackageCodeClient.Contains(parm.PackageCodeClient))
.AndIF(!string.IsNullOrEmpty(parm.LocationCode), wgo => wgo.LocationCode.Contains(parm.LocationCode))
.AndIF(!string.IsNullOrEmpty(parm.FkOutOrderId), wgo => wgo.FkOutOrderId.Contains(parm.FkOutOrderId))
;
var response = Queryable()
.LeftJoin<WmMaterial>((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);
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WmGoodsOutRecord GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
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();
}
/// <summary>
/// 修改出库货物记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
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);
}
}
}