From bed76502512bd0a7f39cfa7024b238d822746e67 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 27 九月 2024 01:30:19 +0800
Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024

---
 Tiger.Business.MES/BIZ/BIZ_MES_WO.cs |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
index 9578dce..517c4f6 100644
--- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
+++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -127,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>()}]锛屼笉鑳戒笅鍙戯紒");
@@ -228,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);
                     }
                 }
@@ -242,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)
                 {
@@ -274,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(() =>
                 {
@@ -283,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)
                 {
@@ -294,7 +307,7 @@
             {
                 result.CatchExceptionWithLog(ex, "鏇存柊宸ュ崟妯℃澘鍙橀噺寮傚父");
             }
-            return await Task.FromResult(result);
+            return result;
         }
 
         /// <summary>
@@ -314,13 +327,20 @@
                     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(input.LabelId)).ToListAsync();
-                var queryable = Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => q.WORK_ORDER.Equals(input.WorkOrder) && q.LABEL_ID.Equals(input.LabelId));
+                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);
+                    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;
                 }
                 //濡傛灉鍒濆鍙橀噺鏁板ぇ浜庡伐鍗曡缃殑鍙橀噺鏁�

--
Gitblit v1.9.3