From a91fdba94705dd25cecccc7a4a5dcc2b3f2c09a6 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期一, 22 十二月 2025 16:16:00 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Sc_MouldRepairInBillListController.cs |  538 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 447 insertions(+), 91 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
index b64edae..f19f304 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)
             {
@@ -11684,9 +11696,9 @@
                 sSubStr = sSubStr.Replace("\\", "");
                 sSubStr = sSubStr.Replace("\n", "");
                 sSubStr = "[" + sSubStr.ToString() + "]";
-                List<Model.ClsSc_MouldStockBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldStockBillSub>>(sSubStr);
+                List<Model.ClsSc_MouldProdBackBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_MouldProdBackBillSub>>(sSubStr);
                 int i = 0;
-                foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls)
+                foreach (Model.ClsSc_MouldProdBackBillSub oItemSub in ls)
                 {
                     i++;
                     oItemSub.HEntryID = i;
@@ -14756,7 +14768,7 @@
         #endregion
 
         #region 鍣ㄥ叿淇濆吇璁板綍鎷嶇収涓婁紶
-        [Route("Sc_MouldMaintainBill/UploadFile")]
+        [Route("Sc_MouldMaintainBill/UploadFile_Maintain")]
         [HttpPost]
         public object UploadFile_Maintain()
         {
@@ -14990,6 +15002,7 @@
 
 
         #region 鍣ㄥ叿鏍″噯璁板綍鍗�
+
         #region 妯″叿鏍″噯璁板綍鍗曡〃鍒嗛〉鍒楄〃
         [Route("Gy_QCVerificationBillMain/GetListPage")]
         [HttpGet]
@@ -14998,7 +15011,7 @@
             try
             {
                 List<object> columnNameList = new List<object>();
-                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -15055,7 +15068,7 @@
         public object DeltetGy_QCVerificationBillMain(string HInterID, string user)
         {
             //缂栬緫鏉冮檺
-            if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, user))
+            if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Delete", 1, false, user))
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
@@ -15096,7 +15109,7 @@
                 }
 
                 //鍒犻櫎鍓嶆帶鍒�=========================================      
-                string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
                 ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeDelCtrl");
                 if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                 {
@@ -15117,7 +15130,7 @@
                 }
                 //==================================================================================  
 
-                bool IsDete = oBill.DeleteBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
+                bool IsDete = oBill.DeleteBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
 
                 if (IsDete)
                 {
@@ -15148,7 +15161,7 @@
         }
         #endregion
 
-        #region [妯″叿缁翠慨鍗曞鏍搞�佸弽瀹℃牳]
+        #region [鍣ㄥ叿鏍″噯璁板綍鍗曞鏍搞�佸弽瀹℃牳]
         /// <summary>
         /// 
         /// </summary>
@@ -15160,7 +15173,7 @@
         [HttpGet]
         public object AuditQCVerificationBillMain(int HInterID, int IsAudit, string CurUserName)
         {
-            string ModRightNameCheck = "Sb_MouldRepairWorkBill_Check";
+            string ModRightNameCheck = "Gy_QCVerificationBillMain_Check";
             DBUtility.ClsPub.CurUserName = CurUserName;
             try
             {
@@ -15237,8 +15250,8 @@
                 if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
                     //瀹℃牳鍓嶆帶鍒�=========================================      
-                    string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
-                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeCheckCtrl");
+                    string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_QCVerificationBill_BeforeCheckCtrl");
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -15260,7 +15273,7 @@
                     }
                     //==================================================================================  
 
-                    if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
+                    if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 1;
@@ -15272,8 +15285,8 @@
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
                     //鍙嶅鏍稿墠鎺у埗=========================================        
-                    string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
-                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeUnCheckCtrl");
+                    string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_QCVerificationBill_BeforeUnCheckCtrl");
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -15293,7 +15306,7 @@
                     }
                     //===========================================================         
 
-                    if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterUnCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
+                    if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterUnCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 1;
@@ -15319,68 +15332,217 @@
         }
         #endregion
 
-
-        #region[缂栬緫鏃惰幏鍙栬〃澶存暟鎹甝
-        [Route("Gy_QCVerificationBillMain/Gy_QCVerificationBillMainCheckDetai")]
+        #region 鍣ㄥ叿鏍″噯璁板綍鍗� 鍏抽棴/鍙嶅叧闂�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param>
+        /// <param name="CurUserName">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MouldMaintainBill/CloseGy_QCVerificationBill")]
         [HttpGet]
-        public ApiResult<DataSet> Gy_QCVerificationBillMainCheckDetai(string HID)
+        public object CloseGy_QCVerificationBill(int HInterID, int IsAudit, string CurUserName)
         {
-            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  where hmainid= " + HID + " ", "h_v_Gy_QCVerificationBillMain");
-            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, ds1;
-            List<object> list = new List<object>();
+            string ModRightNameCheck = "Gy_QCVerificationBillMain_Close";
+            DBUtility.ClsPub.CurUserName = CurUserName;
             try
             {
-                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
-                string sql = "select HInspectInstruMentID,妫�楠屼华鍣ㄤ唬鐮� HInspectInstruMentNumber,妫�楠屼华鍣ㄥ悕绉� HInspectInstruMentName,鐢熸晥鏃ユ湡 HBeginDate,澶辨晥鏃ユ湡 HEndDate,鏍″噯鐘舵�� HHCalibrationStatus  from h_v_Gy_QCVerificationBillMain where 1 = 1 " + sqlWhere;
-                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
 
-               
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsGy_QCVerificationBillMain oBill = new DAL.ClsGy_QCVerificationBillMain();           //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
 
-                list.Add(ds.Tables[0]);
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅叧闂垽鏂�
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                objJsonResult.data = null;
-                objJsonResult.list = list;
 
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (IsAudit == 0) //鍏抽棴鎻愪氦
+                {
+                    string sql = "";
+                    //鍏抽棴鍓嶆帶鍒�===============================================Begin===================================================================
+                    sql = "exec h_p_Gy_QCVerificationBill_BeforeCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Gy_QCVerificationBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍏抽棴鍓嶆帶鍒�===============================================End===================================================================
+
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅叧闂彁浜�
+                {
+                    string sql = "";
+                    //鍙嶅叧闂墠鎺у埗===============================================Begin===================================================================
+                    sql = "exec h_p_Gy_QCVerificationBill_BeforeUnCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Gy_QCVerificationBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍙嶅叧闂墠鎺у埗===============================================End===================================================================
+
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
             }
             catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString();
                 objJsonResult.data = null;
+                return objJsonResult;
             }
-            return objJsonResult;
         }
         #endregion
 
+        #region[缂栬緫鏃惰幏鍙栨暟鎹甝
+        [Route("Gy_QCVerificationBillMain/Gy_QCVerificationBillDetail")]
+        [HttpGet]
+        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  * 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 妯″叿缁翠慨璁板綍鍗曚繚瀛�/缂栬緫
-        /// <summary>
-        /// 淇濆瓨妯″叿缁翠慨鍗�
-        /// </summary>
-        /// <param name="msg"></param>
-        /// <returns></returns>
-        [Route("Gy_QCVerificationBillMain/SaveGetMQCVerificationBillList")]
+        #region 鍣ㄥ叿鏍″噯璁板綍鍗� 淇濆瓨/缂栬緫
+        
+        [Route("Gy_QCVerificationBillMain/SaveGetGy_QCVerificationBill")]
         [HttpPost]
-        public object SaveGetMQCVerificationBillList([FromBody] JObject msg)
+        public object SaveGetGy_QCVerificationBill([FromBody] JObject msg)
         {
             var _value = msg["msg"].ToString();
             string msg1 = _value.ToString();
@@ -15388,14 +15550,12 @@
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
             string msg4 = sArray[2].ToString();
-            //string msg5 = sArray[3].ToString();
 
 
-            string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
-                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4))
+                if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Edit", 1, false, msg4))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -15412,20 +15572,13 @@
                 foreach (Model.ClsGy_QCVerificationBillMain oItem in lsmain)
                 {
                     oItem.HMaker = msg4;
-                    UserName = msg4;  //鍒跺崟浜�
+                    DBUtility.ClsPub.CurUserName = msg4;  //鍒跺崟浜�
                     oItem.HBillType = "3321";
-                    oItem.HBillSubType = "3321";
-                    //oItem.HBillNo = "";    //鍗曟嵁鍙�
-                    //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
+                    oItem.HBillSubType = "3321";                   
                     oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
-                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
-                    //oItem.HEquipID = 0;    //璁惧ID(Gy_EquipMent)
-                    //oItem.HPeriod = 0;
-                    oItem.HCheckEmp = oItem.HEmpID;           //缁翠慨浜�(Gy_Employee)
-                    //oItem.HDeptID = 0;        //缁翠慨閮ㄩ棬(Gy_Department)
-                    //oItem.HMainSourceInterID = oItem.HInterID;
-
-                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));                  
+                    oItem.HCheckEmp = oItem.HEmpID;          
                     if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                     {
                         objJsonResult.code = "0";
@@ -15450,19 +15603,8 @@
 
                     i++;
                     oItem.HEntryID = i;
-                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
                     oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                     oItem.HCloseType = false;   //鍏抽棴绫诲瀷
-                    //oItem.HInspectInstruMentID =1;         //澶囨敞
-                    //oItem.HRelationQty = 0;     //鍏宠仈鏁伴噺
-                    //oItem.HBeginDate = DateTime.Now.ToString();     //鍏宠仈鏁伴噺
-                    //oItem.HEndDate = DateTime.Now.AddYears(1).ToString();     //鍏宠仈鏁伴噺
-                    //oItem.HHCalibrationStatus = "鍚堟牸";     //鍏宠仈鏁伴噺
-                    //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦
-                    //oItemSub.HRepairID = 0;       //缁翠慨椤圭洰
-                    //oItemSub.HRepairExplanation ="";   //缁翠慨瑕佹眰
-                    //oItemSub.HManagerID = 0;   //璐熻矗浜篒D
-                    //oItemSub.HMoney = 0;        //缁翠慨璐圭敤
                     oBill.DetailColl.Add(oItem);
 
                 }
@@ -15472,7 +15614,6 @@
                 bool bResult;
                 if (oBill.omodel.HInterID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
@@ -15484,7 +15625,6 @@
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -15507,6 +15647,222 @@
             }
         }
         #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);
+                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/Gy_QCVerification/" + HSourceBillNo), HFileName);
+                File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                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