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 { /// /// 半成品打印标签事务 /// public class PrintSemiProdLabel : WMSTransactionBase, IPrintSemiProdLabel { public IPrintSemiProdLabel 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(); #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.PrintSemiProdLabel.ScanItem.SnEmptyFailure"); return SetOutPutMqttMsg(action, input.Locale); } var DocLines = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery($"select * from mes_RcvRptDocLine where DocNo = '{input.SN}'"); var temps = new List(); foreach (var item in DocLines) { var temp = new TemplateInput { custCode="", itemCode= item.ItemCode, itemDesc= item.ItemDescription, sapItemCode= "", WoBatch = item.LotCode, batchQty= item.PackQty, qrCode="", }; temps.Add(temp); } //var y = Biz.Db.Storageable(DocLines, 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.PrintSemiProdLabel.Scan.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> ScanItem(BaseInput input) { var action = new ApiAction(new ScanOutput()); try { List items = new List(); List itemhiss = new List(); List itemPkgs = new List(); List itemExts = new List(); var rePrints = (input.Data ?? "").JsonToObject() ?? new PrintSemiProdLabelEntity(); if (!rePrints.SnList.Any() || rePrints.SnList.Any(q => q.Qty <= 0)) { action.IsSuccessed = false; //action.LocaleMsg = Biz.L("数量不能小于等于零,请重新确认条码[{0}]的数量"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN); return action; } else { action.Data.Data = rePrints; action.LocaleMsg = Biz.L("半成品打印标签成功"); } } 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 }