服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-12-25 fc5b73f8d3f3a37d01057799b298cb90e5955eb2
Tiger.Business.WMS/Transaction/Out_Default.cs
@@ -35,15 +35,16 @@
        public string OrgCode { get; set; }
        public Inventory CurInvItem { get; set; }
        public ScanShelfInfo CurScanShelf { get; set; }
        public string Command { get; set; } = "Normal";
        #endregion
        #region Functions
        /// <summary>
        /// 扫描物料并复核,如果是智能货架则亮灯提醒储位
        /// 扫描入口
        /// </summary>
        public async Task<ApiAction<DefaultScanItemOutput>> ScanItem(BaseInput input)
        public async Task<ApiAction<ScanOutput>> Scan(BaseInput input)
        {
            var action = new ApiAction<DefaultScanItemOutput>();
            var action = new ApiAction<ScanOutput>();
            try
            {
                if (input.SN.IsNullOrEmpty())
@@ -51,9 +52,31 @@
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("条码不能为空");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
                    return action;
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //扫描物料并复核
                {
                    action = await ScanItem(input);
                }
            }
            catch (Exception ex)
            {
                //取消当前操作
                ResetInfo();
                //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
            }
            return SetOutPutMqttMsg(action, input.Locale);
        }
        /// <summary>
        /// 扫描物料并复核,如果是智能货架则亮灯提醒储位
        /// </summary>
        public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput() { Command = Command });
            try
            {
                //解析条码
                Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                if (!result.IsSuccessed)
@@ -125,7 +148,7 @@
                    throw dbTran.ErrorException;
                }
                action.Data = new DefaultScanItemOutput()
                action.Data.Data = new DefaultScanItemOutput()
                {
                    SN = CurInvItem.SN,
                    ItemCode = CurInvItem.ItemInfo.ITEM_CODE,
@@ -138,13 +161,13 @@
                    ScanAfCut = CurInvItem.Warehouse.SCAN_AF_CUT
                };
                //action.LocaleMsg = Biz.L($"扫描条码[{0}]从储位[{1}]下架成功");
                action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", action.Data.SN, action.Data.locationCode);
                action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
            }
            catch (Exception ex)
            {
                ResetInfo();
                //action.CatchExceptionWithLog(ex, $"扫描条码[{input.SN}]复核异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", action.Data.SN));
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
            }
            return action;
        }
@@ -152,9 +175,9 @@
        /// <summary>
        /// 扫描货架或者储位(供亮灯货架使用)
        /// </summary>
        public async Task<ApiAction<ScanShelfInfo>> ScanShelf(string Code)
        public async Task<ApiAction<ScanOutput>> ScanShelf(string Code)
        {
            var action = new ApiAction<ScanShelfInfo>();
            var action = new ApiAction<ScanOutput>(new ScanOutput() { Command = Command });
            try
            {
                if (Code.IsNullOrEmpty())
@@ -177,14 +200,13 @@
                    CurScanShelf.WarehouseCode = whUnit.WH_CODE;
                    CurScanShelf.RegionCode = whUnit.REGION_CODE;
                    CurScanShelf.ShelfCode = whUnit.SHELF_CODE;
                    CurScanShelf.LocationCode = whUnit.LOCATION_CODE;
                    CurScanShelf.ShelfType = whUnit.SHELF_TYPE;
                    CurScanShelf.IsSmartRack = true;
                }
                // 扫描储位代码
                // 扫描库位代码
                else
                {
                    var nLocation = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => t.LOCATION_CODE.ToUpper() == Code.ToUpper() && t.AUTH_ORG == OrgCode).FirstAsync();
                    var nLocation = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => t.LOCATION_CODE.ToUpper() == Code.ToUpper() && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
                    if (nLocation == null)
                    {
                        action.IsSuccessed = false;
@@ -210,7 +232,7 @@
                    //        return action;
                    //    }
                    //}
                    CurScanShelf.Shelf = nLocation.Shelf;
                    CurScanShelf.Location = nLocation.Location;
                    CurScanShelf.WarehouseCode = nLocation.WH_CODE;
                    CurScanShelf.RegionCode = nLocation.REGION_CODE;
@@ -222,7 +244,7 @@
                CurScanShelf.IsScanShelf = true;
                //action.LocaleMsg = Biz.L("扫描货架/储位[{0}]成功");
                action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ScanSucceeded", Code);
                action.Data = CurScanShelf;
                action.Data.Data = CurScanShelf;
            }
            catch (Exception ex)
            {
@@ -242,6 +264,7 @@
        public override void ResetInfo()
        {
            base.ResetInfo();
            Command = null;
            CurInvItem = null;
            CurScanShelf = null;
        }