コード例 #1
0
        /// <summary>
        /// 下发堆垛机库外取放货任务  相对于站台来说的
        /// </summary>
        /// <param name="stocker"></param>
        /// <param name="plc"></param>
        /// <param name="task"></param>
        /// <param name="taskEntityStatus"></param>
        /// <param name="forkTaskFlag"></param>
        /// <param name="station"></param>
        /// <returns></returns>
        protected BllResult SendTaskToStation(Equipment stocker, IPLC plc, TaskEntity task, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, Equipment station, int tempStatus)
        {
            task.TaskStatus = taskEntityStatus.GetIndexInt();
            //task.ArrivaEquipmentCode = stocker.Code;
            var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task);

            if (tempResult.Success)
            {
                BllResult sendResult = SendTaskToStocker(stocker, plc, SRMForkAction.货叉1号, forkTaskFlag, "0", "0", "0", station.StationIndex.ToString(), task.Id.ToString());

                if (sendResult.Success)
                {
                    Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,接货站台为:{station.Name}", LogLevel.Success);
                    return(BllResultFactory.Sucess());
                }
                else
                {
                    Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error);
                    //回滚任务状态,记录日志
                    task.TaskStatus = tempStatus;
                    //task.ArriveEquipmentCode = tempGateway;
                    AppSession.Dal.UpdateCommonModel <TaskEntity>(task);
                    return(BllResultFactory.Error());
                }
            }
            else
            {
                Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error);
                return(BllResultFactory.Error($"下发堆垛机{stocker.Name}库外放货时,更新任务{task.Id}状态失败:{tempResult.Msg}"));
            }
        }
コード例 #2
0
        /// <summary>
        /// 下发库内取货与放货任务 相对于库位来说
        /// </summary>
        /// <param name="srm"></param>
        /// <param name="plc"></param>
        /// <param name="task"></param>
        /// <param name="tempFirstStatus"></param>
        /// <param name="tempStatus"></param>
        /// <param name="tempGateway"></param>
        /// <param name="tempLocation"></param>
        /// <returns></returns>
        protected BllResult SendTaskToLocation(Equipment srm, IPLC plc, TaskEntity task, Location tempLocation, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, int tempStatus)
        {
            task.TaskStatus = taskEntityStatus.GetIndexInt();
            var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task);

            if (tempResult.Success)
            {
                // short rowIndex = srm.Code == tempLocation.SrmCode ? tempLocation.RowIndex1.Value : tempLocation.RowIndex2.Value;
                short     rowIndex   = 0;
                BllResult sendResult = SendTaskToSRM(srm, plc, SRMForkAction.货叉1号, forkTaskFlag, rowIndex.ToString(), tempLocation.Line.ToString(), tempLocation.Layer.ToString(), "0", task.Id.ToString());
                if (sendResult.Success)
                {
                    Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,目标库位:{tempLocation.Code}", LogLevel.Success);
                    return(BllResultFactory.Sucess());
                }
                else
                {
                    Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error);
                    //回滚任务状态,记录日志
                    task.TaskStatus = tempStatus;
                    AppSession.Dal.UpdateCommonModel <TaskEntity>(task);
                    return(BllResultFactory.Error());
                }
            }
            else
            {
                Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error);
                return(BllResultFactory.Error($"下发堆垛机{srm.Name}{forkTaskFlag},更新任务{task.Id}状态失败:{tempResult.Msg}"));
            }
        }