From 4ec68e6c86410cc5b932e6c964e8c88ba49a54da Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期二, 30 十二月 2025 11:00:26 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Sc_MouldRepairInBillListController.cs |  410 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 358 insertions(+), 52 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
index ea72be2..08cb6d2 100644
--- a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
+++ b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -2070,7 +2070,6 @@
                     return objJsonResult;
                 }
 
-                sWhere = sWhere.Replace("'", "''");
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
@@ -2078,6 +2077,7 @@
                 }
                 else
                 {
+                    sWhere = sWhere.Replace("'", "''");
                     ds = oCN.RunProcReturn("exec h_p_IF_SellOutBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_IF_SellOutBillList");
                 }
 
@@ -2089,12 +2089,24 @@
                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
 
-                objJsonResult.code = "1";
-                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.list = columnNameList;
-                objJsonResult.data = ds.Tables[0];
-                return objJsonResult;
+                if(ds.Tables[0].Rows.Count > 0)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.list = columnNameList;
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.list = columnNameList;
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+                
             }
             catch (Exception ex)
             {
@@ -10369,13 +10381,14 @@
                     return objJsonResult;
                 }
 
-                sWhere = sWhere.Replace("'", "''");
+                
                 if (sWhere == null || sWhere.Equals(""))
                 {
                     ds = oCN.RunProcReturn("exec h_p_Sc_MouldScrapOutHouseBillList " + page + "," + size + ",''", "h_p_Sc_MouldScrapOutHouseBillList");
                 }
                 else
-                {
+                {   
+                    sWhere = sWhere.Replace("'", "''");
                     ds = oCN.RunProcReturn("exec h_p_Sc_MouldScrapOutHouseBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldScrapOutHouseBillList");
                 }
 
@@ -10638,6 +10651,7 @@
         [HttpPost]
         public object SaveGetMouldScrapOutHouseBillList([FromBody] JObject msg)
         {
+            oCN.BeginTran();
             DAL.ClsSc_MouldScrapOutBill oBill = new DAL.ClsSc_MouldScrapOutBill();
 
             var _value = msg["msg"].ToString();
@@ -10754,14 +10768,40 @@
 
                 if (bResult)
                 {
-                    objJsonResult.code = "0";
+                    if (oSystemParameter.omodel.WMS_CampanyName == "娴峰煄")
+                    {
+
+                        if (setOutBill(msg, ref DBUtility.ClsPub.sErrInfo))
+                        {
+                            oCN.Commit();
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //鎴愬姛锛�
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            oCN.RollBack();
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "閲戣澏鍗曟嵁淇濆瓨澶辫触锛�"+ DBUtility.ClsPub.sErrInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    oCN.Commit();
+                    objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //鎴愬姛锛�
                     objJsonResult.data = null;
                     return objJsonResult;
+                    
+                   
                 }
                 else
                 {
+                    oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
@@ -10771,6 +10811,7 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.Message;
@@ -10778,6 +10819,90 @@
                 return objJsonResult;
             }
         }
+
+        public bool setOutBill([FromBody] JObject msg, ref string sErrInfo)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string sMainStr = sArray[0].ToString();         //涓昏〃鏁版嵁
+            string sSubStr = sArray[1].ToString();          //瀛愯〃鏁版嵁
+            string HMaker = sArray[2].ToString();           //鍒跺崟浜�
+            long id;
+            DataSet ds = oCn.RunProcReturn("select max(HInterID) HInterID from Sc_MouldStockBillMain ", "Sc_MouldStockBillMain");
+            try
+            {
+                //List<Model.ClsKf_OtherOutBillMain> lsmain = new List<Model.ClsKf_OtherOutBillMain>();
+                ListModels oListModels = new ListModels();
+                sMainStr = sMainStr.Replace("\\", "");
+                sMainStr = sMainStr.Replace("\n", "");
+                sMainStr = "[" + sMainStr.ToString() + "]";
+                //lsmain = oListModels.getOtherOutBillMainByJson(sMainStr);
+                List<Model.ClsSc_MouldStockBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldStockBillMain>>(sMainStr);
+                //lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                //lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                string sSourceBillType = "3832";
+                if(lsmain[0].HInterID==0)
+                {
+                    
+                    id = Convert.ToInt64(ds.Tables[0].Rows[0]["HInterID"]);
+                
+                WebAPI.WebS.ClsKf_OtherOutBillMain websLsmain = new WebS.ClsKf_OtherOutBillMain();
+                websLsmain.HInterID = id;
+                websLsmain.HDate = lsmain[0].HDate;
+                websLsmain.HBillNo = lsmain[0].HBillNo;
+                websLsmain.HSupID = lsmain[0].HSupID;
+                websLsmain.HDeptID = lsmain[0].HDeptID;
+                websLsmain.HEmpID = lsmain[0].HKeeperID;
+                websLsmain.HKeeperID = lsmain[0].HKeeperID;
+                websLsmain.HSecManagerID = lsmain[0].HSecManagerID;
+                websLsmain.HRemark = lsmain[0].HRemark??"test";
+                websLsmain.HMaker = lsmain[0].HMaker;
+                websLsmain.HBillerID = 0;
+                websLsmain.HSTOCKORGID = 100038;
+                websLsmain.HOWNERID = 100038;
+                websLsmain.HBillType = "1206";//鍥哄畾鍊�
+                websLsmain.HBillSubType = "test";
+                WebS.WebService1 oWebs = new WebS.WebService1();
+                WebS.ClsXt_SystemParameterMain oSystemParameterMain = new WebS.ClsXt_SystemParameterMain();
+                if (oWebs.set_SaveOtherOutBill_New_haicheng(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //鎴愬姛锛�
+                    objJsonResult.data = null;
+                    return true;
+                }
+                else
+                {
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //澶辫触锛�
+                    objJsonResult.data = null;
+                    return false;
+                }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "璇蜂粠鏂板鐣岄潰鐢熸垚閲戣澏鍗曟嵁" +DBUtility.ClsPub.sErrInfo;  //澶辫触锛�
+                    objJsonResult.data = null;
+                    return false;
+                }
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "涓婁紶澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return false;
+            }
+        }
+
         #endregion
 
         #region [妯″叿澶勭悊鍑哄簱鍗曞垹闄ゅ姛鑳絔
@@ -14756,7 +14881,7 @@
         #endregion
 
         #region 鍣ㄥ叿淇濆吇璁板綍鎷嶇収涓婁紶
-        [Route("Sc_MouldMaintainBill/UploadFile")]
+        [Route("Sc_MouldMaintainBill/UploadFile_Maintain")]
         [HttpPost]
         public object UploadFile_Maintain()
         {
@@ -15511,56 +15636,20 @@
         }
         #endregion
 
-
-        #region[缂栬緫鏃惰幏鍙栬〃澶存暟鎹甝
-        [Route("Gy_QCVerificationBillMain/Gy_QCVerificationBillMainCheckDetai")]
+        #region[缂栬緫鏃惰幏鍙栨暟鎹甝
+        [Route("Gy_QCVerificationBillMain/Gy_QCVerificationBillDetail")]
         [HttpGet]
-        public ApiResult<DataSet> Gy_QCVerificationBillMainCheckDetai(string HID)
+        public ApiResult<DataSet> Gy_QCVerificationBillDetail(string HID)
         {
             if (string.IsNullOrEmpty(HID))
                 return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
             SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCVerificationBillMain_Edit  where hmainid= " + HID + " ", "h_v_Gy_QCVerificationBillMain");
+            var dataSet = oCN.RunProcReturn("select  * from h_v_Gy_QCVerificationBillMain_Edit  where hmainid= " + HID + " ", "h_v_Gy_QCVerificationBillMain_Edit");
             if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                 return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄥ崟鍙�" };
             return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
         }
-        #endregion
-
-        #region[缂栬緫鏃惰幏鍙栬〃浣撴暟鎹甝
-        [Route("Gy_QCVerificationBillMain/SGy_QCVerificationBillMainListProjectDetai")]
-        [HttpGet]
-        public object SGy_QCVerificationBillMainListProjectDetai(string sqlWhere)
-        {
-            DataSet ds;
-            List<object> list = new List<object>();
-            try
-            {
-                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-
-                string sql = "select HInspectInstruMentID,妫�楠屼华鍣ㄤ唬鐮� HInspectInstruMentNumber,妫�楠屼华鍣ㄥ悕绉� HInspectInstruMentName,鐢熸晥鏃ユ湡 HBeginDate,澶辨晥鏃ユ湡 HEndDate,鏍″噯鐘舵�� HHCalibrationStatus  from h_v_Gy_QCVerificationBillMain_Edit where 1 = 1 " + sqlWhere;
-                ds = oCN.RunProcReturn(sql, "h_v_Gy_QCVerificationBillMain_Edit");
-
-                list.Add(ds.Tables[0]);
-
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                objJsonResult.data = null;
-                objJsonResult.list = list;
-
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
-                objJsonResult.data = null;
-            }
-            return objJsonResult;
-        }
-        #endregion
-
+        #endregion       
 
         #region 鍣ㄥ叿鏍″噯璁板綍鍗� 淇濆瓨/缂栬緫
         
@@ -15671,6 +15760,223 @@
             }
         }
         #endregion
+
+        #region 鍣ㄥ叿鏍″噯璁板綍 鏂囦欢涓婁紶
+        [Route("Gy_QCVerificationBillMain/UploadFile_Gy_QCVerification")]
+        [HttpPost]
+        public object UploadFile_Gy_QCVerification()
+        {
+            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 Ret = "";
+            if (oSystemParameter.ShowBill(ref Ret))
+            {
+                if (oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒")
+                {
+                    path = "D:/缃戠珯鍙戝竷/LAYUI/Files/Gy_QCVerification/" + HBillNo;
+                }
+                else
+                {
+                    path = HttpContext.Current.Server.MapPath("~/../Files/Gy_QCVerification/" + HBillNo);
+                }
+            }
+            dynamic dyResult = UploadFile_Gy_QCVerification(files, path, HBillNo, HRemark, HUserName);
+            if (dyResult != null && dyResult.result == 1)
+            {
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "涓婁紶鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = dyResult.returnval;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+
+        public dynamic UploadFile_Gy_QCVerification(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName)
+        {
+            dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" };
+            string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞
+            string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚�
+            string filename = files.FileName;//鏂囦欢鍚�
+            string fileSavePath = path;// 涓婁紶淇濆瓨璺緞
+            int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+            int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
+            try
+            {
+                if (files == null || files.ContentLength <= 0)
+                {
+                    Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" };
+                    return Result_Ob;
+                }
+                if (filesize >= Maxsize)
+                {
+                    Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" };
+                    return Result_Ob;
+                }
+
+                string fileurl = Path.Combine(fileSavePath, filename);
+                if (Directory.Exists(fileurl) == true)  //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�  
+                {
+                    Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" };
+                    return Result_Ob;
+                }
+                //鍒犻櫎鏁版嵁琛ㄦ暟鎹�
+                ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+                if (Directory.Exists(path))
+                {
+                    File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                    files.SaveAs(fileurl);
+                    string StrPath = "";
+
+                    string Ret = "";
+                    if (oSystemParameter.ShowBill(ref Ret))
+                    {
+                        if (oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒")
+                        {
+                            StrPath = "D:/缃戠珯鍙戝竷/LAYUI/Files/Gy_QCVerification/" + HBillNo + "/" + filename;
+                        }
+                        else
+                        {
+                            StrPath = "/files/Gy_QCVerification/" + HBillNo + "/" + filename;
+                        }
+                    }
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+                else
+                {
+                    Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/Gy_QCVerification/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+
+            }
+            catch (Exception e)
+            {
+                Result_Ob = new { result = 0, returnval = e.Message };
+            }
+            return Result_Ob;
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Gy_QCVerificationBillMain/Gy_QCVerification_Filelist")]
+        [HttpGet]
+        public object Gy_QCVerification_Filelist(string HBillNo)
+        {
+            string Ret = "";
+            var url = "";
+            if (oSystemParameter.ShowBill(ref Ret))
+            {
+                if (oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒")
+                {
+                    url = "D:/缃戠珯鍙戝竷/LAYUI/Files/Gy_QCVerification/" + HBillNo + "/";
+                }
+                else
+                {
+                    url = fileip + "/Files/Gy_QCVerification/" + HBillNo + "/";
+                }
+            }
+            try
+            {
+                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList");
+                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_QCVerificationBillMain/Gy_QCVerification_DeleteFilelist")]
+        [HttpGet]
+        public object Gy_QCVerification_DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName)
+        {
+            try
+            {
+
+                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
+       
+                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;
+            }
+        }
+
+
+        #endregion
+
+
         #endregion
 
 

--
Gitblit v1.9.1