1
z8018
2025-06-10 e46aa927d231af83724683c7286d9db503e24cf7
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
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_DTO.BasicInfo;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_WCSServer.Controllers.Task
{
    [Route("api/Task")]
    [ApiController]
    public class TaskController : ApiBaseController<ITaskService, Dt_Task>
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IOrderDetailsService _orderDetailsService;
        private readonly ITaskRepository _taskRepository;
 
        public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor, IOrderDetailsService orderDetailsService, ITaskRepository taskRepository) : base(service)
        {
            _httpContextAccessor = httpContextAccessor;
            _orderDetailsService = orderDetailsService;
            _taskRepository = taskRepository;
        }
 
        [HttpPost, HttpGet, Route("CreateTask"), AllowAnonymous]
        public WebResponseContent CreateTask(string takePosition, string putPosition, string deviceCode, int length, int width, int height)
        {
            return Service.CreateTask(takePosition, putPosition, deviceCode, length, width, height);
        }
 
        [HttpPost, HttpGet, Route("PlaceBlockTest"), AllowAnonymous]
        public WebResponseContent PlaceBlockTest(int orderRowId)
        {
            return Service.PlaceBlockTest(orderRowId);
        }
 
        [HttpPost, HttpGet, Route("GenerateTask"), AllowAnonymous]
        public Dt_Task GenerateTask(string barcode)
        {
            OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(barcode);
 
            var (flag, task, message) = Service.GenerateTask(orderInfo);
            if (flag && task != null)
                return task;
            else
                return new Dt_Task();
        }
 
        [HttpPost, HttpGet, Route("TaskComplete"), AllowAnonymous]
        public WebResponseContent TaskComplete(int taskNum)
        {
            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
            if (task == null)
            {
                return WebResponseContent.Instance.Error($"未找到对应任务信息");
            }
            return Service.TaskComplete(task);
        }
    }
}