入库和出库

This commit is contained in:
qianhao.xu 2025-06-09 16:41:15 +08:00
parent 7b546e5979
commit 0d9571a5b7
8 changed files with 314 additions and 2 deletions

View File

@ -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;
}
}
}

View File

@ -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);
}
}
}

View File

@ -0,0 +1,20 @@
using U8Server.Util;
namespace U8Server.Extensions
{
public static class StringExtensions
{
/// <summary>
/// 对字符串进行 MD5 加密(扩展方法)
/// </summary>
/// <param name="input">待加密的字符串</param>
/// <param name="uppercase">是否返回大写形式</param>
/// <param name="is16bit">是否返回 16 位 MD5默认 32 位)</param>
/// <returns>加密后的字符串</returns>
public static string ToMD5Encrypt(this string input, bool uppercase = false, bool is16bit = false)
{
// 直接调用现有的 MD5Encryption.Encrypt 方法
return MD5Encryption.Encrypt(input, uppercase, is16bit);
}
}
}

View File

@ -95,6 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms
return ToResponse(new ApiResult(200, msg, state));
}
/// <summary>
/// 4.入库
/// </summary>
@ -117,8 +118,6 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms
if (num == 0)
{
msg = "入库数为0";
}
else if (num >= 1)
{

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<key id="41616b3c-f0c2-4c2e-8731-e00f4068434c" version="1">
<creationDate>2024-11-21T06:38:26.0026108Z</creationDate>
<activationDate>2024-11-21T06:38:25.7325286Z</activationDate>
<expirationDate>2025-02-19T06:38:25.7325286Z</expirationDate>
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
<descriptor>
<encryption algorithm="AES_256_CBC" />
<validation algorithm="HMACSHA256" />
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
<!-- Warning: the key below is in an unencrypted form. -->
<value>hJYyLuoFC/c5rG4kg/5UESdMoe+9+EWMl2sdrFlqW9KnQnx+pUVho8v/+Klq6ZEoQ4/8kBasEJ0FzCt8pkNstQ==</value>
</masterKey>
</descriptor>
</descriptor>
</key>

View File

@ -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
{
/// <summary>
/// 物料编码
/// </summary>
public string materialCode { get; set; }
/// <summary>
/// 位置
/// </summary>
public string location { get; set; }
/// <summary>
/// 数量
/// </summary>
public string Qty { get; set; }
/// <summary>
///
/// </summary>
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; }
}
}

View File

@ -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_interactiveModelQuery> eRP_WMS_InteractiveModels)
{
string url = urlBase + "/wms/mes/inbounded";
string contentType = "application/json";
Dictionary<string, string> headers = new Dictionary<string, string>();
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_interactiveModelQuery> eRP_WMS_InteractiveModels)
{
string url = urlBase + "/wms/mes/outbounded";
string contentType = "application/json";
Dictionary<string, string> headers = new Dictionary<string, string>();
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;
}
}
}

View File

@ -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
{
/// <summary>
/// 用友U8和WMS 交互接口
/// </summary>
public interface IERP_WMS_interactive
{
/// <summary>
/// 入库
/// </summary>
/// <returns></returns>
public ERP_WMS_interactiveModelResult inbounded(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels);
/// <summary>
/// 出库
/// </summary>
/// <returns></returns>
public ERP_WMS_interactiveModelResult outbounded(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels);
}
}