using iWareSAP.Cache.Entity;
using iWareSAP.IDOC.Entity;
using iWareSAP.PARAM.Entity;
using iWareSAP.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using UtilDll.UTIL;
namespace iWareSAP.WCF
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“SapWcfService”。
public class SapWcfService : ISapWcfService
{
///
/// 根据采购单号获取采购单
///
///
///
///
public PurchaseOrderEntity GetPurchaseOrder(string poNumber, out string msg)
{
try
{
msg = "";
LogTextHelper.WriteLine(Resources.LogDir, "调用接口{0},poNumber={1}", "GetPurchaseOrder", poNumber);
var po = CacheEntity.SapncoClient.InvokeRFCFunctionGetPoDetail(poNumber, out msg);
if (!string.IsNullOrEmpty(msg))
{
LogTextHelper.WriteLine(Resources.LogDir, "msg={0}", msg);
return null;
}
var purchaseOrder = new PurchaseOrderEntity(po);
if (purchaseOrder != null)
{
LogTextHelper.WriteLine(Resources.LogDir, "purchaseOrder={0}", purchaseOrder);
}
return purchaseOrder;
}
catch (Exception ex)
{
msg = ex.Message;
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "GetPurchaseOrder", msg);
return null;
}
}
///
/// 获取采购单的展示字符传
///
///
///
///
public string GetPurchaseOrderTxt(PurchaseOrderEntity po)
{
return po == null ? "" : po.ToString();
}
///
/// 对收到的物料进行收货确认
///
///
///
///
public string ConfirmGR(List grMaterials, out string msg)
{
try
{
msg = "";
var grStr = "";
grMaterials.ForEach(x => grStr += x.ToString() + "\r\n");
LogTextHelper.WriteLine(Resources.LogDir, "调用接口{0},grMaterials={1}", "ConfirmGR", grStr);
var grs = new List();
grMaterials.ForEach(x => grs.Add(new GRMaterial(x)));
var materialDoc = CacheEntity.SapncoClient.InvokeRFCFunctionPoGR(grs, out msg);
if (!string.IsNullOrEmpty(msg))
{
LogTextHelper.WriteLine(Resources.LogDir, "msg={0}", msg);
}
else
{
LogTextHelper.WriteLine(Resources.LogDir, "materialDoc={0}", materialDoc);
}
return materialDoc;
}
catch (Exception ex)
{
msg = ex.Message;
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "ConfirmGR", msg);
return "";
}
}
///
/// 对物料进行出库确认
///
///
///
///
public string ConfirmGI(List giMaterials, out string msg)
{
try
{
msg = "";
var giStr = "";
giMaterials.ForEach(x => giStr += x.ToString() + "\r\n");
LogTextHelper.WriteLine(Resources.LogDir, "调用接口{0},giMaterials={1}", "ConfirmGI", giStr);
var gies = new List();
giMaterials.ForEach(x => gies.Add(new GIMaterial(x)));
var materialDoc = CacheEntity.SapncoClient.InvokeRFCFunctionWmsGI(gies, out msg);
if (!string.IsNullOrEmpty(msg))
{
LogTextHelper.WriteLine(Resources.LogDir, "msg={0}", msg);
}
else
{
LogTextHelper.WriteLine(Resources.LogDir, "materialDoc={0}", materialDoc);
}
return materialDoc;
}
catch (Exception ex)
{
msg = ex.Message;
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "ConfirmGI", msg);
return "";
}
}
///
/// 对物料进行移库确认
///
///
///
///
public string ConfirmMOV(List movMaterials, out string msg)
{
try
{
msg = "";
var movStr = "";
movMaterials.ForEach(x => movStr += x.ToString() + "\r\n");
LogTextHelper.WriteLine(Resources.LogDir, "调用接口{0},movMaterials={1}", "ConfirmMOV", movStr);
var movs = new List();
movMaterials.ForEach(x => movs.Add(new MovMaterial(x)));
var materialDoc = CacheEntity.SapncoClient.InvokeRFCFunctionWmsStkMov(movs, out msg);
if (!string.IsNullOrEmpty(msg))
{
LogTextHelper.WriteLine(Resources.LogDir, "msg={0}", msg);
}
else
{
LogTextHelper.WriteLine(Resources.LogDir, "materialDoc={0}", materialDoc);
}
return materialDoc;
}
catch (Exception ex)
{
msg = ex.Message;
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "ConfirmMOV", msg);
return "";
}
}
///
/// 根据物料凭证退物料
///
///
///
///
public string WmsReverser(string doc, out string msg)
{
try
{
msg = "";
LogTextHelper.WriteLine(Resources.LogDir, "调用接口{0},doc={1}", "WmsReverser", doc);
var res = CacheEntity.SapncoClient.InvokeRFCFunctionWmsReverser(doc, out msg);
LogTextHelper.WriteLine(Resources.LogDir, "res={0},msg={1}", res, msg);
return res;
}
catch (Exception ex)
{
msg = ex.Message;
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "WmsReverser", msg);
return null;
}
}
}
}