😎新增OA问题报告回传OA接口、定时任务

This commit is contained in:
bairubing 2025-01-16 17:44:19 +08:00
parent f531b6b286
commit 20f3383f8f
4 changed files with 161 additions and 45 deletions

View File

@ -0,0 +1,57 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Furion.Schedule;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vistar.Application.Entity;
using Vistar.Application.Service.OaOpenInterface;
namespace Vistar.Application.Job.OaOpenInterface;
[JobDetail("job_SyncProblemReportingFileToOa", Description = "问题报告回传OA", GroupName = "default", Concurrent = false)]
[PeriodMinutes(10, TriggerId = "trigger_SyncProblemReportingFileToOa", Description = "问题报告回传OA", RunOnStart = false)]
public class SyncProblemReportingFileToOa : IJob
{
private readonly IServiceScopeFactory _scopeFactory;
public OaOpenInterfaceService _oaOpenInterface;
public SyncProblemReportingFileToOa(IServiceScopeFactory scopeFactory, OaOpenInterfaceService oaOpenInterface)
{
_scopeFactory = scopeFactory;
_oaOpenInterface = oaOpenInterface;
}
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
{
using var serviceScope = _scopeFactory.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("1300000000001").CopyNew();
DateTime startTime = DateTime.Now;
var sapOutputs = await _oaOpenInterface.SyncProblemReportingFileToOa();
var json = JsonConvert.SerializeObject(sapOutputs);
string output = json;
var elapsedMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;
if (sapOutputs.Count == 0)
{
output = "未查询到符合条件的记录";
}
db.CopyNew().Insertable<ScheduledTaskLog>(new
{
TaskName = "问题报告回传OA",
LogDateTime = DateTime.Now,
ReturnResult = output,
Elapsed = elapsedMilliseconds.ToLong()
}).ExecuteCommand();
}
}

View File

@ -13,6 +13,7 @@ using System.Threading.Tasks;
namespace Vistar.Application.Service.OaOpenInterface.Dto;
public class OaUploadFileOutput
{
public string EcnNum { get; set; }
public string success { get; set; }
public string message { get; set; }
public string data { get; set; }

View File

@ -451,7 +451,8 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
response = await _solidWorksManageService.AddRelatedFiles(AddRelatedFilesData);
await _solidWorksManageService.CheckIn(CheckData);
}
else {
else
{
response.Success = false;
response.Message = "编码不存在";
}
@ -463,7 +464,6 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
/// <returns></returns>
[ApiDescriptionSettings(Name = "SyncEcnAttach"), HttpGet]
[DisplayName("ecn同步文件")]
[AllowAnonymous]
public async Task<List<OaUploadFileOutput>> SyncEcnAttach()
{
using var serviceScope = _scopeFactory.CreateScope();
@ -489,7 +489,9 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
var problemReport = await db.CopyNew().Queryable<Obj140>().Where(x => x.RecordGuid == item.fld006310_Rec && x.deleted == false).FirstAsync();
if (problemReport != null)
{
var oaUploadFileOutput = await OaUploadFile(problemReport._System_objNBS, manageOutput);
var oaUploadFileOutput = await OaUploadFile(problemReport._System_objNBS, manageOutput, "");
var EcnNum = problemReport._System_objNBS;
oaUploadFileOutput.EcnNum = EcnNum;
output.Add(oaUploadFileOutput);
db.CopyNew().Updateable<Obj118>()
.SetColumns(it => new Obj118
@ -511,18 +513,27 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
/// </summary>
/// <param name="problemNum"></param>
/// <param name="input"></param>
/// <param name="fld006992"></param>
/// <returns></returns>
public async Task<OaUploadFileOutput> OaUploadFile(string problemNum, ExportRelatedFilesOutput input)
public async Task<OaUploadFileOutput> OaUploadFile(string problemNum, ExportRelatedFilesOutput input, string? fld006992)
{
//string url = "http://223.113.253.60:8000/papi/secondev/workflow/uploadFileByReportNo";
string url = "http://192.168.10.35:8000/papi/secondev/workflow/uploadFileByReportNo";
// 构建请求参数字典
string FileName = "";
string FileBate = "";
if (input != null)
{
FileName = input.FileName;
FileBate = input.FileBate;
}
var requestData = new
{
num = problemNum,
filename=input.FileName,
filename = FileName,
filesize = "",
base64 = input.FileBate
base64 = FileBate,
jjfa = fld006992
};
var output = new OaUploadFileOutput();
using (HttpClient client = new HttpClient())
@ -548,4 +559,51 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
}
return output;
}
/// <summary>
/// 问题报告回传OA
/// </summary>
/// <returns></returns>
public async Task<List<OaUploadFileOutput>> SyncProblemReportingFileToOa()
{
using var serviceScope = _scopeFactory.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
var data = await db.CopyNew().Queryable<Obj140>().Where(x => x.CheckedStatus == false && x.IsLatestVersion == true && x._System_CurrentStage == "问题关闭" && x.fld005841 == "不需要" && x.fld007055 == "A").ToListAsync();
var output = new List<OaUploadFileOutput>();
foreach (var item in data)
{
if (!string.IsNullOrEmpty(item.fld006992))
{
var oaOutput = await OaUploadFile(item._System_objNBS, null, item.fld006992);
var EcnNum = item._System_objNBS;
oaOutput.EcnNum = EcnNum;
output.Add(oaOutput);
if (oaOutput.success == "true")
{
db.CopyNew().Updateable<Obj140>().SetColumns(it => new Obj140
{
fld007055 = "N",
fld007058 = DateTime.Now,
fld007057 = oaOutput.message,
fld007056 = "成功"
}).Where(it => it.idRecord == item.idRecord)
.ExecuteCommand();
}
else
{
db.CopyNew().Updateable<Obj140>().SetColumns(it => new Obj140
{
fld007055 = "N",
fld007058 = DateTime.Now,
fld007057 = oaOutput.message,
fld007056 = "失败"
}).Where(it => it.idRecord == item.idRecord)
.ExecuteCommand();
}
}
}
return output;
}
}

View File

@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace Vistar.Application.SolidWorksManageService.Dto;
public class ExportRelatedFilesOutput
{
public string State { get; set; }
public string FileName { get; set; }
public string FileBate { get; set; }
public string? State { get; set; }
public string? FileName { get; set; }
public string? FileBate { get; set; }
}