From 925394b1b7f61a2c2a15fdaa0ecd0763214ccda1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 30 五月 2023 18:01:29 +0800
Subject: [PATCH] 增加App报工、工序检验功能

---
 VueWebApi/DLL/DAL/ReportManagerDAL.cs |  300 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 269 insertions(+), 31 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ReportManagerDAL.cs b/VueWebApi/DLL/DAL/ReportManagerDAL.cs
index dfbf278..ca85f44 100644
--- a/VueWebApi/DLL/DAL/ReportManagerDAL.cs
+++ b/VueWebApi/DLL/DAL/ReportManagerDAL.cs
@@ -221,12 +221,17 @@
 
 
         #region[鐝粍宸ヨ祫鎶ヨ〃璁板綍鏌ヨ]
-        public static ToMessage GroupSalaryReportSearch(string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string username, string operopendate, string operclosedate, int startNum, int endNum, string prop, string order)
+        public static ToMessage GroupSalaryReportSearch(string compute, string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string username, string operopendate, string operclosedate, string rejectstepcode, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (compute == "last")  //鏈亾宸ュ簭
+                {
+                    search += "and P.isend=@isend ";
+                    dynamicParams.Add("@isend", "Y");
+                }
                 if (wocode != "" && wocode != null)
                 {
                     search += "and A.wo_code like '%'+@wocode+'%' ";
@@ -268,26 +273,31 @@
                     dynamicParams.Add("@operopendate", operopendate + " 00:00:00");
                     dynamicParams.Add("@operclosedate", operclosedate + " 23:59:59");
                 }
-
+                if (rejectstepcode != "" && rejectstepcode != null)
+                {
+                    string[] s1 = Array.ConvertAll<string, string>(rejectstepcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[] 
+                    search += "and A.step_code not in @s1";
+                    dynamicParams.Add("@s1", s1);
+                }
                 if (search == "")
                 {
                     search = "and 1=1 ";
                 }
-                search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+                //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select distinct A.id,A.wo_code,M.partcode,M.partname,M.partspec,T.stepcode,T.stepname,A.task_qty,G.group_code,G.group_name,A.good_qty,
                             isnull(S.unprice,0) as unprice,A.good_qty*isnull(S.unprice,0) as usermoney,U.username as lm_user,A.lm_date,B.report_date   
                             from TK_Wrk_Record A
                             inner join TK_Wrk_RecordSub B on A.id=B.m_id
-                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code and P.isend='Y'
+                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code 
                             left  join TK_Wrk_Man K on A.wo_code=K.wo_code
                             left  join TGroup G on B.usergroup_code=G.group_code
-                            left  join TPrteEqp_Stad S on A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code and K.wkshp_code=S.wkspcode
+                            left  join TWoPrteEqp_Stad S on A.wo_code=S.wo and A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code 
                             left  join TMateriel_Info M on A.materiel_code=M.partcode
                             left  join TStep T on A.step_code=T.stepcode
                             left  join TUser U on A.lm_user=U.usercode 
-                            where " + search;
+                            where G.group_code<>'' " + search;
                 var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
@@ -334,12 +344,17 @@
         #endregion
 
         #region[鐝粍宸ヨ祫鎶ヨ〃璁板綍瀵煎嚭]
-        public static ToMessage GroupSalaryReportExcelSearch(string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string username, string operopendate, string operclosedate)
+        public static ToMessage GroupSalaryReportExcelSearch(string compute, string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string username, string operopendate, string operclosedate, string rejectstepcode)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (compute == "last")  //鏈亾宸ュ簭
+                {
+                    search += "and P.isend=@isend ";
+                    dynamicParams.Add("@isend", "Y");
+                }
                 if (wocode != "" && wocode != null)
                 {
                     search += "and A.wo_code like '%'+@wocode+'%' ";
@@ -381,12 +396,17 @@
                     dynamicParams.Add("@operopendate", operopendate + " 00:00:00");
                     dynamicParams.Add("@operclosedate", operclosedate + " 23:59:59");
                 }
-
+                if (rejectstepcode != "" && rejectstepcode != null)
+                {
+                    string[] s1 = Array.ConvertAll<string, string>(rejectstepcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[] 
+                    search += "and A.step_code not in @s1";
+                    dynamicParams.Add("@s1", s1);
+                }
                 if (search == "")
                 {
                     search = "and 1=1 ";
                 }
-                search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+                //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select distinct A.wo_code as 宸ュ崟缂栧彿,M.partcode as 浜у搧缂栫爜,M.partname as 浜у搧鍚嶇О,M.partspec as 浜у搧瑙勬牸,
@@ -394,14 +414,14 @@
                             A.good_qty as 鎶ュ伐鏁伴噺,isnull(S.unprice,0) as 宸ュ簭鍗曚环,A.good_qty*isnull(S.unprice,0) as 璁′欢宸ヨ祫,U.username as 鎿嶄綔浜哄憳,A.lm_date as 鎿嶄綔鏃堕棿,B.report_date as 鎶ュ伐鏃堕棿 
                             from TK_Wrk_Record A
                             inner join TK_Wrk_RecordSub B on A.id=B.m_id
-                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code and P.isend='Y'
+                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code
                             left  join TK_Wrk_Man K on A.wo_code=K.wo_code
                             left  join TGroup G on B.usergroup_code=G.group_code
-                            left  join TPrteEqp_Stad S on A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code and K.wkshp_code=S.wkspcode
+                            left  join TWoPrteEqp_Stad S on A.wo_code=S.wo and A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code 
                             left  join TMateriel_Info M on A.materiel_code=M.partcode
                             left  join TStep T on A.step_code=T.stepcode
                             left  join TUser U on A.lm_user=U.usercode 
-                            where " + search;
+                            where G.group_code<>'' " + search;
                 DataTable data = DapperHelper.selectdata(sql, dynamicParams);
                 data.TableName = "Table"; //璁剧疆DataTable鐨勫悕绉�
                 string msg = DownLoad.DataTableToExcel(data, "鐝粍璁′欢宸ヨ祫鎶ヨ〃");
@@ -423,12 +443,17 @@
 
 
         #region[浜哄憳宸ヨ祫鏄庣粏鎶ヨ〃]
-        public static ToMessage PeopleSalaryReportSearch(string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string reportname, string reportopendate, string reportclosedate, int startNum, int endNum, string prop, string order)
+        public static ToMessage PeopleSalaryReportSearch(string compute, string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string reportname, string reportopendate, string reportclosedate, string rejectstepcode, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (compute == "last")  //鏈亾宸ュ簭
+                {
+                    search += "and AA.isend=@isend ";
+                    dynamicParams.Add("@isend", "Y");
+                }
                 if (wocode != "" && wocode != null)
                 {
                     search += "and AA.wo_code like '%'+@wocode+'%' ";
@@ -470,7 +495,12 @@
                     dynamicParams.Add("@reportopendate", reportopendate + " 00:00:00");
                     dynamicParams.Add("@reportclosedate", reportclosedate + " 23:59:59");
                 }
-
+                if (rejectstepcode != "" && rejectstepcode != null)
+                {
+                    string[] s1 = Array.ConvertAll<string, string>(rejectstepcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[] 
+                    search += "and AA.stepcode not in @s1";
+                    dynamicParams.Add("@s1", s1);
+                }
                 if (search == "")
                 {
                     search = "and 1=1 ";
@@ -479,19 +509,18 @@
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select AA.wo_code,AA.partcode,AA.partname,AA.partspec,AA.stepcode,AA.stepname,
-                            AA.task_qty,AA.group_code,AA.group_name,AA.report_qty,AA.unprice,
-                            AA.moneys/colum as usermoney,AA.username,AA.report_date,colum
+                            AA.task_qty,AA.group_code,AA.group_name,AA.report_qty,AA.unprice,AA.ratio,AA.isend,
+                            AA.moneys as usermoney,AA.username,AA.report_date
                             from (
                             select distinct A.wo_code,M.partcode,M.partname,M.partspec,T.stepcode,T.stepname,
-                            A.task_qty,G.group_code,G.group_name,B.report_qty,isnull(S.unprice,0) as unprice,
-                            B.report_qty*isnull(S.unprice,0) as moneys,U.username,B.report_date,
-                            (select distinct count(*)   from TK_Wrk_RecordSub S  where S.m_id=B.m_id) as colum
+                            A.task_qty,G.group_code,G.group_name,B.report_qty,isnull(S.unprice,0) as unprice,B.ratio,P.isend,
+                            (B.report_qty*isnull(S.unprice,0))*(B.ratio/100) as moneys,U.username,B.report_date
                             from TK_Wrk_Record A
                             inner join TK_Wrk_RecordSub B on A.id=B.m_id
-                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code and P.isend='Y'
+                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code 
                             left  join TK_Wrk_Man K on A.wo_code=K.wo_code
                             left  join TGroup G on B.usergroup_code=G.group_code
-                            left  join TPrteEqp_Stad S on A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code and K.wkshp_code=S.wkspcode
+                            left  join TWoPrteEqp_Stad S on A.wo_code=S.wo and A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code 
                             left  join TMateriel_Info M on A.materiel_code=M.partcode
                             left  join TStep T on A.step_code=T.stepcode
                             left  join TUser U on B.report_person=U.usercode
@@ -515,12 +544,17 @@
         #endregion
 
         #region[浜哄憳宸ヨ祫鏄庣粏鎶ヨ〃瀵煎嚭]
-        public static ToMessage PeopleSalaryReportExcelSearch(string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string reportname, string reportopendate, string reportclosedate)
+        public static ToMessage PeopleSalaryReportExcelSearch(string compute, string wocode, string partcode, string partname, string partspec, string stepname, string groupcode, string reportname, string reportopendate, string reportclosedate, string rejectstepcode)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (compute == "last")  //鏈亾宸ュ簭
+                {
+                    search += "and AA.isend=@isend ";
+                    dynamicParams.Add("@isend", "Y");
+                }
                 if (wocode != "" && wocode != null)
                 {
                     search += "and AA.wo_code like '%'+@wocode+'%' ";
@@ -562,7 +596,12 @@
                     dynamicParams.Add("@reportopendate", reportopendate + " 00:00:00");
                     dynamicParams.Add("@reportclosedate", reportclosedate + " 23:59:59");
                 }
-
+                if (rejectstepcode != "" && rejectstepcode != null)
+                {
+                    string[] s1 = Array.ConvertAll<string, string>(rejectstepcode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[] 
+                    search += "and AA.stepcode not in @s1";
+                    dynamicParams.Add("@s1", s1);
+                }
                 if (search == "")
                 {
                     search = "and 1=1 ";
@@ -570,20 +609,19 @@
                 search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select AA.wo_code as 宸ュ崟缂栧彿,AA.partcode as 浜у搧缂栫爜,AA.partname as 浜у搧鍚嶇О,AA.partspec as 浜у搧瑙勬牸,AA.stepcode as 宸ュ簭缂栫爜,AA.stepname as 宸ュ簭鍚嶇О,
-                            AA.task_qty as 浠诲姟鏁伴噺,AA.group_code as 鐢熶骇鐝粍缂栫爜,AA.group_name as 鐢熶骇鐝粍鍚嶇О,AA.report_qty as 鎶ュ伐鏁伴噺,AA.unprice as 宸ュ簭鍗曚环,
-                            AA.moneys/colum as 璁′欢宸ヨ祫,AA.username as 鎶ュ伐浜哄憳,AA.report_date as 鎶ュ伐鏃堕棿,colum as 鐝粍鎶ュ伐浜烘暟
+                var sql = @"select AA.wo_code as 宸ュ崟缂栧彿,AA.partcode as 浜у搧缂栫爜,AA.partname as 浜у搧鍚嶇О,AA.partspec as 浜у搧瑙勬牸,AA.stepcode as 宸ュ簭缂栫爜,AA.stepname as 宸ュ簭鍚嶇О,AA.isend as 鏄惁鏈亾宸ュ簭,
+                            AA.task_qty as 浠诲姟鏁伴噺,AA.group_code as 鐢熶骇鐝粍缂栫爜,AA.group_name as 鐢熶骇鐝粍鍚嶇О,AA.report_qty as 鎶ュ伐鏁伴噺,AA.unprice as 宸ュ簭鍗曚环,AA.ratio as 鍒嗛厤姣斾緥,
+                            AA.moneys as 璁′欢宸ヨ祫,AA.username as 鎶ュ伐浜哄憳,AA.report_date as 鎶ュ伐鏃堕棿
                             from (
                             select distinct A.wo_code,M.partcode,M.partname,M.partspec,T.stepcode,T.stepname,
-                            A.task_qty,G.group_code,G.group_name,B.report_qty,isnull(S.unprice,0) as unprice,
-                            B.report_qty*isnull(S.unprice,0) as moneys,U.username,B.report_date,
-                            (select distinct count(*)   from TK_Wrk_RecordSub S  where S.m_id=B.m_id) as colum
+                            A.task_qty,G.group_code,G.group_name,B.report_qty,isnull(S.unprice,0) as unprice,B.ratio,P.isend,
+                            (B.report_qty*isnull(S.unprice,0))*(B.ratio/100) as moneys,U.username,B.report_date
                             from TK_Wrk_Record A
                             inner join TK_Wrk_RecordSub B on A.id=B.m_id
-                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code and P.isend='Y'
+                            inner join TK_Wrk_Step P on A.wo_code=P.wo_code and A.step_code=P.step_code 
                             left  join TK_Wrk_Man K on A.wo_code=K.wo_code
                             left  join TGroup G on B.usergroup_code=G.group_code
-                            left  join TPrteEqp_Stad S on A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code and K.wkshp_code=S.wkspcode
+                            left  join TWoPrteEqp_Stad S on A.wo_code=S.wo and A.materiel_code=S.materiel_code and A.eqp_code=S.eqp_code and A.step_code=S.step_code and K.route_code=S.route_code 
                             left  join TMateriel_Info M on A.materiel_code=M.partcode
                             left  join TStep T on A.step_code=T.stepcode
                             left  join TUser U on B.report_person=U.usercode
@@ -1007,5 +1045,205 @@
             return mes;
         }
         #endregion
+
+
+        #region[鐢熶骇杩涘害鎶ヨ〃]
+        public static ToMessage ProductionScheduleReportSearch(string status, string wocode, string routecode, string routename, string partcode, string partname, string partspec, string opendate, string closedate, int startNum, int endNum, string prop, string order)
+        {
+            var dynamicParams = new DynamicParameters();
+            string search = "";
+            try
+            {
+                if (status != "" && status != null)
+                {
+                    switch (status)
+                    {
+                        case "START":
+                            search += "and AA.status='START' ";
+                            break;
+                        case "CLOSED":
+                            search += "and AA.status='CLOSED' ";
+                            break;
+                        default:
+                            search += "and AA.status<>'START' and AA.status<>'CLOSED' ";
+                            break;
+                    }
+                }
+                if (wocode != "" && wocode != null)
+                {
+                    search += "and AA.wo_code like '%'+@wocode+'%' ";
+                    dynamicParams.Add("@wocode", wocode);
+                }
+                if (routecode != "" && routecode != null)
+                {
+                    search += "and AA.route_code like '%'+@routecode+'%' ";
+                    dynamicParams.Add("@routecode", routecode);
+                }
+                if (routename != "" && routename != null)
+                {
+                    search += "and AA.route_name like '%'+@routename+'%' ";
+                    dynamicParams.Add("@routename", routename);
+                }
+                if (partcode != "" && partcode != null)
+                {
+                    search += "and AA.partcode like '%'+@partcode+'%' ";
+                    dynamicParams.Add("@partcode", partcode);
+                }
+                if (partname != "" && partname != null)
+                {
+                    search += "and AA.partname like '%'+@partname+'%' ";
+                    dynamicParams.Add("@partname", partname);
+                }
+                if (partspec != "" && partspec != null)
+                {
+                    search += "and AA.partspec like '%'+@partspec+'%' ";
+                    dynamicParams.Add("@partspec", partspec);
+                }
+                if (opendate != "" && opendate != null)
+                {
+                    search += "and AA.lm_date between @opendate and @closedate ";
+                    dynamicParams.Add("@opendate", opendate + " 00:00:00");
+                    dynamicParams.Add("@closedate", closedate + " 23:59:59");
+                }
+                if (search == "")
+                {
+                    search = "and 1=1 ";
+                }
+                search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+                // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+                var total = 0; //鎬绘潯鏁�
+                var sql = @"select  AA.saleOrderCode,AA.m_po,AA.wo_code,
+                            (case when AA.status='START' then '鎵ц涓�' when AA.status='CLOSED' then '宸插畬鎴�' else '鏈紑濮�' end) as status,
+                            AA.lm_date,AA.route_code,AA.route_name,AA.partcode,AA.partname,AA.partspec,AA.plan_qty,left(AA.concat_name,len(concat_name)-1) as concat_name  from
+                            (
+                            select E.saleOrderCode,W.m_po,m.wo_code,W.status,W.lm_date,W.route_code,R.name as route_name,P.partcode,P.partname,P.partspec,m.plan_qty,
+                            (select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' from TK_Wrk_Step n
+                             inner join TStep S on n.step_code=S.stepcode
+                             where n.wo_code=m.wo_code for xml path('')) as concat_name
+                            from TK_Wrk_Step m
+                            inner join TK_Wrk_Man W on m.wo_code=W.wo_code
+                            left join TKimp_Ewo E on W.m_po=E.wo
+                            inner join TMateriel_Info P on W.materiel_code=p.partcode
+                            inner join TFlw_Rout R on W.route_code=R.code
+                            group by E.saleOrderCode,W.m_po,m.wo_code,W.status,W.lm_date,W.route_code,R.name,P.partcode,P.partname,P.partspec,m.plan_qty
+                            ) AA  
+                            where " + 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 ProductionScheduleReportExcelSearch(string status, string wocode, string routecode, string routename, string partcode, string partname, string partspec, string opendate, string closedate)
+        {
+            var dynamicParams = new DynamicParameters();
+            string search = "";
+            try
+            {
+                if (status != "" && status != null)
+                {
+                    switch (status)
+                    {
+                        case "START":
+                            search += "and AA.status='START' ";
+                            break;
+                        case "CLOSED":
+                            search += "and AA.status='CLOSED' ";
+                            break;
+                        default:
+                            search += "and AA.status<>'START' and AA.status<>'CLOSED' ";
+                            break;
+                    }
+                }
+                if (wocode != "" && wocode != null)
+                {
+                    search += "and AA.wo_code like '%'+@wocode+'%' ";
+                    dynamicParams.Add("@wocode", wocode);
+                }
+                if (routecode != "" && routecode != null)
+                {
+                    search += "and AA.route_code like '%'+@routecode+'%' ";
+                    dynamicParams.Add("@routecode", routecode);
+                }
+                if (routename != "" && routename != null)
+                {
+                    search += "and AA.route_name like '%'+@routename+'%' ";
+                    dynamicParams.Add("@routename", routename);
+                }
+                if (partcode != "" && partcode != null)
+                {
+                    search += "and AA.partcode like '%'+@partcode+'%' ";
+                    dynamicParams.Add("@partcode", partcode);
+                }
+                if (partname != "" && partname != null)
+                {
+                    search += "and AA.partname like '%'+@partname+'%' ";
+                    dynamicParams.Add("@partname", partname);
+                }
+                if (partspec != "" && partspec != null)
+                {
+                    search += "and AA.partspec like '%'+@partspec+'%' ";
+                    dynamicParams.Add("@partspec", partspec);
+                }
+                if (opendate != "" && opendate != null)
+                {
+                    search += "and AA.lm_date between @opendate and @closedate ";
+                    dynamicParams.Add("@opendate", opendate + " 00:00:00");
+                    dynamicParams.Add("@closedate", closedate + " 23:59:59");
+                }
+                if (search == "")
+                {
+                    search = "and 1=1 ";
+                }
+                search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+                // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+                var total = 0; //鎬绘潯鏁�
+                var sql = @"select  AA.saleOrderCode as ERP婧愬崟鍙�,AA.m_po as ERP鐢熶骇璁㈠崟,AA.wo_code as 鐢熶骇宸ュ崟鍙�,
+                            (case when AA.status='START' then '鎵ц涓�' when AA.status='CLOSED' then '宸插畬鎴�' else '鏈紑濮�' end) as 宸ュ崟鐘舵��,
+                            AA.lm_date as 鍗曟嵁鏃ユ湡,AA.route_code as 宸ヨ壓璺嚎缂栧彿,AA.route_name as 宸ヨ壓璺嚎鍚嶇О,
+                            AA.partcode as 浜у搧缂栫爜,AA.partname as 浜у搧鍚嶇О,AA.partspec as 浜у搧瑙勬牸,AA.plan_qty as 浠诲姟鏁伴噺,left(AA.concat_name,len(concat_name)-1) as 鐢熶骇杩涘害  from
+                            (
+                            select E.saleOrderCode,W.m_po,m.wo_code,W.status,W.lm_date,W.route_code,R.name as route_name,P.partcode,P.partname,P.partspec,m.plan_qty,
+                            (select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' from TK_Wrk_Step n
+                             inner join TStep S on n.step_code=S.stepcode
+                             where n.wo_code=m.wo_code for xml path('')) as concat_name
+                            from TK_Wrk_Step m
+                            inner join TK_Wrk_Man W on m.wo_code=W.wo_code
+                            left join TKimp_Ewo E on W.m_po=E.wo
+                            inner join TMateriel_Info P on W.materiel_code=p.partcode
+                            inner join TFlw_Rout R on W.route_code=R.code
+                            group by E.saleOrderCode,W.m_po,m.wo_code,W.status,W.lm_date,W.route_code,R.name,P.partcode,P.partname,P.partspec,m.plan_qty
+                            ) AA  
+                            where " + search;
+                DataTable data = DapperHelper.selectdata(sql, dynamicParams);
+                data.TableName = "Table"; //璁剧疆DataTable鐨勫悕绉�
+                string msg = DownLoad.DataTableToExcel(data, "鐢熶骇杩涘害鎶ヨ〃");
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.count = total;
+                mes.data = msg;
+            }
+            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