using Apache.NMS.ActiveMQ.Commands;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Org.BouncyCastle.Ocsp;
|
using Rhea.Common;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel.Design;
|
using System.Drawing.Drawing2D;
|
using System.Linq;
|
using System.Security.Policy;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Tiger.IBusiness;
|
using Tiger.Model;
|
using Tiger.Model.Minsun;
|
|
namespace Tiger.Business.WMS
|
{
|
public partial class ErpT100 : IErpT100
|
{
|
/// <summary>
|
/// T100接口URL
|
/// </summary>
|
public static string t100Url { get; set; } = @"http://172.18.8.11/wstopprd/ws/r/awsp920";
|
|
public static List<string> curDeliveryNoList { get; set; } = new List<string>();
|
|
/// <summary>
|
/// 从T100获取二级供应商接口
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static T100ActionResult<resultStd_data<Parameter3>> GetSecondarySupplyInfo(SupplierInputParameter input)
|
{
|
var t100Action = new T100Action<actionStd_data<SupplierParameter>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
//datakey = new Datakey
|
//{
|
// EntId = "88",
|
// CompanyId = "XCSJ" //据点 DGXC
|
//},
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_ge_pmaauc"
|
},
|
payload = new PayloadData<actionStd_data<SupplierParameter>>
|
{
|
std_data = new actionStd_data<SupplierParameter>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter3>>>(response.Message);
|
Logger.Interface.Info($"T100获取二级供应商提交Json: {requestJson},返回Json: {response.Message}");
|
|
return result;
|
}
|
|
/// <summary>
|
/// 生成客供料到货单
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static T100ActionResult<resultStd_data<Parameter>> GenerateCustReceipt(CustReceiptInputParameter input)
|
{
|
try
|
{
|
var t100Action = new T100Action<actionStd_data<Parameter<Detail>>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
//datakey = new Datakey
|
//{
|
// EntId = "108", //正式 88
|
// CompanyId = "XCSJ" //据点 DGXC
|
//},
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_gen_apmt520"
|
},
|
payload = new PayloadData<actionStd_data<Parameter<Detail>>>
|
{
|
std_data = new actionStd_data<Parameter<Detail>>
|
{
|
parameter = input.parameter
|
//parameter = new Parameter<Detail>
|
//{
|
// pmds000 = "2",
|
// pmdsdocno = "3453",
|
// pmdsdocdt = "2023-04-26", //当天时间
|
// pmds002 = "L36783", //用户ID
|
// pmds003 = "",
|
// pmds007 = "C0006", //供应商代码
|
// pmds010 = "测试客供料无采购收货", //送货单号
|
// pmdsud001 = "CM017", //二级供应编号
|
// detail = new List<Detail>
|
//{
|
// new Detail
|
// {
|
// pmdtseq= "1",
|
// pmdt001= "",
|
// pmdt002= "",
|
// pmdt003= "",
|
// pmdt004= "",
|
// pmdt006= itemcode, //"K7015AA016141",
|
// pmdt020= qty, //"100.00000",
|
// pmdtud011= "0"
|
// }
|
//}
|
//}
|
}
|
}
|
};
|
|
//如果送货单已经在处理,刚不能再重复抛送
|
if (!curDeliveryNoList.Contains(input.parameter.pmds010) || input.parameter.pmds010.IsNullOrEmpty())
|
{
|
if (!input.parameter.pmds010.IsNullOrEmpty())
|
{
|
curDeliveryNoList.Add(input.parameter.pmds010);
|
}
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
|
Logger.Interface.Info($"生成到货单提交Json: {requestJson},返回Json: {response.Message}");
|
curDeliveryNoList.Remove(input.parameter.pmds010);
|
Logger.Interface.Info($"操作单号列表移除当前操作单号[{input.parameter.pmds010}]");
|
return result;
|
}
|
else
|
{
|
T100ActionResult<resultStd_data<Parameter>> ret = new();
|
ret.payload.std_data.execution.code = "-1";
|
ret.payload.std_data.execution.description = $"此单[{input.parameter.pmds010}]正在推送到T100,不能重复推送!";
|
Logger.Interface.Warn($"生成到货单异常,返回: {ret.payload.std_data.execution.description}");
|
return ret;
|
}
|
|
#region 测试代码
|
|
//var result = new T100ActionResult<resultStd_data<Parameter>>()
|
//{
|
// payload = new()
|
// {
|
// std_data = new()
|
// {
|
// execution = new()
|
// {
|
// code = "0",
|
// sql_code = "0",
|
// description = "执行成功!",
|
// },
|
// parameter = new()
|
// {
|
// docno = $"DGrec-{DateTime.Now:yyMMddHHmm}",
|
// }
|
// }
|
// }
|
//};
|
//Logger.Interface.Info($"生成客供料到货单提交Json: {requestJson},返回Json: {{JsonConvert.SerializeObject(result)}}");
|
|
#endregion 测试代码
|
}
|
catch (System.Exception ex)
|
{
|
curDeliveryNoList.Remove(input.parameter.pmds010);
|
Logger.Interface.Error($"生成到货单异常,返回: {ex.Message}");
|
}
|
|
return new();
|
}
|
|
/// <summary>
|
/// 从T100获取二级供应商接口返回iDropdownlist列表
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public List<iDropdownlist> GetSecondarySupplyInfoToDDL(SupplierInputParameter input)
|
{
|
List<iDropdownlist> iDropdownlists = new List<iDropdownlist>();
|
var list = GetSecondarySupplyInfo(input).payload.std_data.parameter.@return;
|
foreach (var item in list)
|
{
|
iDropdownlist _iDropdownlist = new()
|
{
|
label = item.pmaauc003,
|
value = $"{item.pmaauc002},{item.pmaauc001}",
|
};
|
iDropdownlists.Add(_iDropdownlist);
|
}
|
return iDropdownlists;
|
}
|
|
/// <summary>
|
/// 生成送检单
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static T100ActionResult<resultStd_data<Parameter>> GenerateInspection(InsInputParameter input)
|
{
|
var t100Action = new T100Action<actionStd_data<InsParameter>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
//datakey = new Datakey
|
//{
|
// EntId = "108", //正式 88
|
// CompanyId = "XCSJ" //据点 DGXC
|
//},
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_gen_aqct300"
|
},
|
payload = new PayloadData<actionStd_data<InsParameter>>
|
{
|
std_data = new actionStd_data<InsParameter>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
|
Logger.Interface.Info($"生成送检单提交Json: {requestJson},返回Json: {response.Message}");
|
|
#region 测试代码
|
|
//var result = new T100ActionResult<resultStd_data<Parameter>>()
|
//{
|
// payload = new()
|
// {
|
// std_data = new()
|
// {
|
// execution = new()
|
// {
|
// code = "0",
|
// sql_code = "0",
|
// description = "执行成功!",
|
// },
|
// parameter = new()
|
// {
|
// docno = $"DGtest-{DateTime.Now:yyMMddHHmm}",
|
// }
|
// }
|
// }
|
//};
|
//Logger.Interface.Info($"生成送检单提交Json: {requestJson},返回Json: {JsonConvert.SerializeObject(result)}");
|
|
#endregion 测试代码
|
|
return result;
|
}
|
|
/// <summary>
|
/// 生成其他入库单
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static T100ActionResult<resultStd_data<Parameter>> GenerateOtherIn(OtherInputParameter<Detail4> input)
|
{
|
var t100Action = new T100Action<actionStd_data<InParameter<Detail4>>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_gen_apmt570"
|
},
|
payload = new PayloadData<actionStd_data<InParameter<Detail4>>>
|
{
|
std_data = new actionStd_data<InParameter<Detail4>>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
|
if (result.payload.std_data.execution.code != "0")
|
{
|
throw new Exception($"T100生成入库单失败,失败原因:{result.payload.std_data.execution.description}");
|
}
|
Logger.Interface.Info($"生成入库单请求T100,传入参数Json:{requestJson},返回:{response.Message}");
|
return result;
|
}
|
|
/// <summary>
|
/// 根据领料单号拉单身
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public T100ActionResult<resultStd_data<reqParameter1>> GetMaterialReqDetail(ReqInputParameter input)
|
{
|
var t100Action = new T100Action<actionStd_data<reqParameter>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_erp_wms_getwoissd"
|
},
|
payload = new PayloadData<actionStd_data<reqParameter>>
|
{
|
std_data = new actionStd_data<reqParameter>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<reqParameter1>>>(response.Message);
|
Logger.Interface.Info($"根据领料单号拉单身提交Json: {requestJson},返回Json: {response.Message}");
|
return result;
|
}
|
|
/// <summary>
|
/// 领料单过账
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public static T100ActionResult<resultStd_data<Parameter>> MaterialReqToErp(ReqErpInputParameter input)
|
{
|
var t100Action = new T100Action<actionStd_data<Parameter4>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "WMS",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_gen_asft310"
|
},
|
payload = new PayloadData<actionStd_data<Parameter4>>
|
{
|
std_data = new actionStd_data<Parameter4>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<Parameter>>>(response.Message);
|
Logger.Interface.Info($"领料单过账提交Json: {requestJson},返回Json: {response.Message}");
|
if (input.datakey.CompanyId == "DGXC")
|
{
|
Logger.Interface.Info($"领料单[{input.parameter.sfdadocno}]过账Json保存到数据库开始");
|
DbClient db = ApiConfig.IsOldVersion ? Biz.DataSource["WMS57"].Client : Business.Biz.Db;
|
BIZ_ERP_PROD_OUT entity_h = db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == input.parameter.sfdadocno && x.ERP_BILL_CODE == null).First();
|
if (entity_h != null)
|
{
|
entity_h.COMMIT_JSON = requestJson;
|
entity_h.COMMIT_MSG = response.Message;
|
}
|
//数据库处理操作
|
var dbTran = db.UseTran(() =>
|
{
|
if (entity_h != null)
|
{
|
db.Updateable(entity_h).UpdateColumns(q => new { q.COMMIT_JSON, q.COMMIT_MSG }).ExecuteCommand();
|
}
|
});
|
if (!dbTran.IsSuccess)
|
{
|
Logger.Interface.Error(dbTran.ErrorException);
|
throw dbTran.ErrorException;
|
}
|
Logger.Interface.Info($"领料单[{input.parameter.sfdadocno}]过账Json保存到数据库结束");
|
}
|
|
return result;
|
}
|
}
|
}
|