ldj/WcfService1/MobileService.svc.cs

748 lines
23 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
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<string> getPortAuths(int userId, string token)
{
validUser(userId, token); //针对wince访问手动验证用户
Dictionary<String, List<Authority>> auths = new LAuthority().getMobileAuthorities(userId);
List<string> auth = new List<string>();
if (auths.Keys.Contains("移动设备"))
{
List<Authority> portAuth = auths["移动设备"];
foreach (Authority au in portAuth)
{
auth.Add(au.auth_name);
}
}
if (auths.Keys.Contains("细分权限"))
{
List<Authority> portAuth = auths["细分权限"];
foreach (Authority au in portAuth)
{
auth.Add(au.auth_name);
}
}
return auth;
}
public DataTable getDictionary()
{
return new lNode().QueryByFlags();
}
public List<string> getLines(string custName)
{
DataTable dt = new lTmsLineDetail().getAllLines(custName);
List<string> lines = new List<string>();
foreach (DataRow dr in dt.Rows)
{
lines.Add(dr["id"].ToString() + WmsConstants.SPLIT + dr["name"].ToString());
}
return lines;
}
/// <summary>
///取所属货区
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public List<string> getPartions(int userId)
{
DataTable dt = lport.getPartions(userId);
List<string> partions = new List<string>();
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<string, string> sku = new Dictionary<string, string>();
for (int i = 0; i < skuKeys.Length; i++)
{
sku.Add(skuKeys[i], skuValues[i]);
}
2023-09-04 22:41:19 +08:00
// return (int)lstock.initialStockIn( goodsId,locId, batchCount , sku );
return 1;
2023-05-23 16:13:17 +08:00
}
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.getLocations(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)
{
2023-11-21 19:18:23 +08:00
return pandian.getPandianResultItem(orderNo, locationId);
2023-05-23 16:13:17 +08:00
}
public DataTable getPandianOrders(int ownerId, int status)
{
return pandian.getWmsStockPandian.getPandianOrders(ownerId, status);
}
2023-11-21 19:18:23 +08:00
public bool newPandianItem(string orderNo, string locationId, string barcode, string prdDate,
2023-05-23 16:13:17 +08:00
string batch, decimal count, int operId, string token)
{
validUser(operId, token);
2023-11-21 19:18:23 +08:00
return pandian.newPandianItem( orderNo, locationId, -1, barcode, prdDate, batch, count);
2023-05-23 16:13:17 +08:00
}
//-----------------------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<string, string> sku = new Dictionary<string, string>();
for (int i =0;i<skuKeys.Length;i++ )
{
sku.Add(skuKeys[i], skuValues[i]);
}
2023-09-04 22:41:19 +08:00
return (int)lir.validIn(preInNo, flowNo, goodsId.Trim(), batchCount, seedsCount, sku, isPass, isIsuLocations,false, secondValidUserId);
2023-05-23 16:13:17 +08:00
}
public DataTable getPreValidResult(string preInNo, string flowNo, int operId, string token,bool showAllPartions=false)
{
validUser(operId, token);
return lir.getPreValidResult4Wince(preInNo, flowNo, showAllPartions );
}
//------------------------- stock OUT request begin ------------------------------------------------------------------------------------------
private static lWmsOutPickRequest _lop;
private static lWmsOutPickPort _lport;
lWmsOutPickRequest lop
{
get
{
if (_lop == null || _lop.operId != getOperId())
{
_lop = new lWmsOutPickRequest(getOperId());
}
return _lop;
}
}
lWmsOutPickPort lport
{
get
{
if (_lport == null || _lport.operId != getOperId())
{
_lport = new lWmsOutPickPort(getOperId());
}
return _lport;
}
}
/*
public bool completeBatchOut(string pickOrderNo)
{
return lop.updateBatchPickStatus(pickOrderNo, enumOutStockPickStatus.);
}*/
public DataTable getPickDetail(int Id)
{
//return lop.getWmsOutPickRequest.getPickDetail(Id);
return lop.getPortOutPickOrderDetail(Id);
}
2023-11-21 19:18:23 +08:00
public enumPickResult finishPickItem(string flowNo,string waveNo,string pickOrderNo, int id,decimal pickCount, int operId, string token)
2023-05-23 16:13:17 +08:00
{
validUser(operId, token); //针对wince访问手动验证用户
return lop.finishPickItem(flowNo, waveNo, pickOrderNo, id, pickCount);
}
public bool finishBatchValidateItem(string pickOrderNo, int id, int operId,int checkBy2, string token)
{
validUser(operId, token);
return lop.finishBatchValidateItem(pickOrderNo, id, checkBy2);
}
public DataTable getBatchPickOrders4Valid()
{
return lop.getBatchPickOrders4Validate();
}
public DataTable getPickOrderDetails(string orderNo)
{
return lop.getWmsOutPickRequest.getBatchPickOrderDetail4Wince(orderNo);
}
public int batchPickCount4Valid(string pickOrderNo)
{
return lop.getPickCount4valid(pickOrderNo);
}
public DataTable repTodayDetails4Pick(int userId = 0)
{
return lop.repTodayDetails4Pick(userId);
}
public DataTable repInDetailsByFlowNo(string flowNo,int operId,string token)
{
validUser(operId, token);
return lop.repTodayDetails4In(flowNo);
}
public int regSeedsPlate(string plateId, int partion)
{
return (int)lop.regSeedsPlate(plateId, partion);
}
public DataTable getPlatePickList(string plateId, int partion)
{
return lop.getPlatePickTaskList4wince(plateId, partion);
}
public DataTable getTaskAssigned(int operId, int partion , int lineId , bool batchOnly ,int orderType)
{
2023-11-21 19:18:23 +08:00
return lport.getAssignedTasks4Wince(operId, partion, lineId, batchOnly, (enumOrderType)orderType);
2023-05-23 16:13:17 +08:00
}
public DataTable taskAssign(int partion, int lineId, bool batchOnly, int orderType, int operId, string token)
{
validUser(operId, token);
2023-11-21 19:18:23 +08:00
lport.taskAssign(operId, partion, lineId, 0, 0, WmsConstants.OUT_TASK_ASSIGN_BATCH_ONLY, (enumOrderType)orderType);
2023-05-23 16:13:17 +08:00
return lport.getAssignedTasks4Wince(operId, partion, lineId, batchOnly);
}
public int taskResign(int partion, int lineId, bool batchOnly, int orderType, int operId, string token)
{
2023-11-21 19:18:23 +08:00
return lport.taskRessign(operId, partion, lineId, batchOnly, (enumOrderType)orderType); ;
2023-05-23 16:13:17 +08:00
}
// ------------------TMS begin --------------------------------------------------------------------------------------------------
private static lTmsTranRequest _ltr;
lTmsTranRequest ltr
{
get
{
if (_ltr == null || _ltr.operId != getOperId())
{
_ltr = new lTmsTranRequest(getOperId());
}
return _ltr;
}
}
/// <summary>
/// 有打包零货待装车的运输单
/// </summary>
/// <returns></returns>
public DataTable getTransRequestsWithBulks()
{
return ltr.getTmsTranRequest.getTransRequestsWithBulks4Wince();
}
/// <summary>
/// 待装车的运输单打包零货列表
/// </summary>
/// <returns></returns>
public DataTable getTransRequestsBulks(string transNo)
{
return ltr.getTmsTranRequest.getTransRequestsBulks4Wince(transNo);
}
/// <summary>
///从零库集货区取走零货打包
/// </summary>
/// <returns></returns>
public bool pickBulks(string transNo, int stockId, int operId, string token)
{
validUser(operId, token);
return ltr.pickBulks(transNo, stockId);
}
/// <summary>
/// 待装车的运输单打包零货列表
/// </summary>
/// <returns></returns>
public DataTable getTransRequestsByStatus(int status)
{
return ltr.getTmsTranRequest.getTransRequestsByStatus4Wince((enumTranStatus)status);
}
/// <summary>
/// 运输单拣货单列表
/// </summary>
/// <returns></returns>
public DataTable getTransRequestsDetail(string transNo, int status)
{
return ltr.getTmsTranRequest.getTransRequestsDetail4Wince(transNo, (enumTranDetailStatus)status);
}
/// <summary>
/// 装车
/// </summary>
/// <param name="transNo"></param>
/// <param name="pickOrderNo"></param>
/// <param name="tranDetailId"></param>
/// <returns></returns>
public string loadTrucks(string transNo, string pickOrderNo, int tranDetailId, int operId, string token)
{
return ltr.loadTrucks(transNo, pickOrderNo, tranDetailId);
}
/// <summary>
/// 分区分拣注册箱子
/// </summary>
/// <param name="partion"></param>
/// <param name="boxId"></param>
/// <param name="operId"></param>
/// <param name="token"></param>
/// <returns></returns>
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<ELabel> getLabels()
{
ELabel el = new ELabel();
List<ELabel> lst = new List<ELabel>();
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);
}
2023-11-21 19:18:23 +08:00
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();
}
2023-05-23 16:13:17 +08:00
}
}