using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; using DeiNiu.wms.Logical; using DeiNiu.Utils; using WcfServiceAuthentication; using DeiNiu.wms.Data.Model; using System.Data; using DeiNiu.Wcf; namespace DeiNiu.Wcf { // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。 public class MobileService : basicService, IMobile { public int validUser(string userId, string passwd) { Employee emp = new Employee(); return emp.ValidUser(userId, passwd); } public string login(string account, string passwd) { Employee em = new Employee(); string token = null; if (em.login(account, passwd)) { token = em.token; AuthenticationInspector.authCach[em.ID] = token; } return em.ID + ":" + token + ":" + em.em_account; } private int operId =0; protected new int getOperId() { //wince set auth in the each function return operId; } protected void validUser(int operId, string token) { bool isValid = AuthenticationInspector.validUser(operId, token); if (!isValid) { throw new Exception("非授权用户访问"); } setOperId(operId, token); } protected void setOperId(int operId, string token) { this.operId = operId; this.token = token; } public List getPortAuths(int userId, string token) { validUser(userId, token); //针对wince访问,手动验证用户 Dictionary> auths = new LAuthority().getMobileAuthorities(userId); List auth = new List(); if (auths.Keys.Contains("移动设备")) { List portAuth = auths["移动设备"]; foreach (Authority au in portAuth) { auth.Add(au.auth_name); } } if (auths.Keys.Contains("细分权限")) { List portAuth = auths["细分权限"]; foreach (Authority au in portAuth) { auth.Add(au.auth_name); } } return auth; } public DataTable getDictionary() { return new lNode().QueryByFlags(); } public List getLines(string custName) { DataTable dt = new lTmsLineDetail().getAllLines(custName); List lines = new List(); foreach (DataRow dr in dt.Rows) { lines.Add(dr["id"].ToString() + WmsConstants.SPLIT + dr["name"].ToString()); } return lines; } /// ///取所属货区 /// /// /// public List getPartions(int userId) { DataTable dt = lport.getPartions(userId); List partions = new List(); foreach (DataRow dr in dt.Rows) { partions.Add(dr["partion"].ToString() + WmsConstants.SPLIT + dr["partName"].ToString()); } return partions; } public int validRole(string account, string passwd, string role) { return new LAuthority().validUserRole(account, passwd, role); } //------------------------- stock location begin ------------------------------------------------------------------------------------------ private static lWmslocation _loc; private static lWmsStock _stock; private static lWmsStockPandian _pandian; lWmsStockPandian pandian { get { if (_pandian == null || _pandian.operId != getOperId()) { _pandian = new lWmsStockPandian(getOperId()); } return _pandian; } } lWmsStock lstock { get { if (_stock == null || _stock.operId != getOperId()) { _stock = new lWmsStock(getOperId()); } return _stock; } } lWmslocation loc { get { if (_loc == null || _loc.operId != getOperId()) { _loc = new lWmslocation(getOperId()); } return _loc; } } public void addLocations(Structs locs) { loc.addLocations(locs); } public DataTable getStockLocation(string locId) { return lstock.getStockLocation(locId); } public DataTable getStockLocationsByBarcode(string Barcode) { return lstock.wmsStock.queryByGoodsBarcode(Barcode).Tables[0]; } public int initialStockIn(string goodsId, string locId, decimal batchCount, string[] skuKeys, string[] skuValues, int operId, string token) { validUser(operId, token); Dictionary sku = new Dictionary(); for (int i = 0; i < skuKeys.Length; i++) { sku.Add(skuKeys[i], skuValues[i]); } // return (int)lstock.initialStockIn( goodsId,locId, batchCount , sku ); return 1; } public bool updateStockLocation(string locId, string goodsId, int skuId,string batch, decimal count, string reason, int type, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return lstock.updateStockLocation(locId, goodsId,skuId, batch, count, reason, (enumStockRecordType)type); } public int upDownStockLocation(string locId, string goodsId, int skuId, string batch, decimal count, int type, int operId, string token, int oldRecId) { validUser(operId, token); //针对wince访问,手动验证用户 return (int)lstock.upDownGoodsCountWithLocation(locId, goodsId,skuId, batch, count, "", (enumStockRecordType)type, oldRecId); } public DataTable getDownStockList4Up(int operId) { return lstock.wmsStock.getLocationDownList4Up(operId); } public bool clearLocation(string locId, string reason, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return lstock.clearLocation(locId, reason); } public bool upLocationStatus(string locId, int status, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return lstock.updateLocationStatus(locId, status); } public bool updateGoodsLocationVolume(string goodsId, int volType, decimal volume, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return lstock.updateGoodsLocationVolume(goodsId, volType, volume); } public DataTable getLocation(string locId) { return loc.getWmslocation.getLocationDt(locId); } public DataTable getStockCompareErp(string goodsId, string barcode) { return lstock.wmsStock.getStockLocationCompareErp(goodsId, barcode); } public int locationEleIdCombine(string locId, int eleId, int operId, string token) { validUser(operId, token); return loc.locationEleIdCombine(locId, eleId); } public int repItemIn(string locId, string goodsId, int skuId, string batch, decimal count, int portId, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return (int)lstock.repItemIn(locId, goodsId,skuId, batch, count, portId); } public DataTable getLocations(int skuId,string skuCode,string goodsId, string batch, decimal count) { try { DataTable dt = lstock.getBulkLocations(skuId, skuCode, goodsId, batch, count); return dt; } catch (Exception e) { throw e; } } public DataTable getGoodsStockLocations(string barcode) { return lstock.wmsStock.getGoodsStockLocations(barcode); } public DataTable getGoodsERPStoreByBarcode(string barcode) { return lstock.wmsStock.getGoodsERPStoreByBarcode(barcode); } public DataTable getPandianItem(string orderNo, string locationId) { return pandian.getPandianResultItem(orderNo, locationId); } public DataTable getPandianOrders(int ownerId, int status) { return pandian.getWmsStockPandian.getPandianOrders(ownerId, status); } public bool newPandianItem(string orderNo, string locationId, string barcode, string prdDate, string batch, decimal count, int operId, string token) { validUser(operId, token); return pandian.newPandianItem( orderNo, locationId, -1, barcode, prdDate, batch, count); } //-----------------------stock maintain begin -------------------------------------------------------------- public DataSet getData4Maintain(string locationId = "") { return new WmsStockMaintain().getData4Maintain(locationId); } public DataTable getIssueData(int skuId=0) { return new WmsStockMaintain().getIssueData(skuId); } public bool newMaintain(int stockId, decimal mCount, decimal issueCount, string details, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 try { return lstock.newMaintain(stockId, mCount, issueCount, details); } catch (Exception e) { throw e; } } public bool fixIssueData(int skuId, int operId, string token) { validUser(operId, token); //针对wince访问,手动验证用户 return lstock.fixIssueData(skuId); } //------------------------- stock In Request begin ------------------------------------------------------------------------------------------ static lWmsInRequest _lir; lWmsInRequest lir { get { if (_lir == null || _lir.operId != getOperId()) { _lir = new lWmsInRequest(getOperId()); } return _lir; } } public DataTable getGoodsPackByBarcode(string barcode) { return lir.getGoodsPackByBarcode(barcode); } public DataTable getStockInPortDetail(int portId) { return lir.getPortStockInDetailByPortId(portId); } public DataTable getStockInDetails(string flowNo) { return lir.getPortStockInDetailsByFlowNo( flowNo); } public int finishUpShelfItem(string orderNo, int id, decimal count, string locationId, string reason, int operId, string token) { validUser(operId, token); return (int)lir.finishUpShelfItem(orderNo,id,count,locationId,reason); } public DataTable getPreInDetail(string preInNo,int operId, string token) { validUser(operId, token); return lir.getPreInDetail(preInNo); } public DataTable getReceiveDetailByBarcode(string preInOrder, string barcode) { return lir.getReceiveDetailByBarcode( preInOrder,barcode); } public bool vaildTransTemperature(string goodsId,decimal temperature) { return true; } public bool receiveDetail(string preInNo, string goodsId, decimal arriveNumber, decimal receiveNumber, int inType, string inRemark, decimal temperature, bool isCache, int cachePartion, int operId, string token) { validUser(operId, token); //TODO: valid goods temperature return lir.receivePreDetail(preInNo, goodsId,arriveNumber, receiveNumber, inType, inRemark, isCache, cachePartion,temperature); } public decimal getValidSeedsCnt(string goodsId, decimal batchCount) { return lir.getValidSeedsCnt(goodsId, batchCount); } public bool isFlowNoValid(string preInOrder, string flowNo) { return lir.isFlowNoValid(preInOrder, flowNo); } public 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) { validUser(operId, token); Dictionary sku = new Dictionary(); for (int i =0;i /// 有打包零货待装车的运输单 /// /// public DataTable getTransRequestsWithBulks() { return ltr.getTmsTranRequest.getTransRequestsWithBulks4Wince(); } /// /// 待装车的运输单打包零货列表 /// /// public DataTable getTransRequestsBulks(string transNo) { return ltr.getTmsTranRequest.getTransRequestsBulks4Wince(transNo); } /// ///从零库集货区取走零货打包 /// /// public bool pickBulks(string transNo, int stockId, int operId, string token) { validUser(operId, token); return ltr.pickBulks(transNo, stockId); } /// /// 待装车的运输单打包零货列表 /// /// public DataTable getTransRequestsByStatus(int status) { return ltr.getTmsTranRequest.getTransRequestsByStatus4Wince((enumTranStatus)status); } /// /// 运输单拣货单列表 /// /// public DataTable getTransRequestsDetail(string transNo, int status) { return ltr.getTmsTranRequest.getTransRequestsDetail4Wince(transNo, (enumTranDetailStatus)status); } /// /// 装车 /// /// /// /// /// public string loadTrucks(string transNo, string pickOrderNo, int tranDetailId, int operId, string token) { return ltr.loadTrucks(transNo, pickOrderNo, tranDetailId); } /// /// 分区分拣注册箱子 /// /// /// /// /// /// public int regPartBox(int partion, string boxId, int operId, string token) { validUser(operId, token); return (int)lop.regPartBox(partion, boxId); } public DataTable getPartionRequests(int partion,int operId,string token) { validUser(operId, token); return lop.getPartionRequests(partion ); } public DataTable getLightPartions(int operId, string token) { // validUser(operId, token); return lop.getLightPartions(); } public string getLightService() { lop.initialConstants(); return WmsConstants.LIGHT_SVR_ADDRESS; } public List getLabels() { ELabel el = new ELabel(); List lst = new List(); for (int i = 0; i < 10; i++) { el = new ELabel(); el.address = 20 + i; el.color = 2; el.count = 100 + i; el.labelId = i + 1; el.orderNo = i + 1; el.port = 12; lst.Add(el); } return lst; } //----task center private static lWmsFlow _lWmsFlow; lWmsFlow lWmsFlowObj { get { if (_lWmsFlow == null || _lWmsFlow.operId != getOperId()) { _lWmsFlow = new lWmsFlow(getOperId()); } return _lWmsFlow; } } public DataTable getTasks(int status, int partion, int emId, int operId, string token) { // validUser(operId, token); return lWmsFlowObj.getTasks(status, partion, emId); } public DataTable getTaskDetails(string taskNo, int operId, string token) { validUser(operId, token); return lWmsFlowObj.getTaskDetail(taskNo); } public DataTable getFlowDetails(string flowNo, int operId, string token) { validUser(operId, token); return lWmsFlowObj.getFlowDetail(flowNo); } public DataTable getTaskInfo(string taskNo, int operId, string token) { validUser(operId, token); return lWmsFlowObj.getTaskInfo(taskNo); } public enumFlowTaskResult startTask(string taskNo,int operId, string token) { validUser(operId, token); return lWmsFlowObj.startTask(taskNo); } bool IMobile.finishPickItem(string flowNo, string waveNo, string pickOrderNo, int id, decimal pickCount, int operId, string token) { throw new NotImplementedException(); } public bool newPandianItem(string orderNo, string locationId, int skuId, string barcode, string prdDate, string batch, decimal count, int operId, string token) { throw new NotImplementedException(); } } }