Beispiel #1
0
 private void GenerateAsrsCheckoutTask()
 {
     try
     {
         BindingSource bs = this.dataGridView1.DataSource as BindingSource;
         DataTable     dt = bs.DataSource as DataTable;
         if (dt == null)
         {
             return;
         }
         int pri = int.Parse(this.textBoxPrivilege.Text);
         foreach (DataRow dr in dt.Rows)
         {
             string houseName = dr["库房"].ToString();
             string strCell   = dr["库位"].ToString();
             AsrsControl.AsrsCtlModel asrsCtl = AsrsPresenter.GetAsrsCtlByName(houseName);
             AsrsModel.CellCoordModel cell    = new CellCoordModel(0, 0, 0);
             if (!cell.Parse(strCell))
             {
                 continue;
             }
             EnumCellStatus   cellStoreStat = EnumCellStatus.空闲;
             EnumGSTaskStatus cellTaskStat  = EnumGSTaskStatus.完成;
             if (!asrsResMana.GetCellStatus(houseName, cell, ref cellStoreStat, ref cellTaskStat))
             {
                 Console.WriteLine("获取货位{0}:{1}状态失败", houseName, strCell);
                 continue;
             }
             if (cellStoreStat != EnumCellStatus.满位 || cellTaskStat == EnumGSTaskStatus.锁定)
             {
                 continue;
             }
             CtlDBAccess.Model.ControlTaskModel asrsTask = null;
             if (!asrsCtl.GenerateOutputTask(cell, null, SysCfg.EnumAsrsTaskType.产品出库, false, ref asrsTask, null, pri))
             {
                 logRecorder.AddDebugLog(this.Text, string.Format("生成{0}:{1}出库任务失败", houseName, strCell));
             }
             else
             {
                 logRecorder.AddDebugLog(this.Text, string.Format("生成{0}:{1}产品出库任务成功", houseName, strCell));
             }
             dr["出库任务ID"] = asrsTask.TaskID;
         }
         this.dataGridView1.Refresh();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Beispiel #2
0
        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;
                }
            }
        }