예제 #1
0
        /// <summary>
        /// 統計並設置停機預計時間
        /// </summary>
        /// <param name="recHalt">要設置的停機記錄</param>
        private void SetPredictStopTime(ProjectMachineHaltRecord recHalt)
        {
            if (recHalt == null)
            {
                return;
            }
            if (recHalt.StopReasons == null)
            {
                return;
            }
            List<ProjectMachineHaltRecordReason> listHaltReasons = recHalt.StopReasons;

            List<ProjectBaseItemModel> listBaseReasonItem = base.MachineHaltReasons;
            if (listBaseReasonItem == null)
            {
                return;
            }

            int iPredictStopTime = 0;
            foreach (ProjectMachineHaltRecordReason itemReason in listHaltReasons)
            {
                ProjectBaseItemModel itemBaseReason = listBaseReasonItem.FirstOrDefault(x => x.Code.Trim() == itemReason.StopReasonID.ToString());
                if (itemBaseReason != null)
                {
                    if (!itemBaseReason.IsParallelable)
                    {
                        iPredictStopTime += (int)itemBaseReason.PredictedTime;
                    }
                }
            }

            recHalt.PredictStopTimeMin = iPredictStopTime;
            recHalt.psrd_iPredictStopTime = iPredictStopTime * 60;

            if (base.CurrentMachineHaltRecord != null && base.CurrentMachineHaltRecord.RecordID == recHalt.RecordID)
            {
                base.CurrentMachineHaltRecord.psrd_iPredictStopTime = recHalt.psrd_iPredictStopTime;
                base.CurrentMachineHaltRecord.PredictStopTimeMin = recHalt.PredictStopTimeMin;
            }
        }
예제 #2
0
        /// <summary>
        /// 新增工程停機記錄
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddProjectMachineHaltRecord(ProjectMachineHaltRecord model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into ProjectStopRecord_psrd(");
                strSql.Append("psrd_RecordID,psrd_PPJID,psrd_SPLID,psrd_dBeginTime,psrd_dEndTime,psrd_cTypeID,psrd_iPredictStopTime,psrd_iActualStopTime,psrd_lSync,psrd_dAddDate,psrd_dLastDate,psrd_iDinnerTime)");
                strSql.Append(" values (");
                strSql.Append("@psrd_RecordID,@psrd_PPJID,@psrd_SPLID,@psrd_dBeginTime,@psrd_dEndTime,@psrd_cTypeID,@psrd_iPredictStopTime,@psrd_iActualStopTime,@psrd_lSync,@psrd_dAddDate,@psrd_dLastDate,@psrd_iDinnerTime)");
                SqlParameter[] parameters = {
                        DbHelperSQL.MakeInParam("@psrd_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                        DbHelperSQL.MakeInParam("@psrd_PPJID", SqlDbType.UniqueIdentifier,16, model.psrd_PPJID),
                        DbHelperSQL.MakeInParam("@psrd_SPLID", SqlDbType.UniqueIdentifier,16, model.psrd_SPLID),
                        DbHelperSQL.MakeInParam("@psrd_dBeginTime", SqlDbType.DateTime, 0, model.psrd_dBeginTime),
                        DbHelperSQL.MakeInParam("@psrd_dEndTime", SqlDbType.DateTime, 0, model.psrd_dEndTime),
                        DbHelperSQL.MakeInParam("@psrd_cTypeID", SqlDbType.NChar,50, model.psrd_cTypeID),
                        DbHelperSQL.MakeInParam("@psrd_iPredictStopTime", SqlDbType.Int,4, model.psrd_iPredictStopTime),
                        DbHelperSQL.MakeInParam("@psrd_iActualStopTime", SqlDbType.Int,4, model.psrd_iActualStopTime),
                        DbHelperSQL.MakeInParam("@psrd_lSync", SqlDbType.Bit,1, 0), //model.psrd_lSync;
                        DbHelperSQL.MakeInParam("@psrd_dAddDate", SqlDbType.DateTime, 0,DateTime.Now),
                        DbHelperSQL.MakeInParam("@psrd_dLastDate", SqlDbType.DateTime, 0, DateTime.Now),
                        DbHelperSQL.MakeInParam("@psrd_iDinnerTime", SqlDbType.Int,4, model.psrd_iDinnerTime)
                                            };

                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString(), parameters);

                //停機記錄原因
                if (model.StopReasons != null && model.StopReasons.Count > 0)
                {
                    for (int i = 0; i < model.StopReasons.Count; i++)
                    {
                        ProjectMachineHaltRecordReason reasons = model.StopReasons[i];

                        if (reasons != null && reasons.RecordID != null && reasons.RecordID != Guid.Empty)
                        {
                            StringBuilder strSqlReason = new StringBuilder();
                            strSqlReason.Append("insert into ProjectStopReason_pjsr(");
                            strSqlReason.Append("pjsr_RecordID,pjsr_PPJID,pjsr_PSRDID,pjsr_iSRMID,pjsr_lSync,pjsr_dAddDate,pjsr_dLastDate)");
                            strSqlReason.Append(" values (");
                            strSqlReason.Append("@pjsr_RecordID,@pjsr_PPJID,@pjsr_PSRDID,@pjsr_iSRMID,@pjsr_lSync,@pjsr_dAddDate,@pjsr_dLastDate)");
                            SqlParameter[] rParameters = {
                                DbHelperSQL.MakeInParam("@pjsr_RecordID", SqlDbType.UniqueIdentifier,16, reasons.RecordID),
                                DbHelperSQL.MakeInParam("@pjsr_PPJID", SqlDbType.UniqueIdentifier,16, model.psrd_PPJID),
                                DbHelperSQL.MakeInParam("@pjsr_PSRDID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                                DbHelperSQL.MakeInParam("@pjsr_iSRMID", SqlDbType.Int, 4, reasons.StopReasonID),
                                DbHelperSQL.MakeInParam("@pjsr_lSync", SqlDbType.Bit,1, 0),
                                DbHelperSQL.MakeInParam("@pjsr_dAddDate", SqlDbType.DateTime, 0,DateTime.Now),
                                DbHelperSQL.MakeInParam("@pjsr_dLastDate", SqlDbType.DateTime, 0, DateTime.Now),
                                            };

                            DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSqlReason.ToString(), rParameters);
                        }
                    }
                }

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
예제 #3
0
        /// <summary>
        /// 恢復歷史停機記錄
        /// </summary>
        void RegainHistoryMachineHaltRecord(ProjectMachineHaltRecord recHalt)
        {
            base.CurrentMachineHaltRecord = recHalt;

            this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP;//當前狀態轉為生產停機狀態
            base.OnMachineHaltStatusChanged(this.m_statusProj);

            base.OnRecordEdit(recHalt);//通知界面編輯

            StartTimer_CheckOT();
        }
예제 #4
0
        /// <summary>
        /// 創建當前的停機記錄
        /// </summary>
        /// <param name="IsAutoCreate">是否系統自動創建記錄</param>
        /// <returns>停機記錄</returns>
        ProjectMachineHaltRecord CreateNewHaltRec(bool IsAutoCreate)
        {
            ProjectMachineHaltRecord recHalt = new ProjectMachineHaltRecord();
            recHalt.RecordID = Guid.NewGuid();
            recHalt.psrd_PPJID = base.psrd_PPJID;
            recHalt.psrd_SPLID = base.psrd_SPLID;

            if (!IsAutoCreate)
            {
                recHalt.psrd_dBeginTime = DateTime.Now;
                recHalt.psrd_dEndTime = recHalt.psrd_dBeginTime;
                recHalt.psrd_cTypeID = Common.CustEnum.RecordType.SUPPLEMENT.ToString();
            }
            else
            {
                if (m_dtHaltBegin != null)
                {
                    //Start**************modify by Dandyyang**********************

                    recHalt.psrd_dBeginTime = m_dtHaltBegin.Value;
                    //recHalt.psrd_dBeginTime = DateTime.Now;

                    //End**************modify by Dandyyang**********************

                    m_dtHaltBegin = null;
                }
                else
                {
                    recHalt.psrd_dBeginTime = DateTime.Now;
                }
                recHalt.psrd_dEndTime = null;
                recHalt.psrd_cTypeID = Common.CustEnum.RecordType.NORMAL.ToString();
            }
            recHalt.RecordEditStatus = 1;
            recHalt.StopReasons = new List<ProjectMachineHaltRecordReason>();
            return recHalt;
        }
예제 #5
0
        void RecordEdit(EventBaseInfo<ProjectMachineHaltRecord> e)
        {
            if (e != null)
            {
                this.m_CurrentRecord = e.ObjectInformation as ProjectMachineHaltRecord;

                InitForm();
            }
        }
예제 #6
0
        /// <summary>
        /// 綁定指定記錄ID的停機記錄詳細信息
        /// </summary>
        void LoadMacHaltDetailWithRecID(Guid RecordID)
        {
            Guid gCurrentID = RecordID;
            List<ProjectMachineHaltRecord> listHaltRec = this.m_Controller.MachineHaltRecords;

            if (listHaltRec != null)
            {
                ProjectMachineHaltRecord recMacHalt = listHaltRec.Where(x => x.RecordID == gCurrentID).FirstOrDefault();
                if (recMacHalt != null)
                {
                    this.m_CurrentRecord = recMacHalt;

                    if (recMacHalt.psrd_cTypeID.Trim().ToUpper() == CustEnum.RecordType.NORMAL.ToString().ToUpper())//系統錄入的記錄
                    {
                        SetTimePickersEnabled(false);//系統新增記錄的時間不可選
                        if (recMacHalt.psrd_dEndTime == null)
                        {
                            if (!this.m_tmrHaltEndTimeTick.Enabled)
                            {
                                this.m_tmrHaltEndTimeTick.Start();//停機時間為空時,使用當前時間臨時替代顯示
                            }
                        }
                        else
                        {
                            if (this.m_tmrHaltEndTimeTick.Enabled)
                            {
                                this.m_tmrHaltEndTimeTick.Stop();//停機時間不為空時,停止顯示當前時間作為臨時的停機時間
                            }
                        }
                    }
                    else if (recMacHalt.psrd_cTypeID.Trim().ToUpper() == CustEnum.RecordType.SUPPLEMENT.ToString().ToUpper())
                    {
                        SetTimePickersEnabled(true);//手動新增記錄的時間可選
                    }

                    BindHaltTimes(recMacHalt.psrd_dBeginTime, recMacHalt.psrd_dEndTime);//綁定停機時間相關

                    this.m_frmMacShutdownDetailBase.TextBoxForecast.Text = recMacHalt.PredictStopTimeMin.ToString();
                }
            }
            else
            {
                this.ShowWarningMessage("停機記錄資料異常,沒有可用的停機記錄。");
                FormClose();
            }
        }
예제 #7
0
 /// <summary>
 /// 初始化參數
 /// </summary>
 private void InitParams()
 {
     this.m_CurrentRecord = null;
     this.m_listSelectedReasonItems = new List<ProjectBaseItemModel>();
     InitTimer();
 }