diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj118.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj118.cs index ba884bf..759469f 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj118.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj118.cs @@ -300,4 +300,35 @@ public class Obj118 /// [SugarColumn(ColumnName = "fld006578", ColumnDescription = "", Length = -1)] public string? fld006578 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld006778", ColumnDescription = "", Length = -1)] + public string? fld006778 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld006310", ColumnDescription = "", Length = -1)] + public int? fld006310 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld006310_Rec", ColumnDescription = "", Length = -1)] + public string? fld006310_Rec { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld006780", ColumnDescription = "", Length = -1)] + public DateTime? fld006780 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld006779", ColumnDescription = "", Length = -1)] + public string? fld006779 { get; set; } + } diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileInput.cs new file mode 100644 index 0000000..df2e27a --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileInput.cs @@ -0,0 +1,20 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.Service.OaOpenInterface.Dto; +public class OaUploadFileInput +{ + public string num { get; set; } + public string filename { get; set; } + public string filesize { get; set; } + public string base64 { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileOutput.cs new file mode 100644 index 0000000..f2b8d93 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/Dto/OaUploadFileOutput.cs @@ -0,0 +1,19 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.Service.OaOpenInterface.Dto; +public class OaUploadFileOutput +{ + public string success { get; set; } + public string message { get; set; } + public string data { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/OaOpenInterfaceService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/OaOpenInterfaceService.cs index 529a719..3ecc33f 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/OaOpenInterfaceService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/OaOpenInterface/OaOpenInterfaceService.cs @@ -8,12 +8,15 @@ using Admin.NET.Core; using AngleSharp.Io; using COSXML.Network; using DocumentFormat.OpenXml.Drawing.Charts; +using DocumentFormat.OpenXml.Spreadsheet; +using DocumentFormat.OpenXml.Vml; using Furion.DependencyInjection; using Furion.DynamicApiController; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NewLife.Xml; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; @@ -24,6 +27,8 @@ using Vistar.Application.Const; using Vistar.Application.Entity; using Vistar.Application.Service.OaOpenInterface.Dto; using Vistar.Application.SolidWorksManageService.Dto; +using Field = Vistar.Application.SolidWorksManageService.Dto.Field; +using HttpClient = System.Net.Http.HttpClient; namespace Vistar.Application.Service.OaOpenInterface; /// @@ -38,6 +43,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient public SqlSugarRepository _objectFieldsGroupsRep; public SqlSugarRepository _fieldGroupDefaultRep; public SqlSugarRepository _obj81Rep; + public SqlSugarRepository _obj118Rep; public OaOpenInterfaceService( SqlSugarRepository obj109Rep, @@ -45,8 +51,9 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient SqlSugarRepository obj81Rep, SolidWorksManageService.SolidWorksManageService solidWorksManageService, SqlSugarRepository objectFieldsGroupsRep, - SqlSugarRepository fieldGroupDefaultRep - + SqlSugarRepository fieldGroupDefaultRep, + SqlSugarRepository obj118Rep + ) { _obj109Rep = obj109Rep; @@ -55,6 +62,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient _objectFieldsGroupsRep = objectFieldsGroupsRep; _fieldGroupDefaultRep = fieldGroupDefaultRep; _obj81Rep= obj81Rep; + _obj118Rep= obj118Rep; } /// @@ -422,4 +430,90 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient } return response; } + /// + /// ecn同步文件 + /// + /// + [ApiDescriptionSettings(Name = "SyncEcnAttach"), HttpGet] + [DisplayName("ecn同步文件")] + [AllowAnonymous] + public async Task> SyncEcnAttach() + { + var data=await _obj118Rep.AsQueryable().Where(x=>x.deleted==false&&x.fld006778=="A"&&x._System_CurrentStage=="结束"&&!string.IsNullOrEmpty(x.fld006310_Rec)).ToListAsync(); + + var groupedData = data.GroupBy(item => item.RecordGuid) + .Select(group => group.OrderByDescending(item => item.idRecord).First()) + .ToList(); + var output = new List(); + foreach (var item in groupedData) + { + var id = item.idRecord; + var input = new ExportRelatedFilesInput + { + record_id=id, + object_id=118 + }; + var manageOutput= await _solidWorksManageService.ExportRelatedFiles(input); + if (manageOutput.State=="成功") + { + var problemReport= await _obj140Rep.AsQueryable().Where(x=>x.RecordGuid==item.fld006310_Rec&&x.deleted==false).FirstAsync(); + if (problemReport != null) + { + var oaUploadFileOutput = await OaUploadFile(problemReport._System_objNBS, manageOutput); + output.Add(oaUploadFileOutput); + await _obj118Rep.AsUpdateable().SetColumns(it => new Obj118 + { + fld006778="N", + fld006780=DateTime.Now, + fld006779= oaUploadFileOutput.message + }) + .Where(it => it.idRecord == id) + .ExecuteCommandAsync(); + } + } + } + return output; + } + + /// + /// oa上传文件接口 + /// + /// + /// + /// + public async Task OaUploadFile(string problemNum, ExportRelatedFilesOutput input) + { + string url = "http://223.113.253.60:8000/papi/secondev/workflow/uploadFileByReportNo"; + // 构建请求参数字典 + var requestData = new + { + num = problemNum, + filename=input.FileName, + filesize="", + base64 = input.FileBate + }; + var output = new OaUploadFileOutput(); + using (HttpClient client = new HttpClient()) + { + try + { + // 将对象序列化为JSON字符串 + string json = JsonConvert.SerializeObject(requestData); + // 创建HttpContent,设置为JSON格式的内容 + HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); + HttpResponseMessage response = await client.PostAsync(url,content); + if (response.IsSuccessStatusCode) + { + string contentOutput = await response.Content.ReadAsStringAsync(); + output = JsonConvert.DeserializeObject(contentOutput); + return output; + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + return output; + } }