InOutParam.cs 4.4 KB
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
 

namespace OnlineStore.DeviceLibrary
{ 
    public class InOutParam
    { 
        public InOutParam()
        {
            ACStoreP = null;
            this.PosInfo = new InOutPosInfo("", "");
            MoveP = null;   
        }
        
        public InOutParam(InOutPosInfo inoutInfo, LineMoveP linePosition = null)
        {
            ACStoreP = null; ;
            MoveP = linePosition; 
            this.PosInfo = inoutInfo;
        } 
        private ShelfPosition ACStoreP = null;

        public ShelfPosition GetACPosition()
        {
            try
            {
                if (ACStoreP == null)
                {
                    string posId = PosInfo != null ? PosInfo.ShelfPosId : "";
                    ACStoreP = CSVPositionReader<ShelfPosition>.GetPositon(posId);
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("GetACPosition 出错:" + ex.ToString());
            }
            return ACStoreP;
        } 

        public InOutPosInfo PosInfo { get; set; }
        public LineMoveP MoveP { get; set; }


        public ShelfPosition LocationPos = null;
        public bool  LoadLocationP(int storeID)
        { 
            if (LocationPos == null)
            {
                string posId = EquipManager.GetLocationPosId(storeID, PosInfo.PlateW);
                if (!String.IsNullOrEmpty(posId))
                {
                    LocationPos = CSVPositionReader<ShelfPosition>.GetPositon(posId);
                }
            }
            if (LocationPos == null)
            {
                LogUtil.info(PosInfo.ToStr() + " 出库 不需要定位 ");
                return false;  
            }
            else
            {
                LogUtil.info(PosInfo.ToStr() + " 出库前 需要定位【" + LocationPos.PositionNum + "】 ");
                return true;
            } 
        }
        
    }  
    public class InOutPosInfo
    {
        public InOutPosInfo(string barcode, string shelfPosId, int  platew =0, int plateh =0,bool IsNg=false,string boxPosId="",   string rfid = "",bool urgentReel=false ) 
        {
            this.barcode = barcode;
            this.ShelfPosId = shelfPosId;
            this.PlateW = platew;
            this.PlateH = plateh; 
            this.rfid = rfid; 
            this.IsNg = IsNg;
            this.BoxPosId = boxPosId;
            this.urgentReel = urgentReel;
        }

        /// <summary>
        /// 物品二维码
        /// </summary>
        public string barcode { get; set; }
        /// <summary>
        /// 料加上的库位号
        /// </summary>
        public string ShelfPosId { get; set; }
        /// <summary>
        /// 料仓里的库位号
        /// </summary>
        public string BoxPosId { get; set; }
        /// <summary>
        /// 料盘宽
        /// </summary>
        public int PlateW { get; set; }
        /// <summary>
        /// 料盘高
        /// </summary>
        public int PlateH { get; set; }
         
        /// <summary>
        /// rfid: 分配的料架RFID
        /// </summary>
        public string rfid { get; set; } 
        /// <summary>
        /// 是否是去NG箱的料
        /// </summary>
        public bool IsNg { get; set; }
        /// <summary>
        /// 是否是去NG箱的料
        /// </summary>
        public bool urgentReel { get; set; }


        public string ToStr()
        {
            if (IsNg)
            {
                return $" 门口NG料 [{ barcode }] [{ ShelfPosId }] [{PlateW }x{ PlateH }],boxPos[{ BoxPosId }],rfid [{ rfid}]";
            }
            else if (urgentReel)
            { 
                return $" 门口紧急料 [{ barcode }] [{ ShelfPosId }] [{PlateW }x{ PlateH }],boxPos[{ BoxPosId }],rfid [{ rfid}]";
            }
            else
            {
                return $" 门口物料 [{ barcode }] [{ ShelfPosId }] [{PlateW }x{ PlateH }],boxPos[{ BoxPosId }],rfid [{ rfid}]";
            }
        }

        internal bool IsSameWare(InOutPosInfo posInfo)
        {
            if (BoxPosId.Equals(posInfo.BoxPosId) && barcode.Equals(posInfo.barcode) && rfid.Equals(posInfo.rfid) && IsNg.Equals(posInfo.IsNg) && urgentReel.Equals(posInfo.urgentReel))
            {
                return true;
            }
            return false;
        }
    }
}