2023-05-23 16:13:17 +08:00
/// <summary>
///LOGIC CLASS FOR TABLE t_wmsOutRequest
///By wm with codesmith.
///on 05/18/2017
/// </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 ;
using System.ServiceModel ;
namespace DeiNiu.wms.Logical
{
[Serializable]
2023-09-04 22:41:19 +08:00
public class lWmsOutRequest : lbase
2023-05-23 16:13:17 +08:00
{
WmsOutRequest _obj ;
WmsOutPickRequest _pickRequestObj ;
WmsOutPick _wop ;
WmsOutDetail _wod ;
Erp_sale _esale ;
2023-09-04 22:41:19 +08:00
public lWmsOutRequest ( int operId ) : base ( operId )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
initialize ( ) ;
2023-05-23 16:13:17 +08:00
}
public lWmsOutRequest ( )
{
2023-09-04 22:41:19 +08:00
initialize ( ) ;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public Erp_sale esale
2023-05-23 16:13:17 +08:00
{
get
{
if ( _esale = = null )
{
_esale = new Erp_sale ( ) ;
_esale . operater = operId ;
}
return _esale ;
}
}
2023-09-04 22:41:19 +08:00
public WmsOutPickRequest pickRequestObj
2023-05-23 16:13:17 +08:00
{
get
{
if ( _pickRequestObj = = null )
{
_pickRequestObj = new WmsOutPickRequest ( ) ;
2023-09-04 22:41:19 +08:00
_pickRequestObj . operater = operId ;
2023-05-23 16:13:17 +08:00
}
return _pickRequestObj ;
}
}
2023-09-04 22:41:19 +08:00
public WmsOutRequest outRequest
2023-05-23 16:13:17 +08:00
{
get
{
if ( _obj = = null )
{
_obj = new WmsOutRequest ( ) ;
2023-09-04 22:41:19 +08:00
_obj . operater = operId ;
2023-05-23 16:13:17 +08:00
}
return _obj ;
}
}
public WmsOutDetail outDetail
{
get
{
if ( _wod = = null )
{
_wod = new WmsOutDetail ( ) ;
2023-09-04 22:41:19 +08:00
_wod . operater = operId ;
2023-05-23 16:13:17 +08:00
}
return _wod ;
}
}
public WmsOutPick wop
{
get
{
if ( _wop = = null )
{
_wop = new WmsOutPick ( ) ;
_wop . operater = operId ;
}
return _wop ;
}
}
2023-09-04 22:41:19 +08:00
/// <summary>
/// get all data
/// </summary>
2023-05-23 16:13:17 +08:00
public DataSet getAllData ( )
{
2023-09-04 22:41:19 +08:00
return outRequest . Query ( ) ;
2023-05-23 16:13:17 +08:00
}
/// <summary>
/// get all data
/// </summary>
public DataSet getAllActiveData ( )
{
return outRequest . QueryActived ( ) ;
}
2023-09-04 22:41:19 +08:00
/// <summary>
/// get a record by id
/// </summary>
2023-05-23 16:13:17 +08:00
public void initialize ( int id )
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
_obj = id ! = 0 ? new WmsOutRequest ( id ) : new WmsOutRequest ( ) ;
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
/// <summary>
/// get a record by id 0
/// </summary>
public void initialize ( )
{
initialize ( 0 ) ;
}
2023-09-04 22:41:19 +08:00
/// <summary>
2023-05-23 16:13:17 +08:00
/// get a record by id
/// </summary>
public void initialize ( DataRow dr )
{
_obj = new WmsOutRequest ( dr ) ;
}
protected override DeiNiu . Data . BaseObject . BaseModel getModel ( )
{
return outRequest ;
}
2023-11-21 19:18:23 +08:00
internal DataSet getPickOutDetail ( string queryStr , int rowStart , int rowEnd )
{
return esale . getPickOutDetail ( queryStr , rowStart , rowEnd ) ;
}
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
internal DataSet getPickOutDetailSum ( string queryStr , int rowStart , int rowEnd )
2023-05-23 16:13:17 +08:00
{
2023-11-21 19:18:23 +08:00
return esale . getPickOutDetailSum ( queryStr , rowStart , rowEnd ) ;
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
static bool isSyncing = false ;
/// <summary>
/// get in_stock requests in a transaction scope
/// </summary>
internal void syncOrders ( )
{
logSpec . Debug ( " start sync request....." + isSyncing ) ;
if ( isSyncing )
{
return ;
}
isSyncing = true ;
2023-05-23 16:13:17 +08:00
// DataTable dt = null ;
2023-09-04 22:41:19 +08:00
using ( TransactionScope scope = new TransactionScope ( ) )
{
try
{
// dt = getWmsOutRequest.getNewOrders().Tables[0];
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
enumOutStockRequestStatus wmsStatus = enumOutStockRequestStatus . 待 审 核 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( WmsConstants . AUTO_APPROVE_SALE_ORDER )
{
wmsStatus = enumOutStockRequestStatus . 准 备 分 拣 ;
}
2023-05-23 16:13:17 +08:00
// esale.prepareSaleInTmpData(); //erp_wms 记录 临时数据
2023-09-04 22:41:19 +08:00
//to get available out orders for wms
outRequest . prepareSaleInTmpData ( ) ; // wms 记录 临时数据
// DataTable dt = outRequest.getNewOrders();
2023-05-23 16:13:17 +08:00
2024-10-27 23:47:52 +08:00
fixErpSaleDetailSkuId ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
outRequest . syncOutRequest ( ) ;
DataTable dtLastSync = outRequest . getLastSyncOrders ( ) ; //取本次同步的订单数据
2023-05-23 16:13:17 +08:00
WmsOutRequest wor ;
Erp_sale es = new Erp_sale ( ) ;
foreach ( DataRow dr in dtLastSync . Rows )
{
wor = new WmsOutRequest ( dr ) ;
es = new Erp_sale ( wor . orderNo ) ;
es . updateWhType ( wor . orderNo , ( int ) getWhType ( ( int ) getOutStoreType ( wor . orderType ) ) , wmsStatus ) ; //更新接口数据wms_state
}
if ( dtLastSync . Rows . Count > 0 ) //记录接口数据同步时间戳
2023-09-04 22:41:19 +08:00
{
WmsSyncLog log = new WmsSyncLog ( ) ;
log . lastOrderNo = dtLastSync . Rows [ 0 ] [ "orderNo" ] . ToString ( ) ;
log . lastSyncTime = dtLastSync . Rows [ 0 ] [ "timeFromErp" ] . ToString ( ) ;
log . lastSyncTime = Convert . ToDateTime ( dtLastSync . Rows [ 0 ] [ "timeFromErp" ] ) . ToString ( "yyyy-MM-dd HH:mm:ss.fff" ) ; ;
// LogHelper.debug(this.GetType(), "last sync time is 1 " + dtLastSync.Rows[0]["timeFromErp"].ToString());
// LogHelper.debug(this.GetType(), "last sync time is 2 " + log.lastSyncTime);
log . type = 1 ;
log . AddLog ( ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//根据wms 客户订单分拣类别属性,进行分拣通道分类
outRequest . autoPickPrepare ( ) ;
//自动核准普通客户订单,常规集单出货的客户(连锁分店)订单(非紧急单)单独控制
if ( WmsConstants . AUTO_APPROVE_SALE_ORDER )
{
outRequest . autoApproveOutRequest ( wmsStatus ) ;
// outRequest.deleteBadData(); //TODO: check and find out how bad data in
}
2023-05-23 16:13:17 +08:00
// esale.syncSaleOrdersAfter(wmsStatus);
2023-09-04 22:41:19 +08:00
scope . Complete ( ) ;
// return dt;
}
catch ( Exception e )
{
isSyncing = false ;
scope . Dispose ( ) ;
// return new DataTable() ;
logSpec . Error ( e ) ;
throw new DeiNiu . Utils . DeiNiuException ( e . Message ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
// return dt;
LogHelper . debug ( typeof ( lWmsOutRequest ) , "end sync request....." ) ;
isSyncing = false ;
}
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
internal bool isErpWorking ( )
{
2024-02-06 19:36:47 +08:00
int offset = 6 ;
int hour = DateTime . Now . AddMinutes ( offset ) . Hour ;
int minute = DateTime . Now . AddMinutes ( offset ) . Minute ;
2023-11-21 19:18:23 +08:00
if ( hour = = WmsConstants . ERP_TRANS_DATA_AT_CLOCK )
{
2024-02-06 19:36:47 +08:00
if ( minute < WmsConstants . ERP_TRANS_DATA_SLEEP_MINUES + offset )
2023-11-21 19:18:23 +08:00
{
2024-10-27 23:47:52 +08:00
log . Debug ( string . Format ( " time for erp transfering.... no out process...当前 {0} 点 {1}分 ----持续到 {2}分 " ,
2024-02-06 19:36:47 +08:00
DateTime . Now . Hour , minute - offset , WmsConstants . ERP_TRANS_DATA_SLEEP_MINUES ) ) ;
2023-11-21 19:18:23 +08:00
return true ;
}
}
return false ;
}
2023-05-23 16:13:17 +08:00
/ * *
* erp 没 有 skuid的情况下 , 根 据 batch , expired date , product data 取 skuid
*
* * /
2024-10-27 23:47:52 +08:00
public void fixErpSaleDetailSkuId2 ( )
2023-09-04 22:41:19 +08:00
{
lLot llot = new lLot ( ) ;
DataTable dt = outRequest . getAvErpDetailNoSkuId ( ) ;
Erp_sale_d esd ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( DataRow dr in dt . Rows )
{
esd = new Erp_sale_d ( Convert . ToInt32 ( dr [ "id" ] . ToString ( ) ) ) ;
String prd = Util . getShortDateString ( esd . product_date . Trim ( ) ) ;
String vld = Util . getShortDateString ( esd . save_date . Trim ( ) ) ;
Dictionary < string , string > dicValue = new Dictionary < string , string > ( ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_PRDDATE_ATTNAME , prd ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_EXPIREDATE_ATTNAME , vld ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_BATCH_ATTNAME , esd . batch . Trim ( ) ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_ENTI_ATTNAME , esd . entid ) ;
Dictionary < int , string > skuValue = new Dictionary < int , string > ( ) ;
2024-02-06 19:36:47 +08:00
skuValue = llot . getSKU ( prd , esd . goods_id , esd . batch . Trim ( ) ) ;
2023-09-04 22:41:19 +08:00
foreach ( int i in skuValue . Keys )
{
esd . skuId = i ;
esd . skuCode = skuValue [ i ] ;
break ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( esd . skuId > 0 )
{
esd . Update ( ) ;
}
}
}
2023-05-23 16:13:17 +08:00
2024-10-27 23:47:52 +08:00
public void fixErpSaleDetailSkuId ( )
{
lLot llot = new lLot ( ) ;
DataTable dt = outRequest . getAvErpDetailNoSkuId ( ) ;
Erp_sale_d esd ;
foreach ( DataRow dr in dt . Rows )
{
esd = new Erp_sale_d ( dr ) ;
String prd = Util . getShortDateString ( esd . product_date . Trim ( ) ) ;
String vld = Util . getShortDateString ( esd . save_date . Trim ( ) ) ;
Dictionary < string , string > dicValue = new Dictionary < string , string > ( ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_PRDDATE_ATTNAME , prd ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_EXPIREDATE_ATTNAME , vld ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_BATCH_ATTNAME , esd . batch . Trim ( ) ) ;
dicValue . Add ( WmsConstants . SKU_RESEVRED_ENTI_ATTNAME , esd . entid ) ;
Dictionary < int , string > skuValue = new Dictionary < int , string > ( ) ;
skuValue = llot . getSKU ( prd , esd . goods_id , esd . batch . Trim ( ) ) ;
foreach ( int i in skuValue . Keys )
{
esd . skuId = i ;
esd . skuCode = skuValue [ i ] ;
break ;
}
if ( esd . skuId > 0 )
{
esd . Update ( ) ;
}
}
}
2023-09-04 22:41:19 +08:00
public delegate void UpdateUI ( int step ) ; //声明一个更新主线程的委托
public UpdateUI UpdateUIDelegate ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
public delegate void AccomplishTask ( ) ; //声明一个在完成任务时通知主线程的委托
public AccomplishTask TaskCallBack ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
public static bool isProcessOutOrders = false ;
2023-05-23 16:13:17 +08:00
/// <summary>
/// 出库单生成拣货单,完成出库定位
/// </summary>
/ *
public void preProcessOutOrders ( )
{
if ( isProcessOutOrders )
{
LogHelper . debug ( typeof ( lWmsOutRequest ) , "isProcessOutOrders is true, job running,return... " ) ;
return ;
}
Thread threadPreProcess = new Thread ( preProcessOutOrdersImp ) ;
threadPreProcess . IsBackground = true ;
threadPreProcess . Start ( ) ;
}
* /
2023-09-04 22:41:19 +08:00
void updateOutRequestState ( string pickOrderNo )
{
2023-05-23 16:13:17 +08:00
LogHelper . debug ( typeof ( lWmsOutRequest ) , " try updateOutRequestState " + pickOrderNo ) ;
2023-09-04 22:41:19 +08:00
enumOutStockRequestStatus rstateNew = Utils . enumOutStockRequestStatus . 待 定 位 ;
// enumOutStockRequestStatus rstateOld = enumOutStockRequestStatus.准备分拣;
//LogHelper.debug(typeof(lWmsOutRequest), String.Format("rstateNew: {0}, rstateOld: {1}",rstateNew,rstateOld));
2023-05-23 16:13:17 +08:00
DataTable dt = outRequest . getTemp ( ) ;
LogHelper . debug ( typeof ( lWmsOutRequest ) , String . Format ( "tmp rows cnt: {0} " , dt . Rows . Count ) ) ;
2023-09-04 22:41:19 +08:00
int cnt = outRequest . updateTmpPickState ( pickOrderNo , rstateNew ) ;
2023-05-23 16:13:17 +08:00
LogHelper . debug ( typeof ( lWmsOutRequest ) , String . Format ( "updateTmpPickState rows cnt: {0} " , cnt ) ) ;
esale . updatePickStatus ( pickOrderNo , rstateNew ) ;
2023-09-04 22:41:19 +08:00
//----------------------------------------------------------------------------------------------------------
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
enumOutStockRequestStatus rstate = Utils . enumOutStockRequestStatus . 待 定 位 ;
enumOutStockDetailStatus dstate = enumOutStockDetailStatus . 等 待 分 拣 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
outDetail . updatePickState ( pickOrderNo , dstate ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//--------------------------------------------------------------------------------------------------
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/// <summary>
/// 预处理多个待出库订单
/// 1.检查库存量是否够,不足则订单不能出库
/// 2.检查零库库存量是否够,不够及时补货
/// </summary>
/// <param name="outRequests"></param>
private void preProcessOutOrdersImp ( enumOutStockRequestStatus status )
{
logSpec . Debug ( "开始处理销售订单,订单状态参数为: " + status ) ;
if ( isProcessOutOrders )
{
LogHelper . debug ( typeof ( lWmsOutRequest ) , " 销售订单正在处理中,稍后再试。。。。。。。。。。。。。。" ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return ;
}
else
{
isProcessOutOrders = true ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
try
{
processOutOrders ( status ) ;
isProcessOutOrders = false ;
logSpec . Debug ( "销售订单处理完毕---------------《《" ) ;
}
catch ( Exception er )
{
logSpec . Error ( er ) ;
}
finally
{
isProcessOutOrders = false ;
}
}
public void processOutOrders ( enumOutStockRequestStatus status )
{
if ( WmsConstants . AUTO_APPROVE_SALE_ORDER )
{
//开始同步下一批数据
syncOrders ( ) ;
}
Dictionary < string , decimal > bulkReps = getRepingCnt ( ) ; //取今日未上架完成的补货商品明细
Dictionary < string , decimal > bulkCountRequest = new Dictionary < string , decimal > ( ) ;
Dictionary < string , decimal > bulkRepRequest = new Dictionary < string , decimal > ( ) ;
2024-03-06 20:48:05 +08:00
logTest . Debug ( "start create pick out request------> status :" + status ) ;
2023-05-23 16:13:17 +08:00
// outRequest.preparePick(); // only impact on out detail with skuId.
2023-09-04 22:41:19 +08:00
//根据客户合并出库单,生成拣货单,零货合并成整货的情况下,出整
string lastCust = "" ;
string lastCustAddress = "" ;
string lastCustId = "" ;
string lastSales = "" ;
int lastOrderType = - 1 ;
int lastPriority = - 1 ;
bool isMerge = WmsConstants . OUT_REQUEST_MERGE ;
bool isProcessStock = WmsConstants . OUT_REQUEST_PROCESS_STOCK ;
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
DataTable dt = outRequest . QueryByStateForPick ( status ) ;
int worCnt = 0 ;
2023-05-23 16:13:17 +08:00
// string lastOrder = "";
2023-11-21 19:18:23 +08:00
int maxOutRequestCnt = isMerge ? WmsConstants . PAGER_SIZE : 1 ;
2024-03-06 20:48:05 +08:00
if ( dt . Rows . Count > 0 )
{
logTest . Debug ( " request count to pick " + dt . Rows . Count ) ;
}
2023-09-04 22:41:19 +08:00
int i = 0 ;
2023-05-23 16:13:17 +08:00
DataView dv = dt . DefaultView ;
dv . Sort = " priority,customerId,orderType" ;
outRequest . deleteTmp ( "" ) ;
2023-09-04 22:41:19 +08:00
int randomMark = new Random ( ) . Next ( 1000000 ) ;
2023-05-23 16:13:17 +08:00
for ( int k = 0 ; k < dv . Count ; k + + )
{
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
DataRow dr = dv [ k ] . Row ;
2023-09-04 22:41:19 +08:00
WmsOutRequest wor = new WmsOutRequest ( dr ) ;
2024-02-06 19:36:47 +08:00
/ * if ( ! isMerge )
2023-09-04 22:41:19 +08:00
{
lastOrderType = wor . orderType ;
2023-11-21 19:18:23 +08:00
createPickorder ( ( enumOrderType ) lastOrderType , getOutStoreType ( lastOrderType ) , bulkCountRequest , false , randomMark ) ;
2023-05-23 16:13:17 +08:00
continue ;
2024-02-06 19:36:47 +08:00
} * /
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
2024-02-06 19:36:47 +08:00
2023-05-23 16:13:17 +08:00
if ( string . IsNullOrEmpty ( lastCustId ) )
2023-09-04 22:41:19 +08:00
{
lastCust = wor . customerName ; // pd.customerId;
lastCustAddress = wor . custAddress ;
lastCustId = wor . customerId ;
lastOrderType = wor . orderType ;
lastPriority = wor . priority ;
lastSales = wor . salesperson ;
}
if ( wor . customerId ! = lastCustId )
{
Customer cust = new Customer ( lastCustId ) ;
if ( cust . pickInterval > 0 & &
outRequest . getByCustForPick ( status , lastCustId ) . Rows . Count = = 0 )
{
2024-03-06 20:48:05 +08:00
logTest . Debug ( "cust " + lastCustId + ", no exist out request to pick, to update last outtime. " ) ;
2023-09-04 22:41:19 +08:00
cust . lastOutTime = cust . getDateTime ( ) ;
2024-02-06 19:36:47 +08:00
cust . Update ( ) ;
2023-09-04 22:41:19 +08:00
}
}
//同客户的订单准备合并成分拣单
2024-02-06 19:36:47 +08:00
if ( isMerge & &
2023-09-04 22:41:19 +08:00
lastOrderType = = wor . orderType & & worCnt < maxOutRequestCnt & & lastCustId = = wor . customerId
& & lastCust = = wor . customerName & & lastCustAddress . Equals ( wor . custAddress )
& & lastPriority = = wor . priority & & lastSales = = wor . salesperson )
{
2023-05-23 16:13:17 +08:00
outRequest . insertTmp ( wor . orderNo ) ;
if ( ! isStockLack ( wor ) )
2023-09-04 22:41:19 +08:00
{
worCnt + + ;
}
}
else // new pk
{
2023-11-21 19:18:23 +08:00
createPickorder ( ( enumOrderType ) lastOrderType , getOutStoreType ( lastOrderType ) , bulkCountRequest , false , randomMark ) ;
2023-09-04 22:41:19 +08:00
worCnt = 0 ;
2023-05-23 16:13:17 +08:00
outRequest . insertTmp ( wor . orderNo ) ;
if ( ! isStockLack ( wor ) )
{
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
lastCust = wor . customerName ; // pd.customerId;
lastCustAddress = wor . custAddress ;
lastCustId = wor . customerId ;
lastOrderType = wor . orderType ;
lastPriority = wor . priority ;
lastSales = wor . salesperson ;
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
createPickorder ( ( enumOrderType ) lastOrderType , getOutStoreType ( lastOrderType ) , bulkCountRequest , false , randomMark ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( dv . Count = = 0 | | ! WmsConstants . OUT_STOCK_WHEN_NO_MORE_REQUEST ) // || pickRequestObj.getRequest4StockOut(enumOutStockRequestStatus.待定位).Count>WmsConstants.OUT_PROCESS_ORDERS_CNT)
{
2024-10-27 23:47:52 +08:00
processOutStock ( status ) ;
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
//scope.Complete();
2023-09-04 22:41:19 +08:00
// }
if ( ! isProcessStock )
{
isProcessOutOrders = false ;
return ;
}
isProcessOutOrders = false ;
2024-03-06 20:48:05 +08:00
logTest . Debug ( "end create pick out request---------------------------------------- <<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) ;
2023-09-04 22:41:19 +08:00
}
2024-10-27 23:47:52 +08:00
public void processOutStock ( enumOutStockRequestStatus status )
2023-09-04 22:41:19 +08:00
{
2024-10-27 23:47:52 +08:00
status = status = = enumOutStockRequestStatus . 库 存 不 足 ? status : enumOutStockRequestStatus . 待 定 位 ;
2023-09-04 22:41:19 +08:00
//取生成的所有拣货单, 按pickgroup生成播种单, 对摘果的零货生成补货单
2024-10-27 23:47:52 +08:00
List < WmsOutPickRequest > all = pickRequestObj . getRequest4StockOut ( status /*enumOutStockRequestStatus.待定位*/ ) ;
2023-09-04 22:41:19 +08:00
bool isSeedsCreated = false ;
2024-10-27 23:47:52 +08:00
logTest . Debug ( string . Format ( " 取 {0}状态的的分拣单, 数量 {1} " , status , all . Count ) ) ;
2023-09-04 22:41:19 +08:00
List < WmsOutPickRequest > seedsLst ;
Dictionary < int , List < WmsOutPickRequest > > dicGroup = new Dictionary < int , List < WmsOutPickRequest > > ( ) ;
2024-02-06 19:36:47 +08:00
bool isHour = DateTime . Now . Hour > = WmsConstants . SEEDS_START_HOUR & & DateTime . Now . Hour < = WmsConstants . SEEDS_END_HOUR ;
bool isMinute = DateTime . Now . Minute > = WmsConstants . SEEDS_START_MINUTES & & DateTime . Now . Hour < = WmsConstants . SEEDS_END_MINUTES ;
2024-03-06 20:48:05 +08:00
logTest . Debug ( string . Format ( "系统总拣开始时间{0}:{1},系统总拣结束时间{2}:{3}, 可以总拣? {4}" ,
2024-02-06 19:36:47 +08:00
WmsConstants . SEEDS_START_HOUR , WmsConstants . SEEDS_START_MINUTES , WmsConstants . SEEDS_END_HOUR , WmsConstants . SEEDS_END_MINUTES , isHour & & isMinute ) ) ;
if ( isHour & & isMinute ) //根据系统的集货设置参数,判断当前时间是否可以进行总拣
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickRequest opr in all )
{
if ( opr . pickGroup = = 0 | | ! string . IsNullOrEmpty ( opr . seedsPickNo ) )
{
continue ;
}
2024-02-06 19:36:47 +08:00
/ * Customer cust = new Customer ( opr . customerId ) ; //根据客户的集货时间点判断是不是进行总拣
if ( cust . pickStartOn > 0 )
{
try
{
int hour = Convert . ToInt32 ( new Node ( cust . pickStartOn ) . value . Trim ( ) ) ;
if ( DateTime . Now . Hour < hour )
{
logOut . Debug ( string . Format ( " 分拣单 {0}, customer {1}, 总拣开始时间 {2} ,不取总。 " , opr . pickOrderNo , cust . customerId , hour ) ) ;
continue ;
}
}
catch ( Exception er )
{
}
} * /
2023-09-04 22:41:19 +08:00
if ( ! dicGroup . ContainsKey ( opr . pickGroup ) )
{
dicGroup [ opr . pickGroup ] = new List < WmsOutPickRequest > ( ) ;
}
dicGroup [ opr . pickGroup ] . Add ( opr ) ;
}
2023-05-23 16:13:17 +08:00
2024-03-06 20:48:05 +08:00
// logOut.Debug(" 待定位的分拣单,分组数量 " + dicGroup.Count);
2023-09-04 22:41:19 +08:00
foreach ( int group in dicGroup . Keys )
{
seedsLst = dicGroup [ group ] ;
2024-02-06 19:36:47 +08:00
if ( seedsLst . Count < = 1 ) //1 个 订单 不做总拣
2023-09-04 22:41:19 +08:00
{
continue ;
}
2024-03-06 20:48:05 +08:00
// logOut.Debug(" 分组 " + group);
2023-09-04 22:41:19 +08:00
WmsOutPickRequest seedPickRequest = new WmsOutPickRequest ( ) ;
DataTable dtSeeds = seedPickRequest . getNewSeedDetails ( group ) ;
2024-02-06 19:36:47 +08:00
2024-03-06 20:48:05 +08:00
// logSpec.Debug(string.Format("randomMark:{0} , seeds detail count {1}", group, dtSeeds.Rows.Count));
2023-09-04 22:41:19 +08:00
if ( dtSeeds . Rows . Count > 0 )
{
using ( TransactionScope scope = new TransactionScope ( ) )
{
seedPickRequest . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . seedsPickOrder , seedPickRequest . getNextSeq ( enumCreateOrderType . seedsPickOrder ) ) ;
seedPickRequest . orderType = seedsLst [ 0 ] . orderType ; // (int)enumOutOrderType.销售出库;
seedPickRequest . outStoreType = ( int ) enumOutStoreType . 配 货 汇 总 拣 货 出 库 ;
seedPickRequest . seedsPort = group ;
seedPickRequest . pickGroup = group ;
seedPickRequest . priority = ( int ) enumPickPriority . 优 先 ; // 优先级别
seedPickRequest . state = ( int ) enumOutStockRequestStatus . 待 定 位 ;
2023-11-21 19:18:23 +08:00
seedPickRequest . tranLocationId = new TmsStock ( ) . getSeedsLocation ( ) ;
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
2024-03-06 20:48:05 +08:00
// logOut.Debug(string.Format("生成 播种拣选单 :{0} ", seedPickRequest.pickOrderNo));
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
List < WmsOutPickDetail > lstwpd = new List < WmsOutPickDetail > ( ) ;
2023-09-04 22:41:19 +08:00
foreach ( DataRow dr in dtSeeds . Rows )
{
WmsOutPickDetail pd = new WmsOutPickDetail ( dr ) ;
pd . pickOrderNo = seedPickRequest . pickOrderNo ;
// logSpec.Debug(" pd state is .." + pd.state);
2023-11-21 19:18:23 +08:00
2024-03-06 20:48:05 +08:00
// logTest.Debug( string.Format(" goodsId {4},is seedsout {5}, canSeedOut {0}. isZhitong {1}, isWeightOut {2}, WmsConstants.SEEDS_OUT_NOT_WITH_WEIGHT {3}", pd.goods.canSeedOut, pd.goods.isZhitong, pd.goods.isWeightOut(), WmsConstants.SEEDS_OUT_NOT_WITH_WEIGHT, pd.goods.goodsId, pd.goods.isSeedsOut()));
2024-02-06 19:36:47 +08:00
if ( pd . goods . isSeedsOut ( ) )
{
lstwpd . Add ( pd ) ;
}
else
{
2024-03-06 20:48:05 +08:00
// logSpec.Debug(string.Format("goods id {0} is not seeded ,is weight? {1}",pd.goods.goodsId,pd.goods.isWeightOut()));
2024-02-06 19:36:47 +08:00
}
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
if ( lstwpd . Count > 0 )
2023-09-04 22:41:19 +08:00
{
2024-02-06 19:36:47 +08:00
seedPickRequest . Add ( ) ;
foreach ( WmsOutPickDetail wpd in lstwpd )
{
wpd . Add ( ) ;
}
foreach ( WmsOutPickRequest wp in seedsLst )
{
// wp.seedsPickNo=seedPickRequest.pickOrderNo;
foreach ( WmsOutPickDetail wpd in lstwpd )
{
// if (wp.pickOrderNo.Equals(wpd.pickOrderNo))
{
wp . setSeedsNo ( seedPickRequest . pickOrderNo ) ;
wp . Update ( ) ;
break ;
}
}
}
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
scope . Complete ( ) ;
}
requestOutStock ( seedPickRequest ) ;
isSeedsCreated = true ;
2024-10-27 23:47:52 +08:00
all = pickRequestObj . getRequest4StockOut ( enumOutStockRequestStatus . 待 定 位 ) ;
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
#region 在 分 拣 定 位 时 生 成 补 货 单
/ *
* 在 分 拣 定 位 时 生 成 补 货 单
*
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//比较零库库存
foreach ( string key in bulkCountRequest . Keys )
2023-05-23 16:13:17 +08:00
{
string goodsId , skuId , batch ;
getKeyValueSplit ( out goodsId , out skuId , out batch , key ) ;
decimal inProcessCnt = bulkReps . ContainsKey ( key ) ? bulkReps [ key ] : 0 ; //getRepingCnt(goodsId, batch);//正补货中的数量
2023-11-21 19:18:23 +08:00
WmsGoods goods = new WmsGoods ( goodsId , Convert . ToInt32 ( skuId ) , batch ) ; // ObjectsFactory.getGoods(goodsId, Convert.ToInt32(skuId));//goodsCache[goodsId];//new WmsGoods(goodsId, batch);
2023-05-23 16:13:17 +08:00
decimal cnt = bulkCountRequest [ key ] - goods . stockBulkCountOuting - goods . stockBulkAvCount - inProcessCnt ;
if ( skuId = = "3724" )
LogHelper . debug ( this . GetType ( ) , string . Format ( "key {0},bulkCountRequest {1}, goods.stockBulkCountOuting {2} ,goods.stockBulkAvCount {3}, inProcessCnt {4}"
, key , bulkCountRequest [ key ] , goods . stockBulkCountOuting , goods . stockBulkAvCount , inProcessCnt ) ) ;
if ( goods . stockBatchAvCount > 0 )
if ( cnt > 0 & & goods . canRep ( skuId ) )
{ // 订单按商品,批号,和客户汇总后发现库存零货不足
bulkRepRequest [ key ] = cnt ;
// bulkCountRequest[key] = 0;
if ( skuId = = "3724" )
LogHelper . debug ( typeof ( lWmsOutRequest ) , " createGoodsRepOrder key: " + key + ",count " + cnt ) ;
}
}
//生成补货单
if ( bulkRepRequest . Count > 0 )
{
createGoodsRepOrder ( bulkRepRequest ) ;
}
Dictionary < string , decimal > bulkRepRequestPlus = new Dictionary < string , decimal > ( ) ;
DataTable dtReplst = new WmsGoods ( ) . getRepLst ( ) ;
foreach ( DataRow dr in dtReplst . Rows )
{
WmsOutPickDetail pd = new WmsOutPickDetail ( dr ) ;
string key = pd . goodsId . Trim ( ) + WmsConstants . SPLIT + pd . skuId + WmsConstants . SPLIT + pd . batch ;
WmsGoods goods = new WmsGoods ( pd . goodsId , pd . skuId , pd . batch ) ;
// LogHelper.debug(this.GetType(), string.Format("stockBatchAvCount {0} ", goods.stockBatchAvCount));
if ( goods . stockBatchAvCount > 0 & & goods . canRep ( pd . skuId + "" ) )
{
LogHelper . debug ( this . GetType ( ) , string . Format ( "goods.sumBulkOuting {0} ,goods.stockBulkAvCount{1} " , goods . sumBulkOuting ( pd . skuId + "" ) , goods . stockBulkAvCount ) ) ;
if ( goods . sumBulkOuting ( pd . skuId + "" ) > goods . stockBulkAvCount )
{
if ( ! bulkRepRequest . ContainsKey ( key ) )
{
bulkRepRequestPlus . Add ( key , pd . count ) ;
}
}
}
}
if ( bulkRepRequestPlus . Count > 0 )
{
createGoodsRepOrder ( bulkRepRequestPlus ) ;
bulkRepRequestPlus . Clear ( ) ;
}
2023-09-04 22:41:19 +08:00
* /
#endregion
2024-10-27 23:47:52 +08:00
2023-05-23 16:13:17 +08:00
2024-03-06 20:48:05 +08:00
// logOut.Debug(all.Count + " 个待定位的拣货单 ---------------------------------------------------------- ");
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
DateTime dateTime = DateTime . Now ;
foreach ( WmsOutPickRequest opr in all )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
opr . checkedTime = string . Empty ;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
requestOutStock ( opr ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( opr . state = = ( int ) enumOutStockRequestStatus . 待 定 位 )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
opr . checkedTime = opr . getDateTime ( ) ;
opr . Update ( ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
bool isOverTime = DateTime . Now . CompareTo ( dateTime . AddMinutes ( WmsConstants . OUT_STOCK_PROCESS_MAX_TIME_MINUTE ) ) > 0 ;
//logOut.Debug(" is over time ?" + isOverTime );
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( isOverTime )
{
logOut . Debug ( " is over time ?" + isOverTime ) ;
break ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2024-03-06 20:48:05 +08:00
// logOut.Debug("开始生成补货单...>");
2023-11-21 19:18:23 +08:00
createGoodsRepOrder ( ) ;
2024-03-06 20:48:05 +08:00
// logOut.Debug("补货单生成结束...<");
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
all = pickRequestObj . getRequest4StockOut ( enumOutStockRequestStatus . 等 待 补 货 ) ;
2023-05-23 16:13:17 +08:00
2024-03-06 20:48:05 +08:00
// logTest.Debug(all.Count + " 个等待补货订单 ----------------------------------------------------------------- ");
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickRequest opr in all )
{
2024-03-06 20:48:05 +08:00
logTest . Debug ( "待补货: " + opr . pickOrderNo + " state " + opr . state ) ;
2023-09-04 22:41:19 +08:00
opr . checkedTime = string . Empty ;
requestOutStock ( opr ) ;
if ( opr . state = = ( int ) enumOutStockRequestStatus . 等 待 补 货 )
{
opr . checkedTime = opr . getDateTime ( ) ;
opr . Update ( ) ;
}
bool isOverTime = DateTime . Now . CompareTo ( dateTime . AddMinutes ( WmsConstants . OUT_STOCK_PROCESS_MAX_TIME_MINUTE ) ) > 0 ;
// logOut.Debug(" is over time ?" + isOverTime);
if ( isOverTime )
{
2024-03-06 20:48:05 +08:00
logTest . Debug ( " is over time ?" + isOverTime ) ;
2023-09-04 22:41:19 +08:00
break ;
}
}
2023-11-21 19:18:23 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
bool isStockLack ( WmsOutRequest wor )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
if ( ! WmsConstants . OUT_STOCK_LACK_VALIDATION )
{
return false ;
}
DataTable dtdiff = outRequest . getOverStock ( ) ;
foreach ( DataRow drx in dtdiff . Rows )
{
2024-03-06 20:48:05 +08:00
// LogHelper.WriteLog(typeof(lWmsOutRequest), "goods store lack detected: to insert... ");
2023-09-04 22:41:19 +08:00
WmsStockLack sl = new WmsStockLack ( drx ) ;
sl . getBySaleOrder ( wor . orderNo , sl . goodsId , sl . skuId ) ;
if ( sl . ID = = 0 )
{
sl . orderNo = wor . orderNo ;
sl . Add ( ) ;
}
2024-03-06 20:48:05 +08:00
// LogHelper.WriteLog(typeof(lWmsOutRequest), "goods store lack detected: " + wor.orderNo + ", new id " + sl.ID);
2023-09-04 22:41:19 +08:00
updateDetailStockShortage ( wor , sl . skuId , sl . lackCount ) ;
}
return dtdiff . Rows . Count > 0 ;
}
private void updateDetailStockShortage ( WmsOutRequest wor , int skuId , decimal lackCount )
{
2023-05-23 16:13:17 +08:00
if ( WmsConstants . OUT_STOCK_LACK_HOLD_ORDER )
{
2023-09-04 22:41:19 +08:00
wor . state = ( int ) enumOutStockRequestStatus . 库 存 不 足 ;
wor . operater = this . operId ;
wor . Update ( ) ;
outRequest . updateDetailStockShortage ( wor . orderNo , skuId , lackCount ) ;
2024-03-06 20:48:05 +08:00
// LogHelper.debug(typeof(WmsOutRequest), " begin delete temp 2");
2023-05-23 16:13:17 +08:00
outRequest . deleteTmp ( wor . orderNo ) ;
}
else
{ / * //在 outpickdetail处理
wor . remark + = "缺货:" ;
foreach ( WmsOutDetail wd in wor . outDetails )
{
if ( lackCount < = 0 )
{
return ;
}
if ( wd . skuId = = skuId )
{
if ( wd . count > lackCount )
{
wd . count - = lackCount ;
wd . lackCount = lackCount ;
lackCount = 0 ;
}
else
{
lackCount - = wd . count ;
wd . lackCount = wd . count ;
wd . count = 0 ;
}
wd . bulkCount = wd . count % wd . goods . bigCount ;
wd . batch1Count = wd . count - wd . bulkCount ;
wd . boxcnt = Convert . ToInt32 ( wd . batch1Count / wd . goods . bigCount ) ;
wd . Update ( ) ;
wor . remark + = ";" + wd . skuId + " lack " + wd . lackCount ;
}
} * * /
wor . Update ( ) ;
}
}
private enumOutStoreType getOutStoreType ( int lastOrderType )
{
2023-11-21 19:18:23 +08:00
enumOrderType orderType = ( enumOrderType ) lastOrderType ;
2023-05-23 16:13:17 +08:00
switch ( orderType )
{
2023-11-21 19:18:23 +08:00
case enumOrderType . 销 售 出 库 :
2023-09-04 22:41:19 +08:00
return enumOutStoreType . 拣 货 出 库 ;
2023-11-21 19:18:23 +08:00
case enumOrderType . 退 供 应 商 :
2023-09-04 22:41:19 +08:00
return enumOutStoreType . 返 厂 出 库 ;
2023-11-21 19:18:23 +08:00
case enumOrderType . 仓 间 调 拨 :
2023-05-23 16:13:17 +08:00
return enumOutStoreType . 调 拨 出 库 ;
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
return enumOutStoreType . 拣 货 出 库 ;
}
2023-11-21 19:18:23 +08:00
private void createPickorder ( enumOrderType orderType , enumOutStoreType outStoreType ,
2023-09-04 22:41:19 +08:00
Dictionary < string , decimal > bulkCountRequest , bool isRequestStock = true , int checkNum = 0 )
{
DataTable outCust ;
WmsOutPickRequest pr = null ;
2023-05-23 16:13:17 +08:00
// WmsOutPickDetail pd = null;
2023-09-04 22:41:19 +08:00
List < WmsOutPickDetail > pdCache = new List < WmsOutPickDetail > ( ) ;
// List<WmsOutPickRequest> prCache = new List<WmsOutPickRequest>();
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
// logSpec.Debug(" special is here! ");
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
outCust = outRequest . getNewRequestPickDetails ( ) . Tables [ 0 ] ;
int i = 0 ;
foreach ( DataRow dr1 in outCust . Rows )
{
i + + ;
WmsOutPickDetail pd = new WmsOutPickDetail ( dr1 ) ;
if ( string . IsNullOrEmpty ( pd . goodsId ) )
{
logSpec . Debug ( string . Format ( "goodsId is null exception, customerid is{0} " , pd . customerId ) ) ;
continue ;
}
if ( pr = = null )
{
pr = new WmsOutPickRequest ( dr1 ) ;
pr . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . pickOrder , pr . getNextSeq ( enumCreateOrderType . pickOrder ) ) ;
pr . orderType = ( int ) orderType ;
pr . orderTypeName = orderType . ToString ( ) ;
pr . outStoreType = ( int ) outStoreType ;
pr . bulkCnt = 0 ;
pr . boxCnt = 0 ;
pr . sumPrice = 0 ;
pr . seedsPort = checkNum ; //临时随机记号,标记生成的哪一批
// pr.operater = LoginInfo.UserId;
/ *
pr . customerId = pd . customerId ;
pr . customerName = pd . customerName ;
pr . custAddress = pd . custAddress ;
pr . salesperson = pd . salesperson ;
* /
}
pd . whtype = ( int ) getWhType ( ( int ) outStoreType ) ;
pd . pickOrderNo = pr . pickOrderNo ;
pr . bulkCnt + = pd . bulkCount ; //pick request 总bulk cnt,作为拣选、复合工作量的指标
pr . boxCnt + = pd . boxcnt ;
pr . state = ( int ) enumOutStockRequestStatus . 待 定 位 ;
pr . sumPrice + = pd . count * pd . price ;
/ *
2023-05-23 16:13:17 +08:00
if ( WmsConstants . OUT_REQUEST_PROCESS_STOCK )
2023-09-04 22:41:19 +08:00
{
if ( orderType = = enumOutOrderType . 销 售 出 库 )
if ( pd . bulkCount > 0 & & pd . bulkCount > pd . goods . stockBulkAvCount //pd.getGoodsStockCnt(enumWhLocVol.零库))// pd.goods.stockBulkCount)
{
pd . description = "零库库存不足,等待补货" ;
pr . state = ( int ) enumOutStockRequestStatus . 等 待 补 货 ;
pd . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ;
pr . description = string . Format ( "{0} {1} 零库库存不足,等待补货 " , pd . goods . goodsName , pd . skuId ) ;
logSpec . Debug ( pr . description ) ;
}
} * /
pd . operater = this . operId ;
if ( ! WmsConstants . OUT_REQUEST_PROCESS_STOCK )
{
pd . bulkCount + = pd . batch1Count + pd . batch2Count ;
pd . batch1Count = 0 ;
pd . batch2Count = 0 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pdCache . Add ( pd ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//calculate the total bulk for each goods
if ( pd . bulkCount > 0 )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
string key = pd . goodsId . Trim ( ) + WmsConstants . SPLIT + pd . skuId + WmsConstants . SPLIT + pd . batch ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/ * if ( bulkCountRequest . Keys . Contains ( key ) )
2023-05-23 16:13:17 +08:00
{
bulkCountRequest [ key ] + = pd . bulkCount ;
}
else
{
bulkCountRequest [ key ] = pd . bulkCount ;
}
2023-09-04 22:41:19 +08:00
* /
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( pd . count = = pd . bulkCount ) //batch not exists
{
pd . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
else
{
pd . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//create new pickorder
if ( pr ! = null )
{
pr . orderDate = pr . getDateTime ( ) ;
pr . operater = this . operId ;
try
{
2023-05-23 16:13:17 +08:00
using ( TransactionScope scope1 = new TransactionScope ( ) )
2023-09-04 22:41:19 +08:00
{
pr . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
// int jj = 0;
updateOutRequestState ( pr . pickOrderNo ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickDetail p in pdCache )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( p . batchPickState ! = ( int ) enumOutStockPickStatus . 无 需 分 拣 )
{
pr . batchPickState = ( int ) enumOutStockPickStatus . 待 处 理 ;
}
p . Add ( ) ;
pr . outDetails . Add ( p ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pr . Add ( ) ;
2023-05-23 16:13:17 +08:00
/ *
if ( pr . state ! = ( int ) enumOutStockRequestStatus . 等 待 补 货 )
{
prCache . Add ( pr ) ;
}
* /
2023-11-21 19:18:23 +08:00
// LogHelper.debug(typeof(WmsOutRequest), " begin delete temp 3");
2023-05-23 16:13:17 +08:00
outRequest . deleteTmp ( "" ) ;
2023-09-04 22:41:19 +08:00
DataTable dt = outRequest . getRequestByPickOrder ( pr . pickOrderNo ) ;
decimal fandian = 0 m ;
int delivery = 0 ;
WmsOutRequest wor = new WmsOutRequest ( ) ;
foreach ( DataRow dr in dt . Rows )
{
wor = new WmsOutRequest ( dr ) ;
fandian + = wor . fandian ;
delivery = wor . delivery ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pr . fandian = fandian ;
pr . deliveryType = delivery ;
pr . Update ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
scope1 . Complete ( ) ;
//}
}
}
catch ( Exception er )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
logSpec . Error ( er ) ;
// updateOutRequestState(lastCustId, lastCust, lastCustAddress, "");
logSpec . Error ( "error on creating pickoutrequest " + pr . pickOrderNo ) ;
2023-11-21 19:18:23 +08:00
// logSpec.Error(" begin delete temp 4");
2023-05-23 16:13:17 +08:00
outRequest . deleteTmp ( "" ) ;
2023-09-04 22:41:19 +08:00
return ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pdCache . Clear ( ) ;
2023-11-21 19:18:23 +08:00
// logSpec.Debug("pickrequest created " + pr.pickOrderNo);
2023-09-04 22:41:19 +08:00
if ( isRequestStock )
requestOutStock ( pr . pickOrderNo ) ;
}
}
2023-05-23 16:13:17 +08:00
private enumWhType getWhType ( int outStoreType )
{
enumOutStoreType outType = ( enumOutStoreType ) outStoreType ;
switch ( outType )
{
case enumOutStoreType . 报 废 出 库 :
return enumWhType . 报 废 库 ;
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
case enumOutStoreType . 返 厂 出 库 :
return enumWhType . 返 厂 库 ;
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
default :
return enumWhType . 合 格 库 ;
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
private Dictionary < WmsOutPickRequest , List < WmsOutPickDetail > > handleErrorObjects ( Dictionary < WmsOutPickRequest , List < WmsOutPickDetail > > errorObjects )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( errorObjects . Count = = 0 )
{
return errorObjects ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
List < WmsOutPickRequest > prCache = new List < WmsOutPickRequest > ( ) ;
foreach ( WmsOutPickRequest pr1 in errorObjects . Keys )
{
try
{
using ( TransactionScope scope1 = new TransactionScope ( ) )
{
pr1 . operater = this . operId ;
pr1 . Add ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickDetail pd1 in errorObjects [ pr1 ] )
{
pd1 . operater = this . operId ;
pd1 . Add ( ) ;
}
if ( pr1 . state ! = ( int ) enumOutStockRequestStatus . 等 待 补 货 )
{
prCache . Add ( pr1 ) ;
}
scope1 . Complete ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
}
catch ( Exception er )
{
//continue loop
LogHelper . WriteLog ( typeof ( lWmsOutRequest ) , er ) ;
}
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickRequest pr in prCache )
{
errorObjects . Remove ( pr ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return errorObjects ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
private void getKeyValueSplit ( out string goodsId , out string skuId , out string skuCode , string key )
{
string [ ] tmp = key . Split ( WmsConstants . SPLIT . ToCharArray ( ) ) ;
goodsId = tmp [ 0 ] . ToString ( ) ;
skuId = tmp [ 3 ] . ToString ( ) ; //TODO: 为什么分解成4条?
skuCode = tmp [ 6 ] . ToString ( ) ; //TODO: 为什么分解成4条?
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/// <summary>
/// 批次生成零库补货单(整库出库单)
/// 补货单捡完货出库完成后, 会生成零库入库单,然后开始补货入库流程
/// </summary>
/// <param name="requestRep"></param>
/// <returns></returns>
public bool createGoodsRepOrder ( Dictionary < string , decimal > requestRep )
{
LogHelper . debug ( typeof ( lWmsOutRequest ) , " createGoodsRepOrder start ,detail count: " + requestRep . Count ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( requestRep . Count = = 0 )
{
return false ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsOutPickRequest repRequest = new WmsOutPickRequest ( ) ;
using ( TransactionScope scope = new TransactionScope ( ) )
{
2023-11-21 19:18:23 +08:00
repRequest . orderType = ( int ) enumOrderType . 补 货 出 库 ;
2023-09-04 22:41:19 +08:00
repRequest . outStoreType = ( int ) enumOutStoreType . 补 货 出 库 ;
repRequest . operater = this . operId ;
repRequest . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . repOrderOut , repRequest . getNextSeq ( enumCreateOrderType . repOrderOut ) ) ;
2023-11-21 19:18:23 +08:00
repRequest . orderTypeName = enumOrderType . 补 货 出 库 . ToString ( ) ;
2023-09-04 22:41:19 +08:00
repRequest . orderDate = repRequest . getDateTime ( ) ; // use database default date
repRequest . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
repRequest . state = ( int ) enumOutStockRequestStatus . 待 定 位 ; //(int)enumOutStockRequestStatus.正在分拣;// (int)enumOutStockRequestStatus.等待分拣;
//create request detail
WmsOutPickDetail outd = new WmsOutPickDetail ( ) ;
WmsOutPickDetail cachedObj ;
bool kidborn = false ;
foreach ( string key in requestRep . Keys )
{
string goodsId , skuId , skuCode ;
getKeyValueSplit ( out goodsId , out skuId , out skuCode , key ) ;
// WmsOutPickDetail outd = new WmsOutPickDetail();
2023-11-21 19:18:23 +08:00
cachedObj = new WmsOutPickDetail ( ) ; // ObjectsFactory.getOutDetail(goodsId, Convert.ToInt32(skuId));
2023-09-04 22:41:19 +08:00
WmsGoods goods = new WmsGoods ( goodsId ) ;
2023-11-21 19:18:23 +08:00
DataTable dt = goods . getSkuValues ( goods . lotId , Convert . ToInt32 ( skuId ) , WmsConstants . SKU_RESEVRED_BATCH_ATTNAME ) ;
2023-09-04 22:41:19 +08:00
string batch = "" ;
foreach ( DataRow dr in dt . Rows )
{
batch = dr [ "value" ] . ToString ( ) ;
break ;
}
2023-05-23 16:13:17 +08:00
// Sku sku = new Sku(skuId);
// outd.skuCode = sku.skuCode;
2023-09-04 22:41:19 +08:00
outd . skuCode = skuCode ;
outd . pickOrderNo = repRequest . pickOrderNo ;
// outd.operater = repRequest.operater;
outd . goodsId = goodsId ;
outd . batch = batch ;
2023-11-21 19:18:23 +08:00
outd . skuId = Convert . ToInt32 ( skuId ) ;
2023-09-04 22:41:19 +08:00
outd . productDate = cachedObj . productDate ;
outd . validDate = cachedObj . validDate ;
decimal cnt = requestRep [ key ] ;
2024-10-27 23:47:52 +08:00
goods . getStockInfo ( goods . goodsId , Convert . ToInt32 ( skuId ) ) ;
if ( cnt > goods . stockBatchAvCount )
{
cnt = goods . stockBatchAvCount ;
}
if ( cnt < = 0 )
{
continue ;
}
2023-09-04 22:41:19 +08:00
outd . count = cnt ;
//if (cachedObj.goods.bigCount != 0)
if ( goods . bigCount ! = 0 )
{
int boxcnt = ( int ) Math . Ceiling ( cnt / goods . bigCount ) ;
cnt = boxcnt * goods . bigCount ; //取整箱
outd . count = cnt ;
outd . boxcnt = boxcnt ;
}
outd . batch1Count = cnt ;
outd . whtype = cachedObj . whtype ;
outd . operater = this . operId ;
outd . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
outd . Add ( ) ;
kidborn = true ;
}
if ( kidborn )
{
repRequest . Add ( ) ;
scope . Complete ( ) ;
LogHelper . debug ( typeof ( lWmsOutRequest ) , " start process stock for rep request " + repRequest . pickOrderNo ) ;
return requestOutStock ( repRequest ) ;
}
else
{
scope . Dispose ( ) ;
}
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return true ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
public bool createGoodsRepOrder ( )
{
WmsStockRep stkrep = new WmsStockRep ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
DataTable dt = stkrep . getNewData ( ) ;
if ( dt . Rows . Count = = 0 ) { return false ; }
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsOutPickRequest repRequest = new WmsOutPickRequest ( ) ;
2023-11-21 19:18:23 +08:00
repRequest . orderType = ( int ) enumOrderType . 补 货 出 库 ;
2023-09-04 22:41:19 +08:00
repRequest . outStoreType = ( int ) enumOutStoreType . 补 货 出 库 ;
repRequest . operater = this . operId ;
repRequest . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . repOrderOut , repRequest . getNextSeq ( enumCreateOrderType . repOrderOut ) ) ;
2023-11-21 19:18:23 +08:00
repRequest . orderTypeName = enumOrderType . 补 货 出 库 . ToString ( ) ;
2023-09-04 22:41:19 +08:00
repRequest . orderDate = repRequest . getDateTime ( ) ; // use database default date
repRequest . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
repRequest . state = ( int ) enumOutStockRequestStatus . 待 定 位 ; // (int)enumOutStockRequestStatus.正在分拣;// (int)enumOutStockRequestStatus.等待分拣;
repRequest . priority = ( int ) enumPickPriority . 加 急 ; //高优先级别
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
using ( TransactionScope scope = new TransactionScope ( ) )
{
foreach ( DataRow dr in dt . Rows )
{
stkrep = new WmsStockRep ( dr ) ;
//create request detail
WmsOutPickDetail outd = new WmsOutPickDetail ( ) ;
outd . pickOrderNo = repRequest . pickOrderNo ;
// outd.operater = repRequest.operater;
outd . goodsId = stkrep . goodsId ;
outd . skuId = stkrep . skuId ;
outd . count = stkrep . toRepCnt ;
outd . batch1Count = stkrep . toRepCnt ;
outd . whtype = ( int ) enumWhType . 合 格 库 ;
outd . operater = this . operId ;
outd . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
outd . Add ( ) ;
2024-10-27 23:47:52 +08:00
logSpec . Debug ( string . Format ( "新增补货单{0}, detail id {1}, detail:{2} " , repRequest . pickOrderNo , outd . ID , outd ) ) ;
2023-09-04 22:41:19 +08:00
}
stkrep . repNews ( ) ;
repRequest . Add ( ) ;
scope . Complete ( ) ;
2023-11-21 19:18:23 +08:00
logOut . Debug ( string . Format ( "新增补货单{0}, items count {1} " , repRequest . pickOrderNo , dt . Rows . Count ) ) ;
2023-09-04 22:41:19 +08:00
}
requestOutStock ( repRequest ) ;
return true ;
}
2023-11-21 19:18:23 +08:00
public bool reportBulkLack ( WmsGoods goods , int skuId , string skuCode , decimal count , bool checkOnly = false )
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
if ( count < = 0 )
2023-09-04 22:41:19 +08:00
{
return false ;
}
decimal rpcnt = Math . Ceiling ( count / goods . bigCount ) * goods . bigCount ; ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsStockRep stkrep = new WmsStockRep ( goods . goodsId , skuId ) ;
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( "开始登记补货信息。。goodsId {0}, skuId:{1},skuCode:{2}, 补货数量 {3}" , goods . goodsId , skuId , skuCode , count ) ) ;
2024-10-27 23:47:52 +08:00
logSpec . Debug ( string . Format ( "1 商品补货情汇总--》 toRepCnt {0}, lacCount:{1} ,checkonly {2} " , stkrep . toRepCnt , stkrep . lackCount , checkOnly ) ) ;
2023-11-21 19:18:23 +08:00
if ( ! checkOnly )
{
2024-10-27 23:47:52 +08:00
goods . getStockInfo ( goods . goodsId , skuId ) ;
2023-11-21 19:18:23 +08:00
if ( goods . stockBatch3Count + goods . stockBatch2Count + goods . stockBatch1Count < count )
{
logSpec . Debug ( string . Format ( "整库库存不足,补货单生成失败" ) ) ;
return false ;
}
stkrep . lackCount + = count ; ;
}
else
{
if ( stkrep . toRepCnt > 0 )
{
return false ;
}
}
logSpec . Debug ( string . Format ( " 2 商品补货情汇总--》 toRepCnt {0}, lacCount:{1} " , stkrep . toRepCnt , stkrep . lackCount ) ) ;
2023-09-04 22:41:19 +08:00
/ *
logSpec . Debug ( string . Format ( " 商品补货情汇总--》 累计申请数量{0}, 累计缺货数量:{1},需增加补货数量:{2} " ,
stkrep . repCont + stkrep . toRepCnt , stkrep . lackCount ,
stkrep . lackCount - ( stkrep . repCont + stkrep . toRepCnt ) ) ) ;
* /
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
if ( stkrep . toRepCnt - stkrep . lackCount < count )
{
logSpec . Debug ( string . Format ( "增加补货 {2}, for: stkrep.toRepCnt - stkrep.lackCount {0} < count:{1} " , stkrep . toRepCnt - stkrep . lackCount , count , rpcnt ) ) ;
stkrep . toRepCnt + = rpcnt ;
}
else
{
logSpec . Debug ( string . Format ( "-----------------------------------------------现有补货单可以满足需求,无需创建新补货单 " ) ) ;
}
if ( stkrep . ID > 0 )
{
stkrep . Update ( ) ;
}
else
{
stkrep . Add ( ) ; //TODO: when rep task on shelf, delete the record
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return true ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
public bool createGoodsRepOrder ( string [ ] goodsRep , int fromDetailId = 0 )
{
WmsOutPickRequest repRequest = new WmsOutPickRequest ( ) ;
using ( TransactionScope scope = new TransactionScope ( ) )
{
2023-11-21 19:18:23 +08:00
repRequest . orderType = ( int ) enumOrderType . 补 货 出 库 ;
2023-09-04 22:41:19 +08:00
repRequest . outStoreType = ( int ) enumOutStoreType . 补 货 出 库 ;
repRequest . operater = this . operId ;
repRequest . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . repOrderOut , repRequest . getNextSeq ( enumCreateOrderType . repOrderOut ) ) ;
repRequest . orderTypeName = enumOutStoreType . 补 货 出 库 . ToString ( ) ;
repRequest . orderDate = repRequest . getDateTime ( ) ; // use database default date
repRequest . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
repRequest . state = ( int ) enumOutStockRequestStatus . 待 定 位 ; // (int)enumOutStockRequestStatus.正在分拣;// (int)enumOutStockRequestStatus.等待分拣;
repRequest . priority = ( int ) enumPickPriority . 加 急 ; //高优先级别
//create request detail
WmsOutPickDetail outd = new WmsOutPickDetail ( ) ;
int i = 0 ;
foreach ( string str in goodsRep )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
string [ ] tmp = str . Split ( WmsConstants . SPLIT . ToCharArray ( ) ) ;
string goodsId = tmp [ 0 ] . ToString ( ) ;
string batch = tmp [ 3 ] . ToString ( ) ;
string prdDate = tmp [ 9 ] . ToString ( ) ;
string validDate = tmp [ 12 ] . ToString ( ) ;
decimal repCnt = Convert . ToDecimal ( tmp [ 6 ] . ToString ( ) ) ;
2023-11-21 19:18:23 +08:00
int skuId = Convert . ToInt32 ( tmp [ 15 ] . ToString ( ) ) ;
2023-09-04 22:41:19 +08:00
string skuCode = tmp [ 18 ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsGoods goods = new WmsGoods ( goodsId , skuId , batch ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( goods . stockBatch3Count + goods . stockBatch2Count + goods . stockBatch1Count < repCnt )
{
continue ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
// WmsOutPickDetail outd = new WmsOutPickDetail();
outd . pickOrderNo = repRequest . pickOrderNo ;
// outd.operater = repRequest.operater;
outd . goodsId = goodsId ;
outd . batch = batch ;
outd . skuCode = skuCode ;
outd . skuId = skuId ;
outd . productDate = prdDate ;
outd . validDate = validDate ;
decimal cnt = repCnt ;
if ( cnt < goods . bigCount )
{
cnt = goods . bigCount ;
}
outd . count = cnt ;
outd . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ;
outd . batch1Count = cnt ;
outd . whtype = ( int ) enumWhType . 合 格 库 ;
outd . operater = this . operId ;
outd . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
outd . Add ( ) ;
i + + ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( i > 0 )
{
repRequest . Add ( ) ;
}
else
{
scope . Dispose ( ) ;
return false ;
}
scope . Complete ( ) ;
}
return requestOutStock ( repRequest ) ;
}
/// <summary>
/// 根据补库出库单创建补库手持分拣数据
/// need transacation scope
/// </summary>
/// <param name="outRequest"></param>
private void createRepPortData ( WmsOutPickRequest outRequest )
{
/ *
WmsInRequest repRequest = new WmsInRequest ( ) ;
repRequest . orderType = ( int ) enumInOrderType . repOrderIn ;
// repRequest.operater = LoginInfo.UserId;
repRequest . orderNo = Util . getOrderNo ( enumCreateOrderType . repOrderIn , repRequest . getNextSeq ( ) ) ;
repRequest . orderTypeName = "补零入库单" ;
repRequest . state = ( int ) enumInStockOrderStatus . normal ;
repRequest . orderDate = DateTime . Now . Date . ToString ( ) ; // use database default date
repRequest . operater = this . operId ;
repRequest . Add ( ) ;
* /
DataTable dt = new WmsStockRecord ( ) . getPickStockRecods ( outRequest . pickOrderNo , true ) . Tables [ 0 ] ;
int i = 0 ;
foreach ( DataRow dr in dt . Rows )
{
WmsOutPickPort wpp = new WmsOutPickPort ( ) ;
if (
string . IsNullOrEmpty ( dr [ WmsStockRecord . fields . count . ToString ( ) ] . ToString ( ) )
& & string . IsNullOrEmpty ( dr [ WmsStockRecord . fields . countOuting . ToString ( ) ] . ToString ( ) )
| | string . IsNullOrEmpty ( dr [ WmsStockRecord . fields . locationId . ToString ( ) ] . ToString ( ) ) )
{
continue ;
}
wpp . count = Convert . ToDecimal ( dr [ WmsStockRecord . fields . count . ToString ( ) ] . ToString ( ) )
+ Convert . ToDecimal ( dr [ WmsStockRecord . fields . countOuting . ToString ( ) ] . ToString ( ) ) ;
if ( wpp . count = = 0 )
{
continue ;
}
wpp . locationId = dr [ WmsStockRecord . fields . locationId . ToString ( ) ] . ToString ( ) ;
wpp . pickOrderNo = outRequest . pickOrderNo ;
wpp . recordId = Convert . ToInt32 ( dr [ "id" ] . ToString ( ) ) ;
2023-11-21 19:18:23 +08:00
wpp . volType = wpp . volType = Convert . ToInt32 ( dr [ "volType" ] . ToString ( ) ) ;
2023-09-04 22:41:19 +08:00
wpp . recType = ( int ) enumStockRecordType . 补 零 出 库 ;
wpp . partion = Convert . ToInt32 ( dr [ "partion" ] . ToString ( ) ) ;
wpp . pickDetailId = Convert . ToInt32 ( dr [ "orderDetailId" ] . ToString ( ) ) ;
wpp . Add ( ) ;
i + + ;
}
if ( i > 0 )
{
outRequest . state = ( int ) enumOutStockRequestStatus . 等 待 波 次 ;
outRequest . Update ( ) ;
}
}
/// <summary>
/// 获取(今天)的未上架(未完成的)补货商品明细
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public Dictionary < string , decimal > getRepingCnt ( )
{
Dictionary < string , decimal > ret = new Dictionary < string , decimal > ( ) ;
DataTable dt = pickRequestObj . getRepRequestDetailsLessThan ( enumOutStockPickStatus . 复 核 完 成 ) ; //取未完成零货上架的补库商品明细
List < WmsOutPickDetail > lst = new List < WmsOutPickDetail > ( ) ;
foreach ( DataRow dr in dt . Rows )
{
2023-05-23 16:13:17 +08:00
// lst.Add(new WmsOutPickDetail(dr));
2023-09-04 22:41:19 +08:00
ret [ dr [ "goodsId" ] + WmsConstants . SPLIT + dr [ "skuId" ] ] = Convert . ToDecimal ( dr [ "count" ] . ToString ( ) ) ;
}
return ret ;
}
public decimal getRepingCnt ( string goodsId , string batch )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return 0 m ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/// <summary>
/// 出单一订单
/// </summary>
/// <param name="orderNo"></param>
/// <returns></returns>
public bool requestOutStock ( WmsOutPickRequest requestOrder )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//string testOrder = "PK23082800097562";
2023-11-21 19:18:23 +08:00
// requestOrder = new WmsOutPickRequest(testOrder);
// if( requestOrder.pickOrderNo!= "PK230903059550")
// {
2023-09-04 22:41:19 +08:00
// return false;
2023-11-21 19:18:23 +08:00
// }
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( "开始库存定位 {0}, order type {1}, itemcnt {2}" , requestOrder . pickOrderNo , ( enumOrderType ) requestOrder . orderType , requestOrder . outDetails . Count ) ) ;
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
if ( requestOrder . outDetails . Count = = 0 | | requestOrder . outDetails [ 0 ] . isAllPicked ( requestOrder . pickOrderNo ) )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
if ( requestOrder . outStoreType = = ( int ) enumOutStoreType . 补 货 出 库 )
{
requestOrder . state = ( int ) enumOutStockRequestStatus . 订 单 完 成 ;
}
else
requestOrder . state = ( int ) enumOutStockRequestStatus . 分 拣 完 成 ;
2023-09-04 22:41:19 +08:00
requestOrder . Update ( ) ;
return true ;
}
2023-11-21 19:18:23 +08:00
logSpec . Debug ( "1" ) ;
2023-09-04 22:41:19 +08:00
// printStockIn(orderNo);
requestOrder . operater = this . operId ;
if ( requestOrder . ID = = 0 )
{
// return false;
// throw new DeiNiuException(requestOrder.pickOrderNo + " 不存在");
return false ;
}
if ( requestOrder . state = = ( int ) enumOutStockRequestStatus . 分 拣 完 成 )
{
// return false;
// throw new DeiNiuException(requestOrder.pickOrderNo + " 已经完成分拣");
return false ;
}
else
if ( requestOrder . state = = ( int ) enumOutStockRequestStatus . 正 在 分 拣 )
{
// return false;
// throw new DeiNiuException(requestOrder.pickOrderNo + " 正在分拣");
return false ;
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
// stockOutType = requestOrder.orderType == (int)enumOutStoreType.补货出库 ?
// enumStockRecordType.补零出库 : enumStockRecordType.销售出库;
stockOutType = Util . getStockRecordType ( requestOrder . outStoreType ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
requestOrder . state = ( int ) enumOutStockRequestStatus . 待 定 位 ;
// TransactionOptions option = new TransactionOptions();
// option.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
// using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, option))
// ReadUncommitted 可以在事务期间读取和修改可变数据。
// RepeatableRead 可以在事务期间读取可变数据,但是不可以修改。可以在事务期间添加新数据。
using ( TransactionScope scope = new TransactionScope ( TransactionScopeOption . Required , new TransactionOptions ( )
{
//IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
IsolationLevel = System . Transactions . IsolationLevel . Serializable ,
Timeout = new TimeSpan ( 0 , 10 , 0 )
}
) )
{
bool isNoBatchOut = true ;
decimal sumBulkCunt = 0 m ;
int bulkTypeCnt = 0 ;
int boxcnt = 0 ;
foreach ( WmsOutPickDetail requestDetail in requestOrder . outDetails )
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug("1");
try
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
2024-02-06 19:36:47 +08:00
/ *
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( " detail seedsNo :{4}, pickgroup is: {0}, seedsNo is {1} , pickdetail state is :{2}, goods can seed out: {3} " ,
requestOrder . pickGroup , requestOrder . seedsPickNo , ( enumOutStockDetailStatus ) requestDetail . state , requestDetail . goods . canSeedOut , requestDetail . seedsPickNo
2024-02-06 19:36:47 +08:00
) ) ; * /
2023-05-23 16:13:17 +08:00
2023-12-03 22:13:49 +08:00
if ( ! string . IsNullOrEmpty ( requestDetail . seedsPickNo )
| | requestDetail . state = = ( int ) enumOutStockDetailStatus . 另 单 播 种 )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug("2");
continue ;
}
else
if ( ( enumOutStockDetailStatus ) requestDetail . state > = enumOutStockDetailStatus . 等 待 分 拣 )
{
// logSpec.Debug("3");
// logSpec.Debug(string.Format("{0} , {1}", (enumOutStockDetailStatus)requestDetail.state, (enumOutStockDetailStatus)requestDetail.state >= enumOutStockDetailStatus.等待分拣));
2023-09-04 22:41:19 +08:00
continue ;
}
2023-11-21 19:18:23 +08:00
// else
// if (requestDetail.state >= (int)enumOutStockDetailStatus.等待分拣)
// {
// logSpec.Debug("4");
// continue;
// }
else
if ( requestDetail . state = = ( int ) enumOutStockDetailStatus . 分 拣 异 常 )
{
logOut . Debug ( "异常商品.." + requestDetail ) ;
continue ;
}
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
// logSpec.Debug("5");
if ( requestOrder . pickGroup > 0 & &
! string . IsNullOrEmpty ( requestOrder . seedsPickNo )
& & string . IsNullOrEmpty ( requestDetail . seedsPickNo )
& & requestDetail . state ! = ( int ) enumOutStockDetailStatus . 另 单 播 种
) //剔除播种拣货的明细
{
// logSpec.Debug("6");
if ( requestDetail . goodsId = = "P01971" )
{
logSpec . Debug ( string . Format ( "requestdetail ID {0}, seedsPickNo {1}, goodsId {2}, goods canzhitong {3}, isZhitongFromStore {4}" ,
requestDetail . ID , requestDetail . seedsPickNo , requestDetail . goodsId , requestDetail . goods . canZhitong , requestDetail . goods . isZhitongFromStore
) ) ;
logSpec . Debug ( "P01971 ...shoud be here" ) ;
}
2024-02-06 19:36:47 +08:00
if ( ! requestDetail . goods . canZhitong //非直通商品,参加集中拣货
2023-11-21 19:18:23 +08:00
| | requestDetail . goods . isZhitongFromStore ) //直通商品,但允许在库房有库存的情况下 进行下架分拣
{
if ( requestDetail . goodsId = = "P01971" )
{
logSpec . Debug ( "P01971 ...shoud not be here" ) ;
}
2024-02-06 19:36:47 +08:00
if ( requestDetail . goods . isSeedsOut ( ) ) // 支持取总分拣
2023-11-21 19:18:23 +08:00
{
// logSpec.Debug(string.Format(" old state is {0} set detai state to {1} ", (enumOutStockDetailStatus)requestDetail.state, (int)enumOutStockDetailStatus.另单播种));
requestDetail . seedsPickNo = requestOrder . seedsPickNo ;
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
requestDetail . Update ( ) ;
if ( requestDetail . goodsId = = "P01971" )
{
logSpec . Debug ( "P01971 ...shoud not be here" ) ;
}
continue ;
}
}
}
// logSpec.Debug("3");
requestDetail . operater = this . operId ;
//LogHelper.debug("lWmsOutRequest","requestOutStock begin detail ID: " + requestDetail.ID);
2023-09-04 22:41:19 +08:00
// logSpec.Debug(string.Format("is rep order ?{0},requestOrder.orderType: {1} " , requestOrder.orderType == (int)enumOutOrderType.补货出库, (enumOutOrderType)//requestOrder.orderType
// ));
2023-12-03 22:13:49 +08:00
//蔬菜类总拣后分货时,多下架一部分,分货完毕后,剩余部分自动入库。
2024-02-06 19:36:47 +08:00
/ * if ( requestOrder . outStoreType = = ( int ) enumOutStoreType . 配 货 汇 总 拣 货 出 库
2023-12-03 22:13:49 +08:00
& & requestDetail . goods . isWeightOut ( ) & & ! requestDetail . isWeightScaled )
{
if ( WmsConstants . SEEDS_WEIGHT_OUT_RATE > 0 )
{
requestDetail . count = requestDetail . count * ( 1 + WmsConstants . SEEDS_WEIGHT_OUT_RATE / 100 ) > requestDetail . goods . stockAvCount ? requestDetail . count * ( 1 + WmsConstants . SEEDS_WEIGHT_OUT_RATE / 100 ) : requestDetail . goods . stockAvCount ;
requestDetail . isWeightScaled = true ;
requestDetail . Update ( ) ;
logOut . Debug ( string . Format ( "request detail id {0}, weight seedsout scaled count " , requestDetail . ID ) ) ;
}
}
2024-02-06 19:36:47 +08:00
* /
2023-12-03 22:13:49 +08:00
2023-11-21 19:18:23 +08:00
if (
! WmsConstants . OUT_REQUEST_PROCESS_STOCK
| | goodsOutStock ( requestDetail , requestOrder . orderType = = ( int ) enumOrderType . 补 货 出 库 ) )
{
if ( requestDetail . state = = ( int ) enumOutStockDetailStatus . 另 单 播 种 )
{
requestDetail . Update ( ) ;
continue ;
}
// if (requestOrder.orderType == (int)enumOutOrderType.补货出库)
{
}
if ( requestDetail . state = = ( int ) enumOutStockDetailStatus . 完 成 分 拣 )
{
requestDetail . Update ( ) ;
if ( requestDetail . isAllPicked ( requestDetail . pickOrderNo ) )
{
requestOrder . state = ( int ) enumOutStockRequestStatus . 订 单 完 成 ;
requestOrder . Update ( ) ;
}
continue ;
}
2023-09-04 22:41:19 +08:00
if ( ! WmsConstants . OUT_REQUEST_PROCESS_STOCK )
{
logStockOutErpLocation ( requestDetail ) ;
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 等 待 分 拣 ;
boxcnt + = requestDetail . boxcnt ;
if ( requestDetail . bulkCount > 0 ) //有零货出库,处理整不足出零的情况
{
requestDetail . bulkPickState = ( int ) enumOutStockPickStatus . 已 定 位 ;
if ( requestOrder . bulkPickState ! = ( int ) enumOutStockPickStatus . 已 定 位 )
{
requestOrder . bulkPickState = ( int ) enumOutStockPickStatus . 已 定 位 ;
//requestOrder.Update();
}
bulkTypeCnt + + ;
sumBulkCunt + = requestDetail . bulkCount ;
}
else
{
requestDetail . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
2023-05-23 16:13:17 +08:00
if ( requestDetail . batch1Count + requestDetail . batch2Count = = 0 )
{
requestDetail . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
else
{
requestDetail . batchPickState = ( int ) enumOutStockPickStatus . 已 定 位 ;
}
2023-09-04 22:41:19 +08:00
requestDetail . Update ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
isNoBatchOut = isNoBatchOut & & ( requestDetail . batch1Count + requestDetail . batch2Count = = 0 ) ;
// LogHelper.debug("lWmsOutRequest", "requestOutStock end detail ID succeed: " + requestDetail.ID);
}
else
{
// LogHelper.debug("lWmsOutRequest", "requestOutStock end detail ID faild : " + requestDetail.ID);
2023-11-21 19:18:23 +08:00
logOut . Error ( requestDetail . description ) ;
2023-09-04 22:41:19 +08:00
// LogHelper.WriteLog(typeof(lWmsOutRequest),requestDetail.description);
throw new DeiNiuException ( requestDetail . description ) ;
}
}
catch ( DeiNiuStockBulkCountException bulkEx )
{
2023-05-23 16:13:17 +08:00
//LogHelper.WriteLog(typeof(lWmsOutRequest), bulkEx);
2023-09-04 22:41:19 +08:00
// logSpec.Error(string.Format("pickorder {0} stock bulk exception :{1}", requestOrder.pickOrderNo, bulkEx.Message));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/ *
if ( requestOrder . pickGroup > 0 & & requestOrder . outStoreType = = ( int ) enumOutStoreType . 配 货 汇 总 拣 货 出 库 ) //汇总拣货继续
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ;
requestDetail . description = bulkEx . Message ;
requestDetail . Update ( ) ;
requestOrder . description = requestDetail . goods . goodsName + " 库存不足; " + DateTime . Now ;
continue ;
}
* /
2023-11-21 19:18:23 +08:00
if ( requestDetail . state ! = ( int ) enumOutStockDetailStatus . 库 存 不 足 )
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ; //整库部分继续分拣,零库部分等待补货
}
2023-09-04 22:41:19 +08:00
requestDetail . description = bulkEx . Message ;
if ( requestDetail . batch1Count + requestDetail . batch2Count = = 0 )
{
requestDetail . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
else
{
requestDetail . batchPickState = ( int ) enumOutStockPickStatus . 已 定 位 ;
}
requestDetail . Update ( ) ;
requestOrder . state = ( int ) enumOutStockRequestStatus . 等 待 补 货 ;
requestOrder . Update ( ) ;
continue ;
2023-05-23 16:13:17 +08:00
// return false;
2023-09-04 22:41:19 +08:00
// throw bulkEx;
}
catch ( DeiNiuNoStockException nostkEr )
{
logSpec . Error ( nostkEr ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( requestOrder . pickGroup > 0 & & requestOrder . outStoreType = = ( int ) enumOutStoreType . 配 货 汇 总 拣 货 出 库 ) //汇总拣货继续
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 库 存 不 足 ;
requestDetail . description = nostkEr . Message ;
requestDetail . Update ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
requestOrder . description = requestDetail . goods . goodsName + " 库存不足; " + DateTime . Now ;
continue ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 库 存 不 足 ;
requestDetail . description = nostkEr . Message ;
requestDetail . Update ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( WmsConstants . OUT_STOCK_LACK_HOLD_ORDER )
{
logSpec . Error ( "NO STOCK........整单出库定位回滚。。。。。。。。。。。。。。。。。。。。。。。" ) ;
scope . Dispose ( ) ;
2024-10-27 23:47:52 +08:00
requestOrder . state = ( int ) enumOutStockRequestStatus . 库 存 不 足 ;
// requestOrder.state = (int)enumOutStockRequestStatus.待定位;
requestOrder . Update ( ) ;
2023-09-04 22:41:19 +08:00
return false ;
}
continue ;
}
catch ( DeiNiuException er )
{
2023-11-21 19:18:23 +08:00
logSpec . Error ( er ) ;
requestDetail . state = ( int ) enumOutStockDetailStatus . 分 拣 异 常 ; ;
requestDetail . description = er . Message ;
requestDetail . Update ( ) ;
continue ;
2023-09-04 22:41:19 +08:00
/ *
2023-05-23 16:13:17 +08:00
scope . Dispose ( ) ;
2023-09-04 22:41:19 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 分 拣 异 常 ; ;
requestDetail . description = er . Message ;
requestDetail . Update ( ) ;
requestOrder . description = er . Message ;
requestOrder . state = ( int ) enumOutStockRequestStatus . 订 单 异 常 ;
requestOrder . Update ( ) ;
return false ;
* /
// throw er;
}
catch ( NullReferenceException ne )
{
2023-11-21 19:18:23 +08:00
logSpec . Error ( ne ) ;
2023-09-04 22:41:19 +08:00
throw new DeiNiuException ( "internal error :(-" ) ;
}
catch ( Exception err )
{
logSpec . Error ( err ) ;
throw err ;
// return false;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//如果是补零出库单,入手持捡货表
2023-05-23 16:13:17 +08:00
if ( requestOrder . outStoreType = = ( int ) enumOutStoreType . 补 货 出 库 )
{
createRepPortData ( requestOrder ) ;
}
2023-09-04 22:41:19 +08:00
else
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( requestOrder . state ! = ( int ) enumOutStockRequestStatus . 等 待 补 货 )
{
requestOrder . state = ( int ) enumOutStockRequestStatus . 定 位 完 成 ;
//TODO: update request order status 4 seedspick
esale . updatePickStatus ( requestOrder . pickOrderNo , enumOutStockRequestStatus . 定 位 完 成 ) ;
outRequest . updatePickState ( requestOrder . pickOrderNo , enumOutStockRequestStatus . 定 位 完 成 , enumOutStockRequestStatus . 待 定 位 ) ;
}
2024-10-27 23:47:52 +08:00
if ( WmsConstants . OUT_BULK_SEEDS_PICK_ON & & bulkTypeCnt < WmsConstants . OUT_MAX_SEEDS_GOODSTYPE_CNT
& & sumBulkCunt < WmsConstants . OUT_MAX_SEEDS_BULK_CNT_SUM )
2023-05-23 16:13:17 +08:00
{
requestOrder . seedsLabelId = WmsConstants . SEEDS_LABLEID_MARK_VALUE ; //适合播种的标记
}
2023-11-21 19:18:23 +08:00
/ *
2023-09-04 22:41:19 +08:00
bool isNonePick = true ;
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutPickDetail d in requestOrder . outDetails )
{
isNonePick = isNonePick & & ( d . state > ( int ) enumOutStockDetailStatus . 等 待 分 拣 ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
if ( isNonePick )
{
//订单明细全部取总分拣,本单不需要直接拣选
requestOrder . state = ( int ) enumOutStockRequestStatus . 订 单 异 常 ;
}
2023-11-21 19:18:23 +08:00
* /
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( isNoBatchOut & & sumBulkCunt = = 0
& & ! string . IsNullOrEmpty ( requestOrder . seedsPickNo )
& & requestOrder . pickGroup > 0
& & requestOrder . seedsPort > 0 )
{
bool isAllSeeds = true ;
2023-11-21 19:18:23 +08:00
foreach ( WmsOutPickDetail d in requestOrder . outDetails )
2023-09-04 22:41:19 +08:00
{
if ( string . IsNullOrEmpty ( d . seedsPickNo ) )
{
2023-11-21 19:18:23 +08:00
isAllSeeds = false ;
2023-09-04 22:41:19 +08:00
}
}
if ( isAllSeeds )
{
//订单明细全部取总分拣,本单不需要直接拣选
2023-11-21 19:18:23 +08:00
requestOrder . state = ( int ) enumOutStockRequestStatus . 正 在 分 拣 ;
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
}
else
{
if ( isNoBatchOut )
{
requestOrder . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
if ( sumBulkCunt = = 0 )
{
requestOrder . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
requestOrder . bulkCnt = sumBulkCunt ;
requestOrder . boxCnt = boxcnt ;
}
requestOrder . Update ( ) ;
}
catch ( Exception e )
{
logSpec . Error ( e ) ;
scope . Dispose ( ) ;
return false ;
//throw e;
}
scope . Complete ( ) ;
}
// LogHelper.debug("lWmsOutRequest", "requestOutStock end : " + requestOrder.pickOrderNo);
return true ;
}
public bool requestOutStock ( string orderNo )
{
return requestOutStock ( new WmsOutPickRequest ( orderNo ) ) ;
}
2023-05-23 16:13:17 +08:00
private bool goodsOutStock ( WmsOutPickDetail requestDetail , bool isRep = false )
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug(" ");
// logSpec.Debug(string.Format("开始处理出库定位。。。 isRep {1}, requestDetail.state : {0}", (enumOutStockDetailStatus)requestDetail.state,isRep));
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
// if (isRep)
2023-05-23 16:13:17 +08:00
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug("补货单 定位..... requestDetail.state " + (enumOutStockDetailStatus)requestDetail.state);
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2024-02-06 19:36:47 +08:00
2023-12-03 22:13:49 +08:00
2023-05-23 16:13:17 +08:00
WmsGoods goods = new WmsGoods ( requestDetail . goodsId , requestDetail . skuId , requestDetail . batch ) ;
2024-02-06 19:36:47 +08:00
// if (goods.goodsId!= "P01381")
{
//return false;
}
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( "开始处理出库定位。。。。out request {0} ,detailId {4}, detail status {5}, goodsId : {1},requestDetail.count :{2}, stock av count :{3} " ,
requestDetail . pickOrderNo , requestDetail . goodsId , requestDetail . count , goods . stockAvCount , requestDetail . ID , requestDetail . state ) ) ;
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
if ( goods . bigCount = = 0 )
{
// requestDetail.lackCount = requestDetail.count;
// requestDetail.count=0;
2023-11-21 19:18:23 +08:00
requestDetail . description = string . Format ( "detailId {2}: {0},{1},非法商品,不存在大包装等基础信息" , goods . goodsName , goods . goodsId , requestDetail . ID ) ;
2023-05-23 16:13:17 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 分 拣 异 常 ;
2023-09-04 22:41:19 +08:00
requestDetail . Update ( ) ;
2023-05-23 16:13:17 +08:00
// throw new DeiNiuException(requestDetail.description);
2023-09-04 22:41:19 +08:00
return false ;
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
if ( goods . canZhitong )
2023-05-23 16:13:17 +08:00
{
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( " 直通商品, isZhitongFromStore {0},goods.stockAvCount {1} " , goods . isZhitongFromStore , goods . stockAvCount ) ) ;
//---检测库存,有库存则从库存出,无库存则等待直通播种
if ( ! goods . isZhitongFromStore | | goods . stockAvCount < = 0 )
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
logSpec . Debug ( "直通商品 ,不处理定位 或 无库存" ) ;
return true ;
}
/ *
if ( goods . isZhitongFromStore )
{
if ( goods . stockAvCount > 0 )
{
}
else
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
logSpec . Debug ( "直通商品 ,不处理定位 或 无库存" ) ;
return true ;
}
}
else
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
logSpec . Debug ( "直通商品 ,不处理定位 或 无库存" ) ;
return true ;
} * /
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
decimal batch2bulk = 0 m ;
decimal bulkCnt = requestDetail . bulkCount ;
decimal batch1Cnt = requestDetail . batch1Count ;
decimal batch2Cnt = requestDetail . batch2Count ;
if ( requestDetail . state = = ( int ) enumOutStockDetailStatus . 等 待 补 货 ) //整库已定位并生成拣货任务( TODO: 是否开始分拣未定?)
{
2023-11-21 19:18:23 +08:00
logSpec . Debug ( "订单明细等待补货。。。。" ) ;
2023-09-04 22:41:19 +08:00
// bulkCnt = reductStockCnt(goods, bulkCnt, enumWhLocVol.零库, requestDetail);// 出零货
2023-11-21 19:18:23 +08:00
if (
goods . stockAvCount < requestDetail . count //由缺零到缺货
& & goods . stockSumCountOuting = = 0 //无补货占用
)
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
if ( goods . isZhitong )
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
return true ;
}
requestDetail . state = ( int ) enumOutStockDetailStatus . 库 存 不 足 ;
throw new DeiNiuStockBulkCountException ( ) ; ; //等待下次重新定位
} else
2023-09-04 22:41:19 +08:00
2024-10-27 23:47:52 +08:00
if ( bulkCnt > goods . stockBulkAvCount & & WmsConstants . OUT_BULK_REP_FROM_BATCH ) //零库不足,需要补零库; 整库零出的零不够需补货的情况应该不存在
2023-09-04 22:41:19 +08:00
{
// bulkCnt = Math.Ceiling(bulkCnt / goods.bigCount) * goods.bigCount;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
string msg = string . Format ( "goods sku {0},required bulkcount {1},stock bulk cnt {2} " , goods . goodsName , bulkCnt , goods . stockBulkAvCount ) ;
//logSpec.Debug(msg);
2023-11-21 19:18:23 +08:00
logSpec . Debug ( msg ) ;
/ *
2023-09-04 22:41:19 +08:00
WmsStockRep wmsStockRep = new WmsStockRep ( goods . goodsId , requestDetail . skuId ) ;
if ( wmsStockRep . toRepCnt - wmsStockRep . lackCount < bulkCnt )
{
this . reportBulkLack ( goods , requestDetail . skuId , requestDetail . skuCode , bulkCnt ) ;
2023-11-21 19:18:23 +08:00
} * /
reportBulkLack ( goods , requestDetail . skuId , requestDetail . skuCode , bulkCnt , true ) ;
2023-09-04 22:41:19 +08:00
throw new DeiNiuStockBulkCountException ( msg ) ;
}
}
//else
{
decimal countOuting = WmsConstants . OUT_STOCK_DEDUCT ? goods . stockSumCountOuting : 0 ;
2024-10-27 23:47:52 +08:00
if ( ! isRep ) //非补货单
2023-09-04 22:41:19 +08:00
{
if ( goods . bigCount = = 1 )
{
if ( requestDetail . count < goods . stockBulkAvCount )
{
requestDetail . bulkCount = requestDetail . count ;
}
else
{
requestDetail . bulkCount = goods . stockBulkAvCount ;
}
}
else
{
requestDetail . bulkCount = requestDetail . count % goods . bigCount ;
}
// requestDetail.bulkCount = requestDetail.count % goods.bigCount;
requestDetail . batch1Count = requestDetail . count - requestDetail . bulkCount ;
//根据库存情况,调整出货的类型,减少出库任务碎小的问题,比如整库不足,出零库,会有先出整库时实际从零库出而产生一笔零库出库任务,可能会有多个出零库记录。
decimal b2cnt = requestDetail . batch2Count - ( goods . stockBatch2Count - goods . stockBatch2CountOuting ) ;
if ( b2cnt > 0 )
{
requestDetail . batch2Count = goods . stockBatch2Count - goods . stockBatch2CountOuting ;
requestDetail . batch1Count + = b2cnt ;
}
decimal b1cnt = requestDetail . batch1Count - ( goods . stockBatch1Count - goods . stockBatch1CountOuting ) ;
if ( ! isRep & & b1cnt > 0 )
{
if ( goods . stockBatch2Count - goods . stockBatch2CountOuting - requestDetail . batch2Count > b1cnt ) //batch2 足够
{
requestDetail . batch2Count + = b1cnt ;
requestDetail . batch1Count = goods . stockBatch1Count - goods . stockBatch1CountOuting ;
}
else
{
requestDetail . batch2Count = goods . stockBatch2Count - goods . stockBatch2CountOuting ;
requestDetail . batch1Count = ( goods . stockBatch1Count - goods . stockBatch1CountOuting ) ;
}
}
requestDetail . bulkCount = requestDetail . count - requestDetail . batch1Count - requestDetail . batch2Count ;
2024-10-27 23:47:52 +08:00
// if (requestDetail.goods.stockBatchAvCount == 0)
if ( requestDetail . goods . stockBatchAvCount < = 0 )
{
requestDetail . bulkCount = requestDetail . count ;
requestDetail . batch1Count = 0 ;
requestDetail . batch2Count = 0 ;
}
else if ( ! WmsConstants . OUT_BULK_REP_FROM_BATCH )
2024-04-12 09:43:41 +08:00
{
2024-02-06 19:36:47 +08:00
2024-10-27 23:47:52 +08:00
log . Error ( " 有整库库存!!!!!!!!!!!!!???????: " + requestDetail . goods ) ;
//没有整库 辣得叫
requestDetail . bulkCount = requestDetail . count ;
requestDetail . batch1Count = 0 ;
requestDetail . batch2Count = 0 ;
}
2024-02-06 19:36:47 +08:00
}
2024-10-27 23:47:52 +08:00
else //补货单
2024-02-06 19:36:47 +08:00
{
2024-04-12 09:43:41 +08:00
2024-10-27 23:47:52 +08:00
if ( goods . stockBatchAvCount < requestDetail . count )
{
if ( goods . stockBatchAvCount > 0 )
{
decimal diff = requestDetail . count - goods . stockBatchAvCount ;
WmsStockRep stk = new WmsStockRep ( requestDetail . goodsId , requestDetail . skuId ) ;
if ( stk . ID > 0 )
{
stk . toRepCnt - = diff ;
stk . Update ( ) ;
}
requestDetail . description = "应补" + requestDetail . count + ",实际补 " + ( goods . stockBatchAvCount ) ;
requestDetail . batch1Count = requestDetail . count = goods . stockBatchAvCount ;
requestDetail . Update ( ) ;
}
else
{
requestDetail . state = ( int ) enumOutStockDetailStatus . 库 存 不 足 ;
throw new DeiNiuStockBulkCountException ( ) ; ; //等待下次重新定位
}
}
2024-04-12 09:43:41 +08:00
2024-10-27 23:47:52 +08:00
requestDetail . batch1Count = requestDetail . count ;
requestDetail . bulkCount = requestDetail . batch2Count = 0 ;
2024-02-06 19:36:47 +08:00
}
2023-09-04 22:41:19 +08:00
bulkCnt = requestDetail . bulkCount ;
batch1Cnt = requestDetail . batch1Count ;
batch2Cnt = requestDetail . batch2Count ;
// decimal batch3Cnt = requestDetail.bat;
2024-10-27 23:47:52 +08:00
logSpec . Debug ( string . Format ( "detail id {6},goodsid:{3},skuId:{4},skuCode:{5}, 出库需求明细: bulkCnt: {0} , batch1Cnt: {1} , batch2Cnt: {2} " ,
bulkCnt , batch1Cnt , batch2Cnt , goods . goodsId , requestDetail . skuId , requestDetail . skuCode , requestDetail . ID ) ) ;
2023-09-04 22:41:19 +08:00
2024-04-12 09:43:41 +08:00
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
if ( goods . stockAvCount < requestDetail . count // 库存不足
2024-04-12 09:43:41 +08:00
// && !goods.isZhitong
2023-11-21 19:18:23 +08:00
)
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format("goods stockSumCount: {0},goods countOuting :{1}, required count:{2}", goods.stockSumCount, countOuting, requestDetail.count));
2024-10-27 23:47:52 +08:00
string msg = string . Format ( "库存不足: 可用总库存:{0}, 需求库存{1}" , goods . stockAvCount , requestDetail . count ) ;
logSpec . Debug ( msg ) ;
requestDetail . description = msg ;
requestDetail . Update ( ) ;
2023-09-04 22:41:19 +08:00
if ( isRep )
{
}
else
{
2024-02-06 19:36:47 +08:00
goods = new WmsGoods ( requestDetail . goodsId , requestDetail . skuId , requestDetail . batch ) ;
2024-10-27 23:47:52 +08:00
logSpec . Debug ( string . Format ( "库存不足时,全订单暂停出库 ? {0}" , WmsConstants . OUT_STOCK_LACK_HOLD_ORDER ) ) ;
2023-09-04 22:41:19 +08:00
if ( ! WmsConstants . OUT_STOCK_LACK_HOLD_ORDER )
{
2024-02-06 19:36:47 +08:00
/ * WmsStockLack sl = new WmsStockLack ( ) ;
2023-09-04 22:41:19 +08:00
sl . getByPickOrder ( requestDetail . pickOrderNo , requestDetail . goodsId , requestDetail . skuId ) ;
if ( sl . ID = = 0 )
{
sl . whType = requestDetail . whtype ;
sl . goodsId = goods . goodsId ;
sl . pickOrderNo = requestDetail . pickOrderNo ;
sl . productDate = requestDetail . productDate ;
sl . validDate = requestDetail . validDate ;
sl . skuCode = requestDetail . skuCode ;
sl . skuId = requestDetail . skuId ;
sl . lackCount = requestDetail . count - ( goods . stockSumCount - countOuting ) ;
sl . type = 1 ;
sl . Add ( ) ;
2024-02-06 19:36:47 +08:00
} * /
2023-09-04 22:41:19 +08:00
if ( WmsConstants . OUT_STOCK_LACK_VIR_OUT ) // 库存不足则从虚拟库借出
2024-02-06 19:36:47 +08:00
{
decimal tmpCount = requestDetail . count ;
decimal avCnt = goods . stockAvCount > goods . minOperateCount ? goods . stockAvCount : 0 ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
requestDetail . lackCount = requestDetail . count - avCnt ;
if ( ! WmsConstants . OUT_STOCK_LACK_VIR_OUT_AUTO )
{
requestDetail . lackCount = requestDetail . lackCount > 0 ? requestDetail . lackCount : 0 ;
requestDetail . count = avCnt ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
requestDetail . boxcnt = ( int ) ( requestDetail . count / goods . bigCount ) ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
requestDetail . bulkCount = requestDetail . count % goods . bigCount ;
requestDetail . batch1Count = requestDetail . count - requestDetail . bulkCount ;
requestDetail . batch2Count = 0 ;
bulkCnt = requestDetail . bulkCount ;
batch1Cnt = requestDetail . batch1Count ;
batch2Cnt = requestDetail . batch2Count ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 等 待 分 拣 ;
// requestDetail.count += requestDetail.lackCount;
requestDetail . count = tmpCount ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
}
2023-09-04 22:41:19 +08:00
requestDetail . Update ( ) ;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
decimal lackCnt = requestDetail . lackCount ;
2024-04-12 09:43:41 +08:00
logSpec . Debug ( " 1 库存不足,出虚拟库......数量 " + lackCnt ) ;
if ( ! goods . isWeightOut ( ) & & lackCnt % goods . minOperateCount > 0 ) //借货取整件
{
logSpec . Debug ( "库存 有非整件数量, 余数 " + lackCnt % goods . minOperateCount ) ;
lackCnt = ( ( int ) ( lackCnt / goods . minOperateCount ) ) * goods . minOperateCount + goods . minOperateCount ;
logSpec . Debug ( "2 库存不足,出虚拟库......数量 " + lackCnt ) ;
}
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
WmsLocation loc = new WmsLocation ( ) ;
loc = loc . getVirLocations ( requestDetail . goods . part ) ;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
logSpec . Debug ( " 出周转 虚拟库库位 。。 " + loc . locationId ) ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
WmsStock stkVir = new WmsStock ( loc . locationId , requestDetail . skuId , requestDetail . goodsId ) ;
2023-11-21 19:18:23 +08:00
/ *
2023-09-04 22:41:19 +08:00
DataTable dt = stk . getStockLocation ( loc . locationId ) ;
foreach ( DataRow dr in dt . Rows )
{
2023-11-21 19:18:23 +08:00
WmsStock tmp = new WmsStock ( dr ) ;
if ( tmp . goodsId = = requestDetail . goods . goodsId )
{
stk = new WmsStock ( dr ) ;
break ;
}
}
* /
2024-02-06 19:36:47 +08:00
stkVir . locationId = loc . locationId ;
stkVir . skuId = requestDetail . skuId ;
stkVir . skuCode = String . IsNullOrEmpty ( stkVir . skuCode ) ? requestDetail . skuCode : stkVir . skuCode ;
stkVir . productDate = String . IsNullOrEmpty ( stkVir . productDate ) ? stkVir . getDateTime ( ) : stkVir . productDate ;
stkVir . validDate = String . IsNullOrEmpty ( stkVir . validDate ) ? stkVir . productDate : stkVir . validDate ;
stkVir . batch = String . IsNullOrEmpty ( stkVir . batch ) ? stkVir . productDate : stkVir . batch ;
//缺货,拣货任务从虚拟库位出库,还是从真实库存出库
if ( WmsConstants . OUT_STOCK_LACK_VIR_OUT_AUTO )
{
//从虚拟库存借库存,在实体库位出库; 从零库出任务
2024-03-22 16:00:57 +08:00
logSpec . Debug ( " goods av bulk cnt befor virtual operation : " + goods . stockBulkAvCount + " ,lackcout " + lackCnt ) ;
2024-02-06 19:36:47 +08:00
bool isHit = false ;
foreach ( WmsStock st in goods . AllStocks )
{
// logOut.Debug("to update virtual count for stk " + st.ToString());
if ( st . getAvCount ( ) < 0 )
{
2024-03-22 16:00:57 +08:00
logSpec . Debug ( " 避开负库存。。。。 " + st ) ;
2024-02-06 19:36:47 +08:00
continue ;
}
if ( st . location . volType = = ( int ) enumWhLocVol . 零 库 )
{
st . virtialCount + = lackCnt ;
// st.count += lackCnt;
// st.countOuting -= lackCnt;
isHit = true ;
// st.preLockOut = 88888;
st . updateCountOut ( ) ;
2024-03-22 20:12:53 +08:00
logSpec . Debug ( "updated virtual count for stk " + st . ToString ( ) ) ;
2024-02-06 19:36:47 +08:00
break ;
}
}
2024-03-22 20:12:53 +08:00
logSpec . Debug ( "is hit ? " + isHit ) ;
2024-02-06 19:36:47 +08:00
if ( ! isHit )
{
// WmsLocation bulkLoc = loc.getLocation(enumWhLocVol.零库, goods.part, goods.ABC);
List < WmsLocation > locs = new List < WmsLocation > ( ) ;
try
{
locs = loc . getNewLocations ( lackCnt , goods , enumWhLocVol . 零 库 ) ;
if ( locs . Count = = 0 )
{
locs . Add ( loc . getLocation ( enumWhLocVol . 零 库 , goods . part , goods . ABC ) ) ;
}
}
catch ( Exception er )
{
}
2024-03-22 20:12:53 +08:00
logSpec . Debug ( string . Format ( " get new locs cnt {0} " , locs . Count ) ) ;
2024-02-06 19:36:47 +08:00
if ( locs . Count = = 0 )
{
locs . Add ( loc . getLocation ( enumWhLocVol . 零 库 , goods . part , goods . ABC ) ) ;
}
if ( locs . Count = = 0 )
{
locs . Add ( new WmsLocation ( "11.01.01.11" ) ) ;
}
foreach ( WmsLocation nloc in locs )
{
2024-03-06 20:48:05 +08:00
// WmsStock newstk = new WmsStock(nloc.locationId, requestDetail.skuId, requestDetail.goodsId);
WmsStock newstk = new WmsStock ( ) ;
2024-02-06 19:36:47 +08:00
newstk . virtialCount + = lackCnt ;
2024-03-06 20:48:05 +08:00
if ( newstk . ID = = 0 | | newstk . getAvCount ( ) < 0 )
2024-02-06 19:36:47 +08:00
{
newstk . locationId = nloc . locationId ;
newstk . skuId = requestDetail . skuId ;
newstk . goodsId = requestDetail . goods . goodsId ;
newstk . skuCode = requestDetail . skuCode ;
newstk . productDate = string . IsNullOrEmpty ( requestDetail . productDate ) ? getDateStr ( DateTime . Now . AddDays ( - 1000 ) ) : requestDetail . productDate ; //
newstk . validDate = string . IsNullOrEmpty ( requestDetail . validDate ) ? getDateStr ( DateTime . Now . AddDays ( 1000 ) ) : requestDetail . validDate ;
newstk . batch = string . IsNullOrEmpty ( requestDetail . batch ) ? newstk . productDate : requestDetail . batch ;
newstk . Add ( ) ;
}
else
{
newstk . updateCountOut ( ) ;
}
2024-03-06 20:48:05 +08:00
// logOut.Debug("to create new stk " + newstk.ToString());
2024-02-06 19:36:47 +08:00
}
// logOut.Debug("to create new virtual stk " + newstk.ToString());
}
//重新加载库存信息
goods = new WmsGoods ( requestDetail . goodsId , requestDetail . skuId , requestDetail . batch ) ;
2024-04-12 09:43:41 +08:00
logOut . Debug ( " goods av bulk cnt after virtual operation : " + goods . stockBulkAvCount ) ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
stkVir . countOuting + = lackCnt ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
}
else
{ //从虚拟库库位出库
stkVir . countOuting + = lackCnt ;
}
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
if ( stkVir . ID = = 0
| | string . IsNullOrEmpty ( stkVir . goodsId )
| | stkVir . goodsId ! = requestDetail . goodsId ) //商品没有虚拟记录
2023-09-04 22:41:19 +08:00
{
2024-02-06 19:36:47 +08:00
stkVir . goodsId = requestDetail . goods . goodsId ;
stkVir . Add ( ) ;
2024-03-22 16:00:57 +08:00
logSpec . Debug ( "新增虚拟库存 " + stkVir ) ;
2023-09-04 22:41:19 +08:00
}
else
{
2024-02-06 19:36:47 +08:00
stkVir . Update ( ) ;
2024-03-22 16:00:57 +08:00
logSpec . Debug ( "更新 虚拟库存 " + stkVir ) ;
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
if ( ! WmsConstants . OUT_STOCK_LACK_VIR_OUT_AUTO )
2023-11-21 19:18:23 +08:00
{
2024-02-06 19:36:47 +08:00
logStockOut ( requestDetail , requestDetail . goods , stkVir , lackCnt ) ;
if ( requestDetail . count = = requestDetail . lackCount ) //订单明细缺货
{
return true ;
}
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
}
}
else
{
2024-10-27 23:47:52 +08:00
msg = string . Format ( "rquest {3}, goods:{4}, sku {0},required count {1},stock available cnt {2} " , requestDetail . skuId ,
requestDetail . count , goods . stockSumCount - countOuting , requestDetail . pickOrderNo , goods . goodsName + goods . goodsId ) ;
2023-09-04 22:41:19 +08:00
logSpec . Error ( msg ) ;
throw new DeiNiuNoStockException ( msg ) ;
}
}
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
if ( ! isRep & & bulkCnt > 0 & & bulkCnt > goods . stockBulkAvCount /*requestDetail.getGoodsStockCnt(enumWhLocVol.零库)*/ ) // pd.goods.stockBulkCount)
{
if ( requestDetail . whtype = = ( int ) enumWhType . 合 格 库 )
{
// this.createGoodsRepOrder(goods, requestDetail.skuId, requestDetail.skuCode, bulkCnt); //TODO: check if the rep has been created for it.
}
2024-10-27 23:47:52 +08:00
string msg = string . Format ( "goods : {3} 需要补零, sku {0},required bulkcount {1},stock bulk cnt: {2} " , requestDetail . skuId , bulkCnt , goods . stockBulkAvCount , goods . goodsName ) ;
2023-09-04 22:41:19 +08:00
logSpec . Debug ( msg ) ;
//throw new DeiNiuStockBulkCountException(msg);
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
if ( batch1Cnt + batch2Cnt >
goods . stockBatch1Count + goods . stockBatch2Count + goods . stockBatch3Count
- goods . stockBatch1CountOuting - goods . stockBatch2CountOuting - goods . stockBatch3CountOuting
)
{
string msg = string . Format ( "整库存库存不足,{0} ,detailId{6},skuId{5}, skuCode {4}, \n {1} 整货需 {2}, 实际整库存 {3} "
, requestDetail . pickOrderNo , goods . goodsName
, batch1Cnt + batch2Cnt , goods . stockBatch1Count + goods . stockBatch2Count
, requestDetail . skuCode , requestDetail . skuId , requestDetail . ID ) ;
logSpec . Debug ( msg ) ;
// throw new DeiNiuNoStockException(msg);
}
2023-11-21 19:18:23 +08:00
// logSpec.Debug("");
// logSpec.Debug(string.Format("{4},开始定位扣库存 : bulkCnt:{0}, batch1Cnt:{1},batch2Cnt{2}, 是否严格按效期出库 ? {3}",
2023-09-04 22:41:19 +08:00
// bulkCnt, batch1Cnt, batch2Cnt, WmsConstants.OUT_STOCK_BATCH_FIFO, goods.goodsId));
#region oldLog , can work .
/ *
if ( batch2Cnt > 0 )
{
logSpec . Debug ( "开始出中整..>>." ) ;
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 中 整 , requestDetail ) ; //出中整
if ( batch2Cnt > 0 )
{
requestDetail . batch2Count - = batch2Cnt ;
}
logSpec . Debug ( "中整不足,出大整" ) ;
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 大 整 , requestDetail ) ; //中整不足,出大整
tmp = batch2Cnt ;
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 小 整 , requestDetail ) ; //出小整
requestDetail . batch1Count + = tmp - batch2Cnt ;
if ( ! isRep )
{
tmp = batch2Cnt ;
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 零 库 , requestDetail ) ; //出零货
requestDetail . bulkCount + = tmp - batch2Cnt ;
}
logSpec . Debug ( " 出中整...结束...<<" ) ;
}
if ( batch1Cnt > 0 )
{
logSpec . Debug ( "开始出小整..>>." ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 小 整 , requestDetail ) ; //出小整
if ( batch1Cnt > 0 )
{
requestDetail . batch1Count - = batch1Cnt ;
}
tmp = batch1Cnt ;
logSpec . Debug ( "小整不足,出中整" ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 中 整 , requestDetail ) ; //小整不足,出中整
requestDetail . batch2Count + = tmp - batch1Cnt ;
tmp = batch1Cnt ;
logSpec . Debug ( "中整不足,出大整" ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 大 整 , requestDetail ) ; //中整不足,出大整
tmp = batch1Cnt ;
if ( ! isRep )
{
logSpec . Debug ( "整不足,出零货" ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 零 库 , requestDetail ) ; //整不足,出零货 //TODO: HOW TO PROCESS request bulkcount ,batch count?
requestDetail . bulkCount + = tmp - batch1Cnt ;
}
logSpec . Debug ( " 出小整...结束...<<" ) ;
}
* /
#endregion
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
List < WmsStock > stks = new List < WmsStock > ( ) ;
//
decimal tmpBatch1Cnt = 0 m , tmpBatch2Cnt = 0 m , tmpBulkCnt = 0 m , tmpCnt = 0 m ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( ! WmsConstants . OUT_STOCK_BATCH_FIFO ) //不分货区,全库按近效期优先 ,取待处理货位,所取的货位数量可以满足分配,可能出现零库因为效期问题 补零、整库从零出的情况
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
decimal targetCnt = requestDetail . state = = ( int ) enumOutStockDetailStatus . 等 待 补 货 ? bulkCnt : requestDetail . count ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st in goods . stocks )
{
// logSpec.Debug(string.Format("{0}, avcnt {1}, voltype {2} ", st.skuCode, st.getAvCount(), st.location.volType));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( tmpCnt > = targetCnt )
{
break ;
}
tmpCnt + = st . getAvCount ( ) ; ;
stks . Add ( st ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
else //分货区,各个分区按近效期优先 ,取待处理货位; 结果可能出远效期商品,按分区可能不满足分配需求,可能需要补充
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
logSpec . Debug ( "goods.stocks count : " + goods . stocks . Count ) ;
foreach ( WmsStock st in goods . stocks )
2023-05-23 16:13:17 +08:00
{
2024-10-27 23:47:52 +08:00
logSpec . Debug ( string . Format ( "locId {3}, sku {0}, avcnt {1}, voltype {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType , st . locationId ) ) ;
2023-09-04 22:41:19 +08:00
if ( st . location . volType < ( int ) enumWhLocVol . 小 整 ) //零库
{
if ( tmpBulkCnt < bulkCnt ) //满足零货需求
{
2024-04-12 09:43:41 +08:00
tmpBulkCnt + = st . getAvCount ( ) ;
2023-09-04 22:41:19 +08:00
stks . Add ( st ) ;
}
}
else if ( st . location . volType = = ( int ) enumWhLocVol . 小 整 )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
if ( tmpBatch1Cnt < batch1Cnt )
{
tmpBatch1Cnt + = st . getAvCount ( ) ; ;
stks . Add ( st ) ;
}
}
else if ( st . location . volType = = ( int ) enumWhLocVol . 中 整 )
{
if ( tmpBatch2Cnt < batch2Cnt )
{
tmpBatch2Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
}
2024-04-12 09:43:41 +08:00
if ( ! goods . isWeightOut ( ) & & goods . minOperateCount > 0 )
{
tmpBulkCnt - = tmpBulkCnt % goods . minOperateCount ;
tmpBatch1Cnt - = tmpBatch1Cnt % goods . minOperateCount ;
tmpBatch2Cnt - = tmpBatch2Cnt % goods . minOperateCount ;
}
2023-09-04 22:41:19 +08:00
if ( tmpBulkCnt > = bulkCnt & & tmpBatch1Cnt > = batch1Cnt & & tmpBatch2Cnt > = batch2Cnt )
{
break ;
2023-05-23 16:13:17 +08:00
}
}
2023-09-04 22:41:19 +08:00
if ( tmpBatch1Cnt < batch1Cnt | | tmpBatch2Cnt < batch2Cnt )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
List < WmsStock > tmpStks = new List < WmsStock > ( ) ;
bool ishit = false ;
if ( batch1Cnt > 0 )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st in goods . stocks ) // copy stocklist
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st2 in stks )
{
if ( st . ID = = st2 . ID )
{
ishit = true ;
break ;
}
}
if ( ishit )
{
ishit = false ;
}
else
{
tmpStks . Add ( st ) ;
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "开始处理 batch1" ) ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
tmpBatch1Cnt = 0 ;
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 中 整 )
{
if ( tmpBatch1Cnt < batch1Cnt )
{
tmpBatch1Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
if ( tmpBatch1Cnt < batch1Cnt )
{
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 大 整 )
{
if ( tmpBatch1Cnt < batch1Cnt )
{
tmpBatch1Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
}
if ( ! isRep )
if ( tmpBatch1Cnt < batch1Cnt )
{
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 零 库 )
{
if ( tmpBatch1Cnt < batch1Cnt )
{
tmpBatch1Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
}
/ *
foreach ( WmsStock st in stks )
{
logSpec . Debug ( string . Format ( "{0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
} * /
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( batch2Cnt > 0 )
{
logSpec . Debug ( string . Format ( "开始处理 batch2" ) ) ;
tmpStks . Clear ( ) ;
foreach ( WmsStock st in goods . stocks ) // copy stocklist
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st2 in stks )
{
if ( st . ID = = st2 . ID )
{
ishit = true ;
break ;
}
}
if ( ishit )
{
ishit = false ;
}
else
{
tmpStks . Add ( st ) ;
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
tmpBatch2Cnt = 0 ;
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 大 整 )
{
if ( tmpBatch2Cnt < batch2Cnt )
{
tmpBatch2Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
if ( tmpBatch2Cnt < batch2Cnt )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 小 整 )
{
if ( tmpBatch2Cnt < batch2Cnt )
{
tmpBatch2Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
if ( ! isRep )
if ( tmpBatch2Cnt < batch2Cnt )
{
foreach ( WmsStock st in tmpStks )
{
if ( st . location . volType = = ( int ) enumWhLocVol . 零 库 )
{
if ( tmpBatch2Cnt < batch2Cnt )
{
tmpBatch1Cnt + = st . getAvCount ( ) ;
stks . Add ( st ) ;
}
else
{
break ;
}
}
}
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
// 开始按货位分区类型处理定位
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
goods . tmpStocks = stks ;
2023-11-21 19:18:23 +08:00
logSpec . Debug ( "tmp stklst cnt " + goods . tmpStocks . Count ) ;
2023-09-04 22:41:19 +08:00
if ( batch2Cnt > 0 )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "{0}" , "开始处理 中整。。。。。" ) ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 中 整 , requestDetail ) ;
2023-11-21 19:18:23 +08:00
logSpec . Debug ( string . Format ( " 中整 剩余数量 {0}" , batch2Cnt ) ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 大 整 , requestDetail ) ;
logSpec . Debug ( string . Format ( "大整 剩余数量 {0}" , batch2Cnt ) ) ;
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 小 整 , requestDetail ) ; batch2bulk + = batch2Cnt ;
logSpec . Debug ( string . Format ( "小整 剩余数量 {0}" , batch2Cnt ) ) ;
if ( ! isRep )
batch2Cnt = reductStockCnt ( goods , batch2Cnt , enumWhLocVol . 零 库 , requestDetail ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "零库 剩余数量 {0}" , batch2Cnt ) ) ;
/ * foreach ( WmsStock st in stks )
{
if ( st . location . volType = = 2 )
logSpec . Debug ( string . Format ( "{0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
} * /
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
/ *
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsStock st in stks )
{
logSpec . Debug ( string . Format ( "{0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
} * /
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( batch1Cnt > 0 )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "{0}" , "开始处理 小整。。。。。" ) ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 小 整 , requestDetail ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 中 整 , requestDetail ) ;
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 大 整 , requestDetail ) ; batch2bulk + = batch1Cnt ;
if ( ! isRep )
batch1Cnt = reductStockCnt ( goods , batch1Cnt , enumWhLocVol . 零 库 , requestDetail ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
/ *
foreach ( WmsStock st in stks )
{
// if (st.location.volType == 1)
logSpec . Debug ( string . Format ( "{0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
}
* /
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
if ( bulkCnt > 0 )
2023-05-23 16:13:17 +08:00
{
2023-11-21 19:18:23 +08:00
2024-10-27 23:47:52 +08:00
goods . getStockInfo ( goods . goodsId , requestDetail . skuId ) ;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "开始处理 零库。。。。。bulkCnt :{0}, goods.stockBulkAvCount {1}, goods.tmpStocks count {2} " , bulkCnt , goods . stockBulkAvCount , goods . tmpStocks . Count ) ) ;
/ *
foreach ( WmsStock st in goods . tmpStocks )
{
logSpec . Debug ( string . Format ( " {0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
}
* /
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( bulkCnt < = goods . stockBulkAvCount )
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
bulkCnt = reductStockCnt ( goods , bulkCnt , enumWhLocVol . 零 库 , requestDetail ) ;
/ *
foreach ( WmsStock st in stks )
{
logSpec . Debug ( string . Format ( " {0}, avCount{1}, volType {2} " , st . skuCode , st . getAvCount ( ) , st . location . volType ) ) ;
} * /
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( " {3} 定位后...数量 : bulkCnt:{0}, batch1Cnt:{1},batch2Cnt{2} " , bulkCnt , batch1Cnt , batch2Cnt , goods . goodsId ) ) ;
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format(" {3} 定位后...数量 : bulkCnt:{0}, batch1Cnt:{1},batch2Cnt{2} ", bulkCnt, batch1Cnt, batch2Cnt, goods.goodsId));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
tmpCnt = batch1Cnt + batch2Cnt + bulkCnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( tmpCnt = = 0 ) //库存正常,不需补零、按库位类型出
{
logSpec . Debug ( "定位结束" ) ;
return true ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
else
{
2024-04-12 09:43:41 +08:00
logSpec . Debug ( "! ! ! ! 需要补零或库存不足或不满足最小分拣数量" ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
}
2024-10-27 23:47:52 +08:00
if ( bulkCnt > 0 & & WmsConstants . OUT_BULK_REP_FROM_BATCH )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
string msg = string . Format ( "goods {3}, skuId {0},required bulkcount {1},stock bulk cnt {2} " , requestDetail . skuId , bulkCnt , goods . stockBulkAvCount , goods . goodsId ) ;
logSpec . Debug ( msg ) ;
2024-02-06 19:36:47 +08:00
2023-11-21 19:18:23 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ;
2024-02-06 19:36:47 +08:00
this . reportBulkLack ( goods , requestDetail . skuId , requestDetail . skuCode , bulkCnt ) ;
2023-05-23 16:13:17 +08:00
2024-02-06 19:36:47 +08:00
throw new DeiNiuStockBulkCountException ( msg ) ;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
logSpec . Debug ( string . Format ( "整库处理完毕,未处理数量: bulkCnt: {0} , batch1Cnt: {1} ,batch2Cnt: {2}" , bulkCnt , batch1Cnt , batch2Cnt ) ) ;
2023-05-23 16:13:17 +08:00
if ( batch2Cnt > 0 | | batch1Cnt > 0 ) //货物不足,异常,
{
2023-11-21 19:18:23 +08:00
if ( isRep )
{
// logSpec.Debug("补货定位结束");
if ( batch1Cnt + batch2Cnt = = requestDetail . count ) // no stock get
{
logSpec . Debug ( " 整货不足,补货缺货。。。关闭拣货任务" ) ;
requestDetail . state = ( int ) enumOutStockDetailStatus . 完 成 分 拣 ;
}
return true ;
}
if ( goods . isZhitong )
{
2024-04-12 09:43:41 +08:00
logOut . Debug ( "goods is zhitong!!!" ) ;
2023-11-21 19:18:23 +08:00
requestDetail . state = ( int ) enumOutStockDetailStatus . 另 单 播 种 ;
}
else if ( ! isRep )
2023-05-23 16:13:17 +08:00
{
throw new DeiNiuNoStockException ( "库存异常" ) ;
}
}
2023-09-04 22:41:19 +08:00
decimal batchCont = batch2Cnt + batch1Cnt - batch2bulk ; // +requestDetail.batch2Count;
2023-05-23 16:13:17 +08:00
int boxcnt = ( int ) Math . Ceiling ( batchCont / requestDetail . goods . bigCount ) ;
2023-09-04 22:41:19 +08:00
requestDetail . boxcnt = boxcnt ;
2023-11-21 19:18:23 +08:00
requestDetail . pcs = ( int ) Math . Ceiling ( ( requestDetail . count - requestDetail . lackCount ) / goods . minOperateCount ) ;
2023-05-23 16:13:17 +08:00
/ *
* 在 开 始 已 判 断 是 否 零 库 缺 货
* 整 库 不 足 出 零 库 的 情 况 , 在 总 货 量 足 够 的 情 况 下 , 不 会 出 现 零 库 不 足 的 问 题
if ( bulkCnt > 0 & & bulkCnt > requestDetail . getGoodsStockCnt ( enumWhLocVol . 零 库 ) ) // pd.goods.stockBulkCount)
{
throw new DeiNiuStockBulkCountException ( ) ;
}
* /
2023-09-04 22:41:19 +08:00
logSpec . Debug ( "定位结束" ) ;
return true ; ;
}
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
private decimal reductStockCnt ( WmsGoods goods , decimal targetCnt , enumWhLocVol locVol , WmsOutPickDetail requestDetail , bool useTemp = true )
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
List < WmsStock > stks = useTemp ? goods . tmpStocks : goods . stocks ;
2024-04-12 09:43:41 +08:00
logSpec . Debug ( string . Format ( " {2} 开始定位 {0},待定位数量 {1}" , locVol , targetCnt , goods . goodsName ) ) ;
2023-09-04 22:41:19 +08:00
if ( locVol = = enumWhLocVol . 零 库 ) //零库出库单笔捡货不能超过9999 //TODO: to test the logic
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
decimal tmpCnt = 0 ;
2024-04-12 09:43:41 +08:00
// while (stks.Count > 0 && targetCnt > 0)
2023-09-04 22:41:19 +08:00
{
2024-04-12 09:43:41 +08:00
logSpec . Debug ( string . Format ( "targetcnt {0} " , targetCnt ) ) ;
2024-02-06 19:36:47 +08:00
if ( WmsConstants . OUT_LIGHT_ENABLE & & targetCnt / goods . minOperateCount > WmsConstants . MAX_PICK_CNT_BULK )
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
tmpCnt = WmsConstants . MAX_PICK_CNT_BULK ;
}
else
{
tmpCnt = targetCnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
targetCnt = targetCnt - tmpCnt ;
decimal decnt = 0 ;
int i = 0 ;
foreach ( WmsStock st in stks )
{
2024-04-12 09:43:41 +08:00
logSpec . Debug ( string . Format ( "零库。。。tmpCnt {0} ,location volType {1}, av cnt {2}" , tmpCnt , st . location . volType , st . getAvCount ( ) ) ) ;
2023-09-04 22:41:19 +08:00
if ( tmpCnt = = 0 )
{
break ;
}
if ( st . location . volType = = ( int ) locVol )
{
decimal cnt = st . getAvCount ( ) ;
decimal reductCnt = cnt > = tmpCnt ? tmpCnt : cnt ;
2024-04-12 09:43:41 +08:00
/ * if ( goods . minOperateCount > 1 & & ! goods . isWeightOut ( ) )
{
reductCnt = ( ( int ) ( reductCnt / goods . minOperateCount ) ) * goods . minOperateCount ;
}
* /
if ( ! goods . isWeightOut ( ) & & goods . minOperateCount > 0 )
{
reductCnt - = reductCnt % goods . minOperateCount ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( reductCnt < = 0 )
{
continue ;
}
i + + ;
if ( WmsConstants . OUT_STOCK_DEDUCT )
{
st . countOuting + = reductCnt ;
}
else
{
st . countOut + = reductCnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
st . operater = this . operId ;
// st.Update();
st . updateCountOut ( ) ;
2024-02-06 19:36:47 +08:00
logStockOut ( requestDetail , goods , st , reductCnt ) ;
2023-09-04 22:41:19 +08:00
tmpCnt - = reductCnt ;
decnt + = reductCnt ;
}
}
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format("tmpCnt {0} ,decnt {1} ", tmpCnt,decnt));
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
if ( i > 0 & & decnt < = 0 & & tmpCnt > 0 ) //零库不足
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
logSpec . Debug ( "零库扣库存异常" ) ;
// logSpec.Debug("零库扣库存异常");
2024-04-12 09:43:41 +08:00
// throw new DeiNiuStockBulkCountException();
2023-09-04 22:41:19 +08:00
}
targetCnt + = tmpCnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
else
foreach ( WmsStock st in stks )
{
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format(" targetCnt {0} ,location volType {1}, av cnt {2}", targetCnt, st.location.volType, st.getAvCount()));
2023-09-04 22:41:19 +08:00
if ( targetCnt = = 0 )
{
break ;
}
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format(" st.location.volType == (int)locVol {0} ", st.location.volType == (int)locVol));
2023-09-04 22:41:19 +08:00
if ( st . location . volType = = ( int ) locVol )
{
decimal cnt = st . getAvCount ( ) ;
decimal reductCnt = cnt > = targetCnt ? targetCnt : cnt ;
2023-11-21 19:18:23 +08:00
// logSpec.Debug(string.Format(" reductCnt {0} ", reductCnt));
2023-09-04 22:41:19 +08:00
if ( reductCnt < = 0 )
{
continue ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
if ( WmsConstants . OUT_STOCK_DEDUCT )
{
st . countOuting + = reductCnt ;
}
else
{
st . countOut + = reductCnt ;
if ( st . countIn + st . count - st . countOut < = 0 ) //库存扣完,删除记录
{
st . Delete ( ) ;
}
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
st . operater = this . operId ;
st . Update ( ) ;
logStockOut ( requestDetail , goods , st , reductCnt ) ;
targetCnt - = reductCnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
}
2024-04-12 09:43:41 +08:00
logSpec . Debug ( string . Format ( "{0} 定位完成,未定位数量{1}" , locVol , targetCnt ) ) ;
2023-09-04 22:41:19 +08:00
return targetCnt ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
private enumStockRecordType stockOutType = enumStockRecordType . 销 售 出 库 ;
2024-02-06 19:36:47 +08:00
private void logStockOut ( WmsOutPickDetail pickDetail , WmsGoods goods , WmsStock stock , decimal count )
2023-09-04 22:41:19 +08:00
{
2024-02-06 19:36:47 +08:00
decimal maxFull = goods . full_max > 0 ? goods . full_max : count ; //单个容器最大装载数量 ——> 最大单次分拣数量
2023-12-03 22:13:49 +08:00
decimal leftCnt = count ;
decimal recCnt = 0 ;
2024-02-06 19:36:47 +08:00
decimal lackCnt = pickDetail . lackCount ;
2023-12-03 22:13:49 +08:00
while ( leftCnt > 0 )
2023-09-04 22:41:19 +08:00
{
2024-02-06 19:36:47 +08:00
2023-12-03 22:13:49 +08:00
recCnt = leftCnt > = maxFull ? maxFull : leftCnt ;
leftCnt - = recCnt ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
log . Debug ( string . Format ( "1 goodsId {4},maxFull {0}, leftCnt:{1},recCnt {2}, locId {3},lackCnt {5},stock virtialCnt {6}" , maxFull , leftCnt , recCnt , stock . locationId , goods . goodsId , lackCnt , stock . virtialCount ) ) ;
2023-12-03 22:13:49 +08:00
WmsStockRecord r = new WmsStockRecord ( ) ;
r . batch = stock . batch . Trim ( ) ;
r . skuCode = stock . skuCode ;
r . skuId = stock . skuId ;
if ( WmsConstants . OUT_STOCK_DEDUCT )
{
r . countOuting = recCnt ;
}
else
{
r . count = recCnt ;
}
2024-02-06 19:36:47 +08:00
r . goodsId = pickDetail . goodsId . Trim ( ) ;
2023-12-03 22:13:49 +08:00
r . locationId = stock . locationId . Trim ( ) ;
r . productDate = stock . productDate ;
r . validDate = stock . validDate ;
// r.orderNo = request.orderNo.Trim();
2024-02-06 19:36:47 +08:00
r . orderNo = pickDetail . pickOrderNo . Trim ( ) ;
2023-12-03 22:13:49 +08:00
r . rectype = ( int ) stockOutType ; //out
2024-03-06 20:48:05 +08:00
// logOut.Debug("1 stock.virtialCount " + stock.virtialCount);
2024-02-06 19:36:47 +08:00
// if (stock.virtialCount >0)
if ( pickDetail . lackCount > 0 )
{
decimal virCnt = 0 ;
if ( recCnt < lackCnt )
{
virCnt = recCnt ;
lackCnt - = recCnt ;
}
else
{
virCnt = lackCnt ;
lackCnt = 0 ;
}
r . virCount = virCnt ;
pickDetail . lackCount - = virCnt ;
// stock.virtialCount -= virCnt; //////为什么这里不能对 stock 进行赋值操作????????????????????????????
// stock.virtialCount = stock.virtialCount < 0 ? 0 : stock.virtialCount;
// stock.updateCountOut();
}
2024-03-06 20:48:05 +08:00
// logOut.Debug("2 stock.virtialCount " + stock.virtialCount);
2024-02-06 19:36:47 +08:00
// r.regeditCode = goods..Trim();
r . operater = this . operId ;
r . orderDetailId = pickDetail . ID ; //order detailId,同步 零货捡取临时数据、复核临时数据 的状态
/ *
2023-12-03 22:13:49 +08:00
if ( stock . location . partion > 0 )
{
Node nd = new Node ( stock . location . partion ) ;
r . partion = nd . flag ;
}
2024-02-06 19:36:47 +08:00
* /
r . partion = stock . location . partion ;
2024-04-12 09:43:41 +08:00
int i = r . Add ( ) ;
2023-12-03 22:13:49 +08:00
2024-02-06 19:36:47 +08:00
if ( stock . location . volType = = ( int ) enumWhLocVol . 虚 拟 )
{
leftCnt = 0 ; // return;
}
2024-04-12 09:43:41 +08:00
log . Debug ( string . Format ( "2 goodsId {4},maxFull {0}, leftCnt:{1},recCnt {2}, locId {3},lackCnt {5},stock virtialCnt {6}, new rec id {7}" , maxFull , leftCnt , recCnt , stock . locationId , goods . goodsId , lackCnt , stock . virtialCount , i ) ) ;
2024-02-06 19:36:47 +08:00
2023-12-03 22:13:49 +08:00
}
2023-05-23 16:13:17 +08:00
2024-02-06 19:36:47 +08:00
pickDetail . Update ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
private void logStockOutErpLocation ( WmsOutPickDetail pd )
{
LogHelper . debug ( "lWmsOutRequest" , "logStockOutErpLocation: " + pd . ID ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsStockRecord r = new WmsStockRecord ( ) ;
r . batch = pd . batch . Trim ( ) ;
r . skuCode = pd . skuCode ;
r . skuId = pd . skuId ;
if ( WmsConstants . OUT_STOCK_DEDUCT )
{
r . countOuting = pd . bulkCount ;
}
else
{
r . count = pd . bulkCount ;
}
r . goodsId = pd . goodsId . Trim ( ) ;
r . locationId = pd . locationId . Trim ( ) ;
r . productDate = pd . productDate ;
r . validDate = pd . validDate ;
// r.orderNo = request.orderNo.Trim();
r . orderNo = pd . pickOrderNo . Trim ( ) ;
r . rectype = ( int ) enumStockRecordType . 销 售 出 库 ; ; //out
// r.regeditCode = goods..Trim();
r . operater = this . operId ;
r . orderDetailId = pd . ID ; //order detailId,同步 零货捡取临时数据、复核临时数据 的状态
2024-02-06 19:36:47 +08:00
/ *
2023-09-04 22:41:19 +08:00
if ( pd . location . partion > 0 )
{
Node nd = new Node ( pd . location . partion ) ;
r . partion = nd . flag ;
2024-02-06 19:36:47 +08:00
} * /
r . partion = pd . location . partion ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
r . Add ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
internal int approveOrder ( string orderNo , int status , int priority , bool canMerge )
{
WmsOutRequest order = new WmsOutRequest ( orderNo ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( string . IsNullOrEmpty ( order . pickOrderNo ) )
{
order . state = status ;
order . operater = outRequest . operater ;
order . priority = priority ;
order . isMergable = canMerge ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
Erp_sale es = new Erp_sale ( orderNo ) ;
es . wms_state = status ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
using ( TransactionScope scope = new TransactionScope ( ) )
{
es . Update ( ) ;
order . Update ( ) ;
scope . Complete ( ) ;
}
return 1 ;
}
else
{
throw new Exception ( "操作失败,订单已经进入分拣作业" ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
internal string genPickOrder ( string orderNo )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsOutRequest order = new WmsOutRequest ( orderNo ) ;
if ( order . ID = = 0 )
{
return "" ;
}
if ( string . IsNullOrEmpty ( order . pickOrderNo ) )
{
List < WmsOutDetail > outds = order . outDetails ;
WmsOutPickRequest pr = new WmsOutPickRequest ( ) ;
DataTable dt = order . getOutDetailForPick ( ) ;
pr = new WmsOutPickRequest ( ) ;
pr . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . pickOrder , pr . getNextSeq ( enumCreateOrderType . pickOrder ) ) ;
pr . orderType = order . orderType ;
pr . outStoreType = ( int ) getOutStoreType ( order . orderType ) ; // (int)enumOutStoreType.拣货出库;
pr . operater = this . operId ;
pr . customerId = order . customerId ;
pr . customerName = order . customerName ;
pr . custAddress = order . custAddress ;
List < WmsOutPickDetail > pdCache = new List < WmsOutPickDetail > ( ) ;
foreach ( DataRow dr in dt . Rows )
{
WmsOutPickDetail pd = new WmsOutPickDetail ( dr ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pd . pickOrderNo = pr . pickOrderNo ;
pr . bulkCnt + = pd . bulkCount ; //pick request 总bulk cnt,作为拣选、复合工作量的指标
pr . boxCnt + = pd . boxcnt ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( pd . bulkCount > 0 & & pd . bulkCount > pd . goods . stockBulkAvCount /* pd.getGoodsStockCnt(enumWhLocVol.零库)*/ ) // pd.goods.stockBulkCount)
{
pd . description = "零库库存不足,等待补货" ;
pr . state = ( int ) enumOutStockRequestStatus . 等 待 补 货 ;
pd . state = ( int ) enumOutStockDetailStatus . 等 待 补 货 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pr . description = string . Format ( "{0} 零库库存不足,等待补货 " , pd . goods . goodsName ) ;
LogHelper . debug ( typeof ( lWmsOutRequest ) , pr . description ) ;
}
pd . operater = this . operId ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//calculate the total bulk for each goods
if ( pd . bulkCount > 0 )
{
if ( pd . count = = pd . bulkCount ) //batch not exists
{
pd . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
else
{
pd . bulkPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pdCache . Add ( pd ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( pdCache . Count > 0 & & pr ! = null )
{
pr . orderDate = pr . getDateTime ( ) ;
try
{
using ( TransactionScope scope1 = new TransactionScope ( ) )
{
pr . batchPickState = ( int ) enumOutStockPickStatus . 无 需 分 拣 ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( WmsOutDetail wd in outds )
{
wd . state = ( int ) enumOutStockDetailStatus . 等 待 分 拣 ;
wd . Update ( ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
order . pickOrderNo = pr . pickOrderNo ;
order . state = ( int ) Utils . enumOutStockRequestStatus . 待 定 位 ;
order . Update ( ) ;
esale . updatePickStatus ( pr . pickOrderNo , Utils . enumOutStockRequestStatus . 待 定 位 ) ;
foreach ( WmsOutPickDetail p in pdCache )
{
if ( p . batchPickState ! = ( int ) enumOutStockPickStatus . 无 需 分 拣 )
{
pr . batchPickState = ( int ) enumOutStockPickStatus . 待 处 理 ;
}
p . Add ( ) ;
2023-05-23 16:13:17 +08:00
// pr.outDetails.Add(p); //why duplicated sometimes?
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
pr . Add ( ) ;
scope1 . Complete ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
}
catch ( Exception er )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
LogHelper . WriteLog ( typeof ( lWmsOutRequest ) , er ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
// updateOutRequestState(order.customerId,order.customerName, order.custAddress, "");
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
requestOutStock ( pr . pickOrderNo ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return pr . pickOrderNo ;
// pdCache.Clear();
}
}
else
{
throw new Exception ( string . Format ( "操作失败,订单{0}已经进入分拣作业" , orderNo ) ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return "" ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
internal string genPickOrderByOrders ( string [ ] orderNos )
{
return null ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
internal string createPickOrderByDetails ( int [ ] detailIds )
{
return null ;
}
internal string createSeedsOrder ( int pickGroup , int pickStartOn , string dueDate )
{
enumOutStockRequestStatus enOs = enumOutStockRequestStatus . 待 审 核 ;
enumOutStockDetailStatus enOd = enumOutStockDetailStatus . 待 处 理 ;
// DataTable dt = outRequest.getSeedsSumDetail(pickGroup, pickStartOn, dueDate, enOs, enOd);
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
WmsOutPickRequest pr = new WmsOutPickRequest ( pickGroup , pickStartOn , dueDate ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if ( pr . ID = = 0 )
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
using ( TransactionScope scope = new TransactionScope ( TransactionScopeOption . Required , new TransactionOptions ( )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
IsolationLevel = System . Transactions . IsolationLevel . Serializable ,
Timeout = new TimeSpan ( 0 , 10 , 0 )
}
) )
{
pr . pickGroup = pickGroup ;
pr . pickStartOn = pickStartOn ;
pr . dueDate = dueDate ;
2023-11-21 19:18:23 +08:00
pr . orderType = ( int ) enumOrderType . 销 售 出 库 ;
2023-09-04 22:41:19 +08:00
pr . outStoreType = ( int ) enumOutStoreType . 配 货 汇 总 拣 货 出 库 ;
pr . pickOrderNo = Util . getOrderNo ( enumCreateOrderType . pickOrder , pr . getNextSeq ( enumCreateOrderType . pickOrder ) ) ;
pr . operater = operId ;
LogHelper . debug ( typeof ( lWmsOutRequest ) , "开始新建拣货明细, " ) ;
int cnt = outRequest . groupPickStart ( pickGroup , pickStartOn , dueDate , pr . pickOrderNo , this . operId ) ;
2023-05-23 16:13:17 +08:00
if ( cnt > 0 )
{
pr . Add ( ) ;
}
#region slow way , 1 second slower
/ * DataTable dt = outRequest . getSeedsSumDetail ( pickGroup , pickStartOn , dueDate , enOs , enOd ) ;
foreach ( DataRow dr in dt . Rows )
{
WmsOutPickDetail pd = new WmsOutPickDetail ( dr ) ;
pd . pickOrderNo = pr . pickOrderNo ;
pd . state = ( int ) enumOutStockPickStatus . 待 处 理 ;
pd . Add ( ) ;
}
if ( dt . Rows . Count > 0 )
{
pr . Add ( ) ;
} * /
#endregion
2023-09-04 22:41:19 +08:00
LogHelper . debug ( typeof ( lWmsOutRequest ) , " 新建拣货明细 完成 " ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
scope . Complete ( ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
LogHelper . debug ( typeof ( LoginInfo ) , "------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---------NOT -set userId:---------------- " ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
LogHelper . debug ( typeof ( lWmsOutRequest ) , "开始计算出库: " ) ;
requestOutStock ( pr ) ;
LogHelper . debug ( typeof ( lWmsOutRequest ) , "计算出库结束 " ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return pr . pickOrderNo ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
internal DataTable getSeedsSumDetail ( int pickGroup , int pickStartOn , string dueDate , int enOrderState , int enDetailState )
{
return outRequest . getSeedsSumDetail ( pickGroup , pickStartOn , dueDate ,
( enumOutStockRequestStatus ) enDetailState , ( enumOutStockDetailStatus ) enDetailState ) ;
}
internal DataSet getSeedsSumDetail ( string queryStr , int rowStart , int rowEnd )
{
queryStr = pareseCondition ( queryStr ) ;
return outRequest . getSeedsSumDetail ( queryStr , rowStart , rowEnd ) ;
}
internal DataTable getSeedsDetailByGoods ( string goodsId )
{
return outRequest . getSeedsDetailByGoods ( goodsId ) ;
}
internal DataTable getSeedsDetailBySku ( int skuId )
{
return outRequest . getSeedsDetail ( skuId ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
//------------------------------test begin
/// <summary>
///
/// </summary>
internal void updateTestData ( )
{
2023-05-23 16:13:17 +08:00
Erp_sale sale = new Erp_sale ( ) ;
2023-09-04 22:41:19 +08:00
DataTable dt = sale . QueryActived ( ) . Tables [ 0 ] ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
foreach ( DataRow dr in dt . Rows )
{
sale = new Erp_sale ( dr ) ;
sale . updateCreatetime ( ) ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
Thread . Sleep ( 10000 ) ;
}
Erp_purch ep = new Erp_purch ( ) ;
dt = ep . QueryActived ( ) . Tables [ 0 ] ;
foreach ( DataRow dr in dt . Rows )
{
ep = new Erp_purch ( dr ) ;
ep . updateCreatetime ( ) ;
Thread . Sleep ( 10000 ) ;
}
}
/// <summary>
/// 创建销售出库单
/// </summary>
public void testCreateSales ( string custId )
{
int itemCnt = new Random ( ) . Next ( 2 , 5 ) ;
//logSpec.Debug(string.Format("to create sales out , custId :{0}, itemCnt : {1}", custId, itemCnt));
Customer cust = new Customer ( ) ; ;
if ( ! string . IsNullOrEmpty ( custId ) )
{
cust = new Customer ( custId ) ;
testCreateOut ( cust . ID , itemCnt ) ;
return ;
}
DataTable dtCust = new Erp_customer ( ) . QueryActived ( ) . Tables [ 0 ] ;
foreach ( DataRow dr in dtCust . Rows )
{
testCreateOut ( new Erp_customer ( dr ) . ID , itemCnt ) ;
}
}
void testCreateOut ( int custId , int itemCnt , int type = 0 )
{
Erp_sale saleObj = new Erp_sale ( ) ;
Erp_customer cust = new Erp_customer ( custId ) ;
//logSpec.Debug(string.Format(" cust ID :{0}, customerID : {1}", custId, cust.custId));
saleObj . custor_id = cust . custId ;
saleObj . order_type = type ;
saleObj . orgid = "LDJNBYXGS" ;
saleObj . receive_man = cust . contact ;
saleObj . salse_people = "hi chen" ;
saleObj . send_address = cust . address ;
saleObj . entid = "LDJNBYXGS" ;
saleObj . dueDate = DateTime . Now . AddDays ( 20 ) . ToShortDateString ( ) ;
saleObj . sale_order = "s" + Utils . Util . getOrderNo ( enumCreateOrderType . pickOutInvoice , saleObj . getNextSeq ( enumCreateOrderType . pickOutInvoice ) ) ;
2023-11-21 19:18:23 +08:00
saleObj . Add ( ) ;
2023-09-04 22:41:19 +08:00
WmsGoods goods = new WmsGoods ( ) ;
DataTable goodDt = goods . QueryActived ( ) . Tables [ 0 ] ;
int i = 0 ;
itemCnt = itemCnt > 0 ? itemCnt : goodDt . Rows . Count ;
for ( int j = 0 ; j < itemCnt ; j + + )
{
i = new Random ( ) . Next ( goodDt . Rows . Count - itemCnt ) - j ;
i = i > 0 ? i : j ;
goods = new WmsGoods ( goodDt . Rows [ i ] ) ;
Erp_sale_d saled = new Erp_sale_d ( ) ;
saled . add_date = saled . getDateTime ( ) ;
saled . goods_id = goods . goodsId ;
saled . count = goods . stockBatchAvCount > 10 ? goods . stockBatchAvCount / 10 + 1 : 1 ;
saled . sale_order_sn = j + 1 ;
saled . sale_order = saleObj . sale_order ;
saled . Add ( ) ;
if ( j > 5 )
{
break ;
}
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
lWmsOutPickPort lpp ;
2023-09-04 22:41:19 +08:00
public void testPickOut ( )
{
lpp = new lWmsOutPickPort ( operId ) ;
logTest . Debug ( "开始测试 出库拣货 .......................》》》" ) ;
testFinishPickItem ( ) ;
2023-11-21 19:18:23 +08:00
if ( WmsConstants . TEST_PICK_OUT_SEEDS )
{
logTest . Debug ( "开始测试 ....播种出库。。 " ) ;
testSeedsOut ( ) ;
}
2023-09-04 22:41:19 +08:00
logTest . Debug ( "结束测试 出库拣货 ......................《《《" ) ;
2023-11-21 19:18:23 +08:00
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
void testTaskAssign ( int partion , int lineId , int maxLots , int maxBoxCnt , bool batchOnly , enumOrderType orderType )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
lpp . taskAssignByJob ( operId , partion , lineId , maxLots , maxBoxCnt , batchOnly , ( enumOrderType ) orderType ) ;
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
DataTable testGetAssignedTask ( int partion , int lineId , bool batchOnly , enumOrderType orderType )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
int me = this . operId ;
2023-05-23 16:13:17 +08:00
2024-02-06 19:36:47 +08:00
return lpp . getAssignedOutTasks ( me , "" , partion , lineId , batchOnly , ( enumOrderType ) orderType ) ;
2023-09-04 22:41:19 +08:00
}
int limit = WmsConstants . TEST_PICK_OUT_ITEM_CNT ;
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
void testFinishPickItem ( )
{
2023-11-21 19:18:23 +08:00
lWmsOutPickRequest lop = new lWmsOutPickRequest ( this . operId ) ;
WmsOutPickPort wop ;
int partion ;
2023-09-04 22:41:19 +08:00
int lineId = 0 ;
bool batchOnly = WmsConstants . OUT_TASK_ASSIGN_BATCH_ONLY ;
2023-11-21 19:18:23 +08:00
int maxLots = WmsConstants . MAX_PICK_LOT_CNT ;
int maxBoxCnt = WmsConstants . MAX_PICK_BOX_CNT ;
2023-09-04 22:41:19 +08:00
DataTable dtPartion = lpp . getPartions ( operId ) ;
2023-11-21 19:18:23 +08:00
Dictionary < int , string > orderType = Util . convertEnumToDic ( typeof ( enumOrderType ) ) ;
2023-09-04 22:41:19 +08:00
int f = new Random ( ) . Next ( 1000 ) ;
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
string flowNo ;
logTest . Debug ( string . Format ( "1 maxLocCnt {0},maxBoxs {1}" , maxLots , maxBoxCnt ) ) ;
2023-09-04 22:41:19 +08:00
int i = 0 ;
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
foreach ( DataRow dr in dtPartion . Rows )
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
partion = Convert . ToInt32 ( dr [ "partion" ] . ToString ( ) ) ;
2024-02-06 19:36:47 +08:00
WmsLocation loc = new WmsLocation ( ) . getByPartion ( partion , 1 ) ;
if ( loc . ID = = 0 )
{
continue ;
}
2023-09-04 22:41:19 +08:00
foreach ( int type in orderType . Keys )
{
2024-02-06 19:36:47 +08:00
logTest . Debug ( string . Format ( "order type {2} ,maxLocCnt {0},maxBoxs {1}, partion {3}, locationid {4}" , maxLots , maxBoxCnt , orderType [ type ] , partion , loc . locationId ) ) ;
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
// testTaskAssign(partion, lineId, maxLots, maxBoxCnt, batchOnly, (enumOrderType)type);
lpp . taskAssignByJob ( "" , loc . locationId ) ;
DataTable dt = testGetAssignedTask ( partion , lineId , batchOnly , ( enumOrderType ) type ) ;
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
string waveNo = null ;
2024-02-06 19:36:47 +08:00
logTest . Debug ( string . Format ( "已完成 {0}条,开始下架任务 : {1}条待拣货记录" , i , dt . Rows . Count ) ) ;
2023-11-21 19:18:23 +08:00
string lastCustId = "" ;
2023-09-04 22:41:19 +08:00
foreach ( DataRow dr2 in dt . Rows )
2023-11-21 19:18:23 +08:00
{
flowNo = string . Format ( "o{0}-{1}-{2}" , f , partion , type ) ;
if ( string . IsNullOrEmpty ( lastCustId ) )
{
lastCustId = dr2 [ "customerId" ] . ToString ( ) ;
}
if ( lastCustId ! = dr2 [ "customerId" ] . ToString ( ) ) //拣货容器不能放多个订单, 播种单除外
{
flowNo + = i ;
}
2023-09-04 22:41:19 +08:00
wop = new WmsOutPickPort ( dr2 ) ;
2023-11-21 19:18:23 +08:00
enumPickResult result = lop . finishPickItem ( flowNo , waveNo , wop . pickOrderNo , wop . ID , wop . count ) ;
2023-09-04 22:41:19 +08:00
i + + ;
2023-11-21 19:18:23 +08:00
// logTest.Debug(string.Format("finished pickItem, result {4}, partion {0}, outOrderType {1}, taskId {2}, pickOrderNO {3} ", partion, (enumOrderType)type, wop.ID, wop.pickOrderNo, result )); ;
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
if ( i > limit * 2 )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
logTest . Debug ( string . Format ( "1 总共下架了{0}条记录" , i ) ) ;
2023-09-04 22:41:19 +08:00
return ;
}
}
}
}
2023-11-21 19:18:23 +08:00
logTest . Debug ( string . Format ( "2 总共下架了{0}条记录" , i ) ) ;
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
void testSeedsOut ( )
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
DataTable dt = lpp . getFlows4SeedsOut ( ) ;
bool isByCust = false ;
int j = 0 ;
2023-11-21 19:18:23 +08:00
foreach ( DataRow dr in dt . Rows )
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
j + = testDoSeedsOut ( dr [ "flowNo" ] . ToString ( ) , isByCust ) ;
2023-09-04 22:41:19 +08:00
isByCust = ! isByCust ;
}
2023-11-21 19:18:23 +08:00
logTest . Debug ( string . Format ( "取总分拣 总共分播了{0}条记录" , j ) ) ;
dt = lpp . getFlows4ZhitongSeedsOut ( ) ;
isByCust = false ;
j = 0 ;
foreach ( DataRow dr in dt . Rows )
{
j + = testDoSeedsOut ( dr [ "flowNo" ] . ToString ( ) , isByCust ) ;
isByCust = ! isByCust ;
}
logTest . Debug ( string . Format ( "直通分货 总共分播了{0}条记录" , j ) ) ;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
int testDoSeedsOut ( string flowNo , bool isByCust )
{
string batch = "" , toFlowNo = "" , custId = "" ;
int outDetailId = 0 ;
decimal seedCnt = 0 m ;
DataTable dt = lpp . getSeedsPickDetail ( flowNo , isByCust ) ; //容器的拣货明细
int f = new Random ( ) . Next ( 1000 ) ;
int i = 0 ;
Dictionary < string , string > map = new Dictionary < string , string > ( ) ;
foreach ( DataRow dr in dt . Rows )
{
custId = dr [ "customerId" ] . ToString ( ) ;
if ( map . Keys . Contains ( custId ) )
{
toFlowNo = map [ custId ] ;
}
else
{
toFlowNo = String . Format ( "t{0}-{1}" , f , i ) ;
map . Add ( custId , toFlowNo ) ;
}
batch = dr [ "batch" ] . ToString ( ) ;
outDetailId = Convert . ToInt32 ( dr [ "outDetailId" ] . ToString ( ) ) ;
decimal wantCount = Convert . ToDecimal ( dr [ "wantCount" ] . ToString ( ) ) ;
2023-11-21 19:18:23 +08:00
string prdDate = dr [ "productDate" ] . ToString ( ) ;
int skuId = Convert . ToInt32 ( dr [ "skuId" ] . ToString ( ) ) ;
int inDetailId = Convert . ToInt32 ( dr [ "inDetailId" ] . ToString ( ) ) ;
2023-09-04 22:41:19 +08:00
seedCnt = Convert . ToDecimal ( dr [ "availablecnt" ] . ToString ( ) ) ;
seedCnt = ( wantCount < = seedCnt ) ? wantCount : seedCnt ;
if ( seedCnt < = 0 )
{
continue ;
}
2024-02-06 19:36:47 +08:00
enumRepResult rt = lpp . seedsPickOut ( flowNo , skuId , prdDate , batch , outDetailId , seedCnt , toFlowNo , inDetailId , false ) ;
2023-09-04 22:41:19 +08:00
if ( rt = = enumRepResult . 成 功 )
{
i + + ;
}
else
{
logTest . Debug ( rt ) ;
}
if ( i > limit )
{
2023-11-21 19:18:23 +08:00
// logTest.Debug(string.Format("总共分播了{0}条记录", i));
2023-09-04 22:41:19 +08:00
return i ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return i ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
//---test plate
public void inPlateTest ( )
{
try
{
// public static bool TEST_PLATE_OUT_CUSTOMER;
// public static bool TEST_PLATE_OUT_LINE;
// public static bool TEST_PLATE_OUT_VC;
if ( WmsConstants . TEST_PLATE_OUT_CUSTOMER )
{
logTest . Debug ( string . Format ( " inPlateByCustomerTest cnt: {0}" , inPlateByCustomerTest ( ) ) ) ;
}
} catch ( Exception e )
{
logTest . Error ( e ) ;
}
try
{
if ( WmsConstants . TEST_PLATE_OUT_LINE )
{
logTest . Debug ( string . Format ( " inPlateLineTest cnt: {0}" , inPlateLineTest ( ) ) ) ;
}
}
catch ( Exception e )
{
logTest . Error ( e ) ;
}
try
{
if ( WmsConstants . TEST_PLATE_OUT_VC )
{
logTest . Debug ( string . Format ( " inPlateTranTest cnt: {0}" , inPlateTranTest ( ) ) ) ;
}
}
catch ( Exception e )
{
logTest . Error ( e ) ;
}
try
{
if ( WmsConstants . TEST_PLATE_OUT_LOAD_TRUCK )
{
logTest . Debug ( string . Format ( " loadTruckTest cnt: {0}" , loadTruckTest ( ) ) ) ;
}
}
catch ( Exception e )
{
logTest . Error ( e ) ;
}
try
{
if ( WmsConstants . TEST_PLATE_OUT_START_TRAN )
{
logTest . Debug ( string . Format ( " startTranTest cnt: {0}" , startTranTest ( ) ) ) ;
}
}
catch ( Exception e )
{
logTest . Error ( e ) ;
}
}
/// <summary>
/// 客户集货测试
/// </summary>
/// <returns></returns>
int inPlateByCustomerTest ( )
{
logTest . Debug ( " start inPlateByCustomerTest" ) ;
List < WmsOutPickRequest > requests = new List < WmsOutPickRequest > ( ) ;
List < WmsOutPickPort > listport = new List < WmsOutPickPort > ( ) ;
2024-02-06 19:36:47 +08:00
requests = pickRequestObj . getObjs ( pickRequestObj . getRequests ( enumOutStoreType . 拣 货 出 库 , 2 ) ) ;
2023-11-21 19:18:23 +08:00
List < WmsPlate > plates = new List < WmsPlate > ( ) ;
DataTable dt = new WmsPlate ( ) . QueryActived ( ) . Tables [ 0 ] ;
2024-02-06 19:36:47 +08:00
int i = 0 ;
2023-11-21 19:18:23 +08:00
foreach ( DataRow dr in dt . Rows )
{
2024-02-06 19:36:47 +08:00
WmsPlate p = new WmsPlate ( dr ) ;
if ( p . type = = ( int ) enumPlateLevel . 客 户 集 货 )
{
plates . Add ( new WmsPlate ( dr ) ) ;
i + + ;
}
if ( i = = requests . Count )
{
break ;
}
2023-11-21 19:18:23 +08:00
}
2024-02-06 19:36:47 +08:00
log . Debug ( string . Format ( "客户集货测试 pickrequest cnt {0}, plate cnt {1} " , requests . Count , plates . Count ) ) ;
WmsOutPickPort wpp = new WmsOutPickPort ( ) ;
2023-11-21 19:18:23 +08:00
lWmsPlate lplate = new lWmsPlate ( operId ) ;
2024-02-06 19:36:47 +08:00
i = 0 ;
2023-11-21 19:18:23 +08:00
foreach ( WmsOutPickRequest request in requests )
2024-02-06 19:36:47 +08:00
{
2023-11-21 19:18:23 +08:00
if ( request . orderType ! = ( int ) enumOrderType . 销 售 出 库 | | string . IsNullOrEmpty ( request . customerId ) )
{
continue ;
}
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
WmsPlate p = null ;
foreach ( WmsPlate p1 in plates )
2023-11-21 19:18:23 +08:00
{
2024-02-06 19:36:47 +08:00
if ( p1 . customerId . Equals ( request . customerId ) )
2023-11-21 19:18:23 +08:00
{
2024-02-06 19:36:47 +08:00
p1 . customerId = request . customerId ;
p = p1 ;
break ;
}
}
if ( p = = null )
{
foreach ( WmsPlate p1 in plates )
{
if ( string . IsNullOrEmpty ( p1 . customerId ) )
2023-11-21 19:18:23 +08:00
{
2024-02-06 19:36:47 +08:00
p = p1 ;
break ;
}
}
}
listport = wpp . getObjs ( wpp . getPickDetails ( request . pickOrderNo ) ) ;
log . Debug ( string . Format ( "客户集货测试 pickrequest {0}, list port cnt {1}, to plate {2} " , request . pickOrderNo , listport . Count , p . plateId ) ) ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
foreach ( WmsOutPickPort port in listport )
{
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
enumRegPlateResult rs = lplate . putPlateIntoPlate ( port . flowNo , p . plateId ) ;
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
if ( rs = = enumRegPlateResult . 成 功 )
{
i + + ;
2023-11-21 19:18:23 +08:00
}
2024-02-06 19:36:47 +08:00
log . Debug ( string . Format ( "客户集货测试 pickrequest {0}, fromPlate {1}, toPlate {2}, result{3}" , request . pickOrderNo , port . flowNo , p . plateId , rs ) ) ;
}
p . customerId = request . customerId ;
2023-11-21 19:18:23 +08:00
}
logTest . Debug ( " end inPlateByCustomerTest" ) ;
return i ;
}
/// <summary>
/// 线路集货测试
/// </summary>
/// <returns></returns>
int inPlateLineTest ( )
{
int i = 0 ;
logTest . Debug ( " start inPlateLineTest" ) ;
List < WmsPlate > plates = new List < WmsPlate > ( ) ;
List < WmsPlate > linePlates = new List < WmsPlate > ( ) ;
DataTable dt = new WmsPlate ( ) . QueryActived ( ) . Tables [ 0 ] ;
lWmsPlate lplate = new lWmsPlate ( operId ) ;
foreach ( DataRow dr in dt . Rows )
{
plates . Add ( new WmsPlate ( dr ) ) ;
}
foreach ( WmsPlate p in plates )
{
if ( p . type = = ( int ) enumPlateLevel . 线 路 集 货 )
{
linePlates . Add ( p ) ;
}
}
foreach ( WmsPlate p2 in linePlates )
{
foreach ( WmsPlate p in plates )
{
if ( ! string . IsNullOrEmpty ( p . customerId ) & & p . type = = ( int ) enumPlateLevel . 客 户 集 货 )
{
enumRegPlateResult rs = lplate . putPlateIntoPlate ( p . plateId , p2 . plateId ) ;
logTest . Debug ( string . Format ( " from plate {0},线路集货结果: {1}" , p . plateId , rs ) ) ;
if ( rs = = enumRegPlateResult . 成 功 )
{
i + + ;
}
}
}
}
logTest . Debug ( "end inPlateLineTest" ) ;
return i ;
}
int inPlateTranTest ( )
{
int i = 0 ;
logTest . Debug ( "start inPlateTranTest()" ) ;
List < WmsPlate > plates = new List < WmsPlate > ( ) ;
List < WmsPlate > vPlates = new List < WmsPlate > ( ) ;
DataTable dt = new WmsPlate ( ) . QueryActived ( ) . Tables [ 0 ] ;
lWmsPlate lplate = new lWmsPlate ( operId ) ;
foreach ( DataRow dr in dt . Rows )
{
plates . Add ( new WmsPlate ( dr ) ) ;
}
foreach ( WmsPlate p in plates )
{
if ( p . type = = ( int ) enumPlateLevel . 运 输 车 )
{
vPlates . Add ( p ) ;
}
}
foreach ( WmsPlate p2 in vPlates )
{
foreach ( WmsPlate p in plates )
{
if ( p . type = = ( int ) enumPlateLevel . 线 路 集 货 )
{
enumRegPlateResult rs = lplate . putPlateIntoPlate ( p . plateId , p2 . plateId ) ;
logTest . Debug ( string . Format ( " from plate {0},装车集货结果: {1}" , p . plateId , rs ) ) ;
if ( rs = = enumRegPlateResult . 成 功 )
{
i + + ;
}
}
}
}
logTest . Debug ( "end inPlateTranTest()" ) ;
return i ;
}
/// <summary>
/// 装车测试
/// </summary>
/// <returns></returns>
int loadTruckTest ( )
{
int i = 0 ;
logTest . Debug ( " start loadTruckTest" ) ;
List < WmsPlate > plates = new List < WmsPlate > ( ) ;
List < WmsPlate > truckPlates = new List < WmsPlate > ( ) ;
DataTable dt = new WmsPlate ( ) . QueryActived ( ) . Tables [ 0 ] ;
lWmsPlate lplate = new lWmsPlate ( operId ) ;
foreach ( DataRow dr in dt . Rows )
{
plates . Add ( new WmsPlate ( dr ) ) ;
}
foreach ( WmsPlate p in plates )
{
if ( p . type = = ( int ) enumPlateLevel . 运 输 车 )
{
truckPlates . Add ( p ) ;
}
}
foreach ( WmsPlate p2 in truckPlates )
{
foreach ( WmsPlate p in plates )
{
if ( ! string . IsNullOrEmpty ( p . customerId ) & & p . type = = ( int ) enumPlateLevel . 客 户 集 货 )
{
enumRegPlateResult rs = lplate . loadTruck ( p . plateId , p2 . plateId ) ;
2024-02-06 19:36:47 +08:00
logTest . Debug ( string . Format ( " from plate {0} , to plate {2},装车结果: {1}" , p . plateId , rs , p2 . plateId ) ) ;
2023-11-21 19:18:23 +08:00
if ( rs = = enumRegPlateResult . 成 功 )
{
i + + ;
}
}
}
}
logTest . Debug ( "end loadTruckTest" ) ;
return i ;
}
int startTranTest ( )
{
int i = 0 ;
logTest . Debug ( " start startTranTest" ) ;
List < WmsPlate > plates = new List < WmsPlate > ( ) ;
List < WmsPlate > truckPlates = new List < WmsPlate > ( ) ;
DataTable dt = new WmsPlate ( ) . QueryActived ( ) . Tables [ 0 ] ;
lWmsPlate lplate = new lWmsPlate ( operId ) ;
foreach ( DataRow dr in dt . Rows )
{
plates . Add ( new WmsPlate ( dr ) ) ;
}
foreach ( WmsPlate p in plates )
{
if ( p . type = = ( int ) enumPlateLevel . 运 输 车 )
{
truckPlates . Add ( p ) ;
}
}
foreach ( WmsPlate p2 in truckPlates )
2024-02-06 19:36:47 +08:00
{
logTest . Debug ( " truck plate id " + p2 . plateId ) ;
2023-11-21 19:18:23 +08:00
logTest . Debug ( " test startTran, result " + lplate . startTran ( p2 . plateId ) ) ;
}
logTest . Debug ( "end startTranTest" ) ;
return i ;
}
}
}