服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-10-29 8da1d552357ff91a6ff88514cf0480dda55c03ed
入库单接口
已修改1个文件
已添加4个文件
182 ■■■■■ 文件已修改
Tiger.Business.MES/iERP/MES_U9C.cs 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness.MES/iERP/IMES_U9C.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Tiger.Model.Net.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/iERP/MES_U9C.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,82 @@
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;
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(); // åˆ›å»ºä¸€ä¸ªç©ºçš„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(() =>
                {
                });
                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($"/* å…¥åº“单接口结束 */\r\n"); //固定写法
            return action;
        }
    }
}
Tiger.Controllers.MES/Controllers/MESController.MES_U9C.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using 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);
        }
    }
}
Tiger.IBusiness.MES/iERP/IMES_U9C.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using 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);
    }
}
Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,44 @@
using 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>
    /// å…¥åº“单接口传入参数
    /// </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;
    }
}
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" />