Esempio n. 1
0
        public ProjectBaseData GetProjectBaseData()
        {
            Model.ProfileData profileData;
            if (m_ProfileDataSQLite == null && m_ProfileData == null)
            {
                throw new Exception("請先從服務器或本地SQLite獲取數據!");
            }
            if (m_ProfileData == null)
            {
                profileData = m_ProfileDataSQLite;
            }
            else
            {
                profileData = m_ProfileData;
            }

            ProjectBaseData data = new ProjectBaseData();
            CodeMaster_cmt_Info code = new CodeMaster_cmt_Info();
            List<CodeMaster_cmt_Info> codes = new List<CodeMaster_cmt_Info>();

            //品檢間隔時長(分鐘)
            code = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_DEFAULT, DefineConstantValue.CodeMasterDefine.KEY3_QCINTERVAL);
            if (code != null)
            {
                data.ProjectQCInervalTime = Convert.ToInt32(code.cmt_fNumber);
            }

            //工程停機邏輯時間
            code = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_DEFAULT, DefineConstantValue.CodeMasterDefine.KEY3_PROD_STOP_COND);
            if (code != null)
            {
                data.ProjectMachineHaltLogicTime = Convert.ToInt32(code.cmt_fNumber);
            }

            //目標速度(張/小時)
            data.TargetSpeed = profileData.MachineSpeed;

            //準備工作超時警告提前警告時間量(分鐘)
            code = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_PREPARE, DefineConstantValue.CodeMasterDefine.KEY3_PREPARE_WOTTIME);
            if (code != null)
            {
                data.OvertimeAlertTimeInAdvance = Convert.ToInt32(code.cmt_fNumber);
            }

            //工程等級列表
            List<BaseModel> projectGrades = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_PROJECTLEVEL);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                projectGrades.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.ProjectGrades = projectGrades;

            //工程轉版等級列表
            List<BaseModel> projectPrepareGrades = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_PROJECTPREPARELEVEL);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                projectPrepareGrades.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark + ":" + Convert.ToInt32(item.cmt_fNumber).ToString().Trim()
                });
            }
            data.ProjectPerpareGrades = projectPrepareGrades;

            //消數原因列表
            List<BaseModel> clearUpProductionQuantityReasons = new List<BaseModel>();

            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_MODIFYQTY, DefineConstantValue.CodeMasterDefine.KEY2_CLEARQTY);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                clearUpProductionQuantityReasons.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.ClearUpProductionQuantityReasons = clearUpProductionQuantityReasons;

            //糾數原因列表
            List<BaseModel> correctProductionQuantityReasons = new List<BaseModel>();

            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_MODIFYQTY, DefineConstantValue.CodeMasterDefine.KEY2_CORRECTQTY);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                correctProductionQuantityReasons.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.CorrectProductionQuantityReasons = correctProductionQuantityReasons;

            //工程抽起原因列表
            List<BaseModel> projectExtractionReasons = new List<BaseModel>();

            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_PROJECT, DefineConstantValue.CodeMasterDefine.KEY2_STOPREASON);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                projectExtractionReasons.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.ProjectExtractionReasons = projectExtractionReasons;

            //溫度單位列表
            List<BaseModel> temperatureUnits = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_TEMPERATUREUNIT);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                temperatureUnits.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.TemperatureUnits = temperatureUnits;

            // 壓力單位列表
            List<BaseModel> perssureUnits = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_PRESSUREUNIT);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                perssureUnits.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.PerssureUnits = perssureUnits;

            //油墨列表
            List<BaseModel> printinInks = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_INKTYPE);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                printinInks.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.PrintinInks = printinInks;

            //準備工作項列表
            List<ProjectBaseItemModel> prepareItems = new List<ProjectBaseItemModel>();
            foreach (Model.HBPMS.Master.PrepareProjectMaster_ppm_Info item in profileData.PrepareProjectMaster)
            {
                prepareItems.Add(new ProjectBaseItemModel()
                {
                    Code = item.ppm_RecordID.ToString(),
                    Description = item.ppm_cItemName,
                    IsParallelable = item.ppm_lIsParallelable,
                    PredictedTime = item.ppm_iPredictedTime
                });
            }
            data.PrepareItems = prepareItems;

            //工程物料列表
            List<MaterialMaster> materialItems = new List<MaterialMaster>();
            if (profileData.MaterialMaster != null)
            {
                foreach (Model.HBPMS.Management.RunningManagement.MaterialProfile_mlpf_Info item in profileData.MaterialMaster)
                {
                    if (item != null)
                    {
                        MaterialMaster material = new MaterialMaster();

                        material.pmr_MLPFID = item.mlpf_MLPFID;
                        material.pmr_MaterialNo = item.mlpf_cMaterialCode;
                        material.pmr_MaterialTypeName = item.mlpf_cMaterialType;
                        material.pmr_MaterialName = item.mlpf_cMaterialName;
                        material.pmr_cMARK = item.mlpf_cDescription;
                        material.pmr_MaterialNameAbbreviation = item.mlpf_cMaterialAbbreviation;
                        material.pmr_MaterialBrandName = item.mlpf_cMaterialBrand;
                        material.pmr_UnitName = item.mlpf_cMaterialUnit;
                        material.pmr_cUnit = item.mlpf_cMaterialUnit;
                        material.pmr_fWidth = item.mlpf_fMaterialWidth;
                        material.pmr_fLength = item.mlpf_fMaterialLength;

                        materialItems.Add(material);
                    }

                }
            }
            data.MaterialMasters = materialItems;

            //工程物料類型列表
            List<BaseModel> materialTypes = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_MATERIALTYPE);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                materialTypes.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.MaterialTypes = materialTypes;

            //工程物料單位列表
            List<BaseModel> materialUnits = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_MATERIALUNIT);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                materialUnits.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.MaterialUnits = materialUnits;

            //工程物料所屬科組編號
            code = GetCodeMaster(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_MATERIALDEPARTMENTCODE);
            if (code != null)
            {
                data.MaterialDepartmentCode = code.cmt_cValue.Trim();
            }

            //停機原因項列表
            List<ProjectBaseItemModel> machineHaltReasons = new List<ProjectBaseItemModel>();
            foreach (StopReasonMaster_srm_Info item in profileData.StopReasonMaster)
            {
                machineHaltReasons.Add(new ProjectBaseItemModel()
                {
                    Code = item.srm_iRecordID.ToString(),
                    Description = item.srm_cReasonName,
                    IsParallelable = item.srm_lIsParallelable,
                    PredictedTime = item.srm_iPredictedTime

                });
            }

            data.MachineHaltReasons = machineHaltReasons;

            //工程品檢品質問題列表
            List<ProjectQCQualityIssues> QCQualityIssues = new List<ProjectQCQualityIssues>();
            foreach (QualityProblemMaster_qpm_Info item in profileData.QualityProblemMaster)
            {
                QCQualityIssues.Add(new ProjectQCQualityIssues()
                {
                    Code = item.qpm_iRecordID.ToString(),
                    Description = item.qpm_cProblemName,
                    Solution = item.qpm_cSuggestedTechnique
                });
            }
            data.QCQualityIssues = QCQualityIssues;

            //工程狀態列表
            List<BaseModel> projectStatus = new List<BaseModel>();
            codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_STATUS, DefineConstantValue.CodeMasterDefine.KEY2_PROJECT);
            foreach (CodeMaster_cmt_Info item in codes)
            {
                projectStatus.Add(new BaseModel()
                {
                    Code = item.cmt_cValue,
                    Description = item.cmt_cRemark
                });
            }
            data.ProjectStatus = projectStatus;

            return data;
        }
 /// <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);
        /// <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;
            }
        }