刘磊
4 天以前 5eeed44ad21748ed7560a8c688d4e2d2f03555c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Newtonsoft.Json;
using OfficeOpenXml.ConditionalFormatting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm.AGVTask;
using WIDESEA_Common.AGVTask;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Model.Models;
using WIDESEA_StorageTaskRepository;
 
namespace WIDESEA_StoragIntegrationServices
{
    public partial class ToAGVService
    {
        /// <summary>
        /// AGV回调接口
        /// </summary>
        /// <param name="taskRespon"></param>
        /// <returns></returns>
        public WebResponseContent confirmToContinueTask(object taskRespon)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var taskResult = JsonConvert.DeserializeObject<AgvtaskResult>(taskRespon.ToString());
                if (taskResult == null)
                {
                    throw new Exception("AGV调用接口失败:无请求参数");
                }
 
                LogFactory.GetLog("AGV继续任务参数").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("AGV继续任务参数").Info(true, taskRespon.ToString());
 
                var task = _taskRepository.QueryFirst(x => x.AGVtaskId == taskResult.task_id);
                if (task == null) throw new Exception($"未知任务:{taskResult.task_id}");
 
                if (taskResult.result.ToLower() == "task_execute")   //AGV开始执行
                {
                    task.TaskState = (int)TaskStatusEnum.Executing;
                    _taskRepository.Update(task);
                }
 
                if (taskResult.result.ToLower() == "task_complete") //AGV任务结束 
                {
                    task.TaskState = (int)TaskStatusEnum.Completed;
 
                    WebResponseContent responseContent = _taskService.CompleteAsync((int)task.TaskNum).Result;
                    if (!responseContent.Status)
                    {
                        throw new Exception(responseContent.Message);
                    }
                    //_taskRepository.Update(task);
                }
                return content.OK();
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("AGV继续任务异常").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("AGV继续任务异常").Info(true, ex.Message);
                return content.Error($"AGV继续任务异常:{ex.Message}");
            }
        }
    }
}