服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-02-19 e9530a6caef3da0d3aeb33642de6a4b369bd70df
雅达-新增 In_SemiProd 类及其相关接口和方法

在 `In_SemiProd.cs` 文件中,添加了多个 `using` 语句以引入所需的命名空间。新增了 `Tiger.Business.WMS.Transaction` 命名空间,并在其中定义了 `In_SemiProd` 类,该类继承自 `WMSTransactionBase` 并实现了 `IIn_SemiProd` 接口。添加了 `Init` 方法用于初始化事务,多个属性和变量,包括 `UserCode`、`UserId`、`OrgCode`、`LocationCode`、`Vitem` 和 `CurScanShelf`。添加了 `Scan` 方法用于处理扫描入口逻辑,包含对输入参数的验证、数据库查询和异常处理。添加了 `ScanItem` 方法,目前方法体为空,仅包含异常处理逻辑。重写了 `Close` 方法,增加了保存操作日志的逻辑。

在 `IIn_SemiProd.cs` 文件中,添加了多个 `using` 语句以引入所需的命名空间。新增了 `Tiger.IBusiness` 命名空间,并在其中定义了 `IIn_SemiProd` 接口。在 `IIn_SemiProd` 接口中,定义了 `Init`、`Scan`、`ScanItem` 和 `Close` 方法的签名。
已添加2个文件
183 ■■■■■ 文件已修改
Tiger.Business.WMS/Transaction/In_SemiProd.cs 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness.WMS/Transaction/IIn_SemiProd.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.WMS/Transaction/In_SemiProd.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,160 @@
using Rhea.Common;
using Microsoft.AspNetCore.Http;
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 Apache.NMS;
using System.Drawing.Drawing2D;
using Tiger.Model.Sharetronic.Shelf;
using Tiger.IBusiness;
using Tiger.Model.MES.Yada;
using Apache.NMS.ActiveMQ.Commands;
using System.Diagnostics;
namespace Tiger.Business.WMS.Transaction
{
    /// <summary>
    /// åŠæˆå“å…¥åº“打印标签事务
    /// </summary>
    public class In_SemiProd : WMSTransactionBase, IIn_SemiProd
    {
        public IIn_SemiProd Init(string id, string userCode, string apiHost, string orgCode)
        {
            TransID = id;
            UserCode = userCode;
            ApiHost = apiHost;
            OrgCode = orgCode;
            Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
            return this;
        }
        #region Propertys & Variables
        public string UserCode { get; set; }
        public long UserId { get; set; }
        public string OrgCode { get; set; }
        public string LocationCode { get; set; }
        public List<V_WMS_ITEM> Vitem { get; set; } = new();
        public ScanShelfInfo CurScanShelf { get; set; }
        #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("WMS.RePrint.ScanItem.SnEmptyFailure");
                    return SetOutPutMqttMsg(action, input.Locale);
                }
                var LotNos = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_WhLotCodeQtyInfo>($"select *,'' as ID from mes_WhLotCodeQtyInfo where Bin = '{input.SN}'");
                //Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList();
                CurScanShelf = new ScanShelfInfo();
                // æŸ¥è¯¢è´§æž¶ä¿¡æ¯
                var whUnit = await Biz.Db.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 (!whUnit.IsNullOrEmpty() && whUnit.LOCATION_CODE == input.SN)
                {
                    if (whUnit.IS_ACTIVE == "N")
                    {
                        action.IsSuccessed = false;
                        //action.LocaleMsg = Biz.L("扫描的储位[{0}]未启用");
                        action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfOrLocationDisabled", input.SN);
                        return action;
                    }
                    if (whUnit.Shelf.IsLightShelf || whUnit.Location.IS_SINGLE == "Y")
                    {
                        var locationData = Biz.Db.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", input.SN, 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;
                    LocationCode = whUnit.LOCATION_CODE;
                }
                else {
                    action.IsSuccessed = false;
                    //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码");
                    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
                    return action;
                }
                var temps = new List<TemplateInput>();
                foreach (var item in LotNos)
                {
                    var temp = new TemplateInput
                    {
                        custCode="",
                        itemCode= item.ItemCode,
                        itemDesc= item.Description,
                        sapItemCode= item.SapCode,
                        WoBatch = item.LotCode,
                        batchQty= item.StoreQty,
                        qrCode="",
                    };
                    temps.Add(temp);
                }
                var y = Biz.Db.Storageable(LotNos, UserCode)
                               .WhereColumns(t => new { t.ItemCode, t.LotCode })
                               .ToStorage();
                y.AsInsertable.ExecuteCommand();
                y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                action.Data.Data = temps;
                action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.ScanSuccessed");
            }
            catch (Exception ex)
            {
                //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常");
                action.CatchExceptionWithLog(ex, Biz.L("WMS.RePrint.Scan.ScanException", input.SN));
            }
            return SetOutPutMqttMsg(action, input.Locale);
        }
        public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
        {
            var action = new ApiAction<ScanOutput>(new ScanOutput());
            try
            {
            }
            catch (Exception ex)
            {
                action.CatchExceptionWithLog(ex, Biz.L("半成品入库失败"));
            }
            return action;
        }
        #endregion
        public override bool Close(bool needSaveHistoryLog = false)
        {
            needSaveHistoryLog = true;
            //保存操作日志
            this.IsFinished = true;
            return IsFinished ? base.Close(needSaveHistoryLog) : IsFinished;
        }
    }//endClass
}
Tiger.IBusiness.WMS/Transaction/IIn_SemiProd.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
using Tiger.Model.Sharetronic.Shelf;
namespace Tiger.IBusiness
{
    public interface IIn_SemiProd : IWMSTransaction
    {
        public IIn_SemiProd Init(string id, string userCode, string apiHost, string orgCode);
        public Task<ApiAction<ScanOutput>> Scan(BaseInput input);
        public Task<ApiAction<ScanOutput>> ScanItem(BaseInput input);
        public bool Close(bool needSaveHistoryLog = false);
    }
}