服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
6 天以前 756e6c531d49a4565e47949120cb33bae431566e
Tiger.Business.WMS/Transaction/Out_Default.cs
@@ -9,6 +9,7 @@
using System.Threading.Tasks;
using Tiger.Model;
using Tiger.IBusiness;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Business.WMS.Transaction
{
@@ -19,7 +20,7 @@
    {
        public IOut_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;
        }
@@ -52,7 +53,7 @@
            catch (Exception ex)
            {
                //取消当前操作
                ResetScan();
                ResetTrans();
                //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
            }
@@ -70,12 +71,12 @@
                if (CurInvItem.IsNullOrEmpty())
                {
                    //解析条码
                    Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                    Result<IInventory> result = GetInventory(input.SN, input.AuthOption, true);
                    if (!result.IsSuccessed)
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = result.LocaleMsg;
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    var inv = result.Data as Inventory;
@@ -85,7 +86,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L($"状态[{0}]异常,请重新扫描");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.StatusException", string.Join(',', inv.StatusList.Select(x => x.GetDesc())));
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    //储位验证
                    if (inv.Location.IsNullOrEmpty())
@@ -93,7 +94,7 @@
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L($"条码[{0}]库存信息异常: 没有储位信息,请先上架后再扫描(储位Id: {1})");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationIsNull", inv.CurPkg.SN, inv.CurPkg.LOCATION_ID);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    //物料验证
                    if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N")
@@ -101,7 +102,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);
                    }
                    CurInvItem = inv;
@@ -112,7 +113,7 @@
                        action.Data.Command = Command = "ComfirmQty";
                        //action.LocaleMsg = Biz.L("请确认条码[{0}]要下架的数量");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ComfirmOutQty", input.SN);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                }
@@ -128,7 +129,7 @@
                        action.Data.Command = Command = "ComfirmQty";
                        //action.LocaleMsg = Biz.L("下架数量不能小于等于零,请重新确认条码[{0}]的下架数量");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmOutQty", input.SN);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    else if (qtyList.Any(q => q.QTY > CurInvItem.Items.First(i => i.SN == q.SN).QTY))
                    {
@@ -137,7 +138,7 @@
                        action.Data.Command = Command = "ComfirmQty";
                        //action.LocaleMsg = Biz.L("下架数量不能超过原条码数量,请重新确认条码[{0}]的下架数量");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmExceedOutQty", input.SN);
                        return action;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    else
                    {
@@ -152,13 +153,18 @@
                    item.TRANS_CODE = "Out_Default";
                    item.TRANS_NO = $"Out_Default_{DateTime.Now:yyyyMMdd}";
                }
                foreach (var item in CurInvItem.Packages)
                {
                    item.TRANS_CODE = "Out_Default";
                    item.TRANS_NO = $"Out_Default_{DateTime.Now:yyyyMMdd}";
                }
                Result downResult = TakeDown(downDic, input.AuthOption, WMS_ITEM.STATUSs.OffShelf);
                if (!downResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
                    action.LocaleMsg = downResult.LocaleMsg;
                    ResetScan();
                    return action;
                    ResetTrans();
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //灭灯
@@ -172,11 +178,11 @@
            }
            catch (Exception ex)
            {
                ResetScan();
                ResetTrans();
                //action.CatchExceptionWithLog(ex, $"扫描条码[{input.SN}]复核异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
            }
            return action;
            return SetOutPutMqttMsg(action, input.Locale);
        }
        /// <summary>
@@ -256,7 +262,7 @@
            catch (Exception ex)
            {
                //取消当前操作
                ResetScan();
                ResetTrans();
                //action.CatchExceptionWithLog(ex, $"扫描货架/储位[{0}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
            }
@@ -267,11 +273,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 DefaultScanItemOutput()
@@ -291,18 +302,18 @@
            action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
            //重置工序
            ResetScan();
            return action;
            ResetTrans();
            return SetOutPutMqttMsg(action, locale);
        }
        #endregion
        /// <summary>
        /// 重置当前操作,有需要则重写此方法
        /// 重置事务数据,有需要则重写此方法
        /// </summary>
        public override void ResetScan()
        public override void ResetTrans()
        {
            base.ResetScan();
            base.ResetTrans();
            Command = null;
            CurInvItem = null;
            CurScanShelf = null;