using Tiger.Model;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq.Expressions;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Rhea.Common;
|
using System.Net;
|
using System.Linq;
|
using Newtonsoft.Json;
|
using Tiger.IBusiness;
|
using Microsoft.AspNetCore.Http;
|
using Tiger.Model.Minsun;
|
using Org.BouncyCastle.Asn1.Tsp;
|
using Tiger.Model.Entitys.MES.Position;
|
using Apache.NMS.ActiveMQ.Commands;
|
using System.Security.Cryptography;
|
using System.Diagnostics;
|
using Tiger.Model.Entitys.MES.U9C;
|
using Newtonsoft.Json.Linq;
|
using System.Security.Policy;
|
using NetTaste;
|
|
namespace Tiger.Business.MES
|
{
|
public partial class MES_U9C : IMES_U9C
|
{
|
public static string U9CAuthLoginUrl { get; set; } = "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?";
|
public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20";
|
public static string RcvRptDocCreateUrl
|
{ get; set; } = "http://172.16.80.20/u9C/webapi/RcvRptDoc/Create";
|
|
/// <summary>
|
/// 入库单接口
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<ApiAction> RcvRptDocCreate(RcvRptDocCreateInput input)
|
{
|
Logger.Interface.Info($"/**\r\n *进入入库单接口....\r\n */\r\n"); //固定写法
|
var action = new ApiAction();
|
try
|
{
|
List<RcvRptDocCreateParam> param = new List<RcvRptDocCreateParam>();
|
param.Add(new RcvRptDocCreateParam
|
{
|
CompleteList = new List<CompleteList> { new CompleteList
|
{
|
MOKey = new MOKey { DocNo = input.WorkOrder },
|
Wh = new Wh { Code = input.WhCode },
|
DescFlexField = new DescFlexField { PrivateDescSeg1 = input.PkgQty.ToString() },
|
Item = new Item { Code = input.ItemCode },
|
CompleteQty = input.CompleteQty,
|
OutputType = input.OutputType,
|
StorageType = input.StorageType,
|
DocState = input.DocState,
|
} }
|
});
|
|
var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}");
|
if (u9CLoginResult.Success)
|
{
|
var token = u9CLoginResult.Data;
|
Logger.Interface.Info($"U9C登录token: {token}");
|
var response = await HttpHelper.PostAsync(RcvRptDocCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", token } });
|
var result = JsonConvert.DeserializeObject<U9CResult>(response.Message);
|
if (result != null)
|
{
|
if (result.Success)
|
{
|
Logger.Interface.Info($"生成入库单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}");
|
var db = Biz.Db;
|
var dbTran = db.UseTran(() =>
|
{
|
|
});
|
if (!dbTran.IsSuccess)
|
{
|
action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
|
Logger.Interface.Error(action.Message);
|
}
|
Logger.Interface.Info($"生成入库单成功");
|
}
|
else
|
{
|
action.IsSuccessed = false;
|
action.LocaleMsg = new($"{result.Data[0].m_errorMsg}");
|
Logger.Interface.Info($"生成入库单失败:{result.Data[0].m_errorMsg}");
|
}
|
}
|
}
|
}
|
catch (System.Exception ex)
|
{
|
action.CatchExceptionWithLog(ex, "生成入库单异常");
|
}
|
Logger.Interface.Info($"/* 入库单接口结束 */\r\n"); //固定写法
|
return action;
|
}
|
}
|
}
|