From 649122a1ff1d7ef30f087e726d37948f65bede8a Mon Sep 17 00:00:00 2001
From: YL <YL@LAPTOP-SE03PLUR>
Date: 星期三, 08 九月 2021 18:38:41 +0800
Subject: [PATCH] 报工台,上料防错单保存、自动审核、反审核

---
 WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs |  151 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 115 insertions(+), 36 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
index 5f84dac..af0c38b 100644
--- a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
@@ -26,6 +26,7 @@
         public DAL.ClsSc_MESMaterToSourceBill BillOld = new DAL.ClsSc_MESMaterToSourceBill();   //瀵瑰簲鍗曟嵁绫�
 
 
+        #region 涓婃枡鏀鹃敊鍗昗eb鍒楄〃鏌ヨ
         /// <summary>
         /// 杩斿洖鐢熶骇涓婃枡鍗曞垪琛�
         ///鍙傛暟锛歴tring sql銆�
@@ -52,14 +53,14 @@
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
-                    objJsonResult.data = null;
+                    objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
                 }
                 else
                 {
                     objJsonResult.code = "1";
                     objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.Message = "鏌ヨ鏁版嵁鎴愬姛锛�";
                     objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
                 }
@@ -73,8 +74,67 @@
                 return objJsonResult;
             }
         }
+        #endregion
 
-        //
+        #region 涓婃枡闃查敊鍗曠紪杈戞椂鑾峰彇琛ㄥご鏁版嵁
+        [Route("Sc_MaterToSourceBill/Sc_MaterToSourceBillListCheckDetai")]
+        [HttpGet]
+        public ApiResult<DataSet> Sc_MaterToSourceBillListCheckDetai(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_Sc_MaterToSourceBillMain  where hmainid= " + HID + " ", "h_v_Sc_MaterToSourceBillMain");
+            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("Sc_MaterToSourceBill/Sc_MaterToSourceBillListProjectDetai")]
+        [HttpGet]
+        public object Sc_MaterToSourceBillListProjectDetai(string HInterID)
+        {
+
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
+            string Swhere = "";
+            try
+            {
+                if (HInterID != "" || HInterID != null)
+                {
+                    Swhere = " and hmainid='" + HInterID + "'";
+                }
+                else
+                {
+                    Swhere = HInterID;
+                }
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //鑾峰彇閰嶆枡璁板綍缂栬緫鏁版嵁
+                string sql = "select 鏉″舰鐮� HBarCode,HMaterID,鐗╂枡浠g爜 HNumber,鐗╂枡鍚嶇О HName,瑙勬牸鍨嬪彿 HModel,HUnitID,璁¢噺鍗曚綅鍚嶇О HUnitName,鏁伴噺 HQty   from h_v_Sc_MaterToSourceBillSub where 1 = 1 " + Swhere + "";
+                ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillSub");
+                //鑾峰彇娌诲叿璁板綍缂栬緫鏁版嵁
+                //string sql1 = "select HMaterID, 閰嶄欢浠g爜 HMaterNumber,閰嶄欢鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,HUnitID,鍗曚綅浠g爜 HUnitNumber,鍗曚綅鍚嶇О HUnitName,瀹為檯鐢ㄩ噺 HQty,鏍囧噯鐢ㄩ噺 HQtyMust,HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜� HManagerName,琛ㄤ綋澶囨敞 HRemark  from h_v_Sc_MouldMaintainBillList where 1 = 1 " + Swhere + "";
+                //ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainBillList");
+                list.Add(ds.Tables[0]);
+                //list.Add(ds1.Tables[0]);
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.list = list;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+            }
+            return objJsonResult;
+        }
+        #endregion
+
 
         #region  鎶ュ伐骞冲彴涓婃枡闃查敊鍗曞脊绐楁煡鎵炬暟鎹�
         [Route("Sc_MaterToSourceBill/GetMESMaterToSourceFrom")]
@@ -140,11 +200,14 @@
                 else 
                 {
                     //2.鍖归厤鐢ㄦ枡娓呭崟鐨勭墿鏂欑紪鐮佹槸鍚︿竴鑷�
-                    string sql = string.Format(@"select b.HMaterID,m.HNumber,m.HName,m.HModel,a.HQty HMQty, b.HQty,b.HUnitID,u.HName HUnitName   from sc_PPbomBillMain a
-                                                 inner join Sc_PPBomBillSub b on a.HInterID=b.HInterID
-                                                 left  join Gy_Material m on b.HMaterID=m.HItemID
-                                                 left  join Gy_Unit u on b.HUnitID=u.HItemID
-                                                 where a.HICMOInterID='" + HICMOInterID + "' and a.HICMOEntryID='"+ HICMOEntryID + "'");
+                    string sql = @"select '{0}' HBarCode,b.HMaterID,m.HNumber,m.HName,m.HModel,a.HQty HMQty, b.HQty,b.HUnitID,u.HName HUnitName   from sc_PPbomBillMain a
+                                                 inner join Sc_PPBomBillSub b on a.HInterID = b.HInterID
+                                                 left join Gy_Material m on b.HMaterID = m.HItemID
+                                                 left join Gy_Unit u on b.HUnitID = u.HItemID
+                                                 where a.HICMOInterID = '{1}' and a.HICMOEntryID = '{2}'";
+                    sql = string.Format(sql,HBarCode, HICMOInterID, HICMOEntryID);
+
+               
                     ds = oCN.RunProcReturn(sql, "Sc_PPBomBillSub");
                     if (ds.Tables[0].Rows.Count > 0) //鏈夌敤鏂欐竻鍗曡褰�
                     {
@@ -301,11 +364,24 @@
             ListModels oListModels = new ListModels();
             try
             {
+                //琛ㄥご鏁版嵁瀹炰緥鍖�
                 DAL.ClsSc_MESMaterToSourceBill oBill = new DAL.ClsSc_MESMaterToSourceBill();
                 List<Model.ClsSc_MaterToSourceBillMain> lsmain = new List<Model.ClsSc_MaterToSourceBillMain>();
                 msg2 = msg2.Replace("\\", "");
                 msg2 = msg2.Replace("\n", "");  //\n
                 lsmain = oListModels.getObjectByJson_Sc_MaterToSourceBillMain(msg2);
+
+                //閰嶆枡璁板綍琛ㄤ綋鏁版嵁瀹炰緥鍖�
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsSc_MaterToSourceBillSub> ls = new List<Model.ClsSc_MaterToSourceBillSub>();
+                ls = oListModels.getObjectByJson_Sc_MaterToSourceBillSub(msg3);
+
+                //閰嶄欢椤硅〃浣撴暟鎹疄渚嬪寲
+
                 foreach (Model.ClsSc_MaterToSourceBillMain oItem in lsmain)
                 {
                     if (refSav == "Add")
@@ -369,6 +445,11 @@
                     oItem.HProcExchInterID = 0; //娴佽浆鍗′富鍐呯爜
                     oItem.HProcExchEntryID = 0; //娴佽浆鍗″瓙鍐呯爜
                     oItem.HProcID = 0;          //宸ュ簭ID
+                    oItem.HMainSourceBillNo =oItem.HSourceBillNo;
+                    oItem.HMainSourceBillType = oItem.HSourceBillType;
+                    oItem.HMainSourceInterID = oItem.HSourceInterID;
+                    oItem.HMainSourceEntryID = oItem.HSourceEntryID;
+
 
                     if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                     {
@@ -378,36 +459,34 @@
                         objJsonResult.data = 1;
                         return objJsonResult;
                     }
+
+                    //寰幆閰嶆枡淇℃伅瀛愯〃
+                    int i = 0;
+                    foreach (Model.ClsSc_MaterToSourceBillSub oItemSub in ls)
+                    {
+
+                        i++;
+                        oItemSub.HEntryID = i;
+                        //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                        oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                        oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                                                       //oItemSub.HRemark = "";         //澶囨敞
+                        oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                        oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                                                       //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
+                                                       //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
+                        oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                        oItemSub.HScanDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));//  --鎵爜鏃堕棿
+                        oItemSub.HSourceBillNo = oItem.HSourceBillNo;
+                        oItemSub.HSourceBillType = oItem.HSourceBillType;
+                        oItemSub.HSourceInterID = oItem.HSourceInterID;
+                        oItemSub.HSourceEntryID = oItem.HSourceEntryID;
+                        oBill.DetailColl.Add(oItemSub);
+
+                    }
                     oBill.omodel = oItem;
                 }
-                //閰嶆枡璁板綍琛ㄤ綋鏁版嵁
-                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
-                msg3 = msg3.Substring(1, msg3.Length - 2);
-                msg3 = msg3.Replace("\\", "");
-                msg3 = msg3.Replace("\n", "");  //\n
-                //msg2 = msg2.Replace("'", "鈥�");
-                List<Model.ClsSc_MaterToSourceBillSub> ls = new List<Model.ClsSc_MaterToSourceBillSub>();
-                ls = oListModels.getObjectByJson_Sc_MaterToSourceBillSub(msg3);
-                int i = 0;
-                foreach (Model.ClsSc_MaterToSourceBillSub oItemSub in ls)
-                {
-
-                    i++;
-                    oItemSub.HEntryID = i;
-                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
-                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
-                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
-                    //oItemSub.HRemark = "";         //澶囨敞
-                    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
-                    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
-                    //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
-                    //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
-                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
-                    oBill.DetailColl.Add(oItemSub);
-
-                }
-                //閰嶄欢椤硅〃浣撴暟鎹�
-               
+              
 
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�

--
Gitblit v1.9.1