370 lines
10 KiB
C#
370 lines
10 KiB
C#
|
|
/// <summary>
|
|
///LOGIC CLASS FOR TABLE t_WmsPlate
|
|
///By wm with codesmith.
|
|
///on 04/06/2020
|
|
/// </summary>
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DeiNiu.wms.Data.Model;
|
|
using System.Data;
|
|
using System.Transactions;
|
|
using DeiNiu.Utils;
|
|
|
|
namespace DeiNiu.wms.Logical
|
|
{
|
|
[Serializable]
|
|
public class lWmsPlate :lbase
|
|
{
|
|
WmsPlate _obj;
|
|
public lWmsPlate()
|
|
{
|
|
initialize();
|
|
}
|
|
|
|
public WmsPlate getWmsPlate
|
|
{
|
|
get
|
|
{
|
|
if (_obj == null)
|
|
{
|
|
_obj = new WmsPlate();
|
|
|
|
}
|
|
_obj.operater = operId;
|
|
return _obj;
|
|
}
|
|
}
|
|
WmsPlateStock_tmp _plateStk;
|
|
public WmsPlateStock_tmp PlateStk
|
|
{
|
|
get
|
|
{
|
|
if (_plateStk == null)
|
|
{
|
|
_plateStk = new WmsPlateStock_tmp();
|
|
|
|
}
|
|
_plateStk.operater = operId;
|
|
return _plateStk;
|
|
}
|
|
}
|
|
|
|
|
|
public lWmsPlate(int operId)
|
|
: base(operId)
|
|
{
|
|
initialize();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet getAllData()
|
|
{
|
|
return _obj.Query();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet getAllActiveData()
|
|
{
|
|
return _obj.QueryActived();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// get a record by id
|
|
/// </summary>
|
|
public void initialize(int id)
|
|
{
|
|
_obj = id != 0 ? new WmsPlate(id) : new WmsPlate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a record by id 0
|
|
/// </summary>
|
|
public void initialize()
|
|
{
|
|
initialize(0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a record by id
|
|
/// </summary>
|
|
public void initialize(DataRow dr)
|
|
{
|
|
_obj = new WmsPlate(dr);
|
|
}
|
|
|
|
protected override DeiNiu.Data.BaseObject.BaseModel getModel()
|
|
{
|
|
return _obj;
|
|
}
|
|
|
|
//begin cust db operation, query, excute sql etc.
|
|
|
|
internal int add(WmsPlate obj,int count)
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
|
|
obj.Add();
|
|
obj.plateId = Util.getBoxId(obj.type, obj.color, obj.ID);
|
|
obj.Update();
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// put goods into a plate
|
|
/// </summary>
|
|
|
|
public enumRegPlateResult inPlate(string plateId,enumPlateStatus type, string goodsId,string barcode,int skuId,decimal count,string orderNo)
|
|
{
|
|
/*if (valid( plateId, type, goodsId, skuId) == enumRegPlateResult.成功)
|
|
{
|
|
using (TransactionScope scope = new TransactionScope())
|
|
{
|
|
WmsPlate plate = new WmsPlate(plateId);
|
|
plate.type =(int)type;
|
|
WmsPlateStock_tmp pst = new WmsPlateStock_tmp(plateId,skuId);
|
|
if (pst.ID == 0)
|
|
{
|
|
pst.plateId = plateId;
|
|
pst.goodsId = goodsId;
|
|
pst.skuId = skuId;
|
|
pst.count = count;
|
|
pst.operater = operId;
|
|
pst.barcode = barcode;
|
|
pst.Add();
|
|
}
|
|
else
|
|
{
|
|
pst.count += count;
|
|
pst.operater = operId;
|
|
pst.Update();
|
|
}
|
|
|
|
|
|
switch (type)
|
|
{
|
|
// case enumPlateStatus.播种周转:
|
|
// plate.customerId = orderNo;
|
|
// break;
|
|
case enumPlateStatus.存储架上:
|
|
plate.locationId = orderNo;
|
|
break;
|
|
case enumPlateStatus.临时堆放:
|
|
break;
|
|
case enumPlateStatus.入库待上架:
|
|
plate.preInOrderNo = orderNo;
|
|
break;
|
|
case enumPlateStatus.摘果周转:
|
|
plate.pickOrderNo = orderNo;
|
|
break;
|
|
|
|
case enumPlateStatus.运输周转:
|
|
plate.transNo = orderNo;
|
|
break;
|
|
|
|
}
|
|
|
|
plate.operater = operId;
|
|
plate.Update();
|
|
|
|
scope.Complete();
|
|
}
|
|
}*/
|
|
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
|
|
private enumRegPlateResult valid(string plateId, enumPlateStatus type, string goodsId, int skuId)
|
|
{
|
|
|
|
if (enumPlateStatus.入库待上架 == type)
|
|
{
|
|
WmsPlateStock_tmp pst = new WmsPlateStock_tmp();
|
|
DataTable dt = pst.getPlateStockDetail(plateId);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (dr["goodsId"].ToString() == goodsId)//存在goodsid
|
|
{
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
|
|
}
|
|
WmsGoods wg = new WmsGoods(goodsId);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (Convert.ToInt16(dr["goodsType"].ToString()) == wg.goodsType)//存在goods type
|
|
{
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
|
|
}
|
|
|
|
return enumRegPlateResult.容器已被不同库区或类型物品使用;
|
|
|
|
|
|
}
|
|
|
|
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下级容器可并入上级容器
|
|
/// 客户笼车、线路码头 集货验证
|
|
/// </summary>
|
|
/// <param name="fromPlate"></param>
|
|
/// <param name="toPlate"></param>
|
|
/// <returns></returns>
|
|
public enumRegPlateResult putPlateIntoPlate(string fromPlate,string toPlate)
|
|
{
|
|
//
|
|
|
|
WmsPlate toP = new WmsPlate(toPlate);
|
|
WmsPlate fromP = new WmsPlate(fromPlate);
|
|
|
|
if (toP.type <= fromP.type)
|
|
{
|
|
return enumRegPlateResult.只允许下级容器放入上级容器;
|
|
}
|
|
|
|
WmsPlatePack wpp = new WmsPlatePack();
|
|
wpp.plateId = toPlate;
|
|
wpp.subPlateId = fromPlate;
|
|
|
|
|
|
string custId = "";
|
|
string lineId = "0";
|
|
|
|
WmsPlateStock_tmp ptmp = new WmsPlateStock_tmp();
|
|
|
|
DataTable dt = ptmp.getStockLst(fromPlate);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
ptmp = new WmsPlateStock_tmp(dr);
|
|
DataTable dt1 = ptmp.getOutPort(ptmp.outPortId);
|
|
foreach (DataRow dr1 in dt1.Rows)
|
|
{
|
|
custId = dr1["customerId"].ToString();
|
|
lineId = dr1["lineId"].ToString();
|
|
lineId =lineId.Length == 0 ? "0" : lineId;
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
if(toP.type ==(int)enumPlateLevel.客户集货笼车)
|
|
{
|
|
if (string.IsNullOrEmpty(toP.customerId))
|
|
{
|
|
toP.customerId = custId;
|
|
toP.lineId = Convert.ToInt16(lineId);
|
|
|
|
|
|
}
|
|
else if (toP.customerId != custId)
|
|
{
|
|
return enumRegPlateResult.客户笼车已占用;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (toP.type == (int)enumPlateLevel.线路集货码头)
|
|
{
|
|
|
|
if ( toP.lineId==0)
|
|
{
|
|
toP.lineId = Convert.ToInt16(lineId);
|
|
|
|
}
|
|
else if (toP.lineId != Convert.ToInt16(lineId))
|
|
{
|
|
return enumRegPlateResult.集货区线路不同;
|
|
}
|
|
}
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
{
|
|
wpp.Add();
|
|
toP.Update();
|
|
scope.Complete();
|
|
|
|
}
|
|
|
|
return enumRegPlateResult.成功;
|
|
}
|
|
|
|
|
|
public int mergePlate(string fromPlate ,string toPlate)
|
|
{
|
|
return PlateStk.merge(fromPlate, toPlate);
|
|
}
|
|
|
|
public void releasePlateStock(string plateId,decimal count, int inPortId =0,int outPortId =0)
|
|
{
|
|
logPlate.Debug(string.Format("plateId {0},count {1},inPortId {2},outPortId {3}", plateId, count, inPortId, outPortId));
|
|
WmsPlateStock_tmp plateStock = new WmsPlateStock_tmp();
|
|
if(count==0 && inPortId==0 && outPortId == 0)
|
|
{
|
|
int cnt= plateStock.releasePlate(plateId);
|
|
logPlate.Debug(string.Format("release plate {0} ",plateId));
|
|
return;
|
|
}
|
|
|
|
DataTable dt;
|
|
if (inPortId > 0) {
|
|
dt = plateStock.getPlateIn(plateId, inPortId);
|
|
}
|
|
else
|
|
|
|
dt = plateStock.getPlateOut(plateId, outPortId);
|
|
|
|
logPlate.Debug(string.Format(" stk items count {0} ", dt.Rows.Count));
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
WmsPlateStock_tmp tmp = new WmsPlateStock_tmp(dr);
|
|
|
|
tmp.count -= count;
|
|
|
|
if (tmp.count <= 0)
|
|
{
|
|
tmp.Delete();
|
|
logPlate.Debug(string.Format("release stk {0} ", tmp.ID));
|
|
}
|
|
else
|
|
{
|
|
tmp.Update();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public DataTable getPateJobsDt(string plateId, bool showSub = false)
|
|
{
|
|
return getWmsPlate. getPateJobsDt( plateId, showSub );
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|