7 changed files with 142 additions and 15 deletions
@ -0,0 +1,78 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Net.Http; |
||||
|
using System.Net.Http.Headers; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Newtonsoft.Json; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.aValue_API |
||||
|
{ |
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class aValueAPIController : ControllerBase |
||||
|
{ |
||||
|
private readonly IConfiguration _config; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建構式
|
||||
|
/// </summary>
|
||||
|
public aValueAPIController(IConfiguration config) |
||||
|
{ |
||||
|
_config = config; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// GetPLM ECN
|
||||
|
/// </summary>
|
||||
|
/// <param name="wipNo">工單號碼</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("GetProductDetail")] |
||||
|
public string GetProductDetail(string wipNo) |
||||
|
{ |
||||
|
// aValueAPI Url
|
||||
|
string aValueAPI_Url = _config.GetSection("aValueAPI").Value; |
||||
|
|
||||
|
var client = new HttpClient(); |
||||
|
//設定Header - Accept的資料型別
|
||||
|
client.Timeout = TimeSpan.FromHours(1);//1小時
|
||||
|
client.DefaultRequestHeaders.Accept.Clear(); |
||||
|
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
||||
|
//client.BaseAddress = new Uri($"{aValueAPI_Url}/get_Product_Detail/api/ProductDetail");//ProductDetail
|
||||
|
|
||||
|
// {
|
||||
|
// "Key":"Avalue@Product_Detail#",
|
||||
|
// "MOID":"9930001896"
|
||||
|
//}
|
||||
|
var myClass = new |
||||
|
{ |
||||
|
Key = "Avalue@Product_Detail#", |
||||
|
MOID = wipNo |
||||
|
}; |
||||
|
try |
||||
|
{ |
||||
|
HttpResponseMessage response = client.PostAsync($"{aValueAPI_Url}/get_Product_Detail/api/ProductDetail", |
||||
|
new StringContent(JsonConvert.SerializeObject(myClass), |
||||
|
Encoding.UTF8, "application/json")).Result; |
||||
|
|
||||
|
if (response.IsSuccessStatusCode) |
||||
|
{ |
||||
|
var jsonString = response.Content.ReadAsStringAsync(); |
||||
|
jsonString.Wait(); |
||||
|
return jsonString.Result; |
||||
|
} |
||||
|
//可能會發生錯誤
|
||||
|
return "error"; |
||||
|
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return ex.Message; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.aValue_API |
||||
|
{ |
||||
|
|
||||
|
public partial class ProductDetail |
||||
|
{ |
||||
|
public string MRP_CONTROLLER { get; set; } |
||||
|
public string MATERIAL { get; set; } |
||||
|
public float TARGET_QUANTITY { get; set; } |
||||
|
public string EAN_NO { get; set; } |
||||
|
public string WORK_CENTER { get; set; } |
||||
|
public string MATL_GROUP { get; set; } |
||||
|
public string Z_VIP { get; set; } |
||||
|
public string FINISH_DATE { get; set; } |
||||
|
public string START_DATE { get; set; } |
||||
|
public string CHANGE_NO { get; set; } |
||||
|
public string PUR_STATUS { get; set; } |
||||
|
public string UNLOAD_PT { get; set; } |
||||
|
public string E_MAIL { get; set; } |
||||
|
public string TDLINE { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue