From c476c9cf07c1b1920cc4bf51f60a78f5768c30fa Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 23 十二月 2024 19:41:33 +0800 Subject: [PATCH] 实体变化引起变更 --- Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | 143 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 132 insertions(+), 11 deletions(-) diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs index 9052669..75a63f5 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 { @@ -185,7 +186,6 @@ pars[1].Direction = System.Data.ParameterDirection.Output; pars[2].Direction = System.Data.ParameterDirection.Output; Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_WO2CUST", pars); - //response.LocaleMsg = new(pars[2].Value.ToString()); if (pars[1].Value.ToInt32() == 0) { Logger.Default.Info($"宸ュ崟[{input.Wo.ORDER_NO}]涓嬪彂瀹屾垚鍚庝繚瀛樺伐鑹鸿矾绾挎暟鎹埌浜у搧[{input.Wo.ITEM_CODE}]鐨勫鎴穂{input.Wo.CUST_CODE ?? ""}]鐨勫伐鑹鸿矾绾夸腑锛寋pars[2].Value.ToString()}"); @@ -224,6 +224,8 @@ var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.WorkOrder).FirstAsync(); if (_wo != null) { + _wo.CHANGE_TIME = _wo.STATUS == BIZ_MES_WO.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO.STATUSs.Working.GetValue() ? DateTime.Now : _wo.CHANGE_TIME; + _wo.CHANGE_USER = _wo.STATUS == BIZ_MES_WO.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO.STATUSs.Working.GetValue() ? input.UserId : _wo.CHANGE_USER; _wo.STATUS = input.Status < 0 ? _wo.STATUS : input.Status; _wo.ROUTE_STATUS = input.RouteStatus; } @@ -268,6 +270,8 @@ var _woBatch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.BATCH_NO == input.WoBatch).FirstAsync(); if (_woBatch != null) { + _woBatch.CHANGE_TIME = _woBatch.STATUS == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue()? DateTime.Now: _woBatch.CHANGE_TIME; + _woBatch.CHANGE_USER = _woBatch.STATUS == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue() ? input.UserId: _woBatch.CHANGE_USER; _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status; if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) { @@ -285,6 +289,16 @@ _woBatch.RELEASE_TIME = DateTime.Now; _woBatch.RELEASE_USER = input.UserId; _woBatch.ACT_LINE = input.ActLine; + _woBatch.CHANGE_USER = input.UserId; + _woBatch.CHANGE_TIME = DateTime.Now; + _wo.STATUS = BIZ_MES_WO.STATUSs.Release.GetValue(); + } + else + { + if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Init.GetValue() && !Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WorkOrder && x.BATCH_NO != input.WoBatch && x.STATUS > BIZ_MES_WO_BATCH.STATUSs.Init.GetValue()).Any()) + { + _wo.STATUS = BIZ_MES_WO.STATUSs.Init.GetValue(); + } } } else @@ -300,11 +314,15 @@ //濡傛灉鏄笅鍙� if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue()) { - db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME, x.CHANGE_USER,x.CHANGE_TIME }).ExecuteCommand(); } else { - db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME, x.CHANGE_USER, x.CHANGE_TIME }).ExecuteCommand(); + } + if (!_wo.IsNullOrEmpty()) + { + db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); } }); if (!dbTran.IsSuccess) @@ -579,7 +597,7 @@ //濡傛灉鏌ヤ笉鍒板氨鍘昏涓烘棩蹇楁煡 if (labelPrint.IsNullOrEmpty() && input.ReqType == 1) { - 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 ?? ""; + printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.CARTON_SN.Equals(woSn.OUTER_SN) && q.ACT_VALUE_4 == "Customer" && !SqlFunc.IsNullOrEmpty(q.ACT_VALUE_3)).First()?.ACT_VALUE_3 ?? ""; } else if (labelPrint.IsNullOrEmpty() && input.ReqType == 2) { @@ -604,22 +622,44 @@ /// </summary> /// <param name="wo"></param> /// <returns></returns> - public async Task<ApiAction> GetShipList(string wo, string orgCode) + public async Task<ApiAction<ShippingOutput>> GetShipList(ShippingInput input) { - 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 == input.orgCode).FirstAsync(); + string wo = input.wo; + if (!input.SN.IsNullOrEmpty() && input.wo.IsNullOrEmpty()) { + var woSn = Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.SN == input.SN || q.FLOW_SN == input.SN).First(); + if (!woSn.IsNullOrEmpty()) { + wo = woSn.WORK_ORDER; + } + } + var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && q.Org == org.ID.ToInt64() && q.Status == 2 ).First(); + if (!ship.IsNullOrEmpty()) { - result.Data = shipList[0].ShipQty; + result.Data = ship.BusinessDate.Date == DateTime.Now.Date ? new() + { + ShipDoc = ship.ShipDoc, + ShippingQty = ship.ShipQty.ToDouble(), + Tag = "Customer" + } : new() + { + ShipDoc = ship.ShipDoc, + ShippingQty = ship.ShipQty.ToDouble(), + Tag = "InStoreLabel" + }; result.LocaleMsg = new($"鍑鸿揣淇℃伅瀛樺湪锛�"); } else { - result.Data = "InStoreLabel"; + result.Data = new() + { + ShipDoc = "", + ShippingQty = 0, + Tag = "InStoreLabel" + }; } } catch (Exception ex) @@ -662,5 +702,86 @@ } 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 cartonSn = code.Split('|')[0]; + var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == cartonSn).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().IncludesAllSecondLayer(q => q._ItemInfos).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, + SALES_ORDER = wo.SALES_ORDER, + ITEM_CODE = wo.ITEM_CODE, + ITEM_NAME = wo.ItemInfo?.ITEM_DESC, + SapCode = wo.ItemInfo?.ExtInfo?.SapCode, + SCAN_QTY = woSns.Count, + IS_HANDLED = "N" //Y-宸茬敓鎴愶紝N-鏈敓鎴愶紝F-澶辫触 + }, + InStoreScanInfo = new() { + SN = cartonSn, + SALES_ORDER = wo.SALES_ORDER, + 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; + } + + #region 鎻愪氦鍓嶉�氱敤鏂规硶 + /// <summary> + /// 鎻愪氦鍓嶆鏌ユ槸鍚﹀矖浣嶃�佸伐鍗曞拰涓嶈壇浠g爜 + /// </summary> + /// <param name="code"></param> + /// <returns></returns> + public async Task<ApiAction<CheckCodeOutput>> CheckCode(string code) + { + var action = new ApiAction<CheckCodeOutput>($"妫�鏌ユ潯鐮亄code}鎴愬姛", new CheckCodeOutput()); + try + { + action.Data.Position = DbCache.Cache.Position[code]; + action.Data.WorkOrder = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == code).FirstAsync(); + action.Data.Defect = DbCache.Cache.Defect[code]; + } + catch (Exception ex) + { + action.CatchExceptionWithLog(ex, $"妫�鏌ユ潯鐮亄code}寮傚父"); + } + return action; + } + #endregion } } -- Gitblit v1.9.3