| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 | using SqlSugar;using System;using System.Collections.Generic;using System.Linq;using System.Text;using WCS.Data.Utils;namespace WCS.Data.Models{    /// <summary>    /// 码垛编号清单    /// </summary>    public class WCS_PalletizingCode    {        /// <summary>        /// 码垛编号(码垛机器人使用)        /// </summary>        [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]        public int Id { get; set; }        public int PalletizingNo { get; set; }        /// <summary>        /// 子托盘编号(码垛机器人使用)        /// </summary>        public int PalletizingSonTrayNo { get; set; }        /// <summary>        /// 子托盘编码(WMS中的编码)        /// </summary>        public string PalletizingSonTrayCode { get; set; }        /// <summary>        /// 子托盘尺寸        /// </summary>        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;            }        }        /// <summary>        /// 箱子编号(码垛机器人使用)        /// </summary>        public int PalletizingBoxNo { get; set; }        /// <summary>        /// 箱子尺寸        /// </summary>        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; }        /// <summary>        /// 检测箱子尺寸是否在可用范围        /// </summary>        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;        }        /// <summary>        /// 检测托盘尺寸是否在可用范围        /// </summary>        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;        }    }}
 |