From 7eb6cc3c9be43076802b290645f82e0de74df35f Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期二, 13 五月 2025 07:59:09 +0800
Subject: [PATCH] 1.MES->OA优化 2.MES->OA新增日志
---
Controllers/QC/OAJyController.cs | 13 +++---
service/QC/OaApi.cs | 57 +++++++++++++++++++++++++---
2 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/Controllers/QC/OAJyController.cs b/Controllers/QC/OAJyController.cs
index 3587ecc..fe1f2df 100644
--- a/Controllers/QC/OAJyController.cs
+++ b/Controllers/QC/OAJyController.cs
@@ -15,17 +15,18 @@
OaApiService m = new OaApiService();
[HttpPost("SumbitIQCToOA")]
- public ResponseResult SumbitIQCToOA(dynamic queryObj)
+ public async Task<ResponseResult> SumbitIQCToOA(dynamic queryObj)
{
try
{
- dynamic resultInfos = new ExpandoObject();
- resultInfos = m.SubmitIQCToOA(queryObj);
- var tbBillList = resultInfos;
+ dynamic resultInfos = await m.SubmitIQCToOA(queryObj);
+
return new ResponseResult
{
- status = 0,
- message = "OK",
+ status = (resultInfos.code?.ToString().ToUpper() == "SUCCESS") ? 0 : 1,
+ message = (resultInfos.code?.ToString().ToUpper() == "SUCCESS")
+ ? "OK"
+ : resultInfos.errMsg?.ToString() ?? "鏈煡閿欒",
data = resultInfos
};
}
diff --git a/service/QC/OaApi.cs b/service/QC/OaApi.cs
index 62f6d3f..c299283 100644
--- a/service/QC/OaApi.cs
+++ b/service/QC/OaApi.cs
@@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
+using System.Data.SqlClient;
+using System.Data;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
@@ -63,13 +65,56 @@
// 5. 鍙戦�佽姹�
var response = await PostFormAsync(WorkflowUrl, requestData);
- return JObject.Parse(response);
+
+ // 鏂板鏃ュ織璁板綍锛堝湪杩斿洖鍝嶅簲鍓嶏級
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("prc_log_create", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] logParams =
+ {
+ new("@edtUserGuid", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(queryObj.userId.ToString()) },
+ new("@abtGuid", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(queryObj.qcczdGuid.ToString()) },
+ new("@abtTable", SqlDbType.NVarChar, 40) { Value = "Mes_QC_Exceptional" },
+ new("@detail", SqlDbType.NVarChar, 2500) { Value = "鎻愪氦IQC鍒癘A绯荤粺" },
+ new("@hNo", SqlDbType.NVarChar, 100) { Value = "" },
+ new("@SendJson", SqlDbType.NVarChar) { Value = JObject.FromObject(requestData).ToString() },
+ new("@RtnJson", SqlDbType.NVarChar) { Value = response.Content.ToString() }
+ };
+
+ foreach (var param in logParams)
+ cmd.Parameters.Add(param);
+
+ cmd.ExecuteNonQuery();
+ }
+ catch (Exception logEx)
+ {
+ // 鏃ュ織璁板綍澶辫触涓嶄腑鏂富娴佺▼
+ Console.WriteLine($"鏃ュ織璁板綍澶辫触: {logEx.Message}");
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+
+ return JObject.Parse(response.Content.ToString()); // 鐩存帴瑙f瀽涓篔Object
+
+
+
}
catch (Exception ex)
{
dynamic error = new ExpandoObject();
- error.Error = true;
- error.Message = ex.Message;
+ error.code = "SYSTEM_INNER_ERROR"; // 鏂板鏍囧噯閿欒鐮�
+ error.errMsg = ex.Message; // 淇瀛楁鍚嶅尮閰嶈鑼�
+ error.data = new JObject();
+ error.reqFailMsg = new JObject();
return error;
}
}
@@ -159,7 +204,7 @@
'http://192.168.1.145:81/upload/'+url_Path as url
FROM [Mes_QC_Exceptional_Detail] A
LEFT JOIN MES_QA_ITEMS_DETECT_01 B ON A.releaseNo = B.release_no
-LEFT JOIN MES_FILE C ON C.parent_Guid = B.guid
+RIGHT JOIN MES_FILE C ON C.parent_Guid = B.guid
WHERE pGuid = @guid";
var fileData = Db.Ado.SqlQuery<dynamic>(fileSql, new { guid = queryObj.qcczdGuid });
@@ -396,7 +441,7 @@
return encryptedContent;
}
- private async Task<string> PostFormAsync(string url, Dictionary<string, object> data)
+ private async Task<dynamic> PostFormAsync(string url, Dictionary<string, object> data)
{
// 鏀圭敤FormUrlEncodedContent骞舵纭缃瓹ontent-Type
var formData = new List<KeyValuePair<string, string>>();
@@ -423,7 +468,7 @@
// 璋冭瘯杈撳嚭瀹屾暣鍝嶅簲淇℃伅
Console.WriteLine($"瀹屾暣鍝嶅簲锛歕n{responseInfo.ToString(Formatting.Indented)}");
- return responseInfo.ToString();
+ return responseInfo;
}
public void Dispose()
--
Gitblit v1.9.3