From 1f1daf8fd3b6fd0759d17facc0ad97562e516a3a Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期二, 10 九月 2024 17:38:13 +0800
Subject: [PATCH] 包装规则保存

---
 Tiger.Business/MES/Biz.Route.cs                                       |   14 +++++--
 Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs |   15 +++++++
 Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs                                |   61 ++++++++++++++++++++++++++++++
 Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs                                |   17 ++++++++
 Tiger.Model.Net/Tiger.Model.Net.csproj                                |    1 
 Tiger.Business.MES/Common/DoUnPack.cs                                 |   10 ++++-
 6 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs b/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs
new file mode 100644
index 0000000..8bf6faf
--- /dev/null
+++ b/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs
@@ -0,0 +1,61 @@
+锘縰sing Tiger.Model;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using Rhea.Common;
+using System.Net;
+using System.Linq;
+using Newtonsoft.Json;
+using Tiger.IBusiness;
+using Microsoft.AspNetCore.Http;
+using Tiger.Model.Entitys.MES.BizMesWoBatch;
+using Tiger.Model.Entitys.MES.BizMesWo;
+using Tiger.Model.Entitys.MES.BizBasPkgRule;
+
+namespace Tiger.Business.MES
+{
+    public partial class BizBasPkgRule : IBasPkgRule
+    {
+        /// <summary>
+        /// 淇濆瓨鍖呰瑙勫垯锛屽寘鎷槑缁嗗拰閲嶉噺鑼冨洿
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public async Task<ApiAction> SaveBasPkgRule(BizBasPkgRuleInput input)
+        {
+            var result = new ApiAction();
+            try
+            {
+                //var _wo = Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == wo.ORDER_NO).First();
+                //if (_wo != null && _wo.STATUS != (int)BIZ_MES_WO.STATUSs.Init)
+                //{
+                //    result.IsSuccessed = false;
+                //    result.LocaleMsg = new($"宸ュ崟宸茬粡瀛樺湪涓斾笉鏄垵濮嬪寲鐘舵�侊紝涓嶈兘淇濆瓨淇敼锛�");
+                //    return result;
+                //}
+                var db = Biz.Db;
+                var dbTran = db.UseTran(() =>
+                {
+                    //var y = db.Storageable(wo)
+                    //   .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW })
+                    //   .ToStorage();
+                    //y.AsInsertable.ExecuteCommand();
+                    //y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                });
+                if (!dbTran.IsSuccess)
+                {
+                    result.IsSuccessed = false;
+                    result.Message = $"淇濆瓨鍖呰瑙勫垯寮傚父";
+                }
+            }
+            catch (Exception ex)
+            {
+                result.CatchExceptionWithLog(ex, "淇濆瓨鍖呰瑙勫垯寮傚父");
+            }
+            return await Task.FromResult(result);
+        }
+    }
+}
diff --git a/Tiger.Business.MES/Common/DoUnPack.cs b/Tiger.Business.MES/Common/DoUnPack.cs
index 2019812..04680d7 100644
--- a/Tiger.Business.MES/Common/DoUnPack.cs
+++ b/Tiger.Business.MES/Common/DoUnPack.cs
@@ -25,12 +25,18 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-       public async Task<ApiAction<List<MES_WIP_PKG>>> Submit(DoUnPackInput input)
+        public async Task<ApiAction<List<MES_WIP_PKG>>> Submit(DoUnPackInput input)
         {
             var result = new ApiAction<List<MES_WIP_PKG>>();
             try
             {
                 var wipPkg = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == input.SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync();
+                if (wipPkg == null)
+                {
+                    result.IsSuccessed = false;
+                    result.LocaleMsg = new($"鏉$爜涓嶅瓨鍦ㄥ寘瑁呬腑");
+                    return result;
+                }
                 var wipPkgParent = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == wipPkg.PARENT_SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync();
                 var db = Biz.Db;
                 var dbTran = db.UseTran(() =>
@@ -45,7 +51,7 @@
                 if (!dbTran.IsSuccess)
                 {
                     result.IsSuccessed = false;
-                    result.Message = $"鎷嗚В鍖呰寮傚父";
+                    result.LocaleMsg = new($"鎷嗚В鍖呰寮傚父");
                 }
                 result.Data = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.PARENT_SN == wipPkgParent.SN).ToList();
             }
diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs
index 38f5200..771a429 100644
--- a/Tiger.Business/MES/Biz.Route.cs
+++ b/Tiger.Business/MES/Biz.Route.cs
@@ -273,20 +273,26 @@
                 try
                 {
                     var _route = Db.Queryable<MES_ROUTE>().Where(x => x.ROT_CODE == route.ROT_CODE).First();
-                    if (_route != null && Db.Queryable<MES_ROUTE_NODE>().Where(x => x.ROT_ID == _route.ID).Any())
+                    //if (_route != null && Db.Queryable<MES_ROUTE_NODE>().Where(x => x.ROT_ID == _route.ID).Any())
+                    //{
+                    //    result.IsSuccessed = false;
+                    //    result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夎璁¤褰曪紝涓嶈兘淇濆瓨锛�");
+                    //    return result;
+                    //}
+                    if (_route != null && Db.Queryable<MES_PROD_OPER>().Where(x => x.ROT_ID == _route.ID).Any())
                     {
                         result.IsSuccessed = false;
-                        result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夎璁¤褰曪紝涓嶈兘淇濆瓨锛�");
+                        result.LocaleMsg = new($"宸ヨ壓璺嚎宸茬粡鏈夌粦瀹氳褰曪紝涓嶈兘淇濆瓨锛�");
                         return result;
                     }
                     var db = Db;
                     var dbTran = db.UseTran(() =>
                     {
                         var y = db.Storageable(route)
-                           .WhereColumns(t => new { t.ROT_CODE, t.GHOST_ROW })
+                           //.WhereColumns(t => new { t.ROT_CODE, t.GHOST_ROW })
                            .ToStorage();
                         y.AsInsertable.ExecuteCommand();
-                        y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                        y.AsUpdateable.ExecuteCommand();
                     });
                     if (!dbTran.IsSuccess)
                     {
diff --git a/Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs b/Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs
new file mode 100644
index 0000000..a410cc9
--- /dev/null
+++ b/Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs
@@ -0,0 +1,17 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tiger.Model;
+using Tiger.Model.Entitys.MES.BizBasPkgRule;
+
+namespace Tiger.IBusiness
+{
+    public interface IBasPkgRule
+    {
+        public Task<ApiAction> SaveBasPkgRule(BizBasPkgRuleInput input);
+    }
+}
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs
new file mode 100644
index 0000000..3ee3329
--- /dev/null
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tiger.Model.Entitys.MES.BizBasPkgRule
+{
+    public class BizBasPkgRuleInput
+    {
+        public BAS_PKG_RULE PkgRule { get; set; }
+        public BAS_PKG_DTL PkgDtl { get; set; }
+        public BAS_PKG_PROD PkgProd { get; set; }
+    }
+}
diff --git a/Tiger.Model.Net/Tiger.Model.Net.csproj b/Tiger.Model.Net/Tiger.Model.Net.csproj
index 3cc8b8d..64dfdf8 100644
--- a/Tiger.Model.Net/Tiger.Model.Net.csproj
+++ b/Tiger.Model.Net/Tiger.Model.Net.csproj
@@ -157,6 +157,7 @@
     <Compile Include="Entitys\MES\MES_WO_OPER.cs" />
     <Compile Include="Entitys\MES\node.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\BizMesWoBatchParameter.cs" />
+    <Compile Include="Entitys\MES\ParameterEntity\BizBasPkgRuleParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\DoUnPackParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\CodeVerificationParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\BizMesWoParameter.cs" />

--
Gitblit v1.9.3