Exemplo n.º 1
0
        /// <summary>
        /// 手动取消任务
        /// 删除控制任务、管理任务
        /// 删除控制任务接口
        /// 更新货位状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelTaskEventHandler(object sender, ControlTaskEventArgs e)
        {
            int taskStatus = this.View.AskMessBox("您确定要手动删除选中任务么?");

            try
            {
                if (taskStatus == 0)
                {
                    if (e.ControlTaskIDArr.Count() > 0)//只有任务没有完成的时候才可以取消
                    {
                        for (int i = 0; i < e.ControlTaskIDArr.Count(); i++)
                        {
                            Hashtable deleteManaHs         = null;
                            Hashtable deleteControlInterHs = null;
                            Hashtable deleteStockHs        = null;
                            Hashtable updateGsHs           = null;

                            ControlTaskModel controlTaskModel = bllControlTask.GetModel(e.ControlTaskIDArr[i]);
                            if (controlTaskModel == null)
                            {
                                continue;
                            }
                            if (controlTaskModel.TaskStatus == EnumTaskStatus.执行中.ToString())
                            {
                                this.View.ShowMessage("信息提示", "任务在执行中不允许删除!!");
                                continue;
                            }
                            if (controlTaskModel.TaskStatus == EnumTaskStatus.错误.ToString() || controlTaskModel.TaskStatus == EnumTaskStatus.超时.ToString())
                            {
                                //要调用控制层的接口,处理控制层;
                                MainPresenter.wcs.ClearTask(controlTaskModel);
                            }
                            ManageTaskModel manaTaskModel = bllManaTask.GetModel(controlTaskModel.TaskID);
                            if (manaTaskModel == null)
                            {
                                continue;
                            }

                            StockListModel stockListModel = null;
                            StockModel     stockModel     = null;
                            GoodsSiteModel gsModel        = null;
                            if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯入库_A1 ||
                                controlTaskModel.TaskTypeCode == (int)EnumTaskName.分容入库_A1 ||
                                controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯入库_B1 ||
                                controlTaskModel.TaskTypeCode == (int)EnumTaskName.空料框入库)    //任务完成后需要更新货位状态
                            {
                                stockListModel = bllStockList.GetModelByManaTaskID(controlTaskModel.TaskID);
                                stockModel     = bllStock.GetModel(stockListModel.StockID);
                                if (stockListModel != null && stockModel != null)
                                {
                                    deleteStockHs = bllStock.GetDeleteModelHash(stockModel.StockID);//入库任务取消要删除库存
                                    updateGsHs    = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.空货位.ToString(), EnumGSRunStatus.待用.ToString()
                                                                                  , EnumTaskCategory.出入库.ToString(), stockModel.GoodsSiteID);
                                }
                            }
                            else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.分容出库_A1 ||
                                     controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯出库_A1) //出库删除任务不删除库存
                            {
                                gsModel    = bllGoodsSite.GetGoodsSite(EnumStoreHouse.A1库房, controlTaskModel.StartDevice);
                                stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID);
                                if (stockModel != null)
                                {
                                    updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.货.ToString(), EnumGSRunStatus.任务完成.ToString()
                                                                               , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID);
                                }
                            }
                            else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.电芯出库_B1)
                            {
                                gsModel    = bllGoodsSite.GetGoodsSite(EnumStoreHouse.B1库房, controlTaskModel.StartDevice);
                                stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID);
                                if (stockModel != null)
                                {
                                    updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.货.ToString(), EnumGSRunStatus.任务完成.ToString()
                                                                               , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID);
                                }
                            }
                            else if (controlTaskModel.TaskTypeCode == (int)EnumTaskName.空料框出库)
                            {
                                gsModel    = bllGoodsSite.GetGoodsSite(EnumStoreHouse.B1库房, controlTaskModel.StartDevice);
                                stockModel = bllStock.GetModelByGsID(gsModel.GoodsSiteID);
                                if (stockModel != null)
                                {
                                    updateGsHs = bllGoodsSite.GetUpdateModelHs(EnumGSStoreStatus.空料框.ToString(), EnumGSRunStatus.任务完成.ToString()
                                                                               , EnumTaskCategory.入库.ToString(), stockModel.GoodsSiteID);
                                }
                            }

                            deleteManaHs         = bllManaTask.GetDeleteModelHash(manaTaskModel.TaskID);
                            deleteControlInterHs = bllControlInterface.GetDeleteHash(controlTaskModel.ControlCode);

                            List <Hashtable> hashList = new List <Hashtable>();
                            hashList.Add(deleteManaHs);
                            hashList.Add(deleteControlInterHs);
                            hashList.Add(deleteStockHs);
                            hashList.Add(updateGsHs);
                            bool executeTran = ExecuteManyHashSqls(hashList);
                            if (executeTran == true)
                            {
                                if (mainPres != null)
                                {
                                    mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",ID:" + controlTaskModel.ControlTaskID
                                                         + "任务开始位置:" + controlTaskModel.StartDevice + "任务结束位置:" + controlTaskModel.TargetDevice
                                                         + ",“" + manaTaskModel.TaskTypeName + "”任务手动删除成功!");
                                }
                            }
                            else
                            {
                                if (mainPres != null)
                                {
                                    mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr + ",ID:" + controlTaskModel.ControlTaskID
                                                         + "任务开始位置:" + controlTaskModel.StartDevice + "任务结束位置:" + controlTaskModel.TargetDevice
                                                         + ",“" + manaTaskModel.TaskTypeName + "”任务手动删除失败!");
                                }
                            }
                        }
                    }


                    DataTable dtCtrlTaskList = bllControlTask.GetCtrlDatatable(this.currentEnumTaskName, this.currentEnumTaskStatus
                                                                               , this.currentHouseName, this.currentCreateMode, this.currentTaskType);
                    this.View.ShowControlTaskData(dtCtrlTaskList);
                }
            }
            catch (Exception ex)
            {
                mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.错误, ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        private void CompleteByHandHandler(object sender, ControlTaskEventArgs e)
        {
            int       taskStatus       = this.View.AskMessBox("您确定要手动完成选定任务么?");
            Hashtable updateGsStatusHs = null;

            if (taskStatus == 0)
            {
                for (int i = 0; i < e.ControlTaskIDArr.Count(); i++)
                {
                    ControlTaskModel controlTask = bllControlTask.GetModel(e.ControlTaskIDArr[i]);
                    if (controlTask != null)
                    {
                        //bool gsIsValid = false;
                        //if (controlTask.TaskTypeName == EnumTaskName.电芯入库_A1.ToString()
                        //    || controlTask.TaskTypeName == EnumTaskName.分容入库_A1.ToString()
                        //    || controlTask.TaskTypeName == EnumTaskName.电芯入库_B1.ToString())//A1库房
                        //{
                        //    GoodsSiteModel gsModel = bllGoodsSite.GetGoodsSite(2, EnumGSStoreStatus.空货位, EnumGSRunStatus.待用, EnumGSType.货位);
                        //    if (gsModel != null)
                        //    {
                        //        gsIsValid = true;
                        //    }
                        //}
                        //else if (   controlTask.TaskTypeName == EnumTaskName.空料框入库.ToString())//b1库房
                        //{
                        //    GoodsSiteModel gsModel = bllGoodsSite.GetGoodsSite(2, EnumGSStoreStatus.空货位, EnumGSRunStatus.待用, EnumGSType.货位);
                        //    if (gsModel != null)
                        //    {
                        //        gsIsValid = true;
                        //    }
                        //}

                        //else if (controlTask.TaskTypeName == EnumTaskName.分容出库_A1.ToString()
                        //    ||controlTask.TaskTypeName == EnumTaskName.电芯出库_B1.ToString()
                        //    || controlTask.TaskTypeName == EnumTaskName.电芯出库_A1.ToString())
                        //{
                        //    GoodsSiteModel gsModel = bllGoodsSite.GetGoodsSite(2, EnumGSStoreStatus.有货, EnumGSRunStatus.任务完成, EnumGSType.货位);
                        //    if (gsModel != null)
                        //    {
                        //        gsIsValid = true;
                        //    }
                        //}
                        //else if (controlTask.TaskTypeName == EnumTaskName.空料框出库.ToString())
                        //{
                        //    GoodsSiteModel gsModel = bllGoodsSite.GetGoodsSite(2, EnumGSStoreStatus.空料框, EnumGSRunStatus.任务完成, EnumGSType.货位);
                        //    if (gsModel != null)
                        //    {
                        //        gsIsValid = true;
                        //    }
                        //}
                        controlTask.TaskStatus = EnumTaskStatus.已完成.ToString();

                        //if (gsIsValid == true)
                        //{
                        bool completeTask = bllControlTask.Update(controlTask);
                        if (completeTask == true)
                        {
                            if (mainPres != null)
                            {
                                mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr
                                                     + ",任务开始位置:" + controlTask.StartDevice + "任务结束位置:" + controlTask.TargetDevice + "任务名称:“" + controlTask.TaskTypeName + "”任务手动完成成功!");
                            }
                        }
                        else
                        {
                            if (mainPres != null)
                            {
                                mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "用户:" + this.userNameStr
                                                     + ",任务开始位置:" + controlTask.StartDevice + "任务结束位置:" + controlTask.TargetDevice + "任务名称:“" + controlTask.TaskTypeName + "”手动任务失败!");
                            }
                        }
                        //}
                        //else
                        //{
                        //    if (mainPres != null)
                        //    {
                        //        mainPres.View.AddLog(ECAMSModel.EnumLogCategory.管理层日志, EnumLogType.提示, "<<" + controlTask.TaskTypeName + ">>手动完成任务条件不符,手动任务失败!");
                        //    }
                        //}
                    }
                }
            }
        }