From 6b8782c6810660751b40d284d40ea7a13656c5b7 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 05 九月 2022 20:04:13 +0800
Subject: [PATCH] 设备点检记录功能、大岛车间综合看板接口变更、工单批量关闭查询,提交

---
 VueWebApi/DLL/DAL/ProductionManagementDAL.cs |  139 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 136 insertions(+), 3 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index 848865f..d0b5955 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -700,7 +700,7 @@
         #endregion
 
         #region[MES宸ュ崟鍏抽棴]
-        public static ToMessage ClosedMesOrder(string wocode, string m_po)
+        public static ToMessage ClosedMesOrder(string username,string wocode, string m_po)
         {
             var sql = "";
             List<object> list = new List<object>();
@@ -711,8 +711,8 @@
                 sql = @"update TK_Wrk_Step set status='CLOSED'  where wo_code=@wocode";
                 list.Add(new { str = sql, parm = new { wocode = wocode } });
                 //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
-                sql = @"update TK_Wrk_Man set status='CLOSED'  where wo_code=@wocode";
-                list.Add(new { str = sql, parm = new { wocode = wocode } });
+                sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate  where wo_code=@wocode";
+                list.Add(new { str = sql, parm = new { wocode = wocode, username = username, closedate=DateTime.Now.ToString() } });
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
                 {
@@ -2342,5 +2342,138 @@
         }
         #endregion
 
+
+        #region[MES宸ュ崟鎵归噺鍏抽棴鏌ヨ]
+        public static ToMessage MesOrderBitchClosedSearch(string mesorderstus, string mesordercode, string sourceorder, string ordertype, 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 (mesorderstus != "" && mesorderstus != null)
+                {
+                    search += "and A.status=@mesorderstus ";
+                    dynamicParams.Add("@mesorderstus", mesorderstus);
+                }
+                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 (ordertype != "" && ordertype != null)
+                {
+                    search += "and A.wotype like '%'+@ordertype+'%' ";
+                    dynamicParams.Add("@ordertype", ordertype);
+                }
+                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
+                            ,(select sum(S.good_qty)  from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as good_qty
+                            ,(select sum(S.ng_qty)  from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as ng_qty
+                            ,(select sum(S.bad_qty)  from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as bad_qty
+                            from TK_Wrk_Man A
+                            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' " + 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[MES宸ュ崟鎵归噺鍏抽棴鎻愪氦]
+        public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+                    sql = @"update TK_Wrk_Step set status='CLOSED'  where wo_code=@wocode";
+                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
+                    //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+                    sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate  where wo_code=@wocode";
+                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } });
+                }
+                bool aa = DapperHelper.DoTransaction(list);
+                if (aa)
+                {
+                    mes.code = "200";
+                    mes.count = 0;
+                    mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+                    mes.data = null;
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3