Пример #1
0
        /// <summary>
        /// 处理呼叫盒呼叫
        /// </summary>
        /// <param name="CallBoxID">呼叫盒ID</param>
        /// <param name="BtnID">按钮ID</param>
        /// <returns></returns>
        private bool HandleCallBoxCall(CallBoxInfo CallBox, CallBoxDetail CurrBoxDetail, int BtnID)
        {
            try
            {
                #region 处理呼叫逻辑
                //加载是否启用储位状态
                string IsUserStoreState = CoreData.SysParameter["IsUserStoreState"].ToString();
                if (string.IsNullOrEmpty(IsUserStoreState))
                {
                    IsUserStoreState = "否";
                }
                int CallBoxID = CallBox.CallBoxID;
                IList <TaskConfigDetail> TaskConfigDetails = AGVClientDAccess.load_TaskDetail(CurrBoxDetail.TaskConditonCode);
                if (TaskConfigDetails == null && (TaskConfigDetails != null && TaskConfigDetails.Count <= 0))
                {
                    LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "任务信息");
                    return(false);
                }

                //开始根据任务配置信息创建任务
                StorageInfo CallStore = CoreData.StorageList.FirstOrDefault(q => q.ID == CurrBoxDetail.LocationID);
                if (CallStore == null)
                {
                    LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "对应的监控储位");
                    return(false);
                }
                //验证当前按钮盒下是否存在未完成的任务
                if (AGVSimulationDAccess.ChekAllowCreatTask(CallBoxID, CallStore.LankMarkCode, BtnID) > 0)
                {
                    LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫存在未完成任务,请稍后再试!");
                    return(false);
                }

                //组装任务信息
                string           dispatchNo = Guid.NewGuid().ToString();
                DispatchTaskInfo TaskInfo   = new DispatchTaskInfo();
                TaskInfo.dispatchNo = dispatchNo;
                TaskInfo.TaskState  = 0;
                TaskInfo.CallLand   = CallStore.LankMarkCode;
                TaskInfo.stationNo  = CallBoxID;
                TaskInfo.CallID     = BtnID;
                TaskInfo.taskType   = 0;

                //创建任务明细
                int DetailID   = 1;
                int PrePutType = -1;
                foreach (TaskConfigDetail item in TaskConfigDetails)
                {
                    //通过任务任务配置明细寻找目标地标
                    StorageInfo ArmStore = null;
                    LogHelper.WriteCallBoxLog("呼叫储位为:" + item.ArmOwnArea.ToString());
                    if (item.ArmOwnArea == -1)
                    {
                        ArmStore = CallStore;
                        LogHelper.WriteCallBoxLog("呼叫储位地标为:" + CallStore.LankMarkCode);
                    }
                    else
                    {
                        if (IsUserStoreState == "否")
                        {
                            ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType);
                        }
                        else
                        {
                            ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType && p.LockState == 0);
                        }
                    }
                    if (ArmStore == null)
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫,目的储位不存在[原因:不存在或被占用]");
                        return(false);
                    }

                    //再通过配置任务号来处理必经地标
                    IList <TaskConfigMustPass> ConfigMustPasses = AGVServerDAccess.LoadTaskMustPass(item.TaskConditonCode, item.DetailID);
                    if (ConfigMustPasses != null && ConfigMustPasses.Count > 0)
                    {
                        ////如果配置的必经地标则需要产生任务经过必经地标
                        foreach (TaskConfigMustPass MustPassItem in ConfigMustPasses)
                        {
                            foreach (IOActionInfo Action in MustPassItem.MustPassIOAction)
                            {
                                IOActionInfo CurrIOActionInfo = AGVServerDAccess.LoadAllIOAction(Action.ActionID);
                                if (CurrIOActionInfo == null)
                                {
                                    LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫,必经地标中的IO动作" + Action.ActionID.ToString() + "档案信息不存在");
                                    continue;
                                }
                                DispatchTaskDetail newTaskDetail = new DispatchTaskDetail();
                                newTaskDetail.dispatchNo         = dispatchNo;
                                newTaskDetail.DetailID           = DetailID;
                                newTaskDetail.LandCode           = MustPassItem.MustPassLandCode;
                                newTaskDetail.IsAllowExcute      = Action.IsPass;
                                newTaskDetail.IsSensorStop       = 0;
                                newTaskDetail.OperType           = -1;
                                newTaskDetail.IsWait             = Action.IsWait;
                                newTaskDetail.WaitTime           = Action.WaitTime;
                                newTaskDetail.TaskConditonCode   = MustPassItem.TaskConditonCode;
                                newTaskDetail.TaskConfigDetailID = item.DetailID;
                                TaskInfo.TaskDetail.Add(newTaskDetail);
                            }
                        }



                        //foreach (TaskConfigMustPass MustPassItem in ConfigMustPasses)
                        //{
                        //    //根据配置的IO动作ID加载对应的IO动作明细信息
                        //    IOActionInfo CurrIOActionInfo = AGVServerDAccess.LoadAllIOAction(MustPassItem.Action);
                        //    if (CurrIOActionInfo == null)
                        //    {
                        //        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫,必经地标中的IO动作" + MustPassItem.Action.ToString() + "档案信息不存在");
                        //        continue;
                        //    }
                        //    //找到必经地标中的IO动作后组装任务体
                        //    DispatchTaskDetail dispathDetail_MustPas = new DispatchTaskDetail();
                        //    dispathDetail_MustPas.dispatchNo = dispatchNo;
                        //    dispathDetail_MustPas.DetailID = DetailID;
                        //    dispathDetail_MustPas.LandCode = MustPassItem.MustPassLandCode;
                        //    dispathDetail_MustPas.OperType = -1;
                        //    dispathDetail_MustPas.IsAllowExcute = CurrIOActionInfo.IsWait;
                        //    dispathDetail_MustPas.PutType = -1;
                        //    dispathDetail_MustPas.IOActionID = CurrIOActionInfo.ActionID;
                        //    TaskInfo.TaskDetail.Add(dispathDetail_MustPas);
                        //    DetailID += 1;
                        //}//结束循环处理必经地标配置
                    }

                    //如果没有必经地标或者添加完必经地标后需要继续添加后续的任务配置明细
                    DispatchTaskDetail dispathDetail_TaskConfig = new DispatchTaskDetail();
                    dispathDetail_TaskConfig.dispatchNo    = dispatchNo;
                    dispathDetail_TaskConfig.DetailID      = DetailID;
                    dispathDetail_TaskConfig.LandCode      = ArmStore.LankMarkCode;
                    dispathDetail_TaskConfig.OperType      = item.Action;
                    dispathDetail_TaskConfig.IsAllowExcute = item.IsWaitPass;
                    dispathDetail_TaskConfig.PassType      = item.PassType;
                    if (PrePutType == -1)
                    {
                        dispathDetail_TaskConfig.PutType = ArmStore.StorageState;
                    }
                    else
                    {
                        dispathDetail_TaskConfig.PutType = PrePutType;
                    }
                    dispathDetail_TaskConfig.IsSensorStop = item.IsSensorStop;
                    TaskInfo.TaskDetail.Add(dispathDetail_TaskConfig);
                    PrePutType = ArmStore.StorageState;
                    DetailID  += 1;
                }//结束循环处理任务配置

                //循环组装完任务信息后保存到数据库
                if (TaskInfo != null && TaskInfo.TaskDetail.Count > 0)
                {
                    AGVServerDAccess.CreatTaskInfo(TaskInfo, IsUserStoreState == "是" ? true : false);
                }
                return(true);

                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteCallBoxLog("处理呼叫器呼叫异常:" + ex.Message);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 处理呼叫器呼叫任务
        /// </summary>
        /// <param name="CallBox"></param>
        /// <param name="CurrBoxDetail"></param>
        /// <param name="BtnID"></param>
        /// <returns></returns>
        private bool HandleCallBoxCall(CallBoxInfo CallBox, CallBoxDetail CurrBoxDetail, int BtnID)
        {
            try
            {
                lock (lockstorage)
                {
                    #region 处理呼叫逻辑
                    //加载是否启用储位状态
                    string IsUserStoreState = CoreData.SysParameter["IsUserStoreState"].ToString();
                    if (string.IsNullOrEmpty(IsUserStoreState))
                    {
                        IsUserStoreState = "否";
                    }
                    int CallBoxID = CallBox.CallBoxID;
                    IList <TaskConfigDetail> TaskConfigDetails = AGVClientDAccess.load_TaskDetail(CurrBoxDetail.TaskConditonCode);
                    if (TaskConfigDetails == null && (TaskConfigDetails != null && TaskConfigDetails.Count <= 0))
                    {
                        LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "任务信息");
                        return(false);
                    }
                    DataTable dtstorage = CoreData.dbOperator.LoadDatas("QueryAllStore");
                    CoreData.StorageList = DataToObject.TableToEntity <StorageInfo>(dtstorage);
                    //开始根据任务配置信息创建任务
                    StorageInfo CallStore = CoreData.StorageList.FirstOrDefault(q => q.ID == CurrBoxDetail.LocationID);
                    if (CallStore == null)
                    {
                        LogHelper.WriteCallBoxLog("未配置按钮盒" + CallBox.CallBoxID.ToString() + "对应的监控储位");
                        return(false);
                    }
                    //验证当前按钮盒下是否存在未完成的任务
                    if (AGVSimulationDAccess.ChekAllowCreatTask(CallBoxID, CallStore.LankMarkCode, CurrBoxDetail.ButtonID) > 0)
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫存在未完成任务,请稍后再试!");
                        return(false);
                    }
                    //验证当前按钮盒下是否存在未完成的任务
                    if (AGVSimulationDAccess.ChekAllowCreatTask2(CallBoxID, CallStore.LankMarkCode, CurrBoxDetail.ButtonID) > 0)
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxID.ToString() + "对应呼叫存在未完成任务 未回写的任务,请稍后再试!");
                        return(false);
                    }
                    AreaInfo callarea = CoreData.AllAreaList.FirstOrDefault(p => p.OwnArea == CallStore.OwnArea);
                    if (callarea != null && callarea.MaxTaskCount > 0)
                    {
                        if (AGVSimulationDAccess.ChekAllowCreatTask3(callarea.OwnArea) >= callarea.MaxTaskCount)
                        {
                            LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxIP.ToString() + " 地址" + CurrBoxDetail.DBAddress + " 对应的区域任务数量达到最大,不产生任务");
                            return(false);
                        }
                    }
                    if (!string.IsNullOrEmpty(CallStore.StorageName))
                    {
                        LogHelper.WriteCallBoxLog("按钮盒" + CallBox.CallBoxIP.ToString() + " 地址" + CurrBoxDetail.DBAddress + "对应储位未启用");
                        return(false);
                    }

                    //组装任务信息
                    string           dispatchNo = Guid.NewGuid().ToString();
                    DispatchTaskInfo TaskInfo   = new DispatchTaskInfo();
                    TaskInfo.dispatchNo = dispatchNo;
                    TaskInfo.TaskState  = 0;
                    TaskInfo.CallLand   = CallStore.LankMarkCode;
                    TaskInfo.stationNo  = CallBoxID;
                    TaskInfo.CallID     = BtnID;
                    TaskInfo.taskType   = 0;
                    TaskInfo.OwerArea   = CallStore.OwnArea;
                    //创建任务明细
                    int DetailID   = 1;
                    int PrePutType = -1;
                    foreach (TaskConfigDetail item in TaskConfigDetails)
                    {
                        //通过任务任务配置明细寻找目标地标
                        StorageInfo ArmStore = null;
                        LogHelper.WriteCallBoxLog("呼叫储位为:" + item.ArmOwnArea.ToString());
                        if (item.ArmOwnArea == -1)
                        {
                            ArmStore = CallStore;
                            LogHelper.WriteCallBoxLog("呼叫储位地标为:" + CallStore.LankMarkCode);
                        }
                        else
                        {
                            if (IsUserStoreState == "否")
                            {
                                ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType);
                            }
                            else
                            {
                                ArmStore = CoreData.StorageList.FirstOrDefault(p => p.OwnArea == item.ArmOwnArea && p.StorageState == item.StorageState && p.MaterielType == item.MaterialType && p.LockState == 0);
                            }
                        }
                        if (ArmStore == null)
                        {
                            LogHelper.WriteCallBoxLog(string.Format("按钮盒{0}   地址:{1}   BtnID{2}   对应呼叫,目的储位不存在[原因:不存在或被占用]", CallBox.CallBoxID, CurrBoxDetail.DBAddress, CurrBoxDetail.ButtonID));
                            return(false);
                        }

                        #region  用
                        //再通过配置任务号来处理必经地标
                        IList <TaskConfigMustPass> ConfigMustPasses = AGVServerDAccess.LoadTaskMustPass(item.TaskConditonCode, item.DetailID);
                        if (ConfigMustPasses != null && ConfigMustPasses.Count > 0)
                        {
                            ////如果配置的必经地标则需要产生任务经过必经地标
                            foreach (TaskConfigMustPass MustPassItem in ConfigMustPasses)
                            {
                                foreach (IOActionInfo Action in MustPassItem.MustPassIOAction)
                                {
                                    IOActionInfo CurrIOActionInfo = AGVServerDAccess.LoadAllIOAction(Action.ActionID);
                                    if (CurrIOActionInfo == null)
                                    {
                                        LogHelper.WriteCallBoxLog("按钮器" + CallBox.CallBoxID.ToString() + "对应呼叫,必经地标中的IO动作" + Action.ActionID.ToString() + "档案信息不存在");
                                        continue;
                                    }
                                    DispatchTaskDetail newTaskDetail = new DispatchTaskDetail();
                                    newTaskDetail.dispatchNo         = dispatchNo;
                                    newTaskDetail.DetailID           = DetailID;
                                    newTaskDetail.LandCode           = MustPassItem.MustPassLandCode;
                                    newTaskDetail.IsAllowExcute      = Action.IsPass;
                                    newTaskDetail.IsSensorStop       = 0;
                                    newTaskDetail.OperType           = -1;
                                    newTaskDetail.IsWait             = Action.IsWait;
                                    newTaskDetail.WaitTime           = Action.WaitTime;
                                    newTaskDetail.TaskConditonCode   = MustPassItem.TaskConditonCode;
                                    newTaskDetail.TaskConfigDetailID = item.DetailID;
                                    TaskInfo.TaskDetail.Add(newTaskDetail);
                                }
                            }
                        }
                        #endregion


                        //如果没有必经地标或者添加完必经地标后需要继续添加后续的任务配置明细
                        DispatchTaskDetail dispathDetail_TaskConfig = new DispatchTaskDetail();
                        dispathDetail_TaskConfig.dispatchNo = dispatchNo;
                        dispathDetail_TaskConfig.DetailID   = DetailID;
                        dispathDetail_TaskConfig.LandCode   = ArmStore.LankMarkCode;
                        dispathDetail_TaskConfig.StorageID  = ArmStore.ID;
                        if (!string.IsNullOrEmpty(ArmStore.Remark))
                        {
                            TaskInfo.GoodsInfo = ArmStore.Remark;
                        }
                        dispathDetail_TaskConfig.OperType       = item.Action;
                        dispathDetail_TaskConfig.IsAllowExcute  = item.IsWaitPass;
                        dispathDetail_TaskConfig.PassType       = item.PassType;
                        dispathDetail_TaskConfig.IsNeedCallBack = item.IsNeedCallBack;
                        dispathDetail_TaskConfig.IsCallGoods    = item.IsCallGoods;

                        if (PrePutType == -1)
                        {
                            dispathDetail_TaskConfig.PutType = ArmStore.StorageState;
                        }
                        else
                        {
                            dispathDetail_TaskConfig.PutType = PrePutType;
                        }
                        dispathDetail_TaskConfig.IsSensorStop = item.IsSensorStop;
                        TaskInfo.TaskDetail.Add(dispathDetail_TaskConfig);
                        PrePutType = ArmStore.StorageState;
                        DetailID  += 1;
                    }//结束循环处理任务配置

                    //循环组装完任务信息后保存到数据库
                    if (TaskInfo != null && TaskInfo.TaskDetail.Count > 0)
                    {
                        AGVServerDAccess.CreatTaskInfo(TaskInfo, IsUserStoreState == "是" ? true : false);
                    }
                    return(true);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                DelegateState.InvokeDispatchStateEvent(ex.Message);
                return(false);
            }
        }