From cbc9eb593e382ed40c66b3c38d279c751b10e0fb Mon Sep 17 00:00:00 2001
From: WYB <908761037@qq.com>
Date: 星期四, 15 四月 2021 21:32:47 +0800
Subject: [PATCH] 不良品评审保存逻辑完成

---
 WebAPI/ListModels.cs                                |   24 ++++
 WebAPI/Controllers/Sc_ProcessMangementController.cs |  134 ++++++++++++++++++++++++++
 WebAPI/Controllers/WebAPIController.cs              |  102 ++++++++++----------
 WebAPI/Properties/PublishProfiles/API.pubxml.user   |    6 
 4 files changed, 213 insertions(+), 53 deletions(-)

diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs
index daf2fce..9b16fff 100644
--- a/WebAPI/Controllers/Sc_ProcessMangementController.cs
+++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -896,6 +896,140 @@
         }
 
 
+        /// <summary>
+        /// 淇濆瓨涓嶈壇璇勫鍗曚俊鎭�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveBadReasonList")]
+        [HttpPost]
+        public object SaveBadReasonList([FromBody] JObject msg) 
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+
+            string UserName="";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DAL.ClsQC_NoPassProdCheckBill oBill = new DAL.ClsQC_NoPassProdCheckBill();
+                List<Model.ClsQC_NoPassProdCheckBillMain> lsmain = new List<Model.ClsQC_NoPassProdCheckBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_NoPassProdCheckMain(msg2);
+                foreach (Model.ClsQC_NoPassProdCheckBillMain oItem in lsmain)
+                {
+                    //oItem.HMaker = "";
+                    UserName=oItem.HMaker;
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                    //oItem.HCurID = 1;
+                    //oItem.HExRate = 1;
+                    oItem.HMainSourceInterID = oItem.HInterID;
+                    oItem.HInterID = 0;
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate)=="")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈塪anju鏃ユ湡锛屾棤娉曚繚瀛橈紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }             
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsQC_NoPassProdCheckBillSub> ls = new List<Model.ClsQC_NoPassProdCheckBillSub>();
+                ls = oListModels.getObjectByJson_NoPassProdCheckSub(msg3);
+                int i = 0;
+                foreach (Model.ClsQC_NoPassProdCheckBillSub oItemSub in ls)
+                {
+                    i++;
+                    if (oItemSub.HBadQty<=0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺" + i.ToString() + "琛屼笉鑹瘎瀹℃暟閲忎笉澶т簬0鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if ((double)oItemSub.HBadQty >oBill.omodel.HPlanQty )
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺" + i.ToString() + "琛屾暟閲忎笉鑳藉ぇ浜庝笉鑹暟閲忥紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(oItemSub.HWasterReasonName)=="")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺" + i.ToString() + "琛屾湭濉啓涓嶈壇鍘熷洜锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    oItemSub.HEntryID = i;
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HRemark = "";
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HCloseType = false;
+                    oBill.DetailColl.Add(oItemSub);
+                    
+                }
+                //淇濆瓨鍓嶅垽鏂�(鍗曟嵁鍙烽噸澶嶏紝绗斿綍椤圭洰)
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // 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 = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    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)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+
 
 
      
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 43c62a4..84bae22 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -999,61 +999,63 @@
         /// 鑾峰彇宸ュ簭璁″垝鍗曞垪琛�
         /// </summary>
         /// <returns></returns>
-        //[Route("Web/GetPlanList_Json")]
-        //[HttpGet]
-        //public object GetPlanList_Json(string Billno)
-        //{
-        //    //sWhere = " Where HStopFlag=0  and HEndFlag=1";
-        //    //sWhere = " Where HStopFlag=0  and HEndFlag=1  and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
-        //    if (Billno != "")
-        //    {
-        //        sWhere = sWhere + " and ( 鍗曟嵁鍙� like '%" + Billno + "%' ) ";
-        //    }
-        //    try
-        //    {
-        //        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        //        if (sWhere == null || sWhere.Equals(""))
+        [Route("Web/GetPlanList_Json")]
+        [HttpGet]
+        public object GetPlanList_Json(string Billno)
+        {
+            //sWhere = " Where HStopFlag=0  and HEndFlag=1";
+            //sWhere = " Where HStopFlag=0  and HEndFlag=1  and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
+            if (Billno != "")
+            {
+                sWhere = sWhere + " and ( 鍗曟嵁鍙� like '%" + Billno + "%' ) ";
+            }
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sWhere == null || sWhere.Equals(""))
 
-        //        {
-        //            ds = oCN.RunProcReturn("Select HItemID,HNumber ,HName  from h_v_Sc_ProcessPlanList where HStopflag=0 Order by HItemID ", "Gy_BadReason");
-        //        }
-        //        else
-        //        {
-        //            string sql1 = "Select HItemID,HNumber ,HName  from Gy_BadReason where HStopflag=0 and HEndFlag=1 ";
-        //            string sql = sql1 + sWhere;
-        //            ds = oCN.RunProcReturn(sql, "Gy_BadReason");
-        //        }
+                {
+                    ds = oCN.RunProcReturn("select hmainid,hsubid,鍗曟嵁鍙�,HMaterID,鐗╂枡浠g爜,鐗╂枡鍚嶇О,HCenterID,宸ヤ綔涓績,瑙勬牸鍨嬪彿,璁″垝鏁伴噺 from h_v_Sc_ProcessPlanList", "h_v_Sc_ProcessPlanList");
+                }
+                else
+                {
+                    string sql1 = "select hmainid,hsubid,鍗曟嵁鍙�,HMaterID,鐗╂枡浠g爜,鐗╂枡鍚嶇О,HCenterID,宸ヤ綔涓績,瑙勬牸鍨嬪彿,璁″垝鏁伴噺 from h_v_Sc_ProcessPlanList where 1=1 ";
+                    string sql = sql1 + sWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessPlanList");
+                }
 
-        //        //ds = webserver.GetUnitList(sWhere, ref DBUtility.ClsPub.sErrInfo);
+                //ds = webserver.GetUnitList(sWhere, ref DBUtility.ClsPub.sErrInfo);
 
 
-        //        if (ds == null || ds.Tables[0].Rows.Count <= 0)
-        //        {
-        //            objjson.code = "0";
-        //            objjson.count = 0;
-        //            objjson.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sErrInfo;
-        //            objjson.data = null;
-        //            return objjson;
-        //        }
-        //        else
-        //        {
-        //            objjson.code = "0";
-        //            objjson.count = 1;
-        //            objjson.Message = "鑾峰彇鎴愬姛!";
-        //            objjson.data = ds.Tables[0];
-        //            return objjson;
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sErrInfo;
+                    objjson.data = null;
+                    return objjson;
+                }
+                else
+                {
+                    objjson.code = "0";
+                    objjson.count = 1;
+                    objjson.Message = "鑾峰彇鎴愬姛!";
+                    objjson.data = ds.Tables[0];
+                    return objjson;
+                }
+            }
+            catch (Exception ex)
+            {
 
-        //        objjson.code = "0";
-        //        objjson.count = 0;
-        //        objjson.Message = "鑾峰彇澶辫触" + ex.ToString();
-        //        objjson.data = null;
-        //        return objjson;
-        //    }
-        //}
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "鑾峰彇澶辫触" + ex.ToString();
+                objjson.data = null;
+                return objjson;
+            }
+        }
+
+
 
         #endregion
     }
diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs
index c1e63f1..7c1145e 100644
--- a/WebAPI/ListModels.cs
+++ b/WebAPI/ListModels.cs
@@ -200,5 +200,29 @@
             return list;
         }
 
+        /// <summary>
+        /// 澶勭悊鏂板涓嶈壇璇勫涓昏〃鐨刯son
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Model.ClsQC_NoPassProdCheckBillMain> getObjectByJson_NoPassProdCheckMain(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Model.ClsQC_NoPassProdCheckBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_NoPassProdCheckBillMain>>(jsonString);
+            return list;
+        }
+
+        /// <summary>
+        /// 澶勭悊鏂板涓嶈壇璇勫瀛愯〃鐨刯son
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Model.ClsQC_NoPassProdCheckBillSub> getObjectByJson_NoPassProdCheckSub(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Model.ClsQC_NoPassProdCheckBillSub> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsQC_NoPassProdCheckBillSub>>(jsonString);
+            return list;
+        }
+
     }
 }
\ No newline at end of file
diff --git a/WebAPI/Properties/PublishProfiles/API.pubxml.user b/WebAPI/Properties/PublishProfiles/API.pubxml.user
index 540d76c..fe41f31 100644
--- a/WebAPI/Properties/PublishProfiles/API.pubxml.user
+++ b/WebAPI/Properties/PublishProfiles/API.pubxml.user
@@ -163,10 +163,10 @@
       <publishTime>11/24/2014 11:18:48</publishTime>
     </File>
     <File Include="bin/WebAPI.dll">
-      <publishTime>04/14/2021 19:13:54</publishTime>
+      <publishTime>04/15/2021 21:07:29</publishTime>
     </File>
     <File Include="bin/WebAPI.pdb">
-      <publishTime>04/14/2021 19:13:54</publishTime>
+      <publishTime>04/15/2021 21:07:29</publishTime>
     </File>
     <File Include="bin/WebAPI.XmlSerializers.dll">
       <publishTime>02/04/2021 21:35:21</publishTime>
@@ -340,7 +340,7 @@
       <publishTime>03/26/2021 14:35:48</publishTime>
     </File>
     <File Include="Web.config">
-      <publishTime>04/14/2021 19:15:03</publishTime>
+      <publishTime>04/15/2021 21:08:50</publishTime>
     </File>
   </ItemGroup>
 </Project>
\ No newline at end of file

--
Gitblit v1.9.1