服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2025-03-26 7e0299298399c566b81b1ab786881998c746d228
Tiger.Business.WMS/Transaction/In_Default.cs
@@ -13,6 +13,8 @@
using Tiger.Business.WMS.Sharetronic.Shelf;
//using Microsoft.IdentityModel.Tokens;
using Tiger.Model.MES.Yada;
using static IronPython.Modules.PythonThread;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Business.WMS.Transaction
{
@@ -23,7 +25,7 @@
    {
        public IIn_Default Init(string id, string userCode, string apiHost, string orgCode)
        {
            base.Init(id, apiHost, userCode, orgCode);
            base.Init(id, userCode, apiHost, orgCode);
            Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
            return this;
        }
@@ -86,8 +88,8 @@
                   {
                       action.IsSuccessed = false;
                       action.LocaleMsg = result.LocaleMsg;
                       return action;
                   }
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                   var inv = result.Data as Inventory;
                    //验证条码是否正确
@@ -96,7 +98,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("状态[{0}]异常,请重新扫描");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.StatusException", string.Join(',', inv.StatusList.Select(q => q.GetDesc())));
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    //物料验证
                    if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N")
@@ -104,7 +106,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("物料编码[{0}]不存在或者该物料未启用");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ItemCodeNotExistsOrNotActive", inv.ItemInfo?.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode));
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    if (inv.Items.Count == 0)
@@ -181,20 +183,20 @@
                    CurInvItem = inv;
                    //检查物料数量,如果没有则查询雅达条码主档,把数量返回前端确认
                    if (CurInvItem.Items.Any(q => q.QTY <= 0))
                    //if (CurInvItem.Items.Any(q => q.QTY <= 0))
                    {
                        var qtyList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MaterialBarCode>().Where(q => CurInvItem.Items.Select(q => q.SN).Contains(q.Code)).ToList();
                        foreach (var qty in qtyList)
                        {
                            var item = CurInvItem.Items.First(q => q.SN == qty.Code);
                            item.QTY = qty.WhQty;
                            item.SUPP_LOTNO = qty.Segment7;
                            item.SUPP_LOTNO = CurInvItem.Barcode.LotNo;
                        }
                        action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY });
                        action.Data.Command = Command = "ComfirmQty";
                        //action.LocaleMsg = Biz.L("请确认条码[{0}]的数量是否正确");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ComfirmQty", input.SN);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                }
@@ -208,8 +210,8 @@
                        action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY });
                        action.Data.Command = Command = "ComfirmQty";
                        //action.LocaleMsg = Biz.L("数量不能小于等于零,请重新确认条码[{0}]的数量");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN);
                        return action;
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN);
                        return SetOutPutMqttMsg(action, input.Locale);
                    } 
                    else
                    {
@@ -235,7 +237,7 @@
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = Biz.L(shelfApiResult.GetData<string>());
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    var reaultShelf = shelfApiResult.GetData<ShelfChangeModel>();
@@ -245,7 +247,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L($"货架[{0}]中不存在id为[{1}]的储位,请先维护货架信息");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationNotExistsInShelf", CurScanShelf.Shelf.SHELF_CODE, reaultShelf.ledAddr);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    var locationData = MainDB.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == nLocation.ID).First();
                    if (!locationData.IsNullOrEmpty())
@@ -253,7 +255,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("储位[{0}]已存有物料[{1}],请检查系统库存信息");
                        action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", nLocation.LOCATION_CODE, locationData.SN);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    CurScanShelf.LocationCode = nLocation.LOCATION_CODE;
                }
@@ -264,7 +266,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    nLocation = await MainDB.Queryable<WMS_LOCATION>().Where(t => t.LOCATION_CODE == CurScanShelf.LocationCode && t.AUTH_ORG == OrgCode).FirstAsync();
@@ -277,7 +279,7 @@
                    //action.LocaleMsg = Biz.L("储位[{0}]只能存放一个物料");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationSingleFailure", nLocation.LOCATION_CODE);
                    ResetScan();
                    return action;
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //执行上架数据处理
@@ -292,7 +294,7 @@
                    action.IsSuccessed = false;
                    action.LocaleMsg = putonResult.LocaleMsg;
                    ResetScan();
                    return action;
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //完成所有处理后使用事务保存数据
@@ -305,7 +307,7 @@
                //action.CatchExceptionWithLog(ex, $"扫描条码[{input.SN}]复核异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
            }
            return action;
            return SetOutPutMqttMsg(action, input.Locale);
        }
        /// <summary>
@@ -403,11 +405,16 @@
        /// 完成所有处理后使用事务保存数据
        /// </summary>
        /// <param name="action"></param>
        /// <param name="locale"></param>
        /// <param name="doAfterSave"></param>
        /// <returns></returns>
        public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale)
        public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale, Action doAfterSave = null)
        {
            //保存数据库
            SaveCommitListToDB();
            //保存数据成功后执行
            doAfterSave?.Invoke();
            // 返回数据
            action.Data.Data = new DefaultInStoreOutput
@@ -429,7 +436,7 @@
            //重置扫码信息
            ResetScanInfo();
            return action;
            return SetOutPutMqttMsg(action, locale);
        }
        #endregion