From 9fe67118a220448d5d9647733d6c8308f069e4da Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期日, 13 十月 2024 16:05:23 +0800 Subject: [PATCH] 增加工艺路线必须要有结束节点,及其流程相应优化 增加工单批次自动关单 增加判断条码是未投入生产还是已经完工产出 --- Tiger.Business.MES/Transaction/Position.cs | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs index cf98edc..a5433bb 100644 --- a/Tiger.Business.MES/Transaction/Position.cs +++ b/Tiger.Business.MES/Transaction/Position.cs @@ -97,12 +97,12 @@ /// </summary> /// <param name="input"></param> /// <returns></returns> - public async Task<ApiAction> SelectOrder(WoInput input) + public async Task<ApiAction> SelectOrder(WoInput input, string batchNo = "") { var action = new ApiAction(); try { - if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE)) + if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE, batchNo)) { var wo = await Biz.Db.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync(); //楠岃瘉鏄庣粏鏄惁姝g‘ @@ -116,11 +116,14 @@ if (wo.STATUS != BIZ_MES_WO.STATUSs.Release.GetValue() && wo.STATUS != BIZ_MES_WO.STATUSs.Working.GetValue()) { action.IsSuccessed = false; - //action.LocaleMsg = new($"宸ュ崟[{input.OrderNo}]鐘舵�乕{wo.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetName()}]涓嶈兘鐢熶骇"); + //action.LocaleMsg = new($"宸ュ崟[{0}]鐘舵�乕{1}]涓嶈兘鐢熶骇"); action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.StatusException", input.OrderNo, wo.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetName()); return action; } - var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE).FirstAsync(); + var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption) + .Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE) + .WhereIF(!batchNo.IsNullOrEmpty(), q => q.BATCH_NO == batchNo) + .OrderBy(q => q.STATUS).FirstAsync(); if (batch.IsNullOrEmpty()) { action.IsSuccessed = false; @@ -131,14 +134,14 @@ if (batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() && batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Working.GetValue()) { action.IsSuccessed = false; - //action.LocaleMsg = new($"宸ュ崟[{input.OrderNo}]鐘舵�乕{wo.STATUS.GetEnum<BIZ_MES_WO_BATCH.STATUSs>().GetName()}]涓嶈兘鐢熶骇"); - action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.StatusException", input.OrderNo, batch.STATUS.GetEnum<BIZ_MES_WO_BATCH.STATUSs>().GetName()); + //action.LocaleMsg = new($"宸ュ崟[{0}]鎵规[1]鐘舵�乕{2}]涓嶈兘鐢熶骇"); + action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.BatchStatusException", input.OrderNo, batch.BATCH_NO, batch.STATUS.GetEnum<BIZ_MES_WO_BATCH.STATUSs>().GetName()); return action; } var wb = new WorkBatch(input.OrderNo).Init(CurLine.LINE_CODE); WoContext.WoBatchDic.Add(wb.Batch.BATCH_NO, wb); } - CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE); + CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE, batchNo); if (!OperInfoDic.ContainsKey(CurBatch.Batch.BATCH_NO)) { OperInfoDic.Add(CurBatch.Batch.BATCH_NO, new()); @@ -222,7 +225,12 @@ if (CurWipSNs.Any()) { info.CurNode = CurWipSNs.First().NODE_NAME; - info.NextNode = string.Join(",", CurBatch.GetNextNodes(CurWipSNs.First()).Select(q => q.NODE_NAME)); + var nextNodes = CurBatch.GetNextNodes(CurWipSNs.First()); + info.NextNode = string.Join(",", nextNodes.Select(q => q.NODE_NAME)); + if (nextNodes.Count == 1 && nextNodes.Single().OPER_CODE == "EndNode") + { + info.IsReachedEndNode = true; + } } else { @@ -717,7 +725,7 @@ var snList = string.Join("\r\n", minPkgList); if (snList.IsNullOrEmpty()) { snList = $"{CurSN}"; } var _sn = minPkgList.FirstOrDefault() ?? CurSN; - var itemCode = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == _sn || q.CUST_CODE == _sn).First()?.ITEM_CODE; + var itemCode = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == _sn || q.CUST_SN == _sn).First()?.ITEM_CODE; var weight = action.CurPkg.WeightInfo.Weight; var unit = action.CurPkg.WeightInfo.Unit.ToUpper(); var model = WorkBatch.Product.ExtInfo.Model; @@ -752,7 +760,7 @@ int daysOffset = firstDay.DayOfWeek.GetValue() > 3 ? (firstDay.DayOfWeek.GetValue() - 7) : 0; int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0); int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday); - dic.Add(sn, $"{year.ToString().Substring(2, 2)}{week:00}"); + dic.Add(sn, $"{year.ToString("0000").Substring(2, 2)}{week:00}"); } else { -- Gitblit v1.9.3