You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
10 KiB
C#

2 years ago
using DS.Module.Core;
using DS.Module.Core.Extensions;
2 years ago
using DS.Module.UserModule;
2 years ago
using DS.WMS.Core.WmsModule.Entity;
using DS.WMS.Core.WmsModule.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.WmsModule.Method;
/// <summary>
///
/// </summary>
public class WmsCommonService : IWmsCommonService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="serviceProvider"></param>
public WmsCommonService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
/// <summary>
/// 初始化库存信息
/// </summary>
/// <param name="wmsInDo"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS> InitOpWms(OP_WMS_IN_DO wmsInDo, OP_WMS_IN_DO_GOODS doGoods)
2 years ago
{
var billNo = NumUtil.GetBillNo(db, "WM10");
if (billNo.IsNullOrEmpty())
{
return DataResult<OP_WMS>.Failed("请设置编码规则-库存信息");
}
Guid wmsid = Guid.NewGuid();
var wms = doGoods.Adapt<OP_WMS>();
wms.WMSID = wmsid;
wms.BSNO = billNo;
wms.CORPID = user.GetCompanyId();
wms.CUSTOMERNAME = wmsInDo.CUSTOMERNAME;
wms.ISCLEAR = false;
wms.BSSTATUS = false;
wms.FEESTATUS = false;
wms.INDATE = wmsInDo.DODATE;
wms.FEESTARTDATE = wmsInDo.FEESTARTDATE;
wms.FEERATESTARTDATE = wmsInDo.FEESTARTDATE;
wms.WMSINDATE = wmsInDo.DODATE;
wms.CUSTOMNO = wmsInDo.CUSTOMNO;
wms.BILLTYPE = wmsInDo.BILLTYPE;
wms.GOODSOWNER = wmsInDo.GOODSOWNER;
wms.ARCLIENTWMSOUT = wmsInDo.ARCLIENTWMSOUT;
wms.ClientId = wmsInDo.ClientId;
// wms.setsingle();
2 years ago
wms.WMSBASEID = wms.WMSID;
return DataResult<OP_WMS>.Success(wms);
}
/// <summary>
/// 初始化库存基础信息
/// </summary>
/// <param name="wms"></param>
/// <param name="doGoods"></param>
/// <param name="planGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS_BASE> InitOpWmsBase(OP_WMS wms, OP_WMS_IN_DO_GOODS doGoods,
2 years ago
OP_WMS_IN_PLAN_GOODS planGoods = null)
{
OP_WMS_BASE wmsbase = wms.Adapt<OP_WMS_BASE>();
wmsbase.WMSBASEID = wms.WMSID;
if (planGoods.IsNotNull())
{
planGoods.Adapt(wmsbase);
}
// wmsbase.SEALNO = doGoods.SEALNO_PLAN;
wmsbase.REMARK_GOODS = doGoods.REMARK;
wmsbase.REMARK_BOX = doGoods.REMARK2;
wmsbase.TRUCKNO = doGoods.TRUCKNO;
return DataResult<OP_WMS_BASE>.Success(wmsbase);
}
/// <summary>
/// 初始化物理库存信息
/// </summary>
/// <param name="wms"></param>
/// <param name="wmsInDo"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS_PHYSICS> InitOpWmsPhysics(OP_WMS wms, OP_WMS_IN_DO wmsInDo,
2 years ago
OP_WMS_IN_DO_GOODS doGoods)
{
OP_WMS_PHYSICS physics = doGoods.Adapt<OP_WMS_PHYSICS>();
physics.WMSPHYSICSID = Guid.NewGuid();
physics.WMSID = wms.WMSID;
physics.STARTDATE = wmsInDo.DODATE;
physics.ClientId = wmsInDo.ClientId;
2 years ago
physics.setsingle();
return DataResult<OP_WMS_PHYSICS>.Success(physics);
}
2 years ago
/// <summary>
/// 初始化产生库存变动日志
/// </summary>
/// <param name="wms"></param>
/// <param name="wmsInDo"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS_CHANGE> InitOpWmsChange(OP_WMS wms, OP_WMS_IN_DO wmsInDo, OP_WMS_IN_DO_GOODS doGoods)
2 years ago
{
OP_WMS_CHANGE change = doGoods.Adapt<OP_WMS_CHANGE>();
2 years ago
change.WMSID = wms.WMSID;
change.DODATE = wmsInDo.DODATE;
change.setNew(doGoods);
return DataResult<OP_WMS_CHANGE>.Success(change);
}
2 years ago
/// <summary>
/// 初始化产生物理库存变动日志
/// </summary>
/// <param name="wmsId"></param>
/// <param name="physicsId"></param>
/// <param name="doDate"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS_PHYSICS_CHANGE> InitOpWmsPhysicsChange(Guid wmsId, Guid physicsId, DateTime? doDate,
OP_WMS_IN_DO_GOODS doGoods)
2 years ago
{
OP_WMS_PHYSICS_CHANGE change = doGoods.Adapt<OP_WMS_PHYSICS_CHANGE>();
2 years ago
change.WMSID = wmsId;
change.WMSPHYSICSID = physicsId;
change.DODATE = doDate;
change.setNew(doGoods);
return DataResult<OP_WMS_PHYSICS_CHANGE>.Success(change);
}
/// <summary>
/// 出库确认变更OP_WMS_CHANGE
/// </summary>
/// <param name="wms"></param>
/// <param name="wmsOutDo"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS_CHANGE> OpWmsOutChange(OP_WMS wms, OP_WMS_OUT_DO wmsOutDo, OP_WMS_OUT_DO_GOODS doGoods)
{
OP_WMS_CHANGE change = doGoods.Adapt<OP_WMS_CHANGE>();
change.WMSID = wms.WMSID;
change.DOBSNO = doGoods.WMSDOID.ToString();
change.DOGID = doGoods.WMSDODETAILID;
change.CHANGETYPE = WMSCHANGTYPE.;
change.KGS2 = wms.KGS;
change.NETWEIGHT2 = wms.NETWEIGHT;
change.CBM2 = wms.CBM;
change.PKGS2 = wms.PKGS;
change.SMALLPKGS2 = wms.SMALLPKGS;
change.MINPKGS2 = wms.MINPKGS;
change.STORAGEUNITCOUNT2 = wms.STORAGEUNITCOUNT;
change.RULEUNITCOUNT2 = wms.RULEUNITCOUNT;
change.KGS -= doGoods.KGS;
change.NETWEIGHT -= doGoods.NETWEIGHT;
change.CBM -= doGoods.CBM;
change.PKGS -= doGoods.PKGS;
change.SMALLPKGS -= doGoods.SMALLPKGS;
change.MINPKGS -= doGoods.MINPKGS;
change.STORAGEUNITCOUNT -= doGoods.STORAGEUNITCOUNT;
change.RULEUNITCOUNT -= doGoods.RULEUNITCOUNT;
change.KGS3 = wms.KGS - doGoods.KGS;
change.NETWEIGHT3 = wms.NETWEIGHT - doGoods.NETWEIGHT;
change.CBM3 = wms.CBM - doGoods.CBM;
change.PKGS3 = wms.PKGS - doGoods.PKGS;
change.SMALLPKGS3 = wms.SMALLPKGS - doGoods.SMALLPKGS;
change.MINPKGS3 = wms.MINPKGS - doGoods.MINPKGS;
change.STORAGEUNITCOUNT3 = wms.STORAGEUNITCOUNT - doGoods.STORAGEUNITCOUNT;
change.RULEUNITCOUNT3 = wms.RULEUNITCOUNT - doGoods.RULEUNITCOUNT;
return DataResult<OP_WMS_CHANGE>.Success(change);
}
/// <summary>
/// 出库确认 OP_WMS减库存
/// </summary>
/// <param name="wms"></param>
/// <param name="doGoods"></param>
/// <returns></returns>
public DataResult<OP_WMS> OpWmsOutReduce(OP_WMS wms, OP_WMS_OUT_DO_GOODS doGoods)
{
wms.KGS -= doGoods.KGS;
wms.NETWEIGHT -= doGoods.NETWEIGHT;
wms.CBM -= doGoods.CBM;
wms.PKGS -= doGoods.PKGS;
wms.SMALLPKGS -= doGoods.SMALLPKGS;
wms.MINPKGS -= doGoods.MINPKGS;
wms.STORAGEUNITCOUNT -= doGoods.STORAGEUNITCOUNT;
wms.RULEUNITCOUNT -= doGoods.RULEUNITCOUNT;
return DataResult<OP_WMS>.Success(wms);
}
public DataResult<OP_WMS_PHYSICS_CHANGE> OpWmsPhysicsOutChange(OP_WMS_PHYSICS physics, OP_WMS_OUT_DO wmsOutDo,
OP_WMS_OUT_DO_GOODS doGoods)
{
OP_WMS_PHYSICS_CHANGE change = doGoods.Adapt<OP_WMS_PHYSICS_CHANGE>();
change.WMSID = doGoods.WMSPHYSICSID;
change.WMSPHYSICSID = doGoods.WMSPHYSICSID;
change.DODATE = wmsOutDo.DODATE;
change.WMSPHYSICS_LOGID = new Guid();
change.DOBSNO = doGoods.WMSDOID.ToString();
change.DOGID = doGoods.WMSDODETAILID.ToString();
change.STOREHOUSE2 = physics.STOREHOUSE;
change.STOREHOUSE3 = physics.STOREHOUSE;
change.AREACODE2 = physics.AREACODE;
change.AREACODE3 = physics.AREACODE;
change.CHANGETYPE = WMSCHANGTYPE.;
change.CBM2 = physics.CBM;
change.KGS2 = physics.KGS;
change.PKGS2 = physics.PKGS;
change.SMALLPKGS2 = physics.SMALLPKGS;
change.MINPKGS2 = physics.MINPKGS;
change.STORAGEUNITCOUNT2 = physics.STORAGEUNITCOUNT + physics.LOCKSTORAGEUNITCOUNT;
change.RULEUNITCOUNT2 = physics.RULEUNITCOUNT;
change.NETWEIGHT2 = physics.NETWEIGHT;
change.CBM = -doGoods.CBM;
change.KGS = -doGoods.KGS;
change.PKGS = -doGoods.PKGS;
change.SMALLPKGS = -doGoods.SMALLPKGS;
change.MINPKGS = -doGoods.MINPKGS;
change.STORAGEUNITCOUNT = -doGoods.STORAGEUNITCOUNT;
change.RULEUNITCOUNT = -doGoods.RULEUNITCOUNT;
change.NETWEIGHT = -doGoods.NETWEIGHT;
change.CBM3 = physics.CBM - doGoods.CBM;
change.KGS3 = physics.KGS - doGoods.KGS;
change.PKGS3 = physics.PKGS - doGoods.PKGS;
change.SMALLPKGS3 = physics.SMALLPKGS - doGoods.SMALLPKGS;
change.MINPKGS3 = physics.MINPKGS - doGoods.MINPKGS;
change.STORAGEUNITCOUNT3 = physics.STORAGEUNITCOUNT + physics.LOCKSTORAGEUNITCOUNT - doGoods.STORAGEUNITCOUNT;
change.RULEUNITCOUNT3 = physics.RULEUNITCOUNT - doGoods.RULEUNITCOUNT;
change.NETWEIGHT3 = physics.NETWEIGHT - doGoods.NETWEIGHT;
return DataResult<OP_WMS_PHYSICS_CHANGE>.Success(change);
}
public DataResult<OP_WMS_PHYSICS> OpWmsPhysicsOutReduce(OP_WMS_PHYSICS physics, OP_WMS_OUT_DO_GOODS doGoods)
{
physics.CBM -= doGoods.CBM;
physics.NETWEIGHT -= doGoods.NETWEIGHT;
physics.KGS -= doGoods.KGS;
// physics.LOCKPKGS = - doGoods.PKGS;
physics.LOCKSTORAGEUNITCOUNT -= doGoods.STORAGEUNITCOUNT;
physics.PKGS -= doGoods.PKGS;
physics.SMALLPKGS -= doGoods.SMALLPKGS;
physics.MINPKGS -= doGoods.MINPKGS;
// physics.STORAGEUNITCOUNT = physics.STORAGEUNITCOUNT - doGoods.STORAGEUNITCOUNT;
physics.RULEUNITCOUNT -= doGoods.RULEUNITCOUNT;
return DataResult<OP_WMS_PHYSICS>.Success(physics);
}
2 years ago
}