From 5842a1cde222f57fae12b4ecb45a4747020cd5c2 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 25 十二月 2023 09:15:01 +0800
Subject: [PATCH] 汇报单修改判断保存或者修改字段

---
 WebAPI/Controllers/Sc_ProcessMangementController.cs |  296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 293 insertions(+), 3 deletions(-)

diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs
index 73bcda8..749364a 100644
--- a/WebAPI/Controllers/Sc_ProcessMangementController.cs
+++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -21,7 +21,7 @@
 
         private json objJsonResult = new json();
         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
-
+        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
 
@@ -394,6 +394,83 @@
         //}
         #endregion
 
+
+
+        /// <summary>
+        /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟
+        /// </summary>
+        /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param>
+        /// <returns></returns>
+        [Route("Sc_ProcessMangement/SaveICMOReportBill_Batch")]
+        [HttpPost]
+        public object SaveICMOReportBill_Batch([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string InterID = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string BillNo = sArray[2].ToString();
+            string OrganizationID = sArray[3].ToString();
+            ArrayList InterIDArray = new ArrayList(InterID.Split(','));
+            ArrayList BillNoArray = new ArrayList(BillNo.Split(','));
+            try
+            {
+                string bResult;
+                string HMessage = "";
+                string HSuccessBillNo = "";
+                string HFailBillNo = "";
+                WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController();
+                if (InterIDArray.Count != BillNoArray.Count)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏁版嵁涓嶅畬鏁达紝鍐呯爜鏁伴噺涓嶇瓑浜庡崟鎹彿鏁伴噺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    for (int i = 0; i < InterIDArray.Count;i++)
+                    {
+                        bResult = JsonConvert.SerializeObject(oBill.SaveICMOReportBill(InterIDArray[i].ToString(), user, BillNoArray[i].ToString(), OrganizationID));
+
+                        //鍙嶅簭鍒楀寲
+                        bResult = "[" + bResult.ToString() + "]";
+
+                        List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult);
+
+                        if (list[0].count == 1)
+                        {
+                            HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString()+"," + "\r\n" ;
+                        }
+                        else
+                        {
+                            HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n";
+                        }
+                        HMessage = "姹囨姤鎴愬姛鍗曞彿锛�" + HSuccessBillNo + "\r\n" + "  姹囨姤澶辫触鍗曞彿锛�" + HFailBillNo;
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = HMessage;
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
         /// <summary>
         /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟
         /// </summary>
@@ -405,6 +482,10 @@
         {
             try
             {
+                string sErr = "";
+                oSystemParameter.ShowBill(ref sErr);
+
+
                 //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿
                 Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo);
                 string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true);
@@ -509,6 +590,7 @@
                     FentityModel.Add("FFinishQty", item["鎺ユ敹鏁伴噺"].ToString());//瀹屾垚鏁伴噺1
                     FentityModel.Add("FQuaQty", item["鍚堟牸鏁伴噺"].ToString());//鍚堟牸鏁伴噺1FFailQty
                     FentityModel.Add("FFailQty", item["涓嶈壇鏁伴噺"].ToString());//涓嶅悎鏍兼暟閲�
+                    FentityModel.Add("FScrapQty", item["鎶ュ簾鏁伴噺"].ToString());//鎶ュ簾鏁伴噺                    
                     FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 鍏ュ簱缁勭粐 
                     FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 浠撳簱 
                     FentityModel.Add("FMOID", dr1["FMOID"].ToString());//  
@@ -521,7 +603,10 @@
                     FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 鎴愭湰鏉冮噸
                     FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 鍊掑啿棰嗘枡
                     FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());//
-                    //FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //鍖呰鏍囪瘑
+                    if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�")
+                    {
+                        FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() });//鍖呰鏍囪瘑
+                    }
                     FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //鎵瑰彿
                     FentityModel.Add("F_bsv_Text", dr1["宸ュ簭娴佽浆鍗″彿"].ToString()); //娴佽浆鍗″彿
                     JArray Fentity2 = new JArray();
@@ -594,6 +679,71 @@
                 objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
                 objJsonResult.data = 1;
                 return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟
+        /// </summary>
+        /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param>
+        /// <returns></returns>
+        [Route("Sc_ProcessMangement/SaveProcdutInBill_Batch")]
+        [HttpPost]
+        public object SaveProcdutInBill_Batch([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string BillNo = sArray[0].ToString();
+            BillNo = BillNo.Replace("\r\n", "").Replace("[ ", "").Replace("]", "");
+            BillNo = BillNo.Replace("\\", "").Replace("\n", "").Replace("\"", "");
+            BillNo = BillNo.Trim();
+            ArrayList BillNoArray = new ArrayList(BillNo.Split(','));
+          
+            try
+            {
+                string bResult;
+                string HMessage = "";
+                string HSuccessBillNo = "";
+                string HFailBillNo = "";
+                WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController();
+
+                for (int i = 0; i < BillNoArray.Count; i++)
+                {
+                    bResult = JsonConvert.SerializeObject(oBill.SaveProcdutInBill(BillNoArray[i].ToString().Trim()));
+
+                    //鍙嶅簭鍒楀寲
+                    bResult = "[" + bResult.ToString() + "]";
+
+                    List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult);
+
+                    if (list[0].count == 1)
+                    {
+                        HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString() + "," + "\r\n";
+                    }
+                    else
+                    {
+                        HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n";
+                    }
+                    HMessage = "鍏ュ簱鎴愬姛鍗曞彿锛�" + HSuccessBillNo + "\r\n" + "  鍏ュ簱澶辫触鍗曞彿锛�" + HFailBillNo;
+                }
+                
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = HMessage;
+                objJsonResult.data = null;
+                return objJsonResult;
+
             }
             catch (Exception e)
             {
@@ -686,6 +836,16 @@
                 //
                 //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '鏄�' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc");
                 DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc '" + BillNo + "'", "h_p_TOERPProcduct_LastProc");
+
+                if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈壘鍒板搴旂殑鏈湴鎴栭噾铦朵簯鐢熶骇姹囨姤鍗曡褰�;1.鏈煡璇㈠埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟锛�2.璇风‘淇濆綋鍓嶅伐搴忔槸鏈亾宸ュ簭3.姹囨姤鍗曞搴旂殑鍏ュ簱鏁伴噺宸叉弧 璇峰湪閲戣澏浜戞煡鐪嬪叆搴撹褰曪紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 DataRow dr1 = ds1.Tables[0].Rows[0];
                 if (double.Parse(dr1[0].ToString()) <= 0)
                 {
@@ -730,6 +890,19 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+
+                        //鍒ゆ柇鍞竴ID鏄惁涓虹┖
+                        foreach (DataRow item in ds1.Tables[0].Rows) 
+                        {
+                            if (item["HWYID"].ToString() == null || item["HWYID"].ToString() == "" || item["HWYID"].ToString() == "undefined")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍞竴ID涓虹┖锛岃閲嶆柊鎵嬪姩鍏ュ簱鎴栬仈绯荤鐞嗗憳锛�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }                
                     }
                 }
 
@@ -1003,6 +1176,14 @@
                 //
                 //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '鏄�' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc");
                 DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc_BF '" + BillNo + "'", "h_p_TOERPProcduct_LastProc_BF");
+                if (ds1.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎿嶄綔澶辫触,鏌ヤ笉鍒板搴旂殑鍑虹珯鍗曟嵁!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
                 DataRow dr1 = ds1.Tables[0].Rows[0];
 
                 JObject model = new JObject();
@@ -1065,7 +1246,7 @@
                     FentityModel.Add("FSrcInterId", item["HSourceInterID"].ToString());//  
                     FentityModel.Add("FBasePrdRealQty", item["鏁伴噺"].ToString());//
                     FentityModel.Add("FIsFinished", "false");//
-                    FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT08_SYS" }); //
+                    FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT001" }); //
                     FentityModel.Add("FSrcEntrySeq", item["HSourceSeQ"].ToString());//  婧愬崟鍒嗗綍琛屽彿
                     FentityModel.Add("FMOMAINENTRYID", item["HMOEntryID"].ToString());//
                     FentityModel.Add("FKeeperTypeId", "BD_KeeperOrg");
@@ -2991,6 +3172,115 @@
         }
         #endregion
 
+
+        #region 涓嶈壇鍝佸鐞嗗崟鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("Sc_ProcessMangement/CloseSc_ProcessMangement")]
+        [HttpGet]
+        public object CloseSc_ProcessMangement(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_Close", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "QC_NoPassProdCheckBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //鍏抽棴鍗曟嵁
+                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
+                    DataSet ds;
+                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
+                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    {
+                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插弽鍏抽棴!涓嶉渶瑕佸啀鍙嶅叧闂�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    //鍙嶅叧闂崟鎹�
+                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+
         /// <summary>
         /// PDA宸ュ簭姹囨姤鍗曚繚瀛�
         /// </summary>

--
Gitblit v1.9.1