From f8be4db0be9e9de5830dd41f7d156c368a1ea43f Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期四, 24 四月 2025 09:45:20 +0800
Subject: [PATCH] 优化了一些已知问题

---
 Tiger.Business.MES/BIZ/BIZ_MES_WO.cs |  124 ++++++++++++++++++++++++----------------
 1 files changed, 74 insertions(+), 50 deletions(-)

diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
index 4d9aab6..15f0af6 100644
--- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
+++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -303,6 +303,8 @@
                         _woBatch.CHANGE_USER = input.UserId;
                         _woBatch.CHANGE_TIME = DateTime.Now;
                         _wo.STATUS = BIZ_MES_WO.STATUSs.Release.GetValue();
+                        _wo.RELEASE_TIME = _woBatch.RELEASE_TIME;
+                        _wo.RELEASE_USER = input.UserId;
                     }
                     else
                     {
@@ -333,7 +335,7 @@
                     }
                     if (!_wo.IsNullOrEmpty())
                     {
-                        db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand();
+                        db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME, x.RELEASE_USER, x.RELEASE_TIME }).ExecuteCommand();
                     }
                 });
                 if (!dbTran.IsSuccess)
@@ -788,62 +790,84 @@
             try
             {
                 DbClient db = Biz.DataSource["YadaU9C"].Client;
-                var moPickLists = db.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == code).ToList();
-                var ids = moPickLists.Select(x => SqlFunc.ToString(x.ItemMaster)).ToList();
-                var items = Biz.Db.Queryable<BAS_ITEM>().Where(q => ids.Contains(q.ID)).IncludesAllFirstLayer().ToList();
-                var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == code).IncludesAllFirstLayer().FirstAsync();
-                SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { WO = code });
-                var routeList = Biz.Db.Ado.UseStoredProcedure().SqlQuery<V_MES_WO_PTREE>("SP_MES_GET_WO_PTREE", pars);//杩斿洖List
-                var routeStr = string.Join("->", routeList.Where(q => q.type == "Node" && q.name != "瀹屽伐").OrderBy(x=>x.seq).Select(q=>q.name).ToList());
+                var moPickLists = db.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == code).OrderBy(q => q.DocLineNO).ToList();
                 List<WoFlowCardPrintJson> woFlowCardPrintJson = new();
-                //鐢熸垚鎵撳嵃瀹炰綋
-                int i = 1;
-                WoFlowCardPrintJson printJson = new()
+                if (moPickLists.Count>0)
                 {
-                    ID = Guid.NewGuid().ToString("N"),
-                    OrderNo = code,
-                    ItemCode = wo.ITEM_CODE,
-                    ItemDesc = wo.ItemInfo?.ITEM_DESC,
-                    SapCode = wo.ItemInfo?.ExtInfo?.SapCode,
-                    Qty = wo.PLAN_QTY,
-                    Model = "",
-                    Remark = wo.SALES_REMARK,
-                    RouteStr = routeStr,
-                    Items = new() { }
-                };
-                foreach (var item in moPickLists)
-                {
-                    PrintWoPickList list = new()
+                    var ids = moPickLists.Select(x => SqlFunc.ToString(x.ItemMaster)).ToList();
+                    var items = Biz.Db.Queryable<BAS_ITEM>().Where(q => ids.Contains(q.ID)).IncludesAllFirstLayer().ToList();
+                    var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == code).IncludesAllFirstLayer().FirstAsync();
+                    SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { WO = code });
+                    var routeList = Biz.Db.Ado.UseStoredProcedure().SqlQuery<V_MES_WO_PTREE>("SP_MES_GET_WO_PTREE", pars);//杩斿洖List
+                    var routeStr = string.Join("->", routeList.Where(q => q.type == "Node" && q.name != "瀹屽伐").OrderBy(x => x.seq).Select(q => q.name).ToList());
+                    //鐢熸垚鎵撳嵃瀹炰綋
+                    int i = 1;
+                    int n = 1;
+                    string Model = moPickLists.Where(q => q.IssueStyleName == "鎺ㄥ紡").FirstOrDefault()?.ItemModel;
+                    string MoRemark = moPickLists[0]?.MoRemark;
+                    string SoRemark = moPickLists[0]?.SoRemark;
+                    string Customer = moPickLists[0]?.Customer;
+                    string DemandCode = moPickLists[0]?.DemandCode;
+                    WoFlowCardPrintJson printJson = new()
                     {
-                        LineNo = item.DocLineNO,
-                        SapCode = items.Where(q=> q.ID == SqlFunc.ToString(item.ItemMaster)).FirstOrDefault()?.ExtInfo?.SapCode,
-                        ItemCode = item.Code,
-                        ItemDesc = items.Where(q => q.ID == SqlFunc.ToString(item.ItemMaster)).FirstOrDefault()?.ITEM_DESC,
-                        PickQty = item.ActualReqQty,
-                        LineRemark = "",
-                        WhCode = item.BinCode,
-                        WhCode07 = item.WhCode == "10107" ? item.BinCode : "",
-                        Method = item.IssueStyleName,
+                        ID = Guid.NewGuid().ToString("N"),
+                        OrderNo = code,
+                        Status = wo.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetDesc(),
+                        Model = Model,
+                        ItemCode = wo.ITEM_CODE,
+                        ItemDesc = wo.ItemInfo?.ITEM_DESC,
+                        SapCode = wo.ItemInfo?.ExtInfo?.SapCode,
+                        Qty = wo.PLAN_QTY,
+                        SoRemark = SoRemark,
+                        MoRemark = MoRemark,
+                        Customer = Customer,
+                        DemandCode = DemandCode,
+                        RouteStr = routeStr,
+                        Items = new() { }
                     };
-                    printJson.Items.Add(list);
-                    if (i % 6 == 0)
+                    foreach (var item in moPickLists)
+                    {
+                        PrintWoPickList list = new()
+                        {
+                            LineNo = item.DocLineNO,
+                            SapCode = item.SapCode,
+                            ItemCode = item.Code,
+                            ItemDesc = items.Where(q => q.ID == SqlFunc.ToString(item.ItemMaster)).FirstOrDefault()?.ITEM_DESC,
+                            PickQty = item.ActualReqQty,
+                            LineRemark = item.Remark,
+                            WhCode = item.InventoryInfoCode,
+                            WhCode07 = item.PictureCode,
+                            Method = item.IssueStyleName,
+                        };
+                        printJson.Items.Add(list);
+                        if (i == 8 || n % 11 == 0)
+                        {
+                            if (i == 8) { n = 0; }
+                            woFlowCardPrintJson.Add(printJson);
+                            printJson = new()
+                            {
+                                ID = Guid.NewGuid().ToString("N"),
+                                OrderNo = code,
+                                ItemCode = wo.ITEM_CODE,
+                                ItemDesc = wo.ItemInfo?.ITEM_DESC,
+                                SapCode = wo.ItemInfo?.ExtInfo?.SapCode,
+                                Qty = wo.PLAN_QTY,
+                                Model = Model,
+                                MoRemark = MoRemark,
+                                SoRemark = SoRemark,
+                                Customer = Customer,
+                                DemandCode = DemandCode,
+                                RouteStr = routeStr,
+                                Items = new() { }
+                            };
+                        }
+                        i++;
+                        n++;
+                    }
+                    if (printJson.Items.Count > 0)
                     {
                         woFlowCardPrintJson.Add(printJson);
-                        printJson = new()
-                        {
-                            ID = Guid.NewGuid().ToString("N"),
-                            OrderNo = code,
-                            ItemCode = wo.ITEM_CODE,
-                            ItemDesc = wo.ItemInfo?.ITEM_DESC,
-                            SapCode = wo.ItemInfo?.ExtInfo?.SapCode,
-                            Qty = wo.PLAN_QTY,
-                            Model = "",
-                            Remark = wo.SALES_REMARK,
-                            RouteStr = routeStr,
-                            Items = new() { }
-                        };
                     }
-                    i++;
                 }
                 action.Data = woFlowCardPrintJson;
             }

--
Gitblit v1.9.3