服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
19 小时以前 77da8b9247b9df926678cfb7e4af0f0900f3a084
Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs
@@ -10,11 +10,7 @@
using Tiger.Model;
using Tiger.IBusiness;
using Tiger.Business.WMS.Common;
using Org.BouncyCastle.Ocsp;
using Tiger.Model.Sharetronic.Shelf;
using MailKit.Search;
using Tiger.Business.WMS.Extensions;
using static Tiger.Model.BIZ_WMS_PREP_BTH;
namespace Tiger.Business.WMS.Transaction
{
@@ -34,7 +30,7 @@
        #region Propertys & Variables
        public Preparation CurPREP { get; set; }
        private List<BIZ_WMS_PREP_SN> CurSn = new();
        private BIZ_WMS_PREP_DTL CurPrepDtl = new();
        private BIZ_WMS_PREP_DTL CurPrepDtl;
        public List<SuggestItem> Suggests { get; set; } = new();
        public List<WMS_ITEM_POOL> CurPoolList => Suggests.Where(q => !q.poolItem.IsNullOrEmpty()).Select(q => q.poolItem).ToList();
        public List<WMS_LOCATION> LocationHis { get; set; } = new();
@@ -51,7 +47,8 @@
            var action = new ApiAction<ScanOutput>(new ScanOutput());
            try
            {
                //Result<List<SuggestItem>> result = Suggest("CurPrepDtl.ORDER_NO", "CurPrepDtl.ITEM_CODE", new SuggestOption(), new(), 100.0);
                //action.LocaleMsg = result.LocaleMsg;
                if (input.Command == "ScanOrder")
                {
                    action = await ScanOrder(input);
@@ -158,8 +155,8 @@
        public async Task<ApiAction<BIZ_WMS_PREP>> GetPrepInfo()
        {
            var action = new ApiAction<BIZ_WMS_PREP>();
            CurPREP.Order = MainDB.Queryable<BIZ_WMS_PREP>().Where(q => q.ID == CurPREP.Order.ID).IncludesAllFirstLayer().First();
            var prepId = CurPREP?.Order?.ID;
            CurPREP.Order = MainDB.Queryable<BIZ_WMS_PREP>().Where(q => q.ID == prepId).IncludesAllFirstLayer().First();
            action.Data = CurPREP.Order;
            return action;
        }
@@ -222,7 +219,7 @@
                        var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                        if (inv != null && actQty > 0)
                        {
                            inv.poolItem = inv.Item.GetPoolItem(OrgCode, nameof(CurPREP.Order), CurPrepDtl.ORDER_NO, CurPrepDtl.ORDER_LINE, actQty, true);
                            inv.poolItem = inv.Item.GetPoolItem(OrgCode, TransID, nameof(CurPREP.Order), CurPrepDtl.ORDER_NO, CurPrepDtl.ORDER_LINE, actQty, true);
                        }
                        else
                        {
@@ -239,19 +236,20 @@
                    var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                    Result<List<SuggestItem>> result = Suggest(CurPrepDtl.ORDER_NO, CurPrepDtl.ITEM_CODE, option, input.AuthOption, actQty);
                    action.LocaleMsg = result.LocaleMsg;
                    if (result.IsException)
                    if (result.IsException || result.IsFailed)
                    {
                        action.IsSuccessed = false;
                        return action;
                    }
                    Suggests.Clear();
                    Suggests = result.Data;
                    var remain = actQty;
                    Suggests.ForEach((inv) =>
                    {
                        if (remain > 0)
                        {
                            inv.poolItem = inv.Item.GetPoolItem(input.AuthOption.OrgCode, nameof(CurPREP.Order), CurPrepDtl.ORDER_NO, CurPrepDtl.ORDER_LINE, remain, false);
                            inv.poolItem = inv.Item.GetPoolItem(OrgCode, TransID, nameof(CurPREP.Order), CurPrepDtl.ORDER_NO, CurPrepDtl.ORDER_LINE, remain, false);
                            remain -= inv.poolItem.ALLOC_QTY;
                        }
                        else
@@ -290,12 +288,16 @@
        public async Task<ApiAction<BIZ_WMS_PREP_DTL>> GetCurPrepItem()
        {
            var action = new ApiAction<BIZ_WMS_PREP_DTL>();
            var prepDtl = MainDB.Queryable<BIZ_WMS_PREP_DTL>().Where(q => q.ID == CurPrepDtl.ID).First();
            prepDtl.Suggests = Suggests;
            CurPrepDtl = prepDtl;
            CurPREP.Order.Details.RemoveAll(q => q.ID == CurPrepDtl.ID);
            CurPREP.Order.Details.Add(CurPrepDtl);
            action.Data = CurPrepDtl;
            if (!CurPrepDtl.IsNullOrEmpty())
            {
               var prepDtl = MainDB.Queryable<BIZ_WMS_PREP_DTL>().Where(q => q.ID == CurPrepDtl.ID).First();
               prepDtl.Suggests = Suggests;
                prepDtl.Deliverys = MainDB.Queryable<BIZ_WMS_PREP_SN>().Where(q => q.ORDER_NO == CurPrepDtl.ORDER_NO && q.ORDER_LINE == CurPrepDtl.ORDER_LINE && q.STATUS == WMS_ITEM.STATUSs.OffShelf.GetValue()).ToList();
                CurPrepDtl = prepDtl;
               CurPREP.Order.Details.RemoveAll(q => q.ID == CurPrepDtl.ID);
               CurPREP.Order.Details.Add(CurPrepDtl);
               action.Data = CurPrepDtl;
            }
            return action;
        }
@@ -444,6 +446,14 @@
                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NoNeedItemCode", inv.CurPkg.SN, CurPrepDtl.ITEM_CODE);
                    return action;
                }
                //判断是否在备料数量已经超过需求数量则不允许继续发料
                if (CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl))
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L($"当前物料[{0}]实际需求[{1}]已备料[{2}],无需继续下架,请放回原储位并选择其他物料行继续操作");
                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.PrepQtyEnough", CurPrepDtl.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), CurPrepDtl.QTY_PREP);
                    return action;
                }
                //判断是否在备料中的物料
                //if (!CurPREP.Order.Details.Any(q => q.ITEM_CODE == inv.ItemInfo.ITEM_CODE))
                //{
@@ -452,7 +462,7 @@
                //    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NoNeedItemCode", inv.ItemInfo.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode));
                //    return action;
                //}
                //ProcessingOrderDetail = input.SN;
                //if (WMSContext.TransactionDic.Where(q => !string.IsNullOrWhiteSpace(q.Value.ProcessingSn)).Any(q => q.Value.ProcessingSn == ProcessingSn && q.Value.TransID != this.TransID))
                //{
@@ -515,7 +525,7 @@
                {
                    //action.LocaleMsg = Biz.L($"条码[{0}]扫描成功,备料物料[{1}]需求[{2}]还需备料[{3}],条码需要截料,发出数量[{4}]");
                    //action.LocaleMsg = Biz.L($"条码[{0}]扫描成功,备料物料[{1}]需求[{2}]还需备料[{3}],请选择要超发还是截料?");
                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty);
                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty, CurSn.Sum(q => q.QTY_DLVY));
                    action.Data.Command = "ConfirmExceed";
                    action.Data.Data = new  
                    {
@@ -554,7 +564,7 @@
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L($"条码[{0}]扫描成功,备料物料[{1}]需求[{2}]还需备料[{3}],条码需要截料,发出数量[{4}]");
                    //action.LocaleMsg = Biz.L($"条码[{0}]扫描成功,备料物料[{1}]需求[{2}]还需备料[{3}],请选择要超发还是截料?");
                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty);
                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty, CurSn.Sum(q => q.QTY_DLVY));
                    action.Data.Command = "ConfirmExceed";
                    action.Data.Data = new
                    {
@@ -789,7 +799,9 @@
        /// <returns></returns>
        public async Task<ApiAction> GenerateDlvyBatch(BaseInput input)
        {
            var range = input.Data.ToInt32().GetEnum<BATCH_RANGEs>();
            var range = input.Data.ToInt32().GetEnum<BIZ_WMS_PREP_BTH.BATCH_RANGEs>();
            //从数据库更新当前单据的所有信息
            CurPREP.Order = MainDB.Queryable<BIZ_WMS_PREP>().Where(q => q.ID == CurPREP.Order.ID).IncludesAllFirstLayer().First();
            var action = await CurPREP.Order.BIZ_TYPE.GetEnum<BIZ_WMS_PREP.BIZ_TYPEs>() .GenerateDlvyBatch(this, range);
            return action;
        }
@@ -803,7 +815,7 @@
        {
            ResetScan();
            CurPREP = new(MainDB, UserCode, OrgCode);
            CurPrepDtl = new();
            CurPrepDtl = null;
            CurScanShelf = null;
            base.ResetTrans();
        }
@@ -824,7 +836,7 @@
            //CloseLight(LocationHis).Wait();
            if (!(CurPREP?.Order?.ORDER_NO ?? "").IsNullOrEmpty())
            {
                MainDB.Deleteable<WMS_ITEM_POOL>().Where(x => x.TRANS_NO == CurPREP.Order.ORDER_NO).ExecuteCommand();
                MainDB.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_NO == CurPREP.Order.ORDER_NO || q.TRANS_ID == TransID).ExecuteCommand();
            }
            this.IsFinished = true;