From 72080a2270d06efe6c9d44fbb82e7edf28d14f05 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期四, 08 八月 2024 11:35:08 +0800 Subject: [PATCH] 包装行为增加已扫条码验证,不允许重复扫描 --- Tiger.Business.MES/BIZ_MES_WO.cs | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 110 insertions(+), 0 deletions(-) diff --git a/Tiger.Business.MES/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ_MES_WO.cs index 2d18114..c4f57de 100644 --- a/Tiger.Business.MES/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ_MES_WO.cs @@ -11,6 +11,8 @@ using Newtonsoft.Json; using Tiger.IBusiness; using Microsoft.AspNetCore.Http; +using Tiger.Model.Entitys.MES.BizMesWoBatch; +using Tiger.Model.Entitys.MES.BizMesWo; namespace Tiger.Business.MES { @@ -90,5 +92,113 @@ } return await Task.FromResult(result); } + + /// <summary> + /// 涓嬪彂鏃朵繚瀛樻壒娆″伐鍗曚俊鎭� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction> SaveMesBatchWo(SaveWoBatchInput input) + { + var result = new ApiAction(); + try + { + //淇濆瓨鍓嶇殑鍒ゆ柇,骞剁敓鎴愭壒娆″彿 + var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).FirstAsync(); + //if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Init) + //{ + // result.IsSuccessed = false; + // result.LocaleMsg = new($"宸ュ崟涓嶆槸鍒濆鍖栫姸鎬侊紝涓嶈兘涓嬪彂锛�"); + // return result; + //} + if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Working) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟涓嶆槸鍒濆鍖栫姸鎬侊紝涓嶈兘涓嬪彂锛�"); + return result; + } + var batchs = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).ToListAsync(); + if (batchs.Count > 0 && batchs.Sum(x => x.PLAN_QTY) + input.WoBatch.PLAN_QTY > _wo.PLAN_QTY) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟涓嬪彂鐨勬暟閲忚秴杩囧伐鍗曡鍒掓暟閲忥紝涓嶈兘涓嬪彂锛�"); + return result; + } + var _batchWos = await Biz.Db.Queryable<V_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WoBatch.ORDER_NO).ToListAsync(); + if (_batchWos.Count > 0) + { + input.WoBatch.BATCH_NO = $"{input.WoBatch.ORDER_NO}-{(_batchWos.Max(x => x.BATCH) + 1).ToString("D2")}"; + } + else + { + input.WoBatch.BATCH_NO = $"{input.WoBatch.ORDER_NO}-01"; + } + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(input.Wo) + .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW }) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); + + db.Insertable(input.WoBatch).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"淇濆瓨鎵规宸ュ崟寮傚父"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨鎵规宸ュ崟寮傚父"); + } + return result; + } + + /// <summary> + /// 鏇存柊宸ュ崟鐘舵�� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + /// <exception cref="NotImplementedException"></exception> + public async Task<ApiAction> UpdateWoStatus(BizMesWoInput input) + { + var result = new ApiAction(); + try + { + //淇濆瓨鍓嶇殑鍒ゆ柇,骞剁敓鎴愭壒娆″彿 + var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.WorkOrder).FirstAsync(); + if (_wo != null) + { + _wo.STATUS = input.Status < 0 ? _wo.STATUS : input.Status; + _wo.ROUTE_STATUS = input.RouteStatus; + } + else + { + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟[{input.WorkOrder}]涓嶅瓨鍦�"); + return result; + } + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + db.Updateable(_wo, input.UserId).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"鏇存柊宸ュ崟鐘舵�佸紓甯�"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "鏇存柊宸ュ崟鐘舵�佸紓甯�"); + } + return result; + } } } -- Gitblit v1.9.3