From 6f720a380ec3917c256fdf95f4c2aa7a44017d05 Mon Sep 17 00:00:00 2001
From: shuailong 陈 <3501773624@qq.com>
Date: 星期五, 07 十一月 2025 17:44:28 +0800
Subject: [PATCH] 增加日志记录

---
 MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs |   71 +++++++++++++++++++++++++++++++----
 1 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs b/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
index 82ac388..2895da9 100644
--- a/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
+++ b/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
@@ -1,7 +1,9 @@
-锘縰sing MES.Service.Dto.webApi;
+锘縰sing AngleSharp.Dom;
+using MES.Service.Dto.webApi;
 using MES.Service.Dto.webApi.QcIssueResult;
 using MES.Service.Modes;
 using MES.Service.Modes.QcIssueResult;
+using MES.Service.Modes.SentLaboratory;
 using MES.Service.service;
 using MES.Service.service.QcIssueResult;
 using MES.Service.util;
@@ -10,11 +12,15 @@
 using Newtonsoft.Json.Linq;
 using System.Diagnostics;
 using System.Dynamic;
+using System.Net;
+using System.Text;
+using System.Text.Json.Nodes;
+using System.Web;
 
 namespace MESApplication.Controllers.QcIssueResult;
 
 [ApiController]
-[Route("api/QcIssueResult")]
+[Route("api/[controller]")]
 public class QcIssueResultController : ControllerBase
 {
     private readonly MessageCenterManager _manager = new();
@@ -30,33 +36,82 @@
     [HttpPost("GetProcessNo")]
     public IActionResult StartDingtalkProcess([FromBody] GetQcIssueResultDetail getQcIssueResultDetail)
     {
-   
+
+        var entity = new MessageCenter();
+        entity.TableName = TableName;
+        entity.Url = URL + "Save";
+        entity.Method = METHOD;
+        entity.Data = JsonConvert.SerializeObject(getQcIssueResultDetail);
+        entity.Status = 1;
+        entity.CreateBy = "PL017";
+
         try
         {
+            // 鏂板URL瑙g爜澶勭悊閫昏緫
+            DecodeUrlEncodedProperties(getQcIssueResultDetail);
+
             // 璋冪敤 QcIssueResultManager 涓殑 GetProcessNo 鏂规硶鏉ュ惎鍔ㄩ拤閽夊伐浣滄祦瀹炰緥
             string result = m.GetProcessNo(getQcIssueResultDetail);
 
-            string jsonPart = result.Substring(result.IndexOf("{"));
-            Debug.WriteLine(jsonPart);
-            JObject jsonObject = JObject.Parse(jsonPart);
+            string getLaboratoryDetailsJson = JsonConvert.SerializeObject(getQcIssueResultDetail, Formatting.Indented);
+            Debug.WriteLine("getQcIssueResultDetail: " + getLaboratoryDetailsJson);
 
+            string jsonPart = result.Substring(result.IndexOf("{"));
+            JObject jsonObject = JObject.Parse(jsonPart);
             // 鎻愬彇instanceId鐨勫��
             string instanceId = jsonObject["InstanceId"].ToString();
 
             dynamic resultInfos = new ExpandoObject();
             string ProcessNo = instanceId;
-            //var save = m.SaveProcessNo(ReleaseNo, instanceId);
-            //resultInfos.tbBillList = save;
+            var save = m.SaveProcessNo(getQcIssueResultDetail.ReleaseNo, instanceId);
+            resultInfos.tbBillList = save;
+
+            if (save) entity.Result = 1;
+            entity.DealWith = 1;
+
+            _manager.save(entity);
 
             return Ok(result);
         }
         catch (Exception ex)
         {
             // 鎹曡幏寮傚父骞惰繑鍥為敊璇俊鎭�
+
+            entity.Result = 0;
+
+            entity.DealWith = 0;
+
+            entity.ResultData = ex.Message;
+
+            _manager.save(entity);
+
+            //return ResponseResult.ResponseError(ex);
+
             return StatusCode(500, $"鍚姩閽夐拤宸ヤ綔娴佸疄渚嬪け璐�: {ex.Message}");
         }
     }
 
+    // 鏂板瑙g爜鏂规硶
+    private void DecodeUrlEncodedProperties(object obj)
+    {
+        if (obj == null) return;
+
+        var properties = obj.GetType().GetProperties();
+        foreach (var prop in properties)
+        {
+            // 鍙鐞嗗瓧绗︿覆绫诲瀷鐨勫睘鎬�
+            if (prop.PropertyType == typeof(string) && prop.CanWrite)
+            {
+                var value = prop.GetValue(obj) as string;
+                if (!string.IsNullOrEmpty(value))
+                {
+                    // 浣跨敤UTF8缂栫爜杩涜瑙g爜
+                    var decodedValue = HttpUtility.UrlDecode(value, Encoding.UTF8);
+                    prop.SetValue(obj, decodedValue);
+                }
+            }
+        }
+    }
 
     [HttpPost("Save")]
     public ResponseResult Save(ErpQcIssueResult erpQcIssueResult)

--
Gitblit v1.9.3