kyy
2025-10-23 d739ed99469b37edba4f993ee29db6320ebff91f
增加plm接口
已修改10个文件
已添加13个文件
659 ■■■■■ 文件已修改
MES.Service/Dto/webApi/PLM/BaseObject.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/webApi/PLM/RelatedObject.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/webApi/PLM/StdDocument.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/MES.Service.csproj 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/Kingdee.CDP.WebApi.SDK.dll 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/MES.Service.deps.json 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/MES.Service.dll 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/MES.Service.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/resources/Kingdee.CDP.WebApi.SDK.dll 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/resources/TopSdk.dll 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/PLM/PLMManager.cs 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/PLM/WarehouseDownloadDoc.cs 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Config/appsettings.json 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/PLM/PLMController.cs 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/Config/appsettings.json 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/Kingdee.CDP.WebApi.SDK.dll 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MES.Service.dll 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MES.Service.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.deps.json 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.dll 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.exe 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.staticwebassets.endpoints.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/webApi/PLM/BaseObject.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@

namespace MES.Service.Dto.webApi.PLM;
public class BaseObject
{
    //实体主键
    public long? FID { get; set; }
    //编码
    public string? FCode { get; set; }
    //名称
    public string? FName { get; set; }
}
MES.Service/Dto/webApi/PLM/RelatedObject.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MES.Service.Dto.webApi.PLM;
public class RelatedObject
{
    //实体主键
    public long? FID { get; set; }
    //物料编码
    public string? FRE_FCode { get; set; }
    //相关对象
    public long? FRelatedObject { get; set; }
}
MES.Service/Dto/webApi/PLM/StdDocument.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MES.Service.Dto.webApi.PLM;
public class StdDocument
{
    //实体主键
    public long? FID { get; set; }
    //编码
    public string? FCode { get; set; }
    //名称
    public string? FName { get; set; }
    //物理文件名
    public string? FPhysicalFileName { get; set; }
    //物理文件
    public string? FFileId { get; set; }
    //关联对象 è½¬çš„ pdf
    public string? FRelevantObject { get; set; }
}
MES.Service/MES.Service.csproj
@@ -7,8 +7,14 @@
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Masuit.Tools.Core" Version="2024.3.4"/>
        <PackageReference Include="SqlSugarCore" Version="5.1.4.158"/>
        <PackageReference Include="Masuit.Tools.Core" Version="2024.3.4" />
        <PackageReference Include="SqlSugarCore" Version="5.1.4.158" />
    </ItemGroup>
    <ItemGroup>
      <Reference Include="Kingdee.CDP.WebApi.SDK">
        <HintPath>resources\Kingdee.CDP.WebApi.SDK.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>
MES.Service/bin/Debug/net8.0/Kingdee.CDP.WebApi.SDK.dll
Binary files differ
MES.Service/bin/Debug/net8.0/MES.Service.deps.json
@@ -9,7 +9,8 @@
      "MES.Service/1.0.0": {
        "dependencies": {
          "Masuit.Tools.Core": "2024.3.4",
          "SqlSugarCore": "5.1.4.158"
          "SqlSugarCore": "5.1.4.158",
          "Kingdee.CDP.WebApi.SDK": "8.0.6.0"
        },
        "runtime": {
          "MES.Service.dll": {}
@@ -1061,6 +1062,14 @@
            "fileVersion": "0.8.0.0"
          }
        }
      },
      "Kingdee.CDP.WebApi.SDK/8.0.6.0": {
        "runtime": {
          "Kingdee.CDP.WebApi.SDK.dll": {
            "assemblyVersion": "8.0.6.0",
            "fileVersion": "8.0.6.0"
          }
        }
      }
    }
  },
@@ -1713,6 +1722,11 @@
      "sha512": "sha512-Z62eNBIu8E8YtbqlMy57tK3dV1+m2b9NhPeaYovB5exmLKvrGCqOhJTzrEUH5VyUWU6vwX3c1XHJGhW5HVs8dA==",
      "path": "zstdsharp.port/0.8.0",
      "hashPath": "zstdsharp.port.0.8.0.nupkg.sha512"
    },
    "Kingdee.CDP.WebApi.SDK/8.0.6.0": {
      "type": "reference",
      "serviceable": false,
      "sha512": ""
    }
  }
}
MES.Service/bin/Debug/net8.0/MES.Service.dll
Binary files differ
MES.Service/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
MES.Service/resources/Kingdee.CDP.WebApi.SDK.dll
Binary files differ
MES.Service/resources/TopSdk.dll
Binary files differ
MES.Service/service/PLM/PLMManager.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,189 @@
using Kingdee.CDP.WebApi.SDK;
using MES.Service.Dto.webApi.PLM;
using System.Diagnostics;
using System.Text;
namespace MES.Service.service.PLM;
public class PLMManager
{
    public List<StdDocument> RetrieveDrawings(string ItemNo)
    {
        List<BaseObject> baseObjects = GetPlmCfgBase(ItemNo);
        Debug.WriteLine($"第一完整内容(JSON): {Newtonsoft.Json.JsonConvert.SerializeObject(baseObjects, Newtonsoft.Json.Formatting.Indented)}");
        // æ£€æŸ¥è¿”回结果是否为空
        if (baseObjects == null || !baseObjects.Any())
        {
            throw new NotImplementedException("返回结果为空");
        }
        else
        {
            List<RelatedObject> relatedObjects = GetPlmCfgRelatedObject(baseObjects[0].FID);
            Debug.WriteLine($"第二完整内容(JSON): {Newtonsoft.Json.JsonConvert.SerializeObject(relatedObjects, Newtonsoft.Json.Formatting.Indented)}");
            // æ£€æŸ¥è¿”回结果是否为空
            if (relatedObjects == null || !relatedObjects.Any())
            {
                throw new NotImplementedException("返回结果为空");
            }
            List<StdDocument> stdDocuments = GetPlmStdDocument(relatedObjects);
            return stdDocuments;
        }
    }
    #region 1.通过物料编码(需要唯一)获取物料id
    public List<BaseObject> GetPlmCfgBase(string ItemNo)
    {
        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
        //读取配置,初始化SDK
        K3CloudApi client = new K3CloudApi();
        //用于记录结果
        StringBuilder Info = new StringBuilder();
        //业务对象标识
        //string formId = "PLM_STD_DOCUMENT";
        string formId = "PLM_CFG_BASE";
        DateTime dt = DateTime.Now;
        //查询字段集合,即返回哪些数据,不能为空,根据不同业务单据填写不同的字段名,以下仅为示例
        //string fieldKeys = "FCode,FFileId,FRelevantObject";
        //string FilterString = "FID='-2146304'";
        string fieldKeys = "FID,FCode,FName";
        string FilterString = string.Format(@"FCode='{0}'", ItemNo);
        string OrderString = "";
        int TopRowCount = 0;
        int StartRow = 0;
        int Limit = 0;
        var param = new QueryParam()
        {
            FormId = formId,
            FieldKeys = fieldKeys,
            FilterString = FilterString,
            OrderString = OrderString,
            TopRowCount = TopRowCount,
            StartRow = StartRow,
            Limit = Limit
        };
        //调用接口
        var result = client.ExecuteBillQuery(param.ToJson());
        Debug.WriteLine($"第一个元素内容: {result}");
        return result.Select(s =>
        {
            var entity = new BaseObject
            {
                FID = (long)s[0],
                FCode = (string)s[1],
                FName = (string)s[2],
            };
            return entity;
        }).ToList();
    }
    #endregion
    #region 2.通过物料id获取相关对象【下载需要的文档】的id
    public List<RelatedObject> GetPlmCfgRelatedObject(long? FRelatedObject)
    {
        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
        //读取配置,初始化SDK
        K3CloudApi client = new K3CloudApi();
        //用于记录结果
        StringBuilder Info = new StringBuilder();
        //业务对象标识
        //string formId = "PLM_STD_DOCUMENT";
        string formId = "PLM_CFG_RELATEDOBJECT";
        DateTime dt = DateTime.Now;
        //查询字段集合,即返回哪些数据,不能为空,根据不同业务单据填写不同的字段名,以下仅为示例
        //string fieldKeys = "FCode,FFileId,FRelevantObject";
        //string FilterString = "FID='-2146304'";
        string fieldKeys = "FID,FRE_FCode,FRelatedObject";
        string FilterString = string.Format(@"FRelatedObject='{0}'", FRelatedObject);
        string OrderString = "";
        int TopRowCount = 0;
        int StartRow = 0;
        int Limit = 0;
        var param = new QueryParam()
        {
            FormId = formId,
            FieldKeys = fieldKeys,
            FilterString = FilterString,
            OrderString = OrderString,
            TopRowCount = TopRowCount,
            StartRow = StartRow,
            Limit = Limit
        };
        //调用接口
        var result = client.ExecuteBillQuery(param.ToJson());
        Debug.WriteLine(result);
        return result.Select(s =>
        {
            var entity = new RelatedObject
            {
                FID = (long)s[0],
                FRE_FCode = (string)s[1],
                FRelatedObject = (long)s[2],
            };
            return entity;
        }).ToList();
    }
    #endregion
    #region 3.根据文档id获取文档物理文件id
    public List<StdDocument> GetPlmStdDocument(List<RelatedObject> relatedObjects)
    {
        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
        //读取配置,初始化SDK
        K3CloudApi client = new K3CloudApi();
        //用于记录结果
        StringBuilder Info = new StringBuilder();
        //业务对象标识
        string formId = "PLM_STD_DOCUMENT";
        DateTime dt = DateTime.Now;
        //查询字段集合,即返回哪些数据,不能为空,根据不同业务单据填写不同的字段名,以下仅为示例
        string fieldKeys = "FID,FCode,FName,FPhysicalFileName,FFileId,FRelevantObject";
        // æå– FID å€¼
        var fidList = relatedObjects.Select(obj => obj.FID.ToString()).ToList();
        // å°† FID å€¼ç”¨é€—号分隔,并包裹在单引号中
        string fids = string.Join(",", fidList.Select(fid => $"'{fid}'"));
        // æž„建 FilterString
        string FilterString = $"FID in ({fids})";
        string OrderString = "";
        int TopRowCount = 0;
        int StartRow = 0;
        int Limit = 0;
        var param = new QueryParam()
        {
            FormId = formId,
            FieldKeys = fieldKeys,
            FilterString = FilterString,
            OrderString = OrderString,
            TopRowCount = TopRowCount,
            StartRow = StartRow,
            Limit = Limit
        };
        //调用接口
        var result = client.ExecuteBillQuery(param.ToJson());
        return result.Select(s =>
        {
            var entity = new StdDocument
            {
                FID = (long)s[0],
                FCode = (string)s[1],
                FName = (string)s[2],
                FPhysicalFileName = (string)s[3],
                FFileId = (string)s[4],
                FRelevantObject = (string)s[5],
            };
            return entity;
        }).ToList();
    }
    #endregion
}
MES.Service/service/PLM/WarehouseDownloadDoc.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,146 @@
using Newtonsoft.Json.Linq;
using System.Net;
using System.Text;
namespace ConsoleApp1
{
    #region 1.根据文档物理文件id获取文档流数据
    public class WarehouseDownloadDoc()
    {
        private string _cloudUrl = "http://192.168.0.208/k3cloud";
        private string _warehouse = "http://192.168.0.208/CloudPLMWarehouse";
        #region æ–‡æ¡£æœåŠ¡å™¨ä¸Šä¸‹æ–‡
        private string WarehouseCTX
        {
            get
            {
                //string json = "{\"ap1\":{ \"AcctID\":\"" + "68044981e73323" + "\",\"Username\":\"广深\",\"Password\":\"gs@123456\",\"Lcid\":2052,\"AuthenticateType\":1,\"PasswordIsEncrypted\":\"false\",\"ClientInfo\":{\"ClientType\":8}}";
                string json = "{\"ap1\":{ \"AcctID\":\"" + "66aeecbb0f0a04" + "\",\"Username\":\"demo1\",\"Password\":\"112233\",\"Lcid\":2052,\"AuthenticateType\":1,\"PasswordIsEncrypted\":\"false\",\"ClientInfo\":{\"ClientType\":8}}";
                var resp = GetResponse("http://192.168.0.208/k3cloud/Kingdee.BOS.ServiceFacade.ServicesStub.User.UserService.ValidateLoginInfo.common.kdsvc", json, new Dictionary<string, string>());
                string ret = (new StreamReader(resp.GetResponseStream(), Encoding.UTF8)).ReadToEnd();
                var result = JObject.Parse(ret)["Context"];
                string token = result["UserToken"].ToString();
                var warehouseCtx = string.Format("LoginUrl={0}&KDServiceSessionId={1}", _cloudUrl, JObject.Parse(ret)["KDSVCSessionId"].ToString());//安全新方式
                return Convert.ToBase64String(Encoding.UTF8.GetBytes(warehouseCtx));
            }
        }
        #endregion
        #region ç‰©ç†æ–‡ä»¶id
        private string GetFileId(string fileId)
        {
            return Convert.ToBase64String(Encoding.UTF8.GetBytes(fileId));
        }
        #endregion
        #region ç”µå­ä»“访问凭证
        private string Token
        {
            get
            {
                var token = Guid.NewGuid().ToString();
                return token;
            }
        }
        #endregion
        #region å‘送请求
        public Stream SendRequest(string op, string fileId)
        {
            var header = new Dictionary<string, string>()
            {
                {"FileID" ,GetFileId(fileId) },
                { "CTX",WarehouseCTX},
                { "token", Token },
                { "PLM_ACCESS_TYPE","pure" }
            };
            return PostDataViaHttpWebRequest(RequestUrl(op), string.Empty, header, !op.Equals("Download"));
        }
        #endregion
        #region è¯·æ±‚çš„URL
        private string RequestUrl(string op)
        {
            return _warehouse + "/" + op;
        }
        #endregion
        #region èŽ·å–å“åº”
        private HttpWebResponse GetResponse(string url, string bodyJson, Dictionary<string, string> header)
        {
            byte[] data = Encoding.UTF8.GetBytes(bodyJson);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "application/json";
            request.ContentLength = data.Length;
            if (header != null)
            {
                foreach (var p in header)
                {
                    request.Headers.Add(p.Key, p.Value);
                }
            }
            using (Stream reqStream = request.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
            }
            HttpWebResponse resp = null;
            try
            {
                resp = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException ex)
            {
                var res = ex.Response;
                if (res != null)
                {
                    string statusBase64 = ((HttpWebResponse)ex.Response).StatusDescription;//base64编码后的报错信息
                }
            }
            return resp;
        }
        #endregion
        #region ä¿å­˜æ–‡ä»¶åˆ°æœ¬åœ°
        /*private void PostDataViaHttpWebRequest(string url, string bodyJson, Dictionary<string, string> header, bool isGetContent)
        {
            var resp = GetResponse(url, bodyJson, header);
            var resultJson = string.Empty;
            Stream stream = File.Open("D://DownloadDocDemo.pdf", FileMode.OpenOrCreate);
            int packageSize = 1024 * 1024;
            byte[] buffer = new byte[packageSize];
            using (stream)
            {
                using (Stream outputStream = resp.GetResponseStream())
                {
                    int readLength = 0;
                    while ((readLength = outputStream.Read(buffer, 0, packageSize)) > 0)
                    {
                        stream.Write(buffer, 0, readLength);
                        stream.Flush();
                    }
                    outputStream.Close();
                }
                stream.Close();
            }
        }*/
        #endregion
        #region è¿”回文件流给前端
        private Stream PostDataViaHttpWebRequest(string url, string bodyJson, Dictionary<string, string> header, bool isGetContent)
        {
            var resp = GetResponse(url, bodyJson, header);
            return resp.GetResponseStream(); // ç›´æŽ¥è¿”回响应流
        }
        #endregion
    }
    #endregion
}
MESApplication/Config/appsettings.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
/*{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Version": "1.0.0",
  "X-KDApi-AcctID": "68044981e73323",
  "X-KDApi-UserName": "广深",
  "X-KDApi-AppID": "310990_x3cJ16Do6vC539TFW+6pRy1E6MQ+xooO",
  "X-KDApi-AppSec": "817a815631c24517b931ecebe8f8eae1",
  "X-KDApi-LCID": "2052",
  "X-KDApi-ServerUrl": "http://47.96.178.105/k3cloud"
}*/
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Version": "1.0.0",
  "X-KDApi-AcctID": "66aeecbb0f0a04",
  "X-KDApi-UserName": "Administrator",
  "X-KDApi-AppID": "326508_T/boQ+iFVqqZ3bVO172r2bTJ3q39wtoG",
  "X-KDApi-AppSec": "0d289241fecc475e8525261a20bbd11c",
  "X-KDApi-LCID": "2052",
  "X-KDApi-ServerUrl": "http://192.168.0.208/k3cloud"
}
MESApplication/Controllers/PLM/PLMController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
using ConsoleApp1;
using MES.Service.service.PLM;
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using System.Dynamic;
using System.IO;
using System.Net.Http.Headers;
namespace MESApplication.Controllers.PLM;
[ApiController]
[Route("api/PLM")]
public class PLMController : ControllerBase
{
    private readonly PLMManager m = new();
    private readonly WarehouseDownloadDoc wdd = new();
    //RetrieveDrawings  è°ƒå–图纸
    [HttpPost("RetrieveDrawings")]
    public ResponseResult RetrieveDrawings(string ItemNo)
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            resultInfos = m.RetrieveDrawings(ItemNo);
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
            catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    //RetrieveImageFile  è°ƒå–上传到服务器的拍摄文件
    [HttpGet("GetImageNames")]
    public IActionResult GetImageNames(string releaseNo)
    {
        // æ‹¼æŽ¥æœ¬åœ°æ–‡ä»¶ç³»ç»Ÿè·¯å¾„
        string basePath = @"D:\MES_FTP\IQC\"; // æœåС噍D盘下的基础路径
        string folderPath = Path.Combine(basePath, releaseNo); // åŠ¨æ€æ‹¼æŽ¥å•å·å¯¹åº”çš„æ–‡ä»¶å¤¹è·¯å¾„
        // æ£€æŸ¥æ–‡ä»¶å¤¹æ˜¯å¦å­˜åœ¨
        if (!Directory.Exists(folderPath))
        {
            return NotFound($"文件夹 {folderPath} ä¸å­˜åœ¨ã€‚请检查路径是否正确。");
        }
        // èŽ·å–æ–‡ä»¶å¤¹ä¸­çš„æ‰€æœ‰å›¾ç‰‡æ–‡ä»¶åç§°
        string[] imageExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp" };
        // èŽ·å–æ–‡ä»¶çš„å®Œæ•´è·¯å¾„ï¼Œå¹¶è¿”å›žä¸€ä¸ªåŒ…å«æ–‡ä»¶åå’Œå®Œæ•´è·¯å¾„çš„å¯¹è±¡
        var imageFiles = Directory.GetFiles(folderPath)
            .Where(file => imageExtensions.Any(ext => file.ToLower().EndsWith(ext)))
            .Select(file => new
            {
                FileName = Path.GetFileName(file), // æ–‡ä»¶å
                FilePath = file,
                FileBasePath = ConvertFileToBase64(file) // æ–‡ä»¶çš„ Base64 æ•°æ® // æ–‡ä»¶çš„完整路径
            });
        return Ok(new { success = true, data = imageFiles });
    }
    private string ConvertFileToBase64(string filePath)
    {
        byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
        return Convert.ToBase64String(fileBytes);
    }
    [HttpPost("DeleteImageFile")]
    public IActionResult DeleteImageFile([FromQuery] string filePath)
    {
        // æ£€æŸ¥æ–‡ä»¶è·¯å¾„是否为空
        if (string.IsNullOrWhiteSpace(filePath))
        {
            return BadRequest("文件路径不能为空");
        }
        // ç¡®ä¿è·¯å¾„是绝对路径(可以根据需要调整)
        filePath = Path.GetFullPath(filePath);
        // æ£€æŸ¥æ–‡ä»¶æ˜¯å¦å­˜åœ¨
        if (!System.IO.File.Exists(filePath))
        {
            return NotFound("文件不存在");
        }
        try
        {
            // åˆ é™¤æ–‡ä»¶
            System.IO.File.Delete(filePath);
            return Ok("文件删除成功");
        }
        catch (System.Exception ex)
        {
            // æ•获异常并返回错误信息
            return StatusCode(500, $"删除文件时发生错误: {ex.Message}");
        }
    }
    //RetrieveDrawings  è°ƒå–图纸
    [HttpPost("OpenDrawings")]
    public IActionResult OpenDrawings(string fileId,string fName)
    {
        try
        {
            var resultInfos = wdd.SendRequest("Download", fileId);
            return File(resultInfos, "application/octet-stream", fName);
        }
        catch (Exception ex)
        {
            return StatusCode(500, new ResponseResult
            {
                status = 1,
                message = ex.Message,
                data = null
            });
        }
    }
    //MP-O型圈-83070100066样品1-83070100068样品2.pdf
    //e18f53b6-6615-8140-11ee-423d1dd32487
    //RetrieveDrawings  è°ƒå–图纸 get方式
    [HttpGet("OpenDrawingsGet")]
    public IActionResult OpenDrawingsGet(string fileId, string fName)
    {
        try
        {
            var resultInfos = wdd.SendRequest("Download", fileId);
            // æ·»åŠ Content-Disposition响应头
            var cd = new ContentDispositionHeaderValue("attachment");
            cd.FileNameStar = fName; // è‡ªåŠ¨å¤„ç†ç¼–ç 
            Response.Headers.Add("Content-Disposition", cd.ToString());
            return File(resultInfos, "application/octet-stream", fName);
        }
        catch (Exception ex)
        {
            return StatusCode(500, new ResponseResult
            {
                status = 1,
                message = ex.Message,
                data = null
            });
        }
    }
}
MESApplication/bin/Debug/net8.0/Config/appsettings.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
/*{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Version": "1.0.0",
  "X-KDApi-AcctID": "68044981e73323",
  "X-KDApi-UserName": "广深",
  "X-KDApi-AppID": "310990_x3cJ16Do6vC539TFW+6pRy1E6MQ+xooO",
  "X-KDApi-AppSec": "817a815631c24517b931ecebe8f8eae1",
  "X-KDApi-LCID": "2052",
  "X-KDApi-ServerUrl": "http://47.96.178.105/k3cloud"
}*/
{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "AllowedHosts": "*",
    "Version": "1.0.0",
    "X-KDApi-AcctID": "6533e4ab79156b",
    "X-KDApi-UserName": "接口传输",
    "X-KDApi-AppID": "312912_623D2YuEyMAeQ59HTY5qywUM1h3a5qPp",
    "X-KDApi-AppSec": "fce5af4fdb1a4640a07f277b3da583ce",
    "X-KDApi-LCID": "2052",
    "X-KDApi-ServerUrl": "http://47.96.178.105/k3cloud"
}
MESApplication/bin/Debug/net8.0/Kingdee.CDP.WebApi.SDK.dll
Binary files differ
MESApplication/bin/Debug/net8.0/MES.Service.dll
Binary files differ
MESApplication/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.deps.json
@@ -1412,7 +1412,18 @@
          "SqlSugarCore": "5.1.4.158"
        },
        "runtime": {
          "MES.Service.dll": {}
          "MES.Service.dll": {
            "assemblyVersion": "1.0.0.0",
            "fileVersion": "1.0.0.0"
          }
        }
      },
      "Kingdee.CDP.WebApi.SDK/8.0.6.0": {
        "runtime": {
          "Kingdee.CDP.WebApi.SDK.dll": {
            "assemblyVersion": "8.0.6.0",
            "fileVersion": "8.0.6.0"
          }
        }
      }
    }
@@ -2288,6 +2299,11 @@
      "type": "project",
      "serviceable": false,
      "sha512": ""
    },
    "Kingdee.CDP.WebApi.SDK/8.0.6.0": {
      "type": "reference",
      "serviceable": false,
      "sha512": ""
    }
  }
}
MESApplication/bin/Debug/net8.0/MESApplication.dll
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.exe
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.pdb
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.staticwebassets.endpoints.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}