From 5f5d8997fb860e8554a9bbb4d627715ca66b17cc Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 19 十一月 2024 15:00:50 +0800 Subject: [PATCH] 变量获取更新,获取出货信息更新 --- Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | 107 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 95 insertions(+), 12 deletions(-) diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs index 43b2b5c..29d2183 100644 --- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs @@ -19,6 +19,7 @@ using System.Net.NetworkInformation; using Tiger.Model.MES.Yada; using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; +using Tiger.Model.Minsun; namespace Tiger.Business.MES { @@ -501,7 +502,7 @@ } } //鍏ュ簱鏍囩 - var wipActInStore = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.SN == woSn.SN && q.NODE_ID == pkgList[0].NODE_ID && !SqlFunc.IsNullOrEmpty(q.ACT_VALUE_3) && q.ACT_VALUE_4 == "InStroe").First(); + var wipActInStore = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.SN == woSn.SN && q.NODE_ID == pkgList[0].NODE_ID && !SqlFunc.IsNullOrEmpty(q.ACT_VALUE_3) && q.ACT_VALUE_4 == "InStore").First(); if (!wipActInStore.IsNullOrEmpty()) { var label = JsonConvert.DeserializeObject<BAS_LABEL_TEMP>(wipActInStore.ACT_VALUE_3); @@ -518,7 +519,7 @@ string ACT_VALUE_3 = JsonConvert.SerializeObject(label); foreach (var pkg in pkgList) { - var actSn = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.WIP_ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_VALUE_4 == "InStroe").First(); + var actSn = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.WIP_ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_VALUE_4 == "InStore").First(); if (!actSn.IsNullOrEmpty()) { actSn.ACT_VALUE_3 = ACT_VALUE_3; @@ -579,11 +580,15 @@ //濡傛灉鏌ヤ笉鍒板氨鍘昏涓烘棩蹇楁煡 if (labelPrint.IsNullOrEmpty() && input.ReqType == 1) { - printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => (q.SN.Equals(input.Code) || q.FLOW_SN.Equals(input.Code)) && q.ACT_VALUE_4 == "Customer").First()?.ACT_VALUE_3 ?? ""; + printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.CARTON_SN.Equals(woSn.OUTER_SN) && q.ACT_VALUE_4 == "Customer").First()?.ACT_VALUE_3 ?? ""; + } + else if (labelPrint.IsNullOrEmpty() && input.ReqType == 2) + { + printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.SN.Equals(woSn.SN) && q.ACT_VALUE_4 == "InStore").First()?.ACT_VALUE_3 ?? ""; } else { - printParam = labelPrint.PRINT_PARAM; + printParam = labelPrint?.PRINT_PARAM ?? ""; } result.Data = printParam; result.LocaleMsg = new($"閲嶆墦鏉$爜[{input.Code}]鐨勬爣绛炬垚鍔�"); @@ -600,22 +605,34 @@ /// </summary> /// <param name="wo"></param> /// <returns></returns> - public async Task<ApiAction> GetShipList(string wo, string orgCode) + public async Task<ApiAction<ShippingOutput>> GetShipList(string wo, string orgCode) { - var result = new ApiAction(); + var result = new ApiAction<ShippingOutput>(); try { DbClient db = Biz.DataSource["YadaU9C"].Client; - var org = await Biz.Db.Queryable<SYS_ORGANIZATION>().Where(q=>q.ORG_CODE == orgCode).FirstAsync(); - var shipList = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now) && q.Status == 2 && q.Org == org.ID.ToInt64()).ToList(); - if (shipList.Any()) + var org = await Biz.Db.Queryable<SYS_ORGANIZATION>().Where(q => q.ORG_CODE == orgCode).FirstAsync(); + var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && q.Org == org.ID.ToInt64()).First(); + if (!ship.IsNullOrEmpty()) { - result.Data = shipList[0].ShipQty; + result.Data = ship.BusinessDate.Date == DateTime.Now.Date ? new() + { + ShippingQty = ship.ShipQty, + Tag = "Customer" + } : new() + { + ShippingQty = ship.ShipQty, + Tag = "InStoreLabel" + }; result.LocaleMsg = new($"鍑鸿揣淇℃伅瀛樺湪锛�"); } else { - result.Data = "InStoreLabel"; + result.Data = new() + { + ShippingQty = 0, + Tag = "InStoreLabel" + }; } } catch (Exception ex) @@ -636,14 +653,21 @@ var result = new ApiAction(); try { - var wipList = await Biz.Db.Queryable<MES_WIP_DATA>().Where(q => q.SN.Equals(input.SN) || q.FLOW_SN.Equals(input.SN) || q.CARTON_SN == input.SN).ToListAsync(); + var cartonSn = input.SN.Split('|')[0]; + var wipList = await Biz.Db.Queryable<MES_WIP_DATA>().Where(q => q.SN.Equals(input.SN) || q.FLOW_SN.Equals(input.SN) || q.CARTON_SN == cartonSn).ToListAsync(); if (wipList.Count == 0) { result.IsSuccessed = false; result.LocaleMsg = new($"瑙g粦鐨勬潯鐮佷笉瀛樺湪褰撳墠鎿嶄綔琛ㄤ腑锛�"); + return result; } var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == wipList[0].WORK_ORDER).FirstAsync(); result = WorkBatch.UnbindWipSnFromWO(wo, wipList, input.user); + if (result.IsSuccessed) + { + var newList = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.WORK_ORDER == wo.ORDER_NO && q.BATCH_NO == wipList[0].BATCH_NO && SqlFunc.IsNullOrEmpty(q.PARENT_SN) && q.QTY > 0).ToListAsync(); + result.Data = newList; + } } catch (Exception ex) { @@ -651,5 +675,64 @@ } return result; } + + /// <summary> + /// 鐢熸垚鍏ュ簱鑾峰彇鏉$爜宸ュ崟淇℃伅鍙婂寘瑁呬俊鎭� + /// </summary> + /// <param name="code"></param> + /// <returns></returns> + public async Task<ApiAction<InStoreInfo>> GetErpProdInBth(string code) + { + var result = new ApiAction<InStoreInfo>(); + try + { + //寰楀埌宸ュ崟鏉$爜璁板綍 + var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == code).ToListAsync(); + if (woSns.Count == 0) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"鏉$爜涓嶅瓨鍦紒"); + return result; + } + var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == woSns[0].WORK_ORDER ).IncludesAllFirstLayer().FirstAsync(); + if (wo == null) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"鏉$爜瀵瑰簲鐨勫伐鍗曚笉瀛樺湪"); + return result; + } + InStoreInfo inStoreInfo = new() { + ErpProdInBth= new() { + WORK_ORDER = wo.ORDER_NO, + BATCH_NO = woSns[0].BATCH_NO, + ITEM_CODE = wo.ITEM_CODE, + ITEM_NAME = wo.ItemInfo?.ITEM_NAME, + SCAN_QTY = woSns.Count + }, + ProdInBatch = new() + { + WORK_ORDER = wo.ORDER_NO, + BATCH_NO = woSns[0].BATCH_NO, + ITEM_CODE = wo.ITEM_CODE, + ITEM_NAME = wo.ItemInfo?.ITEM_NAME, + PLAN_QTY = wo.PLAN_QTY, + SCAN_QTY = woSns.Count + }, + InStoreScanInfo = new() { + SN = code, + WORK_ORDER = wo.ORDER_NO, + BATCH_NO = woSns[0].BATCH_NO, + SCAN_QTY = woSns.Count + } + }; + result.Data = inStoreInfo; + result.LocaleMsg = new($"鑾峰彇鏉$爜[{code}]宸ュ崟淇℃伅鍙婂寘瑁呬俊鎭垚鍔�"); + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, $"鑾峰彇鏉$爜[{code}]宸ュ崟淇℃伅鍙婂寘瑁呬俊鎭紓甯�"); + } + return result; + } } } -- Gitblit v1.9.3