2023-05-23 16:13:17 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///LOGIC CLASS FOR TABLE t_wmsInRequest
|
|
|
|
|
///By wm with codesmith.
|
|
|
|
|
///on 05/12/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.Data.BaseObject;
|
|
|
|
|
using DeiNiu.Utils;
|
|
|
|
|
//using Microsoft.Reporting.WinForms;
|
|
|
|
|
namespace DeiNiu.wms.Logical
|
|
|
|
|
{
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class lWmsInRequest : lbase
|
|
|
|
|
{
|
|
|
|
|
WmsInRequest _obj;
|
|
|
|
|
WmsStock _stkObj;
|
|
|
|
|
// private int p;
|
|
|
|
|
Erp_purch _erpPurchObj;
|
|
|
|
|
Erp_purch_ship _erpPurchShipObj;
|
|
|
|
|
Erp_purch_receive_pre _preInObj = new Erp_purch_receive_pre();
|
|
|
|
|
public Erp_purch_receive_pre preInObj
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_preInObj == null)
|
|
|
|
|
{
|
|
|
|
|
_preInObj = new Erp_purch_receive_pre();
|
|
|
|
|
_preInObj.operater = this.operId;
|
|
|
|
|
}
|
|
|
|
|
return _preInObj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Erp_purch_ship erpPurchShipObj
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_erpPurchShipObj == null)
|
|
|
|
|
{
|
|
|
|
|
_erpPurchShipObj = new Erp_purch_ship();
|
|
|
|
|
_erpPurchShipObj.operater = this.operId;
|
|
|
|
|
}
|
|
|
|
|
return _erpPurchShipObj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public WmsStock stkObj
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_stkObj == null)
|
|
|
|
|
{
|
|
|
|
|
_stkObj = new WmsStock();
|
|
|
|
|
_stkObj.operater = this.operId;
|
|
|
|
|
}
|
|
|
|
|
return _stkObj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public Erp_purch erpPurchObj
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_erpPurchObj == null)
|
|
|
|
|
{
|
|
|
|
|
_erpPurchObj = new Erp_purch();
|
|
|
|
|
_erpPurchObj.operater = this.operId;
|
|
|
|
|
}
|
|
|
|
|
return _erpPurchObj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public lWmsInRequest()
|
|
|
|
|
{
|
|
|
|
|
initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public lWmsInRequest(int p):base(p)
|
|
|
|
|
{
|
|
|
|
|
initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WmsInRequest getWmsInRequest
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get all data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DataSet getAllData()
|
|
|
|
|
{
|
|
|
|
|
return _obj.Query();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get all data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DataSet getAllActiveData()
|
|
|
|
|
{
|
|
|
|
|
return _obj.QueryActived();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override BaseModel getModel()
|
|
|
|
|
{
|
|
|
|
|
return _obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get a record by id
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void initialize(int id)
|
|
|
|
|
{
|
|
|
|
|
_obj = id != 0 ? new WmsInRequest(id) : new WmsInRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get a record by id 0
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void initialize()
|
|
|
|
|
{
|
|
|
|
|
initialize(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get a record by id
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void initialize(DataRow dr)
|
|
|
|
|
{
|
|
|
|
|
_obj = new WmsInRequest(dr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//begin cust db operation, query, excute sql etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get in_stock request in a transaction scope
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
public void syncOrders()
|
|
|
|
|
{
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_obj.syncInRequest();
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private bool valid()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool requestInStock(string orderNo)
|
|
|
|
|
{
|
|
|
|
|
return requestInStock(new WmsInRequest(orderNo));
|
|
|
|
|
}
|
|
|
|
|
public bool requestInStock(WmsInRequest requestOrder)
|
|
|
|
|
{
|
|
|
|
|
// printStockIn(orderNo);
|
|
|
|
|
|
|
|
|
|
requestOrder.operater = this.operId;
|
|
|
|
|
if (requestOrder.ID == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
//throw new DeiNiuException(requestOrder.orderNo + " 不存在");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (requestOrder.state == (int)enumInStockOrderStatus.已入库)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
// throw new DeiNiuException(requestOrder.orderNo + " 已经入库");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//入库前检查产品生产日期,有效期
|
|
|
|
|
bool isDateInvalid = false;
|
|
|
|
|
|
|
|
|
|
foreach (WmsInRequestDetail requestDetail in requestOrder.inDetails)
|
|
|
|
|
{
|
|
|
|
|
if (requestDetail.state == (int)enumInStockDetailStatus.已分配货位)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (requestDetail.whType == (int)enumWhType.不合格库)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
requestDetail.operater = this.operId;
|
|
|
|
|
|
|
|
|
|
if (!checkAndUpdateValidDate(requestDetail)) //生产日期,有效期错误
|
|
|
|
|
{
|
|
|
|
|
isDateInvalid = true;
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.日期错误;
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (isDateInvalid)
|
|
|
|
|
{
|
|
|
|
|
requestOrder.state = (int)enumInStockOrderStatus.订单明细日期错误;
|
|
|
|
|
requestOrder.Update();
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
|
|
|
|
|
{
|
|
|
|
|
IsolationLevel = System.Transactions.IsolationLevel.Serializable,
|
|
|
|
|
Timeout = new TimeSpan(0, 10, 0)
|
|
|
|
|
}
|
|
|
|
|
))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (WmsInRequestDetail requestDetail in requestOrder.inDetails)
|
|
|
|
|
{
|
|
|
|
|
if (requestDetail.state == (int)enumInStockDetailStatus.已分配货位)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
requestDetail.operater = this.operId;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
requestDetailIn( requestOrder,requestDetail);
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException nfe)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
scope.Dispose();
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.货位不足; ;
|
|
|
|
|
requestDetail.description = nfe.Message;
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
requestOrder.state = (int)enumInStockOrderStatus.货位不足;
|
|
|
|
|
requestOrder.Update();
|
|
|
|
|
throw nfe;
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuException er)
|
|
|
|
|
{
|
|
|
|
|
scope.Dispose();
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.出现错误; ;
|
|
|
|
|
requestDetail.description = er.Message;
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
requestOrder.state = (int)enumInStockOrderStatus.待上架;
|
|
|
|
|
requestOrder.Update();
|
|
|
|
|
throw er;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception err)
|
|
|
|
|
{
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requestOrder.state = (int)enumInStockOrderStatus.已入库;
|
|
|
|
|
requestOrder.Update();
|
|
|
|
|
if (!WmsConstants.IN_STOCK_RECEIVE_VALID) //不启用验收模块,则一次入库完毕。
|
|
|
|
|
{
|
|
|
|
|
erpPurchObj.updateStockStatus(requestOrder.orderNo, enumInStockOrderStatus.已入库,
|
|
|
|
|
enumReceiveStockDetailStatus.待上架,operId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Erp_purch ep = new Erp_purch(requestOrder.orderNo);
|
|
|
|
|
|
|
|
|
|
if (ep.wms_state == (int)enumInStockOrderStatus.已验收) //入库单明细全部完成验收后
|
|
|
|
|
{
|
|
|
|
|
ep.wms_state = (int)enumInStockOrderStatus.已入库;
|
|
|
|
|
ep.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// Erp_purch_d epd = new Erp_purch_d();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
//if (requestOrder.orderType == (int)enumInOrderType.purOrder)
|
|
|
|
|
//{
|
|
|
|
|
// // printStockIn(requestOrder.orderNo);
|
|
|
|
|
//}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
private void requestDetailIn(WmsInRequest requestOrder, WmsInRequestDetail requestDetail, int recommandWareHouse = 0)
|
|
|
|
|
{
|
|
|
|
|
enumWhType whType = (enumWhType)requestDetail.whType;
|
|
|
|
|
|
|
|
|
|
if (whType == enumWhType.不合格库)
|
|
|
|
|
{
|
|
|
|
|
//Wmslocation location = new Wmslocation();
|
|
|
|
|
|
|
|
|
|
// List<Wmslocation> locs = location.geLocations(enumWhType.不合格库);
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.入不合格区;
|
|
|
|
|
requestDetail.description = "已入不合格区";
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (whType == enumWhType.越仓收货区)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
zhitongIn(requestDetail);
|
|
|
|
|
}
|
|
|
|
|
else if (goodsInStock(requestDetail, recommandWareHouse))
|
|
|
|
|
{
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.已分配货位;
|
|
|
|
|
requestDetail.countIn = requestDetail.validCount;
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
|
|
|
|
|
updateErpDetail(requestDetail);
|
|
|
|
|
}
|
|
|
|
|
else //if(WmsConstants.IN_STOCK_ONE_TIME)
|
|
|
|
|
{
|
|
|
|
|
throw new DeiNiuException("入库异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void zhitongIn(WmsInRequestDetail requestDetail)
|
|
|
|
|
{
|
|
|
|
|
WmsStockPre wsp = new WmsStockPre();
|
|
|
|
|
wsp.orderno = requestDetail.orderNo;
|
|
|
|
|
wsp.orderDetailId = requestDetail.ID;
|
|
|
|
|
wsp.partion = requestDetail.partion;
|
|
|
|
|
wsp.skuCode = requestDetail.skuCode;
|
|
|
|
|
wsp.skuId = requestDetail.skuId;
|
|
|
|
|
wsp.batch = requestDetail.batch;
|
|
|
|
|
wsp.productDate = requestDetail.productDate;
|
|
|
|
|
wsp.validDate = requestDetail.validDate;
|
|
|
|
|
wsp.count = requestDetail.validCount;
|
|
|
|
|
wsp.goodsId = requestDetail.goodsId;
|
|
|
|
|
wsp.Add();
|
|
|
|
|
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.入越仓收货区;
|
|
|
|
|
requestDetail.countIn = requestDetail.validCount;
|
|
|
|
|
requestDetail.description = "已入越库区";
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
updateErpDetail(requestDetail);
|
|
|
|
|
logStock(requestDetail, null, wsp.count, enumInStoreType.直通越仓, wsp);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新入库数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestDetail"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool updateErpDetail(WmsInRequestDetail requestDetail)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!WmsConstants.IN_STOCK_RECEIVE_VALID)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable dt = erpPurchObj.getValidedInDetail(requestDetail.orderNo, (int)enumReceiveStockDetailStatus.已验收);
|
|
|
|
|
|
|
|
|
|
decimal inCnt = requestDetail.validCount;//.countIn;
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
Erp_receiveValidDetail evd = new Erp_receiveValidDetail(dr);
|
|
|
|
|
|
|
|
|
|
if (evd.goods_id == requestDetail.goodsId
|
|
|
|
|
&& evd.batch == requestDetail.batch
|
|
|
|
|
&& evd.productDate == requestDetail.productDate
|
|
|
|
|
&& evd.validDate == requestDetail.validDate)
|
|
|
|
|
{
|
|
|
|
|
evd.inCount = evd.valid_count < inCnt ? evd.valid_count : inCnt;
|
|
|
|
|
|
|
|
|
|
inCnt -= evd.inCount;
|
|
|
|
|
|
|
|
|
|
evd.operater = this.operId;
|
|
|
|
|
evd.wms_state = (int)enumReceiveStockDetailStatus.待上架;
|
|
|
|
|
evd.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inCnt <= 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新上架数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestDetail"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
bool updateErpDetail(int detailId)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.debug(GetType(), "updateErpDetail ? " + detailId);
|
|
|
|
|
WmsInRequestDetail requestDetail = new WmsInRequestDetail(detailId);
|
|
|
|
|
decimal upShelfCnt = requestDetail.countIn;//.countIn;
|
|
|
|
|
// DataTable dt = erpPurchObj.getValidedInDetail(requestDetail.orderNo, (int)enumReceiveStockDetailStatus.待上架);
|
|
|
|
|
Erp_receiveValidDetail evd = new Erp_receiveValidDetail(requestDetail.validId);
|
|
|
|
|
evd.upShelfCount += upShelfCnt;
|
|
|
|
|
evd.operater = this.operId;
|
|
|
|
|
evd.wms_state = (int)enumReceiveStockDetailStatus.已上架;
|
|
|
|
|
evd.Update();
|
|
|
|
|
LogHelper.debug(GetType(), "updateErpDetail ? upShelfCnt is " + upShelfCnt + ", erp_receiveValidDetail updated ");
|
|
|
|
|
|
|
|
|
|
new Erp_purch_receive_pre().upShelfCount(evd.preInOrder, requestDetail.purch_d_id, upShelfCnt, operId);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
DataTable dt = new Erp_receiveValidDetail().getDetailByFlowNo(requestDetail.preInOrder, requestDetail.flowNo);
|
|
|
|
|
|
|
|
|
|
DataView dv = dt.DefaultView;
|
|
|
|
|
dv.RowFilter = "skuId=" + requestDetail.skuId;
|
|
|
|
|
LogHelper.debug(GetType(), "updateErpDetail ? filter by skuId" + requestDetail.skuId +", erp_receiveValidDetail count is " + dv.Count);
|
|
|
|
|
decimal upShelfCnt = requestDetail.countIn;//.countIn;
|
|
|
|
|
foreach (DataRowView dr in dv)
|
|
|
|
|
{
|
|
|
|
|
Erp_receiveValidDetail evd = new Erp_receiveValidDetail(dr.Row);
|
|
|
|
|
|
|
|
|
|
// evd.upShelfCount = evd.inCount < upShelfCnt ? evd.inCount : upShelfCnt;
|
|
|
|
|
evd.upShelfCount += upShelfCnt;
|
|
|
|
|
// upShelfCnt -= evd.inCount;
|
|
|
|
|
evd.operater = this.operId;
|
|
|
|
|
evd.wms_state = (int)enumReceiveStockDetailStatus.已上架;
|
|
|
|
|
evd.Update();
|
|
|
|
|
LogHelper.debug(GetType(), "updateErpDetail ? upShelfCnt is " + upShelfCnt + ", erp_receiveValidDetail updated ");
|
|
|
|
|
|
|
|
|
|
new Erp_purch_receive_pre().upShelfCount(evd.preInOrder, requestDetail.purch_d_id, upShelfCnt, operId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
/// WmsInRequest wir = new WmsInRequest(requestDetail.orderNo);
|
|
|
|
|
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(requestDetail.purch_d_id);
|
|
|
|
|
epd.onShelfCount += upShelfCnt;
|
|
|
|
|
if (epd.onShelfCount >= epd.validCount && epd.wms_state == (int)enumReceiveStockDetailStatus.已验收)
|
|
|
|
|
{
|
|
|
|
|
epd.wms_state =(int)enumReceiveStockDetailStatus.已上架;
|
|
|
|
|
}
|
|
|
|
|
epd.operater = operId;
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
DataTable dtDetails = erpPurchObj.getOrderDetail(requestDetail.orderNo);
|
|
|
|
|
DataView dvDetail = dtDetails.DefaultView;
|
|
|
|
|
dvDetail.RowFilter = "wms_state<" + (int)enumReceiveStockDetailStatus.已上架;
|
|
|
|
|
if (dvDetail.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
_erpPurchObj = new Erp_purch(requestDetail.orderNo);
|
|
|
|
|
_erpPurchObj.wms_state = (int)enumInStockOrderStatus.已上架;
|
|
|
|
|
_erpPurchObj.operater = operId;
|
|
|
|
|
_erpPurchObj.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// erpPurchObj.updateStockStatus(requestDetail.orderNo, (enumInStockOrderStatus)wir.state, enumReceiveStockDetailStatus.已上架, operId);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if(wir.state == (int)enumInStockOrderStatus.已上架 ){
|
|
|
|
|
|
|
|
|
|
erpPurchObj.updateStockStatus(requestDetail.orderNo, enumInStockOrderStatus.已上架, enumReceiveStockDetailStatus.已上架,operId);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
dt = erpPurchObj.getValidedInDetail(requestDetail.orderNo, (int)enumReceiveStockDetailStatus.待上架);
|
|
|
|
|
if (dt.Rows.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
_erpPurchObj = new Erp_purch(requestDetail.orderNo);
|
|
|
|
|
|
|
|
|
|
erpPurchObj.wms_state = (int)enumInStockOrderStatus.已上架;
|
|
|
|
|
|
|
|
|
|
erpPurchObj.Update();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool checkAndUpdateValidDate(WmsInRequestDetail requestDetail)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string productDate = requestDetail.productDate.Trim();
|
|
|
|
|
string validDate = requestDetail.validDate.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] invailidChars = { ".","-","/"};
|
|
|
|
|
|
|
|
|
|
foreach (string s in invailidChars)
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.GOODS_VALID_DATE_FORMAT.IndexOf(s) == -1)
|
|
|
|
|
{
|
|
|
|
|
productDate = productDate.Replace(s, "");
|
|
|
|
|
validDate = validDate.Replace(s, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (productDate.Length < 6 || productDate.Length > 8 || validDate.Length < 6 || validDate.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.IN_STOCK_CHECK_DATE)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
productDate += productDate.Length == 6 ? "28" : "";
|
|
|
|
|
validDate += validDate.Length == 6 ? "01" : "";
|
|
|
|
|
DateTime dtprd, dtvlid;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dtprd = DateTime.ParseExact(productDate, WmsConstants.GOODS_VALID_DATE_FORMAT, System.Globalization.CultureInfo.CurrentCulture);
|
|
|
|
|
dtvlid = DateTime.ParseExact(validDate, WmsConstants.GOODS_VALID_DATE_FORMAT, System.Globalization.CultureInfo.CurrentCulture);
|
|
|
|
|
|
|
|
|
|
if (WmsConstants.IN_STOCK_CHECK_DATE && dtvlid <= DateTime.Now)
|
|
|
|
|
{
|
|
|
|
|
requestDetail.description = "产品过期";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
requestDetail.productDate = dtprd.ToString(WmsConstants.GOODS_VALID_DATE_FORMAT);
|
|
|
|
|
requestDetail.validDate = dtvlid.ToString(WmsConstants.GOODS_VALID_DATE_FORMAT);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.IN_STOCK_CHECK_DATE)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requestDetail.state = (int)enumInStockDetailStatus.未分配货位;
|
|
|
|
|
requestDetail.Update();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分配货位入库
|
|
|
|
|
/// 1.整货入整库,整库不能进零货
|
|
|
|
|
///2. WmsConstants.IN_STOCK_CHECK_BULK_FIRST = true: 商品在零库已有零货位存在的情况下,优先补足零货
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestDetail"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool goodsInStock(WmsInRequestDetail requestDetail, int recommandWareHouse = 0)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.debug(this.GetType(),string.Format("request order {0},detail id {1},count{2}"
|
|
|
|
|
, requestDetail.orderNo, requestDetail.ID, requestDetail.orderCount));
|
|
|
|
|
decimal count = requestDetail.validCount - requestDetail.countIn;
|
|
|
|
|
if (count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// WmsGoods goods = ObjectsFactory.getGoods(requestDetail.goodsId, requestDetail.skuId, requestDetail.batch,true);//new WmsGoods(requestDetail.goodsId);
|
|
|
|
|
WmsGoods goods = new WmsGoods(requestDetail.goodsId, requestDetail.skuId, requestDetail.batch);
|
|
|
|
|
WmsStock stock = new WmsStock();
|
|
|
|
|
|
|
|
|
|
int goodType = goods.goodsType;
|
|
|
|
|
string goodsId = goods.goodsId;
|
|
|
|
|
string batch = requestDetail.batch;
|
|
|
|
|
int skuId = requestDetail.skuId;
|
|
|
|
|
string skuCode = requestDetail.skuCode;
|
|
|
|
|
|
|
|
|
|
if (skuId >0 && string.IsNullOrEmpty(skuCode))
|
|
|
|
|
{
|
|
|
|
|
Sku sku = new Sku(skuId);
|
|
|
|
|
if (sku.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
requestDetail.skuCode = skuCode = sku.skuCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal bigCount = goods.bigCount;
|
|
|
|
|
//decimal boxCount = 0; //箱数
|
|
|
|
|
decimal bulkCnt = 0;
|
|
|
|
|
decimal batch1Cnt = 0;
|
|
|
|
|
decimal batch2Cnt = 0;
|
|
|
|
|
decimal batch3Cnt = 0;
|
|
|
|
|
decimal bulkCntFromBatch = 0;
|
|
|
|
|
|
|
|
|
|
decimal bulkMax = goods.bulkMax;
|
|
|
|
|
decimal batchMax1 = goods.batchMax1;
|
|
|
|
|
decimal batchMax2 = goods.batchMax2;
|
|
|
|
|
decimal batchMax3 = goods.batchMax3;
|
|
|
|
|
// decimal stockCnt =0;
|
|
|
|
|
|
|
|
|
|
if (bigCount == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw new DeiNiuException(string.Format("请维护 '{0}' 的大包装数量", requestDetail.goodsName));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (goodType == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw new DeiNiuException(string.Format("请维护 '{0}' 的商品类型", requestDetail.goodsName));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//现在默认 每种商品 在零货位上的最大容量为 1.3箱 小整4箱 大整 20
|
|
|
|
|
//一箱 是指一个大包装量(erp bigCount)
|
|
|
|
|
bulkMax = bulkMax > 0 ? bulkMax : bigCount * WmsConstants.BULK_MAX_RATE;
|
|
|
|
|
batchMax1 = batchMax1 > 0 ? batchMax1 : bigCount * WmsConstants.BATCH1_MAX_RATE;
|
|
|
|
|
batchMax2 = batchMax2 > 0 ? batchMax2 : bigCount * WmsConstants.BATCH2_MAX_RATE;
|
|
|
|
|
batchMax3 = batchMax3 > 0 ? batchMax3 : bigCount * WmsConstants.BATCH3_MAX_RATE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//boxCount = count / bigCount ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal boxcnt = 0m;
|
|
|
|
|
|
|
|
|
|
// boxcnt = Math.Floor(count / bigCount);
|
|
|
|
|
|
|
|
|
|
// bulkCnt = count - boxcnt * bigCount;
|
|
|
|
|
|
|
|
|
|
bulkCnt = count % bigCount; //取余数,不足箱部分
|
|
|
|
|
|
|
|
|
|
count -= bulkCnt;
|
|
|
|
|
|
|
|
|
|
count = count > 0 ? count : 0;
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if ( WmsConstants.IN_STOCK_CHECK_BULK_FIRST
|
|
|
|
|
&& goods.bulkMax >=0 //只有对设置零库库容的商品有效
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
decimal tmp = 0m;
|
|
|
|
|
|
|
|
|
|
//优先补足零库
|
|
|
|
|
DataTable dt0;
|
|
|
|
|
// dt0 = stock.queryByGoodsIdVolType(skuId,skuCode,goods.goodsId, requestDetail.batch, enumWhLocVol.零库, enumWhType.合格库);
|
|
|
|
|
dt0 = stock.queryByGoodsIdVolType(0, "", goods.goodsId, requestDetail.batch, enumWhLocVol.零库,
|
|
|
|
|
(enumWhType)requestDetail.whType);//库容按商品ID,不是按skuId
|
|
|
|
|
//计算补零货数
|
|
|
|
|
foreach (DataRow dr in dt0.Rows)
|
|
|
|
|
{
|
|
|
|
|
stock = new WmsStock(dr);
|
|
|
|
|
decimal onShelfCnt = stock.count - stock.countOut;
|
|
|
|
|
onShelfCnt = onShelfCnt > 0 ? onShelfCnt : 0;
|
|
|
|
|
tmp += onShelfCnt ;// - stock.countLock;
|
|
|
|
|
|
|
|
|
|
if (WmsConstants.IN_STOCK_PDA_SCAN)
|
|
|
|
|
{
|
|
|
|
|
tmp += stock.countIn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal diff = bulkMax - tmp;
|
|
|
|
|
if (diff > 0) //需要补
|
|
|
|
|
{
|
|
|
|
|
if (diff > bulkCnt ) //需要拆箱补货
|
|
|
|
|
{
|
|
|
|
|
if ( WmsConstants.IN_STOCK_DIFF_PARTS) //同一组验收数量可进不同货区
|
|
|
|
|
{
|
|
|
|
|
decimal cnt = Math.Ceiling((diff - bulkCnt) / bigCount) * bigCount;
|
|
|
|
|
cnt = cnt > count ? count : cnt;
|
|
|
|
|
bulkCnt += cnt;
|
|
|
|
|
count -= cnt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
bulkCnt += tmp >= bulkMax ? 0 //零库充足,不补
|
|
|
|
|
: bulkMax - (tmp + bulkCnt) ; //补充部分
|
|
|
|
|
bulkCnt = Math.Ceiling(bulkCnt / bigCount) * bigCount; //成箱补充
|
|
|
|
|
bulkCnt = bulkCnt > count ? count : bulkCnt;
|
|
|
|
|
count = count - bulkCnt;
|
|
|
|
|
count = count > 0 ? count : 0;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boxcnt = Math.Floor(count / bigCount);
|
|
|
|
|
|
|
|
|
|
if (count > batchMax1) //入整库
|
|
|
|
|
{
|
|
|
|
|
if (count > batchMax2)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
batch3Cnt = count;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
batch2Cnt = count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
batch1Cnt = count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (count >= batchMax1) //入整库
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (count >= batchMax2) //入大整
|
|
|
|
|
{
|
|
|
|
|
boxcnt = Math.Floor(count / batchMax2);
|
|
|
|
|
batch2Cnt = boxcnt * batchMax2;
|
|
|
|
|
|
|
|
|
|
batch1Cnt = count - batch2Cnt;
|
|
|
|
|
|
|
|
|
|
boxcnt = Math.Floor(batch1Cnt / batchMax1);
|
|
|
|
|
batch1Cnt = boxcnt * batchMax1;
|
|
|
|
|
|
|
|
|
|
// batch2Cnt = count;
|
|
|
|
|
}
|
|
|
|
|
else //入小整
|
|
|
|
|
{
|
|
|
|
|
boxcnt = Math.Floor(count / batchMax1);
|
|
|
|
|
batch1Cnt = boxcnt * batchMax1; ;
|
|
|
|
|
|
|
|
|
|
//batch1Cnt = count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//剩余有零货的话则入零货
|
|
|
|
|
bulkCnt += count - batch2Cnt - batch1Cnt;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else //入零库
|
|
|
|
|
{
|
|
|
|
|
bulkCnt += count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
LogHelper.debug(this.GetType(),string.Format("入库数量 大整:{0},小整:{1},零货:{2}", batch2Cnt, batch1Cnt, bulkCnt));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (orderType == enumInOrderType.repOrderIn) //处理补零入库单
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
batch2Cnt = 0;
|
|
|
|
|
bulkCnt = requestDetail.validCount - requestDetail.countIn;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
DataTable dt = stock.querySameGoodsLocations( goods.goodsId,skuId,requestDetail.batch
|
|
|
|
|
, (enumWhType)requestDetail.whType, recommandWareHouse);
|
|
|
|
|
Dictionary<WmsStock, decimal> locsUpdate = new Dictionary<WmsStock, decimal>();
|
|
|
|
|
|
|
|
|
|
Dictionary<WmsStock, decimal> locsBulk = new Dictionary<WmsStock, decimal>();
|
|
|
|
|
Dictionary<WmsStock, decimal> locsBatch1 = new Dictionary<WmsStock, decimal>();
|
|
|
|
|
Dictionary<WmsStock, decimal> locsBatch2 = new Dictionary<WmsStock, decimal>();
|
|
|
|
|
Dictionary<WmsStock, decimal> locsBatch3= new Dictionary<WmsStock, decimal>();
|
|
|
|
|
string lastBatch3Location = "";
|
|
|
|
|
string lastBatch2Location = "";
|
|
|
|
|
string lastBatch1Location = "";
|
|
|
|
|
string lastBulkLocation = "";
|
|
|
|
|
string lastLoc = "";
|
|
|
|
|
//计算补货货位及数量
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
stock = new WmsStock(dr);
|
|
|
|
|
if (lastLoc == "")
|
|
|
|
|
{
|
|
|
|
|
lastLoc = stock.locationId;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (lastLoc.Equals(stock.locationId))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
lastLoc = stock.locationId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stock = new WmsStock(dr);
|
|
|
|
|
if(WmsConstants.IN_STOCK_ABC && stock.location.ABC !=goods.ABC){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enumWhLocStoreType stype = (enumWhLocStoreType)Convert.ToInt16(dr["storeType"].ToString());
|
|
|
|
|
switch (stype)
|
|
|
|
|
{
|
|
|
|
|
case enumWhLocStoreType.同品同批:
|
|
|
|
|
if (stock.batch != batch || stock.skuId != skuId)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case enumWhLocStoreType.混品同批:
|
|
|
|
|
if (stock.batch != batch || stock.skuId != skuId)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal existCnt = stock.count + stock.countIn - stock.countOut;// -stock.countOuting;// - stock.countLock;
|
|
|
|
|
existCnt = existCnt > 0 ? existCnt : 0;
|
|
|
|
|
|
|
|
|
|
LogHelper.debug(this.GetType(), string.Format("现有库存 {0}, skuid {1}, 数量{2}",
|
|
|
|
|
stock.locationId, stock.skuId, existCnt));
|
|
|
|
|
|
|
|
|
|
int locVolType = Convert.ToInt32(dr[WmsLocation.fields.volType.ToString()].ToString());
|
|
|
|
|
decimal goodsMaxcnt = goods.getMaxCount(locVolType);
|
|
|
|
|
|
|
|
|
|
enumWhLocVol volType = (enumWhLocVol)locVolType;
|
|
|
|
|
|
|
|
|
|
decimal freeCntCapicity = Math.Ceiling((1 - stock.getUsedPercent(lastLoc)) * goodsMaxcnt);
|
|
|
|
|
LogHelper.debug(this.GetType(), string.Format("可用容量 {0} ",freeCntCapicity ));
|
|
|
|
|
if (freeCntCapicity <= 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
switch (volType)
|
|
|
|
|
{ //当前货位类型
|
|
|
|
|
|
|
|
|
|
case enumWhLocVol.零库:
|
|
|
|
|
|
|
|
|
|
lastBulkLocation = stock.locationId;
|
|
|
|
|
|
|
|
|
|
if (bulkCnt == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bulkCnt <= freeCntCapicity)
|
|
|
|
|
{
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), bulkCnt);
|
|
|
|
|
bulkCnt = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), freeCntCapicity);
|
|
|
|
|
bulkCnt -= freeCntCapicity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if (existCnt < goodsMaxcnt ) //补充货位 仅适合单品单批
|
|
|
|
|
{
|
|
|
|
|
lastBulkLocation = stock.locationId;
|
|
|
|
|
decimal c = goodsMaxcnt - existCnt;
|
|
|
|
|
|
|
|
|
|
if (c < bulkCnt) // 需要新货位
|
|
|
|
|
{
|
|
|
|
|
bulkCnt -= c; //补现有货位后,剩余的入新货位
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
c = bulkCnt;
|
|
|
|
|
bulkCnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
locsUpdate.Add(new WmsStock(stock.goodsId, stock.batch,stock.locationId), c);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case enumWhLocVol.小整:
|
|
|
|
|
|
|
|
|
|
lastBatch1Location = stock.locationId;
|
|
|
|
|
if (batch1Cnt == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (batch1Cnt <= freeCntCapicity)
|
|
|
|
|
{
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), batch1Cnt);
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
decimal buchongCount = Math.Floor(freeCntCapicity / bigCount) * bigCount;//补整箱
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), buchongCount);
|
|
|
|
|
batch1Cnt -= buchongCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*if (existCnt < goodsMaxcnt) //补充货位
|
|
|
|
|
{
|
|
|
|
|
lastBatch1Location = stock.locationId;
|
|
|
|
|
decimal buchongCount = goodsMaxcnt - existCnt;
|
|
|
|
|
|
|
|
|
|
if (buchongCount < batch1Cnt) // 需要新货位
|
|
|
|
|
{
|
|
|
|
|
buchongCount = Math.Floor(buchongCount / bigCount) * bigCount;//补整箱
|
|
|
|
|
|
|
|
|
|
batch1Cnt -= buchongCount; //补现有货位后,剩余的入新货位
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buchongCount = batch1Cnt;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// locsBatch1.Add(new WmsStock(stock.locationId), c);
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), buchongCount);
|
|
|
|
|
}
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case enumWhLocVol.中整:
|
|
|
|
|
lastBatch2Location = stock.locationId;
|
|
|
|
|
if (batch2Cnt == 0)
|
|
|
|
|
{
|
|
|
|
|
/*if (batch1Cnt > 0 && WmsConstants.IN_STOCK_BIG_LOCATION_FIRST)//优先补大货位
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
if (batch1Cnt <= 0
|
|
|
|
|
|| !WmsConstants.IN_STOCK_BIG_LOCATION_FIRST)//优先补大货位
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existCnt < goodsMaxcnt) //补充货位
|
|
|
|
|
{
|
|
|
|
|
lastBatch2Location = stock.locationId;
|
|
|
|
|
decimal maxCount = goodsMaxcnt - existCnt;
|
|
|
|
|
maxCount = Math.Floor(maxCount / bigCount) * bigCount;//补整箱
|
|
|
|
|
decimal buchongCount = maxCount;// -batch2Cnt;
|
|
|
|
|
|
|
|
|
|
if (batch2Cnt >= maxCount ) // 需要新货位
|
|
|
|
|
{
|
|
|
|
|
batch2Cnt -= maxCount; //补现有货位后,剩余的入新货位
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else //大整数量全部补充货位
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
buchongCount = batch2Cnt;// maxCount - batch2Cnt;
|
|
|
|
|
|
|
|
|
|
if (batch1Cnt > 0 && WmsConstants.IN_STOCK_BIG_LOCATION_FIRST) //优先补大货位
|
|
|
|
|
{
|
|
|
|
|
if (batch1Cnt > maxCount - buchongCount) //小整补完大整货位仍有余
|
|
|
|
|
{
|
|
|
|
|
batch1Cnt -= maxCount - buchongCount;
|
|
|
|
|
buchongCount = maxCount;
|
|
|
|
|
}
|
|
|
|
|
else //小整全部补大整
|
|
|
|
|
{
|
|
|
|
|
// maxCount = batch1Cnt + batch2Cnt;
|
|
|
|
|
|
|
|
|
|
buchongCount = batch1Cnt + batch2Cnt;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch2Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// locsBatch2.Add(new WmsStock(stock.locationId), c);
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), buchongCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case enumWhLocVol.大整:
|
|
|
|
|
|
|
|
|
|
lastBatch3Location = stock.locationId;
|
|
|
|
|
if (batch3Cnt == 0)
|
|
|
|
|
{
|
|
|
|
|
if (batch2Cnt <= 0
|
|
|
|
|
|| !WmsConstants.IN_STOCK_BIG_LOCATION_FIRST)//优先补大货位
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existCnt < goodsMaxcnt) //补充货位
|
|
|
|
|
{
|
|
|
|
|
lastBatch3Location = stock.locationId;
|
|
|
|
|
decimal maxCount = goodsMaxcnt - existCnt;
|
|
|
|
|
maxCount = Math.Floor(maxCount / bigCount) * bigCount;//补整箱
|
|
|
|
|
decimal buchongCount = maxCount;// -batch2Cnt;
|
|
|
|
|
|
|
|
|
|
if (batch3Cnt >= maxCount ) // 需要新货位
|
|
|
|
|
{
|
|
|
|
|
batch3Cnt -= maxCount; //补现有货位后,剩余的入新货位
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else //大整数量全部补充货位
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
buchongCount = batch3Cnt;// maxCount - batch2Cnt;
|
|
|
|
|
|
|
|
|
|
if (batch2Cnt > 0 && WmsConstants.IN_STOCK_BIG_LOCATION_FIRST) //优先补大货位
|
|
|
|
|
{
|
|
|
|
|
if (batch2Cnt > maxCount - buchongCount) //小整补完大整货位仍有余
|
|
|
|
|
{
|
|
|
|
|
batch2Cnt -= maxCount - buchongCount;
|
|
|
|
|
buchongCount = maxCount;
|
|
|
|
|
}
|
|
|
|
|
else //小整全部补大整
|
|
|
|
|
{
|
|
|
|
|
// maxCount = batch1Cnt + batch2Cnt;
|
|
|
|
|
|
|
|
|
|
buchongCount = batch2Cnt + batch3Cnt;
|
|
|
|
|
batch2Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch3Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// locsBatch2.Add(new WmsStock(stock.locationId), c);
|
|
|
|
|
locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), buchongCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stockCnt += cnt;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//入大整
|
|
|
|
|
|
|
|
|
|
WmsLocation nearLocation = new WmsLocation();
|
|
|
|
|
nearLocation.warehouse = recommandWareHouse;
|
|
|
|
|
nearLocation.goodsType = goods.goodsType;
|
|
|
|
|
nearLocation.ABC = goods.ABC;
|
|
|
|
|
nearLocation.ownerCode = requestDetail.entid;// goods.ownerCode; //可能多货主共享商品id
|
|
|
|
|
Dictionary<WmsLocation, Decimal> locs2add = new Dictionary<WmsLocation, decimal>();
|
|
|
|
|
|
|
|
|
|
int locCnt = 1;
|
|
|
|
|
|
|
|
|
|
if (batch3Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
nearLocation.locationId = lastBatch3Location;
|
|
|
|
|
decimal cnt = batch3Cnt / batchMax3;
|
|
|
|
|
locCnt = (int)Math.Ceiling(cnt);//有余数则会进一位
|
|
|
|
|
|
|
|
|
|
nearLocation.volType = (int)enumWhLocVol.大整;
|
|
|
|
|
List<WmsLocation> locs = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
locs = nearLocation.getFreeLocation(nearLocation, (enumWhType)requestDetail.whType, locCnt);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException er) //大整货位不足
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
batch2Cnt += batch3Cnt;
|
|
|
|
|
// batch2Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (locs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsLocation loc in locs)
|
|
|
|
|
{
|
|
|
|
|
decimal c2 = batch3Cnt > batchMax3 ? batchMax3 : batch3Cnt;
|
|
|
|
|
// locsBatch2.Add(loc, c2);
|
|
|
|
|
locs2add.Add(loc, c2);
|
|
|
|
|
batch3Cnt -= batchMax3;
|
|
|
|
|
if (batch3Cnt < 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (batch3Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
batch2Cnt += batch3Cnt; ////大整货位不足,入小整
|
|
|
|
|
// batch2Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (batch2Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
nearLocation.locationId = lastBatch2Location;
|
|
|
|
|
decimal cnt = batch2Cnt / batchMax2;
|
|
|
|
|
locCnt = (int)Math.Ceiling(cnt);//有余数则会进一位
|
|
|
|
|
|
|
|
|
|
nearLocation.volType = (int)enumWhLocVol.中整;
|
|
|
|
|
List<WmsLocation> locs = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
locs = nearLocation.getFreeLocation(nearLocation, (enumWhType)requestDetail.whType, locCnt);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException er) //大整货位不足
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
batch1Cnt += batch2Cnt;
|
|
|
|
|
// batch2Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (locs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsLocation loc in locs)
|
|
|
|
|
{
|
|
|
|
|
decimal c2 = batch2Cnt > batchMax2 ? batchMax2 : batch2Cnt;
|
|
|
|
|
// locsBatch2.Add(loc, c2);
|
|
|
|
|
locs2add.Add(loc, c2);
|
|
|
|
|
batch2Cnt -= batchMax2;
|
|
|
|
|
if (batch2Cnt < 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (batch2Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
batch1Cnt += batch2Cnt; ////大整货位不足,入小整
|
|
|
|
|
// batch2Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (batch1Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
decimal cnt = batch1Cnt / batchMax1;
|
|
|
|
|
locCnt = (int)Math.Ceiling(cnt);
|
|
|
|
|
nearLocation.locationId = lastBatch1Location;
|
|
|
|
|
nearLocation.volType = (int)enumWhLocVol.小整;
|
|
|
|
|
List<WmsLocation> locs = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
locs = nearLocation.getFreeLocation(nearLocation, (enumWhType)requestDetail.whType, locCnt);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException er) //小整货位不足
|
|
|
|
|
{
|
|
|
|
|
bulkCntFromBatch +=batch1Cnt;
|
|
|
|
|
//bulkCnt += batch1Cnt;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (locs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsLocation loc in locs)
|
|
|
|
|
{
|
|
|
|
|
decimal c1 = batch1Cnt > batchMax1 ? batchMax1 : batch1Cnt;
|
|
|
|
|
// locsBatch1.Add(loc.locationId, c1);
|
|
|
|
|
locs2add.Add(loc, c1);
|
|
|
|
|
batch1Cnt -= batchMax1;
|
|
|
|
|
if (batch1Cnt < 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (batch1Cnt > 0 )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (batch2Cnt > 0) //大整货位不足,入零库
|
|
|
|
|
{
|
|
|
|
|
bulkCntFromBatch += batch1Cnt;
|
|
|
|
|
// bulkCnt += batch1Cnt;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ //入大整
|
|
|
|
|
batch2Cnt = batch1Cnt;
|
|
|
|
|
nearLocation.volType = (int)enumWhLocVol.中整;
|
|
|
|
|
nearLocation.locationId = lastBatch2Location;
|
|
|
|
|
cnt = batch2Cnt / batchMax2;
|
|
|
|
|
locCnt = (int)Math.Ceiling(cnt);//有余数则会进一位
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
locs = nearLocation.getFreeLocation(nearLocation, (enumWhType)requestDetail.whType, locCnt);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException er) //大小整货位不足
|
|
|
|
|
{
|
|
|
|
|
bulkCntFromBatch += batch1Cnt;
|
|
|
|
|
// bulkCnt += batch1Cnt;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (locs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsLocation loc in locs)
|
|
|
|
|
{
|
|
|
|
|
decimal c2 = batch2Cnt > batchMax2 ? batchMax2 : batch2Cnt;
|
|
|
|
|
// locsBatch2.Add(loc, c2);
|
|
|
|
|
locs2add.Add(loc, c2);
|
|
|
|
|
batch2Cnt -= batchMax2;
|
|
|
|
|
if (batch2Cnt < 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (batch2Cnt > 0)
|
|
|
|
|
{
|
|
|
|
|
bulkCntFromBatch += batch1Cnt;
|
|
|
|
|
//bulkCnt += batch2Cnt; ////大小整货位不足,入零库
|
|
|
|
|
// batch2Cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch3Cnt = 0;
|
|
|
|
|
batch2Cnt = 0;
|
|
|
|
|
batch1Cnt = 0;
|
|
|
|
|
|
|
|
|
|
//如果不允许整货入零库则报异常
|
|
|
|
|
if (!WmsConstants.IN_STOCK_NO_BATCH_LOCATION_IN_BULK && bulkCntFromBatch > 0)
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.NO_FREE_LOCATION_USE_TMP)
|
|
|
|
|
{
|
|
|
|
|
WmsLocation loc = new WmsLocation();
|
|
|
|
|
loc.locationId = WmsConstants.TMP_BATCH_LOCATION;
|
|
|
|
|
locs2add.Add(loc, bulkCntFromBatch);
|
|
|
|
|
bulkCntFromBatch = 0;
|
|
|
|
|
}else
|
|
|
|
|
// string msg = string.Format("{0}", location);
|
|
|
|
|
throw new DeiNiuNoFreeLocationkException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bulkCnt += bulkCntFromBatch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bulkCnt > 0)
|
|
|
|
|
{
|
|
|
|
|
decimal cnt = bulkCnt / bulkMax;
|
|
|
|
|
locCnt = (int)Math.Ceiling(cnt);
|
|
|
|
|
|
|
|
|
|
nearLocation.volType = (int)enumWhLocVol.零库;
|
|
|
|
|
nearLocation.locationId = lastBulkLocation;
|
|
|
|
|
List<WmsLocation> locs = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
locs = nearLocation.getFreeLocation(nearLocation, (enumWhType)requestDetail.whType, locCnt);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (DeiNiuNoFreeLocationkException er) //零货位不足
|
|
|
|
|
{
|
|
|
|
|
// throw er;
|
|
|
|
|
}
|
|
|
|
|
if (locs != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (WmsLocation loc in locs)
|
|
|
|
|
{
|
|
|
|
|
decimal c = bulkCnt > bulkMax ? bulkMax : bulkCnt;
|
|
|
|
|
//locsBulk .Add(loc.locationId, c );
|
|
|
|
|
locs2add.Add(loc, c);
|
|
|
|
|
bulkCnt -= bulkMax;
|
|
|
|
|
if (bulkCnt < 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//bulkCnt += 500;//for debug
|
|
|
|
|
if (bulkCnt > 0) //get locations from other sharing locations
|
|
|
|
|
{
|
|
|
|
|
// string msg = string.Format("{0}", location);
|
|
|
|
|
decimal goodsMaxcnt = goods.getMaxCount((int)enumWhLocVol.零库);
|
|
|
|
|
|
|
|
|
|
locCnt = (int)Math.Ceiling(bulkCnt / goodsMaxcnt) * 50;
|
|
|
|
|
dt = stock.queryOtherSharingLocations(goods, (int)enumWhLocVol.零库, locCnt,
|
|
|
|
|
(enumWhType)requestDetail.whType);
|
|
|
|
|
lastLoc = "";
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
stock = new WmsStock(dr);
|
|
|
|
|
if (lastLoc == "")
|
|
|
|
|
{
|
|
|
|
|
lastLoc = stock.locationId;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (lastLoc.Equals(stock.locationId))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
lastLoc = stock.locationId;
|
|
|
|
|
|
|
|
|
|
lastBulkLocation = stock.locationId;
|
|
|
|
|
|
|
|
|
|
decimal freeCntCapicity = Math.Ceiling((1 - Convert.ToDecimal(dr["usedPercent"].ToString())) * goodsMaxcnt);
|
|
|
|
|
|
|
|
|
|
if (freeCntCapicity <= 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bulkCnt > freeCntCapicity)
|
|
|
|
|
{
|
|
|
|
|
//locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), freeCntCapicity);
|
|
|
|
|
locs2add.Add(new WmsLocation( stock.locationId) , freeCntCapicity);
|
|
|
|
|
bulkCnt -= freeCntCapicity;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// locsUpdate.Add(new WmsStock( stock.locationId,stock.skuId), bulkCnt);
|
|
|
|
|
locs2add.Add(new WmsLocation(stock.locationId), bulkCnt);
|
|
|
|
|
bulkCnt = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bulkCnt > 0)
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.NO_FREE_LOCATION_USE_TMP)
|
|
|
|
|
{
|
|
|
|
|
WmsLocation loc = new WmsLocation();
|
|
|
|
|
loc.locationId = WmsConstants.TMP_BULK_LOCATION;
|
|
|
|
|
locs2add.Add(loc, bulkCnt);
|
|
|
|
|
bulkCnt = 0;
|
|
|
|
|
}else
|
|
|
|
|
throw new DeiNiuNoFreeLocationkException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var item in locs2add)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
stock = new WmsStock();
|
|
|
|
|
stock.locationId = item.Key.locationId;
|
|
|
|
|
|
|
|
|
|
if (WmsConstants.IN_STOCK_PDA_SCAN)
|
|
|
|
|
{
|
|
|
|
|
stock.countIn += item.Value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stock.count = item.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stock.goodsId = requestDetail.goodsId;
|
|
|
|
|
stock.batch = requestDetail.batch;
|
|
|
|
|
stock.productDate = requestDetail.productDate;
|
|
|
|
|
stock.validDate = requestDetail.validDate;
|
|
|
|
|
stock.validationTerm = 1;
|
|
|
|
|
stock.operater = this.operId;
|
2023-05-23 23:33:56 +08:00
|
|
|
|
stock.state = (int)enumStockLocationStatus.正常;
|
2023-05-23 16:13:17 +08:00
|
|
|
|
stock.skuCode = skuCode;
|
|
|
|
|
stock.skuId = skuId;
|
|
|
|
|
stock.maintainDate = stock.getDateTime();
|
|
|
|
|
if (String.IsNullOrEmpty(stock.batch))
|
|
|
|
|
{
|
|
|
|
|
stock.batch = requestDetail.productDate ;
|
|
|
|
|
}
|
|
|
|
|
stock.Add();
|
|
|
|
|
logStock(requestDetail, stock, item.Value, enumInStoreType.普通入库);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// to update location count in stock
|
|
|
|
|
|
|
|
|
|
// Dictionary<WmsStock, decimal> locsUpdateStock = new Dictionary<WmsStock, decimal>();
|
|
|
|
|
// locsBatch1.Union(locsBatch2).Union(locsBulk); //合并
|
|
|
|
|
//locsUpdateStock.Concat(locsBatch1).Concat(locsBatch2).Concat(locsBulk); //合并
|
|
|
|
|
// mergeDictionary(locsBulk, mergeDictionary(locsBatch2, mergeDictionary(locsBatch1, locsUpdateStock)));
|
|
|
|
|
|
|
|
|
|
foreach (var item in locsUpdate)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
stock = item.Key;
|
|
|
|
|
if (WmsConstants.IN_STOCK_PDA_SCAN)
|
|
|
|
|
{
|
|
|
|
|
stock.countIn += item.Value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stock.count += item.Value;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stock.operater = this.operId;
|
|
|
|
|
stock.Update();
|
|
|
|
|
logStock(requestDetail, stock, item.Value, enumInStoreType.普通入库);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return batch2Cnt + batch1Cnt + bulkCnt <= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal enumRepResult newBarcode(string goodsId, string barcode,decimal packingQty,decimal chang,decimal kuan,decimal gao,decimal weight)
|
|
|
|
|
{
|
|
|
|
|
ErpGoods goods = new ErpGoods(goodsId);
|
|
|
|
|
if( goods.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
if (String.IsNullOrEmpty(goods.barCode))
|
|
|
|
|
{
|
|
|
|
|
goods.barCode = barcode;
|
|
|
|
|
goods.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable dt = new Erp_packing().queryByGoodsId(goodsId);
|
|
|
|
|
DataView dv = dt.DefaultView;
|
|
|
|
|
dv.RowFilter = "barcode='" + barcode + "'";
|
|
|
|
|
if (dv.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Erp_packing ep = new Erp_packing();
|
|
|
|
|
ep.goodsId = goodsId;
|
|
|
|
|
ep.packingQty = packingQty;
|
|
|
|
|
ep.chang = chang;
|
|
|
|
|
ep.kuan = kuan;
|
|
|
|
|
ep.gao = gao;
|
|
|
|
|
ep.weight = weight;
|
|
|
|
|
ep.Add();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return enumRepResult.成功;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return enumRepResult.失败;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal enumRepResult zhiTongSeedOut(int outDetailId, int inDetailId, decimal seedCnt)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail(inDetailId);
|
|
|
|
|
WmsOutDetail wod = new WmsOutDetail(outDetailId);
|
|
|
|
|
wod.pickCount += seedCnt;
|
|
|
|
|
wid.receiveCount += seedCnt;
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
wod.Update();
|
|
|
|
|
wid.Update();
|
|
|
|
|
WmsStockRecord wsr = new WmsStockRecord();
|
|
|
|
|
wsr.orderNo = wod.orderNo;
|
|
|
|
|
wsr.orderDetailId = wod.ID;
|
|
|
|
|
wsr.goodsId = wid.goodsId;
|
|
|
|
|
wsr.count = seedCnt;
|
|
|
|
|
wsr.locationId = wid.partion+"";
|
|
|
|
|
wsr.Add();
|
|
|
|
|
|
|
|
|
|
WmsOutPickPort wop = new WmsOutPickPort();
|
|
|
|
|
wop.recordId = wsr.ID;
|
|
|
|
|
wop.pickBy = operId;
|
|
|
|
|
wop.pickTime = wop.getDateTime();
|
|
|
|
|
wop.partion = wid.partion;
|
|
|
|
|
wop.pickCount = seedCnt;
|
|
|
|
|
wop.pickOrderNo = wid.pickOrderNo;
|
|
|
|
|
wop.state = (int)enumPickState.已拣;
|
|
|
|
|
wop.recType = (int)enumStockRecordType.直通越仓;
|
|
|
|
|
wop.Add();
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return enumRepResult.成功;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
private Dictionary<string, decimal> addLocsUpdate(Dictionary<string, decimal> locsUpdate, string locationId, decimal count)
|
|
|
|
|
{
|
|
|
|
|
if (locsUpdate.Keys.Contains(locationId))
|
|
|
|
|
{
|
|
|
|
|
locsUpdate[locationId] += count;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
locsUpdate[locationId] = count;
|
|
|
|
|
}
|
|
|
|
|
return locsUpdate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Dictionary<WmsStock, decimal> mergeDictionary(Dictionary<WmsStock, decimal> dic1, Dictionary<WmsStock, decimal> dicto)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsStock key in dic1.Keys)
|
|
|
|
|
{
|
|
|
|
|
dicto[key] = dic1[key];
|
|
|
|
|
}
|
|
|
|
|
return dicto;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private void logStock(WmsInRequestDetail request, WmsStock stock, decimal count,
|
|
|
|
|
enumInStoreType inStoreType, WmsStockPre stockPre = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WmsStockRecord r = new WmsStockRecord();
|
|
|
|
|
r.batch = request.batch.Trim();
|
|
|
|
|
if (WmsConstants.IN_STOCK_PDA_SCAN)
|
|
|
|
|
{
|
|
|
|
|
r.countIn = count;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
r.count = count;
|
|
|
|
|
}
|
|
|
|
|
int recType =(int)enumStockRecordType.普通入库;
|
|
|
|
|
if (inStoreType == enumInStoreType.普通入库)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (inStoreType == enumInStoreType.直通越仓)
|
|
|
|
|
{
|
|
|
|
|
recType = (int)enumStockRecordType.直通越仓;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.goodsId = request.goodsId.Trim();
|
|
|
|
|
if (stock != null)
|
|
|
|
|
{
|
|
|
|
|
WmsLocation loc = new WmsLocation(stock.locationId.Trim());
|
|
|
|
|
if (loc.part > 0) {
|
|
|
|
|
Node nd = new Node(loc.part);
|
|
|
|
|
r.partion = nd.flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r.locationId = stock.locationId.Trim();
|
|
|
|
|
r.productDate = stock.productDate;
|
|
|
|
|
r.validDate = stock.validDate;
|
|
|
|
|
}
|
|
|
|
|
if (stockPre != null)
|
|
|
|
|
{
|
|
|
|
|
r.locationId = stockPre.partion+"";
|
|
|
|
|
r.productDate = stockPre.productDate;
|
|
|
|
|
r.validDate = stockPre.validDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.orderNo = request.orderNo.Trim();
|
|
|
|
|
r.regeditCode = request.regeditCode.Trim();
|
|
|
|
|
r.rectype = recType;//in
|
|
|
|
|
r.operater = this.operId;
|
|
|
|
|
r.skuCode = request.skuCode;
|
|
|
|
|
r.skuId = request.skuId;
|
|
|
|
|
r.orderDetailId = request.ID;
|
|
|
|
|
r.Add();
|
|
|
|
|
if ( WmsConstants.IN_STOCK_PDA_SCAN)
|
|
|
|
|
{
|
|
|
|
|
WmsInUpPort inPort = new WmsInUpPort();
|
|
|
|
|
|
|
|
|
|
inPort.count = count;
|
|
|
|
|
inPort.orderNo = request.orderNo;
|
|
|
|
|
inPort.locationId = r.locationId;//stock.locationId;
|
|
|
|
|
inPort.recordId = r.ID;
|
|
|
|
|
inPort.detailId = request.ID;
|
|
|
|
|
inPort.productDate = r.productDate;
|
|
|
|
|
inPort.validDate = r.validDate;
|
|
|
|
|
inPort.goodsId = r.goodsId;
|
|
|
|
|
inPort.batch = r.batch;
|
|
|
|
|
inPort.recType = r.rectype;
|
|
|
|
|
inPort.operater = this.operId;
|
|
|
|
|
inPort.state =(int) enumInStockDetailStatus.已分配货位;
|
|
|
|
|
inPort.skuCode = request.skuCode;
|
|
|
|
|
inPort.skuId = request.skuId;
|
|
|
|
|
inPort.flowNo = request.flowNo;
|
|
|
|
|
inPort.inPreOrder = request.preInOrder;
|
|
|
|
|
inPort.partion = r.partion;
|
|
|
|
|
inPort.Add();
|
|
|
|
|
|
|
|
|
|
//add up shelf task
|
|
|
|
|
string jobNo = Util.getOrderNo(enumCreateOrderType.preInOrder, _obj.getNextSeq(enumCreateOrderType.preInOrder));
|
|
|
|
|
WmsFlow wmsflow = new WmsFlow();
|
|
|
|
|
wmsflow.operater = operId;
|
|
|
|
|
wmsflow.orderNo = r.orderNo;
|
|
|
|
|
wmsflow.type = (int)Util.getTaskType(inPort.recType);
|
|
|
|
|
wmsflow.task = jobNo;
|
|
|
|
|
// wmsflow.fromPartion = inPort.partion;
|
|
|
|
|
wmsflow.toPartion = inPort.partion;
|
|
|
|
|
wmsflow.taskPartion = inPort.partion;
|
|
|
|
|
wmsflow.Add();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool deleteInRequest(string orderNo)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequest inr = new WmsInRequest(orderNo);
|
|
|
|
|
bool r = false;
|
|
|
|
|
if ((enumInStockOrderStatus)inr.state == enumInStockOrderStatus.已入库)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
r= inr.deleteRequest(orderNo);
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// PDA入库上架单列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flowNo">预打印的上架流水号 </param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable getPortStockInDetailsByFlowNo(string flowNo)
|
|
|
|
|
{
|
|
|
|
|
//return getWmsInRequest.getStockInDetail(id);
|
|
|
|
|
return getWmsInRequest.getInPortDetails( flowNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// PDA入库上架单明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="portId">上架 port Id </param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable getPortStockInDetailByPortId(int portId)
|
|
|
|
|
{
|
|
|
|
|
//return getWmsInRequest.getStockInDetail(id);
|
|
|
|
|
return getWmsInRequest.getInPortDetail(portId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal enumRepResult finishUpShelfItem(string flowNo, int portId, decimal count, string locationId, string reason)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WmsInUpPort inPort = new WmsInUpPort(portId);
|
|
|
|
|
|
|
|
|
|
if (count<=0)
|
|
|
|
|
{
|
|
|
|
|
return enumRepResult.上架数量错误;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inPort.state == (int)enumInStockDetailStatus.上架完成)
|
|
|
|
|
{
|
|
|
|
|
return enumRepResult.状态已完成上架;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inPort.upCount += count;
|
|
|
|
|
|
|
|
|
|
if (inPort.upCount > inPort.count)
|
|
|
|
|
{
|
|
|
|
|
return enumRepResult.上架数量大于应上数量;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string description = string.Format("\n type:{0},目标货位{1},实际货位{2} 上架数量{3}, 备注:{4}",
|
|
|
|
|
inPort.recType,inPort.locationId,locationId, count, reason);
|
|
|
|
|
|
|
|
|
|
LogHelper.debug(GetType(), description);
|
|
|
|
|
|
|
|
|
|
WmsStockRecord sr1 = new WmsStockRecord();
|
|
|
|
|
sr1.count = count;
|
|
|
|
|
sr1.count1 = inPort.upCount;
|
|
|
|
|
sr1.goodsId = inPort.goodsId;
|
|
|
|
|
sr1.batch = inPort.batch;
|
|
|
|
|
sr1.skuId = inPort.skuId;
|
|
|
|
|
sr1.skuCode = inPort.skuCode;
|
|
|
|
|
sr1.description = description;
|
|
|
|
|
sr1.orderNo = inPort.orderNo;
|
|
|
|
|
sr1.operater = operId;
|
|
|
|
|
sr1.rectype = inPort.recType;
|
|
|
|
|
sr1.productDate = inPort.productDate;
|
|
|
|
|
sr1.validDate = inPort.validDate;
|
|
|
|
|
sr1.locationId = locationId;
|
|
|
|
|
sr1.skuCode = inPort.skuCode;
|
|
|
|
|
sr1.skuId = inPort.skuId;
|
|
|
|
|
sr1.orderDetailId = inPort.detailId;
|
|
|
|
|
WmsStock stk = new WmsStock( inPort.locationId,inPort.skuId); //
|
|
|
|
|
lWmsStock lsk = new lWmsStock(operId);
|
|
|
|
|
enumRepResult rp = lsk.validLocation(locationId, inPort.goodsId, inPort.skuId, inPort.batch, inPort.count);
|
|
|
|
|
if (rp != enumRepResult.成功)
|
|
|
|
|
{
|
|
|
|
|
return rp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stk.ID == 0)
|
|
|
|
|
{
|
|
|
|
|
stk.skuCode = inPort.skuCode;
|
|
|
|
|
stk.goodsId = inPort.goodsId;
|
|
|
|
|
stk.skuId = inPort.skuId;
|
|
|
|
|
stk.locationId = locationId;
|
|
|
|
|
stk.batch = inPort.batch;
|
|
|
|
|
stk.productDate = inPort.productDate;
|
|
|
|
|
stk.validDate = inPort.validDate;
|
|
|
|
|
stk.maintainDate = stk.getDateTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//WmsStock stk2; ;
|
|
|
|
|
stk.operater = operId;
|
|
|
|
|
stk.countIn -= count;
|
|
|
|
|
stk.countIn = stk.countIn > 0 ? stk.countIn : 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (locationId == inPort.locationId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
stk.count += count;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
inPort.description += string.Format(";{0}:{1}:{2}:{3}", locationId, count,operId, DateTime.Now);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
enumRepResult result = enumRepResult.成功;
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
if (0 < inPort.upCount && inPort.upCount < inPort.count)
|
|
|
|
|
{
|
|
|
|
|
inPort.state = (int)enumInStockDetailStatus.部分上架;
|
|
|
|
|
}
|
|
|
|
|
else if (inPort.upCount == inPort.count)
|
|
|
|
|
{
|
|
|
|
|
inPort.state = (int)enumInStockDetailStatus.上架完成;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
inPort.Update();
|
|
|
|
|
sr1.Add();
|
|
|
|
|
if (stk.ID == 0)
|
|
|
|
|
{
|
|
|
|
|
stk.Add();
|
|
|
|
|
}
|
|
|
|
|
if (locationId != inPort.locationId) //手工指定货位
|
|
|
|
|
{
|
|
|
|
|
WmsLocation loc = new WmsLocation(locationId);
|
|
|
|
|
|
|
|
|
|
if (loc.ID == 0)
|
|
|
|
|
{
|
|
|
|
|
return enumRepResult.货位不存在;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WmsInUpPort newPort = new WmsInUpPort(inPort.getDetail(inPort.ID).Rows[0]);
|
|
|
|
|
newPort.state = (int)enumInStockDetailStatus.上架完成;
|
|
|
|
|
newPort.count = count;
|
|
|
|
|
newPort.upCount = count;
|
|
|
|
|
newPort.description = description;
|
|
|
|
|
newPort.locationId = locationId;
|
|
|
|
|
newPort.Add();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
WmsStock newStk = new WmsStock( locationId,inPort.skuId);
|
|
|
|
|
|
|
|
|
|
if (newStk.ID == 0) //new one
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
newStk.skuCode = inPort.skuCode;
|
|
|
|
|
newStk.goodsId = inPort.goodsId;
|
|
|
|
|
newStk.skuId = inPort.skuId;
|
|
|
|
|
newStk.locationId = locationId;
|
|
|
|
|
newStk.batch = inPort.batch;
|
|
|
|
|
newStk.productDate = inPort.productDate;
|
|
|
|
|
newStk.validDate = inPort.validDate;
|
|
|
|
|
newStk.maintainDate = newStk.getDateTime();
|
|
|
|
|
newStk.Add();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = new lWmsStock(this.operId).upDownGoodsCountWithLocation(locationId, inPort.goodsId, inPort.skuId, inPort.batch, count, "",
|
|
|
|
|
enumStockRecordType.普通入库, inPort.recordId);
|
|
|
|
|
|
|
|
|
|
if (result != enumRepResult.成功)
|
|
|
|
|
{
|
|
|
|
|
scope.Dispose();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (stk.ID > 0) // always should be existed already.
|
|
|
|
|
stk.updateCountOut();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是否一托货全部完成上架
|
|
|
|
|
/*
|
|
|
|
|
if (inPort.isDoneByFlow(flowNo))
|
|
|
|
|
{
|
|
|
|
|
//free flow number
|
|
|
|
|
// WmsFlow.free(flowNo);
|
|
|
|
|
WmsFlow.done(flowNo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
LogHelper.debug(GetType(), "isDoneByDetailId ? " + inPort.detailId);
|
|
|
|
|
// WmsInRequestDetail requestDetail = new WmsInRequestDetail(inPort.detailId);
|
|
|
|
|
/*
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(new WmsInRequestDetail(inPort.detailId).purch_d_id);
|
|
|
|
|
|
|
|
|
|
epd.onShelfCount += count;
|
|
|
|
|
if (epd.onShelfCount >= epd.validCount && epd.wms_state == (int)enumReceiveStockDetailStatus.已验收)
|
|
|
|
|
{
|
|
|
|
|
epd.wms_state = (int)enumReceiveStockDetailStatus.已上架;
|
|
|
|
|
}
|
|
|
|
|
epd.operater = operId;
|
|
|
|
|
epd.Update();
|
|
|
|
|
*/
|
|
|
|
|
if (inPort.isDoneByDetailId(inPort.detailId))
|
|
|
|
|
{
|
|
|
|
|
LogHelper.debug(GetType(), "isDoneByDetailId ? " + true);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
WmsInRequest wir = new WmsInRequest(inPort.orderNo);
|
|
|
|
|
wir.state = (int)enumInStockOrderStatus.已上架;
|
|
|
|
|
wir.operater = operId;
|
|
|
|
|
wir.Update();
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail(inPort.detailId);
|
|
|
|
|
wid.state = (int)enumInStockDetailStatus.上架完成;
|
|
|
|
|
wid.operater = operId;
|
|
|
|
|
wid.Update();*/
|
|
|
|
|
|
|
|
|
|
getWmsInRequest.finishUpShelf(inPort.orderNo, inPort.detailId,operId); //更新订单及明细状态
|
|
|
|
|
|
|
|
|
|
//更新ERP 上架数据
|
|
|
|
|
updateErpDetail(inPort.detailId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// if (inPort.isDoneByOrderNo(inPort.orderNo))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
return enumRepResult.成功;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 待收货列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="querystr"></param>
|
|
|
|
|
/// <param name="rownumStart"></param>
|
|
|
|
|
/// <param name="rownumEnd"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataSet queryReceives(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.queryReceiveNos(querystr, rownumStart, rownumEnd);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 收货、原始采购订单明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderNo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable getRequestInDetail(string orderNo,int status =-1)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.queryPurchDetail(orderNo,status); ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DataTable getRequestDetailByVender(string venderName, int status = -1)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getRequestDetailByVender(venderName, status); ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 收货、原始采购订单明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderNo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable get4ValidDetail(string orderNo)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.get4ValidDetail(orderNo); ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 记录收货明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="arriveNumber">到货数量</param>
|
|
|
|
|
/// <param name="count">收货数量、拒收数量</param>
|
|
|
|
|
/// <param name="inType">0:收货,1:拒收</param>
|
|
|
|
|
/// <param name="inRemark"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool receiveDetail(string preInNo, int id, decimal arriveNumber, decimal count, int inType, string inRemark,
|
|
|
|
|
int shipId, bool isCache, int cachePartion, decimal temperature = 0 )
|
|
|
|
|
{
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(id);
|
|
|
|
|
|
|
|
|
|
if (epd.count == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal rcNumber =inType == 0?count : 0;
|
|
|
|
|
decimal rjNumber = inType == 1 ? count : 0;
|
|
|
|
|
epd.arriveCount += arriveNumber;
|
|
|
|
|
epd.receiveCount += rcNumber;
|
|
|
|
|
epd.rejectCount += rjNumber;
|
|
|
|
|
|
|
|
|
|
epd.storeType = isCache ? 1 : 0;
|
|
|
|
|
epd.zhitongPartion = cachePartion;
|
|
|
|
|
|
|
|
|
|
enumReceiveStockDetailStatus nextState = enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
|
|
|
|
|
WmsGoods wg = new WmsGoods(epd.goods_id);
|
|
|
|
|
if (!wg.isQc)
|
|
|
|
|
{
|
|
|
|
|
nextState = enumReceiveStockDetailStatus.已验收;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!WmsConstants.IN_STOCK_OVER_RECEIVE)
|
|
|
|
|
{
|
|
|
|
|
epd.receiveCount = epd.receiveCount > epd.count? epd.count: epd.receiveCount ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (epd.receiveCount > 0)
|
|
|
|
|
{
|
|
|
|
|
if (epd.receiveCount + epd.rejectCount >= epd.count) //应收数量计算,包含拒收数量
|
|
|
|
|
{
|
|
|
|
|
epd.wms_state = (int)nextState;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( epd.rejectCount >= epd.count)
|
|
|
|
|
{
|
|
|
|
|
epd.wms_state = (int)enumReceiveStockDetailStatus.拒收;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
epd.operater = this.operId;
|
|
|
|
|
epd.receiveRemark = inRemark;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//add receive log
|
|
|
|
|
|
|
|
|
|
Erp_purch_receive_log erl = new Erp_purch_receive_log();
|
|
|
|
|
erl.preInOrder = preInNo;
|
|
|
|
|
erl.arriveCount = arriveNumber;
|
|
|
|
|
erl.receiveCount = rcNumber;
|
|
|
|
|
erl.rejectCount = rjNumber;
|
|
|
|
|
erl.receiveRemark = inRemark;
|
|
|
|
|
erl.shipId = shipId;
|
|
|
|
|
erl.operater = this.operId;
|
|
|
|
|
erl.pur_order = epd.pur_order;
|
|
|
|
|
erl.purch_d_id = epd.ID;
|
|
|
|
|
erl.temperature = temperature;
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
erl.Add();
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
bool isReject = true;
|
|
|
|
|
bool isAllProceed = true;
|
|
|
|
|
DataTable dt = getRequestInDetail(epd.pur_order);
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToInt16(dr["wms_state"].ToString()) == (int)enumReceiveStockDetailStatus.待收货)
|
|
|
|
|
{
|
|
|
|
|
isAllProceed = false;
|
|
|
|
|
isReject = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isReject = isReject
|
|
|
|
|
&& (Convert.ToInt16(dr["wms_state"].ToString()) == (int)enumReceiveStockDetailStatus.拒收);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// process order
|
|
|
|
|
|
|
|
|
|
Erp_purch ep = new Erp_purch(epd.pur_order);
|
|
|
|
|
ep.operater = this.operId;
|
|
|
|
|
|
|
|
|
|
if (isAllProceed)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ep.wms_state = isReject ? (int)enumInStockOrderStatus.已拒收 : (int)nextState;
|
|
|
|
|
ep.Update();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (rcNumber > 0)
|
|
|
|
|
{
|
|
|
|
|
//ep.wms_state = isReject ? (int)enumInStockOrderStatus.已拒收 : (int)enumInStockOrderStatus.待验收;
|
|
|
|
|
ep.canValid = !isReject; //部分验收
|
|
|
|
|
ep.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//to create/update inRequest,indetail for no qc goods.
|
|
|
|
|
|
|
|
|
|
if (!wg.isQc)
|
|
|
|
|
{
|
|
|
|
|
if ( string.IsNullOrEmpty(epd.batch) || string.IsNullOrEmpty(epd.productDate)||string.IsNullOrEmpty(epd.validDate))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
createInrequest4NoQc((enumInOrderType)ep.orderType, epd, isCache, cachePartion, wg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void createInrequest4NoQc( enumInOrderType orderType, Erp_purch_d epd,bool isCache, int cachePartion, WmsGoods wg)
|
|
|
|
|
{
|
|
|
|
|
StructsValideIn svi = new StructsValideIn();
|
|
|
|
|
|
|
|
|
|
svi.goods_id = epd.goods_id;
|
|
|
|
|
svi.flowNo = epd.ID+"";
|
|
|
|
|
svi.seeds_count = 0;
|
|
|
|
|
svi.valid_count = epd.count;
|
|
|
|
|
|
|
|
|
|
svi.validby = 0;
|
|
|
|
|
svi.validAccount = "";
|
|
|
|
|
svi.validAccount1 = "";
|
|
|
|
|
|
|
|
|
|
svi.reason = "No QC needed.";
|
|
|
|
|
svi.validResult = 0;
|
|
|
|
|
svi.receive_order = epd.pur_order;
|
|
|
|
|
svi.purch_d_id = epd.ID;
|
|
|
|
|
svi.wms_state = (int)enumReceiveStockDetailStatus.已验收;
|
|
|
|
|
svi.batch = "";
|
|
|
|
|
svi.product_date = "";
|
|
|
|
|
svi.save_date = "";
|
|
|
|
|
svi.zhitongPartion = cachePartion;
|
|
|
|
|
svi.validResult = cachePartion > 0 ? (int)enumWhType.越仓收货区 : (int)getWhType(orderType);
|
|
|
|
|
svi.whType = svi.validResult;
|
|
|
|
|
string skuCode = string.Format("{0}:{1};", "goodsId", epd.goods_id);
|
|
|
|
|
int skuId = new lLot().getSKU(skuCode, null, wg.lotId, epd.goods_id, wg.ownerCode);
|
|
|
|
|
|
|
|
|
|
svi.skuCode = skuCode;
|
|
|
|
|
svi.skuId = skuId;
|
|
|
|
|
validIn(svi,true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private enumWhType getWhType(enumInOrderType orderType)
|
|
|
|
|
{
|
|
|
|
|
enumWhType whType = enumWhType.合格库;
|
|
|
|
|
|
|
|
|
|
switch (orderType)
|
|
|
|
|
{
|
|
|
|
|
case enumInOrderType.采购入库:
|
|
|
|
|
whType = enumWhType.合格库;
|
|
|
|
|
break;
|
|
|
|
|
case enumInOrderType.调拨入库:
|
|
|
|
|
whType = enumWhType.合格库;
|
|
|
|
|
break;
|
|
|
|
|
case enumInOrderType.销售退仓:
|
|
|
|
|
whType = enumWhType.退货库;
|
|
|
|
|
break;
|
|
|
|
|
case enumInOrderType.召回返仓:
|
|
|
|
|
whType = enumWhType.合格库;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return whType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// OBSOLETED!!!!!
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderNo"></param>
|
|
|
|
|
/// <param name="inType">收货 or 拒收</param>
|
|
|
|
|
/// <param name="inRemark"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool receiveByOrder(string orderNo, int inType, string inRemark, int shipId, bool isCache, int cachePartion)
|
|
|
|
|
{
|
|
|
|
|
Erp_purch ep = new Erp_purch(orderNo);
|
|
|
|
|
DataTable dt = getRequestInDetail(orderNo);
|
|
|
|
|
decimal rcNumber = 0;
|
|
|
|
|
decimal rjNumber = 0;
|
|
|
|
|
Erp_purch_d epd ;
|
|
|
|
|
bool isNeedQc = false;
|
|
|
|
|
enumReceiveStockDetailStatus nextState = enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
WmsGoods wg;
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
epd = new Erp_purch_d(dr);
|
|
|
|
|
nextState = enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
epd.storeType = isCache ? 0 : 1;
|
|
|
|
|
epd.zhitongPartion = cachePartion;
|
|
|
|
|
|
|
|
|
|
wg = new WmsGoods(epd.goods_id);
|
|
|
|
|
if (!wg.isQc) //跳过验收界面,直接进入入库环节
|
|
|
|
|
{
|
|
|
|
|
nextState = enumReceiveStockDetailStatus.已验收;
|
|
|
|
|
|
|
|
|
|
//create inrequest
|
|
|
|
|
|
|
|
|
|
createInrequest4NoQc((enumInOrderType)ep.orderType,epd, isCache, cachePartion, wg);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isNeedQc = true;
|
|
|
|
|
}
|
|
|
|
|
rcNumber = inType == 0 ? epd.count - epd.receiveCount: 0;
|
|
|
|
|
rjNumber = inType == 1 ? epd.count - epd.receiveCount : 0;
|
|
|
|
|
|
|
|
|
|
epd.arriveCount += rcNumber + rjNumber;
|
|
|
|
|
epd.receiveCount += rcNumber;
|
|
|
|
|
epd.rejectCount += rjNumber;
|
|
|
|
|
epd.wms_state = inType == 0 ? (int)nextState : (int)enumReceiveStockDetailStatus.拒收;
|
|
|
|
|
epd.operater = this.operId;
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Erp_purch_receive_log erl = new Erp_purch_receive_log();
|
|
|
|
|
erl.arriveCount = rcNumber + rjNumber;
|
|
|
|
|
erl.receiveCount = rcNumber;
|
|
|
|
|
erl.rejectCount = rjNumber;
|
|
|
|
|
erl.receiveRemark = inRemark;
|
|
|
|
|
erl.shipId = shipId;
|
|
|
|
|
erl.operater = this.operId;
|
|
|
|
|
erl.pur_order = epd.pur_order;
|
|
|
|
|
erl.purch_d_id = epd.ID;
|
|
|
|
|
erl.Add();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enumInStockOrderStatus nextphState = isNeedQc ? enumInStockOrderStatus.待验收 : enumInStockOrderStatus.已验收;
|
|
|
|
|
|
|
|
|
|
ep.wms_state = inType == 1 ? (int)enumInStockOrderStatus.已拒收 : (int)nextphState;
|
|
|
|
|
ep.operater = this.operId;
|
|
|
|
|
ep.receiveRemark = inRemark;
|
|
|
|
|
ep.Update();
|
|
|
|
|
scope.Complete();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataSet queryValidation(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.queryValidation(querystr, rownumStart, rownumEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable getValidedInDetail(string orderNo, int status =-1)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getValidedInDetail(orderNo, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal bool validIn(StructsValideIn validIn, bool isInStockNow = false, int recommandWareHouse = 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(validIn.purch_d_id);
|
|
|
|
|
Erp_purch ep = new Erp_purch(epd.pur_order);
|
|
|
|
|
epd.validCount += validIn.valid_count;
|
|
|
|
|
decimal acount = epd.count /*-epd.receiveCount*/ -epd.rejectCount;
|
|
|
|
|
epd.wms_state = epd.validCount >= acount /*epd.receiveCount*/ ? (int)enumReceiveStockDetailStatus.已验收 : epd.wms_state;
|
|
|
|
|
epd.operater = this.operId;
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(validIn.batch))
|
|
|
|
|
{
|
|
|
|
|
validIn.batch = validIn.product_date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Erp_receiveValidDetail erd = new Erp_receiveValidDetail();
|
|
|
|
|
erd.flowNo = validIn.flowNo;
|
|
|
|
|
erd.batch = validIn.batch;
|
|
|
|
|
erd.goods_id = validIn.goods_id;
|
|
|
|
|
erd.operater = validIn.validby;// this.operId;
|
|
|
|
|
erd.purch_d_id = validIn.purch_d_id;
|
|
|
|
|
erd.receive_order = validIn.receive_order;
|
|
|
|
|
erd.reason = validIn.reason;
|
|
|
|
|
erd.seeds_count = validIn.seeds_count;
|
|
|
|
|
erd.valid_count = validIn.valid_count;
|
|
|
|
|
erd.productDate = validIn.product_date;
|
|
|
|
|
erd.validDate = validIn.save_date;
|
|
|
|
|
erd.validby = validIn.validby;
|
|
|
|
|
erd.validby1 = validIn.validby1;
|
|
|
|
|
erd.validResult = validIn.validResult;
|
|
|
|
|
erd.whType = validIn.zhitongPartion == 0 ? (int)getWhType((enumInOrderType)ep.orderType) : erd.validResult;
|
|
|
|
|
erd.wms_state = validIn.wms_state;
|
|
|
|
|
erd.erp_state = validIn.erp_state;
|
|
|
|
|
erd.preInOrder = String.IsNullOrEmpty(validIn.preInOrder) ? "" : validIn.preInOrder;
|
|
|
|
|
erd.skuId = validIn.skuId;
|
|
|
|
|
erd.skuCode = validIn.skuCode;
|
|
|
|
|
erd.partion = validIn.zhitongPartion;
|
|
|
|
|
erd.validbyTime = erd.getDateTime();
|
|
|
|
|
erd.validbyTime1 = erd.validbyTime;
|
|
|
|
|
erd.pickorderNo = validIn.pickOrderNo;
|
|
|
|
|
erd.Add();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isAllProceed = true;
|
|
|
|
|
DataTable dt = getRequestInDetail(epd.pur_order);
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
// if (Convert.ToInt16(dr["wms_state"].ToString()) != (int)enumReceiveStockDetailStatus.待入库)
|
|
|
|
|
if (Convert.ToInt16(dr["wms_state"].ToString()) == (int)enumReceiveStockDetailStatus.待验收
|
|
|
|
|
|| Convert.ToInt16(dr["wms_state"].ToString()) == (int)enumReceiveStockDetailStatus.待收货
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
isAllProceed = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAllProceed)
|
|
|
|
|
{
|
|
|
|
|
ep.wms_state = (int)enumInStockOrderStatus.已验收;
|
|
|
|
|
ep.operater = this.operId;
|
|
|
|
|
ep.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//to create/update in stock request in wms.
|
|
|
|
|
|
|
|
|
|
WmsInRequest wir = new WmsInRequest(epd.pur_order);
|
|
|
|
|
|
|
|
|
|
if (wir.ID == 0)
|
|
|
|
|
{
|
|
|
|
|
// create new wmsInRequest
|
|
|
|
|
|
|
|
|
|
dt = ep.getRequestIn(ep.pur_order);
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
wir = new WmsInRequest(dr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wir.operater = this.operId;
|
|
|
|
|
wir.orderType = 0;
|
|
|
|
|
wir.Add();
|
|
|
|
|
}
|
|
|
|
|
wir.state = (int)enumInStockOrderStatus.已验收;
|
|
|
|
|
wir.Update();
|
|
|
|
|
|
|
|
|
|
dt = erd.getRequestValidInDetail(erd.ID); // 一条验收记录对应一个WmsInRequestDetail记录
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail(dr);
|
|
|
|
|
wid.operater = this.operId;
|
|
|
|
|
wid.state = (int)enumInStockDetailStatus.未分配货位;
|
|
|
|
|
wid.entid = epd.entid;
|
|
|
|
|
wid.Add();
|
|
|
|
|
if (isInStockNow)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
requestDetailIn(wir, wid, recommandWareHouse);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception er)
|
|
|
|
|
{
|
|
|
|
|
scope.Dispose();
|
|
|
|
|
throw er;
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable getReceivePreSumByVender(string venderId)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getReceivePreSumByVender(venderId);
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getReceivePreSumByVenderNotValided(string venderId)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getReceivePreSumByVenderNotValided(venderId);
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getReceivePreSumByPreNo(string preNo)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getReceivePreSumByPreNo(preNo);
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getReceiveHistory(string purOrderNo)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getReceiveHistory(purOrderNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal int newShipInfo(structShip ship)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Erp_purch_ship eps = new Erp_purch_ship();
|
|
|
|
|
eps.shipOrder = String.IsNullOrEmpty( ship.shipOrder)?"":ship.shipOrder;
|
|
|
|
|
eps.company = String.IsNullOrEmpty(ship.company) ? "" : ship.company;
|
|
|
|
|
eps.driverID = String.IsNullOrEmpty(ship.driverID) ? "" : ship.driverID;
|
|
|
|
|
eps.driverName = String.IsNullOrEmpty(ship.driverName) ? "" : ship.driverName;
|
|
|
|
|
eps.driverPhone = String.IsNullOrEmpty(ship.driverPhone) ? "" : ship.driverPhone;
|
|
|
|
|
eps.operater = this.operId;
|
|
|
|
|
eps.remark = String.IsNullOrEmpty(ship.remark) ? "" : ship.remark;
|
|
|
|
|
eps.temperature = ship.temperature ;
|
|
|
|
|
eps.veNumber = String.IsNullOrEmpty(ship.veNumber) ? "" : ship.veNumber;
|
|
|
|
|
eps.Add() ;
|
|
|
|
|
return eps.ID;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataSet getShipRecs(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return erpPurchShipObj .QueryPages( querystr, rownumStart, rownumEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataSet getReceiveRecs(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getReceiveRecs( querystr, rownumStart, rownumEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable getShipReceiveDetail(string shipNo)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchShipObj.getShipReceiveDetail(shipNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal DataTable getShipReceiveDetail(int shipId)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchShipObj.getShipReceiveDetail(shipId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable getShipDetail(string shipNo)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchShipObj.getShipDetail(shipNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataSet queryValidationLog(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.queryValidationLog(querystr, rownumStart, rownumEnd);
|
|
|
|
|
}
|
|
|
|
|
//----多笔订单一起验收
|
|
|
|
|
internal string receiveDetailsPre(enumInOrderType ordeType, int[] ids, int shipId,string venderId)
|
|
|
|
|
{ string preNo="";
|
|
|
|
|
List<Erp_purch_d> lst = new List<Erp_purch_d>();
|
|
|
|
|
foreach (int id in ids)
|
|
|
|
|
{
|
|
|
|
|
lst.Add(new Erp_purch_d(id));
|
|
|
|
|
}
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
foreach (Erp_purch_d pd in lst)
|
|
|
|
|
{
|
|
|
|
|
receiveDetailPre(pd.pur_order, ordeType, pd.ID, pd.count, "", shipId);
|
|
|
|
|
pd.wms_state = (int)enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
pd.Update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
preNo = postPreIn(venderId, shipId);
|
|
|
|
|
foreach (Erp_purch_d pd in lst)
|
|
|
|
|
{
|
|
|
|
|
receivePreDetail(preNo, pd.goods_id, pd.count, pd.count, 0, "", false, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return preNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 条目预收
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="arriveNumber"></param>
|
|
|
|
|
/// <param name="inRemark"></param>
|
|
|
|
|
/// <param name="shipId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool receiveDetailPre(string orderNo,enumInOrderType ordeType,int id, decimal arriveNumber, string inRemark, int shipId)
|
|
|
|
|
{
|
|
|
|
|
//新到arriveNumber 允许负值,最终预到明细的arriveCount不可负值
|
|
|
|
|
// Erp_purch_d ed = new Erp_purch_d(id);
|
|
|
|
|
Erp_purch_receive_pre eprp = new Erp_purch_receive_pre( );
|
|
|
|
|
eprp.getNewDetailByOrderDetailId(id);
|
|
|
|
|
eprp.mem = inRemark;
|
|
|
|
|
eprp.pur_order = orderNo;
|
|
|
|
|
eprp.purch_d_id = id;
|
|
|
|
|
if (eprp.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
eprp.arriveCount += arriveNumber; //同一个采购单下,未生成预到单的,明细预到数量累积 ,同一个预到单号下,预到明细ID唯一,预到数量不累加。
|
|
|
|
|
//prp.arriveCount = eprp.arriveCount > 0 ? eprp.arriveCount : 0;
|
|
|
|
|
if (eprp.arriveCount <= 0)
|
|
|
|
|
{
|
|
|
|
|
return eprp.Delete()>0;
|
|
|
|
|
}
|
|
|
|
|
return eprp.Update() > 1;
|
|
|
|
|
}
|
|
|
|
|
else if (arriveNumber > 0)
|
|
|
|
|
{
|
|
|
|
|
eprp.orderType = (int)ordeType;
|
|
|
|
|
eprp.arriveCount = arriveNumber;
|
|
|
|
|
return eprp.Add() >1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整单预收
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderNo"></param>
|
|
|
|
|
/// <param name="inRemark"></param>
|
|
|
|
|
/// <param name="shipId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool receiveByOrderPre(string orderNo,enumInOrderType ordeType, string inRemark, int shipId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DataTable dt = getRequestInDetail(orderNo);
|
|
|
|
|
Erp_purch_d epd;
|
|
|
|
|
// Erp_purch_receive_pre eprp;
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
epd = new Erp_purch_d(dr);
|
|
|
|
|
receiveDetailPre(orderNo,ordeType, epd.ID, epd.count - epd.receiveCount, inRemark, shipId);
|
|
|
|
|
/*
|
|
|
|
|
eprp = new Erp_purch_receive_pre(epd.pur_order, epd.ID);
|
|
|
|
|
if (eprp.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
eprp.arriveCount = epd.count - epd.receiveCount;
|
|
|
|
|
eprp.mem = inRemark;
|
|
|
|
|
eprp.Update();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
eprp.arriveCount = epd.count - epd.receiveCount;
|
|
|
|
|
eprp.mem = inRemark;
|
|
|
|
|
eprp.pur_order = epd.pur_order;
|
|
|
|
|
eprp.purch_d_id = epd.ID;
|
|
|
|
|
eprp.Add();
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable queryPurchDetailByVender(string venderId, int status)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.queryPurchDetailByVender(venderId, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal string postPreIn(string venderId ,int shipid)
|
|
|
|
|
{
|
|
|
|
|
string preInNo = Util.getOrderNo(enumCreateOrderType.preInOrder, preInObj.getNextSeq(enumCreateOrderType.preInOrder));
|
|
|
|
|
if (preInObj.postPreIn(venderId, preInNo, shipid))
|
|
|
|
|
{
|
|
|
|
|
if (WmsConstants.IN_STOCK_PREIN_AUTO_RECEIVE)
|
|
|
|
|
{
|
|
|
|
|
receivePreDetailAuto(preInNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return preInNo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
internal bool receivePreDetailAuto(string preInNo)
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = preInObj.getDetailByOrder(preInNo);
|
|
|
|
|
|
|
|
|
|
DataView dv = dt.DefaultView;
|
|
|
|
|
|
|
|
|
|
dv.Sort = "count1 asc";
|
|
|
|
|
|
|
|
|
|
decimal epdReceiveCount = 0;
|
|
|
|
|
decimal epdMax = 0;
|
|
|
|
|
bool ret = false;
|
|
|
|
|
Erp_purch_d epd;
|
|
|
|
|
Erp_purch_receive_pre eprd;
|
|
|
|
|
|
|
|
|
|
foreach (DataRowView dr in dv)
|
|
|
|
|
{
|
|
|
|
|
epd = new Erp_purch_d(dr.Row);
|
|
|
|
|
eprd = new Erp_purch_receive_pre(preInNo, epd.ID);
|
|
|
|
|
// epdMax = epd.count - epd.rejectCount - epd.receiveCount;
|
|
|
|
|
decimal receiveNumber = eprd.arriveCount;
|
|
|
|
|
decimal arriveNumber = eprd.arriveCount;
|
|
|
|
|
epdMax = eprd.arriveCount - eprd.receiveCount;
|
|
|
|
|
if (epdMax == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (epdMax >= receiveNumber)
|
|
|
|
|
{
|
|
|
|
|
epdReceiveCount = receiveNumber;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
epdReceiveCount = epdMax;
|
|
|
|
|
}
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ret = receiveDetail(preInNo, epd.ID, arriveNumber, epdReceiveCount, 0, "AutoReceive", eprd.shipId, false, 0, 100);
|
|
|
|
|
ret = ret && eprd.receive(preInNo, epd.ID, epdReceiveCount, operId) > 0;
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
receiveNumber = receiveNumber - epdReceiveCount;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getPreInDetail(string preInNo)
|
|
|
|
|
{
|
|
|
|
|
return preInObj.getPreInDetailWince(preInNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// pda 收货,基于预收数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="preInNo"></param>
|
|
|
|
|
/// <param name="goodsId"></param>
|
|
|
|
|
/// <param name="arriveNumber"></param>
|
|
|
|
|
/// <param name="receiveNumber"></param>
|
|
|
|
|
/// <param name="inType"></param>
|
|
|
|
|
/// <param name="inRemark"></param>
|
|
|
|
|
/// <param name="isCache"></param>
|
|
|
|
|
/// <param name="cachePartion"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool receivePreDetail(string preInNo, string goodsId, decimal arriveNumber, decimal receiveNumber,
|
|
|
|
|
int inType, string inRemark,bool isCache, int cachePartion,decimal temperature)
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = preInObj.getDetailByOrder(preInNo);
|
|
|
|
|
|
|
|
|
|
DataView dv = dt.DefaultView;
|
|
|
|
|
dv.RowFilter = string.Format("goodsId ='{0}' ", goodsId );
|
|
|
|
|
dv.Sort = "count1 asc";
|
|
|
|
|
|
|
|
|
|
decimal epdReceiveCount = 0;
|
|
|
|
|
decimal epdMax = 0;
|
|
|
|
|
bool ret = false;
|
|
|
|
|
Erp_purch_d epd;
|
|
|
|
|
Erp_purch_receive_pre eprd;
|
|
|
|
|
|
|
|
|
|
foreach (DataRowView dr in dv)
|
|
|
|
|
{
|
|
|
|
|
epd = new Erp_purch_d(dr.Row);
|
|
|
|
|
eprd = new Erp_purch_receive_pre(preInNo, epd.ID);
|
|
|
|
|
// epdMax = epd.count - epd.rejectCount - epd.receiveCount;
|
|
|
|
|
|
|
|
|
|
epdMax = eprd.arriveCount - eprd.receiveCount;
|
|
|
|
|
if (epdMax == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (epdMax >= receiveNumber)
|
|
|
|
|
{
|
|
|
|
|
epdReceiveCount = receiveNumber;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
epdReceiveCount = epdMax;
|
|
|
|
|
}
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ret = receiveDetail(preInNo, epd.ID, arriveNumber, epdReceiveCount, inType, inRemark, eprd.shipId, isCache, cachePartion, temperature);
|
|
|
|
|
ret = ret && eprd.receive(preInNo, epd.ID, epdReceiveCount, operId)>0;
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
receiveNumber = receiveNumber - epdReceiveCount;
|
|
|
|
|
|
|
|
|
|
if (receiveNumber <= 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public decimal getValidSeedsCnt(string goodsId, decimal batchCount)
|
|
|
|
|
{
|
|
|
|
|
WmsGoods wg = new WmsGoods(goodsId);
|
|
|
|
|
decimal bigcount = wg.bigCount;
|
|
|
|
|
|
|
|
|
|
if (bigcount == 0)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal bulkcnt = batchCount % bigcount;
|
|
|
|
|
decimal boxcnt = (batchCount - bulkcnt) / bigcount;
|
|
|
|
|
decimal seedsStep = WmsConstants.GOODS_IN_VALID_SEEDS_BOXS_STEP;
|
|
|
|
|
decimal minStep = WmsConstants.GOODS_IN_VALID_SEEDS_BOXS_STEP_MIN; ;
|
|
|
|
|
decimal stepFactor = WmsConstants.GOODS_IN_VALID_SEEDS_BOXS_STEP_FACTOR; ;
|
|
|
|
|
decimal seedsCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (boxcnt < seedsStep)
|
|
|
|
|
{
|
|
|
|
|
if (boxcnt > minStep)
|
|
|
|
|
{
|
|
|
|
|
seedsCount = minStep;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
seedsCount = boxcnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
seedsCount = minStep + Math.Ceiling((boxcnt - seedsStep) / seedsStep) * stepFactor;
|
|
|
|
|
}
|
|
|
|
|
seedsCount = seedsCount > 0 ? seedsCount : 1;
|
|
|
|
|
return seedsCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal DataTable getGoodsPackByBarcode(string barcode)
|
|
|
|
|
{
|
|
|
|
|
return new WmsGoods().getGoodsBybarcod(barcode);
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getGoodsDetailByBarcode(string barcode)
|
|
|
|
|
{
|
|
|
|
|
return new WmsGoods().getGoodsDetailBybarcode(barcode);
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getReceiveDetailByBarcode(string preInOrder,string barcode)
|
|
|
|
|
{
|
|
|
|
|
return this.preInObj.getReceiveDetailByBarcode(preInOrder,barcode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal enumValidInResult validIn(string preInNo, string flowNo, string goodsId, decimal batchCount, decimal seedsCnt,
|
|
|
|
|
Dictionary<string, string> skuValues, bool isPass, bool isIsuLocations,int secondValidUser=0,int recommandWareHouse=0,
|
|
|
|
|
bool ischeckLeftValidDays=true, bool isFlowUni=false,bool isZhitong=false,string pickOrderNo=null,int zhitongPartion=0)
|
|
|
|
|
{
|
|
|
|
|
if (isFlowUni)
|
|
|
|
|
{
|
|
|
|
|
DataTable tmp = getWmsInRequest.getInPortDetails(preInNo, flowNo);
|
|
|
|
|
if(tmp.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return enumValidInResult.流水码已使用;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
decimal epdValidCount = 0;
|
|
|
|
|
decimal epdMax = 0;
|
|
|
|
|
bool ret = false;
|
|
|
|
|
Erp_purch_d epd;
|
|
|
|
|
Erp_purch_receive_pre eprd ;
|
|
|
|
|
string skuCode = "";
|
|
|
|
|
int skuId = 0;
|
|
|
|
|
StructsValideIn svi = new StructsValideIn();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!isZhitong && skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME))
|
|
|
|
|
{
|
|
|
|
|
skuValues[WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME] = Util.getShortDateString(skuValues[WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME]);
|
|
|
|
|
if (skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME))
|
|
|
|
|
{
|
|
|
|
|
skuValues[WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME] = Util.getShortDateString(skuValues[WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME]);
|
|
|
|
|
|
|
|
|
|
DateTime prdDate= Util.pareseDateString(skuValues[WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME]);
|
|
|
|
|
DateTime validDate= Util.pareseDateString(skuValues[WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME]);
|
|
|
|
|
|
|
|
|
|
if (prdDate >= validDate
|
|
|
|
|
|| prdDate > DateTime.Now
|
|
|
|
|
|| validDate < DateTime.Now)
|
|
|
|
|
{
|
|
|
|
|
return enumValidInResult.效期错误;
|
|
|
|
|
}
|
|
|
|
|
TimeSpan ts1 = new TimeSpan(validDate.Ticks);
|
|
|
|
|
TimeSpan ts2 = new TimeSpan(prdDate.Ticks);
|
|
|
|
|
TimeSpan ts = ts1.Subtract(ts2).Duration();
|
|
|
|
|
|
|
|
|
|
int expDays = ts.Days;
|
|
|
|
|
ts = ts1.Subtract(new TimeSpan(DateTime.Now.Ticks)).Duration();
|
|
|
|
|
int leftDays = ts.Days;
|
|
|
|
|
if (ischeckLeftValidDays && leftDays < WmsConstants.IN_STOCK_LEFT_VALID_DAYS)
|
|
|
|
|
{
|
|
|
|
|
return enumValidInResult.临期商品;
|
|
|
|
|
}
|
|
|
|
|
if (ischeckLeftValidDays && leftDays < expDays * WmsConstants.IN_STOCK_LEFT_VALID_DAYS)
|
|
|
|
|
{
|
|
|
|
|
// return enumValidInResult.临期商品;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.debug(this.GetType(),"日期格式错误" );
|
|
|
|
|
LogHelper.WriteLog(this.GetType(), e);
|
|
|
|
|
return enumValidInResult.效期错误;
|
|
|
|
|
}
|
|
|
|
|
svi.validby1 = secondValidUser;
|
|
|
|
|
if (!isZhitong && isPass)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Dictionary<int, string> dic =new lLot(operId).getSKU(skuValues, goodsId);
|
|
|
|
|
|
|
|
|
|
foreach (int i in dic.Keys)
|
|
|
|
|
{
|
|
|
|
|
skuId = i;
|
|
|
|
|
skuCode = dic[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
svi.validResult = (int)enumWhType.合格库;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
svi.validResult = (int)enumWhType.不合格库;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svi.goods_id = goodsId;
|
|
|
|
|
svi.validby = operId;
|
|
|
|
|
svi.reason = "";
|
|
|
|
|
// svi.receive_order = preInNo;
|
|
|
|
|
svi.wms_state = (int)enumReceiveStockDetailStatus.已验收;
|
|
|
|
|
svi.batch = "";
|
|
|
|
|
svi.product_date = "";
|
|
|
|
|
svi.save_date = "";
|
|
|
|
|
svi.preInOrder = preInNo;
|
|
|
|
|
svi.flowNo = flowNo;
|
|
|
|
|
svi.pickOrderNo=pickOrderNo;
|
|
|
|
|
|
|
|
|
|
if (skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_BATCH_ATTNAME))
|
|
|
|
|
svi.batch = skuValues[WmsConstants.SKU_RESEVRED_BATCH_ATTNAME];
|
|
|
|
|
if (skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME))
|
|
|
|
|
svi.product_date = skuValues[WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME];
|
|
|
|
|
if (skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME))
|
|
|
|
|
svi.save_date = skuValues[WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME];
|
|
|
|
|
if (skuValues.ContainsKey(WmsConstants.SKU_RESEVRED_ENTI_ATTNAME))
|
|
|
|
|
svi.entId = skuValues[WmsConstants.SKU_RESEVRED_ENTI_ATTNAME];
|
|
|
|
|
|
|
|
|
|
//svi.zhitongPartion = 1;
|
|
|
|
|
// svi.validResult = (int)enumWhType.越仓收货区;
|
|
|
|
|
|
|
|
|
|
svi.skuCode = skuCode;
|
|
|
|
|
svi.skuId = skuId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DataTable dt = preInObj.getDetailByOrder(preInNo);
|
|
|
|
|
|
|
|
|
|
DataView dv = dt.DefaultView;
|
|
|
|
|
dv.RowFilter = string.Format("goodsId ='{0}' ", goodsId);
|
|
|
|
|
dv.Sort = "count1 asc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataRowView dr in dv)
|
|
|
|
|
{
|
|
|
|
|
epd = new Erp_purch_d(dr.Row);
|
|
|
|
|
eprd = new Erp_purch_receive_pre(preInNo, epd.ID);
|
|
|
|
|
// epdMax = epd.count - epd.rejectCount - epd.receiveCount;
|
|
|
|
|
svi.whType = (int)getWhType((enumInOrderType)eprd.orderType);
|
|
|
|
|
epdMax = eprd.receiveCount - eprd.validCount;
|
|
|
|
|
if (epdMax == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (epdMax >= batchCount)
|
|
|
|
|
{
|
|
|
|
|
epdValidCount = batchCount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
epdValidCount = epdMax;
|
|
|
|
|
}
|
|
|
|
|
svi.receive_order = epd.pur_order;
|
|
|
|
|
svi.seeds_count = seedsCnt;
|
|
|
|
|
svi.valid_count = batchCount;
|
|
|
|
|
svi.purch_d_id = epd.ID;
|
|
|
|
|
svi.whType = (int)getWhType((enumInOrderType)eprd.orderType);
|
|
|
|
|
if (isZhitong || epd.storeType == 1)//越仓
|
|
|
|
|
{
|
|
|
|
|
svi.zhitongPartion = zhitongPartion;// epd.zhitongPartion;
|
|
|
|
|
svi.validResult = (int)enumWhType.越仓收货区;
|
|
|
|
|
svi.whType = (int)enumWhType.越仓收货区;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eprd.validCount += batchCount;
|
|
|
|
|
eprd.operater = operId;
|
|
|
|
|
eprd.Update();
|
|
|
|
|
ret = validIn(svi, isIsuLocations, recommandWareHouse );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
{
|
|
|
|
|
scope.Dispose();
|
|
|
|
|
return enumValidInResult.失败;
|
|
|
|
|
}
|
|
|
|
|
ret = ret && eprd.Update() > 0;
|
|
|
|
|
|
|
|
|
|
batchCount = batchCount - epdValidCount;
|
|
|
|
|
|
|
|
|
|
if (batchCount <= 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//creat tasks/jobs
|
|
|
|
|
DataTable inPorts = this.getWmsInRequest.getInPortDetails(flowNo);
|
|
|
|
|
dv = inPorts.DefaultView;
|
|
|
|
|
dv.RowFilter = "jobNo is null";
|
|
|
|
|
dv.Sort = "partion";
|
|
|
|
|
int lastPartion = 0;
|
|
|
|
|
foreach (DataRow dr in inPorts.Rows)
|
|
|
|
|
{
|
|
|
|
|
WmsInUpPort port = new WmsInUpPort(dr);
|
|
|
|
|
|
|
|
|
|
if (lastPartion != port.partion)
|
|
|
|
|
{
|
|
|
|
|
port.jobNo = Util.getOrderNo(enumCreateOrderType.pickJobNo, _obj.getNextSeq(enumCreateOrderType.pickJobNo));
|
|
|
|
|
port.Update();
|
|
|
|
|
WmsFlow wmsflow = new WmsFlow();
|
|
|
|
|
wmsflow.operater = operId;
|
|
|
|
|
wmsflow.orderNo = preInNo;
|
|
|
|
|
wmsflow.flowNo = flowNo;
|
|
|
|
|
wmsflow.type = (int)enumStockRecordType.普通入库;
|
|
|
|
|
wmsflow.typeName = enumStockRecordType.普通入库.ToString(); ;
|
|
|
|
|
wmsflow.task = port.jobNo;
|
|
|
|
|
wmsflow.taskPartion = port.partion;
|
|
|
|
|
wmsflow.Add();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
lastPartion = port.partion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
return enumValidInResult.成功;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按单取消
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="preInNo">预到单</param
|
|
|
|
|
/// <param name="skuId">SkuID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool retrieveValidByPreNo(string preInNo,int skuId=0)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail();
|
|
|
|
|
DataTable dt = wid.getByPreInOrder(preInNo);
|
|
|
|
|
|
|
|
|
|
foreach(DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
wid=new WmsInRequestDetail(dr);
|
|
|
|
|
if (skuId == 0 || skuId > 0 && skuId == wid.skuId)
|
|
|
|
|
{
|
|
|
|
|
retrieveValidByDetailId(wid.ID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按板取消
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flowNo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool retrieveValidByFlow(string flowNo)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail();
|
|
|
|
|
DataTable dt = wid.getByFlowNo(flowNo);
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
wid = new WmsInRequestDetail(dr);
|
|
|
|
|
if (flowNo == wid.flowNo)
|
|
|
|
|
{
|
|
|
|
|
retrieveValidByDetailId(wid.ID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 撤销验收记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="detailId">验收记录ID,wmsRequestInDetail.id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool retrieveValidByDetailId(int detailId)
|
|
|
|
|
{
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail(detailId);
|
|
|
|
|
WmsInRequest wmsInRequest = new WmsInRequest(wid.orderNo);
|
|
|
|
|
wmsInRequest.state = (int)enumInStockOrderStatus.待验收;
|
|
|
|
|
WmsInUpPort wip = new WmsInUpPort();
|
|
|
|
|
DataTable dtWip = wip.getJobsByFlowSku(wid.flowNo, wid.skuId);
|
|
|
|
|
DataTable dt = new Erp_receiveValidDetail().getDetailByFlowNo(wid.preInOrder, wid.flowNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow dr in dtWip.Rows)
|
|
|
|
|
{
|
|
|
|
|
wip = new WmsInUpPort(dr);
|
|
|
|
|
if (wip.detailId == detailId)
|
|
|
|
|
{
|
|
|
|
|
if (wip.state == (int)enumInStockDetailStatus.上架完成 || wip.state == (int)enumInStockDetailStatus.部分上架)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsStock wmsStock = new WmsStock(wip.locationId, wip.skuId);
|
|
|
|
|
if (wmsStock.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
wmsStock.countIn -= wip.count;
|
|
|
|
|
wmsStock.updateCountOut();
|
|
|
|
|
}
|
|
|
|
|
wip.state = (int)enumInStockDetailStatus.取消上架;
|
|
|
|
|
wip.description += String.Format("上架取消 by {0},{1}", operId, DateTime.Now);
|
|
|
|
|
wip.Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Erp_purch_receive_pre epr;
|
|
|
|
|
Erp_receiveValidDetail erv;
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
erv = new Erp_receiveValidDetail(dr);
|
|
|
|
|
|
|
|
|
|
if (erv.skuId == wid.skuId)
|
|
|
|
|
{
|
|
|
|
|
epr = new Erp_purch_receive_pre(erv.preInOrder, erv.purch_d_id);
|
|
|
|
|
epr.validCount -= wip.count;
|
|
|
|
|
epr.Update();
|
|
|
|
|
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(erv.purch_d_id);
|
|
|
|
|
epd.validCount -= wip.count;
|
|
|
|
|
epd.wms_state = (int)enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
erv.Delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Erp_purch epc = new Erp_purch(wip.orderNo);
|
|
|
|
|
epc.wms_state = 0;
|
|
|
|
|
epc.Update();
|
|
|
|
|
|
|
|
|
|
wid.Delete();
|
|
|
|
|
wmsInRequest.Update();
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消上架任务,重新验货入库
|
|
|
|
|
/// 同批次的,同托盘的其他任务一起取消
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flowNo">up shelf job flowno</param>
|
|
|
|
|
/// <param name="jobId">up shelf job id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal bool retrieveValidByJobId(int jobId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WmsInUpPort wip = new WmsInUpPort(jobId);
|
|
|
|
|
if (wip.skuId == 0 || wip.upCount > 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wip.state = (int)enumInStockDetailStatus.取消上架;
|
|
|
|
|
wip.description += String.Format("上架取消 by {0},{1}", operId, DateTime.Now);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Erp_purch_receive_pre epr;
|
|
|
|
|
Erp_receiveValidDetail erv;
|
|
|
|
|
DataTable dt = new Erp_receiveValidDetail().getDetailByFlowNo(wip.inPreOrder, wip.flowNo);
|
|
|
|
|
|
|
|
|
|
DataTable dtWip = wip.getJobsByFlowSku(wip.flowNo, wip.skuId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (TransactionScope scope = new TransactionScope())
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow dr in dtWip.Rows)
|
|
|
|
|
{
|
|
|
|
|
wip = new WmsInUpPort(dr);
|
|
|
|
|
if(wip.state==(int)enumInStockDetailStatus.上架完成 || wip.state == (int)enumInStockDetailStatus.部分上架)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
WmsStock wmsStock = new WmsStock(wip.locationId, wip.skuId);
|
|
|
|
|
if (wmsStock.ID > 0)
|
|
|
|
|
{
|
|
|
|
|
wmsStock.countIn -= wip.count;
|
|
|
|
|
wmsStock.updateCountOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
erv = new Erp_receiveValidDetail(dr);
|
|
|
|
|
|
|
|
|
|
if (erv.skuId == wip.skuId)
|
|
|
|
|
{
|
|
|
|
|
epr = new Erp_purch_receive_pre(erv.preInOrder, erv.purch_d_id);
|
|
|
|
|
epr.validCount -= wip.count;
|
|
|
|
|
epr.Update();
|
|
|
|
|
|
|
|
|
|
Erp_purch_d epd = new Erp_purch_d(erv.purch_d_id);
|
|
|
|
|
epd.validCount -= wip.count;
|
|
|
|
|
epd.wms_state = (int)enumReceiveStockDetailStatus.待验收;
|
|
|
|
|
epd.Update();
|
|
|
|
|
|
|
|
|
|
erv.Delete();
|
|
|
|
|
|
|
|
|
|
WmsInRequestDetail wid = new WmsInRequestDetail(erv.receive_order, erv.ID);
|
|
|
|
|
wid.Delete();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wip.retrieveJobs(wip.flowNo, wip.skuId, wip.description);
|
|
|
|
|
|
|
|
|
|
Erp_purch epc = new Erp_purch(wip.orderNo);
|
|
|
|
|
epc.wms_state = 0;
|
|
|
|
|
epc.Update();
|
|
|
|
|
|
|
|
|
|
WmsInRequest wmsInRequest = new WmsInRequest(wip.orderNo);
|
|
|
|
|
wmsInRequest.state = (int)enumInStockOrderStatus.待验收;
|
|
|
|
|
wmsInRequest.Update();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal bool isFlowNoValid(string preInOrder, string flowNo)
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = new Erp_receiveValidDetail().getDetailByFlowNo(preInOrder, flowNo);
|
|
|
|
|
return dt.Rows.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataTable getPreValidResult4Wince(string preInNo, string flowNo, bool showAllUsers = false)
|
|
|
|
|
{
|
|
|
|
|
if (showAllUsers)
|
|
|
|
|
{
|
|
|
|
|
return getWmsInRequest.getPreValidResult4Wince(preInNo, flowNo, 0);
|
|
|
|
|
}
|
|
|
|
|
return getWmsInRequest.getPreValidResult4Wince(preInNo, flowNo, operId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal DataTable getValidInDetail(string preInNo, string flowNo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return getWmsInRequest.getValidInDetail(preInNo, flowNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void truncateDataForTestOnly()
|
|
|
|
|
{
|
|
|
|
|
getWmsInRequest.truncateDataForTestOnly();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataSet queryReceivesByVender(string querystr, int rownumStart, int rownumEnd)
|
|
|
|
|
{
|
|
|
|
|
DataSet ds = erpPurchObj.queryReceivesByVender(querystr, rownumStart, rownumEnd);
|
|
|
|
|
/*
|
|
|
|
|
DataView dv = ds.Tables[0].DefaultView;
|
|
|
|
|
dv.Sort = "vender";
|
|
|
|
|
string vender="";
|
|
|
|
|
if (dv.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
vender=dv[0]["vender"].ToString();
|
|
|
|
|
dv.RowFilter =string.Format("vender ='{0}'" ,vender );
|
|
|
|
|
ds.Tables.Add(dv.ToTable("vender"));
|
|
|
|
|
DataTable dt = getReceivePreSumByVenderNotValided(vender).Copy() ;
|
|
|
|
|
dt.TableName = "venderPres";
|
|
|
|
|
ds.Tables.Add(dt);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
return ds;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
internal DataTable getReceiveDetailByPreInOrder(string preInOrder)
|
|
|
|
|
{
|
|
|
|
|
return this.preInObj.getPreInDetailWindows(preInOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataSet getPreInVendDetailsWindows(string venderPinyin, int orderType)
|
|
|
|
|
{
|
|
|
|
|
return this.preInObj.getPreInVendDetailsWindows(venderPinyin, orderType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataTable getRequestByVenderPinyin(string pinYin, enumInStockOrderStatus status,int orderType)
|
|
|
|
|
{
|
|
|
|
|
return erpPurchObj.getRequestByVenderPinyin(pinYin, status, orderType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫描板号,返回直通物品订单明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flowNo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataTable getZhiTongOrderDetail(string flowNo)
|
|
|
|
|
{
|
|
|
|
|
return getWmsInRequest.getZhiTongOrderDetail(flowNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|