服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-03-24 764c8fef733cdca5c53e60eda45c30cc03045cbf
实现 (U9) 来料打印上架事务功能

新增类 `Print_BIZ_U9_ASN` 处理事务,包括初始化、扫描货架和物料、上架数据处理。更新接口 `IPrint_BIZ_U9_ASN` 以支持新功能。控制器 `WMSController` 添加 API 方法以获取、关闭事务和执行扫描操作,增强系统功能性和可维护性。
已添加3个文件
602 ■■■■■ 文件已修改
Tiger.Business.WMS/Transaction/Yada/Print_BIZ_U9_ASN.cs 436 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Controllers.WMS/Controllers/WMSController.Print_BIZ_U9_ASN.cs 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness.WMS/Transaction/IPrint_BIZ_U9_ASN.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/Yada/Print_BIZ_U9_ASN.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,436 @@
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.Model;
using Tiger.IBusiness;
using Tiger.Model.Sharetronic.Shelf;
using Tiger.Business.WMS.Sharetronic.Shelf;
using Tiger.Model.Entitys.MES.U9C;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Business.WMS.Transaction
{
    /// <summary>
    /// (U9)来料打印上架事务
    /// </summary>
    public class Print_BIZ_U9_ASN : WmsTask, IPrint_BIZ_U9_ASN
    {
        public IPrint_BIZ_U9_ASN Init(string id, string userCode, string apiHost, string orgCode)
        {
            base.Init(id, userCode, apiHost, orgCode);
            Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
            return this;
        }
        #region Propertys & Variables
        #endregion
        #region Functions
        /// <summary>
        /// æ‰«æå…¥å£
        /// </summary>
        public async Task<ApiAction<ScanOutput>> Scan(BaseInput input)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput());
            try
            {
                if (input.SN.IsNullOrEmpty())
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("条码不能为空");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //判断扫描的是否货架
                var whUnit = await MainDB.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
                //if (string.IsNullOrEmpty(CurScanShelf?.ShelfCode))
                if (!whUnit.IsNullOrEmpty() || string.IsNullOrEmpty(CurScanShelf?.ShelfCode))
                {
                    action = await ScanShelf(input.SN, whUnit);
                }
                else//扫描物料并复核
                {
                    action = await ScanItem(input);
                }
            }
            catch (Exception ex)
            {
                //取消当前操作
                ResetScan();
                //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
            {
                if (CurInvItem.IsNullOrEmpty())
                {
                    //解析条码
                    Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                    if (!result.IsSuccessed)
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = result.LocaleMsg;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    var inv = result.Data as Inventory;
                    //验证条码是否正确
                    if (!inv.isNormalStatus || inv.Status != WMS_ITEM.STATUSs.WaitIn)
                    {
                        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 SetOutPutMqttMsg(action, input.Locale);
                    }
                    //物料验证
                    if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N")
                    {
                        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 SetOutPutMqttMsg(action, input.Locale);
                    }
                    CurInvItem = inv;
                }
                var receipt = await Biz.Db.Queryable<BIZ_U9_RECEIPT>().Where(q => q.ORDER_NO == CurInvItem.Items.First().TRANS_NO).IncludesAllFirstLayer().FirstAsync();
                if (receipt.IsNullOrEmpty())
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("收货单中找不到条码所属的单据[{0}]信息,请重新扫描收货单的条码或选择正确的功能上架");
                    action.LocaleMsg = Biz.L("WMS.Print_BIZ_U9_ASN.ScanItem.ReceiptNotExists", CurInvItem.Items.First().TRANS_NO);
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var receiptDtl = receipt.Details.First(q => q.LINE_NO == CurInvItem.Items.First().TRANS_LINE);
                if (receiptDtl.STATUS > BIZ_U9_RECEIPT.STATUSs.Storing.GetValue())
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("收货单中行[{0}]状态[{1}]异常,请扫描正确的条码");
                    action.LocaleMsg = Biz.L("WMS.Print_BIZ_U9_ASN.ScanItem.ReceiptDtlStatusException", receiptDtl.LINE_NO, receiptDtl.STATUS.GetEnumDesc<BIZ_U9_RECEIPT.STATUSs>());
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var receiptSn = receipt.SnList.Where(q => CurInvItem.Items.Any(i => i.SN == q.SN)).ToList();
                if (receiptSn.Any(q => q.STATUS != WMS_ITEM.STATUSs.WaitIn.GetValue()))
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("收货单中条码[{0}]状态[{1}]异常,请扫描正确的条码");
                    action.LocaleMsg = Biz.L("WMS.Print_BIZ_U9_ASN.ScanItem.ReceiptSnStatusException", CurInvItem.SN, receiptSn.First(q => q.STATUS != WMS_ITEM.STATUSs.WaitIn.GetValue()).STATUS.GetEnumDesc<WMS_ITEM.STATUSs>());
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var nLocation = new WMS_LOCATION();
                // åˆ¤æ–­æ˜¯å¦æ™ºèƒ½è´§æž¶
                if (CurScanShelf.Shelf.IsLightShelf)
                {
                    ShelfApiResult shelfApiResult = await Share.Shelf.PutOn(TransID, CurScanShelf.Shelf, CurInvItem.Items[0]);
                    if (!shelfApiResult.IsSuccess)
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = Biz.L(shelfApiResult.GetData<string>());
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    var reaultShelf = shelfApiResult.GetData<ShelfChangeModel>();
                    nLocation = reaultShelf.GetLocation();
                    if (nLocation == null)
                    {
                        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 SetOutPutMqttMsg(action, input.Locale);
                    }
                    var locationData = MainDB.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == nLocation.ID).First();
                    if (!locationData.IsNullOrEmpty())
                    {
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("储位[{0}]已存有物料[{1}],请检查系统库存信息");
                        action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", nLocation.LOCATION_CODE, locationData.SN);
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    CurScanShelf.LocationCode = nLocation.LOCATION_CODE;
                }
                else
                {
                    if (CurScanShelf.LocationCode.IsNullOrEmpty() || CurScanShelf.WarehouseCode.IsNullOrEmpty())
                    {
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                    nLocation = await MainDB.Queryable<WMS_LOCATION>().Where(t => t.LOCATION_CODE == CurScanShelf.LocationCode && t.AUTH_ORG == OrgCode).FirstAsync();
                }
                //判断储位是否单放
                if (nLocation.IS_SINGLE == "Y" && CurInvItem.Items.Count > 1)
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("储位[{0}]只能存放一个物料");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationSingleFailure", nLocation.LOCATION_CODE);
                    ResetScan();
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //执行上架数据处理
                foreach (var item in CurInvItem.Items)
                {
                    item.IS_LOCKED = "Y";
                    item.SOURCE_CODE = item.TRANS_CODE;
                    item.SOURCE_ORDER = item.TRANS_NO;
                    item.SOURCE_LINE = item.TRANS_LINE;
                    item.TRANS_CODE = nameof(BIZ_U9_RECEIPT);
                    item.TRANS_NO = receipt.ORDER_NO;
                    item.TRANS_LINE = receiptDtl.LINE_NO;
                    item.PROD_DATE = item.PROD_DATE < new DateTime(2000, 1, 1) ? DateTime.Now : item.PROD_DATE;
                    item.FIRST_IN_DATE = item.FIRST_IN_DATE < new DateTime(2000, 1, 1) ? DateTime.Now : item.FIRST_IN_DATE;
                }
                Result putonResult = PutOn(input.AuthOption, nLocation.LOCATION_CODE);
                if (!putonResult.IsSuccessed)
                {
                    action.IsSuccessed = false;
                    action.LocaleMsg = putonResult.LocaleMsg;
                    ResetScan();
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                //更新单据信息
                foreach(var sn in receiptSn)
                {
                    sn.STATUS = WMS_ITEM.STATUSs.InStore.GetValue();
                    sn.IS_IN = "Y";
                }
                //如果当前行上架完成标记为待审核
                receiptDtl.QTY_IN = receipt.SnList.Where(q => q.LINE_NO == receiptDtl.LINE_NO).Sum(q => q.QTY);
                if (receiptDtl.QTY_IN == receiptDtl.QTY)
                {
                    receiptDtl.STATUS = BIZ_U9_RECEIPT.STATUSs.Review.GetValue();
                    //当前单据明细已经全部上架完成,可以调用U9行审接口
                    var iInput = new SubmitLineInput
                    {
                        userId = UserCode,
                        IsLogin = true,
                        param = new()
                        {
                            RcvLineID = receiptDtl.ID,
                            RcvDocNo = receiptDtl.ORDER_NO,
                            DocLineNo = receiptDtl.LINE_NO,
                            OrgCode = receiptDtl.AUTH_ORG,
                        }
                    };
                    var result = await DI.Resolve<IWMS_U9C>().ReceivementApproveLine(iInput);
                    if (!result.IsSuccessed)
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = result.LocaleMsg;
                        return SetOutPutMqttMsg(action, input.Locale);
                    }
                }
                else
                {
                    receiptDtl.STATUS = BIZ_U9_RECEIPT.STATUSs.Storing.GetValue();
                }
                var dtlStatus = receipt.Details.Select(q => q.STATUS).Distinct();
                if (dtlStatus.Count() == 1 && dtlStatus.First() == BIZ_U9_RECEIPT.STATUSs.Review.GetValue())
                {
                    receipt.STATUS = BIZ_U9_RECEIPT.STATUSs.Review.GetValue();
                }
                else
                {
                    receipt.STATUS = BIZ_U9_RECEIPT.STATUSs.Storing.GetValue();
                }
                //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值
                var _receipt = receipt.Clone();
                AddCommitAction("Receipt", () =>
                {
                    //使用统一的事务DB对象
                    var db = GetCommitDB();
                    //数据保存逻辑
                    db.Updateable(receipt, UserCode).UpdateColumns(q => new { q.STATUS, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand();
                    db.Updateable(receiptDtl, UserCode).UpdateColumns(q => new { q.STATUS, q.QTY_IN, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand();
                    db.Updateable(receiptSn, UserCode).UpdateColumns(q => new { q.STATUS, q.IS_IN, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand();
                });
                //完成所有处理后使用事务保存数据
                action = DoIfFinish(action, input.Locale);
            }
            catch (Exception ex)
            {
                //取消当前操作
                ResetScan();
                //action.CatchExceptionWithLog(ex, $"扫描条码[{input.SN}]复核异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
            }
            return SetOutPutMqttMsg(action, input.Locale);
        }
        /// <summary>
        /// æ‰«æè´§æž¶æˆ–者储位
        /// </summary>
        public async Task<ApiAction<ScanOutput>> ScanShelf(string Code, V_WH_UNIT whUnit)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput() { Command = Command });
            try
            {
                if (Code.IsNullOrEmpty())
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
                    return action;
                }
                CurScanShelf = new ScanShelfInfo();
                // æŸ¥è¯¢è´§æž¶ä¿¡æ¯
                whUnit = whUnit.IsNullOrEmpty(await MainDB.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == Code || t.LOCATION_CODE.ToUpper() == Code) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync());
                // æ‰«æè´§æž¶ä»£ç ï¼Œä¸”为智能货架
                if (!whUnit.IsNullOrEmpty() && whUnit.SHELF_CODE  == Code)
                {
                    CurScanShelf.Shelf = whUnit.Shelf;
                    CurScanShelf.WarehouseCode = whUnit.WH_CODE;
                    CurScanShelf.RegionCode = whUnit.REGION_CODE;
                    CurScanShelf.ShelfCode = whUnit.SHELF_CODE;
                    CurScanShelf.ShelfType = whUnit.SHELF_TYPE;
                    CurScanShelf.IsSmartRack = true;
                }
                // æ‰«æåº“位代码
                else if (!whUnit.IsNullOrEmpty() && whUnit.LOCATION_CODE == Code)
                {
                    //var nLocation = await MainDB.Queryable<V_WH_UNIT>().Where(t => t.LOCATION_CODE.ToUpper() == Code.ToUpper() && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
                    //if (nLocation == null)
                    //{
                    //    action.IsSuccessed = false;
                    //    //action.LocaleMsg = Biz.L("储位[{0}]不存在");
                    //    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.LocationNotExist", Code);
                    //    return action;
                    //}
                    if (whUnit.IS_ACTIVE == "N")
                    {
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("扫描的储位[{0}]未启用");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfOrLocationDisabled", Code);
                        return action;
                    }
                    if (whUnit.Shelf.IsLightShelf || whUnit.Location.IS_SINGLE == "Y")
                    {
                        var locationData = MainDB.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == whUnit.LOCATION_ID && q.AUTH_ORG == OrgCode).First();
                        if (!locationData.IsNullOrEmpty())
                        {
                            action.IsSuccessed = false;
                            //action.LocaleMsg = Biz.L("储位[{0}]已存有物料[{1}],请检查系统库存信息");
                            action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", Code, locationData.SN);
                            return action;
                        }
                    }
                    CurScanShelf.Shelf = whUnit.Shelf;
                    CurScanShelf.Location = whUnit.Location;
                    CurScanShelf.WarehouseCode = whUnit.WH_CODE;
                    CurScanShelf.RegionCode = whUnit.REGION_CODE;
                    CurScanShelf.ShelfCode = whUnit .SHELF_CODE;
                    CurScanShelf.LocationCode = whUnit.LOCATION_CODE;
                    CurScanShelf.IsSmartRack = false;
                }
                else
                {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
                    return action;
                }
                CurScanShelf.IsScanShelf = true;
                //action.LocaleMsg = Biz.L("扫描货架/储位[{0}]成功");
                action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ScanSucceeded", Code);
                action.Data.Data = CurScanShelf;
            }
            catch (Exception ex)
            {
                //取消当前操作
                ResetScan();
                //action.CatchExceptionWithLog(ex, $"扫描货架/储位[{0}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
            }
            return action;
        }
        /// <summary>
        /// å®Œæˆæ‰€æœ‰å¤„理后使用事务保存数据
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale)
        {
            //保存数据库
            SaveCommitListToDB();
            // è¿”回数据
            action.Data.Data = new DefaultInStoreOutput
            {
                Barcode = CurInvItem.SN,
                MaterialCode = CurInvItem.ItemInfo.ITEM_CODE,
                MaterialName = CurInvItem.ItemInfo.ITEM_NAME,
                CurrentQty = CurInvItem.Items[0].QTY,
                Unit = CurInvItem.Items[0].UNIT,
                DateCode = CurInvItem.Items[0].PROD_DATE,
                WarehouseCode = CurInvItem.Warehouse.WH_CODE,
                RegionCode = CurInvItem.Region.REGION_CODE,
                ShelfCode = CurInvItem.Shelf.SHELF_CODE,
                LocationCode = CurInvItem.Location.LOCATION_CODE,
            };
            //action.LocaleMsg = Biz.L($"扫描条码[{0}]上架到储位[{1}]成功");
            action.LocaleMsg = Biz.L("WMS.Default.ScanItem.PutOnSucceeded", CurInvItem.SN, CurInvItem.Location.LOCATION_CODE);
            //重置工序
            ResetScanInfo();
            return SetOutPutMqttMsg(action, locale);
        }
        #endregion
        /// <summary>
        /// é‡ç½®å½“前操作,有需要则重写此方法
        /// </summary>
        public override void ResetScan()
        {
            base.ResetScan();
            ResetScanInfo();
            CurScanShelf = null;
        }
        /// <summary>
        /// é‡ç½®æ‰«ç ä¿¡æ¯
        /// </summary>
        public void ResetScanInfo()
        {
            Command = null;
            CurInvItem = null;
        }
        public override bool Close(bool needSaveHistoryLog = false)
        {
            this.IsFinished = true;
            return IsFinished ? base.Close(needSaveHistoryLog) : IsFinished;
        }
    }//endClass
}
Tiger.Controllers.WMS/Controllers/WMSController.Print_BIZ_U9_ASN.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,141 @@
using System;
using System.Threading.Tasks;
using Rhea.Common;
using Tiger.Model;
using Tiger.IBusiness;
using Microsoft.AspNetCore.Mvc;
using Tiger.Model.Minsun;
using Autofac;
namespace Tiger.Api.Controllers.WMS
{
    public partial class WMSController : ControllerBase
    {
        /// <summary>
        /// GetTransaction(ApiAction(Data:UserId))
        /// æ ¹æ®ApiAction的id返回一个(U9)来料打印上架事务
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/Print_U9Asn/GetTransaction")]
        public IActionResult Print_BIZ_U9_ASN_GetTransaction([FromBody] ApiAction<USER> action)
        {
            ApiAction response;
            IPrint_BIZ_U9_ASN trans = null;
            try
            {
                if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID))
                {
                    trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IPrint_BIZ_U9_ASN;
                }
                else
                {
                    trans = AutoFacContainer.Instance.Resolve<IPrint_BIZ_U9_ASN>().Init(action.ID, action.Data?.USER_CODE, Request.Host.Value, action.Data?.ORG_CODE);
                    iBiz.WMS.Context.NewTransaction(HttpContext, trans);
                }
                response = action.GetResponse();
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            trans?.AddHistory(Request, action);
            return Ok(response);
        }
        /// <summary>
        /// CloseTransaction(ApiAction)
        /// å…³é—­äº‹åŠ¡
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/Print_U9Asn/CloseTransaction")]
        public IActionResult Print_BIZ_U9_ASN_CloseTransaction([FromBody] ApiAction action)
        {
            ApiAction response;
            IPrint_BIZ_U9_ASN trans = null;
            try
            {
                if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID))
                {
                    trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IPrint_BIZ_U9_ASN;
                    if (!trans.IsFinished)
                    {
                        if (action.IsAsync)
                        {
                            response = action.GetResponse(trans.Close());
                        }
                        else
                        {
                            lock (trans.TransLock) { response = action.GetResponse(trans.Close()); }
                        }
                        response.Message = $"(U9)来料打印上架事务[ID:{action.ID}]关闭{(response.IsSuccessed ? "成功" : "失败")}";
                    }
                    else
                    {
                        response = action.GetResponse($"Transaction Error: (U9)来料打印上架事务[ID:{action.ID}]已经关闭", false);
                    }
                }
                else
                {
                    response = action.GetResponse($"Transaction Error: (U9)来料打印上架事务[ID:{action.ID}]已经关闭", false);
                }
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            trans?.AddHistory(Request, action);
            return Ok(response);
        }
        /// <summary>
        /// æ‰«æå…¥å£
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/Print_U9Asn/Scan")]
        public async Task<IActionResult> Print_BIZ_U9_ASN_ScanAsync([FromBody] ApiAction<BaseInput> action)
        {
            ApiAction response;
            IPrint_BIZ_U9_ASN trans = null;
            try
            {
                if (iBiz.WMS.Context.GetTransDic().ContainsKey(action.ID))
                {
                    trans = iBiz.WMS.Context.GetTransDic()[action.ID] as IPrint_BIZ_U9_ASN;
                    if (!trans.IsFinished)
                    {
                        if (action.IsAsync)
                        {
                            response = action.GetResponse(await trans.Scan(action.Data));
                        }
                        else
                        {
                            lock (trans.TransLock) { response = action.GetResponse(trans.Scan(action.Data).Result); }
                        }
                    }
                    else
                    {
                        response = action.GetResponse($"Transaction Error: (U9)来料打印上架事务[ID:{action.ID}]已经关闭,请重新打开(U9)来料打印上架功能", false);
                    }
                }
                else
                {
                    response = action.GetResponse($"Transaction Error: (U9)来料打印上架事务[ID:{action.ID}]数据丢失,请重新打开(U9)来料打印上架功能", false);
                }
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            trans?.AddHistory(Request, action);
            return Ok(response);
        }
    }
}
Tiger.IBusiness.WMS/Transaction/IPrint_BIZ_U9_ASN.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
namespace Tiger.IBusiness
{
    /// <summary>
    /// (U9)来料打印上架事务
    /// </summary>
    public interface IPrint_BIZ_U9_ASN : IWmsTask
    {
        public IPrint_BIZ_U9_ASN Init(string id, string userCode, string apiHost, string orgCode);
        /// <summary>
        /// æ‰«æå…¥å£
        /// </summary>
        public Task<ApiAction<ScanOutput>> Scan(BaseInput input);
        public bool Close(bool needSaveHistoryLog = false);
    }
}