服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2025-04-06 d2f14f6bb44c6dd19cc0816a033452b6de56184b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 Tiger.Model.Entitys.MES.U9C;
 
namespace Tiger.Business.WMS
{
    public partial class WMS_U9C
    {
        /// <summary>
        /// 创建生产领料单
        /// </summary>
        public static string CreateProdMaterialReqUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/IssueDoc/Create"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateProdMaterialReqUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateProdMaterialReqUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/IssueDoc/Create
 
 
        /// <summary>
        /// 创建生产领料单接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<List<U9CReturnData>>> CreateProdMaterialReq(CreateProdMaterialReqInput input) {
            Logger.Interface.Info($"/**\r\n *进入创建生产领料单接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData>>();
            try
            {
                //如果已经登录则不需要再次登录,直接使用传入的token
                if (input.IsLogin)
                {
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}");
                    if (u9CLoginResult.Success)
                    {
                        input.token = u9CLoginResult.Data;
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
 
                var response = await HttpHelper.PostAsync(CreateProdMaterialReqUrl, JsonConvert.SerializeObject(input.CreateProdMaterialReqParam), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].m_isSucess)
                    {
                        action.Data = result.Data;
                        Logger.Interface.Info($"创建生产领料单接口提交Json: {JsonConvert.SerializeObject(input.CreateProdMaterialReqParam)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {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;
        }
    }
}