From 14c1493badf203b9b65403e6043661127352fc40 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期五, 09 五月 2025 19:01:57 +0800 Subject: [PATCH] 修改 --- StandardInterface/MES.Service/service/QcIssueResult/QcIssueResultManager.cs | 165 +++++++++++++++++-------------------------------------- 1 files changed, 51 insertions(+), 114 deletions(-) diff --git a/StandardInterface/MES.Service/service/QcIssueResult/QcIssueResultManager.cs b/StandardInterface/MES.Service/service/QcIssueResult/QcIssueResultManager.cs index 236aa3f..17d2f46 100644 --- a/StandardInterface/MES.Service/service/QcIssueResult/QcIssueResultManager.cs +++ b/StandardInterface/MES.Service/service/QcIssueResult/QcIssueResultManager.cs @@ -305,12 +305,12 @@ }; AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues12 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues { - Name = "DDPhotoField_QD15KYR764G0", + Name = "DDPhotoField_QD15KYR764G0\r\n", Value = "娴嬭瘯涓嶈壇鍥剧墖", }; AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues13 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues { - Name = "DDAttachment_GLZLFSIWK9S0", + Name = "DDAttachment_GLZLFSIWK9S0\r\n", Value = "闄勪欢", }; AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues14 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues @@ -419,7 +419,7 @@ { var QcIssueResults = new QcIssueResults { - INSTANCEID = ProcessNo, + ProcessNo = ProcessNo, ReleaseNo = ReleaseNo, QcStatu = "" }; @@ -432,44 +432,28 @@ */ public dynamic Save(ErpQcIssueResult erpQcIssueResult) { - //var json = JsonConvert.SerializeObject(erpQcIssueResult); + var json = JsonConvert.SerializeObject(erpQcIssueResult); - ////var saveSuccess = UseTransaction(db => - ////{ - //// var data = GetMesQcIssueResults(erpQcIssueResult); - //// return SaveOrUpdateData(db, data); - ////}); - - //return new + //var saveSuccess = UseTransaction(db => //{ - // SerializedPayload = json, - // ServerTime = DateTime.UtcNow.ToString("O") - //}; + // var data = GetMesQcIssueResults(erpQcIssueResult); + // return SaveOrUpdateData(db, data); + //}); - var mesQcIssueResults = GetMesQcIssueResults(erpQcIssueResult); - - return UseTransaction(db => + return new { - return SaveOrUpdateData(db, mesQcIssueResults) ? 1 : 0; - }) > 0; - + SerializedPayload = json, + ServerTime = DateTime.UtcNow.ToString("O") + }; } public QcIssueResults GetMesQcIssueResults(ErpQcIssueResult erpQcIssueResult) { var mesQcIssueResults = new QcIssueResults { - INSTANCEID = erpQcIssueResult.ProcessNo, + ProcessNo = erpQcIssueResult.ProcessNo, FReview = erpQcIssueResult.FReview, - APPLICATIONNUM = erpQcIssueResult.ApplicationQuantity.ToString(), - BADCAUSES = erpQcIssueResult.BadCauses, - BELONGINGWORKSHOP = erpQcIssueResult.AffiliatedWorkshop, - REVIEWSTATUS = erpQcIssueResult.FReview, - QcStatu = erpQcIssueResult.QcStatus, - ITEMNAME =erpQcIssueResult.ItemName, - ITEMNO =erpQcIssueResult.ItemNo, - SUPPLIERNAME = erpQcIssueResult.SupplierName, - REMARK=erpQcIssueResult.Remark + QcStatu = erpQcIssueResult.QcStatus }; return mesQcIssueResults; @@ -483,7 +467,7 @@ // 鏌ヨ QcIssueResults 琛ㄤ腑鏄惁瀛樺湪鍖归厤鐨勮褰� var mapping = db.Queryable<QcIssueResults>() - .Where(t => t.INSTANCEID == qcIssueResults.INSTANCEID) + .Where(t => t.ProcessNo == qcIssueResults.ProcessNo) .Select(t => new QcIssueResults { ReleaseNo = t.ReleaseNo, @@ -501,20 +485,9 @@ .SetColumns(t => new QcIssueResults { ReleaseNo = ReleaseNo, - INSTANCEID = qcIssueResults.INSTANCEID, - FReview = qcIssueResults.FReview, - APPLICATIONNUM = qcIssueResults.APPLICATIONNUM, - BADCAUSES = qcIssueResults.BADCAUSES, - BELONGINGWORKSHOP = qcIssueResults.BELONGINGWORKSHOP, - REVIEWSTATUS = qcIssueResults.REVIEWSTATUS, - QcStatu = qcIssueResults.QcStatu, - ITEMNAME = qcIssueResults.ITEMNAME, - ITEMNO = qcIssueResults.ITEMNO, - SUPPLIERNAME = qcIssueResults.SUPPLIERNAME, - REMARK = qcIssueResults.REMARK - + FReview = qcIssueResults.FReview }) - .Where(t => t.INSTANCEID == qcIssueResults.INSTANCEID) // 鏄惧紡鎸囧畾鏇存柊鏉′欢 + .Where(t => t.ProcessNo == qcIssueResults.ProcessNo) // 鏄惧紡鎸囧畾鏇存柊鏉′欢 .ExecuteCommand(); // 鏌ヨ UpdateMesQaItems 琛ㄤ腑鏄惁瀛樺湪鍖归厤鐨勮褰� @@ -526,28 +499,41 @@ if (existingRecord != null) { + string result = null; + bool returnValue = false; try { - //瀹氫箟杈撳叆鍙傛暟 - var inputParam1 = new SugarParameter("pi_no", existingRecord.ReleaseNo); - var inputParam2 = new SugarParameter("pi_user", "PL017"); - // 瀹氫箟杈撳嚭鍙傛暟 - var outParam1 = new SugarParameter("po_result", null, true); - var outParam2 = new SugarParameter("po_msg", null, true); - // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ - Db.Ado.ExecuteCommand("BEGIN PRC_MES_IQC_CG_REVOCK(:pi_no,:pi_user,:po_result,:po_msg ); END;", inputParam1, inputParam2, outParam1, outParam2); - // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� - int result = int.Parse((string)outParam1.Value); - string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; - if (result == 1) + string connectionString = "User Id=yc_dev;Password=ycdev;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))"; + using (OracleConnection connection = new OracleConnection(connectionString)) { - //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊� - db.Ado.RollbackTran(); - throw new Exception(message); + using (OracleCommand command = new OracleCommand("PRC_MES_IQC_CG_REVOCK", connection)) + { + command.CommandType = CommandType.StoredProcedure; + // 娣诲姞杈撳叆鍙傛暟 + command.Parameters.Add("pi_no", OracleDbType.Varchar2).Value = existingRecord.ReleaseNo; // 鏇挎崲涓哄疄闄呭�� + command.Parameters.Add("pi_user", OracleDbType.Varchar2).Value = "PL017"; // 鏇挎崲涓哄疄闄呭�� + // 娣诲姞杈撳嚭鍙傛暟 + OracleParameter poResult = new OracleParameter("po_result", OracleDbType.Int32, ParameterDirection.Output); + OracleParameter poMsg = new OracleParameter("po_msg", OracleDbType.Varchar2, 4000, ParameterDirection.Output); + command.Parameters.Add(poResult); + command.Parameters.Add(poMsg); + // 鎵撳紑杩炴帴骞舵墽琛屽懡浠� + connection.Open(); + command.ExecuteNonQuery(); + // 澶勭悊杩斿洖鍊� + if (poResult.Value != null && poResult.Value.ToString() == "0") + { + returnValue = true; + } + else + { + // 杈撳嚭閿欒淇℃伅 + string errorMsg = poMsg.Value != null ? poMsg.Value.ToString() : "Unknown error occurred"; + Console.WriteLine("Error: " + errorMsg); + } + } } - // 鎻愪氦浜嬪姟 - db.Ado.CommitTran(); - return true; + return returnValue; } catch (Exception ex) { @@ -568,20 +554,9 @@ .SetColumns(t => new QcIssueResults { ReleaseNo = ReleaseNo, - INSTANCEID = qcIssueResults.INSTANCEID, - FReview = qcIssueResults.FReview, - APPLICATIONNUM = qcIssueResults.APPLICATIONNUM, - BADCAUSES = qcIssueResults.BADCAUSES, - BELONGINGWORKSHOP = qcIssueResults.BELONGINGWORKSHOP, - REVIEWSTATUS = qcIssueResults.REVIEWSTATUS, - QcStatu = qcIssueResults.QcStatu, - ITEMNAME = qcIssueResults.ITEMNAME, - ITEMNO = qcIssueResults.ITEMNO, - SUPPLIERNAME = qcIssueResults.SUPPLIERNAME, - REMARK = qcIssueResults.REMARK - + FReview = qcIssueResults.FReview }) - .Where(t => t.INSTANCEID == qcIssueResults.INSTANCEID) // 鏄惧紡鎸囧畾鏇存柊鏉′欢 + .Where(t => t.ProcessNo == qcIssueResults.ProcessNo) // 鏄惧紡鎸囧畾鏇存柊鏉′欢 .ExecuteCommand(); // 鏌ヨ UpdateMesQaItems 琛ㄤ腑鏄惁瀛樺湪鍖归厤鐨勮褰� @@ -594,7 +569,7 @@ if (existingRecord != null) { // 鏇存柊 UpdateMesQaItems 琛ㄤ腑鐨勫瓧娈� - existingRecord.FngHandle = qcIssueResults.REVIEWSTATUS; + existingRecord.FngHandle = qcIssueResults.FReview; if (existingRecord.FngHandle == "閫�璐�") { existingRecord.FMRMODE = "閫�鏂欒ˉ鏂�"; @@ -606,44 +581,6 @@ // 鎵ц鏇存柊鎿嶄綔 updateResult = db.Updateable(existingRecord).ExecuteCommand(); - - if (updateResult > 0) - { - try - { - - //瀹氫箟杈撳叆鍙傛暟 - var inputParam1 = new SugarParameter("PI_BILLNO", ReleaseNo); - var inputParam2 = new SugarParameter("PI_USER", "PL017"); - var inputParam3 = new SugarParameter("PI_HANDLE", existingRecord.FngHandle); - var inputParam4 = new SugarParameter("PI_TLFS", existingRecord.FMRMODE); - var inputParam5 = new SugarParameter("PI_REMARK", ""); - - // 瀹氫箟杈撳嚭鍙傛暟 - var outParam1 = new SugarParameter("PO_RESULT", null, true); - var outParam2 = new SugarParameter("PO_MSG", null, true); - // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ - Db.Ado.ExecuteCommand("BEGIN PRC_MES_IQC_CG_SUBMIT(:PI_BILLNO,:PI_BILLNO,:PI_HANDLE,:PI_TLFS,:PI_REMARK,:PO_RESULT,:PO_MSG); END;", inputParam1, inputParam2, inputParam3, inputParam4, inputParam5, outParam1, outParam2); - // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� - int result = int.Parse((string)outParam1.Value); - string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; - if (result == 1) - { - //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊� - db.Ado.RollbackTran(); - throw new Exception(message); - } - // 鎻愪氦浜嬪姟 - db.Ado.CommitTran(); - return true; - - } - catch (Exception ex) - { - Console.WriteLine("Exception: " + ex.Message); - return false; - } - } return updateResult > 0; // 濡傛灉鏇存柊鎴愬姛锛岃繑鍥� true } -- Gitblit v1.9.3