From e3d688658d09fa63a11846bdd30c6de4a83958e5 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 07 三月 2023 07:50:53 +0800
Subject: [PATCH] MES报废补单接口

---
 VueWebApi/Controllers/ProductionManagementController.cs |   27 +++++++++++++
 .vs/VueWebApi/v16/.suo                                  |    0 
 VueWebApi/DLL/BLL/ProductionManagementBLL.cs            |    7 +++
 VueWebApi/DLL/DAL/ProductionManagementDAL.cs            |   77 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 0 deletions(-)

diff --git a/.vs/VueWebApi/v16/.suo b/.vs/VueWebApi/v16/.suo
index 5de457b..1475998 100644
--- a/.vs/VueWebApi/v16/.suo
+++ b/.vs/VueWebApi/v16/.suo
Binary files differ
diff --git a/VueWebApi/Controllers/ProductionManagementController.cs b/VueWebApi/Controllers/ProductionManagementController.cs
index 76eb730..5473ebd 100644
--- a/VueWebApi/Controllers/ProductionManagementController.cs
+++ b/VueWebApi/Controllers/ProductionManagementController.cs
@@ -143,6 +143,33 @@
         }
         #endregion
 
+        #region[MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ]
+        /// <summary>
+        /// MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ
+        /// </summary>
+        /// <param name="mesordercode">宸ュ崟缂栧彿</param>
+        /// <param name="sourceorder">婧愬崟鍗曞彿</param>
+        /// <param name="partcode">浜у搧缂栫爜</param>
+        /// <param name="partname">浜у搧鍚嶇О</param>
+        /// <param name="partspec">浜у搧瑙勬牸</param>
+        /// <param name="creatuser">鍒涘缓浜哄憳</param>
+        /// <param name="createdate">鍒涘缓鏃堕棿</param>
+        /// <param name="page">椤电爜</param>
+        /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+        /// <param name="prop">鎺掑簭瀛楁</param>
+        /// <param name="order">鎺掑簭瑙勫垯</param>
+        /// <returns></returns>
+        [Route(template: "MesBadOrderSearch")]
+        [HttpGet]
+        public HttpResponseMessage MesBadOrderSearch(int page, int rows, string prop, string order, string mesordercode = null, string sourceorder = null, string partcode = null, string partname = null, string partspec = null, string creatuser = null, string createdate = null)
+        {
+            int startNum = rows * (page - 1) + 1;  //璧峰璁板綍rowNum
+            int endNum = rows * page;   //缁撴潫璁板綍 rowNum
+            mes = ProductionManagementBLL.MesBadOrderSearch(mesordercode, sourceorder, partcode, partname, partspec, startNum, creatuser, createdate, endNum, prop, order);
+            return TJson.toJson(mes);
+        }
+        #endregion
+
         #region[浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛]
         /// <summary>
         /// 浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛
diff --git a/VueWebApi/DLL/BLL/ProductionManagementBLL.cs b/VueWebApi/DLL/BLL/ProductionManagementBLL.cs
index 450ef86..db9e473 100644
--- a/VueWebApi/DLL/BLL/ProductionManagementBLL.cs
+++ b/VueWebApi/DLL/BLL/ProductionManagementBLL.cs
@@ -41,6 +41,13 @@
         }
         #endregion
 
+        #region[MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ]
+        public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+        {
+            return ProductionManagementDAL.MesBadOrderSearch(mesordercode, sourceorder, partcode, partname, partspec, startNum, creatuser, createdate, endNum, prop, order);
+        }
+        #endregion
+
         #region[浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛]
         public static ToMessage PartSelectRoute(string partcode)
         {
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index be3521a..a127401 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -391,6 +391,83 @@
         }
         #endregion
 
+        #region[MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ]
+        public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+        {
+            var dynamicParams = new DynamicParameters();
+            string search = "";
+            try
+            {
+                if (mesordercode != "" && mesordercode != null)
+                {
+                    search += "and A.wo_code like '%'+@mesordercode+'%' ";
+                    dynamicParams.Add("@mesordercode", mesordercode);
+                }
+                if (sourceorder != "" && sourceorder != null)
+                {
+                    search += "and A.m_po like '%'+@sourceorder+'%' ";
+                    dynamicParams.Add("@sourceorder", sourceorder);
+                }
+                if (partcode != "" && partcode != null)
+                {
+                    search += "and A.materiel_code like '%'+@partcode+'%' ";
+                    dynamicParams.Add("@partcode", partcode);
+                }
+                if (partname != "" && partname != null)
+                {
+                    search += "and B.partname like '%'+@partname+'%' ";
+                    dynamicParams.Add("@partname", partname);
+                }
+                if (partspec != "" && partspec != null)
+                {
+                    search += "and B.partspec like '%'+@partspec+'%' ";
+                    dynamicParams.Add("@partspec", partspec);
+                }
+                if (createdate != "" && createdate != null)
+                {
+                    search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate ";
+                    dynamicParams.Add("@createdate", createdate);
+                }
+                if (creatuser != "" && creatuser != null)
+                {
+                    search += "and U.username like '%'+@creatuser+'%' ";
+                    dynamicParams.Add("@creatuser", creatuser);
+                }
+
+                if (search == "")
+                {
+                    search = "and 1=1 ";
+                }
+                // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+                var total = 0; //鎬绘潯鏁�
+                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name,
+                            A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date,S.bad_qty
+                            from TK_Wrk_Man A
+                            left join (select wo_code,sum(bad_qty) as bad_qty from  TK_Wrk_Step where bad_qty>0 group by wo_code) S on A.wo_code=S.wo_code
+                            left join TMateriel_Info B on A.materiel_code=B.partcode
+                            left join TOrganization C on A.wkshp_code=C.org_code
+                            left join T_Sec_Stck D on A.stck_code=D.code 
+                            left join TFlw_Rout E on A.route_code=E.code
+                            left join T_Sec_Stck F on A.stck_code=F.code 
+                            left join TUser U on A.lm_user=U.usercode 
+                            where A.is_delete<>'1'  and A.status='START' and A.wotype='PO' and S.bad_qty>0 " + search;
+                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.count = total;
+                mes.data = data.ToList();
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛]
         public static ToMessage PartSelectRoute(string partcode)
         {

--
Gitblit v1.9.3