/// <summary> /// 判斷工程生產狀態 /// </summary> /// <param name="shiftProjectData"></param> void SetProjectStatusInformation(ShiftProjectProductionDataInformation shiftProjectData) { if (this._currentProjectStatus == CustEnum.ProjectStatus.PROD_IN || this._currentProjectStatus == CustEnum.ProjectStatus.PROD_SLOW) { if (shiftProjectData.ProdSpeed <= 0) { this.ProductionProjectStatusSetting(CustEnum.ProjectStatus.PROD_SLOW); } else { if (shiftProjectData.ProdSpeed < this.ProductionData.ProjectMProductionData.ppj_iSpeed) { this.ProductionProjectStatusSetting(CustEnum.ProjectStatus.PROD_SLOW); } else { this.ProductionProjectStatusSetting(CustEnum.ProjectStatus.PROD_IN); } } } shiftProjectData.ProjStatusCode = this._currentProjectStatus; shiftProjectData.ProjStatus = GetProjectStatusDesc(this._currentProjectStatus.ToString().Trim()); }
/// <summary> /// 工程數據整理 /// </summary> void ProjectProductionDataCollator() { //班次內工程生產數據信息 ShiftProjectProductionDataInformation shiftProjectData = new ShiftProjectProductionDataInformation(); //工程機台生產數據 ProjectProductionDataInformation projectData = new ProjectProductionDataInformation(); if (this.ProductionData != null && this.ProductionData.ProjectBaseData != null) { shiftProjectData.GrandTotalProdQty = this.ProductionData.ProjectBaseData.swl_iCompletedQty; shiftProjectData.RemainQty = this.ProductionData.ProjectBaseData.swl_iPlanProdQty; } if (this.ProductionData != null && this.ProductionData.ShiftProjectData != null) { if (this.ProductionData.ShiftProjectData.spl_dBeginTime != null) { shiftProjectData.ProjectBeginTime = this.ProductionData.ShiftProjectData.spl_dBeginTime.Value.ToString(GlobalVar.DTFormat); } if (this.ProductionData.ShiftProjectData.spl_dProdBegin != null) { shiftProjectData.ProdBeginTime = this.ProductionData.ShiftProjectData.spl_dProdBegin.Value.ToString(GlobalVar.DTFormat); } shiftProjectData.ProdEndTime = DateTime.Now.ToString(GlobalVar.DTFormat); shiftProjectData.ActualPrepairTime = DateUtil.Convert(this.ProductionData.ShiftProjectData.spl_iPrepairTime - this.ProductionData.ShiftProjectData.spl_iPrepairDinnerTime); //計算出總停機時間 int stopTime = CountProjectStopTime(); shiftProjectData.StopTime = DateUtil.Convert(stopTime); if (this.ProductionData.ShiftProjectData.MachineHaltRecords != null) { shiftProjectData.StopTimes = this.ProductionData.ShiftProjectData.MachineHaltRecords.Count; } //計算出已耗時間 int totalRunTime = 0; if (this.ProductionData.ShiftProjectData.spl_dBeginTime != null) { totalRunTime = (int)(DateTime.Now - this.ProductionData.ShiftProjectData.spl_dBeginTime.Value).TotalSeconds; } shiftProjectData.RunTime = DateUtil.Convert(totalRunTime); shiftProjectData.ProdSumTime = DateUtil.Convert(totalRunTime - stopTime - this.ProductionData.ShiftProjectData.spl_iPrepairTime - this.ProductionData.ShiftProjectData.spl_iPrepairDinnerTime); //品檢數據 int qcTime = 0; int wastQty = 0; int defectiveQty = 0; this.CountProjectQCTime(out qcTime, out wastQty, out defectiveQty); shiftProjectData.QCTime = DateUtil.Convert(qcTime); shiftProjectData.CountWastNum = wastQty; shiftProjectData.CountDefectiveQty = defectiveQty; //統計糾數數量 int correctQty = CountProjectCorrect(); //根據不同工序計算班次內工程的生產數量 this.ProductionData.ShiftProjectData.spl_iCalQTY = this.GetPLCProductionQty(this.ProductionData.ShiftProjectData.spl_iPLCQTY, this.ProductionData.ProjectMProductionData.ppj_iPertimeProdNum); shiftProjectData.ActualProdQty = this.ProductionData.ShiftProjectData.spl_iCalQTY + correctQty; this.ProductionData.ShiftProjectData.ActualProdQty = this.ProductionData.ShiftProjectData.spl_iCalQTY + correctQty; this.ProductionData.ShiftProjectData.spl_iQTY = this.ProductionData.ShiftProjectData.spl_iCalQTY + correctQty; this.OnProductionQtyRealTimeChanged(shiftProjectData.ActualProdQty);//發送事件通知控制中心生產數量已發生變化 shiftProjectData.ProdSpeed = this._currentProductionSpeed; shiftProjectData.QualifiedQty = this.ProductionData.ShiftProjectData.spl_iCalQTY - wastQty - defectiveQty; if (shiftProjectData.QualifiedQty < 0) { shiftProjectData.QualifiedQty = 0; } //工程機台生產數據 if (this.ProductionData.ProjectMProductionData != null) { if (this.ProductionData.ProjectMProductionData.ppj_dProjBeginTime != null) { projectData.ProjectBeginTime = this.ProductionData.ProjectMProductionData.ppj_dProjBeginTime.Value.ToString(GlobalVar.DTFormat); } if (this.ProductionData.ProjectMProductionData.ppj_dProdBeginTime != null) { projectData.ProdBeginTime = this.ProductionData.ProjectMProductionData.ppj_dProdBeginTime.Value.ToString(GlobalVar.DTFormat); } projectData.ActualPrepairTime = DateUtil.Convert(this.ProductionData.ProjectMProductionData.ppj_iActualPrepairTime + this.ProductionData.ShiftProjectData.spl_iPrepairTime); projectData.StopTime = DateUtil.Convert(this.ProductionData.ProjectMProductionData.ppj_iStopTime + stopTime); projectData.QCTime = DateUtil.Convert(this.ProductionData.ProjectMProductionData.ppj_iQCSumTime + qcTime); projectData.RunTime = DateUtil.Convert(this.ProductionData.ProjectMProductionData.ppj_iProjRunTime + totalRunTime); projectData.CountProdNum = this.ProductionData.ProjectMProductionData.ppj_iCountProdNum + this.ProductionData.ShiftProjectData.spl_iCalQTY; projectData.ActualProdNum = this.ProductionData.ProjectMProductionData.ppj_iActualProdNum + shiftProjectData.ActualProdQty; shiftProjectData.GrandTotalProdQty += shiftProjectData.ActualProdQty; projectData.ProdSpeed = this.ProductionData.ProjectMProductionData.ppj_fProdSpeed * 60; projectData.CountDefectiveQty = this.ProductionData.ProjectMProductionData.ppj_iCountDefectiveQty + defectiveQty; projectData.CountWastNum = this.ProductionData.ProjectMProductionData.ppj_iCountWastNum + wastQty; projectData.QualifiedQty = this.ProductionData.ProjectMProductionData.ppj_iQualifiedQty + shiftProjectData.QualifiedQty; shiftProjectData.CountProdQty = projectData.ActualProdNum; } shiftProjectData.RemainQty -= shiftProjectData.GrandTotalProdQty; if (shiftProjectData.RemainQty > 0) { decimal prodSpeed = 0; if (this._currentProductionSpeed > 0) { prodSpeed = this._currentProductionSpeed; } else { prodSpeed = this.ProductionData.ProjectMProductionData.ppj_iSpeed; } if (prodSpeed <= 0) { prodSpeed = 1; } int needSecond = (int)(shiftProjectData.RemainQty / prodSpeed * 60 * 60); shiftProjectData.ToEstimateNeedTime = Common.Util.DateUtil.Convert(needSecond); shiftProjectData.ToEstimateFinishTime = DateTime.Now.AddSeconds(needSecond).ToString(GlobalVar.DTFormat); } else if (shiftProjectData.RemainQty == 0) { shiftProjectData.ToEstimateNeedTime = "已完成"; shiftProjectData.ToEstimateFinishTime = "已完成"; } else { shiftProjectData.ToEstimateNeedTime = "已超出預計產量"; shiftProjectData.ToEstimateFinishTime = "已超出預計產量"; } this.SetProjectStatusInformation(shiftProjectData); this.OnShiftProjectRealTimeData(shiftProjectData); this.OnProjectRealTimeData(projectData); } }