示例#1
0
        //Bind上班时间下拉列表,返回根据当前时间选定的记录
        public int BindShiftTime(System.Collections.IList list, Resource res)
        {
            //根据res取得班制
            BenQGuru.eMES.BaseSetting.BaseModelFacade bm = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider);

            if (res == null)
            {
                return(-1);
            }
            //Segment seg = bm.GetSegment(res.SegmentCode) as Segment;
            //if(seg == null) return -1;
            //string shifttype = seg.ShiftTypeCode;
            string shifttype = res.ShiftTypeCode;

            //根据
            BenQGuru.eMES.BaseSetting.ShiftModelFacade shift = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
            object[] objs = this.DataProvider.CustomQuery(typeof(Shift), new SQLCondition(string.Format("select {0} from TBLSHIFT where shifttypecode='{1}'order by SHIFTBTIME", DomainObjectUtility.GetDomainObjectFieldsString(typeof(Shift)), shifttype)));
            if (objs != null && objs.Length > 0)
            {
                foreach (object obj in objs)
                {
                    BenQGuru.eMES.Domain.BaseSetting.Shift s = obj as BenQGuru.eMES.Domain.BaseSetting.Shift;
                    if (s != null)
                    {
                        list.Add(new UIShift(s.ShiftCode, s.ShiftBeginTime, s.ShiftEndTime, s.IsOverDate));
                    }
                }
            }

            int time = FormatHelper.TOTimeInt(DateTime.Now);

            return(GetCurrShiftIndex(time, list));
        }
示例#2
0
        private void DoAction()
        {
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                Messages msg = new Messages();

                UIFirstOnline ufo = this.cbxBeginTime.ComboBoxData.SelectedItem as UIFirstOnline;
                if (ufo == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "请选择上班时间"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                //取得班次信息
                BenQGuru.eMES.BaseSetting.ShiftModelFacade bf    = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
                BenQGuru.eMES.Domain.BaseSetting.Shift     shift = bf.GetShift(ufo._first.ShiftCode) as BenQGuru.eMES.Domain.BaseSetting.Shift;
                if (shift == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "班次不存在"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                string itemcode = ufo._first.ItemCode;

                //2006/11/17,Laws Lu add get DateTime from db Server
                DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);

                //DateTime dtNow = DateTime.Now;
                _facade = new FirstOnlineFacade(this.DataProvider);

                DateTime dtShiftDay = dtNow;

                /////如是跨天的班次,并且是处在第二天,则用前一天做为上线日期
                if (shift.IsOverDate == FormatHelper.TRUE_STRING)
                {
                    if (FormatHelper.TOTimeInt(dtShiftDay) < shift.ShiftEndTime)
                    {
                        dtShiftDay = dtShiftDay.AddDays(-1);
                    }
                }

                //object obj_on = _facade.GetFirstOnline(this.ucSSName.Value,FormatHelper.TODateInt(dtShiftDay),itemcode,ul._first.ShiftCode,FormatHelper.TOTimeInt(this.dtpBegin.Text));

                BenQGuru.eMES.Domain.Alert.FirstOnline first_on = ufo._first;                 //= obj_on as BenQGuru.eMES.Domain.Alert.FirstOnline;
//				if(first_on == null)
//				{
//					msg.Add(new UserControl.Message(MessageType.Error,"今天这个上班时间,此产线上此产品还没有首件上线"));//,"$Error_FirstOn_None")); //今天这个班次,此产线上此产品还没有首件上线
//					ApplicationRun.GetInfoForm().Add(msg);
//					return;
//				}

                if (first_on.ActionType == LineActionType.OFF)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "今天这个上班时间,此产线上此产品已经有一个下线首件"));                   //"$Error_FirstOff_Repeat")); //今天这个班次,此产线上此产品已经有一个下线首件
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                try
                {
                    first_on.OfflineRuningCard = this.ucRCard.InnerTextBox.Text.Trim();
                    first_on.ActionType        = LineActionType.OFF;
                    first_on.OffLineTime       = FormatHelper.TOTimeInt(dtNow);

                    this.DataProvider.BeginTransaction();

                    this.DataProvider.Update(first_on);

                    TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(first_on.OffLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(first_on.OnLineTime));

                    //如果跨天,并且是在第二天
                    if (shift.IsOverDate == FormatHelper.TRUE_STRING && FormatHelper.TOTimeInt(dtShiftDay) < shift.ShiftEndTime)
                    {
                        it = DateTime.Parse(FormatHelper.ToTimeString(first_on.OffLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(first_on.OnLineTime));
                    }


                    ucMessage.Add(new UserControl.Message("上班时间" + FormatHelper.ToTimeString(first_on.ShiftTime) + "," +
                                                          String.Format(_firstMsg,
                                                                        (DateTime.Parse((FormatHelper.ToDateString(first_on.MaintainDate)))).ToLongDateString(),
                                                                        first_on.SSCode,
                                                                        first_on.ItemCode,
                                                                        FormatHelper.ToTimeString(first_on.OnLineTime)
                                                                        )
                                                          )
                                  );

                    ucMessageOff.Add(new UserControl.Message("上班时间" + FormatHelper.ToTimeString(first_on.ShiftTime) + "," +
                                                             String.Format(_offMsg,
                                                                           (DateTime.Parse((FormatHelper.ToDateString(first_on.MaintainDate)))).ToLongDateString(),
                                                                           first_on.SSCode,
                                                                           first_on.ItemCode,
                                                                           FormatHelper.ToTimeString(first_on.OffLineTime),
                                                                           it.Hours,
                                                                           it.Minutes
                                                                           )
                                                             )
                                     );

                    this.DataProvider.CommitTransaction();
                    msg.Add(new UserControl.Message(MessageType.Success, "$Error_FirstOff_Sucess"));                    //首件下线成功
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.cbxBeginTime.ComboBoxData.Items.Clear();
                }
                catch (System.Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                    msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
            }
            finally
            {
                this.Cursor        = System.Windows.Forms.Cursors.Arrow;
                this.ucRCard.Value = string.Empty;
                this.ucRCard.TextFocus(false, true);
                CloseConnection();
            }
        }
示例#3
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);
        }