From d82756d630f5f9bcc588fee772b68bc2a7725cb0 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 19 五月 2025 16:06:08 +0800
Subject: [PATCH] 1

---
 WebAPI/DLL/ClsSc_MESBeginWorkBill.cs |  110 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 96 insertions(+), 14 deletions(-)

diff --git a/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs b/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
index 0e38b1b..9b90d41 100644
--- a/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
+++ b/WebAPI/DLL/ClsSc_MESBeginWorkBill.cs
@@ -9,12 +9,13 @@
     {
         public Models.ClsSc_MESBeginWorkBillMain omodel = new Models.ClsSc_MESBeginWorkBillMain();
         public List<Models.ClsSc_MESBeginWorkBillSub> DetailColl = new List<Models.ClsSc_MESBeginWorkBillSub>();
+        public List<Models.ClsSc_MESBeginWorkBillSub_RelationBill> DetailCol2 = new List<Models.ClsSc_MESBeginWorkBillSub_RelationBill>();
         //public List<Model.ClsSc_MESBeginWorkBillSub_Item> DetailColl1 = new List<Model.ClsSc_MESBeginWorkBillSub_Item>();
 
         public ClsSc_MESBeginWorkBill()
         {
             base.MvarItemKeySub = "Sc_MESBeginWorkBillSub";
-            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub2 = "Sc_MESBeginWorkBillSub_RelationBill";
             base.MvarItemKeySub3 = "";
             base.MvarItemKeySub4 = "";
             base.MvarItemKey="Sc_MESBeginWorkBillMain";
@@ -66,6 +67,8 @@
             try
             {
                 DataSet Ds = oCn.RunProcReturn("Exec h_p_Sc_MESBeginWorkBill_AfterSaveCtrl " + HInterID.ToString() + "," + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ",'" + HICMOBillNo + "'," + OperationType.ToString(), "h_p_Sc_MESBeginWorkBill_AfterSaveCtrl");
+                LogService.Write("寮�宸�:2.6.1");
+
                 if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                 {
                     sReturn = "淇濆瓨鍚庡垽鏂け璐ワ紒";
@@ -73,9 +76,12 @@
                 }
                 else
                 {
+                    LogService.Write("寮�宸�:2.6.2"+ Ds.Tables[0].Rows[0]["HBack"]);
                     if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBack"]) == 1)
                     {
+                        LogService.Write("寮�宸�:2.6.3");
                         sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
+                        LogService.Write("寮�宸�:2.6.4");
                         return false;
                     }
                 }
@@ -147,13 +153,47 @@
                 ",HAddr='" + omodel.HAddr + "'" +
                 ",HBarCodeMaker='" + omodel.HBarCodeMaker + "'" +
                 ",HBarCodeMakeDate='" + omodel.HBarCodeMakeDate + "'" +
+                ",HWorkShiftID='" + omodel.HWorkShiftID + "'" +
                 " where HInterID=" + lngBillKey.ToString());
                 //鍒犻櫎鍏宠仈
                 DeleteRelation(ref sReturn, lngBillKey);
                 //鍒犻櫎瀛愯〃
                 DeleteBillSub(lngBillKey);
+                DeleteBillSub2(lngBillKey);
                 //鎻掑叆瀛愯〃
                 omodel.HInterID = lngBillKey;
+
+                //鎻掑叆瀛愯〃_鍓骇璁″垝
+                foreach (Models.ClsSc_MESBeginWorkBillSub_RelationBill oSub in DetailCol2)
+                {
+                    string subSql = "insert into Sc_MESBeginWorkBillSub_RelationBill " +
+                        "(HInterID, HEntryID,HBillNo_bak, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HRemark, " +
+                        "HRelationBillInterID, HRelationBillEntryID, HRelationBillNo, HRelationBillType, HICMOInterID, HICMOEntryID, HICMOBillNo, " +
+                        "HProcExchInterID, HProcExchEntryID, HProcExchBillNo, HMaterID, HProcID) " +
+                        "values(" +
+                        "'" + omodel.HInterID.ToString() + "'," +
+                        "'" + oSub.HEntryID.ToString() + "'," +
+                        "'" + omodel.HBillNo + "'," +
+                        "'" + oSub.HSourceInterID + "'," +
+                        "'" + oSub.HSourceEntryID + "'," +
+                        "'" + oSub.HSourceBillNo + "'," +
+                        "'" + oSub.HSourceBillType + "'," +
+                        "'" + oSub.HRemark + "'," +
+                        "'" + oSub.HRelationBillInterID + "'," +
+                        "'" + oSub.HRelationBillEntryID + "'," +
+                        "'" + oSub.HRelationBillNo + "'," +
+                        "'" + oSub.HRelationBillType + "'," +
+                        "'" + oSub.HICMOInterID + "'," +
+                        "'" + oSub.HICMOEntryID + "'," +
+                        "'" + oSub.HICMOBillNo + "'," +
+                        "'" + oSub.HProcExchInterID + "'," +
+                        "'" + oSub.HProcExchEntryID + "'," +
+                        "'" + oSub.HProcExchBillNo + "'," +
+                        "'" + oSub.HMaterID + "'," +
+                        "'" + oSub.HProcID + "')";
+                    oCn.RunProc(subSql);
+                }
+
                 foreach (Models.ClsSc_MESBeginWorkBillSub oSub in DetailColl)
                 {
                     //oCn.RunProc("Insert into Sc_MESBeginWorkBillSub " +
@@ -219,6 +259,7 @@
         {
             try
             {
+                LogService.Write("寮�宸�:2.2");
                 DataSet ds;
                 //寰楀埌mainid
                 omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -229,7 +270,7 @@
                 {
                     return false;
                 }
-
+                LogService.Write("寮�宸�:2.3");               
                 //涓昏〃
                 oCn.RunProc("Insert Into Sc_MESBeginWorkBillMain " +
                 "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
@@ -238,7 +279,7 @@
                 ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HBeginWorkTime,HSourceID" +
                 ",HSourceInterID_Main,HSourceEntryID_Main,HSourceBillNo_Main,HSourceBillType_Main" +
                 ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
-                 ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HRunStatus,HSourceBeginQty" +
+                 ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HRunStatus,HSourceBeginQty,HWorkShiftID" +
                 ") " +
                 " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + ",getdate(),'" + omodel.HMaker+ "',getdate()" +
                 "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "'" +
@@ -246,9 +287,41 @@
                 ",'" + omodel.HProcExchBillNo + "'," + omodel.HMaterID.ToString() + "," + omodel.HProcID.ToString() + "," + omodel.HICMOQty.ToString() + "," + omodel.HPlanQty.ToString() + ",getdate()," + omodel.HSourceID.ToString() +
                 ",'" + omodel.HMainSourceInterID.ToString() + "'," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo.ToString() + "','" + omodel.HMainSourceBillType.ToString() + "'" +
                 ",'" + omodel.HMainSourceInterID.ToString() + "'," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo.ToString() + "','" + omodel.HMainSourceBillType.ToString() + "'" +
-                "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate(),'"+ omodel.HRunStatus + "','"+ omodel.HSourceBeginQty.ToString() + "'" +
+                "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + omodel.HBarCode + "','" + omodel.HAddr + "','" + omodel.HBarCodeMaker + "',getdate(),'"+ omodel.HRunStatus + "','"+ omodel.HSourceBeginQty.ToString() + "','" + omodel.HWorkShiftID.ToString() + "'" +
               ") ");
 
+                //鎻掑叆瀛愯〃
+                foreach (Models.ClsSc_MESBeginWorkBillSub_RelationBill oSub in DetailCol2)
+                {
+                    string subSql = "insert into Sc_MESBeginWorkBillSub_RelationBill " +
+                        "(HInterID, HEntryID,HBillNo_bak, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HRemark, " +
+                        "HRelationBillInterID, HRelationBillEntryID, HRelationBillNo, HRelationBillType, HICMOInterID, HICMOEntryID, HICMOBillNo, " +
+                        "HProcExchInterID, HProcExchEntryID, HProcExchBillNo, HMaterID, HProcID) " +
+                        "values(" +
+                        "'" + omodel.HInterID.ToString() + "'," +
+                        "'" + oSub.HEntryID.ToString() + "'," +
+                        "'" + omodel.HBillNo + "'," +
+                        "'" + oSub.HSourceInterID + "'," +
+                        "'" + oSub.HSourceEntryID + "'," +
+                        "'" + oSub.HSourceBillNo + "'," +
+                        "'" + oSub.HSourceBillType + "'," +
+                        "'" + oSub.HRemark + "'," +
+                        "'" + oSub.HRelationBillInterID + "'," +
+                        "'" + oSub.HRelationBillEntryID + "'," +
+                        "'" + oSub.HRelationBillNo + "'," +
+                        "'" + oSub.HRelationBillType + "'," +
+                        "'" + oSub.HICMOInterID + "'," +
+                        "'" + oSub.HICMOEntryID + "'," +
+                        "'" + oSub.HICMOBillNo + "'," +
+                        "'" + oSub.HProcExchInterID + "'," +
+                        "'" + oSub.HProcExchEntryID + "'," +
+                        "'" + oSub.HProcExchBillNo + "'," +
+                        "'" + oSub.HMaterID + "'," +
+                        "'" + oSub.HProcID + "')";
+                    oCn.RunProc(subSql);
+                }
+
+                LogService.Write("寮�宸�:2.4");
                 //鍐嶆楠岃瘉 淇濆瓨鏄惁 鍚堢悊
                 ds = oCn.RunProcReturn("exec h_p_JIT_MESBeginWorkBill_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_MESBeginWorkBill_SaveCtrl");
                 if (ds == null || ds.Tables[0].Rows.Count <= 0) 
@@ -263,13 +336,7 @@
                     oCn.RollBack();
                     return false;
                 }
-
-                //淇濆瓨鍚庢帶鍒�
-                if (!AfterSave(omodel.HInterID, omodel.HICMOInterID, omodel.HICMOEntryID, omodel.HICMOBillNo, 1, ref sReturn))
-                {
-                    oCn.RollBack();
-                    return false;
-                }
+                LogService.Write("寮�宸�:2.5");
 
                 //鑾峰彇鏈�杩戠殑涓婃ā鍗�  鎶婂伐鍗曡窡妯″叿杩涜缁戝畾
                 ds = oCn.RunProcReturn(@"select  HICMOInterID,HICMOEntryID,HSourceInterID,HSourceEntryID,HSourceID from Sc_ICMOBillStatus_Tmp where HInterID=" + omodel.HMainSourceInterID.ToString(), "Sc_ICMOBillStatus_Tmp");
@@ -283,14 +350,29 @@
                     string HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
 
                     ds = oCn.RunProcReturn(@"select  HMouldID from Sc_MouldUpperBillMain a
-inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where HICMOInterID=" + HICMOInterID + " and HICMOEntryID=" + HICMOEntryID + " and HProcExchInterID=" + HSourceInterID + " and  HProcExchEntryID=" + HSourceEntryID + " and HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
+                        inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where HICMOInterID=" + HICMOInterID + " and HICMOEntryID=" + HICMOEntryID + " and HProcExchInterID=" + HSourceInterID + " and  HProcExchEntryID=" + HSourceEntryID + " and HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
                     if (ds.Tables[0].Rows.Count > 0)
                     {
                         oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HMouldID= " + ds.Tables[0].Rows[0]["HMouldID"].ToString() + " where HInterID=" + omodel.HMainSourceInterID.ToString());
                     }
-
+                    else
+                    {
+                        ds = oCn.RunProcReturn(@"select  HMouldID from Sc_MouldUpperBillMain a
+                        inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID where  HSourceID=" + HSourceID + " order by HMakeDate desc", "Sc_MouldUpperBillMain");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HMouldID= " + ds.Tables[0].Rows[0]["HMouldID"].ToString() + " where HInterID=" + omodel.HMainSourceInterID.ToString());
+                        }
+                    }
                 }
-               
+                LogService.Write("寮�宸�:2.6  " + omodel.HInterID + "," + omodel.HICMOInterID + ", " + omodel.HICMOEntryID + ", " + omodel.HICMOBillNo + ", 1");
+                //淇濆瓨鍚庢帶鍒�
+                if (!AfterSave(omodel.HInterID, omodel.HICMOInterID, omodel.HICMOEntryID, omodel.HICMOBillNo, 1, ref sReturn))
+                {
+                    oCn.RollBack();
+                    return false;
+                }
+                LogService.Write("寮�宸�:2.7");
                 sReturn = omodel.HInterID.ToString();
                 oCn.Commit();
                 return true;

--
Gitblit v1.9.1