using MES.Service.Dto.webApi.RealTimeInventory;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oracle.ManagedDataAccess.Client;
namespace MESApplication.Controllers.RealTimeInventory;
///
/// 实时库存控制器
/// 负责同步第三方系统库存数据到本地数据库
///
[Route("api/[controller]")]
[ApiController]
public class RealTimeInventoryController : ControllerBase
{
// K3Cloud系统的基础API地址
private readonly string _baseUrl = "http://122.227.249.70:5050/k3cloud";
// 数据库连接字符串
private readonly string _connectionString;
///
/// 构造函数
/// 通过依赖注入获取配置信息
///
/// 配置对象
public RealTimeInventoryController(IConfiguration configuration)
{
// 从配置中获取数据库连接字符串
_connectionString = configuration["AppSettings:DataBaseConn"];
}
///
/// 同步库存数据API
/// 从K3Cloud系统获取库存数据并同步到本地数据库
///
/// 同步结果
[HttpPost("syncInventory")]
public async Task SyncInventory()
{
// 创建自定义HTTP客户端实例
var httpClient = new HttpClientEx();
// 设置身份验证API地址
httpClient.Url =
$"{_baseUrl}/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
// 准备登录参数
var parameters = new List