From 053f992298073d2b0dcbeca564451fa6d1b36ea0 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期五, 27 九月 2024 16:02:56 +0800 Subject: [PATCH] GetHuaWeiWeek再更新 --- Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs index dfdfed4..517c4f6 100644 --- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs @@ -14,6 +14,8 @@ using Tiger.Model.Entitys.MES.BizMesWoBatch; using Tiger.Model.Entitys.MES.BizMesWo; using Tiger.Model.Entitys.MES.Position; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Drawing.Printing; namespace Tiger.Business.MES { @@ -125,7 +127,7 @@ result.LocaleMsg = new($"宸ュ崟涓嬪彂鐨勬暟閲忚秴杩囧伐鍗曡鍒掓暟閲忥紝涓嶈兘涓嬪彂锛�"); return result; } - if (Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS> BIZ_MES_WO.STATUSs.Imported.GetValue() && x.STATUS< BIZ_MES_WO.STATUSs.Closed.GetValue())) + if (Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS > BIZ_MES_WO.STATUSs.Imported.GetValue() && x.STATUS < BIZ_MES_WO.STATUSs.Closed.GetValue())) { result.IsSuccessed = false; result.LocaleMsg = new($"宸ュ崟鎵规鍦ㄧ嚎浣揫{input.WoBatch.ACT_LINE}]涓姸鎬佷负[{input.WoBatch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}]锛屼笉鑳戒笅鍙戯紒"); @@ -226,7 +228,8 @@ if (_woBatch != null) { _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status; - if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) { + if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) + { WoContext.RemoveBatch(input.WoBatch); } } @@ -240,7 +243,7 @@ var db = Biz.Db; var dbTran = db.UseTran(() => { - db.Updateable(_woBatch, input.UserId).UpdateColumns(x=> new { x.STATUS}).ExecuteCommand(); + db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand(); }); if (!dbTran.IsSuccess) { @@ -272,7 +275,14 @@ result.LocaleMsg = new($"宸ュ崟鍙蜂笉鑳戒负绌猴紒"); return result; } - + List<BAS_LABEL_VAR_WO> varWoList = new(); + if (File.Exists(input.LABEL_VIEW_PATH)) + { + string imageFileName = Path.GetFileNameWithoutExtension(input.LABEL_VIEW_PATH); + string? path = Path.GetDirectoryName(input.LABEL_VIEW_PATH); + input.LABEL_VIEW_PATH = $"{path}//Temp//{imageFileName}.png"; + varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == input.LABEL_ID && x.WORK_ORDER == input.WORK_ORDER).ToListAsync(); + } var db = Biz.Db; var dbTran = db.UseTran(() => { @@ -281,6 +291,11 @@ .ToStorage(); y.AsInsertable.ExecuteCommand(); y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); + + if (varWoList.Count > 0) + { + db.Updateable(varWoList).UpdateColumns(q => q.LABEL_VIEW_PATH).ExecuteCommand(); + } }); if (!dbTran.IsSuccess) { @@ -292,7 +307,7 @@ { result.CatchExceptionWithLog(ex, "鏇存柊宸ュ崟妯℃澘鍙橀噺寮傚父"); } - return await Task.FromResult(result); + return result; } /// <summary> @@ -312,13 +327,37 @@ result.LocaleMsg = new($"宸ュ崟鍙蜂笉鑳戒负绌猴紒"); return result; } - query.page = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q=>q.WORK_ORDER.Equals(input.WorkOrder) && q.LABEL_ID.Equals(input.LabelId)).ToPageAsync(input.pageIndex, input.pageSize); - query.Items = query.page.data; + var labeltemp = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE.Equals(input.LabelId) || q.ID.Equals(input.LabelId)).First(); + if (labeltemp == null) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"妯℃澘涓嶅瓨鍦紒"); + return result; + } + var lableVars = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) && q.LABEL_ID.Equals(labeltemp.ID)).ToListAsync(); + var queryable = Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => q.WORK_ORDER.Equals(input.WorkOrder) && q.LABEL_ID.Equals(labeltemp.ID)); + query.page = await queryable.ToPageAsync(input.pageIndex, input.pageSize); //濡傛灉涓嶅瓨鍦紝鍒欒繑鍥炲垵濮嬫暟鎹� - if (query.page.totals == 0) { - query.page = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) && q.LABEL_ID.Equals(input.LabelId)).ToPageAsync(input.pageIndex, input.pageSize); + if (query.page.totals == 0) + { + query.page = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) && q.LABEL_ID.Equals(labeltemp.ID)).ToPageAsync(input.pageIndex, input.pageSize); query.Items = query.page.data; } + //濡傛灉鍒濆鍙橀噺鏁板ぇ浜庡伐鍗曡缃殑鍙橀噺鏁� + if (lableVars.Count > query.page.totals) + { + foreach (var item in lableVars) + { + if (queryable.ToList().Any(q => q.VAR_NAME == item.VAR_NAME)) + { + item.WORK_ORDER = input.WorkOrder; + item.VAR_VALUE = queryable.ToList().Where(q => q.VAR_NAME == item.VAR_NAME).First()?.VAR_VALUE; + } + } + query.Items = lableVars.Skip((input.pageIndex - 1) * input.pageSize).Take(input.pageSize).ToList(); + query.page.totals = lableVars.Count; + query.page.data = query.Items; + } result.Data = query; } catch (Exception ex) -- Gitblit v1.9.3