using Rhea.Common; using Tiger.Model.Minsun; 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; namespace Tiger.Business.WMS.Transaction { /// /// 查储位补印条码事务 /// public class RePrintLabel : WMSTransactionBase, IRePrintLabel { public IRePrintLabel 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 List Vitem { get; set; } = new(); public Inventory CurInv { get; set; } #endregion #region Functions /// /// 扫描入口 /// public async Task> Scan(BaseInput input) { var action = new ApiAction(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.Queryable().Where(t => t.Bin == input.SN).ToList(); //var whUnit = await Biz.Db.Queryable().Where(t => t.LOCATION_CODE.ToUpper() == input.SN && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync(); var items = LotNos.Select(q => q.ItemCode); var ItemList = Biz.Db.Queryable().Where(t => t.AUTH_ORG == OrgCode && items.Contains(t.ITEM_CODE)).IncludesAllFirstLayer().ToList(); var temps = new List(); foreach (var item in LotNos) { var temp = new TemplateInput { custCode="", itemCode= item.ItemCode, itemDesc= ItemList.Where(q => q.ITEM_CODE == item.ItemCode).FirstOrDefault()?.ITEM_DESC, sapItemCode= ItemList.Where(q => q.ITEM_CODE == item.ItemCode).FirstOrDefault()?.ExtInfo?.SapCode, WoBatch = item.LotCode, batchQty= item.StoreQty, qrCode="", }; temps.Add(temp); } 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); } #endregion public override bool Close(bool needSaveHistoryLog = false) { needSaveHistoryLog = true; //保存操作日志 this.IsFinished = true; return IsFinished ? base.Close(needSaveHistoryLog) : IsFinished; } }//endClass }