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; using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; using Tiger.Model.Entitys.MES.U9C; namespace Tiger.Business.WMS.Transaction { /// /// 半成品打印标签事务 /// public class PrintSemiProdLabel : WMSTransactionBase, IPrintSemiProdLabel { private readonly IMES_U9C _IMES_U9C = DI.Resolve(); 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 SemiTemplateInput { RcvRptDocId = item.ID.ToString(), ItemCode = item.ItemCode, ItemDesc = item.ItemDescription, SapItemCode = "", WoBatch = item.LotCode, PackQty = item.PackQty.ToDecimal(), Qty = item.RcvQtyByWhUOM.ToDecimal(), DocNo = item.DocNo, WorkOrder = item.Mo }; temps.Add(temp); } action.Data.Data = temps; action.LocaleMsg = Biz.L("WMS.PrintSemiProdLabel.Scan.ScanSuccessed", input.SN); } catch (Exception ex) { //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常"); action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.Scan.ScanException", input.SN)); } return SetOutPutMqttMsg(action, input.Locale); } /// /// 扫码提交 /// /// /// public async Task> ScanItem(BaseInput input) { var action = new ApiAction(new ScanOutput()); try { var semiTemplate = (input.Data ?? "").JsonToObject() ?? new SemiTemplateInput(); //生成条码 BarcodeCreateByAssignQtyInput barcodeCreateInput = new() { RevDocId = semiTemplate.RcvRptDocId, userId = input.AuthOption.UserId, token = "", IsLogin = true, CreateBarCodeItemQty = semiTemplate.Qty, LabelQty = semiTemplate.PackQty, }; var snList = await _IMES_U9C.U9CCreateBarCodeByAssignQty(barcodeCreateInput); action.Data.Data = snList; //action.Data.Data = new List { // "YDRKD241200014/10/20051210.0013.00/YDMB241254400/0001", // "YDRKD241200014/10/20051210.0013.00/YDMB241254400/0002", // "YDRKD241200014/10/20051210.0013.00/YDMB241254400/0003", // "YDRKD241200014/10/20051210.0013.00/YDMB241254400/0004" //}; } catch (Exception ex) { //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]提交异常"); action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.ScanItem.ScanItemException", 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 }