示例#1
0
        /// <summary>
        /// 保存機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="listNewSummaries">機台實時生產數據匯總記錄</param>
        /// <returns>保存是否成功</returns>
        public bool SaveMacRealtimeSummaries(MachineRealtimeSummary insRecord)
        {
            bool lRes = false;

            if (insRecord == null)
            {
                return lRes;
            }

            try
            {
                using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                {
                    SqlTransaction transaction = null;
                    conn.Open(); //開啟連接
                    transaction = conn.BeginTransaction(); //開啟事務

                    try
                    {
                        MachineRealtimeSummary existRecord = this.m_objProductionDataSynDAL.GetExistedMachineRealtimeSummary(insRecord.MachineNO);

                        insRecord.StatusChangeTime = DateTime.Now;

                        if (existRecord!=null)
                        {
                            if (existRecord.MachineStatusCode.Trim() == insRecord.MachineStatusCode.Trim())
                            {
                                insRecord.StatusChangeTime = existRecord.StatusChangeTime;
                            }

                            this.m_objProductionDataSynDAL.UpdateMacRealtimeSummary(insRecord, transaction);
                        }
                        else
                        {
                            this.m_objProductionDataSynDAL.AddMacRealtimeSummary(insRecord, transaction);
                        }

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

            return lRes;
        }
示例#2
0
 /// <summary>
 /// 綁定機台的實時生產數據
 /// </summary>
 /// <param name="strMacNo">機台編號</param>
 private void BindMacSummary(string strMacNo)
 {
     MachineRealtimeSummaryBLL macSummaryBL = new MachineRealtimeSummaryBLL();
     MachineRealtimeSummary searchInfo = new MachineRealtimeSummary();
     searchInfo.MachineNO = strMacNo.Trim();
     List<MachineRealtimeSummary> listSummaries = macSummaryBL.GetMacRealtimeSummaries(searchInfo);
     this.dtvMacSummary.DataSource = listSummaries;
     this.dtvMacSummary.DataBind();
 }
示例#3
0
        /// <summary>
        /// 新增機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="insRecord">新增的記錄</param>
        /// <param name="sqlTrans">數據庫事務對象</param>
        /// <returns>是否新增成功</returns>
        public bool AddMacRealtimeSummary(MachineRealtimeSummary insRecord, SqlTransaction sqlTrans)
        {
            if (insRecord == null || sqlTrans == null)
            {
                return false;
            }
            if (string.IsNullOrEmpty(insRecord.MachineNO))
            {
                return false;
            }

            try
            {
                Common.MappingTools.MappingHelper.HandleNullProperty(insRecord);//TODO:需要檢查當時間值為空時,會自動填充什麼默認值

                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("insert into MachineRealtimeSummary_mrs(");
                strSql.AppendLine("mrs_cMachineNO,mrs_cMachineStatusCode,mrs_PPJID,mrs_cSONo,mrs_cItemNo,mrs_cItemName,mrs_cEdition,mrs_iPlanProdQty,");
                strSql.AppendLine("mrs_cProjectNo,mrs_dProjBeginTime,mrs_dProdBeginTime,mrs_iProdActualQty,mrs_dPrepareBeginTime,");
                strSql.AppendLine("mrs_dPrepareEndTime,mrs_cPrepareItemsDesc,mrs_cPrepareCountdown,mrs_iMachineHaltTimes,");
                strSql.AppendLine("mrs_iMachineHaltDuration,mrs_cDutyCaptain,mrs_cMachineStaffsDesc,mrs_dLastDate,");
                strSql.AppendLine("mrs_cSystemVersion,mrs_cMachineIP,mrs_dStatusChangeTime");
                strSql.Append(") values (");
                strSql.Append("@mrs_cMachineNO,@mrs_cMachineStatusCode,@mrs_PPJID,@mrs_cSONo,@mrs_cItemNo,@mrs_cItemName,@mrs_cEdition,@mrs_iPlanProdQty,@mrs_cProjectNo,@mrs_dProjBeginTime,@mrs_dProdBeginTime,@mrs_iProdActualQty,@mrs_dPrepareBeginTime,@mrs_dPrepareEndTime,@mrs_cPrepareItemsDesc,@mrs_cPrepareCountdown,@mrs_iMachineHaltTimes,@mrs_iMachineHaltDuration,@mrs_cDutyCaptain,@mrs_cMachineStaffsDesc,GETDATE(),@mrs_cSystemVersion,@mrs_cMachineIP,@mrs_dStatusChangeTime)");

                SqlParameter[] parameters = GetMacSummarySqlParams(insRecord);

                int iRes = DbHelperSQL.ExecuteNonQuery(sqlTrans, CommandType.Text, strSql.ToString(), parameters);
                if (iRes > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex) { throw ex; }
        }
示例#4
0
 /// <summary>
 /// 獲取SQL參數列表
 /// </summary>
 /// <param name="record">機台實時生產數據匯總記錄</param>
 /// <returns>SQL參數列表</returns>
 private SqlParameter[] GetMacSummarySqlParams(MachineRealtimeSummary record)
 {
     if (record == null)
     {
         return null;
     }
     SqlParameter[] parameters = {
             DbHelperSQL.MakeInParam("@mrs_cMachineNO", SqlDbType.NVarChar,80, record.MachineNO),
             DbHelperSQL.MakeInParam("@mrs_cProjectNo", SqlDbType.NVarChar,200, record.ProjectNo),
             DbHelperSQL.MakeInParam("@mrs_cMachineStatusCode", SqlDbType.VarChar,50, record.MachineStatusCode),
             DbHelperSQL.MakeInParam("@mrs_PPJID", SqlDbType.UniqueIdentifier,16, record.PPJID),
             DbHelperSQL.MakeInParam("@mrs_cSONo", SqlDbType.NVarChar,1020, record.SONo),
             DbHelperSQL.MakeInParam("@mrs_cItemNo", SqlDbType.NVarChar,200, record.ItemNo),
             DbHelperSQL.MakeInParam("@mrs_cItemName", SqlDbType.NVarChar,1040, record.ItemName),
             DbHelperSQL.MakeInParam("@mrs_cEdition", SqlDbType.NVarChar,200, record.Edition),
             DbHelperSQL.MakeInParam("@mrs_iPlanProdQty", SqlDbType.Int,4, record.PlanProdQty),
             DbHelperSQL.MakeInParam("@mrs_dProjBeginTime", SqlDbType.DateTime,8,record.ProjBeginTime),
             DbHelperSQL.MakeInParam("@mrs_dProdBeginTime", SqlDbType.DateTime,8,record.ProdBeginTime),
             DbHelperSQL.MakeInParam("@mrs_iProdActualQty", SqlDbType.Int, 4, record.ProdActualQty),
             DbHelperSQL.MakeInParam("@mrs_dPrepareBeginTime", SqlDbType.DateTime,8,record.PrepareBeginTime),
             DbHelperSQL.MakeInParam("@mrs_dPrepareEndTime", SqlDbType.DateTime,8,record.PrepareEndTime),
             DbHelperSQL.MakeInParam("@mrs_cPrepareItemsDesc", SqlDbType.NVarChar, 1000, record.PrepareItemsDesc),
             DbHelperSQL.MakeInParam("@mrs_cPrepareCountdown", SqlDbType.NVarChar,400, record.PrepareCountdown),
             DbHelperSQL.MakeInParam("@mrs_iMachineHaltTimes", SqlDbType.Int,4, record.MachineHaltTimes),
             DbHelperSQL.MakeInParam("@mrs_iMachineHaltDuration", SqlDbType.Int,4, record.MachineHaltDuration),
             DbHelperSQL.MakeInParam("@mrs_cDutyCaptain", SqlDbType.NVarChar,160, record.DutyCaptain),
             DbHelperSQL.MakeInParam("@mrs_cMachineStaffsDesc", SqlDbType.NVarChar,1000, record.MachineStaffsDesc),
             DbHelperSQL.MakeInParam("@mrs_cSystemVersion", SqlDbType.NVarChar,50, record.SystemVersion),
             DbHelperSQL.MakeInParam("@mrs_cMachineIP", SqlDbType.VarChar,50, record.MachineIP),
             DbHelperSQL.MakeInParam("@mrs_dStatusChangeTime", SqlDbType.SmallDateTime,4,record.StatusChangeTime)};
     return parameters;
 }
示例#5
0
        /// <summary>
        /// 更新機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="udRecord">更新的記錄</param>
        /// <param name="sqlTrans">數據庫事務對象</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateMacRealtimeSummary(MachineRealtimeSummary udRecord, SqlTransaction sqlTrans)
        {
            if (udRecord == null || sqlTrans == null)
            {
                return false;
            }
            if (string.IsNullOrEmpty(udRecord.MachineNO))
            {
                return false;
            }

            try
            {
                Common.MappingTools.MappingHelper.HandleNullProperty(udRecord);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update MachineRealtimeSummary_mrs set ");
                strSql.Append("mrs_cProjectNo=@mrs_cProjectNo,");
                strSql.Append("mrs_cMachineStatusCode=@mrs_cMachineStatusCode,");
                strSql.Append("mrs_PPJID=@mrs_PPJID,");
                strSql.Append("mrs_cSONo=@mrs_cSONo,");
                strSql.Append("mrs_cItemNo=@mrs_cItemNo,");
                strSql.Append("mrs_cItemName=@mrs_cItemName,");
                strSql.Append("mrs_cEdition=@mrs_cEdition,");
                strSql.Append("mrs_iPlanProdQty=@mrs_iPlanProdQty,");
                strSql.Append("mrs_dProjBeginTime=@mrs_dProjBeginTime,");
                strSql.Append("mrs_dProdBeginTime=@mrs_dProdBeginTime,");
                strSql.Append("mrs_iProdActualQty=@mrs_iProdActualQty,");
                strSql.Append("mrs_dPrepareBeginTime=@mrs_dPrepareBeginTime,");
                strSql.Append("mrs_dPrepareEndTime=@mrs_dPrepareEndTime,");
                strSql.Append("mrs_cPrepareItemsDesc=@mrs_cPrepareItemsDesc,");
                strSql.Append("mrs_cPrepareCountdown=@mrs_cPrepareCountdown,");
                strSql.Append("mrs_iMachineHaltTimes=@mrs_iMachineHaltTimes,");
                strSql.Append("mrs_iMachineHaltDuration=@mrs_iMachineHaltDuration,");
                strSql.Append("mrs_cDutyCaptain=@mrs_cDutyCaptain,");
                strSql.Append("mrs_cMachineStaffsDesc=@mrs_cMachineStaffsDesc,");
                strSql.Append("mrs_dLastDate=GETDATE(),");
                strSql.Append("mrs_cSystemVersion=@mrs_cSystemVersion,");
                strSql.Append("mrs_cMachineIP=@mrs_cMachineIP,");
                strSql.Append("mrs_dStatusChangeTime=@mrs_dStatusChangeTime");
                strSql.Append(" where mrs_cMachineNO=@mrs_cMachineNO");

                SqlParameter[] parameters = GetMacSummarySqlParams(udRecord);

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

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
示例#6
0
        /// <summary>
        /// 獲取已存在的機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="MachineNo">機台編號</param>
        /// <returns></returns>
        public MachineRealtimeSummary GetExistedMachineRealtimeSummary(string MachineNo)
        {
            MachineRealtimeSummary realtimeSummary = null;

            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("SELECT mrs_cMachineNO,mrs_cMachineStatusCode,mrs_dStatusChangeTime FROM MachineRealtimeSummary_mrs with(nolock) where mrs_cMachineNO = '" + MachineNo.Trim() + "'");

                using (IDataReader dataReader = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (dataReader.Read())
                    {
                        realtimeSummary = new MachineRealtimeSummary();

                        if (dataReader["mrs_cMachineNO"] != null)
                        {
                            realtimeSummary.MachineNO = dataReader["mrs_cMachineNO"].ToString().Trim();
                        }

                        if (dataReader["mrs_cMachineStatusCode"] != null)
                        {
                            realtimeSummary.MachineStatusCode = dataReader["mrs_cMachineStatusCode"].ToString().Trim();
                        }

                        if (dataReader["mrs_dStatusChangeTime"] != null && dataReader["mrs_dStatusChangeTime"].ToString().Trim() != "")
                        {
                            realtimeSummary.StatusChangeTime = DateTime.Parse(dataReader["mrs_dStatusChangeTime"].ToString());
                        }
                    }
                }
            }
            catch (Exception exTran)
            {
                throw exTran;
            }

            return realtimeSummary;
        }
 /// <summary>
 ///  獲取指定條件的機台實時生產數據匯總記錄
 /// </summary>
 /// <param name="searchInfo">篩選條件,傳入NULL值時,返回NULL結果</param>
 /// <returns>機台實時生產數據匯總記錄</returns>
 public List<MachineRealtimeSummary> GetMacRealtimeSummaries(MachineRealtimeSummary searchInfo)
 {
     try
     {
         return this.m_MacSummaryDA.GetMacRealtimeSummaries(searchInfo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 獲取指定條件的機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="strSql">SQL查詢語句</param>
        /// <param name="strConn">數據庫連接字符串</param>
        /// <returns></returns>
        private List<MachineRealtimeSummary> GetSummaries(string strSql, string strConn)
        {
            if (string.IsNullOrEmpty(strSql) || string.IsNullOrEmpty(strConn))
            {
                return null;
            }

            List<MachineRealtimeSummary> listSummary = new List<MachineRealtimeSummary>();

            string strDBType = GetDBType(strConn);

            try
            {
                using (SqlDataReader reader = DbHelperSQL.ExecuteReader(strConn, strSql))
                {
                    while (reader.Read())
                    {
                        MachineRealtimeSummary model = new MachineRealtimeSummary();
                        model.DBType = strDBType;

                        #region 逐個屬性賦值

                        if (reader["mrs_cMachineNO"] != null && reader["mrs_cMachineNO"].ToString() != string.Empty)
                        {
                            model.MachineNO = reader["mrs_cMachineNO"].ToString();
                        }
                        if (reader["MachineName"] != null && reader["MachineName"].ToString() != string.Empty)
                        {
                            model.MachineName = reader["MachineName"].ToString();
                        }
                        if (reader["MachineTypeCode"] != null && reader["MachineTypeCode"].ToString() != string.Empty)
                        {
                            model.MachineTypeCode = reader["MachineTypeCode"].ToString();
                        }
                        if (reader["MachineType"] != null && reader["MachineType"].ToString() != string.Empty)
                        {
                            model.MachineType = reader["MachineType"].ToString();
                        }
                        if (reader["MachineStatus"] != null && reader["MachineStatus"].ToString() != string.Empty)
                        {
                            model.MachineStatus = reader["MachineStatus"].ToString();
                        }
                        if (reader["mrs_cMachineStatusCode"] != null && reader["mrs_cMachineStatusCode"].ToString() != string.Empty)
                        {
                            model.MachineStatusCode = reader["mrs_cMachineStatusCode"].ToString();
                        }
                        if (reader["mrs_PPJID"] != null && reader["mrs_PPJID"].ToString() != string.Empty)
                        {
                            model.PPJID = new Guid(reader["mrs_PPJID"].ToString());
                        }
                        if (reader["mrs_cSONo"] != null && reader["mrs_cSONo"].ToString() != string.Empty)
                        {
                            model.SONo = reader["mrs_cSONo"].ToString();
                        }
                        if (reader["mrs_cItemNo"] != null && reader["mrs_cItemNo"].ToString() != string.Empty)
                        {
                            model.ItemNo = reader["mrs_cItemNo"].ToString();
                        }
                        if (reader["mrs_cItemName"] != null && reader["mrs_cItemName"].ToString() != string.Empty)
                        {
                            model.ItemName = reader["mrs_cItemName"].ToString();
                        }
                        if (reader["ProdName"] != null && reader["ProdName"].ToString() != string.Empty)
                        {
                            model.ProdName = reader["ProdName"].ToString();
                        }
                        if (reader["mrs_cEdition"] != null && reader["mrs_cEdition"].ToString() != string.Empty)
                        {
                            model.Edition = reader["mrs_cEdition"].ToString();
                        }
                        if (reader["mrs_iPlanProdQty"] != null && reader["mrs_iPlanProdQty"].ToString() != string.Empty)
                        {
                            model.PlanProdQty = int.Parse(reader["mrs_iPlanProdQty"].ToString());
                        }
                        if (reader["mrs_cNextGroup"] != null && reader["mrs_cNextGroup"].ToString() != string.Empty)
                        {
                            model.NextGroup = reader["mrs_cNextGroup"].ToString();
                        }
                        if (reader["mrs_dProjBeginTime"] != null && reader["mrs_dProjBeginTime"].ToString() != string.Empty)
                        {
                            model.ProjBeginTime = DateTime.Parse(reader["mrs_dProjBeginTime"].ToString());
                            model.ProjBeginTimeDesc = model.ProjBeginTime.Value.ToString(DateTimeDispalyFormat).Replace('-', '/');
                        }
                        if (reader["mrs_dProdBeginTime"] != null && reader["mrs_dProdBeginTime"].ToString() != string.Empty)
                        {
                            model.ProdBeginTime = DateTime.Parse(reader["mrs_dProdBeginTime"].ToString());
                            model.ProdBeginTimeDesc = model.ProdBeginTime.Value.ToString(DateTimeDispalyFormat).Replace('-', '/');
                        }
                        if (reader["mrs_iProdActualQty"] != null && reader["mrs_iProdActualQty"].ToString() != string.Empty)
                        {
                            model.ProdActualQty = int.Parse(reader["mrs_iProdActualQty"].ToString());
                        }
                        if (reader["mrs_dPrepareBeginTime"] != null && reader["mrs_dPrepareBeginTime"].ToString() != string.Empty)
                        {
                            model.PrepareBeginTime = DateTime.Parse(reader["mrs_dPrepareBeginTime"].ToString());
                            model.PrepareBeginTimeDesc = model.PrepareBeginTime.Value.ToString(DateTimeDispalyFormat).Replace('-', '/');
                        }
                        if (reader["mrs_dPrepareEndTime"] != null && reader["mrs_dPrepareEndTime"].ToString() != string.Empty)
                        {
                            model.PrepareEndTime = DateTime.Parse(reader["mrs_dPrepareEndTime"].ToString());
                            model.PrepareEndTimeDesc = model.PrepareEndTime.Value.ToString(DateTimeDispalyFormat).Replace('-', '/');
                        }
                        if (reader["mrs_cPrepareItemsDesc"] != null && reader["mrs_cPrepareItemsDesc"].ToString() != string.Empty)
                        {
                            model.PrepareItemsDesc = reader["mrs_cPrepareItemsDesc"].ToString();
                        }
                        if (reader["mrs_cPrepareCountdown"] != null && reader["mrs_cPrepareCountdown"].ToString() != string.Empty)
                        {
                            model.PrepareCountdown = reader["mrs_cPrepareCountdown"].ToString();
                        }
                        if (reader["mrs_iMachineHaltTimes"] != null && reader["mrs_iMachineHaltTimes"].ToString() != string.Empty)
                        {
                            model.MachineHaltTimes = int.Parse(reader["mrs_iMachineHaltTimes"].ToString());
                        }
                        if (reader["mrs_iMachineHaltDuration"] != null && reader["mrs_iMachineHaltDuration"].ToString() != string.Empty)
                        {
                            model.MachineHaltDuration = int.Parse(reader["mrs_iMachineHaltDuration"].ToString());
                        }
                        if (reader["mrs_cDutyCaptain"] != null && reader["mrs_cDutyCaptain"].ToString() != string.Empty)
                        {
                            model.DutyCaptain = reader["mrs_cDutyCaptain"].ToString();
                        }
                        if (reader["mrs_cMachineStaffsDesc"] != null && reader["mrs_cMachineStaffsDesc"].ToString() != string.Empty)
                        {
                            model.MachineStaffsDesc = reader["mrs_cMachineStaffsDesc"].ToString();
                        }
                        if (reader["mrs_dLastDate"] != null && reader["mrs_dLastDate"].ToString() != string.Empty)
                        {
                            model.LastDate = DateTime.Parse(reader["mrs_dLastDate"].ToString());
                        }
                        if (reader["AreaCode"] != null && reader["AreaCode"].ToString() != string.Empty)
                        {
                            model.AreaCode = reader["AreaCode"].ToString();
                        }
                        if (reader["AreaName"] != null && reader["AreaName"].ToString() != string.Empty)
                        {
                            model.AreaName = reader["AreaName"].ToString();
                        }
                        if (reader["PublicInstitution"] != null && reader["PublicInstitution"].ToString() != string.Empty)
                        {
                            model.PublicInstitution = reader["PublicInstitution"].ToString();
                        }
                        if (reader["mrs_dStatusChangeTime"] != null && reader["mrs_dStatusChangeTime"].ToString() != string.Empty)
                        {
                            model.StatusChangeTime = DateTime.Parse(reader["mrs_dStatusChangeTime"].ToString());
                        }

                        #endregion

                        listSummary.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return listSummary;
        }
        /// <summary>
        /// 獲取指定條件的機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="searchInfo">篩選條件,傳入NULL值時,為返回全部有效的記錄</param>
        /// <returns>機台實時生產數據匯總記錄</returns>
        private List<MachineRealtimeSummary> GetSummaries(MachineRealtimeSummary searchInfo)
        {
            try
            {
                StringBuilder strSQL = GetSummariesBaseSQL();

                if (searchInfo != null)
                {
                    #region 篩選條件

                    if (!string.IsNullOrEmpty(searchInfo.MachineType))
                    {
                        strSQL.AppendLine("AND CMTType.cmt_cRemark=N'" + searchInfo.MachineType.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.MachineTypeCode))
                    {
                        strSQL.AppendLine("AND mmt_cMachineType='" + searchInfo.MachineTypeCode.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.MachineNO))
                    {
                        strSQL.AppendLine("AND mrs_cMachineNO='" + searchInfo.MachineNO.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.MachineStatusCode))
                    {
                        strSQL.AppendLine("AND mrs_cMachineStatusCode='" + searchInfo.MachineStatusCode.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.AreaCode))
                    {
                        strSQL.AppendLine("AND amr_cAreaCode='" + searchInfo.AreaCode.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.PublicInstitution))
                    {
                        strSQL.AppendLine("AND amr_cPublicInstitution='" + searchInfo.PublicInstitution.Trim() + "'");
                    }
                    if (searchInfo.PPJID != null && searchInfo.PPJID != Guid.Empty)
                    {
                        strSQL.AppendLine("AND mrs_PPJID='" + searchInfo.PPJID.ToString() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.SONo))
                    {
                        strSQL.AppendLine("AND mrs_cSONo = '" + searchInfo.SONo.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.ItemNo))
                    {
                        strSQL.AppendLine("AND mrs_cItemNo = '" + searchInfo.ItemNo.Trim() + "'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.ItemName))
                    {
                        strSQL.AppendLine("AND mrs_cItemName LIKE N'" + searchInfo.ItemName.Trim() + "%'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.Edition))
                    {
                        strSQL.AppendLine("AND mrs_cEdition LIKE N'" + searchInfo.Edition.Trim() + "%'");
                    }
                    if (!string.IsNullOrEmpty(searchInfo.NextGroup))
                    {
                        strSQL.AppendLine("AND mrs_cNextGroup LIKE N'" + searchInfo.NextGroup.Trim() + "%'");
                    }

                    #endregion
                }

                List<MachineRealtimeSummary> listSummary = new List<MachineRealtimeSummary>();
                List<MachineRealtimeSummary> listPatial = GetSummaries(strSQL.ToString(), this.m_strConn_LAMIMSN);
                if (listPatial != null && listPatial.Count > 0)
                {
                    listSummary.AddRange(listPatial);
                }
                listPatial = GetSummaries(strSQL.ToString(), this.m_strConn_HOTIMSN);
                if (listPatial != null && listPatial.Count > 0)
                {
                    listSummary.AddRange(listPatial);
                }
                listPatial = GetSummaries(strSQL.ToString(), this.m_strConn_SILKIMSN);
                if (listPatial != null && listPatial.Count > 0)
                {
                    listSummary.AddRange(listPatial);
                }

                return listSummary;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        ///  獲取指定條件的機台實時生產數據匯總記錄
        /// </summary>
        /// <param name="searchInfo">篩選條件,傳入NULL值時,返回NULL結果</param>
        /// <returns>機台實時生產數據匯總記錄</returns>
        public List<MachineRealtimeSummary> GetMacRealtimeSummaries(MachineRealtimeSummary searchInfo)
        {
            if (searchInfo == null)
            {
                return null;
            }

            return GetSummaries(searchInfo);
        }
        /// <summary>
        /// 實時上傳機台生產數據
        /// </summary>
        void UploadMachineRealtimeProductionData()
        {
            if (this.MachineShiftDataInformation == null || this.MachineShiftDataInformation.sifo_cMachineNO.Trim()=="")
            {
                return;
            }

            if (this.MachineRuningDataInformation == null)
            {
                return;
            }

            MachineRealtimeSummary prodcutionData = new MachineRealtimeSummary();

            prodcutionData.MachineNO = this.MachineShiftDataInformation.sifo_cMachineNO;
            prodcutionData.MachineIP = this.MachineRuningDataInformation.MachineIP;
            prodcutionData.MachineStatusCode = this.MachineRuningDataInformation.MachineStatusNo;
            prodcutionData.SystemVersion = this.MachineRuningDataInformation.SystemVersion;
            prodcutionData.DutyCaptain = this.MachineShiftDataInformation.DutyCaptain;
            prodcutionData.MachineStaffsDesc = this.GetMachineStaffs(this.MachineShiftDataInformation.StaffInfos);

            if (this.ProjectProductionDataInformation != null)
            {
                this.SetProductionDataByProject(this.ProjectProductionDataInformation, prodcutionData);
            }

            try
            {
                this.m_objSynDataBLL.SaveMacRealtimeSummaries(prodcutionData);
            }
            catch (Exception ex)
            {
                this.OnException("ProductionDataSynchronismManager", "UploadMachineRealtimeProductionData", ex.Message);
            }
        }
        /// <summary>
        /// 設置工程信息
        /// </summary>
        /// <param name="projectData"></param>
        /// <param name="prodcutionData"></param>
        /// <returns></returns>
        MachineRealtimeSummary SetProductionDataByProject(ProjectProductionData projectData, MachineRealtimeSummary prodcutionData)
        {
            if (projectData == null)
            {
                return null;
            }

            prodcutionData.PPJID = projectData.ProjectMachineProductionID;

            prodcutionData.ProjectNo = projectData.ProjectBaseData.swl_cProjectNO;
            prodcutionData.SONo = projectData.ProjectBaseData.swl_cSONO;
            prodcutionData.ItemNo = projectData.ProjectBaseData.swl_cItemNO;
            prodcutionData.ItemName = projectData.ProjectBaseData.swl_cItemName;
            prodcutionData.Edition = projectData.ProjectBaseData.swl_cEdition;
            prodcutionData.PlanProdQty = projectData.ProjectBaseData.swl_iPlanProdQty;
            prodcutionData.ProjBeginTime = projectData.ProjectMProductionData.ppj_dProjBeginTime;
            prodcutionData.ProdBeginTime = projectData.ProjectMProductionData.ppj_dProdBeginTime;
            prodcutionData.ProdActualQty = projectData.ProjectMProductionData.ppj_iActualProdNum + projectData.ShiftProjectData.ActualProdQty;
            prodcutionData.PrepareBeginTime = projectData.ProjectMProductionData.ppj_dProjBeginTime;
            prodcutionData.PrepareEndTime = projectData.ProjectMProductionData.ppj_dProdBeginTime;

            string prepareItems = string.Empty;
            if (projectData.PrepareJobItems != null && projectData.PrepareJobItems.Count > 0)
            {
                for (int i = 0; i < projectData.PrepareJobItems.Count; i++)
                {
                    ProjectPrepareJobItem prepareItem=projectData.PrepareJobItems[i];
                    if (prepareItem != null)
                    {
                        if (prepareItems.Trim().Length > 0)
                        {
                            prepareItems += ",";
                        }
                        prepareItems += prepareItem.ItemName.Trim();
                    }
                }
            }
            prodcutionData.PrepareItemsDesc = prepareItems;

            prodcutionData.PrepareCountdown = projectData.ShiftProjectData.PrepareCountdown;

            //停機次數
            int machineHaltTimes = projectData.ProjectMProductionData.ppj_iStopTimes;
            if (projectData.ShiftProjectData.MachineHaltRecords != null)
            {
                machineHaltTimes += projectData.ShiftProjectData.MachineHaltRecords.Count;
            }

            prodcutionData.MachineHaltTimes = machineHaltTimes;

            //停機時間
            int machineHaltTime = projectData.ProjectMProductionData.ppj_iStopTime;
            machineHaltTime += this.CountProjectStopTime(projectData.ShiftProjectData.MachineHaltRecords);
            prodcutionData.MachineHaltDuration = machineHaltTime;

            return prodcutionData;
        }
示例#13
0
        /// <summary>
        /// 獲取指定的實時生產數據的HTML內容
        /// </summary>
        /// <param name="MacSummary">機台實時生產數據記錄</param>
        /// <param name="viewMode">顯示模式</param>
        /// <param name="iTableWidth">信息表格寬度</param>
        /// <param name="iTableHeight">信息表格高度</param>
        /// <returns></returns>
        private string GetSummaryViewHtmlStr(MachineRealtimeSummary MacSummary, EnmViewMode viewMode, out int iTableWidth, out int iTableHeight)
        {
            iTableWidth = 0;
            iTableHeight = 0;

            if (MacSummary == null)
            {
                return string.Empty;
            }
            if (string.IsNullOrEmpty(MacSummary.MachineNO))
            {
                return string.Empty;
            }

            string strMacStatus = MacSummary.MachineStatus;//機台狀態
            string strMacNo = MacSummary.MachineNO.Trim();//機台編號
            string strMacName = MacSummary.MachineName;//機台名稱
            string strCssType = GetSummaryViewCss(MacSummary.MachineStatusCode);//樣式名稱
            string strItemName = "無任務";//生產內容
            string strBeginTime = string.Empty;//工程開始時間
            string strBeginTimeSpan = string.Empty;//工程開始持續時間
            string strLastTimeSpan = string.Empty;//當前狀態持續時間

            int iSubFormWidth = 0;
            int iSubFormHeight = 0;

            if (!string.IsNullOrEmpty(MacSummary.ItemName))
            {
                strItemName = MacSummary.ItemName.Trim();
            }

            if (MacSummary.ProjBeginTime != null)
            {
                strBeginTime = MacSummary.ProjBeginTimeDesc;
                strBeginTimeSpan = Common.Util.DateUtil.Convert((DateTime.Now - MacSummary.ProjBeginTime.Value).TotalSeconds);
            }
            else
            {
                strBeginTimeSpan = "未知";
            }

            if (MacSummary.StatusChangeTime != null)
            {
                strLastTimeSpan = Common.Util.DateUtil.Convert((DateTime.Now - MacSummary.StatusChangeTime.Value).TotalSeconds);
            }
            else
            {
                strLastTimeSpan = "未知";
            }

            string strTbHTML = string.Empty;
            strTbHTML = "<table class='tbMainProfile'  ' cellpadding='0' cellspacing='0' ";

            if (viewMode == EnmViewMode.SmallView)
            {
                iSubFormWidth = 600;
                iSubFormHeight = 480;

                iTableWidth = DataConverter.GetSmallViewTableWidth();
                iTableHeight = DataConverter.GetSmallViewTableHeight();

                string strJS = GetJSScript_OpenPage(strMacName, "MacInfoDetail.aspx?MacNo=" + strMacNo, iSubFormWidth, iSubFormHeight);

                strTbHTML += " width='" + iTableWidth.ToString() + "px' >";
                strTbHTML += "<tr><td align='center' class='tdMacNo' onclick='" + strJS + "'>" + strMacNo + "</td></tr>";
                strTbHTML += "<tr><td align='center'>";
                strTbHTML += "<table cellpadding='0' cellspacing='0' class='" + strCssType + "' ";
                strTbHTML += " height='" + iTableHeight.ToString() + "px'";
                strTbHTML += " style='font-size: 14.25px;color:blue;'' width='100%'>";
                strTbHTML += "<tr align='center'><td>" + strMacStatus + "</td></tr>";
                strTbHTML += "<tr align='center'><td>" + strLastTimeSpan + "</td></tr>";
                strTbHTML += "</table></td></tr>";
            }
            else if (viewMode == EnmViewMode.LargeView)
            {
                iSubFormWidth = 600;
                iSubFormHeight = 620;

                iTableWidth = DataConverter.GetLargeViewTableWidth();
                iTableHeight = DataConverter.GetLargeViewTableHeight();

                string strJS = GetJSScript_OpenPage(strMacName, "MacSummaryView.aspx?MacNo=" + strMacNo, iSubFormWidth, iSubFormHeight);

                strTbHTML += " width='" + iTableWidth.ToString() + "px' >";
                strTbHTML += "<tr align='center'><td class='tdMacNo' onclick='" + strJS + "'>" + MacSummary.MachineName.Trim() + "(" + strMacNo + ")</td></tr>";
                strTbHTML += "<tr align='center'><td><table cellpadding='0' cellspacing='0' class='" + strCssType + "' ";
                strTbHTML += " height='" + iTableHeight.ToString() + "px'";
                strTbHTML += " style='font-size: 14.25px;color:blue;'' width='100%'>";
                strTbHTML += "<tr><td align='right' style='width:25%;'>工程開始&nbsp;&nbsp;</td><td align='left'>" + strBeginTime + "</td></tr>";
                strTbHTML += "<tr><td align='right'>工程單編號&nbsp;&nbsp;</td><td align='left'>" + MacSummary.SONo + "</td></tr>";
                strTbHTML += "<tr><td align='right'>印張編號&nbsp;&nbsp;</td><td align='left'>" + MacSummary.ItemNo + "</td></tr>";
                strTbHTML += "<tr><td align='right'>生產數量&nbsp;&nbsp;</td><td align='left'>" + MacSummary.ProdActualQty.ToString() + "/" + MacSummary.PlanProdQty.ToString() + "</td></tr>";//現時數量/要求生產數量
                strTbHTML += "<tr><td align='right'>狀態時間&nbsp;&nbsp;</td><td align='left'>" + strMacStatus + "/" + strBeginTimeSpan + "</td></tr>";//現時狀態/該狀態從工程開始至目前為止累計的分鐘數
                strTbHTML += "<tr><td align='right'>產品名稱&nbsp;&nbsp;</td><td align='left'>" + MacSummary.ProdName + "</td></tr>";
                strTbHTML += "<tr><td align='right'>產品內容&nbsp;&nbsp;</td><td align='left'>" + strItemName + "</td></tr>";
                strTbHTML += "<tr><td align='right'>持續時間&nbsp;&nbsp;</td><td align='left'>" + strLastTimeSpan + "</td></tr>";//例如停機發生多次,只顯示今次發生的狀態到今刻的時間
                strTbHTML += "</table></td></tr>";
            }
            strTbHTML += "</table>";

            return strTbHTML;
        }