1
yangpeixing
2025-12-04 885092869d8a27a0b77d6e55d3dd3f00f29e8002
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_Tasks.ElevatorJob;
 
namespace WIDESEAWCS_WCSServer.Controllers.Task
{
    [Route("api/Task")]
    [ApiController]
    public class TaskController : ApiBaseController<ITaskService, Dt_Task>
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor) : base(service)
        {
            _httpContextAccessor = httpContextAccessor;
        }
 
        [HttpPost, Route("ReceiveTask"), AllowAnonymous]
        public WebResponseContent ReceiveWMSTask([FromBody] List<WMSTaskDTO> taskDTOs)
        {
            return Service.ReceiveWMSTask(taskDTOs);
        }
 
        [HttpPost, HttpGet, Route("UpdateTaskExceptionMessage")]
        public WebResponseContent UpdateTaskExceptionMessage(int taskNum, string message)
        {
            return Service.UpdateTaskExceptionMessage(taskNum, message);
        }
 
        [HttpPost, HttpGet, Route("UpdateTaskStatusToNext") ,AllowAnonymous]
        public WebResponseContent UpdateTaskStatusToNext(int taskNum)
        {
            return Service.UpdateTaskStatusToNext(taskNum);
        }
 
        [HttpPost, HttpGet, Route("TaskStatusRecovery")]
        public WebResponseContent TaskStatusRecovery(int taskNum)
        {
            return Service.TaskStatusRecovery(taskNum);
        }
 
        [HttpPost, HttpGet, Route("RollbackTaskStatusToLast")]
        public WebResponseContent RollbackTaskStatusToLast(int taskNum)
        {
            return Service.RollbackTaskStatusToLast(taskNum);
        }
 
        [HttpPost, HttpGet, Route("SendAgvTask"),AllowAnonymous]
        public WebResponseContent SendAgvTask(string modelProcessCode, int taskNum)
        {
            return Service.SendAgvTask(modelProcessCode, taskNum);
        }
 
        [HttpPost, HttpGet, Route("elevator"), AllowAnonymous]
        public WebResponseContent initialzationElevator()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                CommonElevator? commonElevator = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ1") as CommonElevator;
                if(commonElevator != null)
                {
                    commonElevator.SetValue<ElevatorDBName, short>(ElevatorDBName.StopElevator, 1);
                    Thread.Sleep(1000);
                    commonElevator.SetValue<ElevatorDBName, short>(ElevatorDBName.StopElevator, 0);
                    return content.OK("提升机初始化成功");
                }
                return content.Error("失败");
            }
            catch(Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
    }
}