357 lines
		
	
	
		
			9.8 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			357 lines
		
	
	
		
			9.8 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(); | |||
|  |          } | |||
|  |          public WmsGoods(string goodsId,string batch):this(goodsId)  | |||
|  |          { | |||
|  |              getStockInfo(goodsId,batch); | |||
|  |          } | |||
|  |          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,bigCount,type,pinYin ,station,repTypeName} | |||
|  |          #endregion | |||
|  | 
 | |||
|  | 
 | |||
|  |          private string _goodsName, _spec, _unit, _manufacturer, _address, _barcode, _regeditCode, _goodsTypeName,   _type,_pinyin; | |||
|  |         // decimal _bigCount; | |||
|  |          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 barcode | |||
|  |          { | |||
|  |              get { return _barcode; } | |||
|  | 
 | |||
|  |          } | |||
|  |          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.barcode.ToString()] is DBNull)) | |||
|  |                { | |||
|  |                    _barcode = dr[exfields.barcode.ToString()].ToString(); | |||
|  |                } | |||
|  | 
 | |||
|  |                if (!(dr[exfields.bigCount.ToString()] is DBNull)) | |||
|  |                { | |||
|  |                    _bigCount = Convert.ToDecimal(dr[exfields.bigCount.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)) | |||
|  |                { | |||
|  |                    _unit = dr[exfields.pinYin.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() | |||
|  |         { | |||
|  |              | |||
|  |             return CustOper(300);   | |||
|  |         } | |||
|  |         /// <summary> | |||
|  |         /// 根据货位类型返回货物的库容量 | |||
|  |         /// </summary> | |||
|  |         /// <param name="locVolType"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public decimal getMaxCount(int locVolType) | |||
|  |         { | |||
|  |             decimal goodsMaxcnt = 0m; | |||
|  |             switch (locVolType) | |||
|  |             { | |||
|  |                 case (int)enumWhLocVol.零库: | |||
|  |                     goodsMaxcnt = this.bulkMax; | |||
|  |                     break; | |||
|  |                 case (int)enumWhLocVol.小整: | |||
|  |                     goodsMaxcnt = this.batchMax1; | |||
|  |                     break; | |||
|  |                 case (int)enumWhLocVol.大整: | |||
|  |                     goodsMaxcnt = this.batchMax2; | |||
|  |                     break; | |||
|  |                 case (int)enumWhLocVol.超大整: | |||
|  |                     goodsMaxcnt = this.batchMax3; | |||
|  |                     break; | |||
|  | 
 | |||
|  |             } | |||
|  |             return goodsMaxcnt; | |||
|  |         } | |||
|  | 
 | |||
|  |         private decimal _stockSumCount, _stockBulkCount, _stockBatch1Count, _stockBatch2Count; | |||
|  |         private decimal _stockSumCountIn, _stockBulkCountIn, _stockBatch1CountIn, _stockBatch2CountIn; | |||
|  |         private decimal _stockSumCountOuting, _stockBulkCountOuting, _stockBatch1CountOuting, _stockBatch2CountOuting; | |||
|  |         public decimal stockSumCountIn | |||
|  |         { | |||
|  |             get { return _stockSumCountIn; } | |||
|  | 
 | |||
|  |         } | |||
|  |         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  stockSumCount | |||
|  |         { | |||
|  |             get { return _stockSumCount; } | |||
|  |              | |||
|  |         } | |||
|  |         public decimal  stockBulkCount | |||
|  |         { | |||
|  |             get { return _stockBulkCount; } | |||
|  | 
 | |||
|  |         } | |||
|  |         public decimal  stockBatch1Count | |||
|  |         { | |||
|  |             get { return _stockBatch1Count; } | |||
|  | 
 | |||
|  |         } | |||
|  |         public decimal stockBatch2Count | |||
|  |         { | |||
|  |             get { return _stockBatch2Count; } | |||
|  | 
 | |||
|  |         } | |||
|  |         private List<WmsStock> _stocks; | |||
|  | 
 | |||
|  |         public List<WmsStock> stocks | |||
|  |         { | |||
|  |             get { | |||
|  |                 if (_stocks == null) | |||
|  |                 {   | |||
|  |                      _stocks = new List<WmsStock>(); | |||
|  |                      | |||
|  |                 } | |||
|  |                   | |||
|  |                 return _stocks;  | |||
|  |             } | |||
|  |               | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 取得商品的即时库存 | |||
|  |         /// </summary> | |||
|  |         /// <param name="goodsId"></param> | |||
|  |         /// <param name="batch"></param> | |||
|  |         public void getStockInfo(string goodsId,string batch, enumWhType whType = enumWhType.合格库) | |||
|  |         { | |||
|  |             cmdParameters[0] = goodsId; | |||
|  |             cmdParameters[1] = batch; | |||
|  |             cmdParameters[2] = (int)whType; | |||
|  |             DataTable dt = CustQuery(400).Tables[0]; | |||
|  |             _stocks = 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; | |||
|  |             foreach (DataRow dr in dt.Rows){ | |||
|  | 
 | |||
|  |                 WmsStock st = new WmsStock(dr); | |||
|  |                 | |||
|  |                 _stocks.Add(st); | |||
|  |                 decimal cnt = st.count - st.countOut; | |||
|  |                 _stockSumCount += cnt; | |||
|  |                 _stockSumCountIn +=st.countIn; | |||
|  |                 _stockSumCountOuting += st.countOuting;  | |||
|  | 
 | |||
|  |                 switch (st.location.whVolType) | |||
|  |                 { | |||
|  |                     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; | |||
|  | 
 | |||
|  |                 }  | |||
|  | 
 | |||
|  |             }  | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  |     } | |||
|  | } | |||
|  |   |