/// <summary> /// 根据layout查询里边个设备的状态灯数据 /// </summary> /// <param name="dsReturn"></param> private void QueryEquipmentData(DataSet dsReturn) { //if (SelectedData == null) return; //DataRow selectedRow = SelectedData; //equLayoutKey = selectedRow[EMS_LAYOUT_MAIN_FIELDS.LAYOUT_KEY].ToString(); //this.txtPicName.Text = selectedRow[EMS_LAYOUT_MAIN_FIELDS.LAYOUT_NAME].ToString(); //this.txtPicName.Tag = equLayoutKey; //string msg; //DataSet dsReturn = EquLayoutEntity.GetEquipmentLayoutDetail(equLayoutKey, out msg); //if (string.IsNullOrEmpty(msg)) //{ if (dsReturn != null && dsReturn.Tables.Count > 0) { SetControlState(true); int layout_width = 1000, layout_height = 500;//默认是500高度 #region 主表信息,则加载布局底图 if (dsReturn.Tables.Contains(EMS_LAYOUT_MAIN_FIELDS.DATABASE_TABLE_NAME)) { //读取图片数据并转换为图片 byte[] imageData = new byte[0]; imageData = (byte[])(dsReturn.Tables[EMS_LAYOUT_MAIN_FIELDS.DATABASE_TABLE_NAME].Rows[0][EMS_LAYOUT_MAIN_FIELDS.LAYOUT_PIC]); Bitmap bitMap = GetBitmap(imageData); if (bitMap != null) { if (LayoutPic.Image != null) { LayoutPic.Image = null; } LayoutPic.Image = (Image)bitMap; LayoutPic.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch; //LayoutPic.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Squeeze; LayoutPic.Controls.Clear(); } } #endregion #region 明细数据,则加载设备布局信息 if (dsReturn.Tables.Contains(EMS_LAYOUT_DETAIL_FIELDS.DATABASE_TABLE_NAME)) { //需修改picCount值 DataTable detailTable = dsReturn.Tables[EMS_LAYOUT_DETAIL_FIELDS.DATABASE_TABLE_NAME]; if (detailTable.Rows.Count > 0) { picCount = detailTable.Rows.Count + 1; this.detailList.Clear(); for (int i = 0; i < detailTable.Rows.Count; i++) { #region detailList 赋值 EquipmentLayoutDetailEntity equDetailEntity = new EquipmentLayoutDetailEntity(); equDetailEntity.LayoutKey = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.LAYOUT_KEY].ToString(); equDetailEntity.PicHeight = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.PIC_HEIGHT].ToString(); equDetailEntity.PicWidth = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.PIC_WIDTH].ToString(); equDetailEntity.PicLeft = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.PIC_LEFT].ToString(); equDetailEntity.PicTop = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.PIC_TOP].ToString(); equDetailEntity.PicType = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.PIC_TYPE].ToString(); equDetailEntity.EquipmentName = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.EQUIPMENT_NAME].ToString(); equDetailEntity.EquipmentKey = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.EQUIPMENT_KEY].ToString(); equDetailEntity.DetailColKey = detailTable.Rows[i][EMS_LAYOUT_DETAIL_FIELDS.DETAIL_COL_KEY].ToString(); equDetailEntity.ChamberIndex = detailTable.Rows[i][EMS_EQUIPMENTS_FIELDS.FIELD_CHAMBER_INDEX].ToString(); equDetailEntity.IsMultiChamber = detailTable.Rows[i][EMS_EQUIPMENTS_FIELDS.FIELD_ISMULTICHAMBER].ToString(); equDetailEntity.ChamberTotal = detailTable.Rows[i][EMS_EQUIPMENTS_FIELDS.FIELD_CHAMBER_TOTAL].ToString(); equDetailEntity.ParentEquKey = detailTable.Rows[i][EMS_EQUIPMENTS_FIELDS.FIELD_PARENT_EQUIPMENT_KEY].ToString(); //取父设备信息,便于建立父设备与子设备的关系表 equDetailEntity.ColorName = detailTable.Rows[i][EMS_EQUIPMENT_STATES_FIELDS.FIELD_EQUIPMENT_STATE_NAME].ToString(); //读取当前设备状态 equDetailEntity.PicName = (i + 1).ToString(); KeyValuePair <string, EquipmentLayoutDetailEntity> keyValuePair = new KeyValuePair <string, EquipmentLayoutDetailEntity>((i + 1).ToString(), equDetailEntity); detailList.Add(keyValuePair); if (equDetailEntity.EquipmentKey != string.Empty) { equipmentList.Add(equDetailEntity.EquipmentKey); if (equDetailEntity.ParentEquKey != string.Empty) { childParentRelationList.Add(new KeyValuePair <string, string>(equDetailEntity.EquipmentKey, equDetailEntity.ParentEquKey)); } } #endregion #region 绘制图片 MemoEdit picBox = new MemoEdit(); //添加设备提示 #region try { if (picBox != null) { if (string.IsNullOrEmpty(StartDate.Text.Trim())) { return; } if (string.IsNullOrEmpty(EndDate.Text.Trim())) { return; } Dictionary <string, string> _dictionary = new Dictionary <string, string>(); _dictionary.Add(EMS_STATE_EVENT_FIELDS.CREATE_TIME, StartDate.Text.Trim() + " 00:00:01"); _dictionary.Add(EMS_STATE_EVENT_FIELDS.EDIT_TIME, EndDate.Text.Trim() + " 23:59:59"); _dictionary.Add(EMS_STATE_EVENT_FIELDS.EQUIPMENT_KEY, equDetailEntity.EquipmentKey); string msg = string.Empty; DataSet dsEquipmentWork = EquLayoutEntity.GetCurrentEquWorkList(_dictionary, out msg); int sum01 = 0, sum02 = 0; //int sum_temp = 0; string sTitle = string.Empty; DataRow dr00 = null; string s156m = "156M", s156p = "156P", s125m = "125M", s156q = "156Q"; DataTable dt00 = dsEquipmentWork.Tables[EMS_EQUIPMENTS_FIELDS.DATABASE_TABLE_NAME]; if (dt00.Rows.Count > 0) { dr00 = dt00.Rows[0]; } DataTable dt01 = dsEquipmentWork.Tables["RUN_LOT"]; DataTable dt02 = dsEquipmentWork.Tables["HOLD_LOT"]; DataTable dt03 = dsEquipmentWork.Tables["WAITING_LOT"]; if (dr00 != null) { sTitle += string.Format("资产编号:{0}", dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_ASSETSNO].ToString()); sTitle += string.Format("\r\n WPH目标值:{0}", dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_WPH].ToString()); sTitle += string.Format("\r\n Av_time:{0}", dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_AV_TIME].ToString()); sTitle += string.Format("\r\n Tract_time:{0}", dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_TRACT_TIME].ToString()); sTitle += string.Format("\r\n 设备编码:{0},描述:{1}", dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_CODE].ToString(), dr00[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_NAME].ToString()); sTitle += string.Format("\r\n 设备状态:{0}", dr00[EMS_EQUIPMENT_STATES_FIELDS.FIELD_DESCRIPTION].ToString()); } sTitle += "\n -----------------------------------------------------"; sTitle += string.Format("\r\n 在制产品信息"); string s01 = string.Empty; string s02 = string.Empty; int t01 = 0, t02 = 0, t03 = 0, t001 = 0, t002 = 0, t003 = 0; foreach (DataRow dr01 in dt01.Rows) { t01 += Convert.ToInt32(dr01["RUN_CELL_NUMBER"].ToString()); t001 += Convert.ToInt32(dr01["RUN_LOC_COUNT"].ToString()); sum01 += t01; sum02 += t001; } foreach (DataRow dr02 in dt02.Rows) { t02 += Convert.ToInt32(dr02["HOLD_CELL_NUMBER"].ToString()); t002 += Convert.ToInt32(dr02["HOLD_LOC_COUNT"].ToString()); sum01 += t02; sum02 += t002; } foreach (DataRow dr03 in dt03.Rows) { t03 += Convert.ToInt32(dr03["WAIT_CELL_NUMBER"].ToString()); t003 += Convert.ToInt32(dr03["WAIT_LOC_COUNT"].ToString()); sum01 += t03; sum02 += t003; } s01 = string.Format("\r\n 批次数:{0}(运行:{1} 暂停:{2} 等待: {3})", sum02.ToString(), t001.ToString(), t002.ToString(), t003.ToString()); s02 = string.Format("\r\n 电池片数:{0}(运行:{1} 暂停:{2} 等待: {3})", sum01.ToString(), t01.ToString(), t02.ToString(), t03.ToString()); sTitle += s01 + s02; sTitle += string.Format("\r\n 产品分布:批次数(电池片数)"); List <string> lst = new List <string>() { s125m, s156m, s156p, s156q }; foreach (string s in lst) { int v_totle_qty = 0, v_sub_qty = 0; DataRow[] drs01 = dt01.Select(string.Format("TYPE='{0}'", s)); DataRow[] drs02 = dt02.Select(string.Format("TYPE='{0}'", s)); DataRow[] drs03 = dt03.Select(string.Format("TYPE='{0}'", s)); foreach (DataRow dr in drs01) { v_totle_qty += Convert.ToInt32(dr["RUN_LOC_COUNT"].ToString()); v_sub_qty += Convert.ToInt32(dr["RUN_CELL_NUMBER"].ToString()); } foreach (DataRow dr in drs02) { v_totle_qty += Convert.ToInt32(dr["HOLD_LOC_COUNT"].ToString()); v_sub_qty += Convert.ToInt32(dr["HOLD_CELL_NUMBER"].ToString()); } foreach (DataRow dr in drs03) { v_totle_qty += Convert.ToInt32(dr["WAIT_LOC_COUNT"].ToString()); v_sub_qty += Convert.ToInt32(dr["WAIT_CELL_NUMBER"].ToString()); } if (v_totle_qty > 0 && v_sub_qty > 0) { sTitle += string.Format("\r\n {0}:{1}({2})", s, v_totle_qty.ToString(), v_sub_qty.ToString()); } } sTitle += "\n -----------------------------------------------------"; if (dr00 != null) { sTitle += string.Format("\r\n 最后操作人员:{0}", dr00["EDITOR"].ToString()); sTitle += string.Format("\r\n 最后操作人员:{0}", dr00["USERNAME"].ToString()); sTitle += string.Format("\r\n 最后操作时间:{0}", dr00["EDIT_TIME"].ToString()); sTitle += string.Format("\r\n 事件名称:{0}", dr00["EQUIPMENT_STATE_NAME"].ToString()); sTitle += string.Format("\r\n 事件备注:{0}", dr00["REMARK"].ToString()); } picBox.ToolTip = sTitle; picBox.ToolTipController.AutoPopDelay = 20000; } } catch //(Exception ex) { } #endregion picBox.Width = Convert.ToInt32(equDetailEntity.PicWidth); picBox.Height = Convert.ToInt32(equDetailEntity.PicHeight); string sText = string.Empty; if (picBox.Width >= picBox.Height) { sText = equDetailEntity.EquipmentName; } if (picBox.Width < picBox.Height) { char[] chars = equDetailEntity.EquipmentName.ToCharArray(); foreach (char c in chars) { sText += " " + c.ToString() + "\r\n"; } } //picBox.Properties.ShowMenu = false; picBox.Name = (i + 1).ToString();//用序列号作为PicBox的名字,便于查找 picBox.Tag = equDetailEntity.EquipmentKey; picBox.Text = equDetailEntity.EquipmentName; picBox.Text = sText; picBox.Font = new Font("Tahoma", 8f); picBox.Properties.ScrollBars = ScrollBars.None; picBox.Properties.ReadOnly = true; picBox.BackColor = new ColorType().GetStateColor(equDetailEntity.ColorName); //picBox.MouseHover += new EventHandler(picBox_MouseHover); picBox.MouseDown += new MouseEventHandler(layoutPicBox_MouseDown); LayoutPic.Controls.Add(picBox); picBox.Top = Convert.ToInt32(equDetailEntity.PicTop); picBox.Left = Convert.ToInt32(equDetailEntity.PicLeft); if ((picBox.Top + picBox.Height) > layout_height) { layout_height = picBox.Top + picBox.Height; } if ((picBox.Width + picBox.Left) > layout_width) { layout_width = picBox.Width + picBox.Left; } #endregion } RefreshEnabled(true); } else { RefreshEnabled(false); } } this.LayoutPic.Width = layout_width + 30; this.LayoutPic.Height = layout_height + 30; #endregion //} } }