/// 
///WCF service
///FOR TABLE t_wmsPlate
///By wm  
///on 05/22/2020
/// 
  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DeiNiu.wms.Logical;
using System.Data;
using DeiNiu.wms.Data.Model;
using DeiNiu.Utils;
namespace DeiNiu.Wcf
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名 。
    public class WmsPlateService: basicService,  IWmsPlate 
    {
        private static  lWmsPlate  _lWmsPlate ;
         lWmsPlate  lWmsPlateObj
        {
            get
            {
                if ( _lWmsPlate  == null ||   _lWmsPlate.operId != getOperId())
                {
                     _lWmsPlate= new  lWmsPlate(getOperId());
                }
                return  _lWmsPlate;
            }
        }
         private static lWmsOutDesk _lWmsOutDesk;
         lWmsOutDesk lWmsOutDeskObj
         {
             get
             {
                 if (_lWmsOutDesk == null || _lWmsOutDesk.operId != getOperId())
                 {
                     _lWmsOutDesk = new lWmsOutDesk(getOperId());
                 }
                 return _lWmsOutDesk;
             }
         }
        public DataSet query(string querystr, int rownumStart, int rownumEnd)
        {
            return   lWmsPlateObj.Query(querystr, rownumStart, rownumEnd);
        }
        public int add(WcfWmsPlate wcfData,int count)
        {
            return lWmsPlateObj.add(getDbObject(wcfData), count); 
        }
        public bool update(List wcfs) 
        {
            foreach (WcfWmsPlate wv in wcfs)
            {
                getDbObject(wv).Update();
            }
            return true;
        }
        public int delete(WcfWmsPlate wcfData)
        {
            return wcfData.getDbObject().Delete();
        }
        WmsPlate getDbObject(WcfWmsPlate wcfBox)
        {
            return wcfBox.getDbObject();
            /*
            WmsPlate dbObj = new WmsPlate(wcfBox.id);
            dbObj.ID = wcfBox.id;
            dbObj.color = wcfBox.color;
            dbObj.partion = wcfBox.partion;
            dbObj.load = wcfBox.load;
            dbObj.volume = wcfBox.volume;
            dbObj.length = wcfBox.length;
            dbObj.width = wcfBox.width;
            dbObj.height = wcfBox.height;
            dbObj.type = wcfBox.type;
            dbObj.state = wcfBox.state;  
            dbObj.plateLevel = wcfBox.plateLevel;
            dbObj.inPlate = wcfBox.inPlate;
            wcfBox.getDbObject();
           // dbObj.plateLevel = wcfBox.plateLevel>0? wcfBox.plateLevel : wcfBox.type;
     
            return dbObj;
            */
        }
       public int inPlate(string plateId, int type, string goodsId, string barcode, int skuId, decimal count, string orderNo)
        {
            return (int) lWmsPlateObj.inPlate(plateId, (Utils.enumPlateStatus)type, goodsId, barcode, skuId, count, orderNo);
        }
        //-------desk begin
        public  int updateDeskType(int id,int type) {
            return lWmsOutDeskObj.updateDeskType(id, (enumDeskType)type);
        }
        public int updateDeskStatus(int id, int status)
        {
             return lWmsOutDeskObj.updateDeskStatus(id, (enumDeskState)status);
         }
        public int updateDeskSeedsCnt(int id, int seedsCnt)
         {
             return lWmsOutDeskObj.updateDeskSeedsCnt(id, seedsCnt);
         }
        public DataSet queryDesk(string querystr, int rownumStart, int rownumEnd)
         {
             return lWmsOutDeskObj.Query(querystr, rownumStart, rownumEnd);
         }
        public int updateDesk(int id, int type, int status, int seedsCnt,int minSeedsCnt)
        {
            return lWmsOutDeskObj.updateDesk(id, (enumDeskType)type, (enumDeskState)status, seedsCnt, minSeedsCnt);
        }
    }
}