Added GetMaterialdaten und GetHerstellerdaten
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,13 +5,11 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using CompControl.ErpConnector.Service.Models;
|
using CompControl.ErpConnector.Service.Models;
|
||||||
using static CompControl.ErpConnector.Service.Models.Cicor_SapModels;
|
|
||||||
using static CompControl.ErpConnector.Service.Models.SapDataTypes;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CompControl.SapFrameworkConnector
|
namespace CompControl.SapFrameworkConnector
|
||||||
{
|
{
|
||||||
[RoutePrefix("api/we")]
|
[RoutePrefix("api/standard")]
|
||||||
public class StandardApiController: ApiController
|
public class StandardApiController: ApiController
|
||||||
{
|
{
|
||||||
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
@@ -21,73 +19,11 @@ namespace CompControl.SapFrameworkConnector
|
|||||||
public async Task<HttpResponseMessage> GetBestellungen([FromBody] FilterBestellungen filterBestellungen, CancellationToken cancellationToken)
|
public async Task<HttpResponseMessage> GetBestellungen([FromBody] FilterBestellungen filterBestellungen, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ApiResultBestellungen result = new ApiResultBestellungen(); //New ApiResult to return via Web
|
ApiResultBestellungen result = new ApiResultBestellungen(); //New ApiResult to return via Web
|
||||||
|
_log.Debug("GetBestellungen received for Filter: " + filterBestellungen.ToString());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_log.Debug("GetBestellungen received for Filter: " + filterBestellungen.ToString());
|
SapStandardFunctions.GetBestellung(filterBestellungen.OrderNo);
|
||||||
|
|
||||||
BAPI_PO_GETDETAIL_IMPORT import = new BAPI_PO_GETDETAIL_IMPORT() { PURCHASEORDER = filterBestellungen.OrderNo };
|
|
||||||
BAPI_PO_GETDETAIL_EXPORT details = SapStandardFunctions.BAPI_PO_GETDETAILS(import);
|
|
||||||
int cnt = 0;
|
|
||||||
|
|
||||||
foreach (BAPIEKPO det in details.PO_ITEMS)
|
|
||||||
{
|
|
||||||
cnt++;
|
|
||||||
string inspect = "";
|
|
||||||
string inspectInfo = "";
|
|
||||||
string prioText = "";
|
|
||||||
string prioChar = "";
|
|
||||||
string ItemText1 = "";
|
|
||||||
bool posIsClosed = false;
|
|
||||||
DateTime expDeliverDate = DateTime.MaxValue;
|
|
||||||
|
|
||||||
if (det.QUAL_INSP.Equals("X"))
|
|
||||||
{
|
|
||||||
inspect = "Q";
|
|
||||||
if (ConfigHelper.SapLanguage.Equals("DE")) { inspectInfo = "Qualitaetspruefung erforderlich!"; }
|
|
||||||
else { inspectInfo = "Quality check mandatory!"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
expDeliverDate = SapStandardFunctions.ConvertSapDateToDateTime(det.ExpectedDeliveryDate, false);
|
|
||||||
if (det.QUANTITY <= det.QUANTITYPROCESSED) { posIsClosed = true; }
|
|
||||||
|
|
||||||
GetMAKTXfromMATNR_IMPORT getMak = new GetMAKTXfromMATNR_IMPORT();
|
|
||||||
getMak.MATNR = det.MATERIAL.Trim();
|
|
||||||
GetMAKTXfromMATNR_EXPORT outMak = SapStandardFunctions.GetMAKTXfromMATNR(getMak);
|
|
||||||
ItemText1 = outMak.MAKTX;
|
|
||||||
|
|
||||||
GrDataItem gr = new GrDataItem();
|
|
||||||
gr.AcceptedManufacturesLink = cnt.ToString();
|
|
||||||
gr.Created = SapStandardFunctions.ConvertSapDateToDateTime(details.PO_HEADER.CREATED_ON);
|
|
||||||
gr.LastUpdate = SapStandardFunctions.ConvertSapDateToDateTime(det.CHANGED_ON);
|
|
||||||
gr.PosIsClosed = posIsClosed;
|
|
||||||
gr.OrderNo = det.PO_NUMBER;
|
|
||||||
gr.OrderPos = det.PO_ITEM;
|
|
||||||
gr.OrderQuantity = det.QUANTITY;
|
|
||||||
gr.ItemNo = det.MATERIAL.Trim();
|
|
||||||
gr.ItemText1 = ItemText1;
|
|
||||||
gr.ItemNoRef = gr.CustomValue05 = det.PUR_MAT;
|
|
||||||
gr.OrderPosInfoText = det.ACCTASSCAT;
|
|
||||||
gr.QuantityProcessed = det.QUANTITYPROCESSED;
|
|
||||||
gr.QuantityUnit = det.UNIT;
|
|
||||||
gr.Plant = det.PLANT;
|
|
||||||
gr.Inspection = inspect;
|
|
||||||
gr.InspectionInfo = inspectInfo;
|
|
||||||
gr.Priority = prioChar;
|
|
||||||
gr.PriorityInfoText = prioText;
|
|
||||||
gr.CustomValue01 = det.QUAL_INSP;
|
|
||||||
gr.ExpectedDeliveryDate = expDeliverDate;
|
|
||||||
gr.MPN = det.MANU_MAT.Trim();
|
|
||||||
gr.SupplierNo = details.PO_HEADER.VENDOR;
|
|
||||||
gr.SupplierName = details.PO_HEADER.VEND_NAME;
|
|
||||||
gr.SupplierItemNo = det.VEND_MAT;
|
|
||||||
gr.StorageLocation = det.STOR_LOC;
|
|
||||||
gr.Schedule = det.SCHEDULE.TrimStart('0');
|
|
||||||
gr.CustomValue08 = details.PO_HEADER.DOC_TYPE;
|
|
||||||
if (!det.DELETE_IND.Equals("L")) { result.GrDataItems.Add(gr); }
|
|
||||||
}
|
|
||||||
|
|
||||||
_log.Debug($"Result of GetBestellungen now consists of {result.GrDataItems.Count} GrDataItems and {result.ManufacturerDataItems.Count} ManufactuerDataItems...");
|
|
||||||
|
|
||||||
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
||||||
else { _log.Error(result); } //An error occurred
|
else { _log.Error(result); } //An error occurred
|
||||||
@@ -108,7 +44,6 @@ namespace CompControl.SapFrameworkConnector
|
|||||||
return Request.CreateResponse(HttpStatusCode.OK, result);
|
return Request.CreateResponse(HttpStatusCode.OK, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Route("getherstellerdaten")]
|
[Route("getherstellerdaten")]
|
||||||
public async Task<HttpResponseMessage> GetHerstellerdaten([FromUri] string itemNo, CancellationToken cancellationToken)
|
public async Task<HttpResponseMessage> GetHerstellerdaten([FromUri] string itemNo, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -117,7 +52,7 @@ namespace CompControl.SapFrameworkConnector
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
SapStandardFunctions.GetHerstellerdaten(itemNo);
|
||||||
|
|
||||||
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
||||||
else { _log.Error(result); } //An error occurred
|
else { _log.Error(result); } //An error occurred
|
||||||
@@ -137,5 +72,63 @@ namespace CompControl.SapFrameworkConnector
|
|||||||
|
|
||||||
return Request.CreateResponse(HttpStatusCode.OK, result);
|
return Request.CreateResponse(HttpStatusCode.OK, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("getmaterialdaten")]
|
||||||
|
public async Task<HttpResponseMessage> GetMaterialdaten([FromUri] string itemNo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
ApiResultMaterialdaten result = new ApiResultMaterialdaten(); //New ApiResult to return via Web
|
||||||
|
_log.Debug("GetMaterialdaten received for itemNo: " + itemNo);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = SapStandardFunctions.GetMaterialdaten(itemNo);
|
||||||
|
|
||||||
|
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
||||||
|
else { _log.Error(result); } //An error occurred
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string sm = $"GetMaterialdaten: An unexpected error occured for '{itemNo}' " + ex;
|
||||||
|
_log.Error(sm);
|
||||||
|
result = new ApiResultMaterialdaten //Default ApiResult on error
|
||||||
|
{
|
||||||
|
ErrorNumber = 101,
|
||||||
|
MessageShort = sm,
|
||||||
|
MessageLong = sm,
|
||||||
|
MessageTechnical = $"{sm} [{itemNo}] - {ex}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Request.CreateResponse(HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("getallmaterialdaten")]
|
||||||
|
public async Task<HttpResponseMessage> GetAllMaterialdaten(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
ApiResultMaterialdaten result = new ApiResultMaterialdaten(); //New ApiResult to return via Web
|
||||||
|
_log.Debug("GetAllMaterialdaten received ");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = SapStandardFunctions.GetMaterialdaten("");
|
||||||
|
|
||||||
|
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
|
||||||
|
else { _log.Error(result); } //An error occurred
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string sm = $"GetAllMaterialdaten: An unexpected error occured => " + ex;
|
||||||
|
_log.Error(sm);
|
||||||
|
result = new ApiResultMaterialdaten //Default ApiResult on error
|
||||||
|
{
|
||||||
|
ErrorNumber = 101,
|
||||||
|
MessageShort = sm,
|
||||||
|
MessageLong = sm,
|
||||||
|
MessageTechnical = $"{sm} [] - {ex}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Request.CreateResponse(HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user