/// <summary> /// 获取所有货位信息 /// </summary> /// <param name="gsList">所有货位集合</param> /// <returns></returns> public bool GetAllGsModel(ref Dictionary <string, GSMemTempModel> gsTempDic, ref string reStr) { gsTempDic = new Dictionary <string, GSMemTempModel>(); List <View_GoodsSiteModel> allGses = bllViewGoodsSite.GetModelList(""); if (allGses == null) { reStr = "库存货位为空!"; return(false); } for (int i = 0; i < allGses.Count; i++) { GSMemTempModel gsModel = new GSMemTempModel(); gsModel.StoreHouseName = allGses[i].StoreHouseName; gsModel.StoreAreaName = allGses[i].StoreHouseAreaName; gsModel.GSEnabled = allGses[i].GsEnabled; gsModel.GSOperate = allGses[i].GoodsSiteOperate; gsModel.GSPos = allGses[i].GoodsSitePos; gsModel.GSStatus = allGses[i].GoodsSiteStatus; gsModel.GSTaskStatus = allGses[i].GoodsSiteTaskStatus; gsModel.ExtProp1 = allGses[i].GoodsSite_Reserve; string keyStr = allGses[i].StoreHouseName + ":" + allGses[i].GoodsSitePos; gsTempDic[keyStr] = gsModel; } List <View_StockModel> stockList = bllViewStock.GetModelList(""); if (stockList == null)//所有货位没有库存的情况直接返回true { reStr = "查询完毕,此时库房没有库存!"; return(true); } for (int i = 0; i < stockList.Count; i++) { string keyStr = stockList[i].StoreHouseName + ":" + stockList[i].GoodsSitePos; gsTempDic[keyStr].InHouseDate = stockList[i].InHouseTime; } reStr = "查询完毕!"; return(true); }
private void AsynQueryAsrsCells() { if (this.dataGridView1.InvokeRequired) { DlgtQueryCells dlgt = new DlgtQueryCells(AsynQueryAsrsCells); this.Invoke(dlgt, null); } else { try { CtlDBAccess.BLL.ControlTaskBll ctlTaskBll = new CtlDBAccess.BLL.ControlTaskBll(); string logicArea = "OCV常温区"; string batCata = this.cbxBatteryCata.Text; DateTime stTime = this.dateTimePicker1.Value; DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("库房"), new DataColumn("库位"), new DataColumn("出库任务ID"), new DataColumn("库位锁定状态"), new DataColumn("托盘码"), new DataColumn("入库时间"), new DataColumn("在库时间(小时)"), new DataColumn("任务优先级") }); string reStr = ""; //查询库位 string houseName = this.comboBox1.Text; string cellTaskStat = this.comboBox3.Text; Dictionary <string, GSMemTempModel> asrsStatDic = new Dictionary <string, GSMemTempModel>(); if (!this.asrsResMana.GetAllGsModel(ref asrsStatDic, ref reStr)) { Console.WriteLine(string.Format("{0} 获取货位状态失败", houseName)); return; } foreach (string strKey in asrsStatDic.Keys) { GSMemTempModel gs = asrsStatDic[strKey]; if (gs.GSTaskStatus != cellTaskStat && cellTaskStat != "所有") { continue; } if (gs.GSStatus != AsrsModel.EnumCellStatus.满位.ToString()) { continue; } if (gs.InHouseDate == null) { continue; } if (gs.InHouseDate > stTime) { continue; } if (gs.StoreAreaName != logicArea) { continue; } AsrsModel.CellCoordModel cell = new CellCoordModel(0, 0, 0); if (!cell.Parse(gs.GSPos)) { continue; } List <string> storePallets = new List <string>(); if (!this.asrsResMana.GetStockDetail(houseName, cell, ref storePallets)) { continue; } if (storePallets.Count() < 1 || storePallets[0].Length < 4) { continue; } if (batCata != "所有" && (storePallets[0].Substring(0, 4).ToUpper() != batCata.ToUpper())) { continue; } string palletIDS = ""; for (int i = 0; i < storePallets.Count(); i++) { if (i != storePallets.Count() - 1) { palletIDS = palletIDS + storePallets[i] + ","; } else { palletIDS = palletIDS + storePallets[i]; } } DataRow dr = dt.Rows.Add(); dr["库房"] = houseName; dr["库位"] = gs.GSPos; string strWhere = string.Format(" TaskType={0} and (TaskStatus = '待执行' or TaskStatus='执行中') and tag1='{1}' and tag2='{2}'", (int)SysCfg.EnumAsrsTaskType.产品出库, houseName, gs.GSPos); List <CtlDBAccess.Model.ControlTaskModel> runningTasks = ctlTaskBll.GetModelList(strWhere); if (runningTasks != null && runningTasks.Count > 0) { dr["出库任务ID"] = runningTasks[0].TaskID; dr["任务优先级"] = runningTasks[0].tag4; } dr["库位锁定状态"] = gs.GSTaskStatus; dr["托盘码"] = palletIDS; dr["入库时间"] = ((DateTime)gs.InHouseDate).ToString("yyyy-MM-dd HH:mm:ss"); TimeSpan ts = System.DateTime.Now - (DateTime)gs.InHouseDate; dr["在库时间(小时)"] = ts.TotalHours.ToString("0.00"); //CellCoordModel cell = new CellCoordModel() // asrsResMana.GetStockDetail(houseName,) //gs.GSPos } //显示 BindingSource bs = new BindingSource(); bs.DataSource = dt; bindingNavigator1.BindingSource = bs; dataGridView1.DataSource = bs; dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView1.Columns["入库时间"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; this.dataGridView1.Sort(this.dataGridView1.Columns["入库时间"], ListSortDirection.Ascending); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { this.picWaitting.Visible = false; } } }