124 lines
4.8 KiB
C#
124 lines
4.8 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;
|
|
}
|
|
if (updateModel.GoodsNumAction == 0)
|
|
{
|
|
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == updateModel.Id).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
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);
|
|
}
|
|
|
|
}
|
|
} |