778 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			778 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
 | ||
| /// <summary>
 | ||
| ///INTERFACE CLASS FOR TABLE t_wmsGoods
 | ||
| ///By wm with codesmith. 
 | ||
| ///on 05/04/2017
 | ||
| /// </summary>
 | ||
| 
 | ||
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Linq;
 | ||
| using System.Text;
 | ||
| using System.Data;
 | ||
| using DeiNiu.Utils;
 | ||
| 
 | ||
| namespace DeiNiu.wms.Data.Model
 | ||
| {
 | ||
|     [Serializable]
 | ||
|     public class WmsGoods : WmsGoods_base
 | ||
|     {
 | ||
|         
 | ||
| 
 | ||
|         public WmsGoods()
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         public WmsGoods(int id): base(id)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
|          public WmsGoods(DataRow dr): base(dr)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|          public WmsGoods(string goodsId)
 | ||
|          { 
 | ||
|              cmdParameters[0] = goodsId;
 | ||
|              getModel(110);
 | ||
|              initialExtFields();
 | ||
|          }
 | ||
|   
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 实例化商品,并取sku库存信息
 | ||
|         /// </summary>
 | ||
|         /// <param name="goodsId"></param>
 | ||
|         /// <param name="skuId"></param>
 | ||
|         /// <param name="skuCode"></param>
 | ||
|          public WmsGoods(string goodsId, int skuId,string batch,enumWhType whType = enumWhType.合格库)
 | ||
|              : this(goodsId)
 | ||
|          {
 | ||
|              getStockInfo(goodsId, skuId, batch, whType);
 | ||
|          }
 | ||
|          protected override void getImp()
 | ||
|          {
 | ||
|              model_imp = new WmsGoods_Imp();
 | ||
| 
 | ||
|          }
 | ||
|         /// <summary>
 | ||
|         /// 更新cache
 | ||
|         /// </summary>
 | ||
|         /// <returns></returns>
 | ||
|          public new int Update()
 | ||
|          {
 | ||
|              base.Update();           
 | ||
|             // ObjectsFactory.putGoods(this);
 | ||
|              return 1;
 | ||
|          }
 | ||
| 
 | ||
|          #region fieldNames
 | ||
|          public enum exfields
 | ||
|          { goodsName, spec,unit,manufacturer,address,barcode, regeditCode,
 | ||
|              goodsTypeName,type,pinYin ,station,repTypeName,
 | ||
|            lotId,lotName,isDateValid
 | ||
|                ,
 | ||
|            bigCount,
 | ||
|             price
 | ||
| 
 | ||
|                ,
 | ||
|             packingUnit
 | ||
|               
 | ||
|                ,
 | ||
|             isZhitong
 | ||
|                ,
 | ||
|            isQc
 | ||
|                ,
 | ||
|             isManufacture
 | ||
|                ,  messureModel
 | ||
|          }
 | ||
|          #endregion
 | ||
| 
 | ||
| 
 | ||
|          private string _goodsName, _spec, _unit, _manufacturer, _address, _barcode,
 | ||
|              _regeditCode, _goodsTypeName,   _type,_pinyin,
 | ||
|             _lotName
 | ||
|           //  ,_expiryDays 
 | ||
|           ,_price 
 | ||
|         //  ,_minOperateCount 
 | ||
|           ,_packingUnit
 | ||
|          // , _minOperateUnit
 | ||
|           , _isZhitong
 | ||
|           , _isQc
 | ||
|           , _isManufacture
 | ||
|           , _messureModel 
 | ||
|              ;
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|          public string price
 | ||
|          {
 | ||
|              get { return _price; }
 | ||
|             
 | ||
|          }
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|          public string packingUnit
 | ||
|          {
 | ||
|              get { return _packingUnit; }
 | ||
|               
 | ||
|          }
 | ||
| 
 | ||
|          public bool isZhitong
 | ||
|          { 
 | ||
|             get { return /*_canZhitong || */!String.IsNullOrEmpty(_isZhitong) &&(_isZhitong.Equals("1") || _isZhitong.Equals("True")); }
 | ||
|          }
 | ||
|         public bool isZhitongFromStore
 | ||
|         {
 | ||
|             get { return canZhitong && WmsConstants.OUT_ZHITONG_FROM_STORE; }
 | ||
|         }
 | ||
| 
 | ||
|          
 | ||
| 
 | ||
|         public bool isQc
 | ||
|          {
 | ||
|              get {
 | ||
|                  return Convert.ToBoolean(_isQc);
 | ||
|                //  return !String.IsNullOrEmpty(_isQc) &&_isQc.Equals("1"); 
 | ||
|              }
 | ||
|              
 | ||
|          }
 | ||
| 
 | ||
|          public bool isManufacture
 | ||
|          { 
 | ||
|                get { return !String.IsNullOrEmpty(_isManufacture) &&_isManufacture.Equals("1"); }
 | ||
|          }
 | ||
| 
 | ||
|          public string messureModel
 | ||
|          {
 | ||
|              get { return _messureModel; }
 | ||
|             
 | ||
|          }
 | ||
| 
 | ||
|         
 | ||
|          private int _lotId;
 | ||
|          private bool _isDateValid;
 | ||
|         /// <summary>
 | ||
|         /// 商品的有效批次规则
 | ||
|         /// 如果plotId=0 则取owner的LotId
 | ||
|         /// </summary>
 | ||
|          public int lotId
 | ||
|          {
 | ||
|              get { return _lotId; }
 | ||
| 
 | ||
|          }
 | ||
|          public string  lotName
 | ||
|          {
 | ||
|              get { return _lotName; }
 | ||
| 
 | ||
|          }
 | ||
|          public string goodsName
 | ||
|          {
 | ||
|              get { return _goodsName; }
 | ||
|              
 | ||
|          }
 | ||
|          public string spec
 | ||
|          {
 | ||
|              get { return _spec; }
 | ||
| 
 | ||
|          }
 | ||
|          public string unit
 | ||
|          {
 | ||
|              get { return _unit; }
 | ||
| 
 | ||
|          }
 | ||
|          public string manufacturer
 | ||
|          {
 | ||
|              get { return _manufacturer; }
 | ||
| 
 | ||
|          }
 | ||
|          public string address
 | ||
|          {
 | ||
|              get { return _address; }
 | ||
| 
 | ||
|          }
 | ||
|          
 | ||
|          public string regeditCode
 | ||
|          {
 | ||
|              get { return _regeditCode; }
 | ||
| 
 | ||
|          }
 | ||
|          public string goodsTypeName
 | ||
|          {
 | ||
|              get { return _goodsTypeName; }
 | ||
| 
 | ||
|          }
 | ||
|          
 | ||
|          public string type
 | ||
|          {
 | ||
|              get { return _type; }
 | ||
| 
 | ||
|          }
 | ||
| 
 | ||
|          public string pinyin
 | ||
|          {
 | ||
|              get { return _pinyin; }
 | ||
| 
 | ||
|          }
 | ||
| 
 | ||
| 
 | ||
|          public void initialExtFields()
 | ||
|          {
 | ||
|              cmdParameters[0] = _goodsId;
 | ||
| 
 | ||
|              DataTable dt = CustQuery(120).Tables[0];
 | ||
|              foreach (DataRow dr in dt.Rows)
 | ||
|              {
 | ||
|                  if (!(dr[exfields.address.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _address = dr[exfields.address.ToString()].ToString();
 | ||
|                  }
 | ||
|                  
 | ||
| 
 | ||
|                
 | ||
|                  if (!(dr[exfields.goodsName.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _goodsName = dr[exfields.goodsName.ToString()].ToString();
 | ||
|                  } if (!(dr[exfields.goodsTypeName.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _goodsTypeName = dr[exfields.goodsTypeName.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.manufacturer.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _manufacturer = dr[exfields.manufacturer.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.regeditCode.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _regeditCode = dr[exfields.regeditCode.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.spec.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _spec = dr[exfields.spec.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.type.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _type = dr[exfields.type.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.unit.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _unit = dr[exfields.unit.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.pinYin.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _pinyin = dr[exfields.pinYin.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.lotId.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _lotId = Convert.ToInt32(dr[exfields.lotId.ToString()].ToString());
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.lotName.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _lotName = dr[exfields.lotName.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.isDateValid.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _isDateValid = Convert.ToBoolean(dr[exfields.isDateValid.ToString()]);
 | ||
|                      _isDateValid = Convert.ToBoolean(dr[exfields.isDateValid.ToString()].ToString().Equals("True"));
 | ||
|                  }
 | ||
|                 
 | ||
| 
 | ||
|                  if (!(dr[exfields.price.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _price = dr[exfields.price.ToString()].ToString();
 | ||
|                  }
 | ||
|                  
 | ||
|                  if (!(dr[exfields.packingUnit.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _packingUnit = dr[exfields.packingUnit.ToString()].ToString();
 | ||
|                  }
 | ||
|                  
 | ||
|                  if (!(dr[exfields.isZhitong.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _isZhitong = dr[exfields.isZhitong.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.isQc.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _isQc = dr[exfields.isQc.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.isManufacture.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _isManufacture = dr[exfields.isManufacture.ToString()].ToString();
 | ||
|                  }
 | ||
| 
 | ||
|                  if (!(dr[exfields.isManufacture.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _isManufacture = dr[exfields.isManufacture.ToString()].ToString();
 | ||
|                  }
 | ||
|                  if (!(dr[exfields.messureModel.ToString()] is DBNull))
 | ||
|                  {
 | ||
|                      _messureModel = dr[exfields.messureModel.ToString()].ToString();
 | ||
|                  }
 | ||
| 
 | ||
|              }
 | ||
| 
 | ||
| 
 | ||
|          }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         //begin cust db operation, query, excute sql etc.
 | ||
|         public DataSet QueryByName(string name)
 | ||
|         {
 | ||
|             cmdParameters[0] = name;
 | ||
|             return  CustQuery(100);
 | ||
|         }
 | ||
|     
 | ||
|         /// <summary>
 | ||
|         /// 同步erp 商品信息
 | ||
|         /// </summary>
 | ||
|         /// <returns></returns>
 | ||
|         public int syncGoods()
 | ||
|         {  
 | ||
|           int cnt= CustOper(300);
 | ||
| 
 | ||
|           DataTable dt = CustQuery(700).Tables[0]; //新的存储类型
 | ||
|           DataTable dtGd;
 | ||
|           string locType;
 | ||
|           Node nd;
 | ||
|           WmsGoods wg;
 | ||
|           foreach (DataRow dr in dt.Rows)
 | ||
|           {
 | ||
|                 locType = dr[0].ToString();
 | ||
| 
 | ||
|                 nd = new Node();
 | ||
|                 nd.parentid = 29;
 | ||
|                 nd.name = locType;
 | ||
|                 nd.Add();
 | ||
|                 cmdParameters[0] = locType;
 | ||
|                 cmdParameters[1] = nd.ID;
 | ||
|                 CustOper(810);
 | ||
|                 /*
 | ||
| 
 | ||
|                 dtGd = CustQuery(800).Tables[0];
 | ||
| 
 | ||
|                 foreach (DataRow dr1 in dtGd.Rows)
 | ||
|                 {
 | ||
|                     wg = new WmsGoods(dr1["goodsId"].ToString());
 | ||
|                     wg._goodsType = nd.ID;
 | ||
|                     wg.Update();
 | ||
| 
 | ||
|                 } 
 | ||
|                 */
 | ||
| 
 | ||
|           }
 | ||
| 
 | ||
|           return cnt;
 | ||
| 
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 根据货位类型返回货物的库容量
 | ||
|         /// </summary>
 | ||
|         /// <param name="locVolType"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public decimal getMaxCount(int locVolType)
 | ||
|         {
 | ||
|             decimal goodsMaxcnt = WmsConstants.BULK_MAX_RATE;
 | ||
|             switch (locVolType)
 | ||
|             {
 | ||
|                 case (int)enumWhLocVol.零库:
 | ||
|                     goodsMaxcnt = this.bulkMax;
 | ||
|                     goodsMaxcnt = goodsMaxcnt > 0 ? goodsMaxcnt : bigCount * WmsConstants.BULK_MAX_RATE;
 | ||
|                     break;
 | ||
|                 case (int)enumWhLocVol.小整:
 | ||
|                     goodsMaxcnt = this.batchMax1;
 | ||
|                     goodsMaxcnt = goodsMaxcnt > 0 ? goodsMaxcnt : bigCount * WmsConstants.BATCH1_MAX_RATE;
 | ||
|                     break;
 | ||
|                 case (int)enumWhLocVol.中整:
 | ||
|                     goodsMaxcnt = this.batchMax2;
 | ||
|                     goodsMaxcnt = goodsMaxcnt > 0 ? goodsMaxcnt : bigCount * WmsConstants.BATCH2_MAX_RATE;
 | ||
|                     break;
 | ||
|                 case (int)enumWhLocVol.大整:
 | ||
|                     goodsMaxcnt = this.batchMax3;
 | ||
|                     goodsMaxcnt = goodsMaxcnt > 0 ? goodsMaxcnt : bigCount * WmsConstants.BATCH3_MAX_RATE;
 | ||
|                     break;
 | ||
|                      
 | ||
| 
 | ||
|             }
 | ||
|             return goodsMaxcnt;
 | ||
|         }
 | ||
| 
 | ||
|         private decimal _stockSumCount, _stockBulkCount, _stockBatch1Count, _stockBatch2Count, _stockBatch3Count,_stockSumAjustCount;
 | ||
|         private decimal _stockSumCountIn, _stockBulkCountIn, _stockBatch1CountIn, _stockBatch2CountIn, _stockBatch3CountIn;
 | ||
|         private decimal _stockSumCountOuting, _stockBulkCountOuting, _stockBatch1CountOuting, _stockBatch2CountOuting, _stockBatch3CountOuting, _stockSumVirtialCount;
 | ||
|         public decimal stockSumCountIn
 | ||
|         {
 | ||
|             get { return _stockSumCountIn; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal  stockSumAjustCount
 | ||
|         {
 | ||
|             get { return _stockSumAjustCount; }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         public decimal stockAvCount 
 | ||
|         {
 | ||
|             get {
 | ||
| 
 | ||
|                 decimal tmp = _stockSumCount - _stockSumCountOuting + _stockSumAjustCount + _stockSumVirtialCount;
 | ||
|                 try
 | ||
|                 {
 | ||
|                     tmp = isWeightOut() ? tmp : ((int)(tmp / minOperateCount)) * minOperateCount;
 | ||
| 
 | ||
|                 }
 | ||
|                 catch
 | ||
|                 {
 | ||
| 
 | ||
|                 }
 | ||
|               
 | ||
| 
 | ||
| 
 | ||
|                 return tmp  >= 0? tmp : 0;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBulkCountIn
 | ||
|         {
 | ||
|             get { return _stockBulkCountIn; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch1CountIn
 | ||
|         {
 | ||
|             get { return _stockBatch1CountIn; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch2CountIn
 | ||
|         {
 | ||
|             get { return _stockBatch2CountIn; }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         public decimal stockSumCountOuting
 | ||
|         {
 | ||
|             get { return _stockSumCountOuting; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBulkCountOuting
 | ||
|         {
 | ||
|             get { return _stockBulkCountOuting; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch1CountOuting
 | ||
|         {
 | ||
|             get { return _stockBatch1CountOuting; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch2CountOuting
 | ||
|         {
 | ||
|             get { return _stockBatch2CountOuting; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch3CountOuting
 | ||
|         {
 | ||
|             get { return _stockBatch3CountOuting; }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         public decimal  stockSumCount
 | ||
|         {
 | ||
|             get { return _stockSumCount; }
 | ||
|             
 | ||
|         }
 | ||
|         public decimal  stockBulkCount
 | ||
|         {
 | ||
|             get { return _stockBulkCount; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBulkAvCount
 | ||
|         {
 | ||
|             get { return _stockBulkCount - _stockBulkCountOuting + _stockSumVirtialCount; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatchAvCount
 | ||
|         {
 | ||
|             get {
 | ||
|                 return stockAvCount - stockBulkAvCount;
 | ||
|                // return _stockSumCount - _stockSumCountOuting - stockBulkAvCount;  
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         public bool canRep(string skuId)
 | ||
|         {
 | ||
|             if (skuId == "3724")
 | ||
|             LogHelper.debug(this.GetType(), "canRep skuid=" + skuId);
 | ||
|             decimal repcnt=0M, pickbulkcnt=0M;
 | ||
|             cmdParameters[0] = skuId;
 | ||
|             DataSet ds = CustQuery(900);
 | ||
|             DataTable dt = ds.Tables[0];
 | ||
|             DataTable dt2 = ds.Tables[1];
 | ||
| 
 | ||
|             if (dt.Rows.Count > 0)
 | ||
|             {
 | ||
|                 repcnt = Convert.ToDecimal( dt.Rows[0][0].ToString());
 | ||
|             }
 | ||
|             if (dt2.Rows.Count > 0)
 | ||
|             {
 | ||
|                 pickbulkcnt = Convert.ToDecimal(dt2.Rows[0][0].ToString());
 | ||
|             }
 | ||
|             if (skuId == "3724")
 | ||
|             LogHelper.debug(this.GetType(), string.Format("{0} repcnt:{1},pickbulkcnt:{2}, can rep: {3}", skuId, repcnt, pickbulkcnt, pickbulkcnt > repcnt));
 | ||
|             return pickbulkcnt > repcnt;
 | ||
| 
 | ||
|         }
 | ||
|         public decimal sumBulkOuting(string skuId)
 | ||
|         {
 | ||
|             cmdParameters[0] = skuId;
 | ||
|             DataSet ds = CustQuery(900);             
 | ||
|             DataTable dt2 = ds.Tables[1];
 | ||
|            return Convert.ToDecimal(dt2.Rows[0][0].ToString());
 | ||
|         }
 | ||
|          
 | ||
| 
 | ||
| 
 | ||
|         public DataTable getRepLst()
 | ||
|         {
 | ||
|             return CustQuery(1000).Tables[0];
 | ||
|         }
 | ||
| 
 | ||
|         public decimal  stockBatch1Count
 | ||
|         {
 | ||
|             get { return _stockBatch1Count; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch2Count
 | ||
|         {
 | ||
|             get { return _stockBatch2Count; }
 | ||
| 
 | ||
|         }
 | ||
|         public decimal stockBatch3Count
 | ||
|         {
 | ||
|             get { return _stockBatch3Count; }
 | ||
| 
 | ||
|         }
 | ||
|         private List<WmsStock> _stocks;
 | ||
| 
 | ||
|         public List<WmsStock> stocks
 | ||
|         {
 | ||
|             get {
 | ||
|                 if (_stocks == null)
 | ||
|                 {  
 | ||
|                      _stocks = new List<WmsStock>();
 | ||
|                     
 | ||
|                 }
 | ||
|                  
 | ||
|                 return _stocks; 
 | ||
|             }
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|         private List<WmsStock> _allStocks;
 | ||
| 
 | ||
|         public List<WmsStock> AllStocks
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_allStocks == null)
 | ||
|                 {
 | ||
|                     _allStocks = new List<WmsStock>();
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                 return _allStocks;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private List<WmsStock> _tmpStocks;
 | ||
|         public List<WmsStock>  tmpStocks
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_tmpStocks == null)
 | ||
|                 {
 | ||
|                     _tmpStocks = new List<WmsStock>();
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                 return _tmpStocks;
 | ||
|             }
 | ||
|             set
 | ||
|             {
 | ||
|                 _tmpStocks = value;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         public DataTable getSkuValues(int lotId,int skuId, string attName)
 | ||
|         {
 | ||
|             cmdParameters[0] = skuId;
 | ||
|             cmdParameters[1] = attName;
 | ||
|             cmdParameters[2] = lotId;
 | ||
|             return CustQuery(400).Tables[0];
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 取得商品的即时库存
 | ||
|         /// </summary>
 | ||
|         /// <param name="goodsId"></param>
 | ||
|         /// <param name="batch"></param>
 | ||
|         public void getStockInfo(string goodsId,int skuId=0,string batch="", enumWhType whType = enumWhType.合格库)
 | ||
|         {
 | ||
|             DataTable dt = new WmsStock().getStockInfo(goodsId, skuId, batch,whType);
 | ||
| 
 | ||
|             
 | ||
| 
 | ||
|             _stocks = new List<WmsStock>();
 | ||
|             _allStocks = new List<WmsStock>();
 | ||
|             
 | ||
|             _stockSumCount = 0m; _stockBulkCount = 0m; _stockBatch1Count = 0m; _stockBatch2Count = 0m;
 | ||
|             _stockSumCountIn = 0m; _stockBulkCountIn = 0m; _stockBatch1CountIn = 0m; _stockBatch2CountIn = 0m;
 | ||
|             _stockSumCountOuting = 0m; _stockBulkCountOuting = 0m; _stockBatch1CountOuting = 0m; _stockBatch2CountOuting = 0m;
 | ||
|             _stockSumVirtialCount = 0m;
 | ||
|             _stockSumAjustCount = 0m;
 | ||
| 
 | ||
|            // if(goodsId=="P04710")
 | ||
|            // LogHelper.debug(GetType(), String.Format("to get stk info, goodsId {0},stk cnt {1}", goodsId, dt.Rows.Count));
 | ||
| 
 | ||
|             foreach (DataRow dr in dt.Rows){
 | ||
| 
 | ||
|                 WmsStock st = new WmsStock(dr);
 | ||
| 
 | ||
|                 //  if (goodsId == "P04710")
 | ||
|                 //     LogHelper.debug(GetType(), String.Format("to get stk info,  stk  {0}", st.ToString()));
 | ||
| 
 | ||
| 
 | ||
|                 _allStocks.Add(st);
 | ||
|                
 | ||
|                 if (st.getAvCount() <= 0)
 | ||
|                 {
 | ||
|                     continue;
 | ||
|                 }
 | ||
| 
 | ||
|                 if (  ( isWeightOut() ? st.getAvCount() : ((int)(st.getAvCount() / minOperateCount)) * minOperateCount) <=0 )
 | ||
|                 {    
 | ||
|                     LogHelper.debug(GetType(), String.Format(" 达不到可拣选的最小数量 to get stk info,  stk  {0}", st.ToString()));
 | ||
| 
 | ||
|                     continue;
 | ||
|                 }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|                 _stocks.Add(st);
 | ||
| 
 | ||
|                 decimal cnt = st.count - st.countOut;
 | ||
| 
 | ||
|                 cnt = isWeightOut() ? cnt : ((int)(cnt / minOperateCount)) * minOperateCount; //取可拣选的最小单位的倍数
 | ||
|               
 | ||
|             
 | ||
| 
 | ||
|                 _stockSumCount += cnt;
 | ||
|                 _stockSumCountIn +=st.countIn;
 | ||
|                 _stockSumCountOuting += st.countOuting;
 | ||
|                 _stockSumAjustCount += st.adjustingCnt;
 | ||
|                 _stockSumVirtialCount += st.virtialCount;
 | ||
|                 switch (st.location.volType)
 | ||
|                 {
 | ||
|                     case (int) enumWhLocVol.零库:
 | ||
|                         _stockBulkCount += cnt;
 | ||
|                         _stockBulkCountIn += st.countIn;
 | ||
|                         _stockBulkCountOuting += st.countOuting; 
 | ||
|                         break;
 | ||
|                     case (int)enumWhLocVol.小整:
 | ||
|                         _stockBatch1Count += cnt;
 | ||
|                         _stockBatch1CountIn += st.countIn;
 | ||
|                         _stockBatch1CountOuting += st.countOuting; 
 | ||
|                         break;
 | ||
|                     case (int)enumWhLocVol.中整:
 | ||
|                         _stockBatch2Count += cnt;
 | ||
|                         _stockBatch2CountIn += st.countIn;
 | ||
|                         _stockBatch2CountOuting += st.countOuting; 
 | ||
|                         break;
 | ||
|                     case (int)enumWhLocVol.大整:
 | ||
|                         _stockBatch3Count += cnt;
 | ||
|                         _stockBatch3CountIn += st.countIn;
 | ||
|                         _stockBatch3CountOuting += st.countOuting;
 | ||
|                         break;
 | ||
|                 } 
 | ||
| 
 | ||
|             } 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
|          
 | ||
| 
 | ||
|         public DataTable queryPacking(string goodsId)
 | ||
|         {
 | ||
|             cmdParameters[0] = goodsId;
 | ||
|              
 | ||
|             return CustQuery(500).Tables[0];
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         public DataTable queryByKeyWords(string keyWords)
 | ||
|         {
 | ||
|             cmdParameters[0] = keyWords;
 | ||
| 
 | ||
|             return CustQuery(1100).Tables[0];
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         public DataTable getGoodsBybarcod(string barcode)
 | ||
|         {
 | ||
|             cmdParameters[0] = barcode;
 | ||
| 
 | ||
|             return CustQuery(600).Tables[0];
 | ||
|         }
 | ||
|         public DataTable getGoodsDetailBybarcode(string barcode)
 | ||
|         {
 | ||
|             cmdParameters[0] = barcode;
 | ||
| 
 | ||
|             return CustQuery(610).Tables[0];
 | ||
|         }
 | ||
| 
 | ||
|         public List<string> getLotAtts()
 | ||
|         {
 | ||
|             List<string> list = new List<string>(); 
 | ||
|             LotAtt lotAtt = new LotAtt();
 | ||
|             DataTable dt =lotAtt.queryByLotId(lotId);
 | ||
|             foreach(DataRow dr in dt.Rows)
 | ||
|             {
 | ||
|                 lotAtt = new LotAtt(dr);
 | ||
|                 list.Add(lotAtt.attName);
 | ||
|             }
 | ||
|             return list;
 | ||
|         }
 | ||
| 
 | ||
|         public bool isWeightOut()
 | ||
|         {
 | ||
|             //return WmsConstants.GOODS_WEIGHT_UNITS.Contains(unit);
 | ||
|             return WmsConstants.GOODS_WEIGHT_UNITS.Contains(this.minOperateUnit);
 | ||
|         }
 | ||
|  
 | ||
| 
 | ||
|         public bool isSeedsOut()
 | ||
|         {
 | ||
| 
 | ||
|             /*
 | ||
| 
 | ||
|                bool b = canSeedOut && !isZhitong //直通不参与
 | ||
|                       && (!isWeightOut() || !WmsConstants.SEEDS_OUT_NOT_WITH_WEIGHT);
 | ||
| 
 | ||
|                return b;
 | ||
| 
 | ||
|                */
 | ||
|             //  bool notSeeds =  isZhitong  || (isWeightOut() && WmsConstants.SEEDS_OUT_NOT_WITH_WEIGHT);
 | ||
| 
 | ||
| 
 | ||
|             return canSeedOut; //|| !notSeeds;
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
|     }
 | ||
| }
 | ||
|   |