From 0529fdff6aec54e5af03e69af16bfe73139ee46c Mon Sep 17 00:00:00 2001
From: cnf <3200815559@qq.com>
Date: 星期一, 24 三月 2025 17:12:57 +0800
Subject: [PATCH] 控制层修改,之前没办法调getlist

---
 MESApplication/bin/Debug/net8.0/MESApplication.pdb                      |    0 
 MES.Service/service/ProductionOrder/ProductionOrderManager.cs           |  200 ++++++++++++++++++++++---------------------------
 MESApplication/bin/Debug/net8.0/MESApplication.exe                      |    0 
 MESApplication/bin/Debug/net8.0/MES.Service.pdb                         |    0 
 MESApplication/bin/Debug/net8.0/MESApplication.dll                      |    0 
 MES.Service/bin/Debug/net8.0/MES.Service.dll                            |    0 
 MESApplication/Controllers/ProductionOrder/ProductionOrderController.cs |    4 
 MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs     |    2 
 MES.Service/Modes/ProductionOrder/FileInfoProduction.cs                 |   16 ++++
 MESApplication/bin/Debug/net8.0/MES.Service.dll                         |    0 
 MES.Service/bin/Debug/net8.0/MES.Service.pdb                            |    0 
 11 files changed, 108 insertions(+), 114 deletions(-)

diff --git a/MES.Service/Modes/ProductionOrder/FileInfoProduction.cs b/MES.Service/Modes/ProductionOrder/FileInfoProduction.cs
new file mode 100644
index 0000000..b4034ef
--- /dev/null
+++ b/MES.Service/Modes/ProductionOrder/FileInfoProduction.cs
@@ -0,0 +1,16 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MES.Service.Modes.ProductionOrder;
+
+public class FileInfoProduction
+{
+    public string spaceId { get; set; }
+    public string fileName { get; set; }
+    public long fileSize { get; set; }
+    public string fileType { get; set; }
+    public string fileId { get; set; }
+}
diff --git a/MES.Service/bin/Debug/net8.0/MES.Service.dll b/MES.Service/bin/Debug/net8.0/MES.Service.dll
index 06e0487..d4f4f04 100644
--- a/MES.Service/bin/Debug/net8.0/MES.Service.dll
+++ b/MES.Service/bin/Debug/net8.0/MES.Service.dll
Binary files differ
diff --git a/MES.Service/bin/Debug/net8.0/MES.Service.pdb b/MES.Service/bin/Debug/net8.0/MES.Service.pdb
index a0dca01..76c7820 100644
--- a/MES.Service/bin/Debug/net8.0/MES.Service.pdb
+++ b/MES.Service/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
diff --git a/MES.Service/service/ProductionOrder/ProductionOrderManager.cs b/MES.Service/service/ProductionOrder/ProductionOrderManager.cs
index 1a4f3a7..f7cab5a 100644
--- a/MES.Service/service/ProductionOrder/ProductionOrderManager.cs
+++ b/MES.Service/service/ProductionOrder/ProductionOrderManager.cs
@@ -73,7 +73,7 @@
         return new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client(config);
     }
 
-    public string GetSpaceId()
+    public string GetProductionDetail( string InstanceId)
     {
         string accessToken = GetToken();
         if (string.IsNullOrEmpty(accessToken))
@@ -81,18 +81,48 @@
             return "鑾峰彇 Access Token 澶辫触";
         }
         AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClientOa();
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetAttachmentSpaceHeaders getAttachmentSpaceHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetAttachmentSpaceHeaders();
-        getAttachmentSpaceHeaders.XAcsDingtalkAccessToken = accessToken;
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetAttachmentSpaceRequest getAttachmentSpaceRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetAttachmentSpaceRequest
+        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceHeaders getProcessInstanceHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceHeaders();
+        getProcessInstanceHeaders.XAcsDingtalkAccessToken = accessToken;
+        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceRequest getProcessInstanceRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceRequest
         {
-            UserId = "923188102",
-            AgentId = 3179487642,
+            ProcessInstanceId = InstanceId,
         };
         try
         {
 
-            var response = client.GetAttachmentSpaceWithOptions(getAttachmentSpaceRequest, getAttachmentSpaceHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
-            return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body));
+            var response = client.GetProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+
+            // 灏嗗搷搴斾綋杞崲涓� JSON 瀛楃涓�
+            var responseJson = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
+
+            // 瑙f瀽 JSON 瀛楃涓蹭负鍔ㄦ�佸璞�
+            dynamic responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseJson);
+
+          
+
+            // 鏌ユ壘 "鐢熶骇鍒堕�犲崟" 瀵瑰簲鐨� Value
+            string fileId = null;
+            foreach (var formValue in responseObj.Result.FormComponentValues)
+            {
+                if (formValue.Name == "鐢熶骇鍒堕�犲崟" && formValue.Value != null)
+                {
+                    // 瑙f瀽 Value 涓殑 JSON 鏁扮粍
+                    var fileInfoArray = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FileInfoProduction>>(formValue.Value.ToString());
+                  
+                    if (fileInfoArray != null && fileInfoArray.Count > 0)
+                    {
+                        fileId = fileInfoArray[0].fileId; // 鎻愬彇绗竴涓枃浠剁殑 fileId
+                      
+                        break;
+                    }
+                }
+            }
+
+            Debug.WriteLine(fileId);
+
+            var result = GetDownloadUrl(fileId, InstanceId);
+
+            return (Newtonsoft.Json.JsonConvert.SerializeObject(result));
         }
         catch (TeaException err)
         {
@@ -103,16 +133,9 @@
             return $"Exception: {_err.Message}";
         }
      }
-    public string GetProcessList()
+
+    public string GetDownloadUrl(string fileId, string InstanceId)
     {
-
-        DateTime targetTime = new DateTime(2025, 3, 10, 0, 0, 0, DateTimeKind.Utc);
-        // 杞崲涓� Unix 鏃堕棿鎴�
-        long unixTimestamp = ((DateTimeOffset)targetTime).ToUnixTimeMilliseconds();
-        Debug.WriteLine(unixTimestamp);  
-
-        long currentTimestamp = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds();
-        Debug.WriteLine(currentTimestamp);  // 杈撳嚭褰撳墠鏃堕棿鐨� Unix 鏃堕棿鎴�
 
         string accessToken = GetToken();
         if (string.IsNullOrEmpty(accessToken))
@@ -120,65 +143,18 @@
             return "鑾峰彇 Access Token 澶辫触";
         }
         AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClientOa();
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsHeaders listProcessInstanceIdsHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsHeaders();
-        listProcessInstanceIdsHeaders.XAcsDingtalkAccessToken = accessToken;
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsRequest listProcessInstanceIdsRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsRequest
+        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GrantProcessInstanceForDownloadFileHeaders grantProcessInstanceForDownloadFileHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GrantProcessInstanceForDownloadFileHeaders();
+        grantProcessInstanceForDownloadFileHeaders.XAcsDingtalkAccessToken = accessToken;
+        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GrantProcessInstanceForDownloadFileRequest grantProcessInstanceForDownloadFileRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GrantProcessInstanceForDownloadFileRequest
         {
-            ProcessCode = "PROC-BBA5632D-DC7C-4267-A3E2-757E2B7023BC",
-            StartTime = unixTimestamp,
-            EndTime = currentTimestamp,
-            NextToken = 0,
-            MaxResults = 10,
-            UserIds = new List<string>
-                {
-                    "923188102"
-                },
-            //Statuses = new List<string>
-            //    {
-                
-            //    },
-        };
-
-        try
-        {
-            var response = client.ListProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
-            return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body));
-        }
-        catch (TeaException err)
-        {
-            return $"TeaException: Code={err.Code}, Message={err.Message}";
-        }
-        catch (Exception _err)
-        {
-            return $"Exception: {_err.Message}";
-        }
-
-    }
-
-    public string GetPermissions()
-    {
-        string accessToken = GetToken();
-        if (string.IsNullOrEmpty(accessToken))
-        {
-            return "鑾峰彇 Access Token 澶辫触";
-        }
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClientOa();
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthHeaders getSpaceWithDownloadAuthHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthHeaders();
-        getSpaceWithDownloadAuthHeaders.XAcsDingtalkAccessToken = accessToken;
-        AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthRequest getSpaceWithDownloadAuthRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthRequest
-        {
-            UserId = "071839512032683883",
-            AgentId = 3179487642,
-            ProcessInstanceId = "3vHyv40ZQUe2zK6wvl11dg06561742534701",
-            FileId = "173564282626",
-            //FileIdList = new List<string>
-            //    {
-            //        "123"
-            //    },
+            ProcessInstanceId = InstanceId,
+            FileId = fileId,
         };
         try
         {
-            var response = client.GetSpaceWithDownloadAuthWithOptions(getSpaceWithDownloadAuthRequest, getSpaceWithDownloadAuthHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+
+            var response = client.GrantProcessInstanceForDownloadFileWithOptions(grantProcessInstanceForDownloadFileRequest, grantProcessInstanceForDownloadFileHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+
             return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body));
         }
         catch (TeaException err)
@@ -197,48 +173,48 @@
          * @return Client
          * @throws Exception
          */
-    public static AlibabaCloud.SDK.Dingtalkyida_1_0.Client CreateClient()
-    {
-        AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
-        config.Protocol = "https";
-        config.RegionId = "central";
-        return new AlibabaCloud.SDK.Dingtalkyida_1_0.Client(config);
-    }
+    //public static AlibabaCloud.SDK.Dingtalkyida_1_0.Client CreateClient()
+    //{
+    //    AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
+    //    config.Protocol = "https";
+    //    config.RegionId = "central";
+    //    return new AlibabaCloud.SDK.Dingtalkyida_1_0.Client(config);
+    //}
 
-    public string GetFileUrl(string imageUrl)
-    {
+    //public string GetFileUrl(string imageUrl)
+    //{
 
-        string accessToken = GetToken();
-        if (string.IsNullOrEmpty(accessToken))
-        {
-            return "鑾峰彇 Access Token 澶辫触";
-        }
-        AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient();
-        AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders getOpenUrlHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders();
-        getOpenUrlHeaders.XAcsDingtalkAccessToken = accessToken;
-        AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest getOpenUrlRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest
-        {
-            SystemToken = "54A66HC1YDSSO9DP61Y93CWQ2W9B36IZZOY6MC81",
-            UserId = "923188102",
-            Language = "zh_CN",
-            FileUrl = imageUrl,
-            Timeout = 3600000,
-        };
-        try
-        {
+    //    string accessToken = GetToken();
+    //    if (string.IsNullOrEmpty(accessToken))
+    //    {
+    //        return "鑾峰彇 Access Token 澶辫触";
+    //    }
+    //    AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient();
+    //    AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders getOpenUrlHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders();
+    //    getOpenUrlHeaders.XAcsDingtalkAccessToken = accessToken;
+    //    AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest getOpenUrlRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest
+    //    {
+    //        SystemToken = "54A66HC1YDSSO9DP61Y93CWQ2W9B36IZZOY6MC81",
+    //        UserId = "923188102",
+    //        Language = "zh_CN",
+    //        FileUrl = imageUrl,
+    //        Timeout = 3600000,
+    //    };
+    //    try
+    //    {
            
-            var response = client.GetOpenUrlWithOptions("APP_Q7PLYKXMKFUJ5HY6DMWR", getOpenUrlRequest, getOpenUrlHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
-            return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body));
-        }
-        catch (TeaException err)
-        {
-            return $"TeaException: Code={err.Code}, Message={err.Message}";
-        }
-        catch (Exception _err)
-        {
-            return $"Exception: {_err.Message}";
-        }
-    }
+    //        var response = client.GetOpenUrlWithOptions("APP_Q7PLYKXMKFUJ5HY6DMWR", getOpenUrlRequest, getOpenUrlHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+    //        return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body));
+    //    }
+    //    catch (TeaException err)
+    //    {
+    //        return $"TeaException: Code={err.Code}, Message={err.Message}";
+    //    }
+    //    catch (Exception _err)
+    //    {
+    //        return $"Exception: {_err.Message}";
+    //    }
+    //}
 
 
     public dynamic Save(ErpProductionOrder erpProductionOrder)
@@ -275,4 +251,6 @@
         if (orUpdate) return true;
         throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�");
     }
+
+
 }
\ No newline at end of file
diff --git a/MESApplication/Controllers/ProductionOrder/ProductionOrderController.cs b/MESApplication/Controllers/ProductionOrder/ProductionOrderController.cs
index 1e94132..eb39d38 100644
--- a/MESApplication/Controllers/ProductionOrder/ProductionOrderController.cs
+++ b/MESApplication/Controllers/ProductionOrder/ProductionOrderController.cs
@@ -16,7 +16,7 @@
 namespace MESApplication.Controllers.ProductionOrder;
 
 [ApiController]
-[Route("api/ProductionOrder")]
+[Route("api/[controller]")]
 public class ProductionOrderController : ControllerBase
 {
     private readonly MessageCenterManager _manager = new();
@@ -164,7 +164,7 @@
             ////resultInfos.tbBillList = save;
 
             Debug.WriteLine(imageUrl);
-            string result = m.GetFileUrl(imageUrl);
+            string result = m.GetProductionDetail(imageUrl);
             Debug.WriteLine(result);
             return Ok(result);
         }
diff --git a/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs b/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
index 24cb605..5e0024f 100644
--- a/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
+++ b/MESApplication/Controllers/QcIssueResult/QcIssueResultController.cs
@@ -14,7 +14,7 @@
 namespace MESApplication.Controllers.QcIssueResult;
 
 [ApiController]
-[Route("api/QcIssueResult")]
+[Route("api/[controller]")]
 public class QcIssueResultController : ControllerBase
 {
     private readonly MessageCenterManager _manager = new();
diff --git a/MESApplication/bin/Debug/net8.0/MES.Service.dll b/MESApplication/bin/Debug/net8.0/MES.Service.dll
index 06e0487..d4f4f04 100644
--- a/MESApplication/bin/Debug/net8.0/MES.Service.dll
+++ b/MESApplication/bin/Debug/net8.0/MES.Service.dll
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MES.Service.pdb b/MESApplication/bin/Debug/net8.0/MES.Service.pdb
index a0dca01..76c7820 100644
--- a/MESApplication/bin/Debug/net8.0/MES.Service.pdb
+++ b/MESApplication/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.dll b/MESApplication/bin/Debug/net8.0/MESApplication.dll
index 7410758..1274950 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.dll
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.dll
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.exe b/MESApplication/bin/Debug/net8.0/MESApplication.exe
index 2aff4ff..a91992a 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.exe
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.exe
Binary files differ
diff --git a/MESApplication/bin/Debug/net8.0/MESApplication.pdb b/MESApplication/bin/Debug/net8.0/MESApplication.pdb
index 0e1a53c..bcad8e4 100644
--- a/MESApplication/bin/Debug/net8.0/MESApplication.pdb
+++ b/MESApplication/bin/Debug/net8.0/MESApplication.pdb
Binary files differ

--
Gitblit v1.9.3