From 4d7047f93580a2a7dd36b915ef05a2ea292e8108 Mon Sep 17 00:00:00 2001
From: cnf <3200815559@qq.com>
Date: 星期四, 20 三月 2025 20:20:56 +0800
Subject: [PATCH] 异常处置单

---
 MES.Service/service/BasicData/ProductionOrderManager.cs |   88 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 1 deletions(-)

diff --git a/MES.Service/service/BasicData/ProductionOrderManager.cs b/MES.Service/service/BasicData/ProductionOrderManager.cs
index da712d9..da236d8 100644
--- a/MES.Service/service/BasicData/ProductionOrderManager.cs
+++ b/MES.Service/service/BasicData/ProductionOrderManager.cs
@@ -1,4 +1,6 @@
-锘縰sing MES.Service.DB;
+锘縰sing AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models;
+using AlibabaCloud.TeaUtil.Models;
+using MES.Service.DB;
 using MES.Service.Dto.webApi;
 using MES.Service.Dto.webApi.DeliveryNote;
 using MES.Service.Modes;
@@ -7,9 +9,93 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Tea;
 
 public class ProductionOrderManager : Repository<ProductionOrders>
 {
+
+    public static AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client CreateClient1()
+    {
+        AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
+        config.Protocol = "https";
+        config.RegionId = "central";
+        return new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client(config);
+    }
+
+    /**
+     * 鑾峰彇閽夐拤鐨� Access Token
+     * @return string 杩斿洖鑾峰彇鍒扮殑 Access Token
+     */
+    public string GetToken()
+    {
+        AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client client = CreateClient1();
+        AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest getAccessTokenRequest = new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest
+        {
+            AppKey = "dingyzos0r1bizj7g6lr",
+            AppSecret = "-HP4RvK2OUbqhG3iBUpd_TPe5MZRj8cfLc0b8Skt8rhC3I38kVLY9SS8P3kLWFcH",
+        };
+
+        try
+        {
+            var response = client.GetAccessToken(getAccessTokenRequest);
+            return response.Body.AccessToken; // 杩斿洖鑾峰彇鍒扮殑 Access Token
+        }
+        catch (TeaException err)
+        {
+            Console.WriteLine($"TeaException: Code={err.Code}, Message={err.Message}");
+            return null;
+        }
+        catch (Exception _err)
+        {
+            Console.WriteLine($"Exception: {_err.Message}");
+            return null;
+        }
+    }
+
+    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 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 = "https://cfw1x5.aliwork.com/inst/filePreview?appType=APP_Q7PLYKXMKFUJ5HY6DMWR&fileName=APP_Q7PLYKXMKFUJ5HY6DMWR_MDcxODM5NTEyMDMyNjgzODgzX09WOTY2V0ExN1lUVFRDS0Q3WjFYTTlQNUw5MVIzTTNaQ1hHOE1SOQ$$.xls",
+            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}";
+        }
+    }
+
+
     public dynamic Save(ErpProductionOrder erpProductionOrder)
     {
         //var erpProductionOrder = productionOrder.erpProductionOrder;

--
Gitblit v1.9.3