using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using wcftest.EnumDefine;
|
using wcftest.orm;
|
using wcftest.sendToSap;
|
|
namespace wcftest.BussinessExtension.Handle
|
{
|
/// <summary>
|
/// 推送SAP失败的记录表处理类
|
/// </summary>
|
public class SapSendFailRecodInfoHandler
|
{
|
/// <summary>
|
/// 出库的时候,新增 推送SAP失败的记录表
|
/// </summary>
|
/// <param name="context"></param>
|
/// <param name="outList"></param>
|
/// <param name="sapInfo"></param>
|
public static void AddForOutStore(GIMaterialEntity[] results, string _retResult, string _retMsg)
|
{
|
//Task.Run(() =>
|
//{
|
try
|
{
|
MoveTypeForSapSend moveTypeForSapSend = MoveTypeForSapSend.出库;
|
if (results != null && results.Length > 0)
|
{
|
using (dbModel context = new dbModel())
|
{
|
foreach (var entity in results)
|
{
|
SapSendFailRecodInfo item = new SapSendFailRecodInfo()
|
{
|
SendSapData = JsonConvert.SerializeObject(results),
|
MoveType = (int)moveTypeForSapSend,
|
MoveTypeName = moveTypeForSapSend.ToString(),
|
|
MaterialCode = entity.MaterialCode,
|
//MaterialName = entity.ma,
|
|
//PoCode = entity.PoNumber,//采购单号
|
SalesOrder = entity.SalesOrder,//销售单号
|
TrackingCode = "",//跟踪号
|
ItemNumber = "",//采购项号
|
SpecAlias = entity.SalesOrderItem,//销售项号
|
BigUnit = entity.Unit,//单位
|
ProductBarCode = entity.StorageLocation,//仓库号
|
Quantity = entity.Quantity,
|
WorkOrder = entity.WorkOrder,
|
|
RetMsg = _retMsg,
|
RetResult = _retResult
|
};
|
var product = BussinessExtension.GetProductInfoByCode(context, entity.MaterialCode);
|
if (product != null) item.MaterialName = product.ProductName;
|
|
item.Creator = item.LastModifier = " ";
|
item.CreateTime = item.LastModifyTime = DateTime.Now;
|
|
|
context.SapSendFailRecodInfo.Add(item);
|
}
|
|
context.SaveChanges();
|
}
|
}
|
}
|
catch (Exception)
|
{//吞掉异常
|
throw;
|
}
|
//});
|
}
|
|
/// <summary>
|
/// 收货的时候,新增 推送SAP失败的记录表
|
/// </summary>
|
/// <param name="context"></param>
|
/// <param name="outList"></param>
|
/// <param name="sapInfo"></param>
|
public static void AddForSH(GRMaterialEntity[] results, string _retResult, string _retMsg)
|
{
|
//Task.Run(() =>
|
//{
|
try
|
{
|
MoveTypeForSapSend moveTypeForSapSend = MoveTypeForSapSend.收货;
|
if (results != null && results.Length > 0)
|
{
|
using (dbModel context = new dbModel())
|
{
|
foreach (var entity in results)
|
{
|
SapSendFailRecodInfo item = new SapSendFailRecodInfo()
|
{
|
SendSapData = JsonConvert.SerializeObject(results),
|
MoveType = (int)moveTypeForSapSend,
|
MoveTypeName = moveTypeForSapSend.ToString(),
|
|
MaterialCode = entity.MaterialCode,
|
//MaterialName = entity.,
|
|
PoCode = entity.PoNumber,//采购单号
|
//SalesOrder = entity.SalesOrder,//销售单号
|
TrackingCode = "",//跟踪号
|
ItemNumber = entity.PoItem,//采购项号
|
//SpecAlias = entity.SalesOrderItem,//销售项号
|
//BigUnit = entity.Unit,//单位
|
ProductBarCode = entity.StorageLocation,//仓库号
|
Quantity = entity.Quantity,
|
//WorkOrder = entity.WorkOrder
|
|
RetMsg = _retMsg,
|
RetResult = _retResult
|
};
|
var product = BussinessExtension.GetProductInfoByCode(context, entity.MaterialCode);
|
if (product != null) item.MaterialName = product.ProductName;
|
|
item.Creator = item.LastModifier = " ";
|
item.CreateTime = item.LastModifyTime = DateTime.Now;
|
|
|
context.SapSendFailRecodInfo.Add(item);
|
}
|
|
context.SaveChanges();
|
}
|
}
|
}
|
catch (Exception)
|
{//吞掉异常
|
throw;
|
}
|
//});
|
}
|
|
|
/// <summary>
|
/// 按凭证退货,新增 推送SAP失败的记录表
|
/// </summary>
|
/// <param name="context"></param>
|
/// <param name="outList"></param>
|
/// <param name="sapInfo"></param>
|
public static void AddForReverser(string results, string _retResult, string _retMsg)
|
{
|
//Task.Run(() =>
|
//{
|
try
|
{
|
MoveTypeForSapSend moveTypeForSapSend = MoveTypeForSapSend.按凭证退货;
|
|
using (dbModel context = new dbModel())
|
{
|
SapSendFailRecodInfo item = new SapSendFailRecodInfo()
|
{
|
SendSapData = results,
|
|
MoveType = (int)moveTypeForSapSend,
|
MoveTypeName = moveTypeForSapSend.ToString(),
|
|
//MaterialCode = entity.MaterialCode,
|
////MaterialName = entity.,
|
|
//PoCode = entity.PoNumber,//采购单号
|
////SalesOrder = entity.SalesOrder,//销售单号
|
//TrackingCode = "",//跟踪号
|
//ItemNumber = entity.PoItem,//采购项号
|
////SpecAlias = entity.SalesOrderItem,//销售项号
|
////BigUnit = entity.Unit,//单位
|
//ProductBarCode = entity.StorageLocation,//仓库号
|
//Quantity = entity.Quantity,
|
//WorkOrder = entity.WorkOrder
|
|
RetMsg = _retMsg,
|
RetResult = _retResult
|
};
|
//var product = BussinessExtension.GetProductInfoByCode(context, entity.MaterialCode);
|
//if (product != null) item.MaterialName = product.ProductName;
|
|
item.Creator = item.LastModifier = " ";
|
item.CreateTime = item.LastModifyTime = DateTime.Now;
|
|
|
context.SapSendFailRecodInfo.Add(item);
|
|
context.SaveChanges();
|
}
|
}
|
catch (Exception)
|
{//吞掉异常
|
throw;
|
}
|
//});
|
}
|
|
|
/// <summary>
|
/// 移库的时候,新增 推送SAP失败的记录表
|
/// </summary>
|
/// <param name="context"></param>
|
/// <param name="outList"></param>
|
/// <param name="sapInfo"></param>
|
public static void AddForMove(MovMaterialEntity[] results, string _retResult, string _retMsg)
|
{
|
//Task.Run(() =>
|
//{
|
try
|
{
|
MoveTypeForSapSend moveTypeForSapSend = MoveTypeForSapSend.移库;
|
if (results != null && results.Length > 0)
|
{
|
using (dbModel context = new dbModel())
|
{
|
foreach (var entity in results)
|
{
|
SapSendFailRecodInfo item = new SapSendFailRecodInfo()
|
{
|
SendSapData = JsonConvert.SerializeObject(results),
|
|
MoveType = (int)moveTypeForSapSend,
|
MoveTypeName = moveTypeForSapSend.ToString(),
|
|
MaterialCode = entity.MaterialCode,
|
//MaterialName = entity.,
|
|
//PoCode = entity.PoNumber,//采购单号
|
////SalesOrder = entity.SalesOrder,//销售单号
|
//TrackingCode = "",//跟踪号
|
//ItemNumber = entity.PoItem,//采购项号
|
////SpecAlias = entity.SalesOrderItem,//销售项号
|
////BigUnit = entity.Unit,//单位
|
//ProductBarCode = entity.StorageLocation,//仓库号
|
Quantity = entity.Quantity,
|
//WorkOrder = entity.WorkOrder
|
|
RetMsg = _retMsg,
|
RetResult = _retResult
|
};
|
var product = BussinessExtension.GetProductInfoByCode(context, entity.MaterialCode);
|
if (product != null) item.MaterialName = product.ProductName;
|
|
item.Creator = item.LastModifier = " ";
|
item.CreateTime = item.LastModifyTime = DateTime.Now;
|
|
|
context.SapSendFailRecodInfo.Add(item);
|
}
|
|
context.SaveChanges();
|
}
|
}
|
}
|
catch (Exception)
|
{//吞掉异常
|
throw;
|
}
|
//});
|
}
|
|
|
|
}
|
}
|