From ae3c361a3f387e9d6963ff4d0a514ebb88ae3e32 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期三, 25 三月 2026 10:39:46 +0800
Subject: [PATCH] 增加获取金蝶基础资料二开方法,工序流转卡派工时候,如果同意机台模具已派工,不允许二次派工

---
 WebAPI/Controllers/基础资料/基础资料/Gy_WorkStationBillController.cs |  189 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 154 insertions(+), 35 deletions(-)

diff --git "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_WorkStationBillController.cs" "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_WorkStationBillController.cs"
index fc0da8a..a9a118d 100644
--- "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_WorkStationBillController.cs"
+++ "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_WorkStationBillController.cs"
@@ -79,11 +79,14 @@
                 string msg1 = _value.ToString();
                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                 string msg2 = sArray[0].ToString();
-                string msg3 = sArray[1].ToString();
+                string msg3 = sArray[2].ToString();
+                string msg4 = sArray[1].ToString();//瀛愯〃
 
                 //鍙嶅簭鍒楀寲
                 msg2 = "[" + msg2.ToString() + "]";
                 List<WorkStation> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkStation>>(msg2);
+                List<WorkStationSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkStationSub>>(msg4);
+
 
                 long HItemID = list[0].HItemID;
                 string HNumber = list[0].HNumber;
@@ -98,40 +101,42 @@
                 long HUSEORGID = list[0].HUSEORGID;
                 long HCREATEORGID = list[0].HCREATEORGID;
 
+                
 
-                #region [娉ㄩ噴浠g爜]
-                ////鍒ゆ柇鏉冮檺
-                //if (!ClsPub.Security_Log("Gy_Warehouse_Edit", 1, false, msg3))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "娌℃湁鎵惧埌璇ュ姛鑳芥ā鍧楋紒";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
 
-                //if (!DBUtility.ClsPub.AllowNumber(HNumber))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
+                    #region [娉ㄩ噴浠g爜]
+                    ////鍒ゆ柇鏉冮檺
+                    //if (!ClsPub.Security_Log("Gy_Warehouse_Edit", 1, false, msg3))
+                    //{
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "娌℃湁鎵惧埌璇ュ姛鑳芥ā鍧楋紒";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
 
-                //if (oDept.HavSameNumber(HItemID, HNumber))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "浠g爜閲嶅锛�";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
-                #endregion
+                    //if (!DBUtility.ClsPub.AllowNumber(HNumber))
+                    //{
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
 
-                //淇濆瓨
-                //淇濆瓨瀹屾瘯鍚庡鐞�
-                if (HItemID == 0)
+                    //if (oDept.HavSameNumber(HItemID, HNumber))
+                    //{
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "浠g爜閲嶅锛�";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
+                    #endregion
+
+                    //淇濆瓨
+                    //淇濆瓨瀹屾瘯鍚庡鐞�
+                    if (HItemID == 0)
                 {
                     oCN.BeginTran();
                     //鍒ゆ柇浠g爜鏄惁閲嶅
@@ -146,14 +151,46 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                    oCN.RunProc("Insert into Gy_WorkStation  " +
+                    DataSet ds = oCN.RunProcReturn("Insert into Gy_WorkStation  " +
                         " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                         ",HLevel,HEndFlag,HStopflag,HRemark," +
-                        "HUSEORGID,HCREATEORGID,HMakeEmp,HMakeTime) " +
+                        "HUSEORGID,HCREATEORGID,HMakeEmp,HMakeTime) output inserted.HItemID" +//鑾峰彇鍒氭墠鎻掑叆鐨勮嚜澧濱D
                         " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
-                        "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',"  + HUSEORGID + ",'" + HCREATEORGID + "','" + msg3 + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
+                        "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',"  + HUSEORGID + ",'" + HCREATEORGID + "','" + msg3 + "',getdate())", "Gy_WorkStation");
+                    int HInterID = Convert.ToInt32(ds.Tables[0].Rows[0]["HItemID"]);//鑷ID
                     //淇敼涓婄骇涓洪潪鏈骇浠g爜
                     oCN.RunProc("Update Gy_WorkStation set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("Delete From " + "Gy_WorkStationSub" + "  where HInterID=" + HInterID);
+
+                    //鎻掑叆瀛愯〃
+                    if (subList != null && subList.Count > 0)
+                    {
+                        int i = 0;
+                        foreach (Models.WorkStationSub oSub in subList)
+                        {
+
+                            if (oSub == null)
+                                continue;
+                            i++;
+                            string subSql = "insert into Gy_WorkStationSub" +
+                                   "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
+                                   ",HMaterID" + ")" +
+                                   " values(" +
+                                   HInterID + "," +
+                                   (i) + "," +
+                                   (oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
+                                   ( oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
+                                   (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
+                                   (oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") +
+                                   ")";
+
+                            oCN.RunProc(subSql);
+                        }
+                    }
+
+
+
                     oCN.Commit();
                 }
                 else
@@ -188,6 +225,37 @@
                     //灏嗕笂绾� 涓洪潪鏈骇
                     oCN.RunProc("Update Gy_WorkStation set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     //
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("Delete From " + "Gy_WorkStationSub" + "  where HInterID=" + HItemID);
+
+                    //鎻掑叆瀛愯〃
+                    if (subList != null && subList.Count > 0)
+                    {
+                        int i = 0;
+                        foreach (Models.WorkStationSub oSub in subList)
+                        {
+
+                            if (oSub == null)
+                                continue;
+                            i++;
+                            string subSql = "insert into Gy_WorkStationSub" +
+                                   "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
+                                   ",HMaterID" + ")" +
+                                   " values(" +
+                                   HItemID + "," +
+                                   (i) + "," +
+                                   (oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
+                                   (oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
+                                   (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
+                                   (oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") +
+                                   ")";
+
+                            oCN.RunProc(subSql);
+                        }
+                    }
+
+
+
                     oCN.Commit();
                 }
                 objJsonResult.code = "0";
@@ -403,6 +471,57 @@
         #endregion
 
 
+        #region 鏍规嵁鍩虹璧勬枡 ID 鎴� 鏉$爜 鏌ユ壘璁板綍
+        [Route("Gy_WorkStationBill/cx1")]
+        [HttpGet]
+        public object cx(long HInterID = -1, string HBarCode = "-1")
+        {
+            try
+            {   
+                if(HInterID != -1)
+                {
+                    return cx(HInterID);
+                }
+
+                if(HBarCode != "-1")
+                {
+                    ds = oCN.RunProcReturn($"select * from h_v_Gy_WorkStationEdit where 宸ヤ綅浠g爜='{HBarCode}'", "h_v_Gy_WorkStationList");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "false锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "Sucess锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    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
+
         #region 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍
         [Route("Gy_WorkStationBill/cx")]
         [HttpGet]
@@ -411,7 +530,7 @@
             try
             {
 
-                ds = oCN.RunProcReturn("select * from h_v_Gy_WorkStationList where HitemID=" + HInterID, "h_v_Gy_WorkStationList");
+                ds = oCN.RunProcReturn("select * from h_v_Gy_WorkStationEdit where HitemID=" + HInterID, "h_v_Gy_WorkStationList");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";

--
Gitblit v1.9.1