using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WCS.Data.Utils;
namespace WCS.Data.Models
{
///
/// 码垛编号清单
///
public class WCS_PalletizingCode
{
///
/// 码垛编号(码垛机器人使用)
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public int Id { get; set; }
public int PalletizingNo { get; set; }
///
/// 子托盘编号(码垛机器人使用)
///
public int PalletizingSonTrayNo { get; set; }
///
/// 子托盘编码(WMS中的编码)
///
public string PalletizingSonTrayCode { get; set; }
///
/// 子托盘尺寸
///
public string PalletizingSonTraySize { get; set; }
[SugarColumn(IsIgnore = true)]
public string[] PalletizingSonTraySizeList
{
get
{
return PalletizingSonTraySize.Split('*');
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeLength
{
get
{
return Convert.ToDecimal(PalletizingSonTraySizeList[0]);
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeLength_Max
{
get
{
decimal maxNum = 0.5M;
return SonTraySizeLength + maxNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeLength_Min
{
get
{
decimal minNum = 0.5M;
return SonTraySizeLength - minNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeWidth
{
get
{
return Convert.ToDecimal(PalletizingSonTraySizeList[1]);
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeWidth_Max
{
get
{
decimal maxNum = 0.5M;
return SonTraySizeWidth + maxNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal SonTraySizeWidth_Min
{
get
{
decimal minNum = 0.5M;
return SonTraySizeWidth - minNum;
}
}
///
/// 箱子编号(码垛机器人使用)
///
public int PalletizingBoxNo { get; set; }
///
/// 箱子尺寸
///
public string PalletizingBoxSize { get; set; }
[SugarColumn(IsIgnore = true)]
public string[] PalletizingBoxSizeList
{
get
{
return PalletizingBoxSize.Split('*');
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeLength
{
get
{
return Convert.ToDecimal(PalletizingBoxSizeList[0]);
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeLength_Max
{
get
{
decimal maxNum = 0.5M;
return BoxSizeLength + maxNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeLength_Min
{
get
{
decimal minNum = 0.5M;
return BoxSizeLength - minNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeWidth
{
get
{
return Convert.ToDecimal(PalletizingBoxSizeList[1]);
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeWidth_Max
{
get
{
decimal maxNum = 0.5M;
return BoxSizeWidth + maxNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeWidth_Min
{
get
{
decimal minNum = 0.5M;
return BoxSizeWidth - minNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeHeight
{
get
{
return Convert.ToDecimal(PalletizingBoxSizeList[2]);
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeHeight_Max
{
get
{
decimal maxNum = 0.5M;
return BoxSizeHeight + maxNum;
}
}
[SugarColumn(IsIgnore = true)]
public decimal BoxSizeHeight_Min
{
get
{
decimal minNum = 0.5M;
return BoxSizeHeight - minNum;
}
}
public string Notes { get; set; }
///
/// 检测箱子尺寸是否在可用范围
///
public bool IsAvailableRange_BoxSize(string boxSize,int task_no)
{
bool result = false;
try
{
string[] boxsizeSet = boxSize.Split('*');
if (boxsizeSet.Count() < 3)
throw new Exception(string.Format("任务[{0}]箱子尺寸[{1}]不正确", task_no, boxSize));
decimal length = Convert.ToDecimal(boxsizeSet[0]);
decimal width = Convert.ToDecimal(boxsizeSet[1]);
decimal height = Convert.ToDecimal(boxsizeSet[2]);
if (length >= BoxSizeLength_Min && length <= BoxSizeLength_Max &&
width >= BoxSizeWidth_Min && width <= BoxSizeWidth_Max &&
height >= BoxSizeHeight_Min && height <= BoxSizeHeight_Max)
{
result = true;
}
}
catch (Exception ex)
{
LogMessageHelper.RecordLogMessage(ex);
}
return result;
}
///
/// 检测托盘尺寸是否在可用范围
///
public bool IsAvailableRange_SonTraySize(string sonTraySize, int task_no)
{
bool result = false;
try
{
string[] sonTraySizeSet = sonTraySize.Split('*');
if (sonTraySizeSet.Count() < 3)
throw new Exception(string.Format("任务[{0}]子托盘尺寸[{1}]不正确", task_no, sonTraySize));
decimal length = Convert.ToDecimal(sonTraySizeSet[0]);
decimal width = Convert.ToDecimal(sonTraySizeSet[1]);
decimal height = Convert.ToDecimal(sonTraySizeSet[2]);
if (length >= SonTraySizeLength_Min && length <= SonTraySizeLength_Max &&
width >= SonTraySizeWidth_Min && width <= SonTraySizeWidth_Max)
{
result = true;
}
}
catch (Exception ex)
{
LogMessageHelper.RecordLogMessage(ex);
}
return result;
}
}
}