using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;
using DeiNiu.Utils;
namespace DeiNiu.Wcf
{
    /// 
    /// wince 专用
    /// 
    [ServiceContract]
    public interface IMobile
    {
        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
          UriTemplate = "validuser?userId={userId}&passwd={passwd}")]
        int validUser(string userId, string passwd);
        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
          UriTemplate = "login?userId={userId}&passwd={passwd}")]
        string login(string account, string passwd);
        [OperationContract]
        DataTable getDictionary();
        /// 
        ///取移动端权限列表
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        List getPortAuths(int userId, string token);
        /// 
        ///取所有线路
        /// 
        /// 可为null,取所有线路 
        /// 
        [OperationContract]
        List getLines(string custName);
        
        /// 
        ///取所属货区
        /// 
        /// 
        /// 
        [OperationContract]
        List getPartions(int userId);
        [OperationContract]
        int validRole(string account,string passwd,string role);
        
        //-------------------------  stock location begin ------------------------------------------------------------------------------------------
        /// 
        /// get stock goods info by locid
        /// for wince
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getStockLocation(string locId);
        [OperationContract]
        DataTable getStockLocationsByBarcode(string barcode);
        /// 
        ///  update stock goods info
        ///  on wince stock check
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool updateStockLocation(string locId, string goodsId, int skuId, string batch, decimal count, string reason, int type, int operId, string token);
      
        
        [OperationContract]
        int initialStockIn(string goodsId,string locId, decimal batchCount, string[] skuKeys, string[] skuValues, int operId, string token);
        
        
        /// 
        /// clear the location
        /// on wince
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool clearLocation(string locId, string reason, int operId, string token);
        /// 
        /// 更新location status
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool upLocationStatus(string locId, int status, int operId, string token);
        /// 
        /// 更新商品库容量
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool updateGoodsLocationVolume(string goodsId, int volType, decimal volume, int operId, string token);
        /// 
        /// location info
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getLocation(string locId);
        /// 
        /// 扫描货位,得到货架上的商品信息,比较该商品在erp和wms库存
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getStockCompareErp(string goodsId, string barcode);
    
        /// 
        /// 手持上下架
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        int upDownStockLocation(string locId, string goodsId, int skuId, string batch, decimal count, int type, int operId, string token, int oldRecId);
        /// 
        /// 已下架待上架商品
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getDownStockList4Up(int operId);
        //绑定id
        [OperationContract]
        int locationEleIdCombine(string locId, int eleId, int operId, string token);
        /// 
        /// 补零入库
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        int repItemIn(string locId, string goodsId, int skuId, string batch, decimal count, int portId, int operId, string token);
        /// 
        /// 货位分配
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getLocations(int skuId, string skuCode, string goodsId, string batch, decimal count);  
        /// 
        /// 根据商品找库存货位信息
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getGoodsStockLocations(string barcode);
      
        /// 
        /// get erp storage by barcode
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getGoodsERPStoreByBarcode(string barcode);
        /// 
        /// get pandian orders by ownerid and status
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
       DataTable getPandianOrders(int ownerId,int status);
        [OperationContract]
        DataTable getPandianItem(string orderNo, string locationId);
        /// 
        /// 盘点采集
        /// 
        /// 
        /// 
        [OperationContract]
        bool newPandianItem(string orderNo, string locationId, int skuId, string barcode, string prdDate,
              string batch, decimal count, int operId, string token);
        //-----------------------stock maintain begin --------------------------------------------------------------
        [OperationContract]
        DataSet getData4Maintain(string locationId = "");
        [OperationContract]
        DataTable getIssueData(int skuId);
         
        /// 
        /// new maintain record
        /// 
        /// 
        [OperationContract]
        bool newMaintain(int stockId,decimal mCount,decimal issueCount, string details, int operId,string token);
        [OperationContract]
        bool fixIssueData(int skuId, int operId, string token);
       // -------------------stock In request begin --------------------------------------------------------------------------------------------------
      
        // 根据预到单收货
        [OperationContract]
        DataTable getPreInDetail(string preInNo,int operId, string token);
     //   [OperationContract]
    //    DataTable getPreInInfo(string preInNo, int operId, string token);
        [OperationContract]
        bool receiveDetail(string preInNo, string goodsId, decimal arriveNumber, decimal receiveNumber, int inType, string inRemark,
            decimal temperature, bool isCache, int cachePartion, int operId, string token);
        [OperationContract]
        DataTable getGoodsPackByBarcode(string barcode);
        [OperationContract]
        DataTable getReceiveDetailByBarcode(string preInOrder, string barcode);
        [OperationContract]
        decimal getValidSeedsCnt(string goodsId, decimal batchCount);
        [OperationContract]
        bool isFlowNoValid(string preInOrder, string flowNo);
        [OperationContract]
        int validIn(string preInNo, string flowNo, string goodsId, decimal batchCount, decimal seedsCount,
            string[] skuKeys, string[] skuValues, bool isPass, bool isIsuLocations, int secondValidUserId, int operId, string token);
        [OperationContract]
        DataTable getPreValidResult(string preInNo, string flowNo, int operId, string token,bool showAllPartions=false);
         [OperationContract]
        DataTable getStockInPortDetail(int portId);
         [OperationContract]
         DataTable getStockInDetails(string flowNo);
        [OperationContract]
        int finishUpShelfItem(string orderNo, int id, decimal count, string locationId,string reason, int operId, string token);
        // -------------------stock OUT request begin --------------------------------------------------------------------------------------------------
        /// 
        /// 取待复核订单列表
        /// 
        /// 
        [OperationContract]
        DataTable getBatchPickOrders4Valid();
        /// 
        /// 取待复核订单明细
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getPickOrderDetails(string orderNo);
         
        /// 
        /// get batch pick detail by port record id
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable getPickDetail(int Id);
        /// 
        /// 手持捡完一个货位,更新状态
        /// 检测到出库单所有整货都已经分拣完毕后将更新订单明细及订单 batchPickStatus,status
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool finishPickItem(string flowNo,string waveNo, string pickOrderNo, int id, decimal pickCount, int operId, string token);
        /// 
        /// 手持复核一个货位,更新状态
        /// 检测到出库单所有整货都已经复核完毕后将更新订单明细及订单 batchPickStatus,status
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        bool finishBatchValidateItem(string pickOrderNo, int id, int operId, int checkBy2, string token);
        [OperationContract]
        int batchPickCount4Valid(string pickOrderNo);
        /// 
        /// 当天待分拣补货明细
        /// 
        /// 
        /// 
        [OperationContract]
        DataTable repTodayDetails4Pick(int userId=0);
        /// 
        /// 待上架补货任务
        /// 
        ///         
        [OperationContract]
        DataTable repInDetailsByFlowNo(string flowNo,int operId,string token);
        [OperationContract]
        int regSeedsPlate(string plateId, int partion);
        [OperationContract]
        DataTable getPlatePickList(string plateId, int partion);
        //获取出库下架任务
        [OperationContract]
        DataTable getTaskAssigned(int operId, int partion  , int lineId , bool batchOnly ,int orderType);
        [OperationContract]
        DataTable taskAssign(int partion, int lineId, bool batchOnly, int orderType, int operId, string token);
        [OperationContract]
        int taskResign(int partion, int lineId, bool batchOnly, int orderType, int operId, string token); 
        // ------------------TMS  begin --------------------------------------------------------------------------------------------------
 
        /// 
        /// 有打包零货待装车的运输单
        /// 
        /// 
        
        [OperationContract]
        DataTable getTransRequestsWithBulks();
        /// 
        /// 待装车的运输单打包零货列表
        /// 
        /// 
        [OperationContract]
        DataTable getTransRequestsBulks(string transNo);
        /// 
        ///从零库集货区取走零货打包
        /// 
        /// 
        [OperationContract]
        bool pickBulks(string tranNo, int stockId,int operId, string token);
         /// 
        /// 待装车的运输单打包零货列表
        /// 
        /// 
        [OperationContract]
        DataTable getTransRequestsByStatus(int status);
        /// 
        /// 运输单拣货单列表
        /// 
        /// 
        [OperationContract]
        DataTable getTransRequestsDetail(string transNo,int status);
        /// 
        /// 装车
        /// 
        /// 
        /// 
        /// 
        /// 
        [OperationContract]
        string loadTrucks(string transNo, string pickOrderNo, int tranDetailId, int operId, string token);
        //-------------------------box reg---------------------------------
        [OperationContract]
        int regPartBox(int partion, string boxId, int operId, string token);
        [OperationContract]
        DataTable getPartionRequests(int partion, int operId, string token);
        [OperationContract]
        DataTable getLightPartions(int operId, string token);
        //------------------------------------------------task centers-------------------------------------
        [OperationContract]
        DataTable getTasks(int status,int partion,int emId,int operId, string token);
        [OperationContract]
        DataTable getTaskDetails(string tastNo, int operId, string token);
        [OperationContract]
        DataTable getFlowDetails(string flowNo, int operId, string token);
        [OperationContract]
        DataTable getTaskInfo(string taskNo, int operId, string token);
        [OperationContract]
        enumFlowTaskResult startTask(string taskNo, int operId, string token);
         
        //---亮灯
        [OperationContract]
        string getLightService();
        [OperationContract]
        [WebInvoke(
            Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "getLabels"
            )]
        List getLabels();
    }
    [DataContract]
    public class ELabel
    {
        [DataMember]
        public int labelId { get; set; }
        [DataMember]
        public int address { get; set; }
        [DataMember]
        public int count { get; set; }
        [DataMember]
        public int color { get; set; }
        [DataMember]
        public int port { get; set; }
        [DataMember]
        public int orderNo { get; set; }
    }
}