From 9e4d2ea113f6d5631f78aa85bbe39481fd701b72 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 27 二月 2025 10:47:39 +0800
Subject: [PATCH] 雅达-扩展和改进半成品入库和打印标签功能

---
 Tiger.Business.WMS/Transaction/PrintSemiProdLabel.cs |   75 +++++++++++++++++++++----------------
 1 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/PrintSemiProdLabel.cs b/Tiger.Business.WMS/Transaction/PrintSemiProdLabel.cs
index ff8fd30..d5f772b 100644
--- a/Tiger.Business.WMS/Transaction/PrintSemiProdLabel.cs
+++ b/Tiger.Business.WMS/Transaction/PrintSemiProdLabel.cs
@@ -16,6 +16,8 @@
 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
 {
@@ -24,6 +26,7 @@
     /// </summary>
     public class PrintSemiProdLabel : WMSTransactionBase, IPrintSemiProdLabel
     {
+        private readonly IMES_U9C _IMES_U9C = DI.Resolve<IMES_U9C>();
         public IPrintSemiProdLabel Init(string id, string userCode, string apiHost, string orgCode)
         {
             TransID = id;
@@ -58,28 +61,23 @@
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
                 var DocLines = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_RcvRptDocLine>($"select * from mes_RcvRptDocLine where DocNo = '{input.SN}'");
-                
-                var temps = new List<TemplateInput>();
+
+                var temps = new List<SemiTemplateInput>();
                 foreach (var item in DocLines)
                 {
-                    var temp = new TemplateInput
+                    var temp = new SemiTemplateInput
                     {
-                        custCode="",
-                        itemCode= item.ItemCode,
-                        itemDesc= item.ItemDescription,
-                        sapItemCode= "",
-                        WoBatch = item.LotCode,
-                        batchQty= item.PackQty,
-                        qrCode="",
+                        RcvRptDocId = item.ID.ToString(),
+                        ItemCode= item.ItemCode,
+                        ItemDesc= item.ItemDescription,
+                        SapItemCode= "",
+                        PackQty= item.PackQty.ToDecimal(),
+                        Qty=0,
+                        DocNo= item.DocNo,
+                        WorkOrder= item.Mo
                     };
                     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");
@@ -87,40 +85,51 @@
             catch (Exception ex)
             {
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
-                action.CatchExceptionWithLog(ex, Biz.L("WMS.RePrint.Scan.ScanException", input.SN));
+                action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.Scan.ScanException", input.SN));
             }
             return SetOutPutMqttMsg(action, input.Locale);
         }
 
+        /// <summary>
+        /// 鎵爜鎻愪氦
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
         public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
         {
             var action = new ApiAction<ScanOutput>(new ScanOutput());
             try
             {
-                List<WMS_ITEM> items = new List<WMS_ITEM>();
-                List<WMS_ITEM_HIS> itemhiss = new List<WMS_ITEM_HIS>();
-                List<WMS_ITEM_PKG> itemPkgs = new List<WMS_ITEM_PKG>();
-                List<WMS_ITEM_EXT> itemExts = new List<WMS_ITEM_EXT>();
-                var rePrints = (input.Data ?? "").JsonToObject<PrintSemiProdLabelEntity>() ?? new PrintSemiProdLabelEntity();
-                if (!rePrints.SnList.Any() || rePrints.SnList.Any(q => q.Qty <= 0))
+                if (input.SN.IsNullOrEmpty())
                 {
                     action.IsSuccessed = false;
-                    //action.LocaleMsg = Biz.L("鏁伴噺涓嶈兘灏忎簬绛変簬闆讹紝璇烽噸鏂扮‘璁ゆ潯鐮乕{0}]鐨勬暟閲�");
-                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN);
-                    return action;
+                    //action.LocaleMsg = Biz.L("鏉$爜涓嶈兘涓虹┖");
+                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
+                    return SetOutPutMqttMsg(action, input.Locale);
                 }
-                else
-                {
+                var semiTemplate = (input.Data ?? "").JsonToObject<SemiTemplateInput>() ?? new SemiTemplateInput();
 
-                    action.Data.Data = rePrints;
-                    action.LocaleMsg = Biz.L("鍗婃垚鍝佹墦鍗版爣绛炬垚鍔�");
-                }
+                //鐢熸垚鏉$爜
+                BarcodeCreateByAssignQtyInput barcodeCreateInput = new()
+                {
+                    RevDocId = semiTemplate.RcvRptDocId,
+                    userId = input.AuthOption.UserId,
+                    token = "",
+                    IsLogin = true,
+                    CreateBarCodeItemQty = semiTemplate.PackQty,
+                    LabelQty = semiTemplate.Qty,
+                };
+               
+                var snList = await _IMES_U9C.U9CCreateBarCodeByAssignQty(barcodeCreateInput);
+                action.Data.Data = snList;
             }
             catch (Exception ex)
             {
-                action.CatchExceptionWithLog(ex, Biz.L("鍗婃垚鍝佹墦鍗版爣绛惧け璐�"));
+                //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]鎻愪氦寮傚父");
+                action.CatchExceptionWithLog(ex, Biz.L("WMS.PrintSemiProdLabel.ScanItem.ScanItemException", input.SN));
+
             }
-            return action;
+            return SetOutPutMqttMsg(action, input.Locale);
         }
 
         #endregion

--
Gitblit v1.9.3