From 78ccddadb87e0d4dd7f74733a031393395db2869 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 29 五月 2024 14:38:39 +0800
Subject: [PATCH] nothing

---
 VueWebApi/DLL/DAL/ProductModelDAL.cs |  245 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 201 insertions(+), 44 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductModelDAL.cs b/VueWebApi/DLL/DAL/ProductModelDAL.cs
index 2399541..ec553e1 100644
--- a/VueWebApi/DLL/DAL/ProductModelDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductModelDAL.cs
@@ -882,10 +882,10 @@
             var dynamicParams = new DynamicParameters();
             try
             {
-                sql = @"select substring(version,charindex('V',version)+1,len(version)-charindex('V',version))+1 as version     
+                sql = @"select isnull(max(substring(version,charindex('V',version)+1,len(version)-charindex('V',version))),0)+1 as version    
                         from TBom_Main where materiel_code=@parentpartcode";
                 dynamicParams.Add("@parentpartcode", parentpartcode);
-                var data = DapperHelper.selecttable(sql);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
                 if (data.Rows.Count > 0)
                 {
                     mes.code = "200";
@@ -925,8 +925,8 @@
                     string sql0 = @"select ISNULL(IDENT_CURRENT('TBom_Main')+1,1) as id";
                     var dt = DapperHelper.selecttable(sql0);
                     //鍐欏叆BOM涓昏〃
-                    sql = @"insert into TBom_Main(materiel_code,quantity,status,version,lm_user,lm_date) 
-                            values(@materiel_code,@quantity,@status,@version,@username,@CreateDate)";
+                    sql = @"insert into TBom_Main(materiel_code,quantity,status,version,lm_user,lm_date,startdate) 
+                            values(@materiel_code,@quantity,@status,@version,@username,@CreateDate,@startdate)";
                     list.Add(new
                     {
                         str = sql,
@@ -937,7 +937,8 @@
                             status = status,
                             version = version,
                             username = username,
-                            CreateDate = DateTime.Now.ToString()
+                            CreateDate = DateTime.Now.ToString(),
+                            startdate = startdate
                         }
                     });
                     //鍐欏叆BOM瀛愯〃
@@ -985,12 +986,12 @@
                         str = sql,
                         parm = new
                         {
-                            id = bomid,
+                            bomid = bomid,
                             materiel_code = parentpartcode,
                             quantity = quantity,
                             status = status,
-                            username = username,
-                            CreateDate = DateTime.Now.ToString()
+                            lm_user = username,
+                            lm_date = DateTime.Now.ToString()
                         }
                     });
                     //鍒犻櫎BOM瀛愯〃
@@ -1000,7 +1001,7 @@
                         str = sql,
                         parm = new
                         {
-                            id = bomid
+                            bomid = bomid
                         }
                     });
                     //鍐欏叆BOM瀛愯〃
@@ -1058,6 +1059,18 @@
             var dynamicParams = new DynamicParameters();
             try
             {
+                //鍒ゆ柇鐗╂枡绫诲瀷鏄惁鏈夊叧鑱旂墿鏂�
+                sql = @"select materiel_code from TK_Wrk_Man   where materiel_code in (select materiel_code from TBom_Main  where id=@bomid ) and bom_id=@bomid";
+                dynamicParams.Add("@bomid", bomid);
+                var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                if (data0.Rows.Count > 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "褰撳墠鐗╂枡娓呭崟宸茶宸ュ崟鍏宠仈浣跨敤,涓嶅厑璁镐慨鏀�!";
+                    mes.data = null;
+                    return mes;
+                }
                 //鑾峰彇Bom瀛愯〃鏁版嵁
                 sql = @"select A.seq,B.partcode,B.partname,B.partspec,B.uom_code,T.name as uom_name,
                          A.base_quantity,A.loss_quantity,A.total_quantity,A.pn_type   
@@ -1081,6 +1094,64 @@
             return mes;
         }
         #endregion
+
+        #region[鐗╂枡娓呭崟鍒犻櫎]
+        public static ToMessage DeleteBoIventory(string bomid)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                //鍒ゆ柇鐗╂枡绫诲瀷鏄惁鏈夊叧鑱旂墿鏂�
+                sql = @"select materiel_code from TK_Wrk_Man   where materiel_code in (select materiel_code from TBom_Main  where id=@bomid ) and bom_id=@bomid";
+                dynamicParams.Add("@bomid", bomid);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "褰撳墠鐗╂枡娓呭崟宸茶宸ュ崟鍏宠仈浣跨敤,涓嶅厑璁稿垹闄�!";
+                    mes.data = null;
+                }
+                else
+                {
+                    //鍒犻櫎鐗╂枡娓呭崟瀛愯〃
+                    sql = @"delete TBom_Deta where m_id=@bomid";
+                    list.Add(new { str = sql, parm = new { bomid = bomid } });
+                    //鍒犻櫎鐗╂枡娓呭崟涓昏〃
+                    sql = @"delete TBom_Main where id=@bomid";
+                    list.Add(new { str = sql, parm = new { bomid = bomid } });
+                    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
+
+
 
 
         #region[宸ヨ壓璺嚎鏌ヨ]
@@ -1215,7 +1286,7 @@
                         {
                             is_firststep = "Y";
                         }
-                        else if (Convert.ToInt32(json.Data.Rows[i]["SEQ"].ToString()) == json.Data.Rows.Count) //鏄惁鏈亾宸ュ簭
+                        if (Convert.ToInt32(json.Data.Rows[i]["SEQ"].ToString()) == json.Data.Rows.Count) //鏄惁鏈亾宸ュ簭
                         {
                             is_laststep = "Y";
                         }
@@ -1259,6 +1330,18 @@
             var dynamicParams = new DynamicParameters();
             try
             {
+                //鍒ゆ柇宸ヨ壓璺矾绾挎槸鍚﹁瀛樿揣缁戝畾
+                sql = @"select *   from TMateriel_Route where route_code=@routecode";
+                dynamicParams.Add("@routecode", routecode);
+                var data_0 = DapperHelper.selectdata(sql, dynamicParams);
+                if (data_0.Rows.Count > 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "瀛樿揣妗f宸插叧鑱斿伐鑹鸿矾绾匡紝涓嶅厑璁稿垹闄�!";
+                    mes.data = null;
+                    return mes;
+                }
                 //鍒ゆ柇宸ヨ壓璺嚎鏄惁琚伐鍗曞紩鐢�(琚紩鐢ㄥ垯涓嶈兘鍒犻櫎)
                 sql = @"select *   from TK_Wrk_Man where route_code=@routecode";
                 dynamicParams.Add("@routecode", routecode);
@@ -1269,6 +1352,7 @@
                     mes.count = 0;
                     mes.Message = "宸ヨ壓璺嚎宸茶宸ュ崟寮曠敤锛屼笉鍏佽鍒犻櫎!";
                     mes.data = null;
+                    return mes;
                 }
                 else
                 {
@@ -1282,6 +1366,7 @@
                         mes.count = 0;
                         mes.Message = "宸ヨ壓璺嚎宸茶缃妭鎷嶅伐浠凤紝璇峰厛鍒犻櫎璁剧疆!";
                         mes.data = null;
+                        return mes;
                     }
                     else
                     {
@@ -1295,21 +1380,23 @@
                         sql = @"delete TMateriel_Route  where route_code=@routecode";
                         list.Add(new { str = sql, parm = new { routecode = routecode } });
                     }
-                }
-                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;
+                    bool aa = DapperHelper.DoTransaction(list);
+                    if (aa)
+                    {
+                        mes.code = "200";
+                        mes.count = 0;
+                        mes.Message = "鍒犻櫎鎴愬姛!";
+                        mes.data = null;
+                        return mes;
+                    }
+                    else
+                    {
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "鍒犻櫎澶辫触!";
+                        mes.data = null;
+                        return mes;
+                    }
                 }
             }
             catch (Exception e)
@@ -1318,6 +1405,7 @@
                 mes.count = 0;
                 mes.Message = e.Message;
                 mes.data = null;
+                return mes;
             }
             return mes;
         }
@@ -1489,6 +1577,9 @@
                             list.Add(new { str = sql_1, parm = new { stepcode = stepcode } });
                             //淇敼宸ュ簭琛ㄥ叧鑱斿伐浣滅珯鏍囪瘑
                             sql_1 = @"update TStep set is_eqp='N' where stepcode=@stepcode";
+                            list.Add(new { str = sql_1, parm = new { stepcode = stepcode } });
+                            //鍒犻櫎璁惧鑺傛媿宸ヤ环琛�
+                            sql_1 = @"delete TPrteEqp_Stad  where step_code=@stepcode";
                             list.Add(new { str = sql_1, parm = new { stepcode = stepcode } });
                         }
                     }
@@ -1930,12 +2021,12 @@
             try
             {
                 //閫氳繃浜у搧缂栫爜鏌ユ壘鍏宠仈鐨勫伐鑹鸿矾绾夸俊鎭�
-                sql = @"select B.stepcode as code,B.stepname as name   
+                sql = @"select B.stepcode as code,B.stepname as name,B.flwtype as flag      
                         from TFlw_Rtdt A
                         inner join TStep B on A.step_code=B.stepcode
                         where A.rout_code=@routecode and B.is_delete<>'1' and A.is_delete<>'1'";
                 dynamicParams.Add("@routecode", routecode);
-                var data = DapperHelper.select<ObjectData>(sql, dynamicParams);
+                var data = DapperHelper.select<StepDefect>(sql, dynamicParams);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
                 mes.data = data;
@@ -1979,30 +2070,82 @@
         }
         #endregion
 
-        #region[鏍规嵁宸ュ簭绾跨紪鐮佹煡鎵惧叧鑱旇澶囬泦鍚圿
-        public static ToMessage StepSelectEqpList(string partcode, string routecode, string stepcode, int startNum, int endNum, string prop, string order)
+        #region[鏍规嵁宸ュ簭绾跨紪鐮佹煡鎵惧叧鑱旇澶�/澶栧崗渚涙柟闆嗗悎]
+        public static ToMessage StepSelectEqpList(string partcode, string routecode, string stepcode,string steptype, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
-            string search = "";
+            string search = "",sql="";
+            int total = 0;
             try
             {
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
-                var total = 0; //鎬绘潯鏁�
-                var sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice  
+                if (steptype == "Z")  //鑷埗宸ュ簭
+                {
+                    total = 0; //鎬绘潯鏁�
+                    //sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice  
+                    //        from (
+                    //        select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
+                    //        where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode 
+                    //        union all
+                    //        select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
+                    //        from TFlw_Rteqp where step_code=@stepcode and style='E' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
+                    //        ) A
+                    //        left join TEqpInfo B on A.eqp_code=B.code 
+                    //        left join TOrganization T on B.wksp_code=T.org_code 
+                    //        left join TMateriel_Info C on A.materiel_code=C.partcode
+                    //        where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1' ";
+
+                    sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice  
                             from (
                             select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
                             where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode 
                             union all
-                            select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
-                            from TFlw_Rteqp where step_code=@stepcode and style='E' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
+                            select @partcode as materiel_code,C.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
+                            from TFlw_Rout A
+                            inner join TFlw_Rtdt B on A.code=B.rout_code
+                            left join TFlw_Rteqp C on B.step_code=C.step_code
+                            where A.code=@routecode and B.step_code=@stepcode and style='E' and @partcode+A.code+C.eqp_code+B.step_code 
+                            not in(select materiel_code+route_code+eqp_code+step_code  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode)
                             ) A
                             left join TEqpInfo B on A.eqp_code=B.code 
                             left join TOrganization T on B.wksp_code=T.org_code 
                             left join TMateriel_Info C on A.materiel_code=C.partcode
-                            where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1' ";
-                dynamicParams.Add("@partcode", partcode);
-                dynamicParams.Add("@routecode", routecode);
-                dynamicParams.Add("@stepcode", stepcode);
+                            where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1'";
+                    dynamicParams.Add("@partcode", partcode);
+                    dynamicParams.Add("@routecode", routecode);
+                    dynamicParams.Add("@stepcode", stepcode);
+                }
+                else  //澶栧崗宸ュ簭
+                {
+                    total = 0; //鎬绘潯鏁�
+                    //sql = @"select B.code as eqpcode,B.name as eqpname,'' as wksp_code,'' as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice  
+                    //        from (
+                    //        select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
+                    //        where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode 
+                    //        union all
+                    //        select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
+                    //        from TFlw_Rteqp where step_code=@stepcode and style='W' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
+                    //        ) A
+                    //        left join TCustomer B on A.eqp_code=B.code
+                    //        where B.is_delete<>'1'";
+                    sql = @"select B.code as eqpcode,B.name as eqpname,'' as wksp_code,'' as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice 
+                            from (
+                            select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
+                            where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode 
+                            union all
+                            select @partcode as materiel_code,C.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
+                            from TFlw_Rout A
+                            inner join TFlw_Rtdt B on A.code=B.rout_code
+                            left join TFlw_Rteqp C on B.step_code=C.step_code
+                            where A.code=@routecode and B.step_code=@stepcode and style='W' and @partcode+A.code+C.eqp_code+B.step_code 
+                            not in(select materiel_code+route_code+eqp_code+step_code  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode)
+                            ) A
+                            left join TCustomer B on A.eqp_code=B.code
+                            where B.is_delete<>'1'";
+                    dynamicParams.Add("@partcode", partcode);
+                    dynamicParams.Add("@routecode", routecode);
+                    dynamicParams.Add("@stepcode", stepcode);
+                }
                 var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
@@ -2029,31 +2172,33 @@
             {
                 if (partcode != "" && partcode != null)
                 {
-                    search += "and A.materiel_code=@partcode ";
+                    search += "and AA.partcode=@partcode ";
                     dynamicParams.Add("@partcode", partcode);
                 }
                 if (routecode != "" && routecode != null)
                 {
-                    search += "and A.route_code=@routecode ";
+                    search += "and AA.route_code=@routecode ";
                     dynamicParams.Add("@routecode", routecode);
                 }
                 if (stepcode != "" && stepcode != null)
                 {
-                    search += "and A.step_code=@stepcode ";
+                    search += "and AA.stepcode=@stepcode ";
                     dynamicParams.Add("@stepcode", stepcode);
                 }
                 if (eqpcode != "" && eqpcode != null)
                 {
-                    search += "and A.eqp_code=@eqpcode";
+                    search += "and AA.eqp_code=@eqpcode";
                     dynamicParams.Add("@eqpcode", eqpcode);
                 }
                 if (search == "")
                 {
                     search = "and 1=1 ";
                 }
+                search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name,
+                var sql = @"select *  from (
+                            select A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name,
                             D.stepcode,D.stepname,A.eqp_code,E.name as eqp_name,E.wksp_code,F.org_name as wksp_name,
                             A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                             from TPrteEqp_Stad A
@@ -2062,7 +2207,19 @@
                             left join TStep D on A.step_code=D.stepcode
                             left join TEqpInfo E on A.eqp_code=E.code
                             left join TOrganization F on E.wksp_code=F.org_code
-                            where B.is_delete<>'1' and C.is_delete<>'1' and D.is_delete<>'1' and E.is_delete<>'1' and F.is_delete<>'1' " + search;
+                            left join TCustomer S on A.eqp_code=S.code
+                            where B.is_delete<>'1' and C.is_delete<>'1' and D.is_delete<>'1' and E.is_delete<>'1' and F.is_delete<>'1'
+                            union all
+                            select A.materiel_code as partcode,B.partname,B.partspec,A.route_code,C.name as route_name,
+                            D.stepcode,D.stepname,S.code,S.name as eqp_name,'' as wksp_code,'' as wksp_name,
+                            A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
+                            from TPrteEqp_Stad A
+                            left join TMateriel_Info B on A.materiel_code=B.partcode
+                            left join TFlw_Rout C on A.route_code=C.code
+                            left join TStep D on A.step_code=D.stepcode
+                            left join TCustomer S on A.eqp_code=S.code
+                            where B.is_delete<>'1' and C.is_delete<>'1' and D.is_delete<>'1' and S.is_delete<>'1'
+                            ) as AA where" + search;
                 var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";

--
Gitblit v1.9.3