840 lines
27 KiB
C#
840 lines
27 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;
|
||
using System.Threading;
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
|
||
lWmsOutPickRequest _lop;
|
||
|
||
public lWmsOutPickRequest lop
|
||
{
|
||
get
|
||
{
|
||
if (_lop == null || _lop.operId!=operId)
|
||
{
|
||
// log.Debug(string.Format("_lop is null? {0},lop.operId {1}, operId {2}", _lop == null, lop.operId, operId));
|
||
_lop = new lWmsOutPickRequest(operId);
|
||
|
||
}
|
||
|
||
return _lop;
|
||
}
|
||
}
|
||
|
||
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((enumPlateLevel)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.ToInt32(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.只允许下级容器放入上级容器;
|
||
}
|
||
else if (fromP.getParentPlate(fromPlate).ID > 0)
|
||
{
|
||
return enumRegPlateResult.容器已集货;
|
||
}
|
||
|
||
|
||
|
||
List<WmsOutPickRequest> requests = getWmsPlate.getPlateRequests(fromPlate, true);
|
||
if (requests.Count == 0)
|
||
{
|
||
return enumRegPlateResult.容器空闲无任务;
|
||
}
|
||
|
||
WmsPlatePack wpp = new WmsPlatePack();
|
||
// wpp.getUpPlateId(fromPlate);
|
||
|
||
|
||
wpp.plateId = toPlate;
|
||
wpp.subPlateId = fromPlate;
|
||
|
||
|
||
string custId = "";
|
||
int lineId = 0;
|
||
|
||
toP.volume += fromP.volume;
|
||
toP.load += fromP.load;
|
||
|
||
|
||
if (toP.type == (int)enumPlateLevel.客户集货)
|
||
{
|
||
|
||
|
||
if (new WmsPlatePack(toPlate,fromPlate ).ID > 0)
|
||
{
|
||
return enumRegPlateResult.容器已完成客户集货;
|
||
}
|
||
|
||
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 = Convert.ToInt32(dr1["lineId"].ToString());
|
||
toP.volume += Convert.ToDecimal(dr1["volCm"].ToString());
|
||
toP.load += Convert.ToDecimal(dr1["weight"].ToString());
|
||
// break;
|
||
}
|
||
|
||
break;
|
||
}
|
||
|
||
|
||
if (string.IsNullOrEmpty(toP.customerId) || toP.customerId == custId)
|
||
{
|
||
toP.customerId = custId;
|
||
toP.lineId = lineId;
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
wpp.removeUp();
|
||
wpp.operater = operId;
|
||
wpp.Add();
|
||
fromP.inPlate = toP.plateId;
|
||
fromP.Update();
|
||
toP.Update();
|
||
scope.Complete();
|
||
}
|
||
return enumRegPlateResult.成功;
|
||
}
|
||
else if (toP.customerId != custId)
|
||
{
|
||
return enumRegPlateResult.客户容器已被其他客户占用;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
else
|
||
|
||
if (toP.type == (int)enumPlateLevel.线路集货)
|
||
{
|
||
// log.Debug(string.Format("线路集货 from plate {0}, to plate {1}, to plate line id {2},from plate line id {3}",fromPlate,toPlate,toP.lineId,lineId));
|
||
|
||
|
||
if (!String.IsNullOrEmpty(fromP.inPlate) )
|
||
{
|
||
// return enumRegPlateResult.容器已完成码头集货;
|
||
}
|
||
|
||
if (fromP.type != (int)enumPlateLevel.客户集货)
|
||
{
|
||
// return enumRegPlateResult.码头集货需要客户类型的容器;
|
||
}
|
||
|
||
|
||
// 检测客户是否已经在其它码头集货
|
||
|
||
DataTable dt2 = getWmsPlate.getLineId(fromP.customerId);
|
||
foreach (DataRow dr in dt2.Rows)
|
||
{
|
||
WmsPlate wp = new WmsPlate(dr);
|
||
if (!String.IsNullOrEmpty(wp.inPlate) && wp.inPlate != toP.plateId)
|
||
{
|
||
return enumRegPlateResult.客户已经在其他码头集货;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
if (toP.lineId == 0)
|
||
{
|
||
toP.lineId = fromP.lineId;
|
||
|
||
}
|
||
else if (toP.lineId != (fromP.lineId) && fromP.lineId > 0)
|
||
{
|
||
return enumRegPlateResult.集货区线路不同;
|
||
}
|
||
fromP.inPlate = toP.plateId;
|
||
|
||
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
wpp.removeUp();
|
||
wpp.operater = operId;
|
||
wpp.Add();
|
||
|
||
|
||
|
||
toP.Update();
|
||
|
||
|
||
WmsFlow wmsflow = new WmsFlow();
|
||
wmsflow.operater = operId;
|
||
wmsflow.orderNo = toP.plateId;
|
||
wmsflow.flowNo = fromP.plateId;
|
||
wmsflow.type = (int)EnumFlowTaskType.装车运输;
|
||
wmsflow.typeName = EnumFlowTaskType.装车运输.ToString();
|
||
wmsflow.task = Util.getOrderNo(enumCreateOrderType.pickJobNo, _obj.getNextSeq(enumCreateOrderType.pickJobNo));
|
||
wmsflow.taskCnt = fromP.getSubPlateIds(fromP.plateId).Count;
|
||
wmsflow.Add();
|
||
|
||
foreach(WmsOutPickRequest req in requests)
|
||
{
|
||
req.loadTruckJob = wmsflow.task;
|
||
|
||
req.Update();
|
||
}
|
||
|
||
fromP.pickOrderNo = wmsflow.task;
|
||
|
||
fromP.Update();
|
||
|
||
scope.Complete();
|
||
}
|
||
}
|
||
|
||
else
|
||
|
||
if (toP.type == (int)enumPlateLevel.运输车)
|
||
{
|
||
//容器临时库存转移到车辆,结束拣货单据,更新拣货状态,通知erp
|
||
|
||
//update the pickrequest directly to validation status.
|
||
if (fromP.type != (int)enumPlateLevel.线路集货)
|
||
{
|
||
// return enumRegPlateResult.装车集货需要码头类型的容器;
|
||
}
|
||
|
||
if (!String.IsNullOrEmpty(fromP.inPlate ))
|
||
{
|
||
// return enumRegPlateResult.容器已完成装车集货;
|
||
}
|
||
|
||
|
||
fromP.inPlate = toP.plateId;
|
||
|
||
List<WmsPlate> custPlates = fromP.getSubPlates(fromP.plateId);
|
||
|
||
log.Debug(string.Format(" 装车 {0} ,码头拣货单数量 {1}", fromPlate, requests.Count));
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
if (string.IsNullOrEmpty(toP.transNo))
|
||
{
|
||
toP.transNo = Util.getOrderNo(enumCreateOrderType.transOrder, _obj.getNextSeq(enumCreateOrderType.transOrder));
|
||
toP.Update();
|
||
logPlate.Debug(string.Format("plate {0} start new trans {1}", toPlate, toP.transNo));
|
||
new lTmsTranRequest(operId).createSimpleTran(requests,toP);// req.transNo = toP.transNo;
|
||
}
|
||
|
||
// toP.Update();
|
||
wpp.removeUp();
|
||
wpp.operater = operId;
|
||
wpp.Add();
|
||
|
||
fromP.Update();
|
||
|
||
log.Debug(string.Format(" 集货,自动复核 {0} ,客户拣货单数量 {1}", fromPlate, requests.Count));
|
||
foreach (WmsOutPickRequest req in requests)
|
||
{
|
||
// log.Debug(string.Format(" 集货,开始复核客户拣货单 {0}", req.pickOrderNo));
|
||
|
||
req.state = (int)enumOutStockRequestStatus.集货完成;
|
||
}
|
||
|
||
foreach(WmsPlate plate in custPlates)
|
||
{
|
||
plate.transNo = toPlate;
|
||
plate.Update();
|
||
}
|
||
|
||
scope.Complete();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
// log.Debug(string.Format("to plate custid {0}, to plate lineid {1} ", toP.customerId, toP.lineId ));
|
||
|
||
|
||
|
||
return enumRegPlateResult.成功;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 按客户装车
|
||
/// </summary>
|
||
/// <param name="fromPlate">客户集货的容器号码</param>
|
||
/// <returns></returns>
|
||
public enumRegPlateResult loadTruck(string fromPlate,string toPlate)
|
||
{
|
||
logPlate.Debug("start load truck, fromPlate "+ fromPlate +", toPlate "+ toPlate);
|
||
WmsPlate fromP = new WmsPlate(fromPlate);
|
||
|
||
/*
|
||
if (fromP.type != (int)enumPlateLevel.客户集货)
|
||
{
|
||
return enumRegPlateResult.装车需要客户类型的容器;
|
||
}
|
||
|
||
if (String.IsNullOrEmpty(fromP.inPlate))
|
||
{
|
||
return enumRegPlateResult.完成码头集货后才能装车;
|
||
}
|
||
|
||
if (String.IsNullOrEmpty(fromP.transNo))
|
||
{
|
||
return enumRegPlateResult.完成装车集货后才能装车;
|
||
}
|
||
|
||
if (!fromP.transNo.Trim().ToUpper() .Equals(toPlate.Trim().ToUpper()))
|
||
{
|
||
return enumRegPlateResult.客户货物不属于此车;
|
||
}
|
||
|
||
*/
|
||
|
||
WmsPlate toP = new WmsPlate(toPlate);
|
||
|
||
if (string.IsNullOrEmpty(toP.transNo ))
|
||
{
|
||
return enumRegPlateResult.完成装车集货后才能装车;
|
||
}
|
||
|
||
List<WmsOutPickRequest> requests = getWmsPlate.getPlateRequests(fromPlate, true);
|
||
if (requests.Count == 0)
|
||
{
|
||
return enumRegPlateResult.容器空闲无任务;
|
||
}
|
||
|
||
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
|
||
|
||
|
||
foreach (WmsOutPickRequest req in requests)
|
||
{
|
||
lop.validationRequest(req);
|
||
req.state = (int)enumOutStockRequestStatus.已装车;
|
||
req.Update();
|
||
}
|
||
//to release plates of customer type and line type
|
||
List<WmsPlate> lst = getWmsPlate.getSubPlates(fromPlate);
|
||
foreach (WmsPlate s in lst)
|
||
{
|
||
s.releaseSubPlate(s.plateId); //to release customer and its subs
|
||
// log.Debug(string.Format("on truck load, released plate {0}, type{1}", s.plateId, (enumPlateLevel)s.type));
|
||
}
|
||
getWmsPlate.releaseSubPlate(fromPlate); //to release custType type and its subs
|
||
log.Debug(string.Format("on truck load, released plate {0} ", fromPlate));
|
||
|
||
|
||
|
||
WmsFlow flow = new WmsFlow(fromP.pickOrderNo);
|
||
flow.finishedCnt = flow.taskCnt;
|
||
flow.state = (int)enumFlowTaskStatus.已完成;
|
||
flow.owner = operId;
|
||
flow.toLocationId = toPlate;
|
||
flow.Update();
|
||
|
||
logPlate.Debug("updated task " + fromP.pickOrderNo);
|
||
|
||
scope.Complete();
|
||
|
||
}
|
||
return enumRegPlateResult.成功;
|
||
}
|
||
|
||
internal enumRegPlateResult startTran(string plateId)
|
||
{
|
||
WmsPlate plate = new WmsPlate(plateId);
|
||
|
||
if (plate.type != (int)enumPlateLevel.运输车)
|
||
{
|
||
return enumRegPlateResult.发车需要运输类型的容器;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(plate.transNo))
|
||
{
|
||
return enumRegPlateResult.容器空闲无任务;
|
||
}
|
||
|
||
TmsTranRequest tmsTranRequest = new TmsTranRequest(plate.transNo);
|
||
if (tmsTranRequest.state == (int)enumTranStatus.配送途中)
|
||
{
|
||
return enumRegPlateResult.已发车;
|
||
}
|
||
List<WmsPlate> lst = getWmsPlate.getSubPlates(plateId);
|
||
foreach (WmsPlate s in lst)
|
||
{
|
||
s.releaseSubPlate(s.plateId); //to release line and its subs
|
||
// log.Debug(string.Format("on start tran load, released plate {0}, type{1}", s.plateId, (enumPlateLevel)s.type));
|
||
}
|
||
|
||
Thread threadPreProcess = new Thread(new ParameterizedThreadStart(porcessStock4TransStart));
|
||
threadPreProcess.IsBackground = true;
|
||
threadPreProcess.Start(plate);
|
||
tmsTranRequest.state = (int)enumTranStatus.配送途中;
|
||
tmsTranRequest.Update();
|
||
return enumRegPlateResult.成功;
|
||
}
|
||
|
||
void porcessStock4TransStart(object plate)
|
||
{
|
||
List<WmsOutPickRequest> requests = new lWmsOutPickRequest(operId).getRequestsByTransNo(((WmsPlate)plate).transNo);
|
||
logPlate.Debug("装车后续处理。。。。开始, plateId " + ((WmsPlate)plate).plateId);
|
||
WmsPlateStock_tmp wpt = new WmsPlateStock_tmp();
|
||
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
|
||
|
||
|
||
foreach (WmsOutPickRequest req in requests)
|
||
{
|
||
|
||
req.state = (int)enumOutStockRequestStatus.配送中;
|
||
req.Update();
|
||
|
||
DataTable dt = wpt.getByOrder(req.pickOrderNo);
|
||
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
wpt = new WmsPlateStock_tmp(dr);
|
||
WmsStock stk = new WmsStock(wpt.locationid, wpt.skuId, wpt.goodsId);
|
||
stk.plateCount -= wpt.count;
|
||
stk.updateCountOut();
|
||
}
|
||
|
||
//to realse plate tmp stock.
|
||
|
||
int cnt = wpt.releasePlateByOrder(req.pickOrderNo);
|
||
logPlate.Debug(req.pickOrderNo + " released tmp stock item cnt " + cnt);
|
||
|
||
}
|
||
|
||
getWmsPlate.releaseSubPlate(((WmsPlate)plate).plateId); //to release truck type and its subs
|
||
|
||
log.Debug("装车后续处理。。。。结束");
|
||
|
||
|
||
scope.Complete();
|
||
}
|
||
|
||
}
|
||
|
||
|
||
public enumRegPlateResult mergePlate(string fromPlate, string toPlate)
|
||
{
|
||
// stock out port plate merge
|
||
|
||
|
||
List<WmsOutPickRequest> requests = getWmsPlate.getPlateRequests(fromPlate, true);
|
||
WmsPlate fromP = new WmsPlate(fromPlate);
|
||
WmsPlate toP = new WmsPlate(toPlate);
|
||
if (fromP.plateLevel != toP.plateLevel)
|
||
{
|
||
return enumRegPlateResult.等级别的容器才可以合并;
|
||
}
|
||
if (fromP.getParentPlate(fromPlate).ID > 0
|
||
&& fromP.getParentPlate(fromPlate).ID != toP.getParentPlate(toPlate).ID)
|
||
{
|
||
return enumRegPlateResult.相同上级容器的子容器才可以相互合并;
|
||
}
|
||
|
||
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
|
||
foreach (WmsOutPickRequest wop in requests)
|
||
{
|
||
PlateStk.merge(fromPlate, toPlate, wop.pickOrderNo);
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
scope.Complete();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
return 0;
|
||
}
|
||
|
||
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)
|
||
{
|
||
DataTable dt = getWmsPlate.getPateJobsDt( plateId, showSub );
|
||
logTest.Debug(string.Format("plate {0} ,showSub {1}, all contents size {2}", plateId, showSub, dt.Rows.Count));
|
||
return dt;
|
||
}
|
||
|
||
internal DataTable queryPlate(string flowNo)
|
||
{
|
||
return getWmsPlate.queryPlate(flowNo);
|
||
}
|
||
|
||
internal enumRegPlateResult takeOutPlate(string fromPlate, string plate)
|
||
{
|
||
WmsPlatePack wpp = new WmsPlatePack(fromPlate,plate);
|
||
log.Debug(string.Format("fromPlate {0}, plate {1}", fromPlate, plate));
|
||
if (wpp.ID == 0)
|
||
{
|
||
return enumRegPlateResult.容器非直接包含关系;
|
||
}
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
wpp.Delete();
|
||
|
||
if (wpp.getSubPlates(fromPlate).Rows.Count == 0)
|
||
{
|
||
WmsPlate wmsPlate = new WmsPlate(fromPlate);
|
||
wmsPlate.customerId = "";
|
||
wmsPlate.lineId = 0;
|
||
wmsPlate.Update();
|
||
}
|
||
scope.Complete();
|
||
}
|
||
return enumRegPlateResult.成功;
|
||
|
||
}
|
||
|
||
internal enumOutValidResult plateValidation(int portId,int skuId,string productDate,string validDate,string batch, decimal validationCnt, string validReason)
|
||
{
|
||
WmsPlateStock_tmp wst = new WmsPlateStock_tmp().getModelByOutPort(portId);
|
||
|
||
WmsOutPickPort wpp = new WmsOutPickPort(portId);
|
||
wpp.validationCnt = validationCnt;
|
||
wpp.checkBy = operId;
|
||
wpp.checkTime = wpp.getDateTime();
|
||
wpp.validationReason = validReason;
|
||
|
||
decimal diffCnt = wst.count - validationCnt;
|
||
|
||
WmsOutPickDetail wpd =null;
|
||
|
||
WmsStock stk = null;
|
||
WmsStockRecord wsr = null;
|
||
if (diffCnt != 0)
|
||
{
|
||
wst.count = validationCnt;
|
||
wsr = new WmsStockRecord(wpp.recordId);
|
||
stk = new WmsStock(wpp.locationId, skuId);
|
||
stk.adjustingCnt += diffCnt;
|
||
wpd = new WmsOutPickDetail(wpp.pickDetailId);
|
||
if (wpp.volType == 0)
|
||
{
|
||
wpd.bulkPicked -= diffCnt;
|
||
}
|
||
else
|
||
{
|
||
wpd.bulkPicked -= diffCnt;
|
||
}
|
||
|
||
|
||
}
|
||
using (TransactionScope scope = new TransactionScope())
|
||
{
|
||
wpp.Update();
|
||
if (diffCnt != 0)
|
||
{
|
||
wpd.Update();
|
||
wst.Update();
|
||
if(stk.Update() == 0)
|
||
{ stk.goodsId=wsr.goodsId;
|
||
stk.skuId = skuId;
|
||
stk.batch = batch;
|
||
stk.productDate = productDate;
|
||
stk.validDate = validDate;
|
||
stk.Add();
|
||
}
|
||
}
|
||
scope.Complete();
|
||
}
|
||
|
||
//new lWmsOutPickRequest(operId).validationPickrequests();//对于复核完毕的订单进行回传erp操作
|
||
|
||
|
||
return enumOutValidResult.成功;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|