AHTC/RGD/RGD.MdsAPI/Base.cs

141 lines
4.3 KiB
C#
Raw Normal View History

2025-05-19 09:22:33 +08:00
using RGD.Common;
using RGD.DataService;
namespace RGD.MdsAPI
{
public class Base
{
#region
/// <summary>入参公共类型
/// 入参公共类型
/// </summary>
public class InPara
{
}
/// <summary>出参公共类型
/// 出参公共类型
/// </summary>
public class OutPara
{
private string _result_flag;
private string _error_info;
///<sumary>成功标志
/// 成功标志
///</sumary>
public string RESULT_FLAG
{
get { return this._result_flag; }
set { this._result_flag = value; }
}
///<sumary>错误代码
/// 错误代码
///</sumary>
public string ERROR_INFO
{
get { return this._error_info; }
set { this._error_info = value; }
}
}
#endregion
#region
/// <summary> 反序列化
/// 反序列化
/// </summary>
/// <param name="type">类型</param>
/// <param name="xml">XML字符串</param>
/// <returns></returns>
public T DeSerialize<T>(string xml)
{
return XmlSerialization.DeSerialize<T>(xml);
}
/// <summary> 序列化XML文件
/// 序列化XML文件
/// </summary>
/// <param name="type">类型</param>
/// <param name="obj">对象</param>
/// <returns></returns>
public string Serializer<T>(T t)
{
return XmlSerialization.Serializer<T>(t);
}
public static string GetWarehouseIndex()
{
return new WarehouseService().GetWarehouseIndex();
}
private static int MAX_X = 12;
private static int MAX_Y = 7;
//public static string getWCS_LOC_NO(string WMS_LOC_NO)
//{
// if (WMS_LOC_NO == "")
// return "";
// int x, y, z;
// int wms_loc = int.Parse(WMS_LOC_NO);
// z = wms_loc / (MAX_X * MAX_Y) + ((wms_loc % (MAX_X * MAX_Y)) > 0 ? 1 : 0);
// int m = (wms_loc - (z - 1) * MAX_X * MAX_Y);
// x = m / MAX_Y + ((m % MAX_Y) > 0 ? 1 : 0);
// y = wms_loc - (z - 1) * MAX_X * MAX_Y - (x - 1) * MAX_Y;
// return z.ToString().PadLeft(2, '0') + "-" + x.ToString().PadLeft(2, '0') + "-" + y.ToString().PadLeft(2, '0');
//}
public static string getWCS_LOC_NO(string WMS_LOC_NO)
{
if (WMS_LOC_NO == "")
return "";
int.TryParse(WMS_LOC_NO,out int index);
int row = (index - 1) / (27 * 6) + 1;
int col = ((index - 1) % (27 * 6)) / 6 + 1;
int layer = (index - 1) % 6 + 1;
return $"{row:D2}-{col:D2}-{layer:D2}";
}
//public static string getWMS_LOC_NO(string WCS_LOC_NO)
//{
// if (WCS_LOC_NO == "")
// return "";
// int x, y, z;
// z = int.Parse(WCS_LOC_NO.Split('-')[0]);
// x = int.Parse(WCS_LOC_NO.Split('-')[1]);
// y = int.Parse(WCS_LOC_NO.Split('-')[2]);
// return ((z - 1) * MAX_X * MAX_Y + (x - 1) * MAX_Y + y).ToString().PadLeft(3, '0');
//}
public static string getWMS_LOC_NO(string WCS_LOC_NO)
{
if (WCS_LOC_NO == "")
return "";
int x, y, z;
z = int.Parse(WCS_LOC_NO.Split('-')[0]);
x = int.Parse(WCS_LOC_NO.Split('-')[1]);
y = int.Parse(WCS_LOC_NO.Split('-')[2]);
int newno = (z-1)*(27*6)+(x-1)*6+(y-1)+1;
return $"{newno:D3}";
}
//public static string getWMS_LOC_NO(string WCS_LOC_NO)
//{
// if (WCS_LOC_NO == "")
// return "";
// int x, y, z;
// z = int.Parse(WCS_LOC_NO.Split('-')[0]);
// x = int.Parse(WCS_LOC_NO.Split('-')[1]);
// y = int.Parse(WCS_LOC_NO.Split('-')[2]);
// int max_x = 15;
// int max_y = 4;
// int newno = (z - 1) * max_x * max_y + (x - 1) * max_y + y;
// return newno.ToString().PadLeft(3, '0');
//}
#endregion
}
}