From 45d569f41e2c20d2afabc42a2fdb9e19d6f1e0ec Mon Sep 17 00:00:00 2001
From: 杨乐 <yang.le.192@qq.com>
Date: 星期五, 21 一月 2022 08:57:42 +0800
Subject: [PATCH] 设备维修派工单  审核/反审核

---
 WebAPI/DLL/ClsSc_MESReturnStepWorkBill.cs |   43 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/WebAPI/DLL/ClsSc_MESReturnStepWorkBill.cs b/WebAPI/DLL/ClsSc_MESReturnStepWorkBill.cs
index 33c00b7..fb0bd06 100644
--- a/WebAPI/DLL/ClsSc_MESReturnStepWorkBill.cs
+++ b/WebAPI/DLL/ClsSc_MESReturnStepWorkBill.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Data;
 using System.Linq;
 using System.Web;
 
@@ -66,11 +67,12 @@
                 oCn.RunProc("Insert Into Sc_ProcessPlanSub " +
                     "(HInterID,HEntryID,HBillNo" +
                     ",HICMOInterID,HICMOBillNo,HProcNo,HProcID" +
-                    ",HGroupID,HDeptID,HWorkerID,HQty,HPlanBeginDate" +
+                    ",HGroupID,HDeptID,HWorkerID,HQty,HPlanBeginDate,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                     ") " +
                     " values(" + omodel.HInterID.ToString() + ",0,'" + omodel.HBillNo +
                     "'," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "','" + omodel.HProcNo + "'," + omodel.HProcID.ToString() + "," + omodel.HGroupID.ToString() +
-                    "," + omodel.HDeptID.ToString() + "," + omodel.HWorkerID.ToString() + "," + omodel.HQty.ToString() + ",'" + omodel.HPlanBeginDate.ToString() +
+                    "," + omodel.HDeptID.ToString() + "," + omodel.HWorkerID.ToString() + "," + omodel.HQty.ToString() + ",'" + omodel.HPlanBeginDate.ToString() + "'," + omodel.HSourceInterID.ToString() +
+                    "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSourceBillType +
                      "') ");
                 sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
                 oCn.Commit();
@@ -88,6 +90,21 @@
         {
             try
             {
+                //鑾峰彇褰撳墠宸ュ簭宸ュ簭鍙蜂互鍙婂垽鏂槸鍚︽湯閬撳伐搴�
+                string sql = string.Format(@"select max(b.HProcNo) HProcNo  from Sc_ProcessPlanMain a
+                               inner join   Sc_ProcessPlanSub  b on a.HInterID=b.HInterID  
+                               where b.HSourceBillNo='" + omodel.HSourceBillNo+"' and b.HSourceInterID='"+omodel.HSourceInterID+"'  and b.HSourceEntryID='"+omodel.HSourceEntryID+"'");
+                DataSet ds= oCn.RunProcReturn(sql, "Sc_ProcessPlanMain");
+                //鏌ヨ鏈�澶у伐搴忓強鍒ゆ柇褰撳墠宸ュ簭鏄惁灏忎簬鏈�澶у伐搴�
+                if (ds.Tables[0].Rows.Count > 0 && int.Parse(ds.Tables[0].Rows[0]["HProcNo"].ToString()) > omodel.HProcID)
+                {
+                    omodel.HProcNo = omodel.HProcNo + 5;
+                }
+                else 
+                {
+                    omodel.HProcNo = omodel.HProcNo + 5; //鏈亾宸ュ簭搴忓彿鍔�5
+                }
+
                 //寰楀埌mainid
                 omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                 //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
@@ -106,12 +123,28 @@
                 oCn.RunProc("Insert Into Sc_ProcessPlanSub " +
                     "(HInterID,HEntryID,HBillNo" +
                     ",HICMOInterID,HICMOBillNo,HProcNo,HProcID" +
-                    ",HGroupID,HDeptID,HWorkerID,HQty,HPlanBeginDate" +
+                    ",HGroupID,HDeptID,HWorkerID,HQty,HPlanBeginDate,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HSourceID" +
                     ") " +
                     " values(" + omodel.HInterID.ToString() + ",0,'" + omodel.HBillNo +
                     "'," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "','" + omodel.HProcNo + "'," + omodel.HProcID.ToString() + "," + omodel.HGroupID.ToString() +
-                    "," + omodel.HDeptID.ToString() + "," + omodel.HWorkerID.ToString() + "," + omodel.HQty.ToString() + ",'" + omodel.HPlanBeginDate.ToString() +
-                     "') ");
+                    "," + omodel.HDeptID.ToString() + "," + omodel.HWorkerID.ToString() + "," + omodel.HQty.ToString() + ",'" + omodel.HPlanBeginDate.ToString() +"',"+ omodel.HSourceInterID.ToString()+
+                    ","+ omodel.HSourceEntryID.ToString()+",'"+ omodel.HSourceBillNo+"','"+ omodel.HSourceBillType+","+ omodel.HSourceID.ToString()+
+                     ") ");
+                //鏂板鐢熶骇鐘舵�佷复鏃惰〃
+                string sql1 = string.Format(@"insert into Sc_ICMOBillStatus_Tmp(HYear,HPeriod,HBillType,HDate,HDeptID,HICMOInterID,HICMOEntryID,HICMOBillNo,HYX,HSplitNO,HICMOStatus,HMaterID
+                                    ,HMaterNumber,HUnitID,HUnitNumber,HSourceID,HSourceNumber,HSplitPlanQty,HSplitRelationQty,HDatePlanQty
+                                    ,HUnitFinishQty,HDateFinishQty,HBadQty,HUnitBadQty,HWasterQty,HSumTimes,HFinishFlag,HCurWorkFlag,HCurQualityFlag
+                                    ,HBeginDate,HEndDate,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo
+                                    ,HSourceBillType,HRelationInterID,HEnoughMaterFlag,HProcID,HPlanQty)
+                                    select HYear,HPeriod,HBillType,HDate,HDeptID,HICMOInterID,HICMOEntryID,HICMOBillNo,HYX,HSplitNO,HICMOStatus,HMaterID
+                                    ,HMaterNumber,HUnitID,HUnitNumber,HSourceID,HSourceNumber,HPlanQty,HSplitPlanQty,HSplitRelationQty,HDatePlanQty
+                                    ,HUnitFinishQty,HDateFinishQty,HBadQty,HUnitBadQty,HWasterQty,HSumTimes,HFinishFlag,HCurWorkFlag,HCurQualityFlag
+                                    ,HBeginDate,HEndDate,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo
+                                    ,HSourceBillType,HRelationInterID,HEnoughMaterFlag,HProcID,'"+omodel.HQty.ToString()+"' " +
+                                    "from Sc_ICMOBillStatus_Tmp where HSourceBillNo='"+omodel.HSourceBillNo.ToString()+"'" +
+                                    " and HSourceInterID='"+omodel.HSourceInterID+"' and HSourceEntryID='"+omodel.HMainSourceEntryID.ToString()+"'" +
+                                    " and HSourceID='"+omodel.HSourceID.ToString()+"' and HProcID='"+omodel.HProcID.ToString()+"'");
+                oCn.RunProc(sql);
                 sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
                 oCn.Commit();
                 return true;

--
Gitblit v1.9.1