😎修改OA创建问题报告接口,新增OA创建问题报告文件接口

This commit is contained in:
bairubing 2024-11-13 17:35:38 +08:00
parent 515a41fa58
commit b7eb1b7f72
3 changed files with 190 additions and 53 deletions

View File

@ -479,5 +479,9 @@ public class Obj140
/// </summary>
[SugarColumn(ColumnName = "_System_ObjParentProcess_Rec", ColumnDescription = "", Length = 40)]
public string? _System_ObjParentProcess_Rec { get; set; }
public long? fld006063 { get; set; }
public string? fld006063_Rec { get; set; }
public long ? fld006064 { get; set; }
public string? fld006064_Rec { get; set; }
}

View File

@ -0,0 +1,26 @@
// 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 OaAddRelatedFilesInput
{
public long object_id { get; set; }
public string _System_objNBS { get; set; }
public long file_structure_id { get; set; }
public string file_name { get; set; }
//public byte[] file { get; set; }
public string file { get; set; }
}

View File

@ -5,12 +5,15 @@
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Admin.NET.Core;
using AngleSharp.Io;
using COSXML.Network;
using DocumentFormat.OpenXml.Drawing.Charts;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NewLife.Xml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -167,10 +170,10 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
[ApiDescriptionSettings(Name = "OaCreateProcess"), HttpPost]
[DisplayName("OA创建流程")]
[AllowAnonymous]
public async Task<ManageResponse> OaCreateProcess(OaCreateProcessInput input)
{
var response = new ManageResponse();
if (
string.IsNullOrWhiteSpace(input._System_objNBS) ||
string.IsNullOrWhiteSpace(input._System_objDescription) ||
@ -185,8 +188,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
string.IsNullOrWhiteSpace(input.fld005850) ||
input.fld005852 == default(DateTime) ||
//string.IsNullOrWhiteSpace(input.fld005852.ToString("yyyy-MM-dd HH:mm:ss")) ||
string.IsNullOrWhiteSpace(input.fld005853) ||
string.IsNullOrWhiteSpace(input.fld005854)
string.IsNullOrWhiteSpace(input.fld005853)
)
{
response.Success = true;
@ -206,43 +208,18 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
fieldList.Add(new Field { key = "fld005831", value = input.fld005831 });
fieldList.Add(new Field { key = "fld005832", value = input.fld005832 });
fieldList.Add(new Field { key = "fld005833", value = input.fld005833 });
var responsiblePersonOaData = await _obj81Rep.AsQueryable().Where(x=>x.fld004900==input.fld005836 && x.deleted==false).ToListAsync();
if (responsiblePersonOaData.Count!=0)
{
fieldList.Add(new Field { key = "fld005836", value = "81" });
fieldList.Add(new Field { key = "fld005836_Rec", value = responsiblePersonOaData[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld005836", value = input.fld005836 });
fieldList.Add(new Field { key = "fld005842", value = input.fld005842 });
var createPersonOaData=await _obj81Rep.AsQueryable().Where(x=>x.fld004900==input.fld005847 && x.deleted==false).ToListAsync();
if (createPersonOaData.Count!=0)
{
fieldList.Add(new Field { key = "fld005848", value = "81" });
fieldList.Add(new Field { key = "fld005848_Rec", value = createPersonOaData[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld005847", value = input.fld005847 });
fieldList.Add(new Field { key = "fld005849", value = input.fld005849.ToString("yyyy-MM-dd HH:mm:ss") });
var reviewerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005850 && x.deleted == false).ToListAsync();
if (reviewerOaData.Count != 0)
{
fieldList.Add(new Field { key = "fld005851", value = "81" });
fieldList.Add(new Field { key = "fld005851_Rec", value = reviewerOaData[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld005850", value = input.fld005850 });
fieldList.Add(new Field { key = "fld005852", value = input.fld005852.ToString("yyyy-MM-dd HH:mm:ss") });
fieldList.Add(new Field { key = "fld005853", value = input.fld005853 });
fieldList.Add(new Field { key = "fld005854", value = input.fld005854 });
fieldList.Add(new Field { key = "fld005855", value = "OA" });
if (!string.IsNullOrWhiteSpace(input.fld005838))
{
var mechanicalProblemHandlerOaId = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005838 && x.deleted == false).ToListAsync();
if (mechanicalProblemHandlerOaId.Count != 0)
{
fieldList.Add(new Field { key = "fld005837", value = "81" });
fieldList.Add(new Field { key = "fld005837_Rec", value = mechanicalProblemHandlerOaId[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld005838", value = input.fld005838 });
}
if (!string.IsNullOrWhiteSpace(input.fld005841))
{
@ -267,22 +244,17 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
if (!string.IsNullOrWhiteSpace(input.fld006061))
{
var electricalProblemHandlerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld006061 && x.deleted == false).ToListAsync();
if (electricalProblemHandlerOaData.Count != 0)
{
fieldList.Add(new Field { key = "fld006063", value = "81" });
fieldList.Add(new Field { key = "fld006063_Rec", value = electricalProblemHandlerOaData[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld006061", value = input.fld006061 });
}
if (!string.IsNullOrWhiteSpace(input.fld006062))
{
var softwareProblemHandlerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld006062 && x.deleted == false).ToListAsync();
if (softwareProblemHandlerOaData.Count != 0)
{
fieldList.Add(new Field { key = "fld006062", value = "81" });
fieldList.Add(new Field { key = "fld006062_Rec", value = softwareProblemHandlerOaData[0].RecordGuid });
}
fieldList.Add(new Field { key = "fld006062", value = input.fld006062 });
}
if (!string.IsNullOrWhiteSpace(input.fld005854))
{
fieldList.Add(new Field { key = "fld005854", value = input.fld005854 });
}
var fieldGroup = await _objectFieldsGroupsRep.AsQueryable().Where(x => x.GroupName == input.field_group && x.ObjectId == 140).FirstAsync();
@ -294,16 +266,99 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
fields = fieldList
};
response = await _solidWorksManageService.CreateProcess(data);
var projectData = await _obj140Rep.AsQueryable().Where(x => x._System_objNBS == input._System_objNBS && x.deleted == false).FirstAsync();
var CheckData = new CheckDataInput()
if (response.Success== true && response.Message== "记录 已成功保存!")
{
object_id = input.object_id,
record_guid = projectData.RecordGuid,
bom_level = 1
};
var projectData = await _obj140Rep.AsQueryable().Where(x => x._System_objNBS == input._System_objNBS && x.deleted == false).OrderByDescending(x=>x.VersionIndex).FirstAsync();
long? fld005835 = null;
string fld005835_Rec = "";
var responsiblePersonOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005836 && x.deleted == false).ToListAsync();
if (responsiblePersonOaData.Count != 0)
{
fld005835 = 81;
fld005835_Rec = responsiblePersonOaData[0].RecordGuid;
}
long? fld005848 = null;
string fld005848_Rec = "";
var createPersonOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005847 && x.deleted == false).ToListAsync();
if (createPersonOaData.Count != 0)
{
fld005848 = 81;
fld005848_Rec= createPersonOaData[0].RecordGuid;
}
await _solidWorksManageService.CheckIn(CheckData);
long? fld005851 = null;
string fld005851_Rec = "";
var reviewerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005850 && x.deleted == false).ToListAsync();
if (reviewerOaData.Count != 0)
{
fld005851 = 81;
fld005851_Rec= reviewerOaData[0].RecordGuid;
}
long? fld005837 = null;
string fld005837_Rec = "";
if (!string.IsNullOrWhiteSpace(input.fld005838))
{
var mechanicalProblemHandlerOaId = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld005838 && x.deleted == false).ToListAsync();
if (mechanicalProblemHandlerOaId.Count != 0)
{
fld005837 = 81;
fld005837_Rec= mechanicalProblemHandlerOaId[0].RecordGuid;
}
}
long? fld006063 = null;
string fld006063_Rec = "";
if (!string.IsNullOrWhiteSpace(input.fld006061))
{
var electricalProblemHandlerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld006061 && x.deleted == false).ToListAsync();
if (electricalProblemHandlerOaData.Count != 0)
{
fld006063 = 81;
fld006063_Rec = electricalProblemHandlerOaData[0].RecordGuid;
}
}
long? fld006064 = null;
string fld006064_Rec = "";
if (!string.IsNullOrWhiteSpace(input.fld006062))
{
var softwareProblemHandlerOaData = await _obj81Rep.AsQueryable().Where(x => x.fld004900 == input.fld006062 && x.deleted == false).ToListAsync();
if (softwareProblemHandlerOaData.Count != 0)
{
fld006064 = 81;
fld006064_Rec = softwareProblemHandlerOaData[0].RecordGuid;
}
}
await _obj140Rep.AsUpdateable()
.SetColumns(it => new Obj140
{
fld005835 = fld005835,
fld005835_Rec= fld005835_Rec,
fld005848 = fld005848,
fld005848_Rec = fld005848_Rec,
fld005851 = fld005851,
fld005851_Rec = fld005851_Rec,
fld005837 = fld005837,
fld005837_Rec = fld005837_Rec,
fld006063 = fld006063,
fld006063_Rec = fld006063_Rec,
fld006064 = fld006064,
fld006064_Rec = fld006064_Rec
})
.Where(it => it.idRecord == projectData.idRecord)
.ExecuteCommandAsync();
var CheckData = new CheckDataInput()
{
object_id = input.object_id,
record_guid = projectData.RecordGuid,
bom_level = 1
};
await _solidWorksManageService.CheckIn(CheckData);
}
}
else
{
@ -311,10 +366,62 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
response.Message = "编码已存在";
}
return response;
return response;
}
/// <summary>
/// OA创建问题报告文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
[ApiDescriptionSettings(Name = "OaAddRelatedFiles"), HttpPost]
[DisplayName("OA创建问题报告文件")]
[AllowAnonymous]
public async Task<ManageResponse> OaAddRelatedFiles(OaAddRelatedFilesInput input)
{
var response = new ManageResponse();
if (input.object_id == 0||string.IsNullOrEmpty(input._System_objNBS)|| input.file_structure_id ==0 || string.IsNullOrEmpty(input.file_name))
{
response.Success = false;
response.Message = "必填项不能为空";
return response;
}
//byte[] bytes = File.ReadAllBytes(input.file);
//string base64String = Convert.ToBase64String(bytes);
byte[] bytes = Convert.FromBase64String(input.file);
var AddRelatedFiles=new List<AddRelatedFilesInput>();
var data=await _obj140Rep.AsQueryable().Where(x=>x._System_objNBS==input._System_objNBS && x.deleted==false).OrderByDescending(x=>x.idRecord).ToListAsync();
if (data.Count > 0)
{
var CheckData = new CheckDataInput()
{
object_id = input.object_id,
record_guid = data[0].RecordGuid,
bom_level = 1
};
await _solidWorksManageService.CheckOut(CheckData);
var latestData = await _obj140Rep.AsQueryable().Where(x => x._System_objNBS == input._System_objNBS && x.deleted == false).OrderByDescending(x => x.idRecord).ToListAsync();
var AddRelatedFilesData = new AddRelatedFilesInput
{
object_id = input.object_id,
record_id = latestData[0].idRecord,
file_structure_id = input.file_structure_id,
file_name = input.file_name,
file = bytes
};
response = await _solidWorksManageService.AddRelatedFiles(AddRelatedFilesData);
await _solidWorksManageService.CheckIn(CheckData);
}
else {
response.Success = false;
response.Message = "编码不存在";
}
return response;
}
}