From fcca000072a8cfae98c1cb3dadce0512b19083cc Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 28 六月 2022 20:09:13 +0800
Subject: [PATCH] ERP订单查询,订单下达、订单关闭功能开发

---
 VueWebApi/DLL/DAL/ProductModelDAL.cs |  279 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 241 insertions(+), 38 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductModelDAL.cs b/VueWebApi/DLL/DAL/ProductModelDAL.cs
index 1ec9a72..05b65c2 100644
--- a/VueWebApi/DLL/DAL/ProductModelDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductModelDAL.cs
@@ -27,7 +27,7 @@
             try
             {
                 //鑾峰彇璁惧绫诲瀷鏁版嵁
-                sql = @"select code,name from T_Dict where dict_group='CHLX' ";
+                sql = @"select code,name from T_Dict where dict_type='CHLX' ";
                 var data = DapperHelper.selecttable(sql);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
@@ -74,7 +74,7 @@
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select A.id,A.code,A.name,A.dict_code as stockcode,B.name as stockname,A.lm_user,A.lm_date  
                             from TMateriel_Type A
-                            left join T_Dict B on A.dict_code=B.code and B.dict_group='CHLX'
+                            left join T_Dict B on A.dict_code=B.code and B.dict_type='CHLX'
                             where A.is_delete<>'1' " + search;
                 var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                 mes.code = "200";
@@ -373,6 +373,30 @@
         }
         #endregion
 
+        #region[鍗曚綅涓嬫媺鍒楄〃鏌ヨ]
+        public static ToMessage UomSelect()
+        {
+            string sql = "";
+            try
+            {
+                //鑾峰彇宸ヨ壓璺嚎鏁版嵁
+                sql = @"select code,name from TUom where is_delete<>'1' ";
+                var data = DapperHelper.selecttable(sql);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.data = data;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[瀛樿揣妗f鏌ヨ]
         public static ToMessage InventoryFileSelect(string partcode, string partname, string partspec, string stocktypecode, string materialtypecode, string storehousecode, int startNum, int endNum, string prop, string order)
         {
@@ -416,7 +440,7 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.partcode,A.partname,A.partspec,A.uom_code,B.name as uom_name,D.code as stocktypecode,D.name as stocktypename,
+                var sql = @"select A.id,A.partcode,A.partname,A.partspec,A.uom_code,B.name as uom_name,D.code as stocktypecode,D.name as stocktypename,
                             C.code as materialtypecode,C.name as materialtypename,A.stck_code,T.name as stck_name,A.maxqty,A.minqty,A.lm_user,
                             A.lm_date,A.proute_id
                             from TMateriel_Info A
@@ -450,8 +474,8 @@
             {
                 if (operType == "Add")
                 {
-                    var sql = @"insert into TMateriel_Info(partcode,partname,partspec,uom_code,materialtypecode,stck_code,proute_id,maxqty,minqty,lm_user,lm_date) 
-                            values(@stocktypecode,@materialtypecode,@materialtypename,@username,@CreateDate)";
+                    var sql = @"insert into TMateriel_Info(partcode,partname,partspec,uom_code,materieltype_code,stck_code,maxqty,minqty,lm_user,lm_date) 
+                            values(@materialcode,@materialname,@materialspec,@uomcode,@materialtypecode,@warehousecode,@maxstockqty,@minstockqty,@username,@CreateDate)";
                     dynamicParams.Add("@materialcode", materialcode);
                     dynamicParams.Add("@materialname", materialname);
                     dynamicParams.Add("@materialspec", materialspec);
@@ -480,8 +504,8 @@
                 }
                 if (operType == "Update")
                 {
-                    var sql = @"update TMateriel_Type set partname=@materialname,partspec=@materialspec,uom_code=@uomcode,materialtypecode=@materialtypecode,stck_code=@warehousecode,
-                                maxqty=@maxstockqty,minqty=@minstockqty lm_user=@username,lm_date=@CreateDate where id=@materialid";
+                    var sql = @"update TMateriel_Type set partname=@materialname,partspec=@materialspec,uom_code=@uomcode,materieltype_code=@materialtypecode,stck_code=@warehousecode,
+                                maxqty=@maxstockqty,minqty=@minstockqty,lm_user=@username,lm_date=@CreateDate where id=@materialid";
                     dynamicParams.Add("@materialid", materialid);
                     dynamicParams.Add("@materialname", materialname);
                     dynamicParams.Add("@materialspec", materialspec);
@@ -635,8 +659,8 @@
                 for (int i = 0; i < data.Rows.Count; i++)
                 {
                     MaterialRout rout = new MaterialRout();
-                    rout.code = data.Rows[i]["CODE"].ToString();
-                    rout.name = data.Rows[i]["NAME"].ToString();
+                    rout.code = data.Rows[i]["ROUTECODE"].ToString();
+                    rout.name = data.Rows[i]["ROUTENAME"].ToString();
                     rout.flag = data.Rows[i]["FLAG"].ToString();
 
                     //鏍规嵁宸ヨ壓璺嚎缂栫爜鑾峰彇鍏宠仈鐨勫伐搴忎俊鎭�
@@ -911,7 +935,7 @@
                     mes.Message = "宸ヨ壓璺嚎宸茶宸ュ崟寮曠敤锛屼笉鍏佽鍒犻櫎!";
                     mes.data = null;
                 }
-                else 
+                else
                 {
                     //鍒ゆ柇褰撳墠宸ヨ壓璺嚎鏄惁鏈夎缃妭鎷嶅伐浠�(鏈夎缃紝鎻愮ず鍏堝垹闄よ妭鎷嶅伐浠疯缃�)
                     sql = @"select *   from TPrteEqp_Stad where route_code=@routecode";
@@ -924,7 +948,7 @@
                         mes.Message = "宸ヨ壓璺嚎宸茶缃妭鎷嶅伐浠凤紝璇峰厛鍒犻櫎璁剧疆!";
                         mes.data = null;
                     }
-                    else 
+                    else
                     {
                         //鍒犻櫎宸ヨ壓璺嚎鍏宠仈宸ュ簭琛�
                         sql = @"delete TFlw_Rtdt  where rout_code=@routecode";
@@ -966,6 +990,30 @@
 
 
 
+
+        #region[宸ヨ壓璺嚎涓嬫媺鏌ヨ鎺ュ彛]
+        public static ToMessage RouteSearch()
+        {
+            string sql = "";
+            try
+            {
+                //鑾峰彇宸ヨ壓璺嚎鏁版嵁
+                sql = @"select code,name from TFlw_Rout where is_delete<>'1' ";
+                var data = DapperHelper.selecttable(sql);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.data = data;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
 
         #region[宸ュ簭鏌ヨ]
         public static ToMessage StepSearch(string stepcode, string stepname, string enable, string steptypecode, string createuser, int startNum, int endNum, string prop, string order)
@@ -1248,7 +1296,7 @@
                         for (int j = 0; j < data0.Rows.Count; j++)
                         {
                             StepEqpCn cn = new StepEqpCn();
-                            cn.code= data0.Rows[j]["CODE"].ToString();//璁惧缂栫爜
+                            cn.code = data0.Rows[j]["CODE"].ToString();//璁惧缂栫爜
                             cn.name = data0.Rows[j]["NAME"].ToString();//璁惧鍚嶇О
                             cn.type = data0.Rows[j]["TYPE"].ToString();//宸ヤ綔绔欑被鍨�(E:璁惧 W:澶栧崗渚涙柟)
                             cn.flag = data0.Rows[j]["FLAG"].ToString();//鍏宠仈鏍囪瘑
@@ -1516,7 +1564,7 @@
                 sql = @"select B.stepcode as code,B.stepname as name   
                         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';";
+                        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);
                 mes.code = "200";
@@ -1534,8 +1582,36 @@
         }
         #endregion
 
+        #region[鏍规嵁宸ュ簭绾跨紪鐮佹煡鎵惧叧鑱旇澶囦笅鎷夋闆嗗悎]
+        public static ToMessage StepSelectEqp(string stepcode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //閫氳繃浜у搧缂栫爜鏌ユ壘鍏宠仈鐨勫伐鑹鸿矾绾夸俊鎭�
+                sql = @"select B.code,B.name  from TFlw_Rteqp A 
+                        left join TEqpInfo B on A.eqp_code=B.code
+                        where A.step_code=@stepcode and A.style='E' and A.is_delete<>'1' and B.is_delete<>'1'";
+                dynamicParams.Add("@stepcode", stepcode);
+                var data = DapperHelper.select<ObjectData>(sql, dynamicParams);
+                mes.code = "200";
+                mes.Message = "鏌ヨ鎴愬姛!";
+                mes.data = data;
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[鏍规嵁宸ュ簭绾跨紪鐮佹煡鎵惧叧鑱旇澶囬泦鍚圿
-        public static ToMessage StepSelectEqp(string partcode, string routecode, string stepcode, int startNum, int endNum, string prop, string order)
+        public static ToMessage StepSelectEqpList(string partcode, string routecode, string stepcode, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
@@ -1576,7 +1652,7 @@
         #endregion
 
         #region[鑺傛媿宸ヤ环鏌ヨ]
-        public static ToMessage BeatRateSearch(string partcode, string partname, string partspec, string routecode, string stepcode, string eqpcode, string eqpname, int startNum, int endNum, string prop, string order)
+        public static ToMessage BeatRateSearch(string partcode, string routecode, string stepcode, string eqpcode, int startNum, int endNum, string prop, string order)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
@@ -1584,38 +1660,23 @@
             {
                 if (partcode != "" && partcode != null)
                 {
-                    search += "and partcode like '%'+@partcode+'%' ";
+                    search += "and A.materiel_code=@partcode ";
                     dynamicParams.Add("@stepcode", partcode);
-                }
-                if (partname != "" && partname != null)
-                {
-                    search += "and stepname like '%'+@partname+'%' ";
-                    dynamicParams.Add("@partname", partname);
-                }
-                if (partspec != "" && partspec != null)
-                {
-                    search += "and stepname like '%'+@partspec+'%' ";
-                    dynamicParams.Add("@partspec", partspec);
                 }
                 if (routecode != "" && routecode != null)
                 {
-                    search += "and enable=@routecode ";
+                    search += "and A.route_code=@routecode ";
                     dynamicParams.Add("@routecode", routecode);
                 }
                 if (stepcode != "" && stepcode != null)
                 {
-                    search += "and flwtype=@stepcode ";
+                    search += "and A.step_code=@stepcode ";
                     dynamicParams.Add("@stepcode", stepcode);
                 }
                 if (eqpcode != "" && eqpcode != null)
                 {
-                    search += "and stepname like '%'+@eqpcode+'%' ";
+                    search += "and A.eqp_code=@eqpcode";
                     dynamicParams.Add("@eqpcode", eqpcode);
-                }
-                if (eqpname != "" && eqpname != null)
-                {
-                    search += "and stepname like '%'+@eqpname+'%' ";
-                    dynamicParams.Add("@eqpname", eqpname);
                 }
                 if (search == "")
                 {
@@ -1623,9 +1684,16 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select stepcode,stepname,flwtype,enable,descr,lm_user,lm_date,is_eqp,is_defect  
-                            from TStep
-                            where is_delete<>'1' " + search;
+                var sql = @"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
+                            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 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;
                 var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                 mes.code = "200";
                 mes.Message = "鏌ヨ鎴愬姛!";
@@ -1643,8 +1711,143 @@
         }
         #endregion
 
-        #region[鑺傛媿宸ヤ环鏂板缂栬緫]
+        #region[鑺傛媿宸ヤ环鎻愪氦]
+        public static ToMessage SaveBeatRate(string partcode, string routecode, string stepcode, string eqpcode, string wkshopcode, string eqp_value, string stand_value, string cavity_qty, string unprice, string username)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                //褰撳墠宸ュ簭鏄惁鍏宠仈宸ヨ壓璺嚎
+                sql = @"select *  from TPrteEqp_Stad
+                        where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                dynamicParams.Add("@partcode", partcode);
+                dynamicParams.Add("@routecode", routecode);
+                dynamicParams.Add("@stepcode", stepcode);
+                dynamicParams.Add("@eqpcode", eqpcode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)  //琚缃叧鑱旇繃灏变慨鏀�
+                {
+                    sql = @"update TPrteEqp_Stad set stand_value=@stand_value,eqp_value=@eqp_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
+                            where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode ";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            partcode = partcode,
+                            routecode = routecode,
+                            stepcode = stepcode,
+                            eqpcode = eqpcode,
+                            stand_value = stand_value,
+                            eqp_value = eqp_value,
+                            cavity_qty = cavity_qty,
+                            unprice = unprice,
+                            username = username,
+                            userdate = DateTime.Now.ToString()
+                        }
+                    });
+                }
+                else
+                {
+                    sql = @"insert into TPrteEqp_Stad(materiel_code,eqp_code,stand_value,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,step_code) 
+                    values(@partcode,@eqpcode,@stand_value,@routecode,@unprice,@eqp_value,@cavity_qty,@wkspcode,@username,@userdate,@stepcode)";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            partcode = partcode,
+                            eqpcode = eqpcode,
+                            stand_value = stand_value,
+                            routecode = routecode,
+                            unprice = unprice,
+                            eqp_value = eqp_value,
+                            cavity_qty = cavity_qty,
+                            wkspcode = wkshopcode,
+                            username = username,
+                            userdate = DateTime.Now.ToString(),
+                            stepcode = stepcode
+                        }
+                    });
+                }
+                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[鑺傛媿宸ヤ环鍒犻櫎]
+        public static ToMessage SaveBeatRate(string partcode, string routecode, string stepcode, string eqpcode)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+
+                //鍒犻櫎鑺傛媿宸ヤ环琛�
+                sql = @"delete TPrteEqp_Stad  where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        partcode = partcode,
+                        routecode = routecode,
+                        stepcode = stepcode,
+                        eqpcode = eqpcode
+                    }
+                });
+
+                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