/// <summary>
 /// 工程“抽起”或“結束”生產數據校驗
 /// </summary>
 /// <param name="shiftInfo">當前班次信息</param>
 /// <param name="projectData">當前工程生產數據</param>
 /// <param name="projectStatus">工程狀態</param>
 public abstract void ProjectFinishProductionDataCheck(MachineShiftData shiftInfo, ProjectProductionData projectData,string projectStatus);
 /// <summary>
 /// 工程跨班時設置新的班次內生產數據
 /// </summary>
 /// <param name="shiftInfo">新的班次信息</param>
 /// <param name="projectData">上班次生產工程數據</param>
 public abstract void SetNewShiftProjectProductionData(MachineShiftData newShiftInfo, ProjectProductionData projectData);
Ejemplo n.º 3
0
        /// <summary>
        /// 新工程開始時獲取新的班次內生產數據
        /// </summary>
        /// <param name="newShiftInfo">新的班次信息</param>
        /// <param name="scheduleProject">排期工程</param>
        /// <param name="projectBaseData">機台生產工程下的基本資料</param>
        /// <param name="spareStatusID">空閒狀態記錄ID</param>
        public override ProjectProductionData GetShiftProjectProductionData(MachineShiftData newShiftInfo, ScheduleProjectData scheduleProject, ProjectBaseData projectBaseData, Guid spareStatusID)
        {
            try
            {
                Guid l_gSWL_ID = scheduleProject.RecordID; //排期工程ID(待印刷工程ID)
                Guid l_gPPJ_ID = Guid.NewGuid();    //工程機台生產ID
                Guid l_gSPL_ID = Guid.NewGuid();   //班次內工程生產ID
                Guid l_gSIFO_ID = newShiftInfo.RecordID; //班次ID
                string l_cMachineNo = newShiftInfo.sifo_cMachineNO;

                scheduleProject.swl_cMachineNO = l_cMachineNo;

                //■■■創建新的“工程生產數據資料”對象■■■
                ProjectProductionData objProjectProductionData = new ProjectProductionData();
                objProjectProductionData.MachineNo = l_cMachineNo;
                objProjectProductionData.ScheduleProjectID = l_gSWL_ID;
                objProjectProductionData.ProjectMachineProductionID = l_gPPJ_ID;
                objProjectProductionData.ShiftProjectID = l_gSPL_ID;
                objProjectProductionData.ProjectBaseData = scheduleProject;
                //===============================================================================//

                //■■■“抽起原因”對象地址■■■
                objProjectProductionData.ExtractionReason = new ProjectExtractionReason();
                objProjectProductionData.ExtractionReason.RecordID = Guid.NewGuid();
                objProjectProductionData.ExtractionReason.psr_SWLID = l_gSWL_ID;
                objProjectProductionData.ExtractionReason.ExtractionReasonIems = new List<ProjectExtractionReasonIem>();
                //===============================================================================//

                //■■■“準備工作項列表” 對象地址■■■
                objProjectProductionData.PrepareJobItems = new List<ProjectPrepareJobItem>();
                //===============================================================================//

                //■■■“工程機台生產數據”對象■■■
                objProjectProductionData.ProjectMProductionData = new ProjectMachineProductionData();
                objProjectProductionData.ProjectMProductionData.RecordID = l_gPPJ_ID;
                objProjectProductionData.ProjectMProductionData.ppj_SWLID = l_gSWL_ID;
                objProjectProductionData.ProjectMProductionData.ppj_cMachineNo = l_cMachineNo;
                objProjectProductionData.ProjectMProductionData.ppj_dProjBeginTime = DateTime.Now;
                objProjectProductionData.ProjectMProductionData.ppj_iQCInterval = projectBaseData.ProjectQCInervalTime;
                objProjectProductionData.ProjectMProductionData.ppj_iSpeed = projectBaseData.TargetSpeed;
                objProjectProductionData.ProjectMProductionData.ppj_iPertimeProdNum = 1;
                //“生產工程更多資料”對象
                objProjectProductionData.ProjectMProductionData.AdditionalInformation = new ProjectAdditionalInformation();
                objProjectProductionData.ProjectMProductionData.AdditionalInformation.RecordID = Guid.NewGuid();
                objProjectProductionData.ProjectMProductionData.AdditionalInformation.pai_PPJRecordID = l_gPPJ_ID;
                //===============================================================================//

                //■■■“班次內工程生產數據” 對象■■■
                objProjectProductionData.ShiftProjectData = new ShiftProjectProductionData();
                objProjectProductionData.ShiftProjectData.RecordID = l_gSPL_ID;
                objProjectProductionData.ShiftProjectData.spl_PPJID = l_gPPJ_ID;
                objProjectProductionData.ShiftProjectData.spl_SIFOID = l_gSIFO_ID;
                objProjectProductionData.ShiftProjectData.spl_dBeginTime = DateTime.Now;
                objProjectProductionData.ShiftProjectData.spl_SpareStatusID = spareStatusID;
                //班次內工程準備工作”對象地址
                objProjectProductionData.ShiftProjectData.PrepareJob = new ProjectPrepareJob();
                objProjectProductionData.ShiftProjectData.PrepareJob.PPJID = l_gPPJ_ID;
                objProjectProductionData.ShiftProjectData.PrepareJob.SPLID = l_gSPL_ID;
                objProjectProductionData.ShiftProjectData.PrepareJob.BeginDatetime = DateTime.Now;
                //“工程相關物料列表” 對象地址
                objProjectProductionData.ShiftProjectData.ProjectMaterials = new List<ProjectMaterial>();
                //工程停機記錄列表” 對象地址
                objProjectProductionData.ShiftProjectData.MachineHaltRecords = new List<ProjectMachineHaltRecord>();
                //“工程品檢記錄列表” 對象地址
                objProjectProductionData.ShiftProjectData.QCRecords = new List<ProjectQCRecord>();
                //“班次內工程消數、糾數記錄列表” 對象地址
                objProjectProductionData.ShiftProjectData.CorrectRecords = new List<ProjectCorrectRecord>();
                //===============================================================================//

                return objProjectProductionData;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// 新工程開始時獲取新的班次內工程生產數據
 /// </summary>
 /// <param name="newShiftInfo">新的班次信息</param>
 /// <param name="scheduleProject">排期工程</param>
 /// <param name="projectBaseData">機台生產工程下的基本資料</param>
 /// <param name="spareStatusID">空閒狀態記錄ID</param>
 public abstract ProjectProductionData GetShiftProjectProductionData(MachineShiftData newShiftInfo, ScheduleProjectData scheduleProject, ProjectBaseData projectBaseData, Guid spareStatusID);
Ejemplo n.º 5
0
 /// <summary>
 /// 獲取新的機台班次內數據記錄
 /// </summary>
 /// <param name="strSTMID">班次類型ID</param>
 /// <param name="strMacNo">機台編號</param>
 /// <param name="strShiftName">班次名稱</param>
 /// <param name="timeBegin">開始工作時間</param>
 /// <param name="timeEnd">結束工作時間</param>
 /// <param name="IsUnplanned">是否計劃外班次</param>
 /// <returns></returns>
 private MachineShiftData GetNewMachineShiftData(string strSTMID, string strMacNo, string strShiftName, DateTime? timeBegin, DateTime? timeEnd, bool IsUnplanned)
 {
     MachineShiftData macShiftData = new MachineShiftData();
     macShiftData.RecordID = Guid.NewGuid();
     int iSTMID = 0;
     try
     {
         iSTMID = int.Parse(strSTMID.Trim());
     }
     catch (Exception exInt)
     {
         iSTMID = 0;
         base.OnException(mc_strControllerName, "GetNewMachineShiftData", "班次類型ID有問題,為非INT類型。" + exInt.Message);
     }
     macShiftData.sifo_iSTMID = iSTMID;
     macShiftData.StaffInfos = new List<ShiftStaff>();
     macShiftData.SpareStatus = new List<MachineSpareStatus>();
     macShiftData.DinnerRecords = new List<DinnerRecord>();
     macShiftData.ShiftName = strShiftName.Trim();
     macShiftData.sifo_cMachineNO = strMacNo.Trim();
     macShiftData.sifo_dBeginTime = timeBegin;
     macShiftData.sifo_dEndTime = timeEnd;
     macShiftData.sifo_dProdDate = timeBegin.Value.Date;
     macShiftData.IsUnplanned = IsUnplanned;
     macShiftData.AddDate = DateTime.Now;
     macShiftData.LastDate = DateTime.Now;
     return macShiftData;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 更新機台班次內數據(只更新部份)
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool UpdateMachineShiftData(MachineShiftData machineShiftData, SqlTransaction tran)
        {
            if (machineShiftData == null)
            {
                return true;
            }

            try
            {

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update ShiftInfo_sifo set ");
                strSql.Append("sifo_DutyCaptainID='" + machineShiftData.sifo_DutyCaptainID + "',");
                strSql.Append("sifo_dLastDate=" + Common.General.HandleSqlFormatDateTime(machineShiftData.LastDate) + "");
                strSql.Append(" where sifo_RecordID='" + machineShiftData.RecordID + "' ");

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

                this.DeleteShiftStaff(machineShiftData.RecordID, tran);
                this.SaveShiftStaff(machineShiftData.StaffInfos, tran);

                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 綁定機組人員信息
        /// </summary>
        void BindMachineStaffInfos(MachineShiftData currentShiftData)
        {
            List<MachineStaffInfo> listAllStaffs = this.m_ShiftInfoController.MachineStaffInfos;
            this.m_AllStaffList = listAllStaffs;
            List<MachineStaffInfo> listCaptains = this.m_ShiftInfoController.GetAllCaptainsList();
            this.m_CaptianList = listCaptains;
            List<MachineStaffInfo> listStaffs = this.m_ShiftInfoController.GetAllStaffsList();
            this.m_StaffList = listStaffs;

            //綁定機長
            BindComboAllCaptains(listCaptains);

            //綁定可選員工
            BindListBoxCanSelectStaffs(listStaffs);

            //綁定已選員工
            if (currentShiftData != null)
            {
                BindSelectedStaff(currentShiftData.StaffInfos, listStaffs);
            }
            else
            {
                BindSelectedStaff(null, listStaffs);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 檢查班次是否為當天的班次信息
        /// </summary>
        /// <param name="shiftInfo">需要檢查的班次信息</param>
        public override bool IsCurrentTimeShift(MachineShiftData shiftInfo)
        {
            if (shiftInfo == null)
            {
                return true;
            }
            if (shiftInfo.sifo_dProdDate == null)
            {
                return true;
            }
            if (shiftInfo.sifo_dBeginTime == null || shiftInfo.sifo_dEndTime == null)
            {
                return true;
            }

            if (DateTime.Now >= shiftInfo.sifo_dBeginTime.Value && DateTime.Now <= shiftInfo.sifo_dEndTime.Value)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 班次結束時班次內工程生產數據校驗
        /// </summary>
        /// <param name="shiftInfo">舊班次信息</param>
        /// <param name="projectData">舊班次內工程生產數據</param>
        public override void ShiftFinishProjectProductionCheck(MachineShiftData shiftInfo, ProjectProductionData projectData)
        {
            try
            {
                int l_iShiftProjectData_DinnerTime = 0; //班次內工程的用餐時間

                //■■■設置“班次內工程生產數據資料”對象中的“工程結束時間”屬性為所在班次的班次結束時間■■■
                projectData.ShiftProjectData.spl_dEndTime = shiftInfo.sifo_dEndTime;

                //■■■設置用餐記錄列表中記錄的“工程ID”、“生產工程ID”、“班次內工程ID”,■■■
                //首先找出在班次內工程的“工程結束時間”和“工程開始時間”範圍內的所有用餐記錄,
                //再判斷這些記錄是否存在“工程ID”,如果不存在時才進行設置
                l_iShiftProjectData_DinnerTime=this.SetShiftProjcetDinnerInfo(shiftInfo.DinnerRecords, projectData);

                //■■■當工程狀態為“準備中”、“準備即將超時”、“準備超時”時■■■
                if (projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE.ToString().ToUpper()
                    || projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE_WOT.ToString().ToUpper()
                    || projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE_OT.ToString().ToUpper()
                  )
                {
                    /*
                    計算欄位:
                    a.“班次內工程生產數據資料”中的“準備時間”
                    b.“班次內工程生產數據資料”中的 “準備中的用餐時間”
                    c. “工程機台生產數據”中的“實際準備時間”
                    d. “班次內工程生產數據資料”中的 “總運作時間”
                    e. “工程機台生產數據”中的“生產總運作時間”
                    計算公式:
                    a=所在班次的班次結束時間-班次內工程開始時間
                    b=班次內已累計的用餐時間(通過“班次內工程開始時間”和“班次內工程結束時間”,從用餐記錄列表中尋找出所有屬於這個時段之內的用餐記錄來計算出用餐時間)
                    c=c +a
                    d=“工程結束時間”-“工程開始時間”
                    e=e+d
                    */
                    if (shiftInfo.sifo_dEndTime.HasValue && projectData.ShiftProjectData.spl_dBeginTime.HasValue)
                        projectData.ShiftProjectData.spl_iPrepairTime = (int)(shiftInfo.sifo_dEndTime.Value - projectData.ShiftProjectData.spl_dBeginTime.Value).TotalSeconds;

                    projectData.ShiftProjectData.spl_iPrepairDinnerTime = l_iShiftProjectData_DinnerTime;

                    projectData.ProjectMProductionData.ppj_iActualPrepairTime += projectData.ShiftProjectData.spl_iPrepairTime;

                    if (projectData.ShiftProjectData.spl_dEndTime.HasValue && projectData.ShiftProjectData.spl_dBeginTime.HasValue)
                        projectData.ShiftProjectData.spl_iRunTime = (int)(projectData.ShiftProjectData.spl_dEndTime.Value - projectData.ShiftProjectData.spl_dBeginTime.Value).TotalSeconds;

                    projectData.ProjectMProductionData.ppj_iProjRunTime += projectData.ShiftProjectData.spl_iRunTime;
                }
                //■■■當工程狀態為不是“準備中”、“準備即將超時”、“準備超時” 時■■■
                else if (projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE.ToString().ToUpper()
                    && projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE_WOT.ToString().ToUpper()
                    && projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE_OT.ToString().ToUpper()
                  )
                {
                    /*
                    檢查“班次內工程生產數據資料”中的“工程停機記錄列表”是否存在沒有停機結束時間的記錄,
                    如果存在:
                    a.將“工程停機記錄”中的“停機結束時間”設置為所在班次的班次結束時間
                    b.計算出“工程停機記錄”中的“實際停機時間”(停機結束時間-停機開始時間)
                    c. 計算出“工程停機記錄”中的“用餐時間”,通過此記錄的“停機開始時間”及“停機結束時間”,
                     * 從用餐記錄列表中尋找出所有在此時間範圍內的用餐記錄計算出總的用餐時間,
                     * 並設置用餐記錄中的“停機記錄ID”屬性
                    */
                    ProjectMachineHaltRecord objNotEndTimeHaltRecord = projectData.ShiftProjectData.MachineHaltRecords.FirstOrDefault(p => p.psrd_dEndTime.HasValue == false);
                    if (objNotEndTimeHaltRecord != null)
                    {
                        objNotEndTimeHaltRecord.psrd_dEndTime = shiftInfo.sifo_dEndTime;
                    }

                    //設置停機記錄用餐信息
                    this.SetMachineHaltRecordDinnerInfo(shiftInfo.DinnerRecords, projectData.ShiftProjectData.MachineHaltRecords);

                    this.SetShiftProjcetQCTimeInfo(projectData.ShiftProjectData.QCRecords,shiftInfo.sifo_dEndTime.Value);
                }

                //■■■計算欄位
                this.CalculateField(projectData);

            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 檢查要“抽起”或“結束”的工程生產數據是否完整,如果不完整則返回一個殘缺數據的類型。
        /// </summary>
        /// <param name="departmentCode">機台所屬科組編號</param>
        /// <param name="operationType">操作類型“抽起”或“結束”</param>
        /// <param name="shiftInfo">當前班次信息</param>
        /// <param name="projectData">當前工程生產數據</param>
        /// <returns>返回一個殘缺的數據類型</returns>
        public override CommonDefine.ProjectDataType CheckProjectProductionDataFull(string departmentCode, CustEnum.ProjectStatus operationType, MachineShiftData shiftInfo, ProjectProductionData projectData)
        {
            try
            {
                CommonDefine.ProjectDataType l_enumDataFull = CommonDefine.ProjectDataType.DataFull;

                //■■■檢查“工程更多資料”是否缺少數據,如果缺少時返回一個“工程更多資料”類型,
                //需要根據不同科組來進行不同的檢查,並退出方法

                ReturnValueInfo projectAdditionalResult = this.CheckProjectAdditionalDataFull(departmentCode, projectData.ProjectMProductionData.AdditionalInformation);

                if (projectAdditionalResult != null)
                {
                    if (!projectAdditionalResult.boolValue)
                    {
                        return CommonDefine.ProjectDataType.ProjectAdditionalInformation;
                    }
                }

                //■■■檢查“停機記錄”列表中是否存在沒有 選擇停機原因的記錄,如果存在則返回一個“停機記錄”類型,並退出方法
                foreach (var item in projectData.ShiftProjectData.MachineHaltRecords)
                {
                    if (item.StopReasons == null || item.StopReasons.Count == 0)
                        return  CommonDefine.ProjectDataType.MachineHaltRecord;
                }

                //■■■檢查“檢品記錄”列表中是否存在沒有進行品檢的記錄,如果存在則返回一個“檢品記錄”類型,並退出方法
                foreach (var item in projectData.ShiftProjectData.QCRecords)
                {
                    if (item.pqc_dQCEndTime.HasValue==false)
                        return CommonDefine.ProjectDataType.ProjectQC;
                }

                //■■■檢查“班次人員”列表中 是否已選擇了班次人員,如果 沒有選擇則返回一個“班次人員”類型,並退出方法
                bool isSelectedStaff= false;

                if (shiftInfo.StaffInfos != null && shiftInfo.StaffInfos.Count > 0)
                {
                    isSelectedStaff = true;
                }

                if (shiftInfo.sifo_DutyCaptainID != null && shiftInfo.sifo_DutyCaptainID!=Guid.Empty)
                {
                    isSelectedStaff = true;
                }

                if (!isSelectedStaff)
                {
                    return CommonDefine.ProjectDataType.ShiftStaff;
                }

                //■■■數據都完整,返回一個完整的類型
                return l_enumDataFull;
            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 班次結束時機台數據校驗
        /// </summary>
        /// <param name="shiftTypeInfos">班次類型信息列表</param>
        /// <param name="shiftInfo">舊班次信息</param>
        /// <param name="projectData">舊班次內工程ID</param>
        public override void ShiftFinishMachineProductionCheck(List<ShiftTypeInfo> shiftTypeInfos, MachineShiftData shiftInfo, Guid shiftProjectID)
        {
            try
            {
                //■■■檢查“空閒狀態”列表是否存在沒有結束時間的記錄,如果存在則將此記錄的結時間設置為所在班次的班次結束時間
                if (shiftInfo.SpareStatus != null)
                {
                    foreach (var item in shiftInfo.SpareStatus)
                    {
                        if (item.sst_dEndTime.HasValue == false)
                            item.sst_dEndTime = shiftInfo.sifo_dEndTime;
                    }
                }

                //■■■如果“空閒狀態”列表中存在沒有結束時間的記錄時,用此記錄的“開始時間”及“所在班次的班次結束時間”,
                //從用餐記錄列表中尋找出所有在此時間範圍內的用餐記錄,並設置這些記錄的“空 閒記錄ID”
                //(如果“空閒記錄ID”為空時才進行設置)
                if (shiftInfo.SpareStatus != null && shiftInfo.DinnerRecords != null)
                {
                    foreach (MachineSpareStatus item in shiftInfo.SpareStatus)
                    {
                        List<DinnerRecord> lstFindDinnerRecord = shiftInfo.DinnerRecords.Where
                            (p => p.dnr_dBeginTime >= item.sst_dBeginTime &&
                                p.dnr_dEndTime <= item.sst_dEndTime).ToList();

                        if (lstFindDinnerRecord != null)
                        {
                            foreach (DinnerRecord dinnerInfo in lstFindDinnerRecord)
                            {
                                if (dinnerInfo.dsm_sstID == Guid.Empty)
                                    dinnerInfo.dsm_sstID = item.RecordID;
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 工程跨班時設置新的班次內生產數據
        /// </summary>
        /// <param name="shiftInfo">新的班次信息</param>
        /// <param name="projectData">上班次生產工程數據</param>
        public override void SetNewShiftProjectProductionData(MachineShiftData newShiftInfo, ProjectProductionData projectData)
        {
            try
            {
                Guid l_gPPJ_ID = projectData.ProjectMachineProductionID;    //工程機台生產ID
                Guid l_gSPL_ID = Guid.NewGuid();   //班次內工程生產ID
                Guid l_gSIFO_ID = newShiftInfo.RecordID; //班次ID
                string l_cMachineNo = newShiftInfo.sifo_cMachineNO;

                //■■■重新創建 “工程生產數據資料”對象中的“班次內工程生產ID”■■■
                projectData.ShiftProjectID = l_gSPL_ID;

                //■■■“班次內工程生產數據” 對象■■■
                projectData.ShiftProjectData = new ShiftProjectProductionData();
                projectData.ShiftProjectData.RecordID = l_gSPL_ID;
                projectData.ShiftProjectData.spl_PPJID = l_gPPJ_ID;
                projectData.ShiftProjectData.spl_SIFOID = l_gSIFO_ID;
                projectData.ShiftProjectData.spl_dBeginTime = newShiftInfo.sifo_dBeginTime;
                //班次內工程準備工作”對象地址
                projectData.ShiftProjectData.PrepareJob = new ProjectPrepareJob();
                //“工程相關物料列表” 對象地址
                projectData.ShiftProjectData.ProjectMaterials = new List<ProjectMaterial>();
                //工程停機記錄列表” 對象地址
                projectData.ShiftProjectData.MachineHaltRecords = new List<ProjectMachineHaltRecord>();
                //“工程品檢記錄列表” 對象地址
                projectData.ShiftProjectData.QCRecords = new List<ProjectQCRecord>();
                //“班次內工程消數、糾數記錄列表” 對象地址
                projectData.ShiftProjectData.CorrectRecords = new List<ProjectCorrectRecord>();

                //■■■當工程狀態為不是“準備中”、“準備即將超時”、“準備超時” 時,設置“生產開始時間”為所在班次的班次開始時間
                if (projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE.ToString().ToUpper()
                    && projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE_WOT.ToString().ToUpper()
                    && projectData.ProjectBaseData.swl_cProjStatus.ToUpper() != CustEnum.ProjectStatus.PREPARE_OT.ToString().ToUpper()
                )
                {
                    projectData.ShiftProjectData.spl_dProdBegin = newShiftInfo.sifo_dBeginTime;
                }
                //■■■當工程狀態為“準備中”、“準備即將超時”、“準備超時” 時,設置“班次內工程準備工作”對象的屬性“工程機台生產數據 ID”、“班次內工程ID”、“開始時間”
                else if (projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE.ToString().ToUpper()
                    || projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE_WOT.ToString().ToUpper()
                    || projectData.ProjectBaseData.swl_cProjStatus.ToUpper() == CustEnum.ProjectStatus.PREPARE_OT.ToString().ToUpper()
                )
                {
                    projectData.ShiftProjectData.PrepareJob.PPJID = l_gPPJ_ID;
                    projectData.ShiftProjectData.PrepareJob.SPLID = l_gSPL_ID;
                    projectData.ShiftProjectData.PrepareJob.BeginDatetime = DateTime.Now;
                }

            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 工程“抽起”或“結束”生產數據校驗
        /// </summary>
        /// <param name="shiftInfo">當前班次信息</param>
        /// <param name="projectData">當前工程生產數據</param>
        /// <param name="projectStatus">工程狀態</param>
        public override void ProjectFinishProductionDataCheck(MachineShiftData shiftInfo, ProjectProductionData projectData, string projectStatus)
        {
            try
            {
                //■■■設置“生產工程的基本資料(待生產工程資料)”中的“工程狀態”屬性。
                projectData.ProjectBaseData.swl_cProjStatus = projectStatus;
                projectData.ProjectBaseData.swl_dStatusChange = DateTime.Now;

                /*■■■檢查“班次內工程生產數據資料”中的“工程停機記錄列表”是否存在沒有停機結束時間的記錄,如果存在:
                    a.將“工程停機記錄”中的“停機結束時間”設置為系統當前時間
                    b.計算出“工程停機記錄”中的“實際停機時間”(停機結束時間-停機開始時間)
                    c.計算出“工程停機記錄”中的“用餐時間”,通過此記錄的“停機開始時間”及“停機結束時間”,
                        從用餐記錄列表中尋找出所有在此時間範圍內的用餐記錄計算出總的用餐時間,並設置用餐記錄中的“停機記錄ID”
                */
                ProjectMachineHaltRecord objNotEndTimeHaltRecord = projectData.ShiftProjectData.MachineHaltRecords.FirstOrDefault(p => p.psrd_dEndTime.HasValue == false);
                if (objNotEndTimeHaltRecord != null)
                {
                    objNotEndTimeHaltRecord.psrd_dEndTime = DateTime.Now;
                }

                //設置停機記錄用餐信息
                this.SetMachineHaltRecordDinnerInfo(shiftInfo.DinnerRecords, projectData.ShiftProjectData.MachineHaltRecords);

                //■■■設置“班次內工程生產數據資料”對象中的“工程結束時間”屬性為系統當前時間
                projectData.ShiftProjectData.spl_dEndTime = DateTime.Now;

                //■■■設置用餐記錄列表中記錄的“工程ID”、“生產工程ID”、“班次內工程ID”,
                //首先找出在班次內工程的“工程結束時間”和“工程開始時間”範圍內的所有用餐記錄,
                //再判斷這些記錄是否存在“工程ID”,如果不存在時才進行設置

                this.SetShiftProjcetDinnerInfo(shiftInfo.DinnerRecords, projectData);

                //■■■設置“工程機台生產數據”中的“結束生產時間”屬性為系統當前時間
                projectData.ProjectMProductionData.ppj_dProdEndTime = DateTime.Now;

                //■■■計算欄位
                this.CalculateField(projectData);
            }
            catch (Exception ex) { throw ex; }
        }
 /// <summary>
 /// 班次結束時機台數據校驗
 /// </summary>
 /// <param name="shiftTypeInfos">班次類型信息列表</param>
 /// <param name="shiftInfo">舊班次信息</param>
 /// <param name="shiftProjectID">舊班次內工程ID</param>
 public abstract void ShiftFinishMachineProductionCheck(List<ShiftTypeInfo> shiftTypeInfos,MachineShiftData shiftInfo, Guid shiftProjectID);
Ejemplo n.º 15
0
        /// <summary>
        /// 綁定班次信息
        /// </summary>
        /// <param name="targetShiftInfo"></param>
        void BindShiftInfo(MachineShiftData targetShiftInfo)
        {
            if (targetShiftInfo == null)
            {
                this.m_frmShiftsInfoInputBase.ButtonSave.Enabled = false;
                return;
            }

            this.m_frmShiftsInfoInputBase.ButtonSave.Enabled = true;
            //機台編號
            this.m_frmShiftsInfoInputBase.TextBoxMachineNo.Text = targetShiftInfo.sifo_cMachineNO.Trim();
            //班次
            this.m_frmShiftsInfoInputBase.TextBoxShiftName.Text = targetShiftInfo.ShiftName.Trim();
            try
            {
                //計劃上班
                if (targetShiftInfo.sifo_dBeginTime != null)
                {
                    this.m_frmShiftsInfoInputBase.TextBoxTimeOnDuty.Text = targetShiftInfo.sifo_dBeginTime.Value.ToString(GlobalVar.DTFormat);
                }
                else
                {
                    this.m_frmShiftsInfoInputBase.TextBoxTimeOnDuty.Text = string.Empty;
                }
                //計劃下班
                if (targetShiftInfo.sifo_dEndTime != null)
                {
                    this.m_frmShiftsInfoInputBase.TextBoxTimeOffDuty.Text = targetShiftInfo.sifo_dEndTime.Value.ToString(GlobalVar.DTFormat);
                }
                else
                {
                    this.m_frmShiftsInfoInputBase.TextBoxTimeOffDuty.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                base.ShowErrorMessage(ex);
            }
        }
 /// <summary>
 /// 班次結束時班次內工程生產數據校驗
 /// </summary>
 /// <param name="shiftInfo">舊班次信息</param>
 /// <param name="projectData">舊班次內工程生產數據</param>
 public abstract void ShiftFinishProjectProductionCheck(MachineShiftData shiftInfo, ProjectProductionData projectData);
Ejemplo n.º 17
0
        /// <summary>
        /// 機台班次信息實時數據上傳到服務器數據庫中
        /// </summary>
        /// <param name="machineShiftData">機台班次信息</param>
        /// <returns></returns>
        public bool SynMachineShiftInformationToDB(MachineShiftData machineShiftData)
        {
            try
            {
                bool l_lIsSuess = false;

                List<DinnerRecord> dinnerRecords = (machineShiftData != null ? machineShiftData.DinnerRecords : null);

                using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                {
                    SqlTransaction transaction = null;

                    conn.Open(); //開啟連接
                    transaction = conn.BeginTransaction(); //開啟事務

                    try
                    {
                        //★檢查服務器數據庫是否存在班次信息記錄(sifo)
                        //如果不存在則將班次信息記錄新增到相應的數據表中
                        if (this.m_objProductionDataSynDAL.CheckExistMachineShiftData(machineShiftData.RecordID) == false)
                        {
                            this.m_objProductionDataSynDAL.AddMachineShiftData(machineShiftData, transaction);
                        }
                        //如果存在則通過對比記錄的最後修改時間來決定是否修改“責任機長”、“最後修改時間”
                        else
                        {
                            MachineShiftData data_DB = this.m_objProductionDataSynDAL.GetMachineShiftData("sifo_RecordID='" + machineShiftData.RecordID + "'").FirstOrDefault();

                            if (data_DB != null && machineShiftData.LastDate!=null)
                            {
                                if (machineShiftData.LastDate> data_DB.LastDate || data_DB.LastDate==null)
                                {
                                    this.m_objProductionDataSynDAL.UpdateMachineShiftData(machineShiftData, transaction);
                                }
                            }
                        }

                        //★檢查所有用餐記錄是否存在於服務器數據庫中(dnr)
                        //如果不存在則將用餐記錄新增到相應的數據表中,
                        //如果存在則通過對比記錄的最後修改時間來決定是否修改“結束時間”、“空閒記錄ID”、“工程ID”、“班次內工程ID”、“生產工程ID”、“停機記錄ID”、“工程狀態”、“最後修改時間”
                        if (dinnerRecords != null)
                        {
                            foreach (DinnerRecord dinnerRecord in dinnerRecords)
                            {
                                if (this.m_objProductionDataSynDAL.CheckExistDinnerRecord(dinnerRecord.RecordID) == false)
                                    this.m_objProductionDataSynDAL.AddDinnerRecord(dinnerRecord, transaction);
                                else
                                {
                                    DinnerRecord data_DB = this.m_objProductionDataSynDAL.GetDinnerRecord("dnr_RecordID='" + dinnerRecord.RecordID + "'").FirstOrDefault();

                                    if (data_DB != null && data_DB.LastDate != dinnerRecord.LastDate)
                                    {
                                        this.m_objProductionDataSynDAL.UpdateDinnerRecord(dinnerRecord.RecordID, dinnerRecord.dnr_dEndTime, dinnerRecord.dsm_sstID, dinnerRecord.dsm_swlID, dinnerRecord.dsm_ppjID,
                                            dinnerRecord.dsm_splID, dinnerRecord.dsm_psrdID, dinnerRecord.dsm_cProjectStatus, dinnerRecord.LastDate, transaction);
                                    }
                                }
                            }
                        }

                        l_lIsSuess = true;
                    }
                    catch (Exception exTran)
                    {
                        l_lIsSuess = false;
                        throw exTran;
                    }
                    finally
                    {
                        if (l_lIsSuess)
                            transaction.Commit();
                        else
                            transaction.Rollback();
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 檢查班次信息是否有區別 --->add at 20150706
        /// </summary>
        /// <param name="dataPre">班次信息一</param>
        /// <param name="dataNext">班次信息二</param>
        /// <returns>是否有區別</returns>
        private bool CheckShiftInfoChange(MachineShiftData dataPre, MachineShiftData dataNext)
        {
            bool rvRes = false;

            if (dataPre != null && dataNext != null)
            {
                if (dataPre.ShiftName != dataNext.ShiftName)
                {
                    return true;
                }
                if (dataPre.sifo_dBeginTime != dataNext.sifo_dBeginTime)
                {
                    return true;
                }
                if (dataNext.sifo_dEndTime != dataNext.sifo_dEndTime)
                {
                    return true;
                }
            }
            else
            {
                return true;
            }

            return rvRes;
        }
Ejemplo n.º 19
0
        //-------------------------------------->>>Begin Add By DonaldHuang 2015-06-02
        /// <summary>
        ///  獲取指定的班次記錄的班次信息描述
        /// </summary>
        /// <param name="shiftInfo">班次信息對象</param>
        public static string GetSpecialShiftDescribe(MachineShiftData shiftInfo)
        {
            if (shiftInfo == null)
            {
                return string.Empty;
            }

            string shiftDesc = string.Empty;

            if (shiftInfo.sifo_dProdDate != null)
            {
                shiftDesc = shiftInfo.sifo_dProdDate.Value.ToString(GlobalVar.DFormat) + "  ";
            }

            shiftDesc += shiftInfo.ShiftName;

            return shiftDesc;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 新增機台班次內數據
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddMachineShiftData(MachineShiftData model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into ShiftInfo_sifo(");
                strSql.Append("sifo_RecordID,sifo_iSTMID,sifo_dProdDate,sifo_cMachineNO,sifo_DutyCaptainID,sifo_iOffDutySetID,sifo_dBeginTime,sifo_dEndTime,sifo_lOvertime,sifo_cType,sifo_lSync,sifo_dAddDate,sifo_dLastDate)");
                strSql.Append(" values (");
                strSql.Append("@sifo_RecordID,@sifo_iSTMID,@sifo_dProdDate,@sifo_cMachineNO,@sifo_DutyCaptainID,@sifo_iOffDutySetID,@sifo_dBeginTime,@sifo_dEndTime,@sifo_lOvertime,@sifo_cType,@sifo_lSync,@sifo_dAddDate,@sifo_dLastDate)");
                SqlParameter[] parameters = {
                    DbHelperSQL.MakeInParam("@sifo_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                    DbHelperSQL.MakeInParam("@sifo_iSTMID", SqlDbType.Int,4, model.sifo_iSTMID),
                    DbHelperSQL.MakeInParam("@sifo_dProdDate", SqlDbType.DateTime, 0, model.sifo_dProdDate),
                    DbHelperSQL.MakeInParam("@sifo_cMachineNO", SqlDbType.NVarChar,20, model.sifo_cMachineNO),
                    DbHelperSQL.MakeInParam("@sifo_DutyCaptainID", SqlDbType.UniqueIdentifier,16, model.sifo_DutyCaptainID),
                    DbHelperSQL.MakeInParam("@sifo_iOffDutySetID", SqlDbType.Int,4, model.sifo_iOffDutySetID),
                    DbHelperSQL.MakeInParam("@sifo_dBeginTime", SqlDbType.DateTime, 0,  model.sifo_dBeginTime),
                    DbHelperSQL.MakeInParam("@sifo_dEndTime", SqlDbType.DateTime, 0,  model.sifo_dEndTime),
                    DbHelperSQL.MakeInParam("@sifo_lOvertime", SqlDbType.Bit,1, model.sifo_lOvertime),
                    DbHelperSQL.MakeInParam("@sifo_cType", SqlDbType.NVarChar,20, model.sifo_cType),
                    DbHelperSQL.MakeInParam("@sifo_lSync", SqlDbType.Bit,1, 0),//model.sifo_lSync;
                    DbHelperSQL.MakeInParam("@sifo_dAddDate", SqlDbType.DateTime, 0, model.AddDate),
                    DbHelperSQL.MakeInParam("@sifo_dLastDate", SqlDbType.DateTime, 0, model.LastDate)
                                            };

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

                this.SaveShiftStaff(model.StaffInfos, tran);

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
 /// <summary>
 /// 檢查要“抽起”或“結束”的工程生產數據是否完整,如果不完整則返回一個殘缺數據的類型
 /// </summary>
 /// <param name="departmentCode">機台所屬科組編號</param>
 /// <param name="operationType">操作類型“抽起”或“結束”</param>
 /// <param name="shiftInfo">當前班次信息</param>
 /// <param name="projectData">當前工程生產數據</param>
 /// <returns>返回一個殘缺的數據類型</returns>
 public abstract CommonDefine.ProjectDataType CheckProjectProductionDataFull(string departmentCode, CustEnum.ProjectStatus operationType, MachineShiftData shiftInfo, ProjectProductionData projectData);
Ejemplo n.º 22
0
 /// <summary>
 /// 对象实体绑定数据(MachineShiftData)
 /// </summary>
 private MachineShiftData ReaderBind_SIFO(IDataReader dataReader)
 {
     MachineShiftData model = new MachineShiftData();
     object ojb;
     ojb = dataReader["sifo_RecordID"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.RecordID = new Guid(ojb.ToString());
     }
     ojb = dataReader["sifo_iSTMID"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_iSTMID = (int)ojb;
     }
     ojb = dataReader["sifo_dProdDate"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_dProdDate = (DateTime)ojb;
     }
     model.sifo_cMachineNO = dataReader["sifo_cMachineNO"].ToString();
     ojb = dataReader["sifo_DutyCaptainID"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_DutyCaptainID = new Guid(ojb.ToString());
     }
     ojb = dataReader["sifo_iOffDutySetID"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_iOffDutySetID = (int)ojb;
     }
     ojb = dataReader["sifo_dBeginTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_dBeginTime = (DateTime)ojb;
     }
     ojb = dataReader["sifo_dEndTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_dEndTime = (DateTime)ojb;
     }
     ojb = dataReader["sifo_lOvertime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.sifo_lOvertime = (bool)ojb;
     }
     model.sifo_cType = dataReader["sifo_cType"].ToString();
     ojb = dataReader["sifo_lSync"];
     if (ojb != null && ojb != DBNull.Value)
     {
         //model.sifo_lSync = (bool)ojb;
     }
     ojb = dataReader["sifo_dAddDate"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.AddDate = (DateTime)ojb;
     }
     ojb = dataReader["sifo_dLastDate"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.LastDate = (DateTime)ojb;
     }
     return model;
 }
        /// <summary>
        /// 創建序列化文件并返回其反序列化實體
        /// </summary>
        /// <param name="macShiftData">機台班次內數據</param>
        /// <param name="strFilePath">序列化的路徑</param>
        private MachineShiftData CreateAndGetEntity_MachineShiftData(MachineShiftData macShiftData, string strFilePath)
        {
            if (macShiftData == null)
            {
                return null;
            }

            if (string.IsNullOrEmpty(strFilePath))
            {
                return null;
            }

            MachineShiftData reObj = null;
            string strErrMsg = string.Empty;

            for (int i = 0; i < mc_iMaxReTryDeserialization; i++)
            {
                try
                {
                    using (FileStream stream = new FileStream(strFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(MachineShiftData));
                        serializer.Serialize(stream, macShiftData);
                        stream.Seek(0, SeekOrigin.Begin);//保持文件流讀取的順序從文件頭開始讀取
                        reObj = serializer.Deserialize(stream) as MachineShiftData;
                        if (reObj != null)
                        {
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    //判斷是否已到重試的最後一次,若是則保留反序列化失敗的文件,否則刪除
                    if (i < mc_iMaxReTryDeserialization - 1)
                    {
                        try
                        {
                            if (File.Exists(strFilePath))
                            {
                                File.Delete(strFilePath);
                            }
                        }
                        catch (Exception exDel)
                        {
                            strErrMsg += exDel.Message + Environment.NewLine;
                        }
                    }

                    strErrMsg += ex.Message + Environment.NewLine;
                    reObj = null;
                    continue;
                }
            }

            if (!string.IsNullOrEmpty(strErrMsg))
            {
                base.OnException(mc_strControllerName, "CreateAndGetEntity_MachineShiftData", strErrMsg);
            }

            return reObj;
        }