服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-02-19 e8aef02a3b8a6b6c5f0b13798f318aa7dc56e13f
Tiger.Business.MES/iERP/MES_U9C.cs
@@ -32,10 +32,13 @@
        public static string RcvRptDocCreateUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 测试
        //public static string RcvRptDocCreateUrl
        //{ get; set; } = Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE;  //正式
        //{ get; set; } = Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE;  //正式
        public static string U9CBarcodeCreateUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["U9CBarcodeCreateUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["U9CBarcodeCreateUrl", "U9CUrl"].PARAM_VALUE;
        public static string CreateBarCodeByAssignQtyUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateBarCodeByAssignQty_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateBarCodeByAssignQty", "U9CUrl"].PARAM_VALUE;
        /// <summary>
        /// 入库单接口
@@ -137,13 +140,14 @@
                                Logger.Interface.Info($"生成入库单成功");
                                //条码主档
                                BarcodeCreateInput barcodeCreateInput = new() {
                                BarcodeCreateInput barcodeCreateInput = new()
                                {
                                    RevDocId = result.Data[0].m_iD,
                                    userId = input.userId,
                                    token = token,
                                    IsLogin = false,
                                };
                                U9CBarcodeCreate(barcodeCreateInput);
                                await U9CBarcodeCreate(barcodeCreateInput);
                            }
                            else
                            {
@@ -250,6 +254,64 @@
            return action;
        }
        /// <summary>
        /// 半成品生成条码接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<BarcodeCreateInput>> U9CCreateBarCodeByAssignQty(BarcodeCreateByAssignQtyInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入半成品生成条码接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<BarcodeCreateInput>();
            try
            {
                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}");
                    }
                }
                List<BarcodeCreateByAssignQtyParam> param = new() {
                     new() {
                        CreateBarCodeEntitys = new(){
                                           new CreateBarCodeEntitys
                                           {
                                                EntityID = input.RevDocId, //入库单ID
                                                EntityType="UFIDA.U9.Complete.RCVRpt.RcvRptDocLine"
                                           }
                                        },
                        BarCodeRuleID = "1002308220305008",
                        CreateBarCodeItemQty = input.CreateBarCodeItemQty,
                        LabelQty = input.LabelQty,
                     }
                };
                var response = await HttpHelper.PostAsync(CreateBarCodeByAssignQtyUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<BarcodeCreateByAssignQtyResult>(response.Message);
                if (result != null)
                {
                    if (result.Success)
                    {
                        Logger.Interface.Info($"半成品生成条码接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data.ErrorMessage}");
                        Logger.Interface.Info($"半成品生成条码失败:{result.Data.ErrorMessage}");
                    }
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "半成品生成条码异常");
            }
            Logger.Interface.Info($"/* 半成品生成条码接口结束 */\r\n"); //固定写法
            return action;
        }
        private List<BAS_LABEL_TEMP> GetLabels(List<InStorePrintJson> printJsons)
        {
            List<BAS_LABEL_TEMP> labels = new List<BAS_LABEL_TEMP>();