😎新增 ecn同步文件接口,给118增加字段

This commit is contained in:
bairubing 2024-12-20 16:55:51 +08:00
parent 540e958898
commit eadcd4cfa0
4 changed files with 166 additions and 2 deletions

View File

@ -300,4 +300,35 @@ public class Obj118
/// </summary> /// </summary>
[SugarColumn(ColumnName = "fld006578", ColumnDescription = "", Length = -1)] [SugarColumn(ColumnName = "fld006578", ColumnDescription = "", Length = -1)]
public string? fld006578 { get; set; } public string? fld006578 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld006778", ColumnDescription = "", Length = -1)]
public string? fld006778 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld006310", ColumnDescription = "", Length = -1)]
public int? fld006310 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld006310_Rec", ColumnDescription = "", Length = -1)]
public string? fld006310_Rec { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld006780", ColumnDescription = "", Length = -1)]
public DateTime? fld006780 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld006779", ColumnDescription = "", Length = -1)]
public string? fld006779 { get; set; }
} }

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -8,12 +8,15 @@ using Admin.NET.Core;
using AngleSharp.Io; using AngleSharp.Io;
using COSXML.Network; using COSXML.Network;
using DocumentFormat.OpenXml.Drawing.Charts; using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Vml;
using Furion.DependencyInjection; using Furion.DependencyInjection;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NewLife.Xml; using NewLife.Xml;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -24,6 +27,8 @@ using Vistar.Application.Const;
using Vistar.Application.Entity; using Vistar.Application.Entity;
using Vistar.Application.Service.OaOpenInterface.Dto; using Vistar.Application.Service.OaOpenInterface.Dto;
using Vistar.Application.SolidWorksManageService.Dto; using Vistar.Application.SolidWorksManageService.Dto;
using Field = Vistar.Application.SolidWorksManageService.Dto.Field;
using HttpClient = System.Net.Http.HttpClient;
namespace Vistar.Application.Service.OaOpenInterface; namespace Vistar.Application.Service.OaOpenInterface;
/// <summary> /// <summary>
@ -38,6 +43,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
public SqlSugarRepository<ObjectFieldsGroups> _objectFieldsGroupsRep; public SqlSugarRepository<ObjectFieldsGroups> _objectFieldsGroupsRep;
public SqlSugarRepository<FieldGroupDefault> _fieldGroupDefaultRep; public SqlSugarRepository<FieldGroupDefault> _fieldGroupDefaultRep;
public SqlSugarRepository<Obj81> _obj81Rep; public SqlSugarRepository<Obj81> _obj81Rep;
public SqlSugarRepository<Obj118> _obj118Rep;
public OaOpenInterfaceService( public OaOpenInterfaceService(
SqlSugarRepository<Obj109> obj109Rep, SqlSugarRepository<Obj109> obj109Rep,
@ -45,8 +51,9 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
SqlSugarRepository<Obj81> obj81Rep, SqlSugarRepository<Obj81> obj81Rep,
SolidWorksManageService.SolidWorksManageService solidWorksManageService, SolidWorksManageService.SolidWorksManageService solidWorksManageService,
SqlSugarRepository<ObjectFieldsGroups> objectFieldsGroupsRep, SqlSugarRepository<ObjectFieldsGroups> objectFieldsGroupsRep,
SqlSugarRepository<FieldGroupDefault> fieldGroupDefaultRep SqlSugarRepository<FieldGroupDefault> fieldGroupDefaultRep,
SqlSugarRepository<Obj118> obj118Rep
) )
{ {
_obj109Rep = obj109Rep; _obj109Rep = obj109Rep;
@ -55,6 +62,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
_objectFieldsGroupsRep = objectFieldsGroupsRep; _objectFieldsGroupsRep = objectFieldsGroupsRep;
_fieldGroupDefaultRep = fieldGroupDefaultRep; _fieldGroupDefaultRep = fieldGroupDefaultRep;
_obj81Rep= obj81Rep; _obj81Rep= obj81Rep;
_obj118Rep= obj118Rep;
} }
/// <summary> /// <summary>
@ -422,4 +430,90 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
} }
return response; return response;
} }
/// <summary>
/// ecn同步文件
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "SyncEcnAttach"), HttpGet]
[DisplayName("ecn同步文件")]
[AllowAnonymous]
public async Task<List<OaUploadFileOutput>> 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<OaUploadFileOutput>();
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;
}
/// <summary>
/// oa上传文件接口
/// </summary>
/// <param name="problemNum"></param>
/// <param name="input"></param>
/// <returns></returns>
public async Task<OaUploadFileOutput> 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<OaUploadFileOutput>(contentOutput);
return output;
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
return output;
}
} }