Beispiel #1
0
        protected override object GetEditObject(GridRecord row)
        {
            if (_facade == null)
            {
                _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
            }
            string strCode = string.Empty;
            object objCode = row.Items.FindItemByKey("ShiftCode").Value;

            if (objCode != null)
            {
                strCode = objCode.ToString();
            }
            object obj = _facade.GetShift(strCode);

            if (obj != null)
            {
                return((Shift)obj);
            }
            return(null);
        }
Beispiel #2
0
        private string[] GetArrayFrom(DomainObject domain)
        {
            BenQGuru.eMES.Domain.Alert.FirstOnline obj = domain as BenQGuru.eMES.Domain.Alert.FirstOnline;
            if (obj != null)
            {
                string offtime = obj.OffLineTime == 0?string.Empty:FormatHelper.ToTimeString(obj.OffLineTime);

                //班次
                BenQGuru.eMES.BaseSetting.ShiftModelFacade shiftFacade = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
                BenQGuru.eMES.Domain.BaseSetting.Shift     shift       = shiftFacade.GetShift(obj.ShiftCode) as BenQGuru.eMES.Domain.BaseSetting.Shift;
                if (shift == null)
                {
                    return(null);
                }

                #region 首台下线耗时
                string tmOff = string.Empty;
                if (obj.ActionType == "OFF")
                {
                    //如果跨天,并且是在第二天
                    if (obj.OffLineTime < obj.ShiftTime && obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.OffLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmOff = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.OffLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime));

                        int tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmOff = tm.ToString();
                    }
                }
                #endregion

                #region 生产准备耗时
                //如果跨天,并且是在第二天
                string tmOn = string.Empty;
                if (obj.OnLineTime < shift.ShiftEndTime                //上线时间在第二天
                    &&
                    obj.OnLineTime < obj.ShiftTime                     ///上班时间在第一天
                    &&
                    obj.ShiftTime > shift.ShiftEndTime 
                    &&
                    obj.IsOverDay == FormatHelper.TRUE_STRING)
                {
                    TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.ShiftTime));
                    int      tm  = it2.Hours * 60 + it2.Minutes;
                    if (tm >= 24 * 60)
                    {
                        tm = 24 * 60 - tm;
                    }
                    tmOn = tm.ToString();
                }
                else
                {
                    TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.ShiftTime));
                    int      tm  = it2.Hours * 60 + it2.Minutes;
                    if (tm >= 24 * 60)
                    {
                        tm = 24 * 60 - tm;
                    }
                    tmOn = tm.ToString();
                }
                #endregion

                #region 末台下线耗时
                string tmLastOff = string.Empty;
                if (obj.LastType == "OFF")
                {
                    //如果跨天,上线和下线不在同一天
                    if (obj.LastOffTime < obj.LastOnTime && obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOnTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOff = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOnTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOff = tm.ToString();
                    }
                }
                #endregion

                #region 无效生产时间
                //如果跨天,且下班时间和末件下线采集时间不在同一天
                string tmLastOn = string.Empty;
                if (obj.LastType == "OFF")
                {
                    //下班时间比上班时间小,末件下线比上班时间大,并且比下班时间大,则下线位于前一天,下班位于后一天
                    if (
                        obj.ShiftTime > shift.ShiftEndTime                  //上班时间在第一天
                        &&
                        obj.EndTime < obj.ShiftTime                         ///下班时间在第二天
                        &&
                        obj.LastOffTime > obj.ShiftTime                     ///采集时间在第1天
                        &&
                        obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.EndTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime));
                        int      tm  = it2.Hours * 60 + it2.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOn = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.EndTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime));
                        int      tm  = it2.Hours * 60 + it2.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOn = tm.ToString();
                    }
                }
                #endregion

                return(new string[] {
                    FormatHelper.ToDateString(obj.MaintainDate),
                    obj.ShiftCode,
                    obj.SSCode,
                    obj.ItemCode,
                    FormatHelper.ToTimeString(obj.ShiftTime),
                    FormatHelper.ToTimeString(obj.OnLineTime),
                    offtime,
                    tmOff,
                    tmOn,
                    FmtTime(obj.EndTime),
                    FmtTime(obj.LastOnTime),
                    FmtTime(obj.LastOffTime),
                    tmLastOff,
                    tmLastOn
                });
            }

            return(null);
        }