From f2bbd33bf5d4a95a138bed23e4990e9a2cbb6032 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期三, 15 十一月 2023 09:00:36 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  208 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 195 insertions(+), 13 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index 1a67950..0038234 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -83,7 +83,7 @@
                     return objJsonResult;
                 }
 
-                if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "")
+                if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "姝e父")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -411,6 +411,16 @@
                 sub = JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(sSubStr);
 
 
+                ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList where 浜у搧鏉$爜='" + omodel.HBarCode_P + "'", "h_v_Gy_QualifiedRecordsList");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏉$爜:" + omodel.HBarCode_P + ",宸插瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
                 string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
                 //淇濆瓨鐢熶骇缁勮鍗曚富琛�
@@ -531,8 +541,15 @@
                   "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ") ");
                 }
 
+              
+
+                ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN 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)
-values({omodel.HInterID}, '{omodel.HBillNo}', {ds.Tables[0].Rows.Count + 1}, '{omodel.HBarCode_P}', 1, GETDATE(), '', 0, 0, '', '', 0, 0)");
+values({omodel.HInterID}, '{omodel.HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{omodel.HBarCode_P}', 1, GETDATE(), '', " + HProcExchInterID + ","+ HProcExchEntryID + ", '"+ HProcExchBillNo + "', '', 0, 0)");
+
+                //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
+                oCN.RunProc("update Sc_StationOutBillMain set HQty+=1  where HProcExchInterID='" + HProcExchInterID + "' and HProcExchEntryID=" + HProcExchEntryID);
 
                 oCN.Commit();
 
@@ -572,14 +589,20 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                else
+
+                if (ds.Tables[0].Rows[0]["HStatus"].ToString() !="")
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "";
-                    objJsonResult.data = ds.Tables[0];
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "褰撳墠鏉$爜鐨勭姸鎬佷负:"+ ds.Tables[0].Rows[0]["HStatus"].ToString() + "锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
                 }
 
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "";
+                objJsonResult.data = ds.Tables[0];
                 return objJsonResult;
             }
             catch (Exception e)
@@ -625,7 +648,7 @@
                     return objJsonResult;
                 }
 
-                if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "") {
+                if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "姝e父") {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "褰撳墠鏉$爜鐘舵�佷负"+ ds.Tables[0].Rows[0]["HStatus"].ToString() + "!";
@@ -682,12 +705,12 @@
         #region  宸ュ簭鍗曞搧杩囩珯 鏌ヨ鍚堟牸璁板綍
         [Route("Cj_SingleStation/HGRecordsList")]
         [HttpGet]
-        public object HGRecordsList(string HBarCode, string user)
+        public object HGRecordsList(string sWhere, string user)
         {
             try
             {
 
-                ds = oCN.RunProcReturn(@"select * from h_v_Sc_AssemblyBillList where HProcExchBillNo='" + HBarCode + "'", "h_v_Sc_AssemblyBillList");
+                ds = oCN.RunProcReturn(@"select * from h_v_Gy_QualifiedRecordsList where 1=1"+ sWhere, "h_v_Gy_QualifiedRecordsList");
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -701,6 +724,116 @@
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ュ簭鍗曞搧杩囩珯 鍒犻櫎涓嶈壇璁板綍
+        [Route("Cj_SingleStation/DelBadRecords")]
+        [HttpGet]
+        public object DelBadRecords(int HInterID, int HEntryID, string user,int HProcID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from h_v_Gy_BadRecordsList  where HInterID = " + HInterID, "h_v_Gy_BadRecordsList");
+
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏌ユ棤鏁版嵁锛�";
+                    objJsonResult.data = null;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "";
+                sql = "delete from Sc_QualityReportBillMain where HInterID = " + HInterID;
+                oCN.RunProc(sql);
+                sql = "delete from Sc_QualityReportBillSub where HInterID = " + HInterID + " and HEntryID = " + HEntryID;
+                oCN.RunProc(sql);
+                string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
+                string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
+                //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑涓嶈壇鏁伴噺
+                oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1  where HProcExchInterID='" + HProcExchInterID + "' and HProcExchEntryID=" + HProcExchEntryID);
+
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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;
+            }
+        }
+        #endregion
+
+        #region 宸ュ簭鍗曞搧杩囩珯 鍒犻櫎鍚堟牸璁板綍
+        [Route("Cj_SingleStation/DelQualifiedRecords")]
+        [HttpGet]
+        public object DelQualifiedRecords(int HInterID, int HEntryID, string user)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from h_v_Gy_QualifiedRecordsList  where hmainid = " + HInterID, "h_v_Gy_QualifiedRecordsList");
+
+                string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
+                string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏌ユ棤鏁版嵁锛�";
+                    objJsonResult.data = null;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "";
+                if (ds.Tables[0].Rows.Count == 1) {
+                    sql = "delete from Sc_StationOutBillMain where HInterID = " + HInterID;
+                    oCN.RunProc(sql);
+                }
+                ds = oCN.RunProcReturn("select * from Sc_StationOutBillSub_SN where HInterID = " + HInterID + " and HEntryID = " + HEntryID, "Sc_StationOutBillSub_SN");
+                string HBarCode = ds.Tables[0].Rows[0]["HBarCode"].ToString();
+                string HBillNo_bak = ds.Tables[0].Rows[0]["HBillNo_bak"].ToString();
+
+                //鍒犻櫎缁勮杩芥函鍗�
+                oCN.RunProc("delete from Sc_AssemblyBillSub where HInterID in(select HInterID from Sc_AssemblyBillMain where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID + " and HBarCode_P='" + HBarCode + "')");
+                oCN.RunProc("delete from   Sc_AssemblyBillMain where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID + " and HBarCode_P='" + HBarCode + "'");
+
+                sql = "delete from Sc_StationOutBillSub_SN where HInterID = " + HInterID + " and HEntryID = " + HEntryID;
+                oCN.RunProc(sql);
+                //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
+                oCN.RunProc("update Sc_StationOutBillMain set HQty-=1  where HProcExchInterID='" + HProcExchInterID + "' and HProcExchEntryID=" + HProcExchEntryID+ " and HBillNo='"+ HBillNo_bak + "'");
+
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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;
             }
@@ -815,8 +948,9 @@
                 string[] sArray = msg.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                 string sMainStr = sArray[0].ToString();
                 string sSubStr = sArray[1].ToString();
-                string user = sArray[2].ToString();
-                string HResult = sArray[3].ToString();
+                string sSubStr2 = sArray[2].ToString();
+                string user = sArray[3].ToString();
+                string HResult = sArray[4].ToString();
 
                 oCN.BeginTran();
                 if (HResult == "閰嶄欢")
@@ -836,8 +970,56 @@
 ({model.HInterID},{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{model.HBillNo}','',{temp.HProcExchInterID}
 ,{temp.HProcExchEntryID},'{temp.HProcExchBillNo}','',{temp.HMaterID},0,'{temp.HBarCode}','{temp.HBatchNo}')");
 
+
+                    ds = oCN.RunProcReturn("select  * from Sc_SourceLineRepairBillSub where HInterID=" + model.HInterID, "Sc_SourceLineRepairBillSub");
+                    if (ds.Tables[0].Rows[0]["HRepairResult"].ToString() == "OK") {
+                        //鐢熸垚 浜х嚎缁勮杩芥函鍗�
+
+                        Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
+                        string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
+
+                        ds = oCN.RunProcReturn("select  * from Sc_SourceLineRepairBillMain where HInterID=" + model.HInterID, "Sc_SourceLineRepairBillMain");
+                        string HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        //淇濆瓨鐢熶骇缁勮鍗曚富琛�
+                        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(),{temp.HProcExchInterID.ToString()},{temp.HProcExchEntryID.ToString()},'{temp.HProcExchBillNo.ToString()}'
+,{model.HICMOInterID.ToString()},'{model.HICMOBillNo.ToString()}','{model.HBarCode.ToString()}',{HMaterID},0,'姹囨姤',{model.HProdOrgID})";
+                        oCN.RunProc(sql);
+
+                       List<Model.Sc_AssemblyBill_BindSourceTemp>  sub = new List<Model.Sc_AssemblyBill_BindSourceTemp>();
+                        sub = JsonConvert.DeserializeObject<List<Model.Sc_AssemblyBill_BindSourceTemp>>(sSubStr2);
+
+                        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,{sub[i].HQty}
+,0,0,getdate(),'{sub[i].HBarCode}','{model.HBarCode}','') ";
+                            oCN.RunProc(sq2);
+                        }
+
+                        //鐢熶骇宸ュ簭鍑虹珯SN鏁版嵁
+                        ds = oCN.RunProcReturn("select top 1  HInterID,HBillNo from Sc_StationOutBillMain where HProcExchInterID=" + temp.HProcExchInterID + " and HProcExchEntryID=" + temp.HProcExchEntryID + " and HBadCount<>0  order by  HInterID desc", "Sc_StationOutBillMain");
+
+                        string HInterIDSN = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                        string HBillNoSN = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+
+                        ds = oCN.RunProcReturn("select *  from Sc_StationOutBillSub_SN where HInterID=" + HInterIDSN , "Sc_StationOutBillSub_SN");
+
+                        oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
+values({HInterIDSN}, '{HBillNoSN}', {ds.Tables[0].Rows.Count + 1}, '{model.HBarCode}', 1, GETDATE(), '', "+ temp.HProcExchInterID + ","+ temp.HProcExchEntryID+ ", '"+ temp.HProcExchBillNo+ "', '', 0, 0)");
+                        //鍙嶅啓宸ュ簭鍑虹珯鍗� 涓昏〃 涓嶈壇鏁伴噺 鍜� 鍚堟牸鏁伴噺
+                        oCN.RunProc("update Sc_StationOutBillMain set HQty+=1,HBadCount-=1  where HInterID='" + HInterIDSN + "'");
+
+                    }
                     //淇敼閰嶄欢缁戝畾娓呭崟缁戝畾鐨勬潯鐮佹壒鍙�
-                    oCN.RunProc("exec h_p_AssemblyBill_Temp '" + temp.HProcExchBillNo + "'," + model.HProcess + "," + temp.HMaterID + ",'" + temp.HBatchNo + "'");
+                    //oCN.RunProc("exec h_p_AssemblyBill_Temp '" + temp.HProcExchBillNo + "'," + model.HProcess + "," + temp.HMaterID + ",'" + temp.HBatchNo + "'");
                 }
                 else if (HResult == "NG"|| HResult == "OK") {
                     Model.ClsSc_SourceLineRepairBillMain model = new Model.ClsSc_SourceLineRepairBillMain();

--
Gitblit v1.9.1