服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-10-29 659d14249d4983e3328b49ac974bbdf733b862b6
生成入库单更新
已修改2个文件
128 ■■■■ 文件已修改
Tiger.Business.MES/iERP/MES_U9C.cs 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/iERP/MES_U9C.cs
@@ -19,12 +19,17 @@
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 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>
        /// 入库单接口
@@ -37,39 +42,54 @@
            var action = new ApiAction();
            try
            {
                JObject json = new JObject();
                json["CompleteList"] = new JArray(); // 创建一个空的JArray
                JObject moKey = new JObject();
                moKey["DocNo"] = input.WorkOrder;
                JObject Wh = new JObject();
                Wh["Code"] = input.WhCode;
                json["CompleteList"]["Wh"] = Wh;
                JObject DescFlexField = new JObject();
                DescFlexField["PrivateDescSeg1"] = input.PkgQty;
                json["CompleteList"]["DescFlexField"] = DescFlexField;
                JObject Item = new JObject();
                Item["Code"] = input.ItemCode;
                json["CompleteList"]["Item"] = Item;
                json["CompleteList"]["CompleteQty"] = input.CompleteQty;
                json["CompleteList"]["OutputType"] = input.OutputType;
                json["CompleteList"]["StorageType"] = input.StorageType;
                json["CompleteList"]["DocState"] = input.DocState;
                var response = await HttpHelper.PostAsync(U9CAuthLoginUrl, json);
                var result = JsonConvert.DeserializeObject<U9CReturnData>(response.Message);
                Logger.Interface.Info($"生成入库单接口提交Json: {json},返回Json: {response.Message}");
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                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,
                    } }
                });
                if (!dbTran.IsSuccess)
                var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}");
                if (u9CLoginResult.Success)
                {
                    action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
                    Logger.Interface.Error(action.Message);
                    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}");
                        }
                    }
                }
                Logger.Interface.Info($"生成入库单成功");
            }
            catch (System.Exception ex)
            {
Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs
@@ -6,14 +6,20 @@
namespace Tiger.Model.Entitys.MES.U9C
{
    public class U9CResult
    public class U9CBaseResult
    {
        public int ResCode { get; set; }
        public bool Success { get; set; }
        public string ResMsg { get; set; }
    }
    public class U9CResult : U9CBaseResult
    {
        public List<U9CReturnData> Data { get; set; }
        public int Status { get; set; }
        public int RouteStatus { get; set; }
    }
    public class U9CLoginResult : U9CBaseResult
    {
        public string Data { get; set; }
    }
    public class U9CReturnData
@@ -30,7 +36,8 @@
    /// <summary>
    /// 入库单接口传入参数
    /// </summary>
    public class RcvRptDocCreateInput {
    public class RcvRptDocCreateInput
    {
        public string WorkOrder { get; set; }
        public string ItemCode { get; set; }
        public string WhCode { get; set; } = "10105";
@@ -41,4 +48,37 @@
        public int DocState { get; set; } = 1;
    }
    public class RcvRptDocCreateParam
    {
       public List<CompleteList> CompleteList { get; set; }
    }
    public class CompleteList
    {
        public MOKey MOKey { get; set; }
        public Wh Wh { get; set; }
        public Item Item { get; set; }
        public DescFlexField DescFlexField { get; set; }
        public int CompleteQty { get; set; }
        public int OutputType { get; set; } = 0;
        public int StorageType { get; set; } = 4;
        public int DocState { get; set; } = 1;
    }
    public class MOKey
    {
        public string DocNo { get; set; }
    }
    public class Wh
    {
        public string Code { get; set; }
    }
    public class Item
    {
        public string Code { get; set; }
    }
    public class DescFlexField
    {
        public string PrivateDescSeg1 { get; set; }
    }
}