From 04b4d4d975858a0d5e207b9df9f3bb46cc6c14fd Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 17 十一月 2025 11:41:24 +0800
Subject: [PATCH] 添康排产页面直接修改排产数量;

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  693 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 669 insertions(+), 24 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index 05c1b76..1e76dd7 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -2439,7 +2439,7 @@
 
         #region 灏忓崼鍗曞搧杩囩珯鎺ュ彛
 
-        #region  宸ュ簭鍗曞搧杩囩珯 鎵规鐮佹牎楠岃繑鍥炰俊鎭�(鍙敤浜庨獙璇佹壒娆℃槸鍚﹀叆搴�)
+        #region  宸ュ簭鍗曞搧杩囩珯 鎵潯鐮佺爜鏍¢獙杩斿洖淇℃伅(鍙敤浜庨獙璇佹壒娆℃槸鍚﹀叆搴�)
         [Route("Cj_SingleStation/checkHBarCode_Batch")]
         [HttpGet]
         public object checkHBarCode_Batch(string HBarCode,string user, int HOrgID)
@@ -2538,7 +2538,7 @@
                 }
 
                 //鏉$爜涓婇亾宸ュ簭鏄惁杩囩珯
-                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_S");
+                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_XW");
                 if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                 {
                     objJsonResult.code = "0";
@@ -2547,7 +2547,7 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
+                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -2557,17 +2557,523 @@
                 }
 
                 //鍒ゆ柇鏉$爜鏄惁宸茬粡鍑虹珯
-                ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 浜у搧鏉$爜='" + barCode_SN + "' and HProcExchInterID=" + omodel.HProcExchInterID + " and HProcExchEntryID=" + omodel.HProcExchEntryID + " and HProcID=" + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
+                //ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 浜у搧鏉$爜='" + barCode_SN + "' and HProcExchInterID=" + omodel.HProcExchInterID + " and HProcExchEntryID=" + omodel.HProcExchEntryID + " and HProcID=" + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
 
-                if (ds.Tables[0].Rows.Count > 0)
+                //if (ds.Tables[0].Rows.Count > 0)
+                //{
+                //    oCN.RollBack();
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "[0000-2-039]鏉$爜:" + barCode_SN + ",宸插嚭绔�!";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                long HMainInterID = 0;
+                string BillType = "3791";
+                string HBillSubType = "3791";
+                long HInterID = omodel.HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = omodel.HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                int HBillStatus = 1;
+                string HMaker = user;//鍒跺崟浜�
+                string HMouldNum = omodel.HMouldNum;//妯$┐鍙�
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = omodel.HRemark;//澶囨敞
+                string HSourceName = omodel.HSourceName;//鐢熶骇璧勬簮鍚嶇О
+                double HPieceQty = omodel.HPieceQty;//杩涚珯PCS鏁�
+                double HWasterQty = 0;//鎶ュ簾鏁伴噺
+                double HPlanPieceQty = 0;//杩涚珯PNL鏁�
+                double HBadPNL = 0;//鎶ュ簾PNL鏁�
+                long HICMOInterID = omodel.HICMOInterID;//浠诲姟鍗旾D
+                long HICMOEntryID = omodel.HICMOEntryID;//浠诲姟鍗旾D
+                string HICMOBillNo = omodel.HICMOBillNo;//浠诲姟鍗�
+                int HProcPlanInterID = 0;
+                int HProcPlanEntryID = 0;
+                string HProcPlanBillNo = "";
+                long HProcExchInterID = omodel.HProcExchInterID;
+                long HProcExchEntryID = omodel.HProcExchEntryID;
+                string HProcExchBillNo = omodel.HProcExchBillNo;//娴佽浆鍗�
+                long HMaterID = omodel.HMaterID;//浜у搧ID
+                long HProcID = omodel.HProcID;//褰撳墠宸ュ簭ID
+                double HICMOQty = omodel.HICMOQty;//浠诲姟鍗曟暟閲�
+                double HPlanQty = omodel.HICMOQty;//绉讳氦PNL鏁�
+                DateTime HStationOutTime = DateTime.Now;//姹囨姤鏃堕棿
+                long HSourceID = omodel.HSourceID;//鐢熶骇璧勬簮ID
+                long HPayProcID = 0;//鏍哥畻宸ュ簭ID
+                long HGroupID = omodel.HGroupID;//鐝粍ID
+                long HDeptID = omodel.HDeptID;
+                long HEmpID = omodel.HEmpID;//鎿嶄綔鍛業D
+                long HEmpID2 = omodel.HEmpID2;////鎿嶄綔鍛�2ID
+                string HBarCode = barCode_SN;//鏉″舰鐮�
+                string HAddr = "";
+                string HBarCodeMaker = "";
+                long HSourceID2 = 0;//鐢熶骇璧勬簮2ID
+                long HSourceID3 = 0;//鐢熶骇璧勬簮3ID
+                long HSourceID4 = 0;//鐢熶骇璧勬簮4ID
+                long HSourceID5 = 0;//鐢熶骇璧勬簮5ID
+                long HSupID = 0;
+                double HQty = omodel.HQty;//鍚堟牸鏁伴噺
+                double HPrice = 0;
+                double HMoney = 0;
+                double HBadCount = omodel.HBadCount;//涓嶈壇鏁伴噺
+                long HCenterID = omodel.HCenterID;//宸ヤ綔涓績ID
+                string HProcNo = omodel.HProcNo;//娴佹按鍙�
+                string HOrderProcNO = omodel.HOrderProcNO;//璁㈠崟璺熻釜鍙�
+                string HSourceNameList = omodel.HSourceNameList;//璁惧娓呭崟
+                long HMainSourceInterID = omodel.HProcExchInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HMainSourceBillNo = omodel.HProcExchBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                string HMainSourceBillType = "3772";
+                bool HLastSubProc = omodel.HLastSubProc;//杞笅宸ュ簭
+                long HEmpID3 = 0;//鎿嶄綔鍛�3ID
+                long HEmpID4 = 0;//鎿嶄綔鍛�4ID
+                long HEmpID5 = 0;//鎿嶄綔鍛�5ID
+                double HDSQty = 0;//鎶樺集鍒�鏁�
+                double HChongQty = 0;//NCT鍐叉鏁�
+                double HPriceRate = 0;//绯绘暟
+                double HWorkTimes = 0;//宸ユ椂
+                long HQCCheckID = omodel.HEmpID;//妫�楠屽憳ID
+                long HPRDOrgID = omodel.HPRDOrgID;//缁勭粐ID
+                double HmaterOutqty = 0;//鐧藉澂鍙戝竷
+                double HProcPriceRate = 0;//宸ヤ环绯绘暟
+                int HTemporaryAreaID = 0;//鏆傛斁鍖�
+                int HShiftsID = 0;
+                string HBatchNo = omodel.HBatchNo;
+                double HWeight = omodel.HWeight;
+                //鑾峰彇褰撳墠鐝
+                //DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HDeptID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
+                //if (set.Tables[0].Rows.Count > 0)
+                //{
+                //    HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
+                //}
+                //鍒ゆ柇褰撳ぉ褰撳墠鐨勬祦杞崱鏄惁鏈夊嚭绔欏崟
+
+                HInterID = DBUtility.ClsPub.CreateBillID("3791", ref sExeReturnInfo);//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3791", ref sExeReturnInfo, true);//閫掑叆type寰楀埌鐨勫崟鎹彿
+
+                //涓昏〃鎻掑叆
+                oCN.RunProc("Insert Into Sc_StationOutBillMain" +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
+                ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
+                ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
+                ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
+                ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
+                ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
+                ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
+                ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
+                    ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
+                ") " +
+                " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
+                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
+                "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
+                ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
+                "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 +
+                "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
+                "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
+                "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
+                "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HShiftsID + ") ");
+                
+
+                ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + omodel.HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+
+                oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HBatchNo,HWeight)
+                    values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{barCode_SN}', 1, GETDATE(), '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + $"', '', 0, 0,'{HBatchNo}',{HWeight})");
+
+                //鎶婃潯鐮佸啓鍏ユ棩蹇楅噷闈�
+                LogService.CustomWriteLog("鏉$爜:" + barCode_SN + ",宸ュ簭:" + HProcID + ",鍑虹珯鏃堕棿:" + DateTime.Now, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
+
+                //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
+                //oCN.RunProc("update Sc_StationOutBillMain set HQty+=1  where HProcExchInterID='" + HProcExchInterID + "' and HProcExchEntryID=" + HProcExchEntryID + " and HInterID=" + HInterID);
+
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_SingleStationOutBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + $@"',{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{barCode_SN}','{user}' ", "h_p_Sc_SingleStationOutBill_AfterSaveCtrl");
+                if (ds2 == null)
                 {
                     oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "[0000-2-039]鏉$爜:" + barCode_SN + ",宸插嚭绔�!";
+                    objJsonResult.Message = "[0000-2-016]淇濆瓨鍚庢帶鍒跺垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-051]淇濆瓨澶辫触2锛�" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+                //============================
+
+                //ds = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
+                //            left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
+                //            where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
+                //            group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
+
+                //if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0)
+                //{
+                //    oCN.RollBack();
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "[3791-2-028]鍑虹珯鏁伴噺瓒呰繃娴佽浆鍗℃暟閲�!";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-050]淇濆瓨鎴愬姛!";
+                objJsonResult.data = HInterID;//杩斿洖鍑虹珯姹囨姤鍗昳d
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-051]娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 杩斿洖鍘嗗彶鍑烘垬姹囨姤鍗曚俊鎭紙鍗冲巻鍙茶繃绔欐竻鍗曪級
+        [Route("Cj_SingleStation/SingleStationOutBillList")]
+        [HttpGet]
+        public object get_Display(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-068]鍑虹珯鍗曟棤鏌ヨ鏉冮檺!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1" + sWhere + "order by hmainid desc", "h_v_Sc_SingleStationOutBillList");
+                }
+                else
+                {
+                    string sql1 = "select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1 ";
+                    string sql = sql1 + sWhere + "  order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_SingleStationOutBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-037]Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-038]Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  宸ュ簭鍗曞搧杩囩珯 SN闀洉鐮佹煡璇㈠叧閿欢娓呭崟
+        [Route("Cj_SingleStation/HBardCodeBomList_XW")]
+        [HttpGet]
+        public object HBardCodeBomList_XW(string HBillNo,string HBarCode,int HProcID,int HOrgID, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-068]鏃犳煡璇㈡潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀瓨鍦ㄦ潯鐮佹。妗堝綋涓�
+                ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "璇ユ潯鐮佷笉瀛樺湪锛�" + HBarCode;
+                    objJsonResult.data = "";
+                    return objJsonResult;
+
+                }
+
+                //鏉$爜妗f涓凡鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽尮閰嶇敤鏂欐竻鍗曪紙鎵爜鏁版嵁鍐欏叆涓存椂琛級
+                ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomMatch_XW '" + HBillNo + "','" + HBarCode + "','" + HProcID + "'," + HOrgID, "h_p_Gy_BarCodeBillBomList_XW");
+                if (ds != null && ds.Tables[0].Rows.Count > 0)
+                {
+                    if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = "";
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ヨ鍒版暟鎹�";
+                    objJsonResult.data = "";
+                    return objJsonResult;
+                }
+
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-010]娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ュ簭鍗曞搧杩囩珯 鍏抽敭浠剁粦瀹氶厤浠朵俊鎭复鏃跺瓨鍌�
+        [Route("Cj_SingleStation/BarCodeBillBomMatch_XW")]
+        [HttpGet]
+        public object PartsBardCode_JX(string HBillNo,string HBarCode, string HBarCode_P, int HProcID, string user, int HOrgID)
+        {
+            try
+            {
+                //鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀瓨鍦ㄦ潯鐮佹。妗堝綋涓�
+                ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    //鏉$爜妗f涓病鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽垯鏍规嵁瑙勫垯瑙f瀽鐢熸垚鏉$爜
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "璇ユ潯鐮佷笉瀛樺湪锛�" + HBarCode;
+                    objJsonResult.data = "";
+                    return objJsonResult;
+                    
+                }
+
+                //鏉$爜妗f涓凡鏈夋湰娆℃壂鎻忕殑鏉$爜锛屾煡璇㈤厤浠朵俊鎭紙鎵弿鏉$爜淇℃伅鍐欏叆涓存椂琛級
+                ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomBind_XW '" + HBillNo + "','" + HBarCode + "','" + HBarCode_P + "','" + HProcID + "','" + HOrgID + "'", "h_p_Gy_BarCodeBillBomBind_XW");
+
+                if (ds != null && ds.Tables[0].Rows.Count > 0)
+                {
+                    if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = "";
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "";
+                    objJsonResult.data = "娌℃湁鏌ヨ鍒版暟鎹�";
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "ERROR锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  宸ュ簭鍗曞搧杩囩珯 鎵玈N鐮佸嚭绔欎繚瀛�(淇濆瓨鍒板嚭绔欐眹鎶ラ噷(+鍏抽敭浠剁粦瀹�))
+        [Route("Cj_SingleStation/AddStationOutBillAndAssemblyBill")]
+        [HttpPost]
+        public object AddStationOutBillAndAssemblyBill([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg = _value.ToString();
+                string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string sMainStr = sArray[0].ToString();//涓昏〃淇℃伅鍖呭惈宸ュ簭锛岀彮缁�,鎵规绛変俊鎭�
+                string barCode_SN = sArray[1].ToString();//鎵弿鐨凷N鐮侀暛闆曠爜浜у搧淇℃伅
+                string sSubStr = sArray[2].ToString();//瀛愯〃鍏抽敭浠朵俊鎭�
+                string user = sArray[3].ToString();
+
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-2-038]鏃犱繚瀛樻潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+                string sExeReturnInfo = "";
+
+                StationBill omodel = new StationBill();
+                omodel = JsonConvert.DeserializeObject<StationBill>(sMainStr);
+
+                List<Model.ClsSc_AssemblyBillSub> sub = new List<Model.ClsSc_AssemblyBillSub>();
+                sub = JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(sSubStr);
+
+                //鍒ゆ柇鏄惁鏈夊搴旀祦杞崱淇℃伅骞惰幏鍙�
+                ds = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_ProcessExchangeBillList");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    //灏嗘祦杞崱淇℃伅鍐欏叆
+                    omodel.HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
+                    omodel.HProcExchInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString());
+                    omodel.HProcExchEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString());
+                    omodel.HMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HMainMaterID"].ToString());
+                    omodel.HCenterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCenterID"].ToString());
+                    omodel.HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
+                    omodel.HICMOInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOInterID"].ToString());
+                    omodel.HICMOEntryID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString());
+                    omodel.HICMOQty = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HICMOQty"].ToString());
+                    omodel.HProcNo = ds.Tables[0].Rows[0]["HProcNo"].ToString();
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[3791-2-019]]褰撳墠SN鐮佸拰宸ュ簭鏃犳硶鎵惧埌瀵瑰簲娴佽浆鍗¤妫�鏌ユ槸鍚﹁緭鍏ラ�夋嫨閿欒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鏉$爜涓婇亾宸ュ簭鏄惁杩囩珯浠ュ強鏈亾鏉$爜鏄惁宸茬粡鍑虹珯
+                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_XW '" + barCode_SN + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_XW");
+                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-045]鏌ユ棤鏁版嵁!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-051]" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇鏉$爜鏄惁宸茬粡鍑虹珯
+                //ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 浜у搧鏉$爜='" + barCode_SN + "' and HProcExchInterID=" + omodel.HProcExchInterID + " and HProcExchEntryID=" + omodel.HProcExchEntryID + " and HProcID=" + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
+
+                //if (ds.Tables[0].Rows.Count > 0)
+                //{
+                //    oCN.RollBack();
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "[0000-2-039]鏉$爜:" + barCode_SN + ",宸插嚭绔�!";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                //澧炲姞浜х嚎缁勮杩芥函鍗�
+                DataSet ds1;
+                if (1==1)
+                {
+                    ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + barCode_SN + "'", "Sc_AssemblyBillMain");
+
+                    if (ds1.Tables[0].Rows.Count == 0)
+                    {
+                        Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
+                        string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
+
+                        //淇濆瓨鐢熶骇缁勮鍗曚富琛�
+                        string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
+                        ,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
+                        ,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID)
+                        values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate()
+                        ,'{HBillNo1}','1','{user}',getdate(),{omodel.HProcExchInterID.ToString()},{omodel.HProcExchEntryID.ToString()},'{omodel.HProcExchBillNo.ToString()}'
+                        ,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{barCode_SN.ToString()}',{omodel.HMaterID},0,'姹囨姤',{omodel.HPRDOrgID})";
+                        oCN.RunProc(sql);
+                        
+                        
+                        for (int i = 0; i < sub.Count; i++)
+                        {
+                            //瀛愯〃瀛樺偍
+                            string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
+                            ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
+                            ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
+                            values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
+                            ,'',{sub[i].HMaterID},0,0,0,1
+                            ,0,0,getdate(),'{sub[i].HBarCode}','{barCode_SN}','') ";
+                            oCN.RunProc(sq2);
+                        }
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-2-039]鏉$爜宸插瓨鍦ㄧ粦瀹氬崟:" + barCode_SN + "";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                }
+
 
                 long HMainInterID = 0;
                 string BillType = "3791";
@@ -2671,7 +3177,7 @@
                 "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
                 "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                 "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HShiftsID + ") ");
-                
+
 
                 ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + omodel.HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
 
@@ -2743,35 +3249,86 @@
         }
         #endregion
 
-        #region 杩斿洖鍘嗗彶鍑烘垬姹囨姤鍗曚俊鎭紙鍗冲巻鍙茶繃绔欐竻鍗曪級
-        [Route("Cj_SingleStation/SingleStationOutBillList")]
+        #region  宸ュ簭鍗曞搧杩囩珯 涓鐮佺敓鎴�
+        [Route("Cj_SingleStation/AddCaseCode")]
+        [HttpPost]
+        public object AddCaseCode([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg = _value.ToString();
+                string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string sMainStr = sArray[0].ToString();//涓昏〃淇℃伅SN鐮佹。妗坕d杩欑鏍煎紡
+                string user = sArray[1].ToString();
+
+                oCN.BeginTran();
+                ds = oCN.RunProcReturn("exec h_p_Gy_CaseCodeBySN '" + sMainStr + "'", "h_p_Sc_SNBarcodeProcCtrl_S");
+                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-045]鏌ユ棤鏁版嵁!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-051]" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-050]淇濆瓨鎴愬姛!";
+                objJsonResult.data = ds.Tables[0].Rows[0]["HBackRemark"].ToString();
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-051]娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 杩囩珯瑙g粦鍒楄〃 鏌ヨ
+        [Route("Cj_SingleStation/UnbindBarList")]
         [HttpGet]
-        public object get_Display(string sWhere, string user)
+        public object BarList(string sWhere, string user)
         {
             try
             {
                 List<object> columnNameList = new List<object>();
-                
-                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
-                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Cj_SingleStation_UnbindBarList", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "[0000-1-068]鍑虹珯鍗曟棤鏌ヨ鏉冮檺!";
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1" + sWhere + "order by hmainid desc", "h_v_Sc_SingleStationOutBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList order by 鏉$爜鏃ユ湡 desc", "h_v_Sc_UnbindStation_BarList");
                 }
                 else
                 {
-                    string sql1 = "select Top 1000 * from h_v_Sc_SingleStationOutBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere + "  order by hmainid desc";
-                    ds = oCN.RunProcReturn(sql, "h_v_Sc_SingleStationOutBillList");
+                    string sql1 = "select * from h_v_Sc_UnbindStation_BarList where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鏉$爜鏃ユ湡 desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_UnbindStation_BarList");
                 }
 
                 //娣诲姞鍒楀悕
@@ -2782,26 +3339,114 @@
                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
 
-                
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "[0000-1-037]Sucess锛�";
-                objJsonResult.list = columnNameList;
+                objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
                 return objJsonResult;
-                
             }
             catch (Exception e)
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "[0000-1-038]Exception锛�" + e.ToString();
+                objJsonResult.Message = "Exception锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }
         }
         #endregion
 
+        #region 閲嶅伐鏉$爜淇℃伅 鏌ヨ
+        [Route("Cj_SingleStation/UnbindBarInfo")]
+        [HttpGet]
+        public object UnbindBarInfo(string HBarCodeIDs, string user)
+        {
+            try
+            {
+                if (HBarCodeIDs == null || HBarCodeIDs.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閲嶅伐鏉$爜淇℃伅鏈�掑叆锛岃閫�鍑洪噸璇�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    string sql = "exec h_p_Sc_UnbindBarInfo '" + HBarCodeIDs + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_UnbindBarInfo");
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瑙i櫎鍖呰鍏崇郴銆佹媶闄ょ墿鏂�(1:瑙i櫎鍖呰鍏崇郴锛�2.鎷嗛櫎鐗╂枡)
+        [Route("Cj_SingleStation/DelRelation")]
+        [HttpGet]
+        public object DelRelation(string HBarCodeIDs, Int64 HICMOInterID, Int64 HICMOEntryID, Int64 HProcID, Int64 HType, string user)
+        {
+            try
+            {
+                if (HBarCodeIDs == null || HBarCodeIDs.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎷嗛櫎鏉$爜淇℃伅鏈�掑叆锛岃閫�鍑洪噸璇�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    string sql = "exec h_p_Sc_DelbindBarRelation '" + HBarCodeIDs + "'," + HICMOInterID + "," + HICMOEntryID + "," + HProcID + "," + HType;
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_DelbindBarRelation");
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() == "0")
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = ds.Tables[0].Rows[0]["HBackRemark"].ToString();
+                    objJsonResult.data = "";
+                    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