From 8da1d552357ff91a6ff88514cf0480dda55c03ed Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期二, 29 十月 2024 01:13:11 +0800
Subject: [PATCH] 入库单接口

---
 Tiger.Business.MES/iERP/MES_U9C.cs                          |   82 ++++++++++++++++++++
 Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs |   44 +++++++++++
 Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs  |   38 +++++++++
 Tiger.Model.Net/Tiger.Model.Net.csproj                      |    1 
 Tiger.IBusiness.MES/iERP/IMES_U9C.cs                        |   17 ++++
 5 files changed, 182 insertions(+), 0 deletions(-)

diff --git a/Tiger.Business.MES/iERP/MES_U9C.cs b/Tiger.Business.MES/iERP/MES_U9C.cs
new file mode 100644
index 0000000..069f0a5
--- /dev/null
+++ b/Tiger.Business.MES/iERP/MES_U9C.cs
@@ -0,0 +1,82 @@
+锘縰sing 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;
+
+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";
+
+        /// <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
+            {
+                JObject json = new JObject();
+                json["CompleteList"] = new JArray(); // 鍒涘缓涓�涓┖鐨凧Array
+                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($"鐢熸垚鍏ュ簱鍗曟帴鍙f彁浜son: {json}锛岃繑鍥濲son: {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($"鐢熸垚鍏ュ簱鍗曟垚鍔�");
+            }
+            catch (System.Exception ex)
+            {
+                action.CatchExceptionWithLog(ex, "鐢熸垚鍏ュ簱鍗曞紓甯�");
+            }
+            Logger.Interface.Info($"/* 鍏ュ簱鍗曟帴鍙g粨鏉� */\r\n"); //鍥哄畾鍐欐硶
+            return action;
+        }
+    }
+}
diff --git a/Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs b/Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs
new file mode 100644
index 0000000..016f505
--- /dev/null
+++ b/Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs
@@ -0,0 +1,38 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Rhea.Common;
+using SqlSugar;
+using System.Threading.Tasks;
+using Tiger.IBusiness;
+using Tiger.Model;
+using Tiger.Model.Entitys.MES.BizMesWo;
+using Tiger.Model.Entitys.MES.BizMesWoBatch;
+using Tiger.Api.iBiz;
+using Tiger.Model.Entitys.MES.U9C;
+
+namespace Tiger.Api.Controllers.MES
+{
+    public partial class MESController : ControllerBase
+    {
+
+        /// <summary>
+        /// 鍏ュ簱鍗曟帴鍙�
+        /// </summary>
+        /// <param name="action"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("api/[controller]/[action]")]
+        public async Task<IActionResult> RcvRptDocCreate([FromBody] ApiAction<RcvRptDocCreateInput> action)
+        {
+            ApiAction response = new();
+            try
+            {
+                response = response.GetResponse(await DI.Resolve<IMES_U9C>().RcvRptDocCreate(action.Data));
+            }
+            catch (System.Exception ex)
+            {
+                response = response.GetResponse().CatchExceptionWithLog(ex);
+            }
+            return Ok(response);
+        }
+    }
+}
diff --git a/Tiger.IBusiness.MES/iERP/IMES_U9C.cs b/Tiger.IBusiness.MES/iERP/IMES_U9C.cs
new file mode 100644
index 0000000..03c4ef2
--- /dev/null
+++ b/Tiger.IBusiness.MES/iERP/IMES_U9C.cs
@@ -0,0 +1,17 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tiger.Model;
+using Tiger.Model.Entitys.MES.U9C;
+
+namespace Tiger.IBusiness
+{
+    public interface IMES_U9C
+    {
+        public Task<ApiAction> RcvRptDocCreate(RcvRptDocCreateInput input);
+    }
+}
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs
new file mode 100644
index 0000000..14e9dc7
--- /dev/null
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs
@@ -0,0 +1,44 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tiger.Model.Entitys.MES.U9C
+{
+    public class U9CResult
+    {
+        public int ResCode { get; set; }
+        public bool Success { get; set; }
+        public string ResMsg { get; set; }
+        public List<U9CReturnData> Data { get; set; }
+        public int Status { get; set; }
+        public int RouteStatus { get; set; }
+    }
+
+    public class U9CReturnData
+    {
+        public string u9c_version { get; set; }
+        public bool m_isSucess { get; set; }
+        public string m_otherID { get; set; }
+        public string m_iD { get; set; }
+        public string m_code { get; set; }
+        public string m_errorMsg { get; set; }
+        public string m_datas { get; set; }
+    }
+
+    /// <summary>
+    /// 鍏ュ簱鍗曟帴鍙d紶鍏ュ弬鏁�
+    /// </summary>
+    public class RcvRptDocCreateInput { 
+        public string WorkOrder { get; set; }
+        public string ItemCode { get; set; }
+        public string WhCode { get; set; } = "10105";
+        public int PkgQty { 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;
+    }
+
+}
diff --git a/Tiger.Model.Net/Tiger.Model.Net.csproj b/Tiger.Model.Net/Tiger.Model.Net.csproj
index c8a8462..7aff1bd 100644
--- a/Tiger.Model.Net/Tiger.Model.Net.csproj
+++ b/Tiger.Model.Net/Tiger.Model.Net.csproj
@@ -162,6 +162,7 @@
     <Compile Include="Entitys\MES\node.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\BizMesWoBatchParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\BizBasPkgRuleParameter.cs" />
+    <Compile Include="Entitys\MES\ParameterEntity\U9CParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\DoUnPackParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\CodeVerificationParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\BizMesWoParameter.cs" />

--
Gitblit v1.9.3