From 47f5a9401f1e83efeca8b6a5cd28e1da805811f9 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 18 六月 2024 17:36:23 +0800
Subject: [PATCH] 1.设置文件上传大小 2.工艺SOP查看接口 3.工单SOP查看接口

---
 VueWebCoreApi/Program.cs                         |    9 +++
 VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs            |   14 ++++
 VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs            |   85 ++++++++++++++++++++++++++++
 VueWebCoreApi/Startup.cs                         |   28 +++++++--
 VueWebCoreApi/Controllers/WorkOrderController.cs |   35 +++++++++++
 5 files changed, 165 insertions(+), 6 deletions(-)

diff --git a/VueWebCoreApi/Controllers/WorkOrderController.cs b/VueWebCoreApi/Controllers/WorkOrderController.cs
index 4c324f5..add5868 100644
--- a/VueWebCoreApi/Controllers/WorkOrderController.cs
+++ b/VueWebCoreApi/Controllers/WorkOrderController.cs
@@ -305,6 +305,41 @@
         }
         #endregion
 
+        #region[MES宸ュ崟鏌ョ湅宸ュ崟SOP]
+        /// <summary>
+        /// MES宸ュ崟鏌ョ湅宸ュ崟SOP
+        /// </summary>
+        /// <param name="wocode">宸ュ崟缂栧彿</param>
+        /// <param name="materielcode">浜у搧缂栫爜</param>
+        /// <returns></returns>
+        [Route(template: "MesOrderSopSearch")]
+        [HttpGet]
+        public JsonResult MesOrderSopSearch(string wocode, string materielcode)
+        {
+            mes = WorkOrderBLL.MesOrderSopSearch(wocode, materielcode);
+            return Json(mes);
+        }
+        #endregion
+
+        #region[MES宸ュ崟鏌ョ湅宸ヨ壓SOP]
+        /// <summary>
+        /// MES宸ュ崟鏌ョ湅宸ヨ壓SOP
+        /// </summary>
+        /// <param name="materielcode">浜у搧缂栫爜</param>
+        /// <param name="routecode">宸ヨ壓璺嚎缂栫爜</param>
+        /// <param name="stepcode">宸ュ簭缂栫爜</param>
+        /// <returns></returns>
+        [Route(template: "MesOrderProcessSopSearch")]
+        [HttpGet]
+        public JsonResult MesOrderProcessSopSearch(string materielcode,string routecode,string stepcode)
+        {
+            var token = HttpContext.Request.Headers["Token"].ToString();
+            User us = JwtTools.Denocode(token.ToString());
+            mes = WorkOrderBLL.MesOrderProcessSopSearch(materielcode, routecode, stepcode,us);
+            return Json(mes);
+        }
+        #endregion
+
 
         #region[MES宸ュ崟娲惧彂鎻愪氦]
         /// <summary>
diff --git a/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs b/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
index 3b2c104..6820ea0 100644
--- a/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
+++ b/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
@@ -102,6 +102,20 @@
         }
         #endregion
 
+        #region[MES宸ュ崟鏌ョ湅宸ュ崟SOP]
+        public static ToMessage MesOrderSopSearch(string wocode, string materielcode)
+        {
+            return WorkOrderDAL.MesOrderSopSearch(wocode, materielcode);
+        }
+        #endregion
+
+        #region[MES宸ュ崟鏌ョ湅宸ヨ壓SOP]
+        public static ToMessage MesOrderProcessSopSearch(string materielcode, string routecode, string stepcode, User us)
+        {
+            return WorkOrderDAL.MesOrderProcessSopSearch(materielcode, routecode, stepcode,us);
+        }
+        #endregion
+
 
         #region[MES宸ュ崟娲惧彂鎻愪氦]
         public static ToMessage MesOrderDistribution(string[] wocodelist, User us)
diff --git a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
index 82a768b..9d4975e 100644
--- a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
@@ -1198,6 +1198,91 @@
         }
         #endregion
 
+        #region[MES宸ュ崟鏌ョ湅宸ュ崟SOP]
+        public static ToMessage MesOrderSopSearch(string wocode, string materielcode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //鑾峰彇SOP鏂囦欢淇℃伅
+                sql = @"select filename,filepath,version from TWrkOrderSop
+                        where wo=@wocode and materielcode=@materielcode
+                        order by version";
+                dynamicParams.Add("@wocode", wocode);
+                dynamicParams.Add("@materielcode", materielcode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.message = "鏌ヨ鎴愬姛!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.message = "褰撳墠宸ュ崟浜у搧鏆傛棤SOP鏂囦欢!";
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
+        #region[MES宸ュ崟鏌ョ湅宸ヨ壓SOP]
+        public static ToMessage MesOrderProcessSopSearch(string materielcode, string routecode, string stepcode, User us)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                dynamic dynObj = JObject.Parse(us.mesSetting);
+                bool route = dynObj.route;
+                if (route) //宸ヨ壓璺嚎鐗�
+                {
+                    //鑾峰彇SOP鏂囦欢淇℃伅
+                    sql = @"select filename,filepath,version from TProcessSop
+                        where  materielcode=@materielcode and routecode=@routecode and stepcode=@stepcode
+                        order by version";
+                    dynamicParams.Add("@materielcode", materielcode);
+                    dynamicParams.Add("@routecode", routecode);
+                    dynamicParams.Add("@stepcode", stepcode);
+                }
+                else
+                {
+                    //鑾峰彇SOP鏂囦欢淇℃伅
+                    sql = @"select filename,filepath,version from TProcessSop
+                        where  materielcode=@materielcode and stepcode=@stepcode
+                        order by version";
+                    dynamicParams.Add("@materielcode", materielcode);
+                    dynamicParams.Add("@stepcode", stepcode);
+                }
+
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                mes.code = "200";
+                mes.count = data.Rows.Count;
+                mes.data = data;
+                mes.message = "鏌ヨ鎴愬姛!";
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
 
         #region[MES宸ュ崟娲惧彂鎻愪氦]
         public static ToMessage MesOrderDistribution(string[] wocodelist, User us)
diff --git a/VueWebCoreApi/Program.cs b/VueWebCoreApi/Program.cs
index 947ca45..2b3a0ae 100644
--- a/VueWebCoreApi/Program.cs
+++ b/VueWebCoreApi/Program.cs
@@ -20,6 +20,15 @@
             Host.CreateDefaultBuilder(args)
                 .ConfigureWebHostDefaults(webBuilder =>
                 {
+                    //设置Kestrel文件上传大小
+                    webBuilder.ConfigureKestrel((context, options) =>
+                    {
+                        // 获取或设置任何请求正文的最大允许大小(以字节为单位)。 设置为 null 时,最大请求正文大小不受限制
+                        // 默认为 30000000 字节 大约为 28.6MB
+
+                        options.Limits.MaxRequestBodySize = 1073741824; //限制1G 
+                        //options.Limits.MaxRequestBodySize = null; //表示不限制 
+                    });
                     webBuilder.UseStartup<Startup>();
                 });
     }
diff --git a/VueWebCoreApi/Startup.cs b/VueWebCoreApi/Startup.cs
index 00f51e1..863b384 100644
--- a/VueWebCoreApi/Startup.cs
+++ b/VueWebCoreApi/Startup.cs
@@ -7,9 +7,11 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http.Connections;
+using Microsoft.AspNetCore.Http.Features;
 using Microsoft.AspNetCore.HttpsPolicy;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Authorization;
+using Microsoft.AspNetCore.Server.Kestrel.Core;
 using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
@@ -80,7 +82,6 @@
                 string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
                 string xmlPath = Path.Combine(basePath, "VueWebCoreApi.xml");
                 c.IncludeXmlComments(xmlPath, true);
-               
             });
             #endregion
 
@@ -123,6 +124,19 @@
             //设置Cookies
             services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
 
+            #region 允许大文件上传
+            //允许上传大文件
+            services.Configure<IISServerOptions>(options =>
+            {
+                options.MaxRequestBodySize = 1073741824;//此处限制最大1G  
+            });
+            //解决文件上传Multipart body length limit 134217728 exceeded.
+            services.Configure<FormOptions>(x =>
+            {
+                x.ValueLengthLimit = int.MaxValue;
+                x.MultipartBodyLengthLimit = 1073741824; //此处限制最大1G  
+            });
+            #endregion 允许大文件上传
         }
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
         public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLeftTime, ILoggerFactory loggerFactory)
@@ -158,13 +172,15 @@
             //添加静态文件中间件
             app.UseDefaultFiles();
             //添加授权文件
-            app.UseStaticFiles(new StaticFileOptions() { 
-                ContentTypeProvider = new FileExtensionContentTypeProvider() { 
+            app.UseStaticFiles(new StaticFileOptions()
+            {
+                ContentTypeProvider = new FileExtensionContentTypeProvider()
+                {
                     Mappings = {
-                        [".xls"] = "application/vnd.ms-excel", 
+                        [".xls"] = "application/vnd.ms-excel",
                         [".apk"] = "application/vnd.android.package-archive"
-                    } 
-                } 
+                    }
+                }
             });
             app.UseStaticFiles();
             //跨域

--
Gitblit v1.9.3