diff --git a/Infrastructure/ERP/Util/GetSign.cs b/Infrastructure/ERP/Util/GetSign.cs new file mode 100644 index 00000000..2d810b6b --- /dev/null +++ b/Infrastructure/ERP/Util/GetSign.cs @@ -0,0 +1,20 @@ +using System; +using System.Globalization; +using U8Server.Extensions; + +namespace U8Server.Util +{ + public class GetSign + { + public static string GetBy16Md5() + { + string appId = "gN9yId!!lfwaRoi3"; + string appSecret = "xr35$IQAutBRX1UYhgOUY#CqChI#Y3b$"; + string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture); + string key = $"{appSecret}{appId}{timestamp}{appSecret}"; + string sign = key.ToMD5Encrypt(uppercase: false, is16bit: true) + ?? throw new InvalidOperationException("MD5加密失败"); + return sign; + } + } +} diff --git a/Infrastructure/ERP/Util/MD5Encryption.cs b/Infrastructure/ERP/Util/MD5Encryption.cs new file mode 100644 index 00000000..3237061b --- /dev/null +++ b/Infrastructure/ERP/Util/MD5Encryption.cs @@ -0,0 +1,110 @@ +using System.Security.Cryptography; +using System.Text; + +namespace U8Server.Util +{ + // + // 摘要: + // MD5 加密 + public static class MD5Encryption + { + // + // 摘要: + // MD5 比较 + // + // 参数: + // text: + // 加密文本 + // + // hash: + // MD5 字符串 + // + // uppercase: + // 是否输出大写加密,默认 false + // + // is16: + // 是否输出 16 位 + // + // 返回结果: + // bool + public static bool Compare(string text, string hash, bool uppercase = false, bool is16 = false) + { + return Compare(Encoding.UTF8.GetBytes(text), hash, uppercase, is16); + } + + // + // 摘要: + // MD5 加密 + // + // 参数: + // text: + // 加密文本 + // + // uppercase: + // 是否输出大写加密,默认 false + // + // is16: + // 是否输出 16 位 + public static string Encrypt(string text, bool uppercase = false, bool is16 = false) + { + return Encrypt(Encoding.UTF8.GetBytes(text), uppercase, is16); + } + + // + // 摘要: + // MD5 加密 + // + // 参数: + // bytes: + // 字节数组 + // + // uppercase: + // 是否输出大写加密,默认 false + // + // is16: + // 是否输出 16 位 + public static string Encrypt(byte[] bytes, bool uppercase = false, bool is16 = false) + { + byte[] array = MD5.HashData(bytes); + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < array.Length; i++) + { + stringBuilder.Append(array[i].ToString("x2")); + } + + string text = stringBuilder.ToString(); + string text2 = ((!is16) ? text : text.Substring(8, 16)); + if (uppercase) + { + return text2.ToUpper(); + } + + return text2; + } + + // + // 摘要: + // MD5 比较 + // + // 参数: + // bytes: + // 字节数组 + // + // hash: + // MD5 字符串 + // + // uppercase: + // 是否输出大写加密,默认 false + // + // is16: + // 是否输出 16 位 + // + // 返回结果: + // bool + public static bool Compare(byte[] bytes, string hash, bool uppercase = false, bool is16 = false) + { + string value = Encrypt(bytes, uppercase, is16); + return hash.Equals(value, StringComparison.OrdinalIgnoreCase); + } + } +} diff --git a/Infrastructure/ERP/Util/StringExtensions.cs b/Infrastructure/ERP/Util/StringExtensions.cs new file mode 100644 index 00000000..b35545a5 --- /dev/null +++ b/Infrastructure/ERP/Util/StringExtensions.cs @@ -0,0 +1,20 @@ +using U8Server.Util; + +namespace U8Server.Extensions +{ + public static class StringExtensions + { + /// + /// 对字符串进行 MD5 加密(扩展方法) + /// + /// 待加密的字符串 + /// 是否返回大写形式 + /// 是否返回 16 位 MD5(默认 32 位) + /// 加密后的字符串 + public static string ToMD5Encrypt(this string input, bool uppercase = false, bool is16bit = false) + { + // 直接调用现有的 MD5Encryption.Encrypt 方法 + return MD5Encryption.Encrypt(input, uppercase, is16bit); + } + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs index d2a17bd9..12dcb2e0 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs @@ -95,6 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms return ToResponse(new ApiResult(200, msg, state)); } + /// /// 4.入库 /// @@ -117,8 +118,6 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms if (num == 0) { msg = "入库数为0!"; - - } else if (num >= 1) { diff --git a/ZR.Admin.WebApi/DataProtection/key-41616b3c-f0c2-4c2e-8731-e00f4068434c.xml b/ZR.Admin.WebApi/DataProtection/key-41616b3c-f0c2-4c2e-8731-e00f4068434c.xml new file mode 100644 index 00000000..840671d6 --- /dev/null +++ b/ZR.Admin.WebApi/DataProtection/key-41616b3c-f0c2-4c2e-8731-e00f4068434c.xml @@ -0,0 +1,16 @@ + + + 2024-11-21T06:38:26.0026108Z + 2024-11-21T06:38:25.7325286Z + 2025-02-19T06:38:25.7325286Z + + + + + + + hJYyLuoFC/c5rG4kg/5UESdMoe+9+EWMl2sdrFlqW9KnQnx+pUVho8v/+Klq6ZEoQ4/8kBasEJ0FzCt8pkNstQ== + + + + \ No newline at end of file diff --git a/ZR.Model/MES/wms/ERP_WMS_interactiveModel.cs b/ZR.Model/MES/wms/ERP_WMS_interactiveModel.cs new file mode 100644 index 00000000..48d5dbe9 --- /dev/null +++ b/ZR.Model/MES/wms/ERP_WMS_interactiveModel.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.wms +{ + public class ERP_WMS_interactiveModel + { + + } + + public class ERP_WMS_interactiveModelQuery + { + /// + /// 物料编码 + /// + public string materialCode { get; set; } + + /// + /// 位置 + /// + public string location { get; set; } + + /// + /// 数量 + /// + public string Qty { get; set; } + + /// + /// + /// + public string LotNo { get; set; } + + + public DateTime createTime { get; set; } + + + public string userID { get; set; } + + + public string guid { get; set; } + + public string lineno { get; set; } + } + + + public class ERP_WMS_interactiveModelResult + { + public string code { get; set; } + public string type { get; set; } + public string message { get; set; } + public Object result { get; set; } + public Object extras { get; set; } + public DateTime time { get; set; } + } + +} diff --git a/ZR.Service/mes/wms-u8/ERP_WMS_interactiveService.cs b/ZR.Service/mes/wms-u8/ERP_WMS_interactiveService.cs new file mode 100644 index 00000000..70455c90 --- /dev/null +++ b/ZR.Service/mes/wms-u8/ERP_WMS_interactiveService.cs @@ -0,0 +1,61 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using U8Server.Util; +using ZR.Model.MES.wms; +using ZR.Service.mes.wms.IService; +using ZR.Service.mes.wms_u8.IService; + +namespace ZR.Service.mes.wms_u8 +{ + [AppService(ServiceType = typeof(IERP_WMS_interactive), ServiceLifetime = LifeTime.Transient)] + public class ERP_WMS_interactiveService : IERP_WMS_interactive + { + public ERP_WMS_interactiveModelResult inbounded(string urlBase,List eRP_WMS_InteractiveModels) + { + string url = urlBase + "/wms/mes/inbounded"; + + string contentType = "application/json"; + Dictionary headers = new Dictionary(); + headers.Add("appid", "gN9yId!!lfwaRoi3"); + headers.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture)); + headers.Add("sign", GetSign.GetBy16Md5()); + + string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels); + Object result = HttpHelper.HttpPost(url, postData, contentType, 30, headers); + if (result != null && result is ERP_WMS_interactiveModelResult) + { + return (ERP_WMS_interactiveModelResult)result; + } + + return null; + + } + + public ERP_WMS_interactiveModelResult outbounded(string urlBase, List eRP_WMS_InteractiveModels) + { + string url = urlBase + "/wms/mes/outbounded"; + + string contentType = "application/json"; + Dictionary headers = new Dictionary(); + headers.Add("appid", "gN9yId!!lfwaRoi3"); + headers.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture)); + headers.Add("sign", GetSign.GetBy16Md5()); + + string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels); + Object result = HttpHelper.HttpPost(url, postData, contentType, 30, headers); + if (result != null && result is ERP_WMS_interactiveModelResult) + { + return (ERP_WMS_interactiveModelResult)result; + } + + return null; + } + } +} diff --git a/ZR.Service/mes/wms-u8/IService/IERP_WMS_interactive.cs b/ZR.Service/mes/wms-u8/IService/IERP_WMS_interactive.cs new file mode 100644 index 00000000..f5151529 --- /dev/null +++ b/ZR.Service/mes/wms-u8/IService/IERP_WMS_interactive.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.MES.wms; + +namespace ZR.Service.mes.wms_u8.IService +{ + /// + /// 用友U8和WMS 交互接口 + /// + public interface IERP_WMS_interactive + { + /// + /// 入库 + /// + /// + public ERP_WMS_interactiveModelResult inbounded(string urlBase, List eRP_WMS_InteractiveModels); + + /// + /// 出库 + /// + /// + public ERP_WMS_interactiveModelResult outbounded(string urlBase, List eRP_WMS_InteractiveModels); + } +}