From 1a94e0e270668ef1cfbcd5043b72bc6591a50706 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期四, 07 八月 2025 15:18:46 +0800
Subject: [PATCH] 价目表新增审核按钮无效修理bug

---
 WebAPI/Controllers/基础资料/基础资料/Gy_SOPBillEditController.cs |  289 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 270 insertions(+), 19 deletions(-)

diff --git "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_SOPBillEditController.cs" "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_SOPBillEditController.cs"
index eb1dc4a..d0e7a0c 100644
--- "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_SOPBillEditController.cs"
+++ "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_SOPBillEditController.cs"
@@ -27,7 +27,9 @@
         public DAL.ClsGy_SOPBill BillOld = new DAL.ClsGy_SOPBill();
         public bool BillChange;   //
         public DataGridView grdMain = new System.Windows.Forms.DataGridView();
-        ClsGridViewSum oSumGrid = new ClsGridViewSum();        
+        ClsGridViewSum oSumGrid = new ClsGridViewSum();
+        //鑾峰彇绯荤粺鍙傛暟
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
         //瀹氫箟
         public const Int16 HTagCol = 0;
@@ -147,6 +149,7 @@
                 List<SOPBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SOPBill>>(msg2);
 
                 string HBillNo = list[0].HBillNo;
+                int HInterID = list[0].HInterID;
                 DateTime HDate = list[0].HDate;
                 string HName = list[0].HName;
                 int HMaterID = list[0].HMaterID;
@@ -200,12 +203,12 @@
                  ",HYear,HPeriod,HRemark,HMaker,Hmakedate,HMaterID,HName,HMaterTypeID" +
                  ",HUnitID,HMaterNumber,HUnitNumber,HStandard" +
                  ") " +
-                  " values('" + 3305 + "'," + lID + ",'" + HBillNo + "'," + "getdate()" +
+                  " values('" + 3305 + "'," + HInterID + ",'" + HBillNo + "'," + "getdate()" +
                 "," + "datepart(yyyy,GETDATE())" + "," + "datepart(mm,getdate())" + ",'" + HRemark + "','" + HMaker + "'," + "getdate()" + "," + HMaterID.ToString() + ",'" + HName + "'," + HMaterTypeID +
                 "," + HUnitID.ToString() + ",'" + HMaterNumber + "','" + HUnitNumber + "','" + HStandard.ToString() +
                 "') ");
             
-                oCN.RunProc("update Gy_BillNumber set IDNow=IDNow+1 where BillType='" + BillType.Trim() + "'");
+                //oCN.RunProc("update Gy_BillNumber set IDNow=IDNow+1 where BillType='" + BillType.Trim() + "'");
                 //" values(" + 3305 + "','" + 12333 + "','" + "test" + "','" + HDate + "','" +
                 //2022 + "','" + 11 + "','" + HRemark + "','" + "Test" + "','" + "2022-11-04" + "','" + HMaterID.ToString() + "','" + HName + "','" + "656" +
                 //"','" + HUnitID.ToString() + "','" + HMaterNumber + "','" + HUnitNumber + "','" + HStandard.ToString() +
@@ -218,7 +221,7 @@
                 "(HInterID,HEntryID,HProcID,HProcNO" +
                 ",HWorkStationID,HCenterID,HRemark" +
                 ") values("
-                + lID + "," + 1 + "," + HProcID + "," + HProcNo +
+                + HInterID + "," + 1 + "," + HProcID + "," + HProcNo +
                 "," + HWorkStationID + "," + HCenterID + ",'" + HRemark2 + "'" +
                 ") ");
               
@@ -240,6 +243,92 @@
             }
         }
         #endregion
+
+        #region 淇濆瓨鍗曟嵁
+        [Route("Gy_SOPBill/Save")]
+        [HttpPost]
+        public object Save([FromBody] JObject oMain)
+        {
+            try
+            {
+                var _value = oMain["oMain"].ToString();
+                string msg1 = _value.ToString();
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msgMain = sArray[0].ToString(); //琛ㄥご淇℃伅
+                string msgSub = sArray[1].ToString(); //琛ㄤ綋淇℃伅
+                string OperationType = sArray[2].ToString(); //鎿嶄綔绫诲瀷
+                string user = sArray[3].ToString(); //鐢ㄦ埛
+                DBUtility.ClsPub.CurUserName = user;
+
+                ListModels oListModels = new ListModels();
+                DAL.ClsGy_SOPBill oBill = new DAL.ClsGy_SOPBill();
+                List<Model.ClsGy_SOPBillMain> lsmain = new List<Model.ClsGy_SOPBillMain>();
+                msgMain = msgMain.Replace("\\", "");
+                msgMain = msgMain.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_SOPBillMain(msgMain);
+                foreach (Model.ClsGy_SOPBillMain oItem in lsmain)
+                {                    
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msgSub = msgSub.Substring(1, msgSub.Length - 2);
+                msgSub = msgSub.Replace("\\", "");
+                msgSub = msgSub.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsGy_SOPBillSub> ls = new List<Model.ClsGy_SOPBillSub>();
+                ls = oListModels.getObjectByJson_Gy_SOPBillSub(msgSub);
+                int i = 0;
+                foreach (Model.ClsGy_SOPBillSub oItemSub in ls)
+                {
+
+                    i++;
+                    oItemSub.HEntryID = i;
+                    
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (OperationType == "1" || OperationType == "2")
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }              
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         [Route("Gy_SOPBill/Use")]
         [HttpGet]
         public object sy_Click()
@@ -288,14 +377,26 @@
         [HttpPost]
         public object UploadFile1()
         {
-
+            string path="";
             string HBillNo = HttpContext.Current.Request.Params["HBillNo"];  //鍗曟嵁鍙�
-            string HRemark = HttpContext.Current.Request.Params["HRemark"];  //澶囨敞
             string HUserName = HttpContext.Current.Request.Params["HUserName"];  //鍒涘缓浜�
-            HttpPostedFile files = HttpContext.Current.Request.Files["file"];
-            string path = HttpContext.Current.Server.MapPath("~/../Files/" + HBillNo);
+            string HInterID = HttpContext.Current.Request.Params["HInterID"];  //鍗曟嵁鍐呯爜
+            HttpPostedFile files = HttpContext.Current.Request.Files["file"]; //鏂囦欢
+            string Ret = "";
+            if (oSystemParameter.ShowBill(ref Ret))
+            {
+                if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
+                {
+                    path = "D:/缃戠珯鍙戝竷/MES/MES娴嬭瘯/LAYUI/Files/SOP/" + HBillNo;
+                }
+                else
+                {
+                    path = HttpContext.Current.Server.MapPath("~/../Files/SOP/" + HBillNo);
+                }
+            }                    
             //string path = @"D:\\Files\\"+ HBillNo;
-            dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName);
+            Int64 HEntryID = Convert.ToInt64(HttpContext.Current.Request.Params["HEntryID"]);  //瀛愬唴鐮�
+            dynamic dyResult = UpLoadFile(files, path, HBillNo, HInterID, HUserName, HEntryID);
             if (dyResult != null && dyResult.result == 1)
             {
                 objJsonResult.code = "1";
@@ -311,11 +412,10 @@
                 objJsonResult.Message = dyResult.returnval;
                 objJsonResult.data = null;
                 return objJsonResult;
-            }
-
+            }           
         }
 
-        public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName)
+        public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HInterID, string HUserName,Int64 HEntryID)
         {
             dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" };
             string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞
@@ -369,7 +469,20 @@
                 {
                     File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
                     files.SaveAs(fileurl);
-                    string StrPath = "/files/" + HBillNo + "/" + filename;
+                    string StrPath = "";
+                    string Ret = "";
+                    if (oSystemParameter.ShowBill(ref Ret))
+                    {
+                        if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
+                        {
+                            StrPath = "D:/缃戠珯鍙戝竷/MES/MES娴嬭瘯/LAYUI/Files/SOP/" + HBillNo + "/" + filename;
+                        }
+                        else
+                        {
+                            StrPath = "/files/SOP/" + HBillNo + "/" + filename;
+                        }
+                    }
+
                     if (File.Exists(fileurl))
                     {
                         //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
@@ -377,8 +490,8 @@
                         oCN.RunProc("Insert into Gy_SOPBillSub2 (HFileName,HPath,HFileType" +
                                ",HUpMan,HUpTime,HInterID,HEntryID,HSno,HFileID,HFileSize" +
                               ") values('"
-                               + filename.ToString() + "','" + filePath.ToString() + "','" +  fileExtension.ToString() + "'" +
-                               ",'" + HUserName + "',getdate()"  + ",'" + Sno + "','" + 0 + "','" + Sno + "','" + lID + "','" + 0 +
+                               + filename.ToString() + "','" + StrPath.ToString() + "','" +  fileExtension.ToString() + "'" +
+                               ",'" + HUserName + "',getdate()"  + ",'" + HInterID + "','" + HEntryID + "','" + Sno + "','" + lID + "','" + filesize +
                         "') ");
                     }
                     else
@@ -389,8 +502,22 @@
                 else
                 {
                     Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
-                    files.SaveAs(fileurl);
-                    string StrPath = "/files/" + HBillNo + "/" + filename;
+                    files.SaveAs(fileurl);                    
+                    string StrPath = "";
+                    string Ret = "";
+                    //if (oSystemParameter.ShowBill(ref Ret))
+                    //{
+                    //    if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
+                    //    {
+                    //        StrPath = "D:/缃戠珯鍙戝竷/MES/MES娴嬭瘯/LAYUI/Files/SOP/" + HBillNo + "/" + filename;
+                    //    }
+                    //    else
+                    //    {
+                    //        StrPath = "/files/SOP/" + HBillNo + "/" + filename;
+                    //    }
+                    //}
+                    StrPath = "/files/SOP/" + HBillNo + "/" + filename;
+
                     if (File.Exists(fileurl))
                     {
                         //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
@@ -398,8 +525,8 @@
                         oCN.RunProc("Insert into Gy_SOPBillSub2 (HFileName,HPath,HFileType" +
                                      ",HUpMan,HUpTime,HInterID,HEntryID,HSno,HFileID,HFileSize" +
                                     ") values('"
-                                     + filename.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
-                                     ",'" + HUserName + "',getdate()" + ",'" + 111 + "','" + 222 + "','" + 333 + "','" + 444 + "','" + 555 +
+                                     + filename.ToString() + "','" + StrPath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                     ",'" + HUserName + "',getdate()" + ",'" + HInterID + "','" + HEntryID + "','" + Sno + "','" + lID + "','" + filesize +
                                     "') ");
                     }
                     else
@@ -416,5 +543,129 @@
             return Result_Ob;
         }
 
+
+        #region 浣滀笟鎸囧涔︾紪杈�
+     
+        [Route("Gy_SOPBill/GetGy_SOPEdit")]
+        [HttpGet]
+        public object GetSB_EquipICMOTechParamBill_Json(Int64 HInterID, string HMaker)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_SOPBill_Edit", 3, false, HMaker))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //杩斿洖鍒楄〃淇℃伅
+                ds = oCN.RunProcReturn("exec h_p_Gy_SOPBill_Edit " + HInterID, "h_p_Gy_SOPBill_Edit");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌浣滀笟鎸囧涔︼紝璇峰埛鏂版暟鎹悗閲嶆柊閫夋嫨锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "杩斿洖浣滀笟鎸囧涔︿俊鎭け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        /// <summary>
+        /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Gy_SOPBill/GetFilelist")]
+        [HttpGet]
+        public object GetFilelist(string HBillNo,string HInterID)
+        {
+            string Ret = "";
+            var url = "";
+            if (oSystemParameter.ShowBill(ref Ret))
+            {
+                if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
+                {
+                    url = "D:/缃戠珯鍙戝竷/MES/MES娴嬭瘯/LAYUI/Files/SOP/" + HBillNo + "/" ;
+                }
+                else
+                {
+                    url = "/files/SOP/" + HBillNo + "/";
+                }
+            }
+            try
+            {
+                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from Gy_SOPBillSub2 where HInterID='" + HInterID + "'", "Gy_SOPBillSub2");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁ID锛屽垹闄ゆ枃浠�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Gy_SOPBillEditController/DeleteFile")]
+        [HttpGet]
+        public object DeleteFile(string HFileID, string HPath)
+        {
+            try
+            {
+                // 鍒犻櫎鏁版嵁搴撹褰�
+                oCN.RunProc("delete from Gy_SOPBillSub2 where HItemID =" + HFileID);
+           
+                //File.Delete(HPath);      //鍒犻櫎鎸囧畾鏂囦欢
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1