😎SolidWorksManage服务新增保存物料清单
This commit is contained in:
parent
9b82e073d4
commit
016e25694e
@ -0,0 +1,24 @@
|
||||
// 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.SolidWorksManageService.Dto;
|
||||
public class AddItemsInBomInput
|
||||
{
|
||||
public string parent_object_id { get; set; }
|
||||
public string parent_record_id { get; set; }
|
||||
public string child_object_id { get; set; }
|
||||
public string child_record_id { get; set; }
|
||||
public string config_id { get; set; }
|
||||
public string version_index { get; set; }
|
||||
public string view_name { get; set; }
|
||||
public string quantity { get; set; }
|
||||
}
|
@ -392,6 +392,51 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
||||
{
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var errorResponse = new ManageResponse()
|
||||
{
|
||||
Success = false,
|
||||
Message = responseBody,
|
||||
Data = "",
|
||||
CustomAction = "",
|
||||
CustomAttributes = ""
|
||||
};
|
||||
return errorResponse;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存物料清单
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ManageResponse> AddItemsInBom(AddItemsInBomInput input)
|
||||
{
|
||||
// 获取 SolidWorksManage 地址
|
||||
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
||||
// 拼接接口地址
|
||||
string url = $"{apiUrl}/api/BOM/AddItemsInBom";
|
||||
//获取token
|
||||
var token = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageAuthorization);
|
||||
// 将参数对象序列化为 JSON 字符串
|
||||
string jsonParameters = JsonConvert.SerializeObject(input);
|
||||
// 设置请求内容
|
||||
var content = new StringContent(jsonParameters, Encoding.UTF8, "application/json");
|
||||
client.DefaultRequestHeaders.Remove("Authorization");
|
||||
// 添加 Authorization 到请求头
|
||||
client.DefaultRequestHeaders.Add("Authorization", token);
|
||||
// 发送 POST 请求
|
||||
HttpResponseMessage response = await client.PostAsync(url, content);
|
||||
// 处理响应
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
// 解析 JSON 数据
|
||||
var result = JsonConvert.DeserializeObject<ManageResponse>(responseBody);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var errorResponse = new ManageResponse()
|
||||
{
|
||||
Success = false,
|
||||
|
Loading…
Reference in New Issue
Block a user