using HH.WCS.Mobox3.pinggao.wms;
using HH.WCS.Mobox3.pinggao;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static HH.WCS.Mobox3.pinggao.api.ApiModel;
using static HH.WCS.Mobox3.pinggao.api.OtherModel;
using static HH.WCS.Mobox3.pinggao.models.SapRoot;
using HH.WCS.Mobox3.pinggao.util;
using NLog.Fluent;
using static HH.WCS.Mobox3.pinggao.models.SapRoot.WcReturnRoot;
using System.Reflection;
using System.Web.Http.Description;
using Newtonsoft.Json.Linq;
using Swashbuckle.Swagger;
using static HH.WCS.Mobox3.pinggao.models.SapRoot.CKDdto;
using static HH.WCS.Mobox3.pinggao.dispatch.NDC;
using static HH.WCS.Mobox3.pinggao.wms.WMSHelper.AddChangeModel;
using HH.WCS.Mobox3.pinggao.models;
using static HH.WCS.Mobox3.pinggao.models.SapRoot.otherDto;
using HH.WCS.Mobox3.pinggao.api;
using static HH.WCS.Mobox3.pinggao.api.ApibackModel;
using System.Net.Http;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Xml;
using System.Security.Policy;
using HH.WCS.Mobox3.pinggao.models;
using static HH.WCS.Mobox3.pinggao.wms.WMSHelper;
using WHTest;
using System.Net;
using SqlSugar;
using static HH.WCS.Mobox3.pinggao.models.SapRoot.GYSDto;
namespace HH.WCS.Mobox3.pinggao.api
{
public class WmsSpaHelper
{
static WmsSpaHelper()
{
}
///
/// 数据
///
///
///
///
public static void EnsureArrayFormat(JObject json, string name, string name1)
{
foreach (var property in json.Properties())
{
if (property.Name == name || property.Name == name1)
{
if (property.Value is JObject && !(property.Value is JArray))
{
// 若为单个对象,包装成数组
property.Value = new JArray(property.Value);
}
}
if (property.Value is JObject)
{
// 递归处理子对象
EnsureArrayFormat((JObject)property.Value, name, name1);
}
else if (property.Value is JArray)
{
// 递归处理数组中的每个元素
foreach (var item in (JArray)property.Value)
{
if (item is JObject)
{
EnsureArrayFormat((JObject)item, name, name1);
}
}
}
}
}
public static void EnsureArrayFormat(JObject json, string propertyName)
{
// 查找名为 propertyName 的属性
JProperty property = json.Property(propertyName);
if (property != null)
{
// 检查属性值是否为 JObject 类型(即单个对象)
if (property.Value is JObject)
{
// 将单个对象包装成数组
JArray newArray = new JArray(property.Value);
property.Value = newArray;
}
else if (property.Value is JArray)
{
// 如果属性值已经是 JArray,则不需要做任何操作
// 但如果需要递归检查数组中的每个元素,可以在这里实现
}
}
}
public static void EnsureArrayFormats(JObject json, string name)
{
foreach (var property in json.Properties())
{
// 如果当前属性名与指定名称匹配
if (property.Name.Equals(name))
{
// 如果属性值是 JObject,且不是 JArray,则将其包装成数组
if (property.Value is JObject)
{
JArray newArray = new JArray(property.Value);
property.Value = newArray;
}
// 如果属性值已经是 JArray,则不需要进一步操作
else if (property.Value is JArray)
{
// 已经是数组,无需操作
}
// 如果属性值是其他类型,则将其转换为单个元素的数组
else
{
JArray newArray = new JArray(property.Value);
property.Value = newArray;
}
}
// 如果属性值是 JObject,递归检查其子属性
else if (property.Value is JObject)
{
EnsureArrayFormats((JObject)property.Value, name);
}
}
}
//内采收货返回参数
public static string GetNcJsonResult(string WLPZBH, string WLPZND, string MSGCODE, string MSGDESP)
{
var root = new Dictionary
{
{ "ITEM", new Dictionary
{
{ "WLPZBH", WLPZBH },
{ "WLPZND", WLPZND },
{ "MSGCODE", MSGCODE },
{ "MSGDESP", MSGDESP }
}
}
};
string json = JsonConvert.SerializeObject(root);
return json;
}
//外采收货返回参数
public static string GetJsonResult(string WLPZBH, string MSGCODE, string MSGDESP)
{
var root = new Dictionary
{
{ "ITEM", new Dictionary
{
{ "WLPZBH", WLPZBH },
{ "MSGCODE", MSGCODE },
{ "MSGDESP", MSGDESP }
}
}
};
string json = JsonConvert.SerializeObject(root);
return json;
}
//出库返回参数
public static string CkGetJsonResult(string LLDH, string GC, string MSGCODE, string MSGDESP)
{
var root = new Dictionary
{
{ "ITEM", new Dictionary
{
{ "LLDH ", LLDH },
{ "GC ", GC },
{ "MSGCODE", MSGCODE },
{ "MSGDESP", MSGDESP }
}
}
};
string json = JsonConvert.SerializeObject(root);
return json;
}
///
/// 外采入库/入库冲销
///
///
///
internal static List Inbound_Order_In(models.SapRoot.Root model)
{
var db = new SqlHelper